From 4403c27b5275e4f26d110671c0dbb0c46350b62f Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Tue, 26 Sep 2017 14:14:37 -0700 Subject: [PATCH] working checkpoint. still needs verification/hashing, etc. --- libraries/entities/src/EntityItem.cpp | 25 ++++++++++++-- libraries/entities/src/EntityItem.h | 4 --- .../entities/src/EntityItemProperties.cpp | 20 +++++------ libraries/entities/src/ModelEntityItem.cpp | 34 +++++++++++-------- .../entities/src/ParticleEffectEntityItem.cpp | 10 +++--- libraries/entities/src/ZoneEntityItem.h | 2 +- 6 files changed, 59 insertions(+), 36 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 9084a4b878..5a205742ae 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1568,6 +1568,27 @@ float EntityItem::getRadius() const { return 0.5f * glm::length(getDimensions()); } +// Checking Certifiable Properties +QString EntityItem::getStaticCertificateJSON() const { + // Produce a compact json of every non-default static certificate property, with the property names in alphabetical order. + // The static certificate properties include all an only those properties that cannot be changed without altering the identity + // of the entity as reviewed during the certification submission. + return "FIXME"; +} +QString EntityItem::getStaticCertificateHash() const { + // The base64 encoded, sha224 hash of static certificate json. + return "FIXME"; +} +bool EntityItem::verifyStaticCertificateProperties() const { + // True IIF a non-empty certificateID matches the static certificate json. + // I.e., if we can verify that the certificateID was produced by High Fidelity signing the static certificate hash. + if (_certificateID.isEmpty()) { + return false; + } + return false; // fixme +} + + void EntityItem::adjustShapeInfoByRegistration(ShapeInfo& info) const { if (_registrationPoint != ENTITY_ITEM_DEFAULT_REGISTRATION_POINT) { glm::mat4 scale = glm::scale(getDimensions()); @@ -2829,8 +2850,8 @@ type EntityItem::get##accessor() const { \ #define DEFINE_PROPERTY_SETTER(type, accessor, var) \ void EntityItem::set##accessor(const type##& value) { \ withWriteLock([&] { \ - _##var = value; \ - }); \ + _##var = value; \ + }); \ } #define DEFINE_PROPERTY_ACCESSOR(type, accessor, var) DEFINE_PROPERTY_GETTER(type, accessor, var) DEFINE_PROPERTY_SETTER(type, accessor, var) DEFINE_PROPERTY_ACCESSOR(QString, ItemName, itemName) diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index e2221ac58a..a6153c0234 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -327,10 +327,6 @@ public: QString getStaticCertificateJSON() const; QString getStaticCertificateHash() const; bool verifyStaticCertificateProperties() const; - QString getVerifiedCertificateId(); - - bool getShouldHighlight() const; - void setShouldHighlight(const bool value); // TODO: get rid of users of getRadius()... float getRadius() const; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 4e01bffe5f..007c5dcc6c 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1394,6 +1394,11 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem properties.getType() == EntityTypes::Sphere) { APPEND_ENTITY_PROPERTY(PROP_SHAPE, properties.getShape()); } + APPEND_ENTITY_PROPERTY(PROP_NAME, properties.getName()); + APPEND_ENTITY_PROPERTY(PROP_COLLISION_SOUND_URL, properties.getCollisionSoundURL()); + APPEND_ENTITY_PROPERTY(PROP_ACTION_DATA, properties.getActionData()); + APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha()); + // Certifiable Properties APPEND_ENTITY_PROPERTY(PROP_ITEM_NAME, properties.getItemName()); APPEND_ENTITY_PROPERTY(PROP_ITEM_DESCRIPTION, properties.getItemDescription()); @@ -1405,11 +1410,6 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem APPEND_ENTITY_PROPERTY(PROP_EDITION_NUMBER, properties.getEditionNumber()); APPEND_ENTITY_PROPERTY(PROP_ENTITY_INSTANCE_NUMBER, properties.getEntityInstanceNumber()); APPEND_ENTITY_PROPERTY(PROP_CERTIFICATE_ID, properties.getCertificateID()); - - APPEND_ENTITY_PROPERTY(PROP_NAME, properties.getName()); - APPEND_ENTITY_PROPERTY(PROP_COLLISION_SOUND_URL, properties.getCollisionSoundURL()); - APPEND_ENTITY_PROPERTY(PROP_ACTION_DATA, properties.getActionData()); - APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha()); } if (propertyCount > 0) { @@ -1703,6 +1703,11 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHAPE, QString, setShape); } + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_NAME, QString, setName); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLLISION_SOUND_URL, QString, setCollisionSoundURL); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ACTION_DATA, QByteArray, setActionData); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA, float, setAlpha); + // Certifiable Properties READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ITEM_NAME, QString, setItemName); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ITEM_DESCRIPTION, QString, setItemDescription); @@ -1715,11 +1720,6 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ENTITY_INSTANCE_NUMBER, quint32, setEntityInstanceNumber); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_CERTIFICATE_ID, QString, setCertificateID); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_NAME, QString, setName); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLLISION_SOUND_URL, QString, setCollisionSoundURL); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ACTION_DATA, QByteArray, setActionData); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA, float, setAlpha); - return valid; } diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index b02cf04651..b50ed008a7 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -215,16 +215,18 @@ void ModelEntityItem::debugDump() const { } void ModelEntityItem::setShapeType(ShapeType type) { - if (type != _shapeType) { - if (type == SHAPE_TYPE_STATIC_MESH && _dynamic) { - // 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; + withWriteLock([&] { + if (type != _shapeType) { + if (type == SHAPE_TYPE_STATIC_MESH && _dynamic) { + // 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; + } + _shapeType = type; + _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; } - _shapeType = type; - _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; - } + }); } ShapeType ModelEntityItem::getShapeType() const { @@ -257,13 +259,15 @@ void ModelEntityItem::setModelURL(const QString& url) { } void ModelEntityItem::setCompoundShapeURL(const QString& url) { - if (_compoundShapeURL != url) { - ShapeType oldType = computeTrueShapeType(); - _compoundShapeURL = url; - if (oldType != computeTrueShapeType()) { - _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; + withWriteLock([&] { + if (_compoundShapeURL != url) { + ShapeType oldType = computeTrueShapeType(); + _compoundShapeURL = url; + if (oldType != computeTrueShapeType()) { + _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; + } } - } + }); } void ModelEntityItem::setAnimationURL(const QString& url) { diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index 9bbf4323da..c6616f8cd3 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -633,10 +633,12 @@ void ParticleEffectEntityItem::debugDump() const { } void ParticleEffectEntityItem::setShapeType(ShapeType type) { - if (type != _shapeType) { - _shapeType = type; - _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; - } + withWriteLock([&] { + if (type != _shapeType) { + _shapeType = type; + _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; + } + }); } void ParticleEffectEntityItem::setMaxParticles(quint32 maxParticles) { diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 14e7cd2f40..c3be53599c 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -56,7 +56,7 @@ public: static void setDrawZoneBoundaries(bool value) { _drawZoneBoundaries = value; } virtual bool isReadyToComputeShape() const override { return false; } - void setShapeType(ShapeType type) override { _shapeType = type; } + void setShapeType(ShapeType type) override { withWriteLock([&] { _shapeType = type; }); } virtual ShapeType getShapeType() const override; virtual bool hasCompoundShapeURL() const;