Merge branch 'physicsaedra3' of https://github.com/jhooks1/openmw.git into objectRotationScaling

Conflicts:
	apps/openmw/mwclass/npc.cpp
	apps/openmw/mwworld/physicssystem.cpp
actorid
gugus 13 years ago
commit feec67094f

@ -178,6 +178,12 @@ namespace MWBase
virtual void moveObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0;
virtual void scaleObject (MWWorld::Ptr& ptr, float scale) = 0;
virtual void rotateObject (MWWorld::Ptr& ptr,float x,float y,float z,bool WorldAxis) = 0;
virtual void setObjectRotation (MWWorld::Ptr& ptr,float x,float y,float z) = 0;
virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false)
const = 0;
///< Convert cell numbers to position.

@ -125,10 +125,14 @@ namespace MWClass
void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{
MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>();
assert (ref->base != NULL);
std::string headID = ref->base->head;
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
@ -136,7 +140,8 @@ namespace MWClass
std::string smodel = "meshes\\base_anim.nif";
if(beast)
smodel = "meshes\\base_animkna.nif";
physics.insertActorPhysics(ptr, smodel);
physics.insertActorPhysics(ptr, smodel);
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
}

@ -596,10 +596,10 @@ namespace MWScript
const int opcodeModDisposition = 0x200014d;
const int opcodeModDispositionExplicit = 0x200014e;
const int opcodeSetScale = 0x2000154;
const int opcodeSetScaleExplicit = 0x2000155;
const int opcodeSetAngle = 0x2000156;
const int opcodeSetAngleExplicit = 0x2000157;
const int opcodeSetScale = 0x2000164;
const int opcodeSetScaleExplicit = 0x2000165;
const int opcodeSetAngle = 0x2000166;
const int opcodeSetAngleExplicit = 0x2000167;
void registerExtensions (Compiler::Extensions& extensions)
{

@ -238,6 +238,7 @@ namespace MWWorld
void PhysicsSystem::addObject (const std::string& handle, const std::string& mesh,
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position)
{
handleToMesh[handle] = mesh;
OEngine::Physic::RigidBody* body = mEngine->createRigidBody(mesh,handle,scale);
mEngine->addRigidBody(body);
btTransform tr;
@ -290,21 +291,24 @@ namespace MWWorld
void PhysicsSystem::rotateObject (const std::string& handle, const Ogre::Quaternion& rotation)
{
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
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))
{
body->setWorldTransform(btTransform(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w),body->getWorldTransform().getOrigin()));
}
}
void PhysicsSystem::scaleObject (const std::string& handle, float scale)
{
if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle))
if(handleToMesh.find(handle) != handleToMesh.end())
{
//body->setWorldTransform(btTransform().se
btTransform transform = mEngine->getRigidBody(handle)->getWorldTransform();
removeObject(handle);
Ogre::Quaternion quat = Ogre::Quaternion(transform.getRotation().getW(), transform.getRotation().getX(), transform.getRotation().getY(), transform.getRotation().getZ());
Ogre::Vector3 vec = Ogre::Vector3(transform.getOrigin().getX(), transform.getOrigin().getY(), transform.getOrigin().getZ());
addObject(handle, handleToMesh[handle], quat, scale, vec);
}
}

@ -72,6 +72,7 @@ namespace MWWorld
OEngine::Physic::PhysicEngine* mEngine;
bool mFreeFly;
playerMove* playerphysics;
std::map<std::string, std::string> handleToMesh;
PhysicsSystem (const PhysicsSystem&);
PhysicsSystem& operator= (const PhysicsSystem&);

@ -597,7 +597,7 @@ namespace MWWorld
mPhysics->moveObject (ptr.getRefData().getHandle(), Ogre::Vector3 (x, y, z));
}
void World::scaleObject (Ptr ptr, float scale)
void World::scaleObject (Ptr& ptr, float scale)
{
MWWorld::Class::get(ptr).adjustScale(ptr,scale);
@ -607,7 +607,7 @@ namespace MWWorld
mPhysics->scaleObject( Class::get(ptr).getId(ptr), scale );
}
void World::rotateObject (Ptr ptr,float x,float y,float z,bool WorldAxis)
void World::rotateObject (Ptr& ptr,float x,float y,float z,bool WorldAxis)
{
MWWorld::Class::get(ptr).adjustRotation(ptr,x,y,z);
@ -641,7 +641,7 @@ namespace MWWorld
//mPhysics->scaleObject( Class::get(ptr).getId(ptr), scale );
}
void World::setObjectRotation (Ptr ptr,float x,float y,float z)
void World::setObjectRotation (Ptr& ptr,float x,float y,float z)
{
MWWorld::Class::get(ptr).adjustRotation(ptr,x,y,z);

@ -219,6 +219,12 @@ namespace MWWorld
virtual void moveObject (const Ptr& ptr, float x, float y, float z);
virtual void scaleObject (Ptr& ptr, float scale);
virtual void rotateObject (Ptr& ptr,float x,float y,float z,bool WorldAxis);
virtual void setObjectRotation (Ptr& ptr,float x,float y,float z);
virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false)
const;
///< Convert cell numbers to position.

@ -343,8 +343,8 @@ namespace Physic
mShapeLoader->load(outputstring,"General");
BulletShapeManager::getSingletonPtr()->load(outputstring,"General");
BulletShapePtr shape = BulletShapeManager::getSingleton().getByName(outputstring,"General");
shape->Shape->setLocalScaling(btVector3(scale,scale,scale));
shape->Shape->setLocalScaling( btVector3(scale,scale,scale));
//btScaledBvhTriangleMeshShape* scaled = new btScaledBvhTriangleMeshShape(dynamic_cast<btBvhTriangleMeshShape*> (shape->Shape), btVector3(scale,scale,scale));
//create the motionState
CMotionState* newMotionState = new CMotionState(this,name);
@ -407,10 +407,16 @@ namespace Physic
if (it != RigidBodyMap.end() )
{
RigidBody* body = it->second;
//btScaledBvhTriangleMeshShape* scaled = dynamic_cast<btScaledBvhTriangleMeshShape*> (body->getCollisionShape());
if(body != NULL)
{
delete body;
}
/*if(scaled != NULL)
{
delete scaled;
}*/
RigidBodyMap.erase(it);
}
}

@ -7,6 +7,7 @@
#include <list>
#include <map>
#include "BulletShapeLoader.h"
#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"
class btRigidBody;
class btBroadphaseInterface;

@ -527,7 +527,7 @@ int PM_StepSlideMove( bool gravity )
delta = pm->ps.origin.z - start_o.z;
if ( delta > 2 )
{
pm->ps.counter = 10;
pm->ps.counter = 5;
/*
if (gravity)
@ -858,6 +858,8 @@ static void PM_WalkMove( playerMove* const pmove )
float accelerate;
float vel;
//pm->ps.gravity = 4000;
//std::cout << "Player is walking\n";
if ( pm->ps.waterlevel > 2 && //DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 )
pml.forward.dotProduct(pml.groundTrace.planenormal) > 0.0f)
@ -1159,6 +1161,10 @@ void PM_GroundTraceMissed()
{
traceResults trace;
Ogre::Vector3 point;
//We should not have significant upwards velocity when in the air, unless we jumped.
//This code protects against flying into the air when moving at high speeds.
//Z velocity is set to 50, instead of 0, to help move up certain steps.
//std::cout << "Ground trace missed\n";
// we just transitioned into freefall
//if ( pm->debugLevel )
@ -1421,10 +1427,13 @@ static void PM_GroundTrace( void )
// if the trace didn't hit anything, we are in free fall
if ( trace.fraction == 1.0)
{
if(pm->ps.velocity.z > 50.0f && pm->ps.bSnap && pm->ps.speed > 1000.0f)
pm->ps.velocity.z = 50.0f;
if(pm->ps.snappingImplemented){
if(pm->ps.bSnap && pm->ps.counter <= 0)
PM_GroundTraceMissed();
}
return;
@ -1584,8 +1593,11 @@ void PM_AirMove()
else
PM_SlideMove ( qtrue );
#endif*/
//std::cout << "Moving in the air" << pm->ps.velocity << "\n";
/*bprintf("%i ", */PM_StepSlideMove ( true )/* )*/;
}
static void PM_NoclipMove( void )

@ -28,7 +28,7 @@ static const Ogre::Vector3 halfExtents(14.64f * 2, 14.24f * 2, 33.25f * 2);
#define MAX_CLIP_PLANES 5
#define OVERCLIP 1.001f
//#define STEPSIZE 18 // 18 is way too much
#define STEPSIZE (18 / 2)
#define STEPSIZE (9)
#ifndef M_PI
#define M_PI 3.14159265358979323846f
#endif

Loading…
Cancel
Save