From c3182222bd3fef6009f98205c0203d61a7509b11 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 26 Jan 2011 15:56:10 +0000 Subject: Corrected the origin alignment of collision mesh bodies. --- src/core/entity.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/entity.cc b/src/core/entity.cc index 9275477..cf005a0 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -511,11 +511,14 @@ void Entity::reset() if (flag_is_set(Complex) && model()->collisionmesh()) { // use collision mesh - btBvhTriangleMeshShape *mesh = new btBvhTriangleMeshShape(model()->collisionmesh()->triangles(), true, true); - entity_collision_shape = mesh; + btBvhTriangleMeshShape *meshshape = new btBvhTriangleMeshShape(model()->collisionmesh()->triangles(), true, true); + meshshape->buildOptimizedBvh(); + meshshape->recalcLocalAabb(); btVector3 modelscalevec(modelscale, modelscale, modelscale); - mesh->setLocalScaling(modelscalevec); + meshshape->setLocalScaling(modelscalevec); + + entity_collision_shape = meshshape; } else { // use bounding box -- cgit v1.2.3