2015-05-12 03:02:15 +02:00
|
|
|
#ifndef OPENMW_MWPHYSICS_PHYSICSSYSTEM_H
|
|
|
|
#define OPENMW_MWPHYSICS_PHYSICSSYSTEM_H
|
2011-08-01 15:55:36 +02:00
|
|
|
|
2020-10-15 06:11:00 +02:00
|
|
|
#include <array>
|
2014-10-05 22:24:11 +02:00
|
|
|
#include <functional>
|
2015-06-03 23:04:35 +02:00
|
|
|
#include <map>
|
2021-08-12 20:54:42 +02:00
|
|
|
#include <memory>
|
2022-01-29 05:04:32 +01:00
|
|
|
#include <optional>
|
2015-11-19 23:33:08 +01:00
|
|
|
#include <set>
|
2022-08-01 00:28:14 +02:00
|
|
|
#include <span>
|
2021-08-12 20:54:42 +02:00
|
|
|
#include <unordered_map>
|
2021-10-07 21:47:05 +02:00
|
|
|
#include <variant>
|
2014-10-05 22:24:11 +02:00
|
|
|
|
2020-05-11 13:37:00 +00:00
|
|
|
#include <osg/BoundingBox>
|
2015-05-03 00:39:01 +02:00
|
|
|
#include <osg/Quat>
|
2020-11-20 13:11:53 +01:00
|
|
|
#include <osg/Timer>
|
|
|
|
#include <osg/ref_ptr>
|
2015-05-03 00:39:01 +02:00
|
|
|
|
2023-05-05 10:31:06 +02:00
|
|
|
#include <components/esm/util.hpp>
|
2022-04-11 19:30:54 +02:00
|
|
|
|
2015-05-10 01:09:00 +02:00
|
|
|
#include "../mwworld/ptr.hpp"
|
2013-08-17 07:48:45 -07:00
|
|
|
|
2015-06-01 01:57:15 +02:00
|
|
|
#include "collisiontype.hpp"
|
2020-08-03 22:44:16 +02:00
|
|
|
#include "raycasting.hpp"
|
2015-06-01 01:57:15 +02:00
|
|
|
|
2015-05-03 00:39:01 +02:00
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Group;
|
2017-03-06 19:04:17 +01:00
|
|
|
class Object;
|
2020-05-22 00:11:23 +02:00
|
|
|
class Stats;
|
2015-05-03 00:39:01 +02:00
|
|
|
}
|
2013-02-07 12:11:10 -08:00
|
|
|
|
2015-05-03 00:39:01 +02:00
|
|
|
namespace MWRender
|
|
|
|
{
|
|
|
|
class DebugDrawer;
|
|
|
|
}
|
|
|
|
|
2015-11-16 23:30:10 +01:00
|
|
|
namespace Resource
|
2015-05-12 03:02:15 +02:00
|
|
|
{
|
|
|
|
class BulletShapeManager;
|
2016-02-09 19:04:59 +01:00
|
|
|
class ResourceSystem;
|
2015-05-12 03:02:15 +02:00
|
|
|
}
|
|
|
|
|
2015-05-27 23:09:38 +02:00
|
|
|
class btCollisionWorld;
|
2015-05-27 22:32:11 +02:00
|
|
|
class btBroadphaseInterface;
|
|
|
|
class btDefaultCollisionConfiguration;
|
|
|
|
class btCollisionDispatcher;
|
|
|
|
class btCollisionObject;
|
|
|
|
class btCollisionShape;
|
2020-10-25 22:33:19 +01:00
|
|
|
class btVector3;
|
2015-05-10 02:08:25 +02:00
|
|
|
|
2015-05-10 01:09:00 +02:00
|
|
|
namespace MWPhysics
|
2011-08-01 15:55:36 +02:00
|
|
|
{
|
2015-05-10 02:08:25 +02:00
|
|
|
class HeightField;
|
2015-05-12 03:02:15 +02:00
|
|
|
class Object;
|
|
|
|
class Actor;
|
2020-10-15 06:11:00 +02:00
|
|
|
class PhysicsTaskScheduler;
|
2019-02-13 11:30:16 +04:00
|
|
|
class Projectile;
|
2020-10-15 06:11:00 +02:00
|
|
|
|
2022-04-04 17:09:52 +00:00
|
|
|
using ActorMap = std::unordered_map<const MWWorld::LiveCellRefBase*, std::shared_ptr<Actor>>;
|
2020-12-05 01:09:43 +01:00
|
|
|
|
2020-11-01 22:30:48 +01:00
|
|
|
struct ContactPoint
|
|
|
|
{
|
|
|
|
MWWorld::Ptr mObject;
|
|
|
|
osg::Vec3f mPoint;
|
|
|
|
osg::Vec3f mNormal;
|
|
|
|
};
|
|
|
|
|
2020-10-15 06:11:00 +02:00
|
|
|
struct LOSRequest
|
|
|
|
{
|
|
|
|
LOSRequest(const std::weak_ptr<Actor>& a1, const std::weak_ptr<Actor>& a2);
|
|
|
|
std::array<std::weak_ptr<Actor>, 2> mActors;
|
|
|
|
std::array<const Actor*, 2> mRawActors;
|
|
|
|
bool mResult;
|
|
|
|
bool mStale;
|
|
|
|
int mAge;
|
|
|
|
};
|
|
|
|
bool operator==(const LOSRequest& lhs, const LOSRequest& rhs) noexcept;
|
|
|
|
|
|
|
|
struct ActorFrameData
|
|
|
|
{
|
2021-07-23 23:08:35 +02:00
|
|
|
ActorFrameData(Actor& actor, bool inert, bool waterCollision, float slowFall, float waterlevel);
|
|
|
|
osg::Vec3f mPosition;
|
|
|
|
osg::Vec3f mInertia;
|
2021-07-23 22:37:55 +02:00
|
|
|
const btCollisionObject* mStandingOn;
|
2021-07-21 19:04:36 +02:00
|
|
|
bool mIsOnGround;
|
|
|
|
bool mIsOnSlope;
|
|
|
|
bool mWalkingOnWater;
|
2021-07-23 23:08:35 +02:00
|
|
|
const bool mInert;
|
|
|
|
btCollisionObject* mCollisionObject;
|
|
|
|
const float mSwimLevel;
|
|
|
|
const float mSlowFall;
|
2021-07-21 19:04:36 +02:00
|
|
|
osg::Vec2f mRotation;
|
2021-07-23 23:08:35 +02:00
|
|
|
osg::Vec3f mMovement;
|
2021-07-22 19:29:20 +02:00
|
|
|
osg::Vec3f mLastStuckPosition;
|
2021-07-23 23:08:35 +02:00
|
|
|
const float mWaterlevel;
|
|
|
|
const float mHalfExtentsZ;
|
|
|
|
float mOldHeight;
|
|
|
|
unsigned int mStuckFrames;
|
|
|
|
const bool mFlying;
|
|
|
|
const bool mWasOnGround;
|
|
|
|
const bool mIsAquatic;
|
|
|
|
const bool mWaterCollision;
|
|
|
|
const bool mSkipCollisionDetection;
|
2020-10-15 06:11:00 +02:00
|
|
|
};
|
|
|
|
|
2021-10-09 18:16:29 +02:00
|
|
|
struct ProjectileFrameData
|
|
|
|
{
|
|
|
|
explicit ProjectileFrameData(Projectile& projectile);
|
|
|
|
osg::Vec3f mPosition;
|
|
|
|
osg::Vec3f mMovement;
|
|
|
|
const btCollisionObject* mCaster;
|
|
|
|
const btCollisionObject* mCollisionObject;
|
|
|
|
Projectile* mProjectile;
|
|
|
|
};
|
|
|
|
|
2020-10-15 06:11:00 +02:00
|
|
|
struct WorldFrameData
|
|
|
|
{
|
|
|
|
WorldFrameData();
|
|
|
|
bool mIsInStorm;
|
|
|
|
osg::Vec3f mStormDirection;
|
|
|
|
};
|
2015-05-10 02:08:25 +02:00
|
|
|
|
2022-01-29 05:04:32 +01:00
|
|
|
template <class Ptr, class FrameData>
|
|
|
|
class SimulationImpl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit SimulationImpl(const std::weak_ptr<Ptr>& ptr, FrameData&& data)
|
|
|
|
: mPtr(ptr)
|
|
|
|
, mData(data)
|
|
|
|
{
|
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2022-01-29 05:04:32 +01:00
|
|
|
std::optional<std::pair<std::shared_ptr<Ptr>, std::reference_wrapper<FrameData>>> lock()
|
|
|
|
{
|
|
|
|
if (auto locked = mPtr.lock())
|
|
|
|
return { { std::move(locked), std::ref(mData) } };
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2022-01-29 05:04:32 +01:00
|
|
|
private:
|
|
|
|
std::weak_ptr<Ptr> mPtr;
|
|
|
|
FrameData mData;
|
|
|
|
};
|
|
|
|
|
|
|
|
using ActorSimulation = SimulationImpl<Actor, ActorFrameData>;
|
|
|
|
using ProjectileSimulation = SimulationImpl<Projectile, ProjectileFrameData>;
|
2021-10-09 18:16:29 +02:00
|
|
|
using Simulation = std::variant<ActorSimulation, ProjectileSimulation>;
|
2021-10-07 21:47:05 +02:00
|
|
|
|
2020-08-03 22:44:16 +02:00
|
|
|
class PhysicsSystem : public RayCastingInterface
|
2011-08-01 15:55:36 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-05-12 16:24:53 +02:00
|
|
|
PhysicsSystem(Resource::ResourceSystem* resourceSystem, osg::ref_ptr<osg::Group> parentNode);
|
2020-08-26 12:34:27 +04:00
|
|
|
virtual ~PhysicsSystem();
|
2014-10-05 22:24:11 +02:00
|
|
|
|
2021-09-30 22:58:16 +02:00
|
|
|
Resource::BulletShapeManager* getShapeManager();
|
2015-05-12 19:02:56 +02:00
|
|
|
|
2021-08-31 16:25:45 +02:00
|
|
|
void enableWater(float height);
|
2021-02-25 23:12:14 +00:00
|
|
|
void setWaterHeight(float height);
|
2019-02-13 11:30:16 +04:00
|
|
|
void disableWater();
|
|
|
|
|
2015-05-12 19:02:56 +02:00
|
|
|
void addObject(const MWWorld::Ptr& ptr, const std::string& mesh, osg::Quat rotation,
|
|
|
|
int collisionType = CollisionType_World);
|
|
|
|
void addActor(const MWWorld::Ptr& ptr, const std::string& mesh);
|
|
|
|
|
|
|
|
int addProjectile(
|
2015-12-18 17:36:14 +01:00
|
|
|
const MWWorld::Ptr& caster, const osg::Vec3f& position, const std::string& mesh, bool computeRadius);
|
|
|
|
void setCaster(int projectileId, const MWWorld::Ptr& caster);
|
|
|
|
void removeProjectile(const int projectileId);
|
2016-03-05 15:56:19 +01:00
|
|
|
|
|
|
|
void updatePtr(const MWWorld::Ptr& old, const MWWorld::Ptr& updated);
|
2015-05-12 03:02:15 +02:00
|
|
|
|
2020-10-23 20:27:07 +02:00
|
|
|
Actor* getActor(const MWWorld::Ptr& ptr);
|
|
|
|
const Actor* getActor(const MWWorld::ConstPtr& ptr) const;
|
|
|
|
|
2021-01-29 16:51:05 +04:00
|
|
|
const Object* getObject(const MWWorld::ConstPtr& ptr) const;
|
2015-05-12 03:02:15 +02:00
|
|
|
|
2021-02-05 14:55:42 +01:00
|
|
|
Projectile* getProjectile(int projectileId) const;
|
2015-05-12 03:02:15 +02:00
|
|
|
|
2021-10-11 19:23:08 +02:00
|
|
|
// Object or Actor
|
|
|
|
void remove(const MWWorld::Ptr& ptr);
|
2012-03-13 17:09:50 +01:00
|
|
|
|
|
|
|
void updateScale(const MWWorld::Ptr& ptr);
|
|
|
|
void updateRotation(const MWWorld::Ptr& ptr, osg::Quat rotate);
|
2015-05-12 03:02:15 +02:00
|
|
|
void updatePosition(const MWWorld::Ptr& ptr);
|
2012-03-13 17:09:50 +01:00
|
|
|
|
2018-03-14 01:49:08 +03:00
|
|
|
void addHeightField(const float* heights, int x, int y, int size, int verts, float minH, float maxH,
|
|
|
|
const osg::Object* holdObject);
|
|
|
|
|
2011-08-01 15:55:36 +02:00
|
|
|
void removeHeightField(int x, int y);
|
2013-08-20 11:31:49 -07:00
|
|
|
|
2023-08-13 02:02:00 +02:00
|
|
|
const HeightField* getHeightField(int x, int y) const;
|
2021-07-31 23:26:10 +02:00
|
|
|
|
|
|
|
bool toggleCollisionMode();
|
2014-06-23 20:43:24 +02:00
|
|
|
|
2015-12-18 17:56:48 +01:00
|
|
|
/// Determine new position based on all queued movements, then clear the list.
|
2020-11-01 22:30:48 +01:00
|
|
|
void stepSimulation(
|
2017-02-10 02:43:49 +01:00
|
|
|
float dt, bool skipSimulation, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats);
|
2013-02-05 12:45:10 -08:00
|
|
|
|
2015-12-18 17:38:21 +01:00
|
|
|
/// Apply new positions to actors
|
2020-10-14 11:32:12 +02:00
|
|
|
void moveActors();
|
2015-06-07 17:00:00 +02:00
|
|
|
void debugDraw();
|
2012-03-25 20:52:56 +02:00
|
|
|
|
2015-12-18 17:56:48 +01:00
|
|
|
std::vector<MWWorld::Ptr> getCollisions(const MWWorld::ConstPtr& ptr, int collisionGroup,
|
|
|
|
int collisionMask) const; ///< get handles this object collides with
|
2020-11-01 22:30:48 +01:00
|
|
|
std::vector<ContactPoint> getCollisionsPoints(
|
|
|
|
const MWWorld::ConstPtr& ptr, int collisionGroup, int collisionMask) const;
|
2020-08-03 22:44:16 +02:00
|
|
|
osg::Vec3f traceDown(const MWWorld::Ptr& ptr, const osg::Vec3f& position, float maxHeight);
|
2015-11-18 19:00:43 +01:00
|
|
|
|
2021-09-27 19:34:26 +00:00
|
|
|
/// @param me Optional, a Ptr to ignore in the list of results. targets are actors to filter for, ignoring all
|
2015-11-03 18:15:47 +01:00
|
|
|
/// other actors.
|
2021-09-27 19:34:26 +00:00
|
|
|
RayCastingResult castRay(const osg::Vec3f& from, const osg::Vec3f& to,
|
|
|
|
const MWWorld::ConstPtr& ignore = MWWorld::ConstPtr(),
|
|
|
|
const std::vector<MWWorld::Ptr>& targets = std::vector<MWWorld::Ptr>(), int mask = CollisionType_Default,
|
|
|
|
int group = 0xff) const override;
|
2022-11-06 20:49:59 +01:00
|
|
|
using RayCastingInterface::castRay;
|
2015-06-01 15:34:46 +02:00
|
|
|
|
2020-10-22 23:57:53 +02:00
|
|
|
RayCastingResult castSphere(const osg::Vec3f& from, const osg::Vec3f& to, float radius,
|
|
|
|
int mask = CollisionType_Default, int group = 0xff) const override;
|
2012-07-25 20:25:53 +04:00
|
|
|
|
2015-06-01 02:40:42 +02:00
|
|
|
/// Return true if actor1 can see actor2.
|
|
|
|
bool getLineOfSight(const MWWorld::ConstPtr& actor1, const MWWorld::ConstPtr& actor2) const override;
|
|
|
|
|
2016-11-15 00:20:17 +09:00
|
|
|
bool isOnGround(const MWWorld::Ptr& actor);
|
|
|
|
|
2015-12-18 17:36:14 +01:00
|
|
|
bool canMoveToWaterSurface(const MWWorld::ConstPtr& actor, const float waterlevel);
|
2015-06-01 21:41:13 +02:00
|
|
|
|
2019-03-03 14:45:36 +03:00
|
|
|
/// Get physical half extents (scaled) of the given actor.
|
|
|
|
osg::Vec3f getHalfExtents(const MWWorld::ConstPtr& actor) const;
|
|
|
|
|
2015-11-01 21:45:58 +01:00
|
|
|
/// Get physical half extents (not scaled) of the given actor.
|
2015-12-18 17:36:14 +01:00
|
|
|
osg::Vec3f getOriginalHalfExtents(const MWWorld::ConstPtr& actor) const;
|
2015-11-03 18:15:47 +01:00
|
|
|
|
|
|
|
/// @see MWPhysics::Actor::getRenderingHalfExtents
|
2016-02-13 02:56:41 +01:00
|
|
|
osg::Vec3f getRenderingHalfExtents(const MWWorld::ConstPtr& actor) const;
|
2015-11-01 21:45:58 +01:00
|
|
|
|
2020-05-11 13:37:00 +00:00
|
|
|
/// Get the position of the collision shape for the actor. Use together with getHalfExtents() to get the
|
|
|
|
/// collision bounds in world space.
|
|
|
|
/// @note The collision shape's origin is in its center, so the position returned can be described as center of
|
|
|
|
/// the actor collision box in world space.
|
|
|
|
osg::Vec3f getCollisionObjectPosition(const MWWorld::ConstPtr& actor) const;
|
|
|
|
|
2021-07-31 23:26:10 +02:00
|
|
|
/// Get bounding box in world space of the given object.
|
2015-05-12 03:02:15 +02:00
|
|
|
osg::BoundingBox getBoundingBox(const MWWorld::ConstPtr& object) const;
|
2013-08-17 07:48:45 -07:00
|
|
|
|
2014-08-13 16:23:34 +02:00
|
|
|
/// Queues velocity movement for a Ptr. If a Ptr is already queued, its velocity will
|
|
|
|
/// be overwritten. Valid until the next call to stepSimulation
|
2023-12-27 19:11:49 +00:00
|
|
|
void queueObjectMovement(const MWWorld::Ptr& ptr, const osg::Vec3f& velocity);
|
2014-08-13 16:23:34 +02:00
|
|
|
|
2014-07-29 19:01:40 +02:00
|
|
|
/// Clear the queued movements list without applying.
|
2015-12-18 17:56:48 +01:00
|
|
|
void clearQueuedMovement();
|
2014-07-29 19:01:40 +02:00
|
|
|
|
|
|
|
/// Return true if \a actor has been standing on \a object in this frame
|
|
|
|
/// This will trigger whenever the object is directly below the actor.
|
2015-12-18 17:56:48 +01:00
|
|
|
/// It doesn't matter if the actor is stationary or moving.
|
|
|
|
bool isActorStandingOn(const MWWorld::Ptr& actor, const MWWorld::ConstPtr& object) const;
|
2014-07-29 19:01:40 +02:00
|
|
|
|
|
|
|
/// Get the handle of all actors standing on \a object in this frame.
|
2015-12-18 17:56:48 +01:00
|
|
|
void getActorsStandingOn(const MWWorld::ConstPtr& object, std::vector<MWWorld::Ptr>& out) const;
|
2014-07-29 19:01:40 +02:00
|
|
|
|
|
|
|
/// Return true if \a actor has collided with \a object in this frame.
|
|
|
|
/// This will detect running into objects, but will not detect climbing stairs, stepping up a small object, etc.
|
2015-12-18 17:56:48 +01:00
|
|
|
bool isActorCollidingWith(const MWWorld::Ptr& actor, const MWWorld::ConstPtr& object) const;
|
2014-07-29 19:01:40 +02:00
|
|
|
|
2015-05-03 00:39:01 +02:00
|
|
|
/// Get the handle of all actors colliding with \a object in this frame.
|
|
|
|
void getActorsCollidingWith(const MWWorld::ConstPtr& object, std::vector<MWWorld::Ptr>& out) const;
|
|
|
|
|
2015-11-20 19:22:31 +01:00
|
|
|
bool toggleDebugRendering();
|
|
|
|
|
|
|
|
/// Mark the given object as a 'non-solid' object. A non-solid object means that
|
|
|
|
/// \a isOnSolidGround will return false for actors standing on that object.
|
|
|
|
void markAsNonSolid(const MWWorld::ConstPtr& ptr);
|
2018-05-26 17:44:25 +03:00
|
|
|
|
2018-09-22 12:57:50 +04:00
|
|
|
bool isOnSolidGround(const MWWorld::Ptr& actor) const;
|
|
|
|
|
2018-05-26 17:44:25 +03:00
|
|
|
void updateAnimatedCollisionShape(const MWWorld::Ptr& object);
|
|
|
|
|
|
|
|
template <class Function>
|
2021-09-29 00:42:29 +02:00
|
|
|
void forEachAnimatedObject(Function&& function) const
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2022-08-01 00:28:14 +02:00
|
|
|
std::for_each(mAnimatedObjects.begin(), mAnimatedObjects.end(), function);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2020-02-09 18:24:08 +01:00
|
|
|
|
2020-10-25 22:33:19 +01:00
|
|
|
bool isAreaOccupiedByOtherActor(const osg::Vec3f& position, const float radius,
|
|
|
|
std::span<const MWWorld::ConstPtr> ignore, std::vector<MWWorld::Ptr>* occupyingActors) const;
|
2020-05-22 00:11:23 +02:00
|
|
|
|
2011-08-01 15:55:36 +02:00
|
|
|
void reportStats(unsigned int frameNumber, osg::Stats& stats) const;
|
|
|
|
void reportCollision(const btVector3& position, const btVector3& normal);
|
2012-08-17 10:10:37 +04:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
private:
|
2014-10-05 22:24:11 +02:00
|
|
|
void updateWater();
|
|
|
|
|
2022-09-07 01:55:51 +02:00
|
|
|
void prepareSimulation(bool willSimulate, std::vector<Simulation>& simulations);
|
2020-10-15 06:11:00 +02:00
|
|
|
|
2020-10-14 11:32:12 +02:00
|
|
|
std::unique_ptr<btBroadphaseInterface> mBroadphase;
|
|
|
|
std::unique_ptr<btDefaultCollisionConfiguration> mCollisionConfiguration;
|
|
|
|
std::unique_ptr<btCollisionDispatcher> mDispatcher;
|
2021-03-26 23:43:49 +01:00
|
|
|
std::unique_ptr<btCollisionWorld> mCollisionWorld;
|
Process movement queue in one or several background threads
Before movement calculation, the main thread prepare a
vector of ActorFrameData, which contains all data necessary to perform
the simulation, and feed it to the solver. At the same time it fetches
the result from the previous background simulation, which in turn is
used by the game mechanics.
Other functions of the physics system (weapon hit for instance)
interrupt the background simulation, with some exceptions described
below.
The number of threads is controlled by the numeric setting
[Physics]
async num threads
In case 'async num threads' > 1 and Bullet doesn't support multiple threads,
1 async thread will be used. 0 means synchronous solver.
Additional settings (will be silently switched off if async num threads = 0)
[Physics]
defer aabb update
Update AABBs of actors and objects in the background thread(s). It is not an especially
costly operation, but it needs exclusive access to the collision world, which blocks
other operations. Since AABB needs to be updated for collision detection, one can queue
them to defer update before start of the movement solver. Extensive tests on as much
as one installation (mine) show no drawback having that switched on.
[Physics]
lineofsight keep inactive cache
Control for how long (how many frames) the line of sight (LOS) request will be kept updated.
When a request for LOS is made for the first time, the background threads are stopped to
service it. From now on, the LOS will be refreshed preemptively as part of the background
routine until it is not required for lineofsight keep inactive cache frames. This mean
that subsequent request will not interrupt the background computation.
2020-10-15 06:11:44 +02:00
|
|
|
std::unique_ptr<PhysicsTaskScheduler> mTaskScheduler;
|
2015-05-10 02:08:25 +02:00
|
|
|
|
2017-04-28 17:30:26 +02:00
|
|
|
std::unique_ptr<Resource::BulletShapeManager> mShapeManager;
|
2016-02-06 16:57:54 +01:00
|
|
|
Resource::ResourceSystem* mResourceSystem;
|
2015-05-12 03:02:15 +02:00
|
|
|
|
2021-08-12 20:54:42 +02:00
|
|
|
using ObjectMap = std::unordered_map<const MWWorld::LiveCellRefBase*, std::shared_ptr<Object>>;
|
2015-05-12 03:02:15 +02:00
|
|
|
ObjectMap mObjects;
|
2022-04-04 17:09:52 +00:00
|
|
|
|
|
|
|
std::map<Object*, bool> mAnimatedObjects; // stores pointers to elements in mObjects
|
2015-11-19 23:33:08 +01:00
|
|
|
|
2015-05-12 03:02:15 +02:00
|
|
|
ActorMap mActors;
|
|
|
|
|
2020-10-23 20:27:07 +02:00
|
|
|
using ProjectileMap = std::map<int, std::shared_ptr<Projectile>>;
|
2019-02-13 11:30:16 +04:00
|
|
|
ProjectileMap mProjectiles;
|
|
|
|
|
2020-12-25 18:20:42 +01:00
|
|
|
using HeightFieldMap = std::map<std::pair<int, int>, std::unique_ptr<HeightField>>;
|
2015-05-10 02:08:25 +02:00
|
|
|
HeightFieldMap mHeightFields;
|
|
|
|
|
2015-05-03 00:39:01 +02:00
|
|
|
bool mDebugDrawEnabled;
|
|
|
|
|
2013-08-20 11:31:49 -07:00
|
|
|
float mTimeAccum;
|
|
|
|
|
2020-10-23 20:27:07 +02:00
|
|
|
unsigned int mProjectileId;
|
2019-02-13 11:30:16 +04:00
|
|
|
|
2014-10-05 22:24:11 +02:00
|
|
|
float mWaterHeight;
|
2017-04-20 00:28:27 +09:00
|
|
|
bool mWaterEnabled;
|
2014-10-05 22:24:11 +02:00
|
|
|
|
2017-04-28 17:30:26 +02:00
|
|
|
std::unique_ptr<btCollisionObject> mWaterCollisionObject;
|
|
|
|
std::unique_ptr<btCollisionShape> mWaterCollisionShape;
|
2014-10-05 22:24:11 +02:00
|
|
|
|
2017-04-28 17:30:26 +02:00
|
|
|
std::unique_ptr<MWRender::DebugDrawer> mDebugDrawer;
|
2015-05-03 00:39:01 +02:00
|
|
|
|
|
|
|
osg::ref_ptr<osg::Group> mParentNode;
|
|
|
|
|
2017-09-26 21:19:53 +04:00
|
|
|
float mPhysicsDt;
|
|
|
|
|
2022-09-07 01:55:51 +02:00
|
|
|
std::size_t mSimulationsCounter = 0;
|
|
|
|
std::array<std::vector<Simulation>, 2> mSimulations;
|
2022-09-08 01:54:05 +02:00
|
|
|
std::vector<std::pair<MWWorld::Ptr, osg::Vec3f>> mActorsPositions;
|
2022-09-07 01:55:51 +02:00
|
|
|
|
2011-08-22 21:34:51 +02:00
|
|
|
PhysicsSystem(const PhysicsSystem&);
|
|
|
|
PhysicsSystem& operator=(const PhysicsSystem&);
|
2011-08-01 15:55:36 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|