From 035653e94a3d74b8f18c993034199d7cd08a895a Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 21 Jan 2011 14:41:35 +0000 Subject: Support structures for complex entity collision, renamed sv_arrysize cvar to mem_vertex. --- src/core/entity.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/core/entity.cc') 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()); } -- cgit v1.2.3