move shape polymorphism to ModelEntityItem

This commit is contained in:
Andrew Meadows 2015-01-30 16:25:35 -08:00
parent bc52ba1d29
commit 9da6b623a3
3 changed files with 17 additions and 12 deletions

View file

@ -1021,18 +1021,7 @@ float EntityItem::getRadius() const {
}
void EntityItem::computeShapeInfo(ShapeInfo& info) const {
// HACK: Default first first approximation is to boxify the entity... but only if it is 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);
} else {
info.clear();
}
info.clear();
}
void EntityItem::recalculateCollisionShape() {

View file

@ -245,6 +245,21 @@ bool ModelEntityItem::needsToCallUpdate() const {
return isAnimatingSomething() ? true : EntityItem::needsToCallUpdate();
}
void ModelEntityItem::computeShapeInfo(ShapeInfo& info) const {
// HACK: Default first first approximation is to boxify the entity... but only if it is 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);
} else {
info.clear();
}
}
void ModelEntityItem::update(const quint64& now) {
// only advance the frame index if we're playing
if (getAnimationIsPlaying()) {

View file

@ -46,6 +46,7 @@ public:
virtual void update(const quint64& now);
virtual bool needsToCallUpdate() const;
void computeShapeInfo(ShapeInfo& info) const;
virtual void debugDump() const;