diff options
Diffstat (limited to 'src/core/entity.cc')
-rw-r--r-- | src/core/entity.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc index 4c7b0da..9275477 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -508,7 +508,19 @@ void Entity::reset() // create collision shape if (model() && model()->radius()) { const float modelscale = radius() / model()->radius(); - entity_collision_shape = new btBoxShape(to_btVector3(model()->box().max() * modelscale)); + + if (flag_is_set(Complex) && model()->collisionmesh()) { + // use collision mesh + btBvhTriangleMeshShape *mesh = new btBvhTriangleMeshShape(model()->collisionmesh()->triangles(), true, true); + entity_collision_shape = mesh; + + btVector3 modelscalevec(modelscale, modelscale, modelscale); + mesh->setLocalScaling(modelscalevec); + + } else { + // use bounding box + entity_collision_shape = new btBoxShape(to_btVector3(model()->box().max() * modelscale)); + } } else { entity_collision_shape = new btSphereShape(radius()); } |