2011-08-01 13:55:36 +00:00
|
|
|
#ifndef GAME_MWWORLD_PHYSICSSYSTEM_H
|
|
|
|
#define GAME_MWWORLD_PHYSICSSYSTEM_H
|
|
|
|
|
2013-02-07 20:11:10 +00:00
|
|
|
#include <OgreVector3.h>
|
|
|
|
|
2013-02-07 05:47:09 +00:00
|
|
|
#include <btBulletCollisionCommon.h>
|
|
|
|
|
2013-08-17 14:48:45 +00:00
|
|
|
#include "ptr.hpp"
|
|
|
|
|
2013-02-07 20:11:10 +00:00
|
|
|
|
|
|
|
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;
|
2013-08-17 14:48:45 +00:00
|
|
|
|
|
|
|
typedef std::vector<std::pair<Ptr,Ogre::Vector3> > PtrVelocityList;
|
2011-08-01 13:55:36 +00:00
|
|
|
|
|
|
|
class PhysicsSystem
|
|
|
|
{
|
|
|
|
public:
|
2012-01-29 15:31:18 +00:00
|
|
|
PhysicsSystem (OEngine::Render::OgreRenderer &_rend);
|
2011-08-01 13:55:36 +00:00
|
|
|
~PhysicsSystem ();
|
2011-08-22 19:34:51 +00:00
|
|
|
|
2013-03-14 02:04:02 +00:00
|
|
|
void addObject (const MWWorld::Ptr& ptr, bool placeable=false);
|
2011-08-22 19:34:51 +00:00
|
|
|
|
2012-11-05 18:40:02 +00:00
|
|
|
void addActor (const MWWorld::Ptr& ptr);
|
2011-08-22 19:34:51 +00:00
|
|
|
|
2012-03-13 16:09:50 +00:00
|
|
|
void addHeightField (float* heights,
|
|
|
|
int x, int y, float yoffset,
|
|
|
|
float triSize, float sqrtVerts);
|
|
|
|
|
|
|
|
void removeHeightField (int x, int y);
|
|
|
|
|
2012-11-05 18:40:02 +00:00
|
|
|
// 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
|
|
|
|
2012-11-05 18:40:02 +00:00
|
|
|
void moveObject (const MWWorld::Ptr& ptr);
|
2011-08-22 19:34:51 +00:00
|
|
|
|
2012-11-05 18:40:02 +00:00
|
|
|
void rotateObject (const MWWorld::Ptr& ptr);
|
2011-08-22 19:34:51 +00:00
|
|
|
|
2012-11-05 18:40:02 +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-08-20 18:31:49 +00:00
|
|
|
|
2013-04-28 12:59:15 +00:00
|
|
|
std::vector<std::string> getCollisions(const MWWorld::Ptr &ptr); ///< get handles this object collides with
|
2013-04-03 21:55:57 +00:00
|
|
|
Ogre::Vector3 traceDown(const MWWorld::Ptr &ptr);
|
2013-02-05 20:45:10 +00:00
|
|
|
|
2013-08-25 22:10:22 +00:00
|
|
|
std::pair<float, std::string> getFacedHandle(float queryDistance);
|
2013-08-23 14:01:30 +00:00
|
|
|
std::pair<std::string,Ogre::Vector3> getHitContact(const std::string &name,
|
|
|
|
const Ogre::Vector3 &origin,
|
|
|
|
const Ogre::Quaternion &orientation,
|
|
|
|
float queryDistance);
|
2013-01-08 07:00:00 +00:00
|
|
|
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
|
|
|
|
2013-05-05 23:46:50 +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);
|
|
|
|
|
2012-05-15 14:47:23 +00:00
|
|
|
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)
|
|
|
|
|
2012-01-29 15:31:18 +00:00
|
|
|
OEngine::Physic::PhysicEngine* getEngine();
|
2012-04-30 21:55:22 +00:00
|
|
|
|
2012-07-26 12:14:11 +00:00
|
|
|
bool getObjectAABB(const MWWorld::Ptr &ptr, Ogre::Vector3 &min, Ogre::Vector3 &max);
|
2012-07-24 14:52:08 +00:00
|
|
|
|
2013-08-17 14:48:45 +00:00
|
|
|
/// 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:
|
2012-08-17 06:10:37 +00:00
|
|
|
|
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
|
|
|
|
2013-08-17 14:48:45 +00:00
|
|
|
PtrVelocityList mMovementQueue;
|
|
|
|
PtrVelocityList mMovementResults;
|
|
|
|
|
2013-08-20 18:31:49 +00:00
|
|
|
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
|