Softbody physics w/ any mesh

Softbody physics without using the built-in physics engine. It works on any mesh and is fairly robust (length and volume constraints). Here it is working on some random meshes from the toolbox:



The softbodies are simulated using particles and constraints (which preserve lengths and volumes with some lenience). A previous softbody simulation I made only preserved lengths which made it less robust (no volume constraints meant it could collapse into a flat object and wouldn’t be able to recover). It also didn’t support arbitrary meshes.

6 Likes

I’m not able to play the videos :frowning:

1 Like


Do these work? Its the same video but the first is a direct upload and the second is an imgur.com link.

1 Like

I’m not smart enough to understand all of this, but I’m guessing we would need to simulate a plane for each face? Or would that not work or is just inefficient.

2 Likes

I’m not sure what the optimal solution here would be, but testing the surface would be a lot more accurate than testing the vertices. I don’t think it would be too inefficient, since here the bottleneck for performance is drawing the object, the actual physics has a negligible performance impact.

1 Like

The first video works, but not the second, thank you!

1 Like

I really liked this post, so I’m trying to help slowly solve the collision issue. Currently, I only have code to find the bounding box of your vertices Lol.

local function verticesBoundingBox(vertices)
	local minX, minY, minZ = math.huge, math.huge, math.huge
	local maxX, maxY, maxZ = -math.huge, -math.huge, -math.huge

	for _, vertex in ipairs(vertices) do
		local x, y, z = vertex.X, vertex.Y, vertex.Z

		if x < minX then minX = x end
		if y < minY then minY = y end
		if z < minZ then minZ = z end

		if x > maxX then maxX = x end
		if y > maxY then maxY = y end
		if z > maxZ then maxZ = z end
	end

	return Vector3.new(minX, minY, minZ), Vector3.new(maxX, maxY, maxZ)
end

My idea was to see if the bounding box interacts with a part, run some code that I haven’t thought of yet. Will be doing this later.

what if you just find the face using edge and vertex stuff and do collision on it