From 4ca0eb93eec7ef18f453ac8d086911bcc34f8a04 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 24 Oct 2012 17:47:03 +0200 Subject: [PATCH] fix markers used for raycasting and blocking activation --- components/nifbullet/bullet_nif_loader.cpp | 7 ++++--- libs/openengine/bullet/BulletShapeLoader.cpp | 3 ++- libs/openengine/bullet/BulletShapeLoader.h | 4 +++- libs/openengine/bullet/physic.cpp | 10 +++++++--- libs/openengine/bullet/physic.hpp | 3 ++- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index 6449ad246..d2ec7ca82 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -71,7 +71,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) { cShape = static_cast(resource); resourceName = cShape->getName(); - cShape->collide = false; + cShape->mCollide = false; mBoundingBox = NULL; cShape->boxTranslation = Ogre::Vector3(0,0,0); cShape->boxRotation = Ogre::Quaternion::IDENTITY; @@ -108,7 +108,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) handleNode(node,0,NULL,hasCollisionNode,false,false); //if collide = false, then it does a second pass which create a shape for raycasting. - if(cShape->collide == false) + if(cShape->mCollide == false) { handleNode(node,0,NULL,hasCollisionNode,false,true); } @@ -177,6 +177,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, if (node->name.find("marker") != std::string::npos) { flags |= 0x800; + cShape->mIgnore = true; } // Check for extra data @@ -254,7 +255,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, } else if (node->recType == Nif::RC_NiTriShape && (isCollisionNode || !hasCollisionNode)) { - cShape->collide = !(flags&0x800); + cShape->mCollide = !(flags&0x800); handleNiTriShape(dynamic_cast(node), flags,node->trafo.rotation,node->trafo.pos,node->trafo.scale,raycastingOnly); } else if(node->recType == Nif::RC_RootCollisionNode) diff --git a/libs/openengine/bullet/BulletShapeLoader.cpp b/libs/openengine/bullet/BulletShapeLoader.cpp index 59a414f30..dd3bca692 100644 --- a/libs/openengine/bullet/BulletShapeLoader.cpp +++ b/libs/openengine/bullet/BulletShapeLoader.cpp @@ -16,7 +16,8 @@ Ogre::Resource(creator, name, handle, group, isManual, loader) we have none as such. Full details can be set through scripts. */ Shape = NULL; - collide = true; + mCollide = true; + mIgnore = false; createParamDictionary("BulletShape"); } diff --git a/libs/openengine/bullet/BulletShapeLoader.h b/libs/openengine/bullet/BulletShapeLoader.h index 8640fd54f..21d21777a 100644 --- a/libs/openengine/bullet/BulletShapeLoader.h +++ b/libs/openengine/bullet/BulletShapeLoader.h @@ -34,7 +34,9 @@ public: Ogre::Vector3 boxTranslation; Ogre::Quaternion boxRotation; //this flag indicate if the shape is used for collision or if it's for raycasting only. - bool collide; + bool mCollide; + + bool mIgnore; }; /** diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 4f16a4143..d78e25ce7 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -169,6 +169,7 @@ namespace Physic RigidBody::RigidBody(btRigidBody::btRigidBodyConstructionInfo& CI,std::string name) : btRigidBody(CI) , mName(name) + , mIgnore(false) { } @@ -327,7 +328,7 @@ namespace Physic btRigidBody::btRigidBodyConstructionInfo CI = btRigidBody::btRigidBodyConstructionInfo(0,newMotionState,hfShape); RigidBody* body = new RigidBody(CI,name); - body->collide = true; + body->mCollide = true; body->getWorldTransform().setOrigin(btVector3( (x+0.5)*triSize*(sqrtVerts-1), (y+0.5)*triSize*(sqrtVerts-1), (maxh+minh)/2.f)); HeightField hf; @@ -397,7 +398,8 @@ namespace Physic //create the real body btRigidBody::btRigidBodyConstructionInfo CI = btRigidBody::btRigidBodyConstructionInfo(0,newMotionState,shape->Shape); RigidBody* body = new RigidBody(CI,name); - body->collide = shape->collide; + body->mCollide = shape->mCollide; + body->mIgnore = shape->mIgnore; if(scaledBoxTranslation != 0) *scaledBoxTranslation = shape->boxTranslation * scale; @@ -414,7 +416,9 @@ namespace Physic { if(body) { - if(body->collide) + if (body->mIgnore) + return; + if(body->mCollide) { dynamicsWorld->addRigidBody(body,COL_WORLD,COL_WORLD|COL_ACTOR_INTERNAL|COL_ACTOR_EXTERNAL); } diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index e4e71706f..f320d009d 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -152,7 +152,8 @@ namespace Physic std::string mName; //is this body used for raycasting only? - bool collide; + bool mCollide; + bool mIgnore; }; struct HeightField