SmartBone 2 - Simulated Physics and Collision solution for Bones

Another difference is I am connecting to the PreRender signal instead of RenderStepped in the ‘runtime’ script. That way the bones are positioned before the frame renders. The modified version I’m using still works and my curtains are no longer disappearing when the wind is active. I PMed you and the Creator a copy.

can i use smart bone for ragdoll skinnedmesh ?

1 Like

Isn’t there a plugin that does all the bone adding for you, or adding all the attributes?

You can find the plugins here​​​​​​​​​​​​​​​

SmartBone Editor seems to be private:
image

oh yeah my bad i forgot, visit this link: SmartBone Editor - Roblox

1 Like

Do any of you know how to stop the smartbone of one specific object? I’m trying to simulate a ship’s flag and I need it to stop being a smartbone when landed to stop it from expanding.

Hello, incredible module you made here! Honestly I am still flabbergasted with these kind of things, however I am having an issue that I have no idea what is causing it, the screenshot can explain by itself.


(Yes that’s a tail btw lol)

If it helps, here is the settings of the mesh.

image
(Ignore the update rate being so high I was just messing around with it)

If anyone knows a solution to this I would appreciate it a lot!

Did you mean to define two roots? I believe that may be the cause if the 2nd root is where the tail falls down

I added Tail1 in the roots to make it look slightly more natural from the start of the tail since it looked kinda strange, however I don’t believe that’s what it makes the tail float over wedges. (I just tried with one root and still happens lol)

Is there a tutorial for the usage?

why does smartbone freeze for me? I tried fixing it but it wouldnt work I even ported things in smartbones test place and it just freezes in place does anyone know why?

It is possible to use it for ragdoll ?

1 Like

I’m not sure what the issue is but the bones of my rigged object moves but nothing moves visually, everything is in the same position but in explorer the bones seem to move. Does anyone have a solution to this?

I have used it for ragdoll before and it works pretty good :+1:

1 Like

does anyone know how i can fix objects with smartbone welded to my character being offsetted randomly?

1 Like

I found a major optimization concerning the UpdateRate variable!
The issue is the UpdateRate may exceed the frame rate, thus resulting in numerous calculations being done. In my project I have a single bit of code that calculates frame rate and frame timing, and it updates a number value to the current frame rate. In this section Class:m_UpdateBoneTree, my version looks like this;

local MaxUpdateRate=game.Players.LocalPlayer.PlayerGui:WaitForChild("CharacterSelect").FPS
function Class:m_UpdateBoneTree(BoneTree: IBoneTree, Index: number, Delta: number)
do end
	
if BoneTree.Destroyed then
		table.remove(self.BoneTrees, Index)
BoneTree:Destroy()
		
		return
	end

	BoneTree:PreUpdate(Delta) -- Pre update MUST be called before we call SkipUpdate!

	if not BoneTree.InView or not BoneTree.InWorkspace then--or math.floor(BoneTree.UpdateRate) == 0 
		local AlreadySkipped = BoneTree.IsSkippingUpdates

		BoneTree:SkipUpdate()

		if not AlreadySkipped then
do end
			
task.synchronize()
BoneTree:ApplyTransform()
task.desynchronize()	

			----SB_VERBOSE_LOG(
		--		`Skipping BoneTree, InView: {BoneTree.InView}, Update Rate == 0: {math.floor(BoneTree.UpdateRate) == 0}, InWorkspace: {BoneTree.InWorkspace}`
		--	)
		end

		return
	end
do end	
----if everyother==false then
--	everyother=true
--else
--everyother=false
for _, ColliderObject in self.ColliderObjects do
		ColliderObject:Step()
	end
do end
--end	
local UpdateHz = 1 / math.min(MaxUpdateRate.Value,BoneTree.UpdateRate)
	local DidUpdate = false

	BoneTree.AccumulatedDelta += Delta
	while BoneTree.AccumulatedDelta > UpdateHz do
		BoneTree.AccumulatedDelta -= UpdateHz

		DidUpdate = true

		BoneTree:StepPhysics(UpdateHz)
		
		BoneTree:Constrain(self.ColliderObjects, UpdateHz)
		BoneTree:SolveTransform(UpdateHz)
	end
do end
	
if DidUpdate then
		task.synchronize()
		BoneTree:ApplyTransform()
		task.desynchronize()
	end
end

The change I’m talking about is clamping the UpdateHz to

local UpdateHz = 1 / math.min(MaxUpdateRate.Value,BoneTree.UpdateRate)

using a number value representing the frame rate.

local MaxUpdateRate=game.Players.LocalPlayer.PlayerGui:WaitForChild("CharacterSelect").FPS

With the patch applied I’m getting up to 4x lower CPU usage in certain areas with many curtains where my previous test showed up to 27% down to a high of 9% CPU usage.

I was diving in this looking for any optimizations, I really like this code and use it as a core feature for animating hair, and fabric.

I noticed some other possible optimizations that were lost due to the way the code is structured. I think it would perform better with less iterations on the ‘ColliderObjects’ array by combining their for statements.

This is by design- It is a user choice to decide the update rate of objects where higher update rates may be favourable at times

I see, I am currently using these massive curtains with a tiled texture. Super optimized! One giant curtain for this entire wall of curtains. The curtain primitive is super useful!

.

. The bones

They are great!

I’m not quite sure where else to report a bug, but here you go.