1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-10 15:39:02 +00:00
OpenMW/apps/openmw/mwworld/physicssystem.hpp

103 lines
3.6 KiB
C++
Raw Normal View History

2011-08-01 13:55:36 +00:00
#ifndef GAME_MWWORLD_PHYSICSSYSTEM_H
#define GAME_MWWORLD_PHYSICSSYSTEM_H
#include <OgreVector3.h>
2013-02-07 05:47:09 +00:00
#include <btBulletCollisionCommon.h>
#include "ptr.hpp"
namespace OEngine
{
namespace Render
{
class OgreRenderer;
}
namespace Physic
{
class PhysicEngine;
}
}
2011-08-01 13:55:36 +00:00
namespace MWWorld
{
2013-02-07 05:47:09 +00:00
class World;
typedef std::vector<std::pair<Ptr,Ogre::Vector3> > PtrVelocityList;
2011-08-01 13:55:36 +00:00
class PhysicsSystem
{
public:
PhysicsSystem (OEngine::Render::OgreRenderer &_rend);
2011-08-01 13:55:36 +00:00
~PhysicsSystem ();
2011-08-22 19:34:51 +00:00
void addObject (const MWWorld::Ptr& ptr, bool placeable=false);
2011-08-22 19:34:51 +00:00
void addActor (const MWWorld::Ptr& ptr);
2011-08-22 19:34:51 +00:00
void addHeightField (float* heights,
int x, int y, float yoffset,
float triSize, float sqrtVerts);
void removeHeightField (int x, int y);
// have to keep this as handle for now as unloadcell only knows scenenode names
2011-08-01 13:55:36 +00:00
void removeObject (const std::string& handle);
2011-08-22 19:34:51 +00:00
void moveObject (const MWWorld::Ptr& ptr);
2011-08-22 19:34:51 +00:00
void rotateObject (const MWWorld::Ptr& ptr);
2011-08-22 19:34:51 +00:00
void scaleObject (const MWWorld::Ptr& ptr);
2011-08-22 19:34:51 +00:00
2011-08-01 13:55:36 +00:00
bool toggleCollisionMode();
2013-04-28 12:59:15 +00:00
std::vector<std::string> getCollisions(const MWWorld::Ptr &ptr); ///< get handles this object collides with
Ogre::Vector3 traceDown(const MWWorld::Ptr &ptr);
2013-08-25 22:10:22 +00:00
std::pair<float, std::string> getFacedHandle(float queryDistance);
std::pair<std::string,Ogre::Vector3> getHitContact(const std::string &name,
const Ogre::Vector3 &origin,
const Ogre::Quaternion &orientation,
float queryDistance);
std::vector < std::pair <float, std::string> > getFacedHandles (float queryDistance);
std::vector < std::pair <float, std::string> > getFacedHandles (float mouseX, float mouseY, float queryDistance);
2012-03-25 18:52:56 +00:00
// cast ray, return true if it hit something. if raycasringObjectOnlt is set to false, it ignores NPCs and objects with no collisions.
2013-05-07 18:42:21 +00:00
bool castRay(const Ogre::Vector3& from, const Ogre::Vector3& to, bool raycastingObjectOnly = true,bool ignoreHeightMap = false);
2011-08-22 19:34:51 +00:00
2012-07-25 16:25:53 +00:00
std::pair<bool, Ogre::Vector3>
castRay(const Ogre::Vector3 &orig, const Ogre::Vector3 &dir, float len);
std::pair<bool, Ogre::Vector3> castRay(float mouseX, float mouseY);
///< cast ray from the mouse, return true if it hit something and the first result (in OGRE coordinates)
OEngine::Physic::PhysicEngine* getEngine();
bool getObjectAABB(const MWWorld::Ptr &ptr, Ogre::Vector3 &min, Ogre::Vector3 &max);
/// Queues velocity movement for a Ptr. If a Ptr is already queued, its velocity will
/// be overwritten. Valid until the next call to applyQueuedMovement.
void queueObjectMovement(const Ptr &ptr, const Ogre::Vector3 &velocity);
const PtrVelocityList& applyQueuedMovement(float dt);
2011-08-01 13:55:36 +00:00
private:
2011-08-01 13:55:36 +00:00
OEngine::Render::OgreRenderer &mRender;
OEngine::Physic::PhysicEngine* mEngine;
2012-06-18 00:56:10 +00:00
std::map<std::string, std::string> handleToMesh;
2012-04-03 02:08:46 +00:00
PtrVelocityList mMovementQueue;
PtrVelocityList mMovementResults;
float mTimeAccum;
2011-08-22 19:34:51 +00:00
PhysicsSystem (const PhysicsSystem&);
PhysicsSystem& operator= (const PhysicsSystem&);
2011-08-01 13:55:36 +00:00
};
}
#endif