mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:44:01 +02:00
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:
commit
0758611243
3 changed files with 12 additions and 0 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue