mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-28 20:36:42 +00:00
Remove the unneeded playerMove object from PhysicsSystem
This commit is contained in:
parent
8de2d24d0e
commit
fe0e6c452d
4 changed files with 27 additions and 31 deletions
|
@ -9,8 +9,9 @@
|
||||||
#include <OgreCamera.h>
|
#include <OgreCamera.h>
|
||||||
#include <OgreTextureManager.h>
|
#include <OgreTextureManager.h>
|
||||||
|
|
||||||
#include <libs/openengine/bullet/trace.h>
|
#include <openengine/bullet/trace.h>
|
||||||
#include <libs/openengine/bullet/physic.hpp>
|
#include <openengine/bullet/physic.hpp>
|
||||||
|
#include <openengine/ogre/renderer.hpp>
|
||||||
|
|
||||||
#include <components/nifbullet/bullet_nif_loader.hpp>
|
#include <components/nifbullet/bullet_nif_loader.hpp>
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
|
|
||||||
static const float sMaxSlope = 60.0f;
|
static const float sMaxSlope = 60.0f;
|
||||||
|
static const float sStepSize = 9.0f;
|
||||||
|
|
||||||
class MovementSolver
|
class MovementSolver
|
||||||
{
|
{
|
||||||
|
@ -35,13 +37,13 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
traceResults trace; // no initialization needed
|
traceResults trace; // no initialization needed
|
||||||
|
|
||||||
newtrace(&trace, position+Ogre::Vector3(0.0f,0.0f,STEPSIZE),
|
newtrace(&trace, position+Ogre::Vector3(0.0f,0.0f,sStepSize),
|
||||||
position+Ogre::Vector3(0.0f,0.0f,STEPSIZE)+velocity*remainingTime,
|
position+Ogre::Vector3(0.0f,0.0f,sStepSize)+velocity*remainingTime,
|
||||||
halfExtents, verticalRotation, isInterior, engine);
|
halfExtents, verticalRotation, isInterior, engine);
|
||||||
if(trace.fraction == 0.0f || (trace.fraction != 1.0f && getSlope(trace.planenormal) > sMaxSlope))
|
if(trace.fraction == 0.0f || (trace.fraction != 1.0f && getSlope(trace.planenormal) > sMaxSlope))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
newtrace(&trace, trace.endpos, trace.endpos-Ogre::Vector3(0,0,STEPSIZE), halfExtents, verticalRotation, isInterior, engine);
|
newtrace(&trace, trace.endpos, trace.endpos-Ogre::Vector3(0.0f,0.0f,sStepSize), halfExtents, verticalRotation, isInterior, engine);
|
||||||
if(getSlope(trace.planenormal) < sMaxSlope)
|
if(getSlope(trace.planenormal) < sMaxSlope)
|
||||||
{
|
{
|
||||||
// only step down onto semi-horizontal surfaces. don't step down onto the side of a house or a wall.
|
// only step down onto semi-horizontal surfaces. don't step down onto the side of a house or a wall.
|
||||||
|
@ -197,20 +199,16 @@ namespace MWWorld
|
||||||
PhysicsSystem::PhysicsSystem(OEngine::Render::OgreRenderer &_rend) :
|
PhysicsSystem::PhysicsSystem(OEngine::Render::OgreRenderer &_rend) :
|
||||||
mRender(_rend), mEngine(0), mFreeFly (true)
|
mRender(_rend), mEngine(0), mFreeFly (true)
|
||||||
{
|
{
|
||||||
|
|
||||||
playerphysics = new playerMove;
|
|
||||||
// Create physics. shapeLoader is deleted by the physic engine
|
// Create physics. shapeLoader is deleted by the physic engine
|
||||||
NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader();
|
NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader();
|
||||||
mEngine = new OEngine::Physic::PhysicEngine(shapeLoader);
|
mEngine = new OEngine::Physic::PhysicEngine(shapeLoader);
|
||||||
playerphysics->mEngine = mEngine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicsSystem::~PhysicsSystem()
|
PhysicsSystem::~PhysicsSystem()
|
||||||
{
|
{
|
||||||
delete mEngine;
|
delete mEngine;
|
||||||
delete playerphysics;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OEngine::Physic::PhysicEngine* PhysicsSystem::getEngine()
|
OEngine::Physic::PhysicEngine* PhysicsSystem::getEngine()
|
||||||
{
|
{
|
||||||
return mEngine;
|
return mEngine;
|
||||||
|
@ -279,15 +277,8 @@ namespace MWWorld
|
||||||
|
|
||||||
void PhysicsSystem::setCurrentWater(bool hasWater, int waterHeight)
|
void PhysicsSystem::setCurrentWater(bool hasWater, int waterHeight)
|
||||||
{
|
{
|
||||||
playerphysics->hasWater = hasWater;
|
|
||||||
if(hasWater){
|
|
||||||
playerphysics->waterHeight = waterHeight;
|
|
||||||
}
|
|
||||||
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
|
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
|
||||||
{
|
|
||||||
it->second->setCurrentWater(hasWater, waterHeight);
|
it->second->setCurrentWater(hasWater, waterHeight);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
btVector3 PhysicsSystem::getRayPoint(float extent)
|
btVector3 PhysicsSystem::getRayPoint(float extent)
|
||||||
|
@ -428,14 +419,8 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
||||||
// start positions others than 0, 0, 0
|
// start positions others than 0, 0, 0
|
||||||
if (handle == "player")
|
if (handle != "player")
|
||||||
{
|
|
||||||
playerphysics->ps.origin = position;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
act->setPosition(position);
|
act->setPosition(position);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,7 +459,6 @@ namespace MWWorld
|
||||||
|
|
||||||
bool PhysicsSystem::toggleCollisionMode()
|
bool PhysicsSystem::toggleCollisionMode()
|
||||||
{
|
{
|
||||||
playerphysics->ps.move_type = (playerphysics->ps.move_type == PM_NOCLIP ? PM_NORMAL : PM_NOCLIP);
|
|
||||||
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
|
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
|
||||||
{
|
{
|
||||||
if (it->first=="player")
|
if (it->first=="player")
|
||||||
|
|
|
@ -1,15 +1,27 @@
|
||||||
#ifndef GAME_MWWORLD_PHYSICSSYSTEM_H
|
#ifndef GAME_MWWORLD_PHYSICSSYSTEM_H
|
||||||
#define GAME_MWWORLD_PHYSICSSYSTEM_H
|
#define GAME_MWWORLD_PHYSICSSYSTEM_H
|
||||||
|
|
||||||
|
#include <OgreVector3.h>
|
||||||
|
|
||||||
#include <btBulletCollisionCommon.h>
|
#include <btBulletCollisionCommon.h>
|
||||||
|
|
||||||
#include <openengine/ogre/renderer.hpp>
|
|
||||||
#include <openengine/bullet/pmove.h>
|
namespace OEngine
|
||||||
#include "ptr.hpp"
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
class OgreRenderer;
|
||||||
|
}
|
||||||
|
namespace Physic
|
||||||
|
{
|
||||||
|
class PhysicEngine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class World;
|
class World;
|
||||||
|
class Ptr;
|
||||||
|
|
||||||
class PhysicsSystem
|
class PhysicsSystem
|
||||||
{
|
{
|
||||||
|
@ -74,7 +86,6 @@ namespace MWWorld
|
||||||
OEngine::Render::OgreRenderer &mRender;
|
OEngine::Render::OgreRenderer &mRender;
|
||||||
OEngine::Physic::PhysicEngine* mEngine;
|
OEngine::Physic::PhysicEngine* mEngine;
|
||||||
bool mFreeFly;
|
bool mFreeFly;
|
||||||
playerMove* playerphysics;
|
|
||||||
std::map<std::string, std::string> handleToMesh;
|
std::map<std::string, std::string> handleToMesh;
|
||||||
|
|
||||||
PhysicsSystem (const PhysicsSystem&);
|
PhysicsSystem (const PhysicsSystem&);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "../mwbase/mechanicsmanager.hpp"
|
#include "../mwbase/mechanicsmanager.hpp"
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
|
#include "physicssystem.hpp"
|
||||||
#include "player.hpp"
|
#include "player.hpp"
|
||||||
#include "localscripts.hpp"
|
#include "localscripts.hpp"
|
||||||
#include "esmstore.hpp"
|
#include "esmstore.hpp"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "../mwrender/renderingmanager.hpp"
|
#include "../mwrender/renderingmanager.hpp"
|
||||||
|
|
||||||
#include "physicssystem.hpp"
|
#include "ptr.hpp"
|
||||||
#include "globals.hpp"
|
#include "globals.hpp"
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
|
@ -34,9 +34,9 @@ namespace MWRender
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
|
class PhysicsSystem;
|
||||||
class Player;
|
class Player;
|
||||||
class CellStore;
|
class CellStore;
|
||||||
class Ptr;
|
|
||||||
|
|
||||||
class Scene
|
class Scene
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue