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

Add RigidBodyComponent#getPosition/getRotation to reduce Ammo coupling #6948

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions scripts/physics/render-physics.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,8 @@ RenderPhysics.prototype.postUpdate = function (dt) {
debugShape._collisionType = collision.type;
collision._debugShape = debugShape;
}

// Use the rigid body position if we have it
if (collision.entity.rigidbody) {
var body = collision.entity.rigidbody.body;
if (body) {
var t = body.getWorldTransform();

var p = t.getOrigin();
var q = t.getRotation();
collision._debugShape.setPosition(p.x(), p.y(), p.z());
collision._debugShape.setRotation(q.x(), q.y(), q.z(), q.w());
}
} else {
collision._debugShape.setPosition(collision.entity.getPosition());
collision._debugShape.setRotation(collision.entity.getRotation());
}

collision._debugShape.setPosition(collision.getShapePosition());
collision._debugShape.setRotation(collision.getShapeRotation());
// If the shape is a capsule, cone or cylinder, rotate it so that its axis is taken into account
if (collision.type === 'capsule' || collision.type === 'cone' || collision.type === 'cylinder') {
if (collision._debugShape._axis === 0) {
Expand Down