EntityItem base class now computes shapeInfo

This commit is contained in:
Andrew Meadows 2015-01-30 14:17:29 -08:00
parent b035c5b082
commit 80f6f718d0
5 changed files with 19 additions and 15 deletions

View file

@ -96,11 +96,6 @@ void BoxEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst
APPEND_ENTITY_PROPERTY(PROP_COLOR, appendColor, getColor());
}
void BoxEntityItem::computeShapeInfo(ShapeInfo& info) const {
glm::vec3 halfExtents = 0.5f * getDimensionsInMeters();
info.setBox(halfExtents);
}
void BoxEntityItem::debugDump() const {
quint64 now = usecTimestampNow();
qDebug() << " BOX EntityItem id:" << getEntityItemID() << "---------------------------------------------";

View file

@ -51,8 +51,6 @@ public:
_color[BLUE_INDEX] = value.blue;
}
void computeShapeInfo(ShapeInfo& info) const;
virtual void debugDump() const;
protected:

View file

@ -1022,6 +1022,25 @@ float EntityItem::getRadius() const {
void EntityItem::computeShapeInfo(ShapeInfo& info) const {
info.clear();
if (_type == EntityTypes::Sphere) {
glm::vec3 halfExtents = 0.5f * getDimensionsInMeters();
// TODO: support ellipsoid shapes
info.setSphere(halfExtents.x);
} else if (_type == EntityTypes::Box) {
glm::vec3 halfExtents = 0.5f * getDimensionsInMeters();
info.setBox(halfExtents);
} else if (_type == EntityTypes::Model) {
// For first approximation we just boxify all models... but only if they are small enough.
// The limit here is chosen to something that most avatars could not comfortably fit inside
// to prevent houses from getting boxified... we don't want the things inside houses to
// collide with a house as if it were a giant solid block.
const float MAX_SIZE_FOR_BOXIFICATION_HACK = 3.0f;
float diagonal = glm::length(getDimensionsInMeters());
if (diagonal < MAX_SIZE_FOR_BOXIFICATION_HACK) {
glm::vec3 halfExtents = 0.5f * getDimensionsInMeters();
info.setBox(halfExtents);
}
}
}
void EntityItem::recalculateCollisionShape() {

View file

@ -101,12 +101,6 @@ void SphereEntityItem::recalculateCollisionShape() {
_sphereShape.setRadius(largestDiameter / 2.0f);
}
void SphereEntityItem::computeShapeInfo(ShapeInfo& info) const {
glm::vec3 halfExtents = 0.5f * getDimensionsInMeters();
// TODO: support ellipsoid shapes
info.setSphere(halfExtents.x);
}
bool SphereEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face,
void** intersectedObject, bool precisionPicking) const {

View file

@ -56,8 +56,6 @@ public:
// TODO: implement proper contains for 3D ellipsoid
//virtual bool contains(const glm::vec3& point) const;
void computeShapeInfo(ShapeInfo& info) const;
virtual bool supportsDetailedRayIntersection() const { return true; }
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face,