mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 06:48:04 +02:00
main actions interface is in EntityItem. changes in actions are queued up and applied before simulation step
This commit is contained in:
parent
f84e970c48
commit
a31a5a1554
7 changed files with 37 additions and 22 deletions
|
@ -2461,8 +2461,9 @@ void Application::update(float deltaTime) {
|
||||||
|
|
||||||
|
|
||||||
updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process...
|
updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process...
|
||||||
|
|
||||||
DependencyManager::get<AvatarManager>()->updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them...
|
//loop through all the other avatars and simulate them...
|
||||||
|
DependencyManager::get<AvatarManager>()->updateOtherAvatars(deltaTime);
|
||||||
|
|
||||||
updateCamera(deltaTime); // handle various camera tweaks like off axis projection
|
updateCamera(deltaTime); // handle various camera tweaks like off axis projection
|
||||||
updateDialogs(deltaTime); // update various stats dialogs if present
|
updateDialogs(deltaTime); // update various stats dialogs if present
|
||||||
|
@ -2476,6 +2477,7 @@ void Application::update(float deltaTime) {
|
||||||
_physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete());
|
_physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete());
|
||||||
_physicsEngine.addObjects(_entitySimulation.getObjectsToAdd());
|
_physicsEngine.addObjects(_entitySimulation.getObjectsToAdd());
|
||||||
_physicsEngine.changeObjects(_entitySimulation.getObjectsToChange());
|
_physicsEngine.changeObjects(_entitySimulation.getObjectsToChange());
|
||||||
|
_entitySimulation.applyActionChanges();
|
||||||
_entitySimulation.unlock();
|
_entitySimulation.unlock();
|
||||||
|
|
||||||
AvatarManager* avatarManager = DependencyManager::get<AvatarManager>().data();
|
AvatarManager* avatarManager = DependencyManager::get<AvatarManager>().data();
|
||||||
|
@ -2498,7 +2500,8 @@ void Application::update(float deltaTime) {
|
||||||
|
|
||||||
if (!_aboutToQuit) {
|
if (!_aboutToQuit) {
|
||||||
PerformanceTimer perfTimer("entities");
|
PerformanceTimer perfTimer("entities");
|
||||||
// Collision events (and their scripts) must not be handled when we're locked, above. (That would risk deadlock.)
|
// Collision events (and their scripts) must not be handled when we're locked, above. (That would risk
|
||||||
|
// deadlock.)
|
||||||
_entitySimulation.handleCollisionEvents(collisionEvents);
|
_entitySimulation.handleCollisionEvents(collisionEvents);
|
||||||
// NOTE: the _entities.update() call below will wait for lock
|
// NOTE: the _entities.update() call below will wait for lock
|
||||||
// and will simulate entity motion (the EntityTree has been given an EntitySimulation).
|
// and will simulate entity motion (the EntityTree has been given an EntitySimulation).
|
||||||
|
@ -2511,11 +2514,12 @@ void Application::update(float deltaTime) {
|
||||||
PerformanceTimer perfTimer("overlays");
|
PerformanceTimer perfTimer("overlays");
|
||||||
_overlays.update(deltaTime);
|
_overlays.update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("myAvatar");
|
PerformanceTimer perfTimer("myAvatar");
|
||||||
updateMyAvatarLookAtPosition();
|
updateMyAvatarLookAtPosition();
|
||||||
DependencyManager::get<AvatarManager>()->updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
|
// Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
|
||||||
|
DependencyManager::get<AvatarManager>()->updateMyAvatar(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -1369,8 +1369,6 @@ void EntityItem::removeAction(const QUuid actionID) {
|
||||||
simulation->removeAction(action->getID());
|
simulation->removeAction(action->getID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete action;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
virtual void addAction(EntityActionInterface* action) {}
|
virtual void addAction(EntityActionInterface* action) {}
|
||||||
virtual void removeAction(const QUuid actionID) {}
|
virtual void removeAction(const QUuid actionID) {}
|
||||||
virtual void removeActions(QList<QUuid> actionIDsToRemove) {}
|
virtual void removeActions(QList<QUuid> actionIDsToRemove) {}
|
||||||
|
virtual void applyActionChanges() {}
|
||||||
|
|
||||||
protected: // these only called by the EntityTree?
|
protected: // these only called by the EntityTree?
|
||||||
/// \param entity pointer to EntityItem to be added
|
/// \param entity pointer to EntityItem to be added
|
||||||
|
@ -116,7 +117,7 @@ protected:
|
||||||
SetOfEntities _entitiesToDelete; // entities simulation decided needed to be deleted (EntityTree will actually delete)
|
SetOfEntities _entitiesToDelete; // entities simulation decided needed to be deleted (EntityTree will actually delete)
|
||||||
SetOfEntities _simpleKinematicEntities; // entities undergoing non-colliding kinematic motion
|
SetOfEntities _simpleKinematicEntities; // entities undergoing non-colliding kinematic motion
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void moveSimpleKinematics();
|
void moveSimpleKinematics();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -233,19 +233,33 @@ void PhysicalEntitySimulation::handleCollisionEvents(CollisionEvents& collisionE
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicalEntitySimulation::addAction(EntityActionInterface* action) {
|
void PhysicalEntitySimulation::addAction(EntityActionInterface* action) {
|
||||||
if (_physicsEngine) {
|
// if (_physicsEngine) {
|
||||||
_physicsEngine->addAction(action);
|
// _physicsEngine->addAction(action);
|
||||||
}
|
// }
|
||||||
|
_actionsToAdd += action;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicalEntitySimulation::removeAction(const QUuid actionID) {
|
void PhysicalEntitySimulation::removeAction(const QUuid actionID) {
|
||||||
if (_physicsEngine) {
|
// if (_physicsEngine) {
|
||||||
_physicsEngine->removeAction(actionID);
|
// _physicsEngine->removeAction(actionID);
|
||||||
}
|
// }
|
||||||
|
_actionsToRemove += actionID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicalEntitySimulation::removeActions(QList<QUuid> actionIDsToRemove) {
|
void PhysicalEntitySimulation::removeActions(QList<QUuid> actionIDsToRemove) {
|
||||||
|
// if (_physicsEngine) {
|
||||||
|
// _physicsEngine->removeActions(actionIDsToRemove);
|
||||||
|
// }
|
||||||
|
_actionsToRemove += actionIDsToRemove;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PhysicalEntitySimulation::applyActionChanges() {
|
||||||
if (_physicsEngine) {
|
if (_physicsEngine) {
|
||||||
_physicsEngine->removeActions(actionIDsToRemove);
|
foreach (EntityActionInterface* actionToAdd, _actionsToAdd) {
|
||||||
|
_physicsEngine->addAction(actionToAdd);
|
||||||
|
}
|
||||||
|
foreach (QUuid actionToRemove, _actionsToRemove) {
|
||||||
|
_physicsEngine->removeAction(actionToRemove);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
virtual void addAction(EntityActionInterface* action);
|
virtual void addAction(EntityActionInterface* action);
|
||||||
virtual void removeAction(const QUuid actionID);
|
virtual void removeAction(const QUuid actionID);
|
||||||
virtual void removeActions(QList<QUuid> actionIDsToRemove);
|
virtual void removeActions(QList<QUuid> actionIDsToRemove);
|
||||||
|
virtual void applyActionChanges();
|
||||||
|
|
||||||
protected: // only called by EntitySimulation
|
protected: // only called by EntitySimulation
|
||||||
// overrides for EntitySimulation
|
// overrides for EntitySimulation
|
||||||
|
@ -68,6 +69,9 @@ private:
|
||||||
EntityEditPacketSender* _entityPacketSender = nullptr;
|
EntityEditPacketSender* _entityPacketSender = nullptr;
|
||||||
|
|
||||||
uint32_t _lastStepSendPackets = 0;
|
uint32_t _lastStepSendPackets = 0;
|
||||||
|
|
||||||
|
QList<EntityActionInterface*> _actionsToAdd;
|
||||||
|
QList<QUuid> _actionsToRemove;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_PhysicalEntitySimulation_h
|
#endif // hifi_PhysicalEntitySimulation_h
|
||||||
|
|
|
@ -466,11 +466,6 @@ void PhysicsEngine::removeAction(const QUuid actionID) {
|
||||||
ObjectAction* action = _objectActions[actionID];
|
ObjectAction* action = _objectActions[actionID];
|
||||||
_dynamicsWorld->removeAction(action);
|
_dynamicsWorld->removeAction(action);
|
||||||
_objectActions.remove(actionID);
|
_objectActions.remove(actionID);
|
||||||
}
|
delete action;
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicsEngine::removeActions(QList<QUuid> actionIDsToRemove) {
|
|
||||||
foreach(QUuid actionID, actionIDsToRemove) {
|
|
||||||
removeAction(actionID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,6 @@ public:
|
||||||
|
|
||||||
void addAction(EntityActionInterface* action);
|
void addAction(EntityActionInterface* action);
|
||||||
void removeAction(const QUuid actionID);
|
void removeAction(const QUuid actionID);
|
||||||
void removeActions(QList<QUuid> actionIDsToRemove);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void removeContacts(ObjectMotionState* motionState);
|
void removeContacts(ObjectMotionState* motionState);
|
||||||
|
|
Loading…
Reference in a new issue