From 51bacdebddf74724425746a9538b3a645dd15921 Mon Sep 17 00:00:00 2001 From: samcake Date: Wed, 10 Feb 2016 11:52:37 -0800 Subject: [PATCH] Trying to notify the entity changes to the render item correctly, need more work --- libraries/entities-renderer/src/RenderableEntityItem.h | 1 + libraries/entities/src/EntityItem.cpp | 6 +++++- libraries/entities/src/EntityItem.h | 7 +++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableEntityItem.h b/libraries/entities-renderer/src/RenderableEntityItem.h index fc4d00f9a5..aaeecbdc0e 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.h +++ b/libraries/entities-renderer/src/RenderableEntityItem.h @@ -95,6 +95,7 @@ public: \ virtual bool addToScene(EntityItemPointer self, std::shared_ptr scene, render::PendingChanges& pendingChanges) override { return _renderHelper.addToScene(self, scene, pendingChanges); } \ virtual void removeFromScene(EntityItemPointer self, std::shared_ptr scene, render::PendingChanges& pendingChanges) override { _renderHelper.removeFromScene(self, scene, pendingChanges); } \ virtual void locationChanged() override { EntityItem::locationChanged(); _renderHelper.notifyChanged(); } \ + virtual void dimensionsChanged() override { EntityItem::dimensionsChanged(); _renderHelper.notifyChanged(); } \ private: \ SimpleRenderableEntityItem _renderHelper; diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index e56f2c267a..2793b68eaf 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1192,7 +1192,6 @@ void EntityItem::setDimensions(const glm::vec3& value) { return; } setScale(value); - requiresRecalcBoxes(); } /// The maximum bounding cube for the entity, independent of it's rotation. @@ -1916,3 +1915,8 @@ void EntityItem::locationChanged() { requiresRecalcBoxes(); SpatiallyNestable::locationChanged(); // tell all the children, also } + +void EntityItem::dimensionsChanged() { + requiresRecalcBoxes(); + SpatiallyNestable::dimensionsChanged(); // Do what you have to do +} diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index c8b54bca87..6a02816681 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -250,8 +250,9 @@ public: const glm::vec3& getRegistrationPoint() const { return _registrationPoint; } /// registration point as ratio of entity /// registration point as ratio of entity - void setRegistrationPoint(const glm::vec3& value) - { _registrationPoint = glm::clamp(value, 0.0f, 1.0f); requiresRecalcBoxes(); } + void setRegistrationPoint(const glm::vec3& value) { + _registrationPoint = glm::clamp(value, 0.0f, 1.0f); dimensionsChanged(); // Registration Point affects the bounding box + } bool hasAngularVelocity() const { return getAngularVelocity() != ENTITY_ITEM_ZERO_VEC3; } @@ -405,6 +406,8 @@ protected: void setActionDataInternal(QByteArray actionData); virtual void locationChanged() override; + virtual void dimensionsChanged() override; + EntityTypes::EntityType _type; quint64 _lastSimulated; // last time this entity called simulate(), this includes velocity, angular velocity, // and physics changes