From 773b7635a40b77663ec789b0d8092e172a4839d8 Mon Sep 17 00:00:00 2001 From: gugus Date: Tue, 22 Mar 2011 21:30:46 +0100 Subject: [PATCH 1/2] decrease the range of the raycast, and modifie the gravity/speed of the player. --- apps/openmw/mwrender/mwscene.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/mwscene.cpp b/apps/openmw/mwrender/mwscene.cpp index e0aa8c45b9..93197f690c 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); } } From b2194398a4a8745e3e6b94b822d3b1f11b6ea458 Mon Sep 17 00:00:00 2001 From: gugus Date: Wed, 23 Mar 2011 13:42:28 +0100 Subject: [PATCH 2/2] fixed a bug in loading. Every collision mesh is correctly loaded now. --- components/nifbullet/bullet_nif_loader.cpp | 42 ++++++++++++++++++---- components/nifbullet/bullet_nif_loader.hpp | 7 +++- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index 074d4fb8ea..301060cd6f 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 0900ecb9fc..6039e8d71c 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.