fix math for expanded bounding box

This commit is contained in:
Andrew Meadows 2017-07-21 10:17:10 -07:00
parent e1eb223616
commit 1e6fc85e3e

View file

@ -952,10 +952,13 @@ bool SpatiallyNestable::checkAndMaybeUpdateQueryAACube() {
bool success; bool success;
AACube maxAACube = getMaximumAACube(success); AACube maxAACube = getMaximumAACube(success);
if (success && (!_queryAACubeSet || !_queryAACube.contains(maxAACube))) { if (success && (!_queryAACubeSet || !_queryAACube.contains(maxAACube))) {
const float expansionFactor = (_parentJointIndex != INVALID_JOINT_INDEX || _children.size() > 0 ) if (_parentJointIndex != INVALID_JOINT_INDEX || _children.size() > 0 ) {
? PARENTED_EXPANSION_FACTOR : 1.0f; // make an expanded AACube centered on the object
float scale = maxAACube.getScale(); float scale = PARENTED_EXPANSION_FACTOR * maxAACube.getScale();
_queryAACube = AACube(maxAACube.getCorner() - glm::vec3(scale), scale * expansionFactor); _queryAACube = AACube(maxAACube.calcCenter() - glm::vec3(0.5f * scale), scale);
} else {
_queryAACube = maxAACube;
}
getThisPointer()->forEachDescendant([&](SpatiallyNestablePointer descendant) { getThisPointer()->forEachDescendant([&](SpatiallyNestablePointer descendant) {
bool success; bool success;
@ -1002,12 +1005,14 @@ bool SpatiallyNestable::queryAACubeNeedsUpdate() const {
void SpatiallyNestable::updateQueryAACube() { void SpatiallyNestable::updateQueryAACube() {
bool success; bool success;
AACube currentAACube = getMaximumAACube(success); AACube maxAACube = getMaximumAACube(success);
// make an AACube with edges thrice as long and centered on the object if (_parentJointIndex != INVALID_JOINT_INDEX || _children.size() > 0 ) {
const float expansionFactor = (_parentJointIndex != INVALID_JOINT_INDEX || _children.size() > 0 ) ? // make an expanded AACube centered on the object
PARENTED_EXPANSION_FACTOR : 1.0f; float scale = PARENTED_EXPANSION_FACTOR * maxAACube.getScale();
float scale = currentAACube.getScale(); _queryAACube = AACube(maxAACube.calcCenter() - glm::vec3(0.5f * scale), scale);
_queryAACube = AACube(currentAACube.getCorner() - glm::vec3(scale), scale * expansionFactor); } else {
_queryAACube = maxAACube;
}
getThisPointer()->forEachDescendant([&](SpatiallyNestablePointer descendant) { getThisPointer()->forEachDescendant([&](SpatiallyNestablePointer descendant) {
bool success; bool success;