SmartBone 2 - Simulated Physics and Collision solution for Bones

Go to the docs and then SmartBone

1 Like

Before getting into my problem I just want to say this is an amazing system and please continue improving it.

Is there a way to add separate Modifiers (Stiffness,Dampness,etc) to Roots under the same Root Part
Iā€™m using a custom skinned mesh character that has both Hair Bones and Tail Bones but iā€™d like to make the tail a lot more stiff than the hair.Since all the bones are under a Root Part,I canā€™t just add the tags to separate parts.

1 Like

At the moment there isnā€™t support for this, but this is something that was thought about and considered alot later into development which is more or less the reason as to why it already isnā€™t a feature. There is still the possibility of this feature being added but itā€™s not planned atm. The only way that you could do this would be by splitting the meshes which doesnt seem applicable for your circumstance.

Sorry for the inconvienince.

3 Likes

SmartBone already encorporates frustum culling in a more sophisticated way by computing the bounding box of all the bones and checking that, Iā€™m not sure as to how you managed to reach 63% in the latest update as without your patch it comfortably sits at about 3.5% when not looking at the objects and about 8-9% while looking at the objects.

I know during startup the runtime has a short spike in activity but this is due to all the bones being setup and the colliders being found and initialised.

All objects in view:
image

Most objects out of view:
image

1 Like

Oooh I see, yes there is a frustum module here. Thatā€™s awkward. :sweat_smile: After double checking it does appear to be the same performance. Iā€™m hoping this scales well I plan on incorporating it into a procedurally generated infinite world, I have a custom renderer that destroys objects not in view, and compresses them to a reference of their source object. or if their is none such as procedurally generated characters, they are cached, so does the smartbone disconnect if the object is not a descendant of the workspace?
How often is the frustum culling done on every object every frame? Is there anyway to change the refresh rate of that for performance benchmarks?

In my renderer I have a refresh rate the calculations are all done within that time by dividing the refresh rate by the number of steps. So, a refresh rate of .6 seconds makes the function always take .6 seconds to complete while distributing the load and reduces the cpu usage significantly. Then a signal is sent to the server, and the server returns the signal when completed to initiate the next culling cycle and to account for server ping.
Iā€™m new to your smartbone system but I will keep my eye out for any optimizations I can think of, or at least spark some interest and maybe provide some insight.

So when an object is deleted smartbone removes all its references to it, deletes the runtime and it was like it was never there. If the object is then added back then smartbone will see that and create a new runtime for it and it will start simulating, you do point out a good point that an object not in workspace still simulates, now Iā€™m not 100% sure if it does or doesnā€™t but I know for sure that colliders are ignored if they arent a descendant of workspace. I will look into skipping updates if objects arenā€™t a descendent of workspace for the next update.

The frustum culling is done every frame for every object that has a runtime, the current solution is very performant as I spent a while going over it, it uses the same frustum algorithim as windshake just modified to allow for dynamic objects and what not. You can also change the far plane in the config file found in src/Dependencies/Config . As of right now there is not a way to change the frequency at which frustum culling is checked.

1 Like

Iā€™ve added a card to the trello related to changing the frequency of the frustum culling, so next update this should be supported along with a value in the config.

As for the debug calls, I was aware they had a performance impact but I didnt know it was that much. Iā€™ll look into removing them on releases.

2 Likes

Iā€™m glad to hear that! Iā€™m not sure if you said smartbone doesnā€™t check if an object is in the workspace when rendering its bones but a way to check this could be

if RootObject:IsDescendantOf(workspace) then -- is true or false
--disconnect the heart beat function until the object is in view again
end
RootObject.AncestryChanged:ConnectParallel(function()
if RootObject:IsDescendantOf(workspace) then
render:Connect() -- reconnect the heartbeat signal
end
end)

I love optimizations Iā€™ve been doing a lot of that.
I also am about to implement a library Iā€™ve assembled of over 50 hair 3-D models, Iā€™ve also been creating this module I will be sharing as a resource on this thread probably tomorrow or the next couple days.
Itā€™s called SmartBoneUtility and hosts useful functions for creating your own libraries with this resource.

But if an object is then re-parented from replicated storage or cloned and then reparented it will not work. I already have a fix in mind to not simulate objects outside of workspace.

Iā€™m not exactly sure what you mean by this, do you mean when the object is out of view you disconnect the heartbeat connection in the runtime?

This implementation isnā€™t applicable as certain functions still have to run inside smartbone whilst the object is out of view to prevent stretching issues and what not as the object comes back into view.

1 Like

It only does the Setup once, connecting to the Rendered==true bool is arbitrary on initialization, I Noticed that for some reason my cullsmartbones function checks if the Runtime is not enabled, this was an oversight, that I didnā€™t delete, because itā€™s never disabled, it only disconnects the heartbeat signal. I will test it some more and let you know how it goes.

Yeah the heartbeat connection is what calls StepBoneTrees, that function has to run every frame to prevent the afformentioned issues.

Thatā€™s very interesting! Iā€™ll try to take a look at that, i imagine upon the rendering disconnect to reset the bones to their initial Setup state. but Iā€™ll have a look at that. I imagine itā€™s like how skyrim does it when you see characters hair bounce into physics, at worst Iā€™ll keep a modified runtime for my own tinkering :slight_smile: I would like to make it very scalable and efficient so I can use it willy nilly.

Upon further testing it doesnā€™t seem to cause an issue and works perfectly, CPU usage jumps to 1% upon viewing the capes, and .5 when not in view, and then just continue from where it left off.

I sent you a place file to evaluate it for yourself. the culling function test script is location inside the ClientLoader. perhaps call the culling in a cycle inside the Init function?

Wind can be ignored via WindInfluence and inertia can be set to 0

Smartbone Editor Plugin

You can now purchase the plugin via this place:

v0.4.0

Bug Fixes

  • Fixed constraints being updated with wrong delta time
  • Class.Running is now set to false when .Stop() is called
  • Fixed tailbones not being created if a non-bone child existed
  • Fixed bones not following welds in certain circumstances
  • Fixed a bug related to anchors rotate

Features

  • Changed Sin wind to sample multiple octaves of sine waves
  • Added object based velocity wind, the faster the object the higher the frequency of wind.
  • Objects are now checked to see if they are a descendant of workspace
  • Rigid welds now force a bones rotation
  • Wind is now based on velocity, walking into the wind increases the wind speed and walking with the wind decreases wind speed.

Optimizations

  • Various optimizations around the codebase related to math.min and math.max
  • Added a config value to the config related to the frequency at which frustum checks are done (FRUSTUM_FREQ)
  • Debug profiling is now removed on release builds for increased performance
  • Minor optimization for axis constraints

Misc

  • Changed debug overlay to respect ALLOW_LIVE_GAME_DEBUG
  • Fixed profiling warning in m_CleanColliders
  • Renamed FirstSkipUpdate to IsSkippingUpdates in Bone and BoneTree
  • Fixed formatting in README and added a link to the trello
5 Likes

NOTICE

There is a bug in v0.4.0 which may cause your rigs to deform incorrectly, if you run into this issue then switch back to v0.3.1 for the time being until I am able to fix it and release the next version. I sincerely apologise for the inconviencence this may cause.

1 Like

For the Smart bone Editor Plugin, do you plan on adding visualisation for each bone with their limits (X-Axis limits, Y-Axis limits etc)? Maybe for example if you selected a bone and then started editing the Minimum Y Axis Limit, it would show a grid marking what Y you put. That way, it would make it much easier to set them in the editor without having to switch between testing and editing.

(or maybe this is already a feature and Iā€™ve just missed it haha)

This was a planned feature for the plugin when it was last updated however I ran into issues while implementing it, and due to time constraints with releasing the update I updated the plugin without the gizmos. Whenever I get around to updating the plugin next I will be sure to add gizmo support.

2 Likes