Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/entity.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 53a0f95..4a6528f 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -552,7 +552,7 @@ void Entity::reset()
if (model()->collisionmodel() && model()->collisionmodel()->size()) {
- // complex collision is enabled and a valid collision model has been found
+ // a valid collision model has been found, use it to construct a compoundshape
btCompoundShape *compoundshape = new btCompoundShape();
for (model::CollisionModel::CollisionMeshes::iterator it = model()->collisionmodel()->meshes().begin();
it != model()->collisionmodel()->meshes().end(); it++) {
@@ -560,19 +560,24 @@ void Entity::reset()
model::CollisionMesh *mesh = (*it);
// generate a btCollisionShape for each model::CollisionMesh in the model::CollisionModel
- // static entities use a btBvhTriangleMeshShape
+ // static entities use a btBvhTriangleMeshShape
btBvhTriangleMeshShape *meshshape = new btBvhTriangleMeshShape(mesh->triangles(), true, true);
meshshape->setMargin(Cvar::sv_collisionmargin->value());
const float meshscale = mesh->scale() * modelscale;
const btVector3 meshscalevec(meshscale, meshscale, meshscale);
+ // TODO
+ // This does not work as advertized, it is actually the underlying mesh that
+ // gets scaled. If there are multiple entities with the same model at a different scale,
+ // the scale is set per-model instead of per-entity
+ // Note that it is still possible to reuse and rescale the same model used by an Entitycontrolable
+ // (and most likely, EntityDynamic as well)
meshshape->setLocalScaling(meshscalevec);
meshshape->buildOptimizedBvh();
meshshape->recalcLocalAabb();
// apply collision mesh properties to the btCollisionShape
- // FIXME this goes wrong with rotated entities (see alexandria)
btTransform child_transform;
child_transform.setIdentity();
child_transform.setOrigin(to_btVector3(mesh->location() * modelscale));