stride3d / stride3d/stride

PhysicsComponent.UpdatePhysicsTransformation() adds extra offset to physics debug model

Open
#395 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-Physics bug
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

Release Type: Official Release

Version: 3.0.0.8 / 3.1.0.1-beta01-0441

Platform(s): Windows

Describe the bug
PhysicsComponent.UpdatePhysicsTransformation() adds extra offset to physics debug model when ColliderShape.LocalOffset is not 0.
That seems not to happen when a StaticColliderComponent gets CompoundColliderShape.

To Reproduce
Steps to reproduce the behavior:

  1. Create new game project.
  2. Add a StaticColliderComponent to the Sphere entity and add a sphere collider to it.
  3. Set the sphere collider's LocalOffset to X=1 Y=0 Z=0.
  4. Add a SyncScript like this.
    public class TestScript : SyncScript
    {
        public override void Start()
        {
        }

        public override void Update()
        {
            DebugText.Print(
            $"Sphere: {Entity.Transform.WorldMatrix.TranslationVector.ToString()}" + Environment.NewLine +
            $"Sphere Collider: {Entity.Get<StaticColliderComponent>().PhysicsWorldTransform.TranslationVector.ToString()}" + Environment.NewLine +
            $"Debug Entity: {Entity.Get<StaticColliderComponent>().DebugEntity?.Transform.WorldMatrix.TranslationVector.ToString()}" + Environment.NewLine +
            $"Debug Entity Child: {Entity.Get<StaticColliderComponent>().DebugEntity?.GetChild(0)?.Transform.WorldMatrix.TranslationVector.ToString()}",
            new Int2(10));
            if (Input.IsKeyPressed(Keys.Space))
            {
                Entity.Get<StaticColliderComponent>().UpdatePhysicsTransformation();
            }
        }
    }
  1. Add it to the Sphere entity.
  2. Add DebugPhysicsShapes asset and add it to the Sphere entity.
  3. Run the game.
  4. Press Ctrl + Shift + P keys.
  5. Press space key.

Expected behavior
Nothing happens when you press space key.

Screenshots
Step 8.
update00

Step 9.
update01

Log and callstacks

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at StaticColliderComponent.UpdatePhysicsTransformation() and trace how ColliderShape.LocalOffset is applied to the physics debug model, comparing the regular sphere collider with CompoundColliderShape behavior. Reproduce the issue using DebugPhysicsShapes and the supplied SyncScript, then verify that pressing Space no longer moves the debug model when the local offset is nonzero.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.