Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2011-01-21 14:41:35 +0000
committerStijn Buys <ingar@osirion.org>2011-01-21 14:41:35 +0000
commit035653e94a3d74b8f18c993034199d7cd08a895a (patch)
tree6acc56c14a86b499657b6e7faaf50f9e6f7ff57d /src/core/entity.cc
parent4af61dca099d2b7010d4fa83833ceeeef01b0b0f (diff)
Support structures for complex entity collision,
renamed sv_arrysize cvar to mem_vertex.
Diffstat (limited to 'src/core/entity.cc')
-rw-r--r--src/core/entity.cc14
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());
}