remove legacy shapes from EntityItem and friends

This commit is contained in:
Andrew Meadows 2015-02-03 10:05:39 -08:00
parent 28a3c3f469
commit 90202591fc
7 changed files with 4 additions and 50 deletions

View file

@ -57,8 +57,6 @@ void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
_collisionsWillMove = ENTITY_ITEM_DEFAULT_COLLISIONS_WILL_MOVE;
_locked = ENTITY_ITEM_DEFAULT_LOCKED;
_userData = ENTITY_ITEM_DEFAULT_USER_DATA;
recalculateCollisionShape();
}
EntityItem::EntityItem(const EntityItemID& entityItemID) {
@ -541,7 +539,6 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
bytesRead += readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, propertyFlags, overwriteLocalData);
recalculateCollisionShape();
if (overwriteLocalData && (getDirtyFlags() & (EntityItem::DIRTY_POSITION | EntityItem::DIRTY_VELOCITY))) {
// NOTE: This code is attempting to "repair" the old data we just got from the server to make it more
// closely match where the entities should be if they'd stepped forward in time to "now". The server
@ -1024,13 +1021,6 @@ void EntityItem::computeShapeInfo(ShapeInfo& info) const {
info.clear();
}
void EntityItem::recalculateCollisionShape() {
AACube entityAACube = getMinimumAACube();
entityAACube.scale(TREE_SCALE); // scale to meters
_collisionShape.setTranslation(entityAACube.calcCenter());
_collisionShape.setScale(entityAACube.getScale());
}
const float MIN_POSITION_DELTA = 0.0001f;
const float MIN_ALIGNMENT_DOT = 0.9999f;
const float MIN_VELOCITY_DELTA = 0.01f;
@ -1041,7 +1031,6 @@ const float MIN_SPIN_DELTA = 0.0003f;
void EntityItem::updatePosition(const glm::vec3& value) {
if (glm::distance(_position, value) * (float)TREE_SCALE > MIN_POSITION_DELTA) {
_position = value;
recalculateCollisionShape();
_dirtyFlags |= EntityItem::DIRTY_POSITION;
}
}
@ -1050,7 +1039,6 @@ void EntityItem::updatePositionInMeters(const glm::vec3& value) {
glm::vec3 position = glm::clamp(value / (float) TREE_SCALE, 0.0f, 1.0f);
if (glm::distance(_position, position) * (float)TREE_SCALE > MIN_POSITION_DELTA) {
_position = position;
recalculateCollisionShape();
_dirtyFlags |= EntityItem::DIRTY_POSITION;
}
}
@ -1058,7 +1046,6 @@ void EntityItem::updatePositionInMeters(const glm::vec3& value) {
void EntityItem::updateDimensions(const glm::vec3& value) {
if (_dimensions != value) {
_dimensions = glm::abs(value);
recalculateCollisionShape();
_dirtyFlags |= (EntityItem::DIRTY_SHAPE | EntityItem::DIRTY_MASS);
}
}
@ -1067,7 +1054,6 @@ void EntityItem::updateDimensionsInMeters(const glm::vec3& value) {
glm::vec3 dimensions = glm::abs(value) / (float) TREE_SCALE;
if (_dimensions != dimensions) {
_dimensions = dimensions;
recalculateCollisionShape();
_dirtyFlags |= (EntityItem::DIRTY_SHAPE | EntityItem::DIRTY_MASS);
}
}
@ -1075,7 +1061,6 @@ void EntityItem::updateDimensionsInMeters(const glm::vec3& value) {
void EntityItem::updateRotation(const glm::quat& rotation) {
if (glm::dot(_rotation, rotation) < MIN_ALIGNMENT_DOT) {
_rotation = rotation;
recalculateCollisionShape();
_dirtyFlags |= EntityItem::DIRTY_POSITION;
}
}

View file

@ -16,13 +16,11 @@
#include <glm/glm.hpp>
#include <AACubeShape.h>
#include <AnimationCache.h> // for Animation, AnimationCache, and AnimationPointer classes
#include <CollisionInfo.h>
#include <Octree.h> // for EncodeBitstreamParams class
#include <OctreeElement.h> // for OctreeElement::AppendState
#include <OctreePacketData.h>
#include <ShapeInfo.h>
#include "EntityItemID.h"
#include "EntityItemProperties.h"
@ -150,7 +148,7 @@ public:
glm::vec3 getPositionInMeters() const { return _position * (float) TREE_SCALE; } /// get position in meters
/// set position in domain scale units (0.0 - 1.0)
void setPosition(const glm::vec3& value) { _position = value; recalculateCollisionShape(); }
void setPosition(const glm::vec3& value) { _position = value; }
void setPositionInMeters(const glm::vec3& value) /// set position in meter units (0.0 - TREE_SCALE)
{ setPosition(glm::clamp(value / (float) TREE_SCALE, 0.0f, 1.0f)); }
@ -163,13 +161,13 @@ 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
virtual void setDimensions(const glm::vec3& value) { _dimensions = value; recalculateCollisionShape(); }
virtual void setDimensions(const glm::vec3& value) { _dimensions = value; }
/// 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); }
const glm::quat& getRotation() const { return _rotation; }
void setRotation(const glm::quat& rotation) { _rotation = rotation; recalculateCollisionShape(); }
void setRotation(const glm::quat& rotation) { _rotation = rotation; }
float getGlowLevel() const { return _glowLevel; }
void setGlowLevel(float glowLevel) { _glowLevel = glowLevel; }
@ -229,7 +227,7 @@ public:
/// registration point as ratio of entity
void setRegistrationPoint(const glm::vec3& value)
{ _registrationPoint = glm::clamp(value, 0.0f, 1.0f); recalculateCollisionShape(); }
{ _registrationPoint = glm::clamp(value, 0.0f, 1.0f); }
const glm::vec3& getAngularVelocity() const { return _angularVelocity; }
void setAngularVelocity(const glm::vec3& value) { _angularVelocity = value; }
@ -259,7 +257,6 @@ public:
float getRadius() const;
void applyHardCollision(const CollisionInfo& collisionInfo);
virtual const Shape& getCollisionShapeInMeters() const { return _collisionShape; }
virtual bool contains(const glm::vec3& point) const { return getAABox().contains(point); }
virtual void computeShapeInfo(ShapeInfo& info) const;
@ -301,7 +298,6 @@ protected:
static bool _sendPhysicsUpdates;
virtual void initFromEntityItemID(const EntityItemID& entityItemID); // maybe useful to allow subclasses to init
virtual void recalculateCollisionShape();
EntityTypes::EntityType _type;
QUuid _id;
@ -357,8 +353,6 @@ protected:
/// set radius in domain scale units (0.0 - 1.0) this will also reset dimensions to be equal for each axis
void setRadius(float value);
AACubeShape _collisionShape;
// _physicsInfo is a hook reserved for use by the EntitySimulation, which is guaranteed to set _physicsInfo
// to a non-NULL value when the EntityItem has a representation in the physics engine.
void* _physicsInfo; // only set by EntitySimulation

View file

@ -42,16 +42,11 @@ LightEntityItem::LightEntityItem(const EntityItemID& entityItemID, const EntityI
_cutoff = PI;
setProperties(properties);
// a light is not collide-able so we make it's shape be a tiny sphere at origin
_emptyShape.setTranslation(glm::vec3(0.0f, 0.0f, 0.0f));
_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();
}

View file

@ -12,7 +12,6 @@
#ifndef hifi_LightEntityItem_h
#define hifi_LightEntityItem_h
#include <SphereShape.h>
#include "EntityItem.h"
class LightEntityItem : public EntityItem {
@ -98,13 +97,10 @@ public:
float getCutoff() const { return _cutoff; }
void setCutoff(float value) { _cutoff = value; }
virtual const Shape& getCollisionShapeInMeters() const { return _emptyShape; }
static bool getLightsArePickable() { return _lightsArePickable; }
static void setLightsArePickable(bool value) { _lightsArePickable = value; }
protected:
virtual void recalculateCollisionShape() { /* nothing to do */ }
// properties of a light
rgbColor _ambientColor;
@ -117,9 +113,6 @@ protected:
float _exponent;
float _cutoff;
// used for collision detection
SphereShape _emptyShape;
static bool _lightsArePickable;
};

View file

@ -94,13 +94,6 @@ void SphereEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBi
APPEND_ENTITY_PROPERTY(PROP_COLOR, appendColor, getColor());
}
void SphereEntityItem::recalculateCollisionShape() {
_sphereShape.setTranslation(getCenterInMeters());
glm::vec3 dimensionsInMeters = getDimensionsInMeters();
float largestDiameter = glm::max(dimensionsInMeters.x, dimensionsInMeters.y, dimensionsInMeters.z);
_sphereShape.setRadius(largestDiameter / 2.0f);
}
void SphereEntityItem::computeShapeInfo(ShapeInfo& info) const {
glm::vec3 halfExtents = 0.5f * getDimensionsInMeters();
// TODO: support ellipsoid shapes

View file

@ -12,7 +12,6 @@
#ifndef hifi_SphereEntityItem_h
#define hifi_SphereEntityItem_h
#include <SphereShape.h>
#include "EntityItem.h"
class SphereEntityItem : public EntityItem {
@ -51,8 +50,6 @@ public:
_color[BLUE_INDEX] = value.blue;
}
virtual const Shape& getCollisionShapeInMeters() const { return _sphereShape; }
// TODO: implement proper contains for 3D ellipsoid
//virtual bool contains(const glm::vec3& point) const;
@ -66,10 +63,8 @@ public:
virtual void debugDump() const;
protected:
virtual void recalculateCollisionShape();
rgbColor _color;
SphereShape _sphereShape;
};
#endif // hifi_SphereEntityItem_h

View file

@ -44,7 +44,6 @@ 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 {