Merge pull request #3919 from ZappoMan/enforceDimensionsForLightsAndText

enforce dimensions for Light and Text entities
This commit is contained in:
Philip Rosedale 2014-12-08 09:19:06 -08:00
commit 7de2256744
5 changed files with 21 additions and 1 deletions

View file

@ -160,7 +160,7 @@ public:
float getLargestDimension() const { return glm::length(_dimensions); } /// get the largest possible dimension
/// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately
void setDimensions(const glm::vec3& value) { _dimensions = value; recalculateCollisionShape(); }
virtual void setDimensions(const glm::vec3& value) { _dimensions = value; recalculateCollisionShape(); }
/// set dimensions in meter units (0.0 - TREE_SCALE) this will also reset radius appropriately
void setDimensionsInMeters(const glm::vec3& value) { setDimensions(value / (float) TREE_SCALE); }

View file

@ -47,6 +47,13 @@ LightEntityItem::LightEntityItem(const EntityItemID& entityItemID, const EntityI
_emptyShape.setRadius(0.0f);
}
void LightEntityItem::setDimensions(const glm::vec3& value) {
float maxDimension = glm::max(value.x, value.y, value.z);
_dimensions = glm::vec3(maxDimension, maxDimension, maxDimension);
recalculateCollisionShape();
}
EntityItemProperties LightEntityItem::getProperties() const {
EntityItemProperties properties = EntityItem::getProperties(); // get the properties from our base class

View file

@ -22,6 +22,9 @@ public:
LightEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
ALLOW_INSTANTIATION // This class can be instantiated
/// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately
virtual void setDimensions(const glm::vec3& value);
// methods for getting/setting all properties of an entity
virtual EntityItemProperties getProperties() const;

View file

@ -40,6 +40,13 @@ TextEntityItem::TextEntityItem(const EntityItemID& entityItemID, const EntityIte
setProperties(properties, true);
}
void TextEntityItem::setDimensions(const glm::vec3& value) {
// NOTE: Text Entities always have a "depth" of 1cm.
float fixedDepth = 0.01f / (float)TREE_SCALE;
_dimensions = glm::vec3(value.x, value.y, fixedDepth);
recalculateCollisionShape();
}
EntityItemProperties TextEntityItem::getProperties() const {
EntityItemProperties properties = EntityItem::getProperties(); // get the properties from our base class

View file

@ -21,6 +21,9 @@ public:
TextEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
ALLOW_INSTANTIATION // This class can be instantiated
/// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately
virtual void setDimensions(const glm::vec3& value);
// methods for getting/setting all properties of an entity
virtual EntityItemProperties getProperties() const;