-
-
Notifications
You must be signed in to change notification settings - Fork 23.7k
Fix console errors and crash in cleanup code for PhysicalBoneSimulator3D #103921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Apologies. I deleted my local branch and that invalidated the PR. This is the resubmit, I'll leave this one open. ref: |
SaracenOne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm...this seems fine in so far as a way to make sure the simulator is able to keep track of bone count changes. After looking over it a bit, I can't see anything obviously problematic with this approach and it does appear to address the problem.
Would recommend cleaning up the redundant switch cases, but other than that, I think this will be fine to approve.
SaracenOne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
|
Looks good! Could you squash the commits? See PR workflow for instructions. |
@akien-mga I think I did the squash correctly as my branch only shows one commit, but I'm still seeing 7 here and "processing updates" has been running for some time? I'm not sure if it is slow or I broke something. Apologies if I missed something obvious. This is my first time using git's PR system 😅 |
|
It's the first time I see a PR stuck like this with "Processing updates". It might have been a GitHub fluke. You could try to do an amend (with no edit) and force push again to get GitHub to hopefully wake up. |
de17670 to
df3a5a4
Compare
I did that myself (with a commit message tweak) and that seemed to do the trick this time. |
df3a5a4 to
d39003c
Compare
|
Thanks! Congratulations on your first merged contribution! 🎉 |
|
@Repiteo thank you! i've been using this engine for a few years, feels really good to make a tiny contribution back ^__^ |
|
Cherry-picked for 4.4.1. |
Skeleton3D/PhysicalBoneSimulator does not clean up internal state when removing bones
Description
There is a bug which prevents dynamically removing and then adding bones to a skeleton.
The use case for dynamically constructing skeletons is in creating generative creatures, mechanism, and so on.
For my example, I use a ball and chain simulation with dynamic number of links. The scene componentry builds a chain link up from a link template and a ball template. This repo is a test case for demonstrating the behavior.
The Chain.gd file creates a ball-and-chain simulation with a dynamic number of links that can be changed directly within the editor. It is the only script file of interest for the project.
Project for reproducing:
https://github.com/mikest/godot-chain/
Steps to reproduce crash
Results:
Investigation
Skeleton3D,PhysicalBoneSimulator3D, andPhysicalBone3Dall maintain a set of internal caching structures that appear to be there as speed optimizations. These caching structures are not properly kept in sync when removing physical bones or when callingSkeleton3D::clear_bones()to remove logical bones. In most cases, this results in numerous errors logged in the console, but on occasion, it can also result in crashes.This PR is an attempt to reduce those errors and to reduce the conditions which trigger spurious console logging from cache size misses due to stale cache data.
To address this, I included more cache invalidation in
Skeleton3D::clear_bones().I also fixed cache sync problems with the
bone_global_pose_dirtyandnested_set_offset_to_bone_indexinSkeleton3D::add_bone(const String &p_name).Many of the logging errors that arrise after removing and adding a bone are due to caches being rebuilt before the
PhysicalBone3Dhas been added to the tree. I have moved the cache rebuild toNOTIFICATION_POST_ENTER_TREE. This fixes the errors from_reload_joints.The last change I made was to the
PhysicalBoneSimulator3D::_pose_updated()call, which when detecting a cache size mismatch between the skeleton bone count and the internalbonescache will rebuild it. This happens when a physical bone is still attached and the Skeleton clears the bones and then rebuilds them to a different size. The simulator will make pose updates and cause cache misses.Related Issues
Fix error spam at start with Skeleton3D modifiers #102030
#102030
NOTE: I'm not terribly familiar with the godot internals and this is my first PR, so extra attention is probably warranted.