-
Notifications
You must be signed in to change notification settings - Fork 9
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
Random plane cut #4
Comments
Yes - if you check how the resulting mesh cells are generated, the process
|
the code seems to cut the same mesh over and over again with different planes, but you're missing the part where the resulting mesh is pieced together after a cut -- that is, meshCut will return the cut triangles, but only flag those which are on the chosen side of the cutting plane (according to the supplied flag). |
I can't fully understand it can you point me to parts from the original code ? |
Yes, I had to read the code a bit more carefully to remember all of this: actually it all happens within the meshCut call and not as a separate process as I recalled it. The steps in meshCut.cpp are first the triangle splitting (meshCut.cpp, line 776), cleanup of resulting geometry to deal with degenerate cases, then we fill the hole left by the cut (so that the resulting volume remains closed), line 1026, and finally add the resulting triangles from the hole filling into the 'interior triangles' list (1048) -- This is not the best name, and should be clarified, the 'interior triangle list' contains those triangles which are inside of the original mesh after cutting it. Note this list is an input/output list which needs to be passed everywhere because further cuts may split interior triangles even more and we need to propagate their 'interiorness' to the resulting triangles. We finally purge the triangles according to the desired plane flag (1052) and finish up with some more geometry cleanup. The final mesh going back to maya is a straightforward copy from the resulting data, in DelaunayNode.cpp line 566. Some things to note which may help understanding the process: meshCut is designed to cut a closed mesh which describes a valid volume (for instance a torus or a cube, but not a bunch of cubes overlapping together like your picture seems to imply, because this will cause the hole filling heuristics to fail. This is probably what you're seeing). Also, the process of cutting a voronoi cell by splitting the mesh in two with successive planes works because the cell walls describe a convex volume, and thus the resulting piece is mostly convex (depends on the surface of the original mesh, but in most cases it will be). This may be easier to understand if you do some drawings, but what I want to stress is that the method can't be generallised to random planes describing a non-convex volume. |
Yes, that case is well defined and should work well -- I was getting confused by your previous screenshot. I can't spot anything immediately wrong from your code, so lets simplify things: can you cut the box with only one plane and attach a debugger to meshCut to gather more information of what's going on? (especially around the purgeTriangles function, you can even disable the hole filling for a single cut and simplify the code even further). Should be a simple enough case to track down. You can also copy some of the debug code on the original delaunayNode.cpp to dump the cuts and intermediate steps to debug visually. |
I see it is similar to the algorithms I found. Let say we do MESHCUT_DISCARD_NONE and cut by 4 planes at the same time is there a way to maybe to flag the pieces and loop over them so that I can get separate pieces ? Do we keep track of any adjacency at the moment ? |
Not sure I quite follow what you mean: there's no cutting by more than one plane at a time (precisely because cutting is a serial process where the next plane that comes along needs to process the output pieces from the previous cut). DISCARD_NONE means "keep the pieces from both sides of the plane", that is, don't discard anything. Lastly, yes, there's an adjacency cache which is used to keep track of edges/triangles/vertices, used in the method as described above, not sure if this is what you meant. |
Yeah I understand what it does I was trying to get optimal performance for multiplane cut but at the same time preserve my chunks so that I can use them with bullet. But I am trying now naive approaches which are slow. By DISCARD_NONE I meant: Will end up with box cut by many planes then is there a way to split those chunk again ? |
You'd generate a new input mesh (or simply reuse the arrays) for all of the resulting chunks, and feed these to the next plane. In the specific case of voronoi cells, we generate each cell from the original mesh and split those with every wall of a given cell. The next cell comes along and starts from the entire source mesh again (imagine an interior cell for instance, where nothing of the original mesh surface is left remaining, but just the results of the hole filling). If what you're after is more a kind of random splitting, maybe you can lay it out more efficiently by precomputing which meshes are guaranteed not to be touched by a cut plane before you feed these to the mesh cutting. |
Well If keep cutting the same arrays all over and over again with DISCARD_FRONT I will end up with one chunk. If I cut by 4 planes I would like to have all the 9 chunks but I keep getting confused on how to do that. |
Hello ,
Is it currently possible to do random plane cut using only the meshCut function and randomly generated planes ? Do I have to run recursively the meshCut function to get this effect ?
The text was updated successfully, but these errors were encountered: