Dynamic Mesh Cutter - A flexible run time mesh cutting solution [Discussion Thread]

Please read through the manual first before asking questions.

Release Details

V1.2.6
-Improved scaling of colliders in ExampleScene.
-Added package uploads from older Unity versions.

V1.2.5
-Fixed a race condition that caused performance issues when Async Cutting was enabled.
-Added option for user to manually choose the amount of Threads used for Async Cutting.

V.1.2.4
-Updated documentation

V.1.2.3
-Option to prevent mesh creation when cut mesh has <N vertices
-“Tags” for stone cuts now carrying over

V.1.2.2
-Disabled MeshTargets.cs components will no longer be cut.
-Perfomance improvements
-Fixed a bug that prevented building

V1.2.1 Fixed a prefab bug where mesh wouldn’t render

V1.2
Fixed namespace issues and improved code readability.
Updated materials.

V1.1
Dynamic Ragdoll Update.

V1.0
Initial release.

Manual
Demonstration Video 1
Demonstration Video 2
Unity Asset Store Link

Why this thread?
Because of requests from my users, I created this discussion thread for anyone having questions, comments, advice or other feedback regarding Dynamic Mesh Cutter. I will always answer mails at philipbeaucamp.inquiries@gmail.com as well, but this thread will act as an alternative way of reaching out to me.

What is Dynamic Mesh Cutter?
Dynamic Mesh Cutter is a runtime algorithm that allows you to quickly cut meshes in a very performant way. More than that it can separate disjoint meshes and also cut ragdolls, allowing you to cut a human ragdoll and have its newly cut meshes behave like ragdolls as well. The latter requires quite a bit of setup that I’m happy to explain further if people have questions.

How does it work?
Whatever mesh (be it static or skinned) will be cut by an infinitely large plane. If this plane intersects any triangles of the mesh, the mesh counts as cut. The result will first be split into two parts, a positive and a negative side and can optionally further be separated into individual meshes if the vertices are disjoint. This however is a option the user can enable or disable. There are many settings to choose from, such as whether to have the algorithm run asynchronously (for better performance) and how the resulted mesh should be treated.

What is this tool NOT?
You can not cut a mesh a “certain distance” only or in any other form but via a plane. You can add cool vfx, animations, sounds or other callback related logic yourself (I exposed the right callbacks for this), in fact I encourage you to do this since it will greatly enhance the cutting experience, but keep in mind that this tool is a cutting algorithm only. It is not meant to do all the cool fancy stuff for you, it just cuts meshes.

What are some current limitations/issues?
This algorithm does not detect holes inside a mesh. It correctly cuts most shapes, such as human limbs and does exceptionally well for convex shapes, but it might not be the right tool for you if you plane on using vastly complex meshes.

3 Likes

Hey , I want to achieve an effect similar to the video the square mesh change to take the shape of the metal obstacle . (change from square to tree based on the collision) . is that possible with your framework ?blindimaginarydartfrog

Hi @y0u553ef . That’s not possible but most likely also not what you want to be doing. From the video it looks like the mesh is simply being replaced by another, tree shaped one. This solution is much more performent and easier to achieve. To clarify, Dynamic Mesh Cutter only cuts via a plane, but again you most likely want to simply replace your mesh if the shape is already predefined and known at editor time anyway. Hope this helps!

hi. so I’m interested in a couple of things. in the description it says it cuts ragdoll, but in the example scene it still falls like a stiff statue, not a ragdoll. it is not implemented in that scene?

limbhacker had a problem with nested hierarchies (I usually keep ragdoll object (switched off) under main character object), but tried this dynamic ragdoll script’s autocalculate and everything seems fine. so it should be no problem, right?

  • a bit more info on this: so the cutting should be done on the ragdoll object after it is switched on. is it possible somehow?

also, can something be done with worldwide mesh cutting, so cutting functions like a sword? something like filtering meshes based on distance (?) or collision, and perhaps maximizing joints to cut, if it’s a big world, many actors to save performance?

do I get this right:
this is the line that starts it all
Cut(target, transform.position, transform.forward, null, OnCreated);
so if the right target of a object is fed in and the right plane defined (?), it would do the trick?

hi @bobadi .

In order for the “ragdoll” cutting to work you have to change the DefaultBehaviour setting on the MeshTarget component and set it to “Ragdoll”.

Not sure I fully understand your question, but the ragdoll cut will work as long as the dynamic ragdoll component is set up properly in advance in the editor. The colliders should be detected even when the gameobjects are disabled in the hierarchy.

The algorithm currently cuts any active MeshTarget components that intersect with the plane (which is infinite). If you need to exclude/include certain objects or only want to cut objects in a certain range, you’ll have to implement that logic yourself (e.g. disable the MeshTarget component if the sword is not touching the enemy etc.).

That’s absolutely correct. This is the only line you need to call for the algorithm to start!

Hope this helps!

Hi! I’ve been using your tool and it’s awesome! I’ve one question for you: is there a way I can modify the cut behaviour so that I always cut the mesh parts that are on the upper side of the cut plane? (both mouse behaviour and plane behaviour cases). My goal is to have always a visible mesh on the ground (it’s a moving object) but if I do a horizontal cut side to side the upper mesh is the one remaining. I hope I made my question clear enough :slight_smile:

Hi @thePortalDude . I’m afraid I don’t exactly understand what you mean by “cutting the mesh parts on the upper side”.
Could you try and elaborate? Sorry!

@PBTools Let’s say I have a cube, if I draw a cut line horizontally in the middle of the cube what I would always want is that the cube is cut by half and the lower mesh is the only part that remains. This should be true for every cut I perform: I would want that every part of the mesh that is above the line is the cut part.

Currently the behaviour is the one I am showing in the screenshots I posted. As you can see the cut erased the lower half of the mesh, but what I would want is the opposite.

Sorry if this is still unclear, I’ll try again if necessary :stuck_out_tongue:

Thanks for your time!

8024933--1033838--Immagine 2022-04-06 125419.png 8024933--1033844--Immagine 2022-04-06 125420.png

What I am not fully understanding is what you mean by “remaining” and “erased”. The tool does not erase anything, it should just separate the green box into two different, smaller meshes.

Are you talking about manually deleting/disabling the mesh that ends up being on the upper side of the cut after both meshes have been created? You could achieve this by disabling the objects in the OnCut or OnCreated callbacks in the CutterBehaviour. (See the manual, point 2.3 and check out the Info class of those callbacks if you don’t know what I’m talking about).

Hello dear I have a question about your asset when I cut one human leg it will cut both legs can I change something with your code mousebehaviour or planebehaviour and thank you

Hi @marounkattar , unfortunately that’s not possible.

Hello.
Thanks for your reply in the review.
I am able to call the plane to the VR controller position.
Sorry for the rudimentary question.
How can I make this called plane execute the cut automatically?
Even if I could call a plane with PlaneBehaviour on it.
I don’t know how to execute the cut in game.

hi @beddggv ,
Once you have a plane all you need to do is call the “Cut” function on the CutterBehaviour script in your scene.
You will need at least one CutterBehaviour in your scene. Once you have a reference to it, simply call the public function called “Cut” and pass in the plane and the rest of the parameters. I hope this helps.

Hello.
Thanks for the advice, now I can execute the cuts!
I have an additional question.
If the cutter target is set to ragdoll or animation, the settings of the original object will be inherited.
However, in the case of stones, they cannot be taken over.
How can I reflect tags and components in the cut object even in the case of stones?

@beddggv That is a great catch! Currently only in the case of “stone” I am making a brand new gameobject. For the other cases I am duplicating the objects which is why things such as tags carry over.
I think its a good idea to be able to keep tags and perhaps components as well, give me some time to update the package!

If you need the fixes ASAP I would recommended adding the tags/component in the OnCreated callback manually. I know this is not pretty but hopefully I will find a better solution soon!

Thanks again for the feedback.

First, it is a very great asset !

I have question:
Is it possible to apply a texture that adapts to the size of the face ?
For some reason, the texture from the material face i want to apply is zoomed in when i cut from certains angles …

Since it’s impossible to know how the cut face will look in advance it’s hard to have textures “adapt” to the new face. I recommend using textures with basic, simple colors for the cut face.

Hi there!
I am looking at your asset in the store. I am wondering when I cut a mesh, can I, have the inside (new surface), have a different material?

I often see the mesh cutting games where the inside (new surface) is a rainbow, while the old, original surface is chocolate cake, for example.

Thanks!

@renman3000 Sorry for my late reply but yes, that is possible! You can apply a new material to the new surface that is being created by the cut, or you can also choose to simply have the same material be applied. Check out the documentation for more info.

Hi, I’m curious if this supports Puppetmaster at all, and if not if you have any guidance for getting this to work with puppetmaster.