Merge pull request #2893 from ZappoMan/master

fix crash in model server when you attempt to create an unreasonably small model
This commit is contained in:
Brad Hefta-Gaub 2014-05-21 15:22:20 -07:00
commit 0758611243
3 changed files with 12 additions and 0 deletions

View file

@ -95,6 +95,11 @@ bool ModelTreeElement::bestFitModelBounds(const ModelItem& model) const {
if (_box.contains(clampedMin) && _box.contains(clampedMax)) {
int childForMinimumPoint = getMyChildContainingPoint(clampedMin);
int childForMaximumPoint = getMyChildContainingPoint(clampedMax);
// if this is a really small box, then it's close enough!
if (_box.getScale() <= SMALLEST_REASONABLE_OCTREE_ELEMENT_SCALE) {
return true;
}
// If I contain both the minimum and maximum point, but two different children of mine
// contain those points, then I am the best fit for that model
if (childForMinimumPoint != childForMaximumPoint) {

View file

@ -1412,6 +1412,11 @@ OctreeElement* OctreeElement::getOrCreateChildElementContaining(const AABox& box
if (!child) {
child = addChildAtIndex(childIndex);
}
// if we've made a really small child, then go ahead and use that one.
if (child->getScale() <= SMALLEST_REASONABLE_OCTREE_ELEMENT_SCALE) {
return child;
}
// Now that we have the child to recurse down, let it answer the original question...
return child->getOrCreateChildElementContaining(box);

View file

@ -32,6 +32,8 @@ class OctreePacketData;
class ReadBitstreamToTreeParams;
class VoxelSystem;
const float SMALLEST_REASONABLE_OCTREE_ELEMENT_SCALE = (1.0f / TREE_SCALE) / 10000.0f; // 1/10,000th of a meter
// Callers who want delete hook callbacks should implement this class
class OctreeElementDeleteHook {
public: