-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Merge function #394
Add Merge function #394
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #394 +/- ##
==========================================
+ Coverage 85.90% 85.94% +0.03%
==========================================
Files 36 38 +2
Lines 4492 4574 +82
==========================================
+ Hits 3859 3931 +72
- Misses 633 643 +10
... and 3 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
This also involved moving |
@@ -580,6 +503,21 @@ void Dump(const std::vector<T>& vec) { | |||
} | |||
std::cout << std::endl; | |||
} | |||
|
|||
template <typename T> | |||
void Diff(const std::vector<T>& a, const std::vector<T>& b) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an extra debug helper to quickly see just which parts of two vectors are not identical.
src/collider/include/collider.h
Outdated
template <typename T> | ||
SparseIndices Collisions(const VecDH<T>& queriesIn) const; | ||
SparseIndices Collisions(const VecDH<T>& queriesIn, | ||
bool selfCollision = false) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the Collider so that we can collide a vector with itself and not spend a bunch of time reporting that every index collides with itself. This might come in handy down the road too.
#ifndef GSK_GRAPH_LITE_H | ||
#define GSK_GRAPH_LITE_H | ||
|
||
#include <algorithm> | ||
#include <cassert> | ||
#include <ciso646> // Added to fix MSVC error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's not actually much change here - I think it's just formatting. I added this line to make MSVC able to compile and
in addition to &&
. The only update I pulled in was to not emit warnings about duplicate edges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! According to cppreference
This means that in a conforming implementation, including this header has no effect.
Thought MSVC is a conforming implementation :P
@@ -242,20 +242,17 @@ struct CoplanarEdge { | |||
const int edgeIdx = thrust::get<2>(inOut); | |||
|
|||
const Halfedge edge = halfedge[edgeIdx]; | |||
if (!edge.IsForward()) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixed a bug I found - I was not deduplicating property verts correctly before.
* multi-material MeshGL was produced, but its merge vectors were lost due to a | ||
* round-trip through a file format. | ||
*/ | ||
bool MeshGL::Merge() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the result may not be a manifold, the users may want to use IsManifold
to check for manifoldness. Should we move the method out of the testing hooks group?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that reminds me, I've been meaning to get rid of that function. They can just use the Manifold
constructor to check if it's manifold.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add this to the documentation and then merge this?
bool MeshGL::Merge() { | ||
std::multiset<Edge> openEdges; | ||
|
||
std::vector<int> merge(NumVert()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that when mergeFromVert.size()
is much smaller than NumVert()
, it may be more beneficial to use a sparse hashmap. (just a nitpick)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it might save a bit of memory, but not compute. I figure if I'm not allocating more memory than I already have stored in the structure I'm operating on, then the savings probably isn't worth the trouble.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on the size and sparsity. For large data set, saving memory equals to better cache utilization which means better performance. But yeah this may not worth the trouble.
* start Merge * started Merge function * added collider * refactor now builds * connect vectors * finished Merge, updated Collider * added tests * added sorting, updated graph_lite * revert submodule change * fixed indexing * fixed prop dedupe bug * fixed test * update meshIO linking * fix MSVC * use assimp on Mac * add precision handling * improved tests * revert test tweak * update collider * clean up multiset * updated docs
Fixes #363
Fixes #398
This adds a
Merge
function toMeshGL
that will heuristically fill inmergeFromVert
andmergeToVert
vectors, the purpose of which is to create manifold meshes from GL-style meshes that appear manifold but are not due to unshared verts where materials, UVs, normals, etc. have a boundary.This will not attempt to fix meshes that are more broken - I'll leave that to external auto-manifold tools for now, since that is more complicated and arbitrary.