parents AACube should encompass all children's

This commit is contained in:
Seth Alves 2015-12-21 10:55:07 -08:00
parent 1d9a81d5d4
commit abaa329984
3 changed files with 22 additions and 0 deletions

View file

@ -465,3 +465,10 @@ AABox AACube::clamp(float min, float max) const {
return temp.clamp(min, max);
}
AACube& AACube::operator += (const glm::vec3& point) {
_corner = glm::min(_corner, point);
glm::vec3 scale = point - _corner;
_scale = glm::max(_scale, scale.x, scale.y, scale.z);
return (*this);
}

View file

@ -64,6 +64,8 @@ public:
AABox clamp(const glm::vec3& min, const glm::vec3& max) const;
AABox clamp(float min, float max) const;
AACube& operator += (const glm::vec3& point);
private:
glm::vec3 getClosestPointOnFace(const glm::vec3& point, BoxFace face) const;
glm::vec3 getClosestPointOnFace(const glm::vec4& origin, const glm::vec4& direction, BoxFace face) const;

View file

@ -585,6 +585,19 @@ bool SpatiallyNestable::setPuffedQueryAACube() {
_queryAACube = AACube(currentAACube.getCorner() - glm::vec3(currentAACube.getScale()), currentAACube.getScale() * 3.0f);
// _queryAACube = AACube(currentAACube.getCorner(), currentAACube.getScale());
_queryAACubeSet = true;
getThisPointer()->forEachDescendant([&](SpatiallyNestablePointer descendant) {
bool success;
AACube descendantAACube = descendant->getMaximumAACube(success);
if (success) {
if (_queryAACube.contains(currentAACube)) {
return;
}
_queryAACube += descendantAACube.getMinimumPoint();
_queryAACube += descendantAACube.getMaximumPoint();
}
});
return true;
}