Skip to content
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

Remove scene context from errors/warnings in Jolt Physics module #102717

Closed
wants to merge 1 commit into from

Conversation

mihe
Copy link
Contributor

@mihe mihe commented Feb 11, 2025

Fixes #102638.
Supersedes #102726.

Warning

This PR is entirely untested as of writing this.

This PR removes any mention of specific scene nodes in the various error/warning messages found in modules/jolt_physics, due to calls to Object::to_string being problematic when using physics/3d/run_on_separate_thread.

This PR also changes most of these warnings to be WARN_PRINT_ONCE instead, since there's no real context provided anymore, and therefore no point in spamming the warning continuously.

I've also gone ahead and removed most of the errors related to invalid scaling (e.g. scaling a cylinder on anything but its height axis) as previously emitted by the JOLT_ENSURE_SCALE_VALID macro, as they were already adding some friction for some users, and without context they're likely to cause even more friction, especially when emitted during runtime.

Now instead we only do a WARN_PRINT_ONCE inside of JoltShape3D::make_scale_valid if a significant invalid scale is detected, and only for DEV_ENABLED builds. This should allow us to catch these kinds of errors when bugs are reported that suffer from this, but they won't bother end users.

I've left in the errors for zero-scaled transforms, as emitted by the JOLT_ENSURE_SCALE_NOT_ZERO macro, as they will typically cause a lot of problems and thus should be dealt with in some way, which I currently do by just resetting the entire Basis to identity. That seems to me like a significant enough of an intervention to warrant emitting an error, even without any context.

@mihe mihe force-pushed the jolt/less-error-context branch from 41d7aac to 9508e8a Compare February 11, 2025 16:18
@akien-mga
Copy link
Member

This PR removes any mention of specific scene nodes in the various error/warning messages found in modules/jolt_physics, due to calls to Node::to_string being problematic when using physics/3d/run_on_separate_thread.

I missed that the linked issue was only when running physics on a separate thread (which isn't the default). In that case maybe it still makes sense to preserve the detailed messages for the case where physics/3d/run_on_separate_thread is false, and only fall back to a more generic message in the other case?

@mihe
Copy link
Contributor Author

mihe commented Feb 11, 2025

In that case maybe it still makes sense to preserve the detailed messages for the case where physics/3d/run_on_separate_thread is false, and only fall back to a more generic message in the other case?

Having two different error message everywhere would be quite messy. I could however make it so that any node name is reported as <unknown> or something when running on a separate thread, which wouldn't require changing the existing messages in any way. I already do this if the instance ID (ObjectID in the case of nodes) isn't found in ObjectDB.

@Calinou
Copy link
Member

Calinou commented Feb 11, 2025

I could however make it so that any node name is reported as <unknown> or something when running on a separate thread, which wouldn't require changing the existing messages in any way.

That makes sense to me, as long as we document this limitation in run_in_separate_thread's documentation.

@mihe
Copy link
Contributor Author

mihe commented Feb 11, 2025

You'll find this simpler implementation in #102726.

@akien-mga
Copy link
Member

Superseded by #102726.

@akien-mga akien-mga closed this Feb 11, 2025
@akien-mga akien-mga removed this from the 4.4 milestone Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jolt Physics warnings for PhysicalBone3D fail to report bone names when running physics on separate thread
3 participants