From 9c81909be55ef6f60da6b5ab6c53c829322c38a7 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 30 Jan 2018 16:42:08 -0800 Subject: [PATCH 1/8] restructures _dirtyFlags name and bits --- .../src/RenderableModelEntityItem.cpp | 2 +- .../src/RenderablePolyVoxEntityItem.cpp | 4 +- libraries/entities/src/EntityItem.cpp | 123 +++++++++++------- libraries/entities/src/EntityItem.h | 10 +- libraries/entities/src/ModelEntityItem.cpp | 20 +-- .../entities/src/ParticleEffectEntityItem.cpp | 2 +- libraries/entities/src/SimulationFlags.h | 4 +- 7 files changed, 97 insertions(+), 68 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 9fcb7640ef..1134c385f2 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -1,4 +1,4 @@ -// + // // RenderableModelEntityItem.cpp // interface/src // diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index ade3790df6..abd14d017e 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -99,7 +99,7 @@ const float MARCHING_CUBE_COLLISION_HULL_OFFSET = 0.5; In RenderablePolyVoxEntityItem::render, these flags are checked and changes are propagated along the chain. decompressVolumeData() is called to decompress _voxelData into _volData. recomputeMesh() is called to invoke the - polyVox surface extractor to create _mesh (as well as set Simulation _dirtyFlags). Because Simulation::DIRTY_SHAPE + polyVox surface extractor to create _mesh (as well as set Simulation _flags). Because Simulation::DIRTY_SHAPE is set, isReadyToComputeShape() gets called and _shape is created either from _volData or _shape, depending on the surface style. @@ -1138,7 +1138,7 @@ void RenderablePolyVoxEntityItem::setMesh(graphics::MeshPointer mesh) { bool neighborsNeedUpdate; withWriteLock([&] { if (!_collisionless) { - _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; + _flags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; } _mesh = mesh; _meshDirty = true; diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index fe5213baa8..7e227c90d6 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -933,7 +933,7 @@ void EntityItem::setDensity(float density) { withWriteLock([&] { if (_density != clampedDensity) { _density = clampedDensity; - _dirtyFlags |= Simulation::DIRTY_MASS; + _flags |= Simulation::DIRTY_MASS; } }); } @@ -958,7 +958,7 @@ void EntityItem::setMass(float mass) { withWriteLock([&] { if (_density != newDensity) { _density = newDensity; - _dirtyFlags |= Simulation::DIRTY_MASS; + _flags |= Simulation::DIRTY_MASS; } }); } @@ -1623,41 +1623,43 @@ void EntityItem::setParentID(const QUuid& value) { if (!value.isNull() && tree) { EntityItemPointer entity = tree->findEntityByEntityItemID(value); if (entity) { - newParentNoBootstrapping = entity->getDirtyFlags() & Simulation::NO_BOOTSTRAPPING; + newParentNoBootstrapping = entity->getSpecialFlags() & Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING; } } if (!oldParentID.isNull() && tree) { EntityItemPointer entity = tree->findEntityByEntityItemID(oldParentID); if (entity) { - oldParentNoBootstrapping = entity->getDirtyFlags() & Simulation::NO_BOOTSTRAPPING; + oldParentNoBootstrapping = entity->getDirtyFlags() & Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING; } } if (!value.isNull() && (value == Physics::getSessionUUID() || value == AVATAR_SELF_ID)) { - newParentNoBootstrapping |= Simulation::NO_BOOTSTRAPPING; + newParentNoBootstrapping |= Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING; } if (!oldParentID.isNull() && (oldParentID == Physics::getSessionUUID() || oldParentID == AVATAR_SELF_ID)) { - oldParentNoBootstrapping |= Simulation::NO_BOOTSTRAPPING; + oldParentNoBootstrapping |= Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING; } if ((bool)(oldParentNoBootstrapping ^ newParentNoBootstrapping)) { - if ((bool)(newParentNoBootstrapping & Simulation::NO_BOOTSTRAPPING)) { - markDirtyFlags(Simulation::NO_BOOTSTRAPPING); - forEachDescendant([&](SpatiallyNestablePointer object) { - if (object->getNestableType() == NestableType::Entity) { - EntityItemPointer entity = std::static_pointer_cast(object); - entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP | Simulation::NO_BOOTSTRAPPING); - } - }); - } else { - clearDirtyFlags(Simulation::NO_BOOTSTRAPPING); + if ((bool)(newParentNoBootstrapping & Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING)) { + markSpecialFlags(Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING); + qDebug() << "setParentID" << QString::fromStdString(std::bitset<32>(_flags).to_string()) << " <--------"; forEachDescendant([&](SpatiallyNestablePointer object) { if (object->getNestableType() == NestableType::Entity) { EntityItemPointer entity = std::static_pointer_cast(object); entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP); - entity->clearDirtyFlags(Simulation::NO_BOOTSTRAPPING); + entity->markSpecialFlags(Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING); + } + }); + } else { + clearSpecialFlags(Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING); + forEachDescendant([&](SpatiallyNestablePointer object) { + if (object->getNestableType() == NestableType::Entity) { + EntityItemPointer entity = std::static_pointer_cast(object); + entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP); + entity->clearSpecialFlags(Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING); } }); } @@ -1694,7 +1696,7 @@ void EntityItem::setUnscaledDimensions(const glm::vec3& value) { locationChanged(); dimensionsChanged(); withWriteLock([&] { - _dirtyFlags |= (Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS); + _flags |= (Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS); _queryAACubeSet = false; }); } @@ -1703,7 +1705,7 @@ void EntityItem::setUnscaledDimensions(const glm::vec3& value) { void EntityItem::setRotation(glm::quat rotation) { if (getLocalOrientation() != rotation) { setLocalOrientation(rotation); - _dirtyFlags |= Simulation::DIRTY_ROTATION; + _flags |= Simulation::DIRTY_ROTATION; forEachDescendant([&](SpatiallyNestablePointer object) { if (object->getNestableType() == NestableType::Entity) { EntityItemPointer entity = std::static_pointer_cast(object); @@ -1733,7 +1735,7 @@ void EntityItem::setVelocity(const glm::vec3& value) { velocity = value; } setLocalVelocity(velocity); - _dirtyFlags |= Simulation::DIRTY_LINEAR_VELOCITY; + _flags |= Simulation::DIRTY_LINEAR_VELOCITY; } } } @@ -1744,7 +1746,7 @@ void EntityItem::setDamping(float value) { withWriteLock([&] { if (_damping != clampedDamping) { _damping = clampedDamping; - _dirtyFlags |= Simulation::DIRTY_MATERIAL; + _flags |= Simulation::DIRTY_MATERIAL; } }); } @@ -1763,7 +1765,7 @@ void EntityItem::setGravity(const glm::vec3& value) { } else { _gravity = value; } - _dirtyFlags |= Simulation::DIRTY_LINEAR_VELOCITY; + _flags |= Simulation::DIRTY_LINEAR_VELOCITY; } } } @@ -1788,7 +1790,7 @@ void EntityItem::setAngularVelocity(const glm::vec3& value) { angularVelocity = value; } setLocalAngularVelocity(angularVelocity); - _dirtyFlags |= Simulation::DIRTY_ANGULAR_VELOCITY; + _flags |= Simulation::DIRTY_ANGULAR_VELOCITY; } } } @@ -1799,7 +1801,7 @@ void EntityItem::setAngularDamping(float value) { withWriteLock([&] { if (_angularDamping != clampedDamping) { _angularDamping = clampedDamping; - _dirtyFlags |= Simulation::DIRTY_MATERIAL; + _flags |= Simulation::DIRTY_MATERIAL; } }); } @@ -1808,7 +1810,7 @@ void EntityItem::setCollisionless(bool value) { withWriteLock([&] { if (_collisionless != value) { _collisionless = value; - _dirtyFlags |= Simulation::DIRTY_COLLISION_GROUP; + _flags |= Simulation::DIRTY_COLLISION_GROUP; } }); } @@ -1817,7 +1819,7 @@ void EntityItem::setCollisionMask(uint8_t value) { withWriteLock([&] { if ((_collisionMask & ENTITY_COLLISION_MASK_DEFAULT) != (value & ENTITY_COLLISION_MASK_DEFAULT)) { _collisionMask = (value & ENTITY_COLLISION_MASK_DEFAULT); - _dirtyFlags |= Simulation::DIRTY_COLLISION_GROUP; + _flags |= Simulation::DIRTY_COLLISION_GROUP; } }); } @@ -1829,11 +1831,11 @@ void EntityItem::setDynamic(bool value) { if (value && getShapeType() == SHAPE_TYPE_STATIC_MESH) { if (_dynamic) { _dynamic = false; - _dirtyFlags |= Simulation::DIRTY_MOTION_TYPE; + _flags |= Simulation::DIRTY_MOTION_TYPE; } } else { _dynamic = value; - _dirtyFlags |= Simulation::DIRTY_MOTION_TYPE; + _flags |= Simulation::DIRTY_MOTION_TYPE; } }); } @@ -1844,7 +1846,7 @@ void EntityItem::setRestitution(float value) { withWriteLock([&] { if (_restitution != clampedValue) { _restitution = clampedValue; - _dirtyFlags |= Simulation::DIRTY_MATERIAL; + _flags |= Simulation::DIRTY_MATERIAL; } }); @@ -1855,7 +1857,7 @@ void EntityItem::setFriction(float value) { withWriteLock([&] { if (_friction != clampedValue) { _friction = clampedValue; - _dirtyFlags |= Simulation::DIRTY_MATERIAL; + _flags |= Simulation::DIRTY_MATERIAL; } }); } @@ -1864,7 +1866,7 @@ void EntityItem::setLifetime(float value) { withWriteLock([&] { if (_lifetime != value) { _lifetime = value; - _dirtyFlags |= Simulation::DIRTY_LIFETIME; + _flags |= Simulation::DIRTY_LIFETIME; } }); } @@ -1873,7 +1875,7 @@ void EntityItem::setCreated(quint64 value) { withWriteLock([&] { if (_created != value) { _created = value; - _dirtyFlags |= Simulation::DIRTY_LIFETIME; + _flags |= Simulation::DIRTY_LIFETIME; } }); } @@ -1902,7 +1904,7 @@ void EntityItem::computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask } } - if ((bool)(_dirtyFlags & Simulation::NO_BOOTSTRAPPING)) { + if ((bool)(_flags & Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING)) { userMask &= ~USER_COLLISION_GROUP_MY_AVATAR; } mask = Physics::getDefaultCollisionMask(group) & (int16_t)(userMask); @@ -1997,17 +1999,18 @@ bool EntityItem::addActionInternal(EntitySimulationPointer simulation, EntityDyn serializeActions(success, newDataCache); if (success) { _allActionsDataCache = newDataCache; - _dirtyFlags |= Simulation::DIRTY_PHYSICS_ACTIVATION; + _flags |= Simulation::DIRTY_PHYSICS_ACTIVATION; auto actionType = action->getType(); if (actionType == DYNAMIC_TYPE_HOLD || actionType == DYNAMIC_TYPE_FAR_GRAB) { - if (!(bool)(_dirtyFlags & Simulation::NO_BOOTSTRAPPING)) { - _dirtyFlags |= Simulation::NO_BOOTSTRAPPING; - _dirtyFlags |= Simulation::DIRTY_COLLISION_GROUP; // may need to not collide with own avatar + if (!(bool)(_flags & Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING)) { + _flags |= Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING; + _flags |= Simulation::DIRTY_COLLISION_GROUP; // may need to not collide with own avatar forEachDescendant([&](SpatiallyNestablePointer child) { if (child->getNestableType() == NestableType::Entity) { EntityItemPointer entity = std::static_pointer_cast(child); - entity->markDirtyFlags(Simulation::NO_BOOTSTRAPPING | Simulation::DIRTY_COLLISION_GROUP); + entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP); + entity->markSpecialFlags(Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING); } }); } @@ -2033,7 +2036,7 @@ bool EntityItem::updateAction(EntitySimulationPointer simulation, const QUuid& a if (success) { action->setIsMine(true); serializeActions(success, _allActionsDataCache); - _dirtyFlags |= Simulation::DIRTY_PHYSICS_ACTIVATION; + _flags |= Simulation::DIRTY_PHYSICS_ACTIVATION; } else { qCDebug(entities) << "EntityItem::updateAction failed"; } @@ -2091,17 +2094,17 @@ bool EntityItem::removeActionInternal(const QUuid& actionID, EntitySimulationPoi _objectActions.remove(actionID); if ((removedActionType == DYNAMIC_TYPE_HOLD || removedActionType == DYNAMIC_TYPE_FAR_GRAB) && !stillHasGrabActions()) { - _dirtyFlags &= ~Simulation::NO_BOOTSTRAPPING; - _dirtyFlags |= Simulation::DIRTY_COLLISION_GROUP; // may need to not collide with own avatar + _flags &= ~Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING; + _flags |= Simulation::DIRTY_COLLISION_GROUP; // may need to not collide with own avatar forEachDescendant([&](SpatiallyNestablePointer child) { if (child->getNestableType() == NestableType::Entity) { EntityItemPointer entity = std::static_pointer_cast(child); entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP); - entity->clearDirtyFlags(Simulation::NO_BOOTSTRAPPING); + entity->clearSpecialFlags(Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING); } }); } else { - // NO-OP: we assume NO_BOOTSTRAPPING bits and collision group are correct + // NO-OP: we assume SPECIAL_FLAGS_NO_BOOTSTRAPPING bits and collision group are correct // because they should have been set correctly when the action was added // and/or when children were linked } @@ -2112,7 +2115,7 @@ bool EntityItem::removeActionInternal(const QUuid& actionID, EntitySimulationPoi bool success = true; serializeActions(success, _allActionsDataCache); - _dirtyFlags |= Simulation::DIRTY_PHYSICS_ACTIVATION; + _flags |= Simulation::DIRTY_PHYSICS_ACTIVATION; setDynamicDataNeedsTransmit(true); return success; } @@ -2132,8 +2135,8 @@ bool EntityItem::clearActions(EntitySimulationPointer simulation) { // empty _serializedActions means no actions for the EntityItem _actionsToRemove.clear(); _allActionsDataCache.clear(); - _dirtyFlags |= Simulation::DIRTY_PHYSICS_ACTIVATION; - _dirtyFlags |= Simulation::DIRTY_COLLISION_GROUP; // may need to not collide with own avatar + _flags |= Simulation::DIRTY_PHYSICS_ACTIVATION; + _flags |= Simulation::DIRTY_COLLISION_GROUP; // may need to not collide with own avatar }); return true; } @@ -2364,7 +2367,7 @@ QList EntityItem::getActionsOfType(EntityDynamicType typeT void EntityItem::locationChanged(bool tellPhysics) { requiresRecalcBoxes(); if (tellPhysics) { - _dirtyFlags |= Simulation::DIRTY_TRANSFORM; + _flags |= Simulation::DIRTY_TRANSFORM; EntityTreePointer tree = getTree(); if (tree) { tree->entityChanged(getThisPointer()); @@ -2832,7 +2835,7 @@ DEFINE_PROPERTY_ACCESSOR(quint32, StaticCertificateVersion, staticCertificateVer uint32_t EntityItem::getDirtyFlags() const { uint32_t result; withReadLock([&] { - result = _dirtyFlags; + result = _flags; }); return result; } @@ -2840,13 +2843,33 @@ uint32_t EntityItem::getDirtyFlags() const { void EntityItem::markDirtyFlags(uint32_t mask) { withWriteLock([&] { - _dirtyFlags |= mask; + _flags |= mask; }); } void EntityItem::clearDirtyFlags(uint32_t mask) { withWriteLock([&] { - _dirtyFlags &= ~mask; + _flags &= ~mask; + }); +} + +uint32_t EntityItem::getSpecialFlags() const { + uint32_t result; + withReadLock([&] { + result = _flags; + }); + return result; +} + +void EntityItem::markSpecialFlags(uint32_t mask) { + withWriteLock([&] { + _flags |= mask; + }); +} + +void EntityItem::clearSpecialFlags(uint32_t mask) { + withWriteLock([&] { + _flags &= ~mask; }); } diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 4c398b8a29..fb0f36c4d6 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -358,7 +358,11 @@ public: uint32_t getDirtyFlags() const; void markDirtyFlags(uint32_t mask); - void clearDirtyFlags(uint32_t mask = 0xffffffff); + void clearDirtyFlags(uint32_t mask = 0x0000ffff); + + uint32_t getSpecialFlags() const; + void markSpecialFlags(uint32_t mask); + void clearSpecialFlags(uint32_t mask = 0xffff0000); bool isMoving() const; bool isMovingRelativeToParent() const; @@ -385,7 +389,7 @@ public: void getAllTerseUpdateProperties(EntityItemProperties& properties) const; void flagForOwnershipBid(uint8_t priority); - void flagForMotionStateChange() { _dirtyFlags |= Simulation::DIRTY_MOTION_TYPE; } + void flagForMotionStateChange() { _flags |= Simulation::DIRTY_MOTION_TYPE; } QString actionsToDebugString(); bool addAction(EntitySimulationPointer simulation, EntityDynamicPointer action); @@ -572,7 +576,7 @@ protected: // // DirtyFlags are set whenever a property changes that the EntitySimulation needs to know about. - uint32_t _dirtyFlags { 0 }; // things that have changed from EXTERNAL changes (via script or packet) but NOT from simulation + uint32_t _flags { 0 }; // things that have changed from EXTERNAL changes (via script or packet) but NOT from simulation // these backpointers are only ever set/cleared by friends: EntityTreeElementPointer _element; // set by EntityTreeElement diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index a615beefa9..5d33e4c047 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -85,7 +85,7 @@ bool ModelEntityItem::setProperties(const EntityItemProperties& properties) { bool somethingChangedInAnimations = _animationProperties.setProperties(properties); if (somethingChangedInAnimations) { - _dirtyFlags |= Simulation::DIRTY_UPDATEABLE; + _flags |= Simulation::DIRTY_UPDATEABLE; } somethingChanged = somethingChanged || somethingChangedInAnimations; @@ -132,7 +132,7 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, READ_ENTITY_PROPERTY(PROP_SHAPE_TYPE, ShapeType, setShapeType); if (animationPropertiesChanged) { - _dirtyFlags |= Simulation::DIRTY_UPDATEABLE; + _flags |= Simulation::DIRTY_UPDATEABLE; somethingChanged = true; } @@ -305,10 +305,10 @@ void ModelEntityItem::setShapeType(ShapeType type) { // dynamic and STATIC_MESH are incompatible // since the shape is being set here we clear the dynamic bit _dynamic = false; - _dirtyFlags |= Simulation::DIRTY_MOTION_TYPE; + _flags |= Simulation::DIRTY_MOTION_TYPE; } _shapeType = type; - _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; + _flags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; } }); } @@ -336,7 +336,7 @@ void ModelEntityItem::setModelURL(const QString& url) { if (_modelURL != url) { _modelURL = url; if (_shapeType == SHAPE_TYPE_STATIC_MESH) { - _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; + _flags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; } } }); @@ -348,14 +348,14 @@ void ModelEntityItem::setCompoundShapeURL(const QString& url) { ShapeType oldType = computeTrueShapeType(); _compoundShapeURL.set(url); if (oldType != computeTrueShapeType()) { - _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; + _flags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; } } }); } void ModelEntityItem::setAnimationURL(const QString& url) { - _dirtyFlags |= Simulation::DIRTY_UPDATEABLE; + _flags |= Simulation::DIRTY_UPDATEABLE; withWriteLock([&] { _animationProperties.setURL(url); }); @@ -422,16 +422,16 @@ void ModelEntityItem::setAnimationSettings(const QString& value) { bool allowTranslation = settingsMap["allowTranslation"].toBool(); setAnimationAllowTranslation(allowTranslation); } - _dirtyFlags |= Simulation::DIRTY_UPDATEABLE; + _flags |= Simulation::DIRTY_UPDATEABLE; } void ModelEntityItem::setAnimationIsPlaying(bool value) { - _dirtyFlags |= Simulation::DIRTY_UPDATEABLE; + _flags |= Simulation::DIRTY_UPDATEABLE; _animationProperties.setRunning(value); } void ModelEntityItem::setAnimationFPS(float value) { - _dirtyFlags |= Simulation::DIRTY_UPDATEABLE; + _flags |= Simulation::DIRTY_UPDATEABLE; _animationProperties.setFPS(value); } diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index c20572a491..7d27011c56 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -601,7 +601,7 @@ void ParticleEffectEntityItem::setShapeType(ShapeType type) { withWriteLock([&] { if (type != _shapeType) { _shapeType = type; - _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; + _flags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; } }); } diff --git a/libraries/entities/src/SimulationFlags.h b/libraries/entities/src/SimulationFlags.h index aaa92000e7..6f305ef1ff 100644 --- a/libraries/entities/src/SimulationFlags.h +++ b/libraries/entities/src/SimulationFlags.h @@ -27,7 +27,9 @@ namespace Simulation { const uint32_t DIRTY_PHYSICS_ACTIVATION = 0x0800; // should activate object in physics engine const uint32_t DIRTY_SIMULATOR_ID = 0x1000; // the simulatorID has changed const uint32_t DIRTY_SIMULATION_OWNERSHIP_PRIORITY = 0x2000; // our own bid priority has changed - const uint32_t NO_BOOTSTRAPPING = 0x4000; + + + const uint32_t SPECIAL_FLAGS_NO_BOOTSTRAPPING = 0x10000; const uint32_t DIRTY_TRANSFORM = DIRTY_POSITION | DIRTY_ROTATION; const uint32_t DIRTY_VELOCITIES = DIRTY_LINEAR_VELOCITY | DIRTY_ANGULAR_VELOCITY; From 4429be23c0ca70e368d037d9e7f068c7f306003d Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 31 Jan 2018 09:13:11 -0800 Subject: [PATCH 2/8] add comment --- libraries/entities/src/SimulationFlags.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/entities/src/SimulationFlags.h b/libraries/entities/src/SimulationFlags.h index 6f305ef1ff..da82916fe3 100644 --- a/libraries/entities/src/SimulationFlags.h +++ b/libraries/entities/src/SimulationFlags.h @@ -28,7 +28,7 @@ namespace Simulation { const uint32_t DIRTY_SIMULATOR_ID = 0x1000; // the simulatorID has changed const uint32_t DIRTY_SIMULATION_OWNERSHIP_PRIORITY = 0x2000; // our own bid priority has changed - + // bits 17-32 are reservied for special flags const uint32_t SPECIAL_FLAGS_NO_BOOTSTRAPPING = 0x10000; const uint32_t DIRTY_TRANSFORM = DIRTY_POSITION | DIRTY_ROTATION; From c3b8565dea5f26035f0a98ac4fe049715fa1dc78 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 31 Jan 2018 09:23:00 -0800 Subject: [PATCH 3/8] min diff --- libraries/entities-renderer/src/RenderableModelEntityItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 1134c385f2..9fcb7640ef 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -1,4 +1,4 @@ - // +// // RenderableModelEntityItem.cpp // interface/src // From 9ff6e079ee7d4bcf2fab2261bd557140dfad4a4d Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 31 Jan 2018 10:09:23 -0800 Subject: [PATCH 4/8] fix functions --- libraries/entities/src/EntityItem.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 7e227c90d6..79f9f97aa4 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -2835,7 +2835,7 @@ DEFINE_PROPERTY_ACCESSOR(quint32, StaticCertificateVersion, staticCertificateVer uint32_t EntityItem::getDirtyFlags() const { uint32_t result; withReadLock([&] { - result = _flags; + result = _flags & 0x0000ffff; }); return result; } @@ -2843,12 +2843,14 @@ uint32_t EntityItem::getDirtyFlags() const { void EntityItem::markDirtyFlags(uint32_t mask) { withWriteLock([&] { + mask &= 0x0000ffff; _flags |= mask; }); } void EntityItem::clearDirtyFlags(uint32_t mask) { withWriteLock([&] { + mask &= 0x0000ffff; _flags &= ~mask; }); } @@ -2856,19 +2858,21 @@ void EntityItem::clearDirtyFlags(uint32_t mask) { uint32_t EntityItem::getSpecialFlags() const { uint32_t result; withReadLock([&] { - result = _flags; + result = _flags & 0xffff0000; }); return result; } void EntityItem::markSpecialFlags(uint32_t mask) { withWriteLock([&] { + mask &= 0xffff0000; _flags |= mask; }); } void EntityItem::clearSpecialFlags(uint32_t mask) { withWriteLock([&] { + mask &= 0xffff0000; _flags &= ~mask; }); } From 01f8227fa25cc2cddd49dcf11e940a475223d17b Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 31 Jan 2018 10:41:08 -0800 Subject: [PATCH 5/8] remove stray prints --- libraries/entities/src/EntityItem.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 79f9f97aa4..ac349ad74d 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1645,7 +1645,6 @@ void EntityItem::setParentID(const QUuid& value) { if ((bool)(oldParentNoBootstrapping ^ newParentNoBootstrapping)) { if ((bool)(newParentNoBootstrapping & Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING)) { markSpecialFlags(Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING); - qDebug() << "setParentID" << QString::fromStdString(std::bitset<32>(_flags).to_string()) << " <--------"; forEachDescendant([&](SpatiallyNestablePointer object) { if (object->getNestableType() == NestableType::Entity) { EntityItemPointer entity = std::static_pointer_cast(object); From f6029ed9dcabdf0634efdcb77ab8a5d4bebe839f Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 31 Jan 2018 15:21:22 -0800 Subject: [PATCH 6/8] made requested changes --- libraries/entities/src/EntityItem.cpp | 12 ++++++------ libraries/entities/src/SimulationFlags.h | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index ac349ad74d..9ac24b4324 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -2834,7 +2834,7 @@ DEFINE_PROPERTY_ACCESSOR(quint32, StaticCertificateVersion, staticCertificateVer uint32_t EntityItem::getDirtyFlags() const { uint32_t result; withReadLock([&] { - result = _flags & 0x0000ffff; + result = _flags & ~Simulation::SPECIAL_FLAGS; }); return result; } @@ -2842,14 +2842,14 @@ uint32_t EntityItem::getDirtyFlags() const { void EntityItem::markDirtyFlags(uint32_t mask) { withWriteLock([&] { - mask &= 0x0000ffff; + mask &= ~Simulation::SPECIAL_FLAGS; _flags |= mask; }); } void EntityItem::clearDirtyFlags(uint32_t mask) { withWriteLock([&] { - mask &= 0x0000ffff; + mask &= ~Simulation::SPECIAL_FLAGS; _flags &= ~mask; }); } @@ -2857,21 +2857,21 @@ void EntityItem::clearDirtyFlags(uint32_t mask) { uint32_t EntityItem::getSpecialFlags() const { uint32_t result; withReadLock([&] { - result = _flags & 0xffff0000; + result = _flags & ~Simulation::DIRTY_FLAGS; }); return result; } void EntityItem::markSpecialFlags(uint32_t mask) { withWriteLock([&] { - mask &= 0xffff0000; + mask &= ~Simulation::DIRTY_FLAGS; _flags |= mask; }); } void EntityItem::clearSpecialFlags(uint32_t mask) { withWriteLock([&] { - mask &= 0xffff0000; + mask &= ~Simulation::DIRTY_FLAGS; _flags &= ~mask; }); } diff --git a/libraries/entities/src/SimulationFlags.h b/libraries/entities/src/SimulationFlags.h index da82916fe3..c45b333b29 100644 --- a/libraries/entities/src/SimulationFlags.h +++ b/libraries/entities/src/SimulationFlags.h @@ -33,6 +33,22 @@ namespace Simulation { const uint32_t DIRTY_TRANSFORM = DIRTY_POSITION | DIRTY_ROTATION; const uint32_t DIRTY_VELOCITIES = DIRTY_LINEAR_VELOCITY | DIRTY_ANGULAR_VELOCITY; + const uint32_t SPECIAL_FLAGS = SPECIAL_FLAGS_NO_BOOTSTRAPPING; + + const uint32_t DIRTY_FLAGS = DIRTY_POSITION | + DIRTY_ROTATION | + DIRTY_LINEAR_VELOCITY | + DIRTY_ANGULAR_VELOCITY | + DIRTY_MASS | + DIRTY_COLLISION_GROUP | + DIRTY_MOTION_TYPE | + DIRTY_SHAPE | + DIRTY_LIFETIME | + DIRTY_UPDATEABLE | + DIRTY_MATERIAL | + DIRTY_PHYSICS_ACTIVATION | + DIRTY_SIMULATOR_ID | + DIRTY_SIMULATION_OWNERSHIP_PRIORITY; }; #endif // hifi_SimulationFlags_h From bd5fc65bfbaab291e0deba95d774a7cfc6aca273 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 31 Jan 2018 16:19:14 -0800 Subject: [PATCH 7/8] fix getDirtyFlags & getSpecialFlags function --- libraries/entities/src/EntityItem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 9ac24b4324..842e5cd7b4 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -2834,7 +2834,7 @@ DEFINE_PROPERTY_ACCESSOR(quint32, StaticCertificateVersion, staticCertificateVer uint32_t EntityItem::getDirtyFlags() const { uint32_t result; withReadLock([&] { - result = _flags & ~Simulation::SPECIAL_FLAGS; + result = _flags & Simulation::SPECIAL_FLAGS; }); return result; } @@ -2857,7 +2857,7 @@ void EntityItem::clearDirtyFlags(uint32_t mask) { uint32_t EntityItem::getSpecialFlags() const { uint32_t result; withReadLock([&] { - result = _flags & ~Simulation::DIRTY_FLAGS; + result = _flags & Simulation::DIRTY_FLAGS; }); return result; } From ab20643ada020d58b196685f795e7570c1213bdc Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 1 Feb 2018 08:13:43 -0800 Subject: [PATCH 8/8] fix mistakes --- libraries/entities/src/EntityItem.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 842e5cd7b4..ed13a46414 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -2834,7 +2834,7 @@ DEFINE_PROPERTY_ACCESSOR(quint32, StaticCertificateVersion, staticCertificateVer uint32_t EntityItem::getDirtyFlags() const { uint32_t result; withReadLock([&] { - result = _flags & Simulation::SPECIAL_FLAGS; + result = _flags & Simulation::DIRTY_FLAGS; }); return result; } @@ -2842,14 +2842,14 @@ uint32_t EntityItem::getDirtyFlags() const { void EntityItem::markDirtyFlags(uint32_t mask) { withWriteLock([&] { - mask &= ~Simulation::SPECIAL_FLAGS; + mask &= Simulation::DIRTY_FLAGS; _flags |= mask; }); } void EntityItem::clearDirtyFlags(uint32_t mask) { withWriteLock([&] { - mask &= ~Simulation::SPECIAL_FLAGS; + mask &= Simulation::DIRTY_FLAGS; _flags &= ~mask; }); } @@ -2857,21 +2857,21 @@ void EntityItem::clearDirtyFlags(uint32_t mask) { uint32_t EntityItem::getSpecialFlags() const { uint32_t result; withReadLock([&] { - result = _flags & Simulation::DIRTY_FLAGS; + result = _flags & Simulation::SPECIAL_FLAGS; }); return result; } void EntityItem::markSpecialFlags(uint32_t mask) { withWriteLock([&] { - mask &= ~Simulation::DIRTY_FLAGS; + mask &= Simulation::SPECIAL_FLAGS; _flags |= mask; }); } void EntityItem::clearSpecialFlags(uint32_t mask) { withWriteLock([&] { - mask &= ~Simulation::DIRTY_FLAGS; + mask &= Simulation::SPECIAL_FLAGS; _flags &= ~mask; }); }