2015-05-12 01:02:15 +00:00
|
|
|
#ifndef OPENMW_MWPHYSICS_ACTOR_H
|
|
|
|
#define OPENMW_MWPHYSICS_ACTOR_H
|
|
|
|
|
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 04:11:44 +00:00
|
|
|
#include <atomic>
|
2015-05-12 01:02:15 +00:00
|
|
|
#include <memory>
|
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 04:11:44 +00:00
|
|
|
#include <mutex>
|
2015-05-12 01:02:15 +00:00
|
|
|
|
2018-03-18 11:32:45 +00:00
|
|
|
#include "ptrholder.hpp"
|
2015-05-12 01:02:15 +00:00
|
|
|
|
2020-10-14 13:47:50 +00:00
|
|
|
#include <LinearMath/btTransform.h>
|
2015-05-12 01:02:15 +00:00
|
|
|
#include <osg/Vec3f>
|
2015-05-12 14:49:21 +00:00
|
|
|
#include <osg/Quat>
|
2015-05-12 01:02:15 +00:00
|
|
|
|
|
|
|
class btCollisionShape;
|
|
|
|
class btCollisionObject;
|
2017-02-10 00:58:27 +00:00
|
|
|
class btConvexShape;
|
2015-05-12 01:02:15 +00:00
|
|
|
|
2015-11-16 22:30:10 +00:00
|
|
|
namespace Resource
|
2015-05-12 01:02:15 +00:00
|
|
|
{
|
2016-02-09 17:51:17 +00:00
|
|
|
class BulletShape;
|
2015-05-12 01:02:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWPhysics
|
|
|
|
{
|
2020-10-14 09:32:12 +00:00
|
|
|
class PhysicsTaskScheduler;
|
2015-05-12 01:02:15 +00:00
|
|
|
|
2020-10-14 09:32:12 +00:00
|
|
|
class Actor final : public PtrHolder
|
2015-05-12 01:02:15 +00:00
|
|
|
{
|
|
|
|
public:
|
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 04:11:44 +00:00
|
|
|
Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, PhysicsTaskScheduler* scheduler);
|
2020-10-14 09:32:12 +00:00
|
|
|
~Actor() override;
|
2015-05-12 01:02:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the collisionMode for this actor. If disabled, the actor can fly and clip geometry.
|
|
|
|
*/
|
|
|
|
void enableCollisionMode(bool collision);
|
|
|
|
|
|
|
|
bool getCollisionMode() const
|
|
|
|
{
|
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 04:11:44 +00:00
|
|
|
return mInternalCollisionMode.load(std::memory_order_acquire);
|
2015-05-12 01:02:15 +00:00
|
|
|
}
|
|
|
|
|
2017-02-10 00:58:27 +00:00
|
|
|
btConvexShape* getConvexShape() const { return mConvexShape; }
|
|
|
|
|
2015-05-12 01:02:15 +00:00
|
|
|
/**
|
|
|
|
* Enables or disables the *external* collision body. If disabled, other actors will not collide with this actor.
|
|
|
|
*/
|
|
|
|
void enableCollisionBody(bool collision);
|
|
|
|
|
|
|
|
void updateScale();
|
2021-01-29 12:51:13 +00:00
|
|
|
void updateRotation();
|
2016-02-13 01:56:41 +00:00
|
|
|
|
2017-02-23 21:34:42 +00:00
|
|
|
/**
|
|
|
|
* Return true if the collision shape looks the same no matter how its Z rotated.
|
|
|
|
*/
|
|
|
|
bool isRotationallyInvariant() const;
|
|
|
|
|
2020-11-01 16:14:59 +00:00
|
|
|
/**
|
|
|
|
* Used by the physics simulation to store the simulation result. Used in conjunction with mWorldPosition
|
|
|
|
* to account for e.g. scripted movements
|
|
|
|
*/
|
2020-11-28 19:45:23 +00:00
|
|
|
void setSimulationPosition(const osg::Vec3f& position);
|
|
|
|
osg::Vec3f getSimulationPosition() const;
|
2015-05-12 01:02:15 +00:00
|
|
|
|
2016-02-13 01:56:41 +00:00
|
|
|
void updateCollisionObjectPosition();
|
|
|
|
|
2015-05-12 01:02:15 +00:00
|
|
|
/**
|
2015-11-01 20:45:58 +00:00
|
|
|
* Returns the half extents of the collision body (scaled according to collision scale)
|
2015-05-12 01:02:15 +00:00
|
|
|
*/
|
|
|
|
osg::Vec3f getHalfExtents() const;
|
|
|
|
|
2019-03-03 11:45:36 +00:00
|
|
|
/**
|
|
|
|
* Returns the half extents of the collision body (not scaled)
|
|
|
|
*/
|
|
|
|
osg::Vec3f getOriginalHalfExtents() const;
|
|
|
|
|
2020-12-27 22:16:11 +00:00
|
|
|
/// Returns the mesh translation, scaled and rotated as necessary
|
|
|
|
osg::Vec3f getScaledMeshTranslation() const;
|
|
|
|
|
2015-11-03 17:15:47 +00:00
|
|
|
/**
|
|
|
|
* Returns the position of the collision body
|
|
|
|
* @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.
|
|
|
|
*/
|
2016-02-13 01:56:41 +00:00
|
|
|
osg::Vec3f getCollisionObjectPosition() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store the current position into mPreviousPosition, then move to this position.
|
2020-12-18 07:18:07 +00:00
|
|
|
* Returns true if the new position is different.
|
2016-02-13 01:56:41 +00:00
|
|
|
*/
|
2020-12-18 07:18:07 +00:00
|
|
|
bool setPosition(const osg::Vec3f& position);
|
2021-03-13 08:52:05 +00:00
|
|
|
|
|
|
|
// force set actor position to be as in Ptr::RefData
|
2020-12-19 19:25:46 +00:00
|
|
|
void updatePosition();
|
2021-03-13 08:52:05 +00:00
|
|
|
|
|
|
|
// register a position offset that will be applied during simulation.
|
2021-05-01 12:13:17 +00:00
|
|
|
void adjustPosition(const osg::Vec3f& offset, bool ignoreCollisions);
|
2016-02-13 01:56:41 +00:00
|
|
|
|
2021-03-13 08:52:05 +00:00
|
|
|
// apply position offset. Can't be called during simulation
|
|
|
|
void applyOffsetChange();
|
|
|
|
|
2015-11-03 17:15:47 +00:00
|
|
|
osg::Vec3f getPosition() const;
|
|
|
|
|
2016-02-13 01:56:41 +00:00
|
|
|
osg::Vec3f getPreviousPosition() const;
|
|
|
|
|
2015-11-01 20:45:58 +00:00
|
|
|
/**
|
|
|
|
* Returns the half extents of the collision body (scaled according to rendering scale)
|
|
|
|
* @note The reason we need this extra method is because of an inconsistency in MW - NPC race scales aren't applied to the collision shape,
|
|
|
|
* most likely to make environment collision testing easier. However in some cases (swimming level) we want the actual scale.
|
|
|
|
*/
|
|
|
|
osg::Vec3f getRenderingHalfExtents() const;
|
|
|
|
|
2015-05-12 01:02:15 +00:00
|
|
|
/**
|
|
|
|
* Sets the current amount of inertial force (incl. gravity) affecting this physic actor
|
|
|
|
*/
|
|
|
|
void setInertialForce(const osg::Vec3f &force);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the current amount of inertial force (incl. gravity) affecting this physic actor
|
|
|
|
*/
|
|
|
|
const osg::Vec3f &getInertialForce() const
|
|
|
|
{
|
|
|
|
return mForce;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setOnGround(bool grounded);
|
|
|
|
|
|
|
|
bool getOnGround() const
|
|
|
|
{
|
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 04:11:44 +00:00
|
|
|
return mInternalCollisionMode.load(std::memory_order_acquire) && mOnGround.load(std::memory_order_acquire);
|
2015-05-12 01:02:15 +00:00
|
|
|
}
|
|
|
|
|
2017-02-06 03:46:44 +00:00
|
|
|
void setOnSlope(bool slope);
|
|
|
|
|
|
|
|
bool getOnSlope() const
|
|
|
|
{
|
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 04:11:44 +00:00
|
|
|
return mInternalCollisionMode.load(std::memory_order_acquire) && mOnSlope.load(std::memory_order_acquire);
|
2017-02-06 03:46:44 +00:00
|
|
|
}
|
|
|
|
|
2015-05-12 01:02:15 +00:00
|
|
|
btCollisionObject* getCollisionObject() const
|
|
|
|
{
|
|
|
|
return mCollisionObject.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Sets whether this actor should be able to collide with the water surface
|
|
|
|
void setCanWaterWalk(bool waterWalk);
|
|
|
|
|
|
|
|
/// Sets whether this actor has been walking on the water surface in the last frame
|
|
|
|
void setWalkingOnWater(bool walkingOnWater);
|
|
|
|
bool isWalkingOnWater() const;
|
|
|
|
|
2020-11-07 17:30:52 +00:00
|
|
|
MWWorld::Ptr getStandingOnPtr() const;
|
|
|
|
void setStandingOnPtr(const MWWorld::Ptr& ptr);
|
|
|
|
|
2021-03-21 01:14:56 +00:00
|
|
|
unsigned int getStuckFrames() const
|
|
|
|
{
|
|
|
|
return mStuckFrames;
|
|
|
|
}
|
|
|
|
void setStuckFrames(unsigned int frames)
|
|
|
|
{
|
|
|
|
mStuckFrames = frames;
|
|
|
|
}
|
|
|
|
|
|
|
|
const osg::Vec3f &getLastStuckPosition() const
|
|
|
|
{
|
|
|
|
return mLastStuckPosition;
|
|
|
|
}
|
|
|
|
void setLastStuckPosition(osg::Vec3f position)
|
|
|
|
{
|
|
|
|
mLastStuckPosition = position;
|
|
|
|
}
|
|
|
|
|
2021-05-01 12:13:17 +00:00
|
|
|
bool skipCollisions();
|
|
|
|
|
2021-05-01 18:28:17 +00:00
|
|
|
void setVelocity(osg::Vec3f velocity);
|
|
|
|
osg::Vec3f velocity();
|
|
|
|
|
2015-05-12 01:02:15 +00:00
|
|
|
private:
|
2020-11-07 17:30:52 +00:00
|
|
|
MWWorld::Ptr mStandingOnPtr;
|
2015-05-12 01:02:15 +00:00
|
|
|
/// Removes then re-adds the collision object to the dynamics world
|
|
|
|
void updateCollisionMask();
|
2016-12-16 19:22:07 +00:00
|
|
|
void addCollisionMask(int collisionMask);
|
2020-10-14 09:32:12 +00:00
|
|
|
int getCollisionMask() const;
|
2015-05-12 01:02:15 +00:00
|
|
|
|
|
|
|
bool mCanWaterWalk;
|
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 04:11:44 +00:00
|
|
|
std::atomic<bool> mWalkingOnWater;
|
2015-05-12 01:02:15 +00:00
|
|
|
|
2017-02-23 21:34:42 +00:00
|
|
|
bool mRotationallyInvariant;
|
|
|
|
|
2017-04-28 15:30:26 +00:00
|
|
|
std::unique_ptr<btCollisionShape> mShape;
|
2017-02-10 00:58:27 +00:00
|
|
|
btConvexShape* mConvexShape;
|
2015-05-12 01:02:15 +00:00
|
|
|
|
2017-04-28 15:30:26 +00:00
|
|
|
std::unique_ptr<btCollisionObject> mCollisionObject;
|
2015-05-12 01:02:15 +00:00
|
|
|
|
|
|
|
osg::Vec3f mMeshTranslation;
|
|
|
|
osg::Vec3f mHalfExtents;
|
2015-05-12 14:49:21 +00:00
|
|
|
osg::Quat mRotation;
|
2015-05-12 01:02:15 +00:00
|
|
|
|
|
|
|
osg::Vec3f mScale;
|
2015-11-01 20:45:58 +00:00
|
|
|
osg::Vec3f mRenderingScale;
|
2020-11-28 19:45:23 +00:00
|
|
|
osg::Vec3f mSimulationPosition;
|
2015-05-12 01:02:15 +00:00
|
|
|
osg::Vec3f mPosition;
|
2016-02-13 01:56:41 +00:00
|
|
|
osg::Vec3f mPreviousPosition;
|
2020-12-18 07:18:07 +00:00
|
|
|
osg::Vec3f mPositionOffset;
|
2021-05-01 18:28:17 +00:00
|
|
|
osg::Vec3f mVelocity;
|
2020-12-18 07:18:07 +00:00
|
|
|
bool mWorldPositionChanged;
|
2021-05-01 12:13:17 +00:00
|
|
|
bool mSkipCollisions;
|
2020-10-14 13:47:50 +00:00
|
|
|
btTransform mLocalTransform;
|
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 04:11:44 +00:00
|
|
|
mutable std::mutex mPositionMutex;
|
2015-05-12 01:02:15 +00:00
|
|
|
|
2021-03-21 01:14:56 +00:00
|
|
|
unsigned int mStuckFrames;
|
|
|
|
osg::Vec3f mLastStuckPosition;
|
|
|
|
|
2015-05-12 01:02:15 +00:00
|
|
|
osg::Vec3f mForce;
|
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 04:11:44 +00:00
|
|
|
std::atomic<bool> mOnGround;
|
|
|
|
std::atomic<bool> mOnSlope;
|
|
|
|
std::atomic<bool> mInternalCollisionMode;
|
2015-05-12 01:02:15 +00:00
|
|
|
bool mExternalCollisionMode;
|
|
|
|
|
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 04:11:44 +00:00
|
|
|
PhysicsTaskScheduler* mTaskScheduler;
|
2015-05-12 01:02:15 +00:00
|
|
|
|
|
|
|
Actor(const Actor&);
|
|
|
|
Actor& operator=(const Actor&);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|