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

Bug: RigidBody.setType before addShape makes body not work #64

Closed
fy0 opened this issue May 22, 2023 · 1 comment
Closed

Bug: RigidBody.setType before addShape makes body not work #64

fy0 opened this issue May 22, 2023 · 1 comment
Labels

Comments

@fy0
Copy link

fy0 commented May 22, 2023

Code:

world = new oimo.dynamics.World(oimo.collision.broadphase.BroadPhaseType.BVH);
const geoBox = new oimo.collision.geometry.BoxGeometry(new oimo.common.Vec3(1, 1, 1));
const sc = new oimo.dynamics.rigidbody.ShapeConfig();
sc.geometry = geoBox;

const bc = new oimo.dynamics.rigidbody.RigidBodyConfig();
const b = new oimo.dynamics.rigidbody.RigidBody(bc);

// this line
b.setType(oimo.dynamics.rigidbody.RigidBodyType.DYNAMIC);
b.addShape(new oimo.dynamics.rigidbody.Shape(sc));

world.addRigidBody(b);
// (b as any).updateMass();

world.step(0.01);

// 0, 0, 0
console.log(b.getPosition())

If move the setType line after b.addShape, it's OK.

@saharan saharan added the bug label May 17, 2024
@saharan
Copy link
Owner

saharan commented May 17, 2024

I think these lines unintentionally turn RigidBody._type into RigidBodyType.STATIC in this case. I will fix this in the next version. Thanks!

// force static
if (_type == RigidBodyType._DYNAMIC) {
_type = RigidBodyType._STATIC;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants