Cleaning up the files updated

This commit is contained in:
samcake 2017-04-05 13:49:07 -07:00
parent 8356e5495f
commit 5629cf425e
6 changed files with 22 additions and 22 deletions

View file

@ -96,7 +96,7 @@ void PhysicalEntitySimulation::changeEntityInternal(EntityItemPointer entity) {
if (motionState) { if (motionState) {
if (!entity->shouldBePhysical()) { if (!entity->shouldBePhysical()) {
// the entity should be removed from the physical simulation // the entity should be removed from the physical simulation
_transaction.remove(motionState); _pendingChanges.remove(motionState);
_physicalObjects.remove(motionState); _physicalObjects.remove(motionState);
_outgoingChanges.remove(motionState); _outgoingChanges.remove(motionState);
_entitiesToRemoveFromPhysics.insert(entity); _entitiesToRemoveFromPhysics.insert(entity);
@ -104,7 +104,7 @@ void PhysicalEntitySimulation::changeEntityInternal(EntityItemPointer entity) {
_simpleKinematicEntities.insert(entity); _simpleKinematicEntities.insert(entity);
} }
} else { } else {
_transaction.insert(motionState); _pendingChanges.insert(motionState);
} }
} else if (entity->shouldBePhysical()) { } else if (entity->shouldBePhysical()) {
// The intent is for this object to be in the PhysicsEngine, but it has no MotionState yet. // The intent is for this object to be in the PhysicsEngine, but it has no MotionState yet.
@ -148,7 +148,7 @@ void PhysicalEntitySimulation::clearEntitiesInternal() {
_entitiesToRemoveFromPhysics.clear(); _entitiesToRemoveFromPhysics.clear();
_entitiesToRelease.clear(); _entitiesToRelease.clear();
_entitiesToAddToPhysics.clear(); _entitiesToAddToPhysics.clear();
_transaction.clear(); _pendingChanges.clear();
_outgoingChanges.clear(); _outgoingChanges.clear();
} }
@ -170,7 +170,7 @@ void PhysicalEntitySimulation::getObjectsToRemoveFromPhysics(VectorOfMotionState
EntityMotionState* motionState = static_cast<EntityMotionState*>(entity->getPhysicsInfo()); EntityMotionState* motionState = static_cast<EntityMotionState*>(entity->getPhysicsInfo());
if (motionState) { if (motionState) {
_transaction.remove(motionState); _pendingChanges.remove(motionState);
_outgoingChanges.remove(motionState); _outgoingChanges.remove(motionState);
_physicalObjects.remove(motionState); _physicalObjects.remove(motionState);
result.push_back(motionState); result.push_back(motionState);
@ -246,18 +246,18 @@ void PhysicalEntitySimulation::getObjectsToAddToPhysics(VectorOfMotionStates& re
void PhysicalEntitySimulation::setObjectsToChange(const VectorOfMotionStates& objectsToChange) { void PhysicalEntitySimulation::setObjectsToChange(const VectorOfMotionStates& objectsToChange) {
QMutexLocker lock(&_mutex); QMutexLocker lock(&_mutex);
for (auto object : objectsToChange) { for (auto object : objectsToChange) {
_transaction.insert(static_cast<EntityMotionState*>(object)); _pendingChanges.insert(static_cast<EntityMotionState*>(object));
} }
} }
void PhysicalEntitySimulation::getObjectsToChange(VectorOfMotionStates& result) { void PhysicalEntitySimulation::getObjectsToChange(VectorOfMotionStates& result) {
result.clear(); result.clear();
QMutexLocker lock(&_mutex); QMutexLocker lock(&_mutex);
for (auto stateItr : _transaction) { for (auto stateItr : _pendingChanges) {
EntityMotionState* motionState = &(*stateItr); EntityMotionState* motionState = &(*stateItr);
result.push_back(motionState); result.push_back(motionState);
} }
_transaction.clear(); _pendingChanges.clear();
} }
void PhysicalEntitySimulation::handleDeactivatedMotionStates(const VectorOfMotionStates& motionStates) { void PhysicalEntitySimulation::handleDeactivatedMotionStates(const VectorOfMotionStates& motionStates) {

View file

@ -67,7 +67,7 @@ private:
SetOfEntities _entitiesToRelease; SetOfEntities _entitiesToRelease;
SetOfEntities _entitiesToAddToPhysics; SetOfEntities _entitiesToAddToPhysics;
SetOfEntityMotionStates _transaction; // EntityMotionStates already in PhysicsEngine that need their physics changed SetOfEntityMotionStates _pendingChanges; // EntityMotionStates already in PhysicsEngine that need their physics changed
SetOfEntityMotionStates _outgoingChanges; // EntityMotionStates for which we may need to send updates to entity-server SetOfEntityMotionStates _outgoingChanges; // EntityMotionStates for which we may need to send updates to entity-server
SetOfMotionStates _physicalObjects; // MotionStates of entities in PhysicsEngine SetOfMotionStates _physicalObjects; // MotionStates of entities in PhysicsEngine

View file

@ -35,12 +35,12 @@ void Transaction::updateItem(ItemID id, const UpdateFunctorPointer& functor) {
_updateFunctors.push_back(functor); _updateFunctors.push_back(functor);
} }
void Transaction::merge(const Transaction& change) { void Transaction::merge(const Transaction& transaction) {
_resetItems.insert(_resetItems.end(), change._resetItems.begin(), change._resetItems.end()); _resetItems.insert(_resetItems.end(), transaction._resetItems.begin(), transaction._resetItems.end());
_resetPayloads.insert(_resetPayloads.end(), change._resetPayloads.begin(), change._resetPayloads.end()); _resetPayloads.insert(_resetPayloads.end(), transaction._resetPayloads.begin(), transaction._resetPayloads.end());
_removedItems.insert(_removedItems.end(), change._removedItems.begin(), change._removedItems.end()); _removedItems.insert(_removedItems.end(), transaction._removedItems.begin(), transaction._removedItems.end());
_updatedItems.insert(_updatedItems.end(), change._updatedItems.begin(), change._updatedItems.end()); _updatedItems.insert(_updatedItems.end(), transaction._updatedItems.begin(), transaction._updatedItems.end());
_updateFunctors.insert(_updateFunctors.end(), change._updateFunctors.begin(), change._updateFunctors.end()); _updateFunctors.insert(_updateFunctors.end(), transaction._updateFunctors.begin(), transaction._updateFunctors.end());
} }
Scene::Scene(glm::vec3 origin, float size) : Scene::Scene(glm::vec3 origin, float size) :

View file

@ -34,7 +34,7 @@ public:
void updateItem(ItemID id, const UpdateFunctorPointer& functor); void updateItem(ItemID id, const UpdateFunctorPointer& functor);
void updateItem(ItemID id) { updateItem(id, nullptr); } void updateItem(ItemID id) { updateItem(id, nullptr); }
void merge(const Transaction& change); void merge(const Transaction& transaction);
ItemIDs _resetItems; ItemIDs _resetItems;
Payloads _resetPayloads; Payloads _resetPayloads;

View file

@ -53,8 +53,8 @@ namespace Setting {
const auto& key = handle->getKey(); const auto& key = handle->getKey();
withWriteLock([&] { withWriteLock([&] {
QVariant loadedValue; QVariant loadedValue;
if (_transaction.contains(key) && _transaction[key] != UNSET_VALUE) { if (_pendingChanges.contains(key) && _pendingChanges[key] != UNSET_VALUE) {
loadedValue = _transaction[key]; loadedValue = _pendingChanges[key];
} else { } else {
loadedValue = value(key); loadedValue = value(key);
} }
@ -73,7 +73,7 @@ namespace Setting {
} }
withWriteLock([&] { withWriteLock([&] {
_transaction[key] = handleValue; _pendingChanges[key] = handleValue;
}); });
} }
@ -98,8 +98,8 @@ namespace Setting {
void Manager::saveAll() { void Manager::saveAll() {
bool forceSync = false; bool forceSync = false;
withWriteLock([&] { withWriteLock([&] {
for (auto key : _transaction.keys()) { for (auto key : _pendingChanges.keys()) {
auto newValue = _transaction[key]; auto newValue = _pendingChanges[key];
auto savedValue = value(key, UNSET_VALUE); auto savedValue = value(key, UNSET_VALUE);
if (newValue == savedValue) { if (newValue == savedValue) {
continue; continue;
@ -112,7 +112,7 @@ namespace Setting {
setValue(key, newValue); setValue(key, newValue);
} }
} }
_transaction.clear(); _pendingChanges.clear();
}); });
if (forceSync) { if (forceSync) {

View file

@ -47,7 +47,7 @@ namespace Setting {
QHash<QString, Interface*> _handles; QHash<QString, Interface*> _handles;
QPointer<QTimer> _saveTimer = nullptr; QPointer<QTimer> _saveTimer = nullptr;
const QVariant UNSET_VALUE { QUuid::createUuid() }; const QVariant UNSET_VALUE { QUuid::createUuid() };
QHash<QString, QVariant> _transaction; QHash<QString, QVariant> _pendingChanges;
friend class Interface; friend class Interface;
friend void cleanupPrivateInstance(); friend void cleanupPrivateInstance();