OpenMW
|
#include <physicssystem.hpp>
Classes | |
struct | RayResult |
Public Member Functions | |
PhysicsSystem (Resource::ResourceSystem *resourceSystem, osg::ref_ptr< osg::Group > parentNode) | |
~PhysicsSystem () | |
void | setUnrefQueue (SceneUtil::UnrefQueue *unrefQueue) |
Resource::BulletShapeManager * | getShapeManager () |
void | enableWater (float height) |
void | setWaterHeight (float height) |
void | disableWater () |
void | addObject (const MWWorld::Ptr &ptr, const std::string &mesh, int collisionType=CollisionType_World) |
void | addActor (const MWWorld::Ptr &ptr, const std::string &mesh) |
void | updatePtr (const MWWorld::Ptr &old, const MWWorld::Ptr &updated) |
Actor * | getActor (const MWWorld::Ptr &ptr) |
const Actor * | getActor (const MWWorld::ConstPtr &ptr) const |
const Object * | getObject (const MWWorld::ConstPtr &ptr) const |
void | remove (const MWWorld::Ptr &ptr) |
void | updateScale (const MWWorld::Ptr &ptr) |
void | updateRotation (const MWWorld::Ptr &ptr) |
void | updatePosition (const MWWorld::Ptr &ptr) |
void | addHeightField (const float *heights, int x, int y, float triSize, float sqrtVerts) |
void | removeHeightField (int x, int y) |
bool | toggleCollisionMode () |
void | stepSimulation (float dt) |
void | debugDraw () |
std::vector< MWWorld::Ptr > | getCollisions (const MWWorld::ConstPtr &ptr, int collisionGroup, int collisionMask) const |
get handles this object collides with More... | |
osg::Vec3f | traceDown (const MWWorld::Ptr &ptr, float maxHeight) |
std::pair< MWWorld::Ptr, osg::Vec3f > | getHitContact (const MWWorld::ConstPtr &actor, const osg::Vec3f &origin, const osg::Quat &orientation, float queryDistance) |
float | getHitDistance (const osg::Vec3f &point, const MWWorld::ConstPtr &target) const |
RayResult | castRay (const osg::Vec3f &from, const osg::Vec3f &to, MWWorld::ConstPtr ignore=MWWorld::ConstPtr(), int mask=CollisionType_World|CollisionType_HeightMap|CollisionType_Actor|CollisionType_Door, int group=0xff) const |
RayResult | castSphere (const osg::Vec3f &from, const osg::Vec3f &to, float radius) |
bool | getLineOfSight (const MWWorld::ConstPtr &actor1, const MWWorld::ConstPtr &actor2) const |
Return true if actor1 can see actor2. More... | |
bool | isOnGround (const MWWorld::Ptr &actor) |
bool | canMoveToWaterSurface (const MWWorld::ConstPtr &actor, const float waterlevel) |
osg::Vec3f | getHalfExtents (const MWWorld::ConstPtr &actor) const |
Get physical half extents (scaled) of the given actor. More... | |
osg::Vec3f | getRenderingHalfExtents (const MWWorld::ConstPtr &actor) const |
osg::Vec3f | getCollisionObjectPosition (const MWWorld::ConstPtr &actor) const |
void | queueObjectMovement (const MWWorld::Ptr &ptr, const osg::Vec3f &velocity) |
const PtrVelocityList & | applyQueuedMovement (float dt) |
Apply all queued movements, then clear the list. More... | |
void | clearQueuedMovement () |
Clear the queued movements list without applying. More... | |
bool | isActorStandingOn (const MWWorld::Ptr &actor, const MWWorld::ConstPtr &object) const |
void | getActorsStandingOn (const MWWorld::ConstPtr &object, std::vector< MWWorld::Ptr > &out) const |
Get the handle of all actors standing on object in this frame. More... | |
bool | isActorCollidingWith (const MWWorld::Ptr &actor, const MWWorld::ConstPtr &object) const |
void | getActorsCollidingWith (const MWWorld::ConstPtr &object, std::vector< MWWorld::Ptr > &out) const |
Get the handle of all actors colliding with object in this frame. More... | |
bool | toggleDebugRendering () |
void | markAsNonSolid (const MWWorld::ConstPtr &ptr) |
bool | isOnSolidGround (const MWWorld::Ptr &actor) const |
Private Types | |
typedef std::map < MWWorld::ConstPtr, Object * > | ObjectMap |
typedef std::map < MWWorld::ConstPtr, Actor * > | ActorMap |
typedef std::map< std::pair < int, int >, HeightField * > | HeightFieldMap |
typedef std::map< MWWorld::Ptr, MWWorld::Ptr > | CollisionMap |
Private Member Functions | |
void | updateWater () |
void | updateCollisionMapPtr (CollisionMap &map, const MWWorld::Ptr &old, const MWWorld::Ptr &updated) |
PhysicsSystem (const PhysicsSystem &) | |
PhysicsSystem & | operator= (const PhysicsSystem &) |
Private Attributes | |
osg::ref_ptr < SceneUtil::UnrefQueue > | mUnrefQueue |
btBroadphaseInterface * | mBroadphase |
btDefaultCollisionConfiguration * | mCollisionConfiguration |
btCollisionDispatcher * | mDispatcher |
btCollisionWorld * | mCollisionWorld |
std::auto_ptr < Resource::BulletShapeManager > | mShapeManager |
Resource::ResourceSystem * | mResourceSystem |
ObjectMap | mObjects |
std::set< Object * > | mAnimatedObjects |
ActorMap | mActors |
HeightFieldMap | mHeightFields |
bool | mDebugDrawEnabled |
CollisionMap | mStandingCollisions |
PtrVelocityList | mMovementQueue |
PtrVelocityList | mMovementResults |
float | mTimeAccum |
float | mWaterHeight |
float | mWaterEnabled |
std::auto_ptr< btCollisionObject > | mWaterCollisionObject |
std::auto_ptr< btCollisionShape > | mWaterCollisionShape |
std::auto_ptr < MWRender::DebugDrawer > | mDebugDrawer |
osg::ref_ptr< osg::Group > | mParentNode |
|
private |
|
private |
|
private |
|
private |
MWPhysics::PhysicsSystem::PhysicsSystem | ( | Resource::ResourceSystem * | resourceSystem, |
osg::ref_ptr< osg::Group > | parentNode | ||
) |
MWPhysics::PhysicsSystem::~PhysicsSystem | ( | ) |
|
private |
void MWPhysics::PhysicsSystem::addActor | ( | const MWWorld::Ptr & | ptr, |
const std::string & | mesh | ||
) |
void MWPhysics::PhysicsSystem::addHeightField | ( | const float * | heights, |
int | x, | ||
int | y, | ||
float | triSize, | ||
float | sqrtVerts | ||
) |
void MWPhysics::PhysicsSystem::addObject | ( | const MWWorld::Ptr & | ptr, |
const std::string & | mesh, | ||
int | collisionType = CollisionType_World |
||
) |
const PtrVelocityList & MWPhysics::PhysicsSystem::applyQueuedMovement | ( | float | dt | ) |
Apply all queued movements, then clear the list.
bool MWPhysics::PhysicsSystem::canMoveToWaterSurface | ( | const MWWorld::ConstPtr & | actor, |
const float | waterlevel | ||
) |
PhysicsSystem::RayResult MWPhysics::PhysicsSystem::castRay | ( | const osg::Vec3f & | from, |
const osg::Vec3f & | to, | ||
MWWorld::ConstPtr | ignore = MWWorld::ConstPtr() , |
||
int | mask = CollisionType_World|CollisionType_HeightMap|CollisionType_Actor|CollisionType_Door , |
||
int | group = 0xff |
||
) | const |
me | Optional, a Ptr to ignore in the list of results |
PhysicsSystem::RayResult MWPhysics::PhysicsSystem::castSphere | ( | const osg::Vec3f & | from, |
const osg::Vec3f & | to, | ||
float | radius | ||
) |
void MWPhysics::PhysicsSystem::clearQueuedMovement | ( | ) |
Clear the queued movements list without applying.
void MWPhysics::PhysicsSystem::debugDraw | ( | ) |
void MWPhysics::PhysicsSystem::disableWater | ( | ) |
void MWPhysics::PhysicsSystem::enableWater | ( | float | height | ) |
Actor * MWPhysics::PhysicsSystem::getActor | ( | const MWWorld::Ptr & | ptr | ) |
const Actor * MWPhysics::PhysicsSystem::getActor | ( | const MWWorld::ConstPtr & | ptr | ) | const |
void MWPhysics::PhysicsSystem::getActorsCollidingWith | ( | const MWWorld::ConstPtr & | object, |
std::vector< MWWorld::Ptr > & | out | ||
) | const |
Get the handle of all actors colliding with object in this frame.
void MWPhysics::PhysicsSystem::getActorsStandingOn | ( | const MWWorld::ConstPtr & | object, |
std::vector< MWWorld::Ptr > & | out | ||
) | const |
Get the handle of all actors standing on object in this frame.
osg::Vec3f MWPhysics::PhysicsSystem::getCollisionObjectPosition | ( | const MWWorld::ConstPtr & | actor | ) | const |
Get the position of the collision shape for the actor. Use together with getHalfExtents() to get the collision bounds in world space.
std::vector< MWWorld::Ptr > MWPhysics::PhysicsSystem::getCollisions | ( | const MWWorld::ConstPtr & | ptr, |
int | collisionGroup, | ||
int | collisionMask | ||
) | const |
get handles this object collides with
osg::Vec3f MWPhysics::PhysicsSystem::getHalfExtents | ( | const MWWorld::ConstPtr & | actor | ) | const |
Get physical half extents (scaled) of the given actor.
std::pair< MWWorld::Ptr, osg::Vec3f > MWPhysics::PhysicsSystem::getHitContact | ( | const MWWorld::ConstPtr & | actor, |
const osg::Vec3f & | origin, | ||
const osg::Quat & | orientation, | ||
float | queryDistance | ||
) |
float MWPhysics::PhysicsSystem::getHitDistance | ( | const osg::Vec3f & | point, |
const MWWorld::ConstPtr & | target | ||
) | const |
Get distance from point to the collision shape of target. Uses a raycast to find where the target vector hits the collision shape and then calculates distance from the intersection point. This can be used to find out how much nearer we need to move to the target for a "getHitContact" to be successful.
bool MWPhysics::PhysicsSystem::getLineOfSight | ( | const MWWorld::ConstPtr & | actor1, |
const MWWorld::ConstPtr & | actor2 | ||
) | const |
Return true if actor1 can see actor2.
const Object * MWPhysics::PhysicsSystem::getObject | ( | const MWWorld::ConstPtr & | ptr | ) | const |
osg::Vec3f MWPhysics::PhysicsSystem::getRenderingHalfExtents | ( | const MWWorld::ConstPtr & | actor | ) | const |
Resource::BulletShapeManager * MWPhysics::PhysicsSystem::getShapeManager | ( | ) |
bool MWPhysics::PhysicsSystem::isActorCollidingWith | ( | const MWWorld::Ptr & | actor, |
const MWWorld::ConstPtr & | object | ||
) | const |
Return true if actor has collided with object in this frame. This will detect running into objects, but will not detect climbing stairs, stepping up a small object, etc.
bool MWPhysics::PhysicsSystem::isActorStandingOn | ( | const MWWorld::Ptr & | actor, |
const MWWorld::ConstPtr & | object | ||
) | const |
Return true if actor has been standing on object in this frame This will trigger whenever the object is directly below the actor. It doesn't matter if the actor is stationary or moving.
bool MWPhysics::PhysicsSystem::isOnGround | ( | const MWWorld::Ptr & | actor | ) |
bool MWPhysics::PhysicsSystem::isOnSolidGround | ( | const MWWorld::Ptr & | actor | ) | const |
void MWPhysics::PhysicsSystem::markAsNonSolid | ( | const MWWorld::ConstPtr & | ptr | ) |
Mark the given object as a 'non-solid' object. A non-solid object means that isOnSolidGround will return false for actors standing on that object.
|
private |
void MWPhysics::PhysicsSystem::queueObjectMovement | ( | const MWWorld::Ptr & | ptr, |
const osg::Vec3f & | velocity | ||
) |
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 MWPhysics::PhysicsSystem::remove | ( | const MWWorld::Ptr & | ptr | ) |
void MWPhysics::PhysicsSystem::setUnrefQueue | ( | SceneUtil::UnrefQueue * | unrefQueue | ) |
void MWPhysics::PhysicsSystem::setWaterHeight | ( | float | height | ) |
void MWPhysics::PhysicsSystem::stepSimulation | ( | float | dt | ) |
bool MWPhysics::PhysicsSystem::toggleCollisionMode | ( | ) |
bool MWPhysics::PhysicsSystem::toggleDebugRendering | ( | ) |
osg::Vec3f MWPhysics::PhysicsSystem::traceDown | ( | const MWWorld::Ptr & | ptr, |
float | maxHeight | ||
) |
|
private |
void MWPhysics::PhysicsSystem::updatePosition | ( | const MWWorld::Ptr & | ptr | ) |
void MWPhysics::PhysicsSystem::updatePtr | ( | const MWWorld::Ptr & | old, |
const MWWorld::Ptr & | updated | ||
) |
void MWPhysics::PhysicsSystem::updateRotation | ( | const MWWorld::Ptr & | ptr | ) |
void MWPhysics::PhysicsSystem::updateScale | ( | const MWWorld::Ptr & | ptr | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |