mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:47:30 +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 <PerfStat.h>
|
||||||
|
|
||||||
#include "EntityDynamicInterface.h"
|
|
||||||
#include "EntityItem.h"
|
#include "EntityItem.h"
|
||||||
#include "EntityTree.h"
|
#include "EntityTree.h"
|
||||||
|
|
||||||
|
@ -59,10 +58,10 @@ public:
|
||||||
|
|
||||||
void updateEntities();
|
void updateEntities();
|
||||||
|
|
||||||
virtual void addDynamic(EntityDynamicPointer dynamic);
|
// FIXME: remove these
|
||||||
virtual void removeDynamic(const QUuid dynamicID);
|
virtual void addDynamic(EntityDynamicPointer dynamic) {}
|
||||||
virtual void removeDynamics(QList<QUuid> dynamicIDsToRemove);
|
virtual void removeDynamic(const QUuid dynamicID) {}
|
||||||
virtual void applyDynamicChanges();
|
virtual void applyDynamicChanges() {};
|
||||||
|
|
||||||
/// \param entity pointer to EntityItem to be added
|
/// \param entity pointer to EntityItem to be added
|
||||||
/// \sideeffect sets relevant backpointers in entity, but maybe later when appropriate data structures are locked
|
/// \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 _entitiesToSort; // entities moved by simulation (and might need resort in EntityTree)
|
||||||
SetOfEntities _simpleKinematicEntities; // entities undergoing non-colliding kinematic motion
|
SetOfEntities _simpleKinematicEntities; // entities undergoing non-colliding kinematic motion
|
||||||
QList<EntityDynamicPointer> _dynamicsToAdd;
|
|
||||||
QSet<QUuid> _dynamicsToRemove;
|
|
||||||
QMutex _dynamicsMutex { QMutex::Recursive };
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SetOfEntities _deadEntities; // dead entities that might still be in the _entityTree
|
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";
|
"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() {
|
void PhysicalEntitySimulation::applyDynamicChanges() {
|
||||||
QList<EntityDynamicPointer> dynamicsFailedToAdd;
|
QList<EntityDynamicPointer> dynamicsFailedToAdd;
|
||||||
if (_physicsEngine) {
|
if (_physicsEngine) {
|
||||||
|
@ -666,8 +681,8 @@ void PhysicalEntitySimulation::applyDynamicChanges() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// applyDynamicChanges will clear _dynamicsToRemove and _dynamicsToAdd
|
_dynamicsToAdd.clear();
|
||||||
EntitySimulation::applyDynamicChanges();
|
_dynamicsToRemove.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// put back the ones that couldn't yet be added
|
// put back the ones that couldn't yet be added
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <btBulletDynamicsCommon.h>
|
#include <btBulletDynamicsCommon.h>
|
||||||
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
|
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
|
||||||
|
|
||||||
|
#include <EntityDynamicInterface.h>
|
||||||
#include <EntityItem.h>
|
#include <EntityItem.h>
|
||||||
#include <EntitySimulation.h>
|
#include <EntitySimulation.h>
|
||||||
#include <workload/Space.h>
|
#include <workload/Space.h>
|
||||||
|
@ -58,8 +59,10 @@ public:
|
||||||
void init(EntityTreePointer tree, PhysicsEnginePointer engine, EntityEditPacketSender* packetSender);
|
void init(EntityTreePointer tree, PhysicsEnginePointer engine, EntityEditPacketSender* packetSender);
|
||||||
void setWorkloadSpace(const workload::SpacePointer space) { _space = space; }
|
void setWorkloadSpace(const workload::SpacePointer space) { _space = space; }
|
||||||
|
|
||||||
virtual void addDynamic(EntityDynamicPointer dynamic) override;
|
void addDynamic(EntityDynamicPointer dynamic) override;
|
||||||
virtual void applyDynamicChanges() override;
|
void removeDynamic(const QUuid dynamicID) override;
|
||||||
|
//void removeDynamics(QList<QUuid> dynamicIDsToRemove);
|
||||||
|
void applyDynamicChanges() override;
|
||||||
|
|
||||||
virtual void takeDeadEntities(SetOfEntities& deadEntities) override;
|
virtual void takeDeadEntities(SetOfEntities& deadEntities) override;
|
||||||
void takeDeadAvatarEntities(SetOfEntities& deadEntities);
|
void takeDeadAvatarEntities(SetOfEntities& deadEntities);
|
||||||
|
@ -123,6 +126,11 @@ private:
|
||||||
VectorOfEntityMotionStates _bids;
|
VectorOfEntityMotionStates _bids;
|
||||||
SetOfEntities _deadAvatarEntities;
|
SetOfEntities _deadAvatarEntities;
|
||||||
std::vector<EntityItemPointer> _entitiesToDeleteLater;
|
std::vector<EntityItemPointer> _entitiesToDeleteLater;
|
||||||
|
|
||||||
|
QList<EntityDynamicPointer> _dynamicsToAdd;
|
||||||
|
QSet<QUuid> _dynamicsToRemove;
|
||||||
|
QMutex _dynamicsMutex { QMutex::Recursive };
|
||||||
|
|
||||||
workload::SpacePointer _space;
|
workload::SpacePointer _space;
|
||||||
uint64_t _nextBidExpiry;
|
uint64_t _nextBidExpiry;
|
||||||
uint32_t _lastStepSendPackets { 0 };
|
uint32_t _lastStepSendPackets { 0 };
|
||||||
|
|
Loading…
Reference in a new issue