Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Obi SoftBody with unity Mesh Collider and Mesh Filter
#4
(20-01-2023, 12:29 PM)ilyas_Gefeasoft Wrote: Thank you for you reply. Tímido

I am trying to remove or delete the part of a softbody when it is contacted by another game object using raycast. For example, if the game object is touching the surface of softbody, that part which is contacted gets removed, such as the cauterization method in tissue operation. 
I have implemented my algorithm on rigidbodies and it gives the result I was looking for but with softbodies, i am unable to get the same result perhaps, I have been treating softbodies same a as rigidbodies.  Huh

Rigidbodies and softbodies have very little in common, and what you are trying to do is *a lot*more complex to do in the case of a softbody than it is for a rigidbody.

A rigidbody -as the name implies- is "rigid". This means its mesh cannot deform at all due to collisions or external forces. As a consequence of this, its center of mass is fixed in its local frame of reference. As the rigidbody moves, you can basically transform all vertices in the mesh by the object's transform and you're done. MeshColliders take advantage of the fact that the mesh doesn't deform to implement collision detection efficiently:mesh data is preprocessed and stored in a spatial partitioning data structure (BVH, BIH, Kd-tree, etc), that stays the same throughout the lifetime of the rigidbody.

Removing a triangle from a rigidbody is as simple as taking out the triangle from the mesh, and telling its MeshCollider to update its internal data structure.

A softbody however, is "soft". Its mesh will deform, so you cannot easily define a single frame of reference for it, and you cannot use MeshColiders since that would require to update its internal stricture every frame which is terribly slow. So for physical simulation, multiple particles (each with their own position, mass, inertia tensor, etc) are used, and their positions re-used for collision detection, instead of using the mesh directly. Each individual vertex in the mesh is independently transformed (just like in an animated character) so SkinnedMeshRenderer must be used instead of a MeshRenderer.

Removing a triangle from a softbody requires taking it out from the mesh, updating its particle-based physical representation (the blueprint, in Obi's case) and also update the skinning information in the SkinnedMeshRenderer, used to transform the mesh's vertices as the softbody deforms.

I'd recommend reading up on particle position-based dynamics and linear blend skinning. There's a lot of new concepts you must understand before attempting to do what you want.

kind regards,
Reply


Messages In This Thread
RE: Obi SoftBody with unity Mesh Collider and Mesh Filter - by josemendez - 20-01-2023, 12:48 PM