From a711a3ebe1b67886a58b004ddc13e5bbfc446fa2 Mon Sep 17 00:00:00 2001 From: gugus Date: Tue, 29 May 2012 16:45:43 +0200 Subject: [PATCH] Various fixes --- apps/openmw/mwscript/docs/vmformat.txt | 4 +++- apps/openmw/mwscript/statsextensions.cpp | 10 +++++++--- apps/openmw/mwworld/physicssystem.cpp | 4 ---- apps/openmw/mwworld/world.cpp | 1 + libs/openengine/bullet/physic.cpp | 24 ++++++++++++++++++++---- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index bb8f8a214..86cf73117 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -147,5 +147,7 @@ op 0x2000150: ForceGreeting, explicit reference op 0x2000151: ToggleFullHelp op 0x2000152: Goodbye op 0x2000153: SetScale -op 0x2000154: SetAngle +op 0x2000154: SetScale, explicit reference +op 0x2000155: SetAngle +op 0x2000156: SetAngle, explicit reference opcodes 0x2000155-0x3ffffff unused diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index c68febec3..83bfacf40 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -592,7 +592,9 @@ namespace MWScript const int opcodeModDispositionExplicit = 0x200014e; const int opcodeSetScale = 0x2000153; - const int opcodeSetAngle = 0x2000154; + const int opcodeSetScaleExplicit = 0x2000154; + const int opcodeSetAngle = 0x2000155; + const int opcodeSetAngleExplicit = 0x2000156; void registerExtensions (Compiler::Extensions& extensions) { @@ -677,8 +679,8 @@ namespace MWScript opcodeModDispositionExplicit); extensions.registerFunction("getpcrank",'l',"/S",opcodeGetPCRank,opcodeGetPCRankExplicit); - extensions.registerInstruction("setscale","/l",opcodeSetScale); - extensions.registerInstruction("setangle","/Sl",opcodeSetAngle); + extensions.registerInstruction("setscale","l",opcodeSetScale,opcodeSetScaleExplicit); + extensions.registerInstruction("setangle","Sl",opcodeSetAngle,opcodeSetAngleExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -752,7 +754,9 @@ namespace MWScript interpreter.installSegment3(opcodeGetPCRankExplicit,new OpGetPCRank); interpreter.installSegment5(opcodeSetScale,new OpSetScale); + interpreter.installSegment5(opcodeSetScaleExplicit,new OpSetScale); interpreter.installSegment5(opcodeSetAngle,new OpSetAngle); + interpreter.installSegment5(opcodeSetAngleExplicit,new OpSetAngle); } } } diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index c4e34a540..8ebdf2981 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -290,8 +290,6 @@ namespace MWWorld { if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle)) { - // TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow - // start positions others than 0, 0, 0 act->setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)); } if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle)) @@ -304,8 +302,6 @@ namespace MWWorld { if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle)) { - // TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow - // start positions others than 0, 0, 0 //body->setWorldTransform(btTransform().se } } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 69da98096..db96b6a19 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -668,6 +668,7 @@ namespace MWWorld Ogre::Quaternion rotz(Ogre::Degree(z),Ogre::Vector3::UNIT_Z); ptr.getRefData().getBaseNode()->setOrientation(rotx*roty*rotz); mPhysics->rotateObject(Class::get(ptr).getId(ptr),ptr.getRefData().getBaseNode()->getOrientation()); + std::cout << Class::get(ptr).getId(ptr); } void World::indexToPosition (int cellX, int cellY, float &x, float &y, bool centre) const diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index d30d5e9f1..4ead88994 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -392,8 +392,16 @@ namespace Physic RigidBody* PhysicEngine::getRigidBody(std::string name) { - RigidBody* body = RigidBodyMap[name]; - return body; + RigidBodyContainer::iterator it = RigidBodyMap.find(name); + if (it != RigidBodyMap.end() ) + { + RigidBody* body = RigidBodyMap[name]; + return body; + } + else + { + return 0; + } } void PhysicEngine::stepSimulation(double deltaT) @@ -450,8 +458,16 @@ namespace Physic PhysicActor* PhysicEngine::getCharacter(std::string name) { - PhysicActor* act = PhysicActorMap[name]; - return act; + PhysicActorContainer::iterator it = PhysicActorMap.find(name); + if (it != PhysicActorMap.end() ) + { + PhysicActor* act = PhysicActorMap[name]; + return act; + } + else + { + return 0; + } } void PhysicEngine::emptyEventLists(void)