Skip to content

Physics: skip inertia calculation for statics#3268

Open
Spajker7 wants to merge 1 commit into
stride3d:masterfrom
Spajker7:skip-static-mesh-inertia
Open

Physics: skip inertia calculation for statics#3268
Spajker7 wants to merge 1 commit into
stride3d:masterfrom
Spajker7:skip-static-mesh-inertia

Conversation

@Spajker7

Copy link
Copy Markdown

PR Details

ICollider.TryAttach computes the shape's inertia unconditionally, but only bodies read it - StaticComponent.AttachInner discards the shapeInertia parameter unread. The waste is real for the non-trivial colliders: MeshCollider's inertia iterates over every triangle of the mesh, and CompoundCollider additionally combines and inverts its children's inertia tensors in BuildDynamicCompound.

This PR adds a ShouldCalculateInertia flag through the attach path so statics skip that work

Related Issue

/

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

@Spajker7

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@Eideren Eideren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants