diff --git a/apps/openmw/mwrender/mwscene.cpp b/apps/openmw/mwrender/mwscene.cpp index e0aa8c45b..93197f690 100644 --- a/apps/openmw/mwrender/mwscene.cpp +++ b/apps/openmw/mwrender/mwscene.cpp @@ -72,7 +72,7 @@ std::pair MWScene::getFacedHandle (MWWorld::World& world) //let's avoid the capsule shape of the player. centerRay.setOrigin(centerRay.getOrigin() + 20*centerRay.getDirection()); btVector3 from(centerRay.getOrigin().x,-centerRay.getOrigin().z,centerRay.getOrigin().y); - btVector3 to(centerRay.getPoint(1000).x,-centerRay.getPoint(1000).z,centerRay.getPoint(1000).y); + btVector3 to(centerRay.getPoint(500).x,-centerRay.getPoint(500).z,centerRay.getPoint(500).y); return eng->rayTest(from,to); } @@ -115,7 +115,7 @@ void MWScene::doPhysics (float duration, MWWorld::World& world, { Ogre::Quaternion quat = yawNode->getOrientation(); Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); - dir = 0.07*(quat*dir1); + dir = 0.025*(quat*dir1); } //set the walk direction @@ -208,7 +208,7 @@ void MWScene::toggleCollisionMode() { mFreeFly = false; act->enableCollisions(true); - act->setGravity(10.); + act->setGravity(4.); act->setVerticalVelocity(0); } } diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index 074d4fb8e..301060cd6 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -125,18 +125,47 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) return; } + bool hasCollisionNode = hasRootCollisionNode(node); + //do a first pass - handleNode(node,0,Ogre::Matrix3::IDENTITY,Ogre::Vector3::ZERO,1,false,false); + handleNode(node,0,Ogre::Matrix3::IDENTITY,Ogre::Vector3::ZERO,1,hasCollisionNode,false,false); //if collide = false, then it does a second pass which create a shape for raycasting. if(cShape->collide == false) { - handleNode(node,0,Ogre::Matrix3::IDENTITY,Ogre::Vector3::ZERO,1,false,true); + std::cout << "collide = false "<recType == Nif::RC_NiNode) + { + Nif::NodeList &list = ((Nif::NiNode*)node)->children; + int n = list.length(); + for (int i=0; irecType == Nif::RC_NiTriShape) + { + return false; + } + else if(node->recType == Nif::RC_RootCollisionNode) + { + return true; + } + + return false; +} + void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, - Ogre::Matrix3 parentRot,Ogre::Vector3 parentPos,float parentScale,bool isCollisionNode,bool raycastingOnly) + Ogre::Matrix3 parentRot,Ogre::Vector3 parentPos,float parentScale,bool hasCollisionNode,bool isCollisionNode,bool raycastingOnly) { // Accumulate the flags from all the child nodes. This works for all // the flags we currently use, at least. @@ -194,11 +223,11 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, { if (list.has(i)) { - handleNode(&list[i], flags,finalRot,finalPos,finalScale,isCollisionNode,raycastingOnly); + handleNode(&list[i], flags,finalRot,finalPos,finalScale,hasCollisionNode,isCollisionNode,raycastingOnly); } } } - else if (node->recType == Nif::RC_NiTriShape && isCollisionNode) + else if (node->recType == Nif::RC_NiTriShape && (isCollisionNode || !hasCollisionNode)) { cShape->collide = true; handleNiTriShape(dynamic_cast(node), flags,finalRot,finalPos,finalScale,raycastingOnly); @@ -210,7 +239,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, for (int i=0; iaddChildShape(tr,NodeShape); + std::cout << "tri"; } void ManualBulletShapeLoader::load(const std::string &name,const std::string &group) diff --git a/components/nifbullet/bullet_nif_loader.hpp b/components/nifbullet/bullet_nif_loader.hpp index 0900ecb9f..6039e8d71 100644 --- a/components/nifbullet/bullet_nif_loader.hpp +++ b/components/nifbullet/bullet_nif_loader.hpp @@ -105,7 +105,12 @@ private: *Parse a node. */ void handleNode(Nif::Node *node, int flags, - Ogre::Matrix3 parentRot,Ogre::Vector3 parentPos,float parentScale,bool isCollisionNode,bool raycastingOnly); + Ogre::Matrix3 parentRot,Ogre::Vector3 parentPos,float parentScale,bool hasCollisionNode,bool isCollisionNode,bool raycastingOnly); + + /** + *Helpler function + */ + bool hasRootCollisionNode(Nif::Node* node); /** *convert a NiTriShape to a bullet trishape.