mirror of
https://github.com/lubosz/overte.git
synced 2025-04-10 04:28:59 +02:00
unravel more spaghetti into PhysicalEntitySimulation
This commit is contained in:
parent
86c60204fd
commit
72ba94f2cd
4 changed files with 32 additions and 36 deletions
|
@ -260,26 +260,3 @@ void EntitySimulation::moveSimpleKinematics(uint64_t now) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EntitySimulation::addDynamic(EntityDynamicPointer dynamic) {
|
||||
QMutexLocker lock(&_dynamicsMutex);
|
||||
_dynamicsToAdd += dynamic;
|
||||
}
|
||||
|
||||
void EntitySimulation::removeDynamic(const QUuid dynamicID) {
|
||||
QMutexLocker lock(&_dynamicsMutex);
|
||||
_dynamicsToRemove += dynamicID;
|
||||
}
|
||||
|
||||
void EntitySimulation::removeDynamics(QList<QUuid> dynamicIDsToRemove) {
|
||||
QMutexLocker lock(&_dynamicsMutex);
|
||||
foreach(QUuid uuid, dynamicIDsToRemove) {
|
||||
_dynamicsToRemove.insert(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
void EntitySimulation::applyDynamicChanges() {
|
||||
QMutexLocker lock(&_dynamicsMutex);
|
||||
_dynamicsToAdd.clear();
|
||||
_dynamicsToRemove.clear();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include <PerfStat.h>
|
||||
|
||||
#include "EntityDynamicInterface.h"
|
||||
#include "EntityItem.h"
|
||||
#include "EntityTree.h"
|
||||
|
||||
|
@ -59,10 +58,10 @@ public:
|
|||
|
||||
void updateEntities();
|
||||
|
||||
virtual void addDynamic(EntityDynamicPointer dynamic);
|
||||
virtual void removeDynamic(const QUuid dynamicID);
|
||||
virtual void removeDynamics(QList<QUuid> dynamicIDsToRemove);
|
||||
virtual void applyDynamicChanges();
|
||||
// FIXME: remove these
|
||||
virtual void addDynamic(EntityDynamicPointer dynamic) {}
|
||||
virtual void removeDynamic(const QUuid dynamicID) {}
|
||||
virtual void applyDynamicChanges() {};
|
||||
|
||||
/// \param entity pointer to EntityItem to be added
|
||||
/// \sideeffect sets relevant backpointers in entity, but maybe later when appropriate data structures are locked
|
||||
|
@ -102,9 +101,6 @@ protected:
|
|||
|
||||
SetOfEntities _entitiesToSort; // entities moved by simulation (and might need resort in EntityTree)
|
||||
SetOfEntities _simpleKinematicEntities; // entities undergoing non-colliding kinematic motion
|
||||
QList<EntityDynamicPointer> _dynamicsToAdd;
|
||||
QSet<QUuid> _dynamicsToRemove;
|
||||
QMutex _dynamicsMutex { QMutex::Recursive };
|
||||
|
||||
protected:
|
||||
SetOfEntities _deadEntities; // dead entities that might still be in the _entityTree
|
||||
|
|
|
@ -648,10 +648,25 @@ void PhysicalEntitySimulation::addDynamic(EntityDynamicPointer dynamic) {
|
|||
"dynamic that was already in _physicsEngine";
|
||||
}
|
||||
}
|
||||
EntitySimulation::addDynamic(dynamic);
|
||||
QMutexLocker lock(&_dynamicsMutex);
|
||||
_dynamicsToAdd += dynamic;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicalEntitySimulation::removeDynamic(const QUuid dynamicID) {
|
||||
QMutexLocker lock(&_dynamicsMutex);
|
||||
_dynamicsToRemove += dynamicID;
|
||||
}
|
||||
|
||||
/*
|
||||
void PhysicalEntitySimulation::removeDynamics(QList<QUuid> dynamicIDsToRemove) {
|
||||
QMutexLocker lock(&_dynamicsMutex);
|
||||
foreach(QUuid uuid, dynamicIDsToRemove) {
|
||||
_dynamicsToRemove.insert(uuid);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void PhysicalEntitySimulation::applyDynamicChanges() {
|
||||
QList<EntityDynamicPointer> dynamicsFailedToAdd;
|
||||
if (_physicsEngine) {
|
||||
|
@ -666,8 +681,8 @@ void PhysicalEntitySimulation::applyDynamicChanges() {
|
|||
}
|
||||
}
|
||||
}
|
||||
// applyDynamicChanges will clear _dynamicsToRemove and _dynamicsToAdd
|
||||
EntitySimulation::applyDynamicChanges();
|
||||
_dynamicsToAdd.clear();
|
||||
_dynamicsToRemove.clear();
|
||||
}
|
||||
|
||||
// put back the ones that couldn't yet be added
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <btBulletDynamicsCommon.h>
|
||||
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
|
||||
|
||||
#include <EntityDynamicInterface.h>
|
||||
#include <EntityItem.h>
|
||||
#include <EntitySimulation.h>
|
||||
#include <workload/Space.h>
|
||||
|
@ -58,8 +59,10 @@ public:
|
|||
void init(EntityTreePointer tree, PhysicsEnginePointer engine, EntityEditPacketSender* packetSender);
|
||||
void setWorkloadSpace(const workload::SpacePointer space) { _space = space; }
|
||||
|
||||
virtual void addDynamic(EntityDynamicPointer dynamic) override;
|
||||
virtual void applyDynamicChanges() override;
|
||||
void addDynamic(EntityDynamicPointer dynamic) override;
|
||||
void removeDynamic(const QUuid dynamicID) override;
|
||||
//void removeDynamics(QList<QUuid> dynamicIDsToRemove);
|
||||
void applyDynamicChanges() override;
|
||||
|
||||
virtual void takeDeadEntities(SetOfEntities& deadEntities) override;
|
||||
void takeDeadAvatarEntities(SetOfEntities& deadEntities);
|
||||
|
@ -123,6 +126,11 @@ private:
|
|||
VectorOfEntityMotionStates _bids;
|
||||
SetOfEntities _deadAvatarEntities;
|
||||
std::vector<EntityItemPointer> _entitiesToDeleteLater;
|
||||
|
||||
QList<EntityDynamicPointer> _dynamicsToAdd;
|
||||
QSet<QUuid> _dynamicsToRemove;
|
||||
QMutex _dynamicsMutex { QMutex::Recursive };
|
||||
|
||||
workload::SpacePointer _space;
|
||||
uint64_t _nextBidExpiry;
|
||||
uint32_t _lastStepSendPackets { 0 };
|
||||
|
|
Loading…
Reference in a new issue