use of com.bulletphysics.collision.shapes.CollisionShape in project bdx by GoranM.
the class GImpactShapeInterface method setMargin.
@Override
public void setMargin(float margin) {
collisionMargin = margin;
int i = getNumChildShapes();
while ((i--) != 0) {
CollisionShape child = getChildShape(i);
child.setMargin(margin);
}
needs_update = true;
}
use of com.bulletphysics.collision.shapes.CollisionShape in project bdx by GoranM.
the class GameObject method updateBody.
public void updateBody(Mesh mesh) {
GameObject compParent = parent != null && parent.body.getCollisionShape().isCompound() ? parent : null;
boolean isCompChild = compParent != null && !(currBodyType == BodyType.NO_COLLISION || currBodyType == BodyType.SENSOR);
if (isCompChild) {
parent(null);
}
Matrix4f transform = transform();
Vector3f scale = scale();
CollisionShape shape = body.getCollisionShape();
body.setCollisionShape(Bullet.makeShape(mesh.model.meshes.first(), currBoundsType, shape.getMargin(), shape.isCompound()));
Transform startTransform = new Transform();
body.getMotionState().getWorldTransform(startTransform);
Matrix4f originMatrix = new Matrix4f();
originMatrix.set(origin);
Transform centerOfMassTransform = new Transform();
centerOfMassTransform.set(originMatrix);
centerOfMassTransform.mul(startTransform);
body.setCenterOfMassTransform(centerOfMassTransform);
transform(transform);
scale(scale);
if (body.isInWorld()) {
scene.world.updateSingleAabb(body);
} else {
// update Aabb hack for when not in world
scene.world.addRigidBody(body);
scene.world.updateSingleAabb(body);
scene.world.removeRigidBody(body);
}
if (isCompChild) {
parent(compParent);
}
}
Aggregations