From 0c2765511e46d292fa14005bd9369cf369f4c149 Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Fri, 15 Apr 2011 18:30:22 +0200 Subject: [PATCH] Unhack some Inertia octree hack. No performance change. --- indra/llmath/lloctree.h | 20 ++-- indra/newview/llspatialpartition.cpp | 153 ++++++++++++++------------- 2 files changed, 86 insertions(+), 87 deletions(-) diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index ff62b703e..ced65d1d9 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -44,7 +44,12 @@ #define OCT_ERRS LL_WARNS("OctreeErrors") #endif +#if LL_DEBUG #define LL_OCTREE_PARANOIA_CHECK 0 +#else +#define LL_OCTREE_PARANOIA_CHECK 0 +#endif + #define LL_OCTREE_MAX_CAPACITY 128 template class LLOctreeNode; @@ -295,7 +300,7 @@ public: //if this is a redundant insertion, error out (should never happen) if (mData.find(data) != mData.end()) { - llwarns << "Redundant octree insertion detected. " << data << llendl; + llerrs << "Redundant octree insertion detected. " << data << llendl; return false; } #endif @@ -313,16 +318,9 @@ public: child = getChild(i); if (child->isInside(data->getPositionGroup())) { - // - // tempfix, test, shitsux - //child->insert(data); - if(child->getElementCount() < LL_OCTREE_MAX_CAPACITY) - { - child->insert(data); - return false; - } - //return false; - // + llassert(child->getElementCount() <= LL_OCTREE_MAX_CAPACITY); + child->insert(data); + return false; } } diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 63784107b..7f20e7e3e 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -116,6 +116,78 @@ void validate_drawable(LLDrawable* drawablep) #define validate_drawable(x) #endif +class LLOctreeStateCheck : public LLOctreeTraveler +{ +public: + U32 mInheritedMask[LLViewerCamera::NUM_CAMERAS]; + + LLOctreeStateCheck() + { + for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) + { + mInheritedMask[i] = 0; + } + } + + virtual void traverse(const LLSpatialGroup::OctreeNode* node) + { + LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0); + + node->accept(this); + + + U32 temp[LLViewerCamera::NUM_CAMERAS]; + + for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) + { + temp[i] = mInheritedMask[i]; + mInheritedMask[i] |= group->mOcclusionState[i] & LLSpatialGroup::OCCLUDED; + } + + for (U32 i = 0; i < node->getChildCount(); i++) + { + traverse(node->getChild(i)); + } + + for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) + { + mInheritedMask[i] = temp[i]; + } + } + + + virtual void visit(const LLOctreeNode* state) + { + LLSpatialGroup* group = (LLSpatialGroup*) state->getListener(0); + + for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) + { + if (mInheritedMask[i] && !(group->mOcclusionState[i] & mInheritedMask[i])) + { + llerrs << "Spatial group failed inherited mask test." << llendl; + } + } + + if (group->isState(LLSpatialGroup::DIRTY)) + { + assert_parent_state(group, LLSpatialGroup::DIRTY); + } + } + + void assert_parent_state(LLSpatialGroup* group, LLSpatialGroup::eSpatialState state) + { + LLSpatialGroup* parent = group->getParent(); + while (parent) + { + if (!parent->isState(state)) + { + llerrs << "Spatial group failed parent state check." << llendl; + } + parent = parent->getParent(); + } + } +}; + S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad) { @@ -421,15 +493,17 @@ void validate_draw_info(LLDrawInfo& params) { if (indicesp[i] < (U16)params.mStart) { - llerrs << "Draw batch has vertex buffer index out of range error (index too low)." << llendl; + llerrs << "Draw batch has vertex buffer index out of range error (index too low). " + << "indicesp["< (U16)params.mEnd) { - llerrs << "Draw batch has vertex buffer index out of range error (index too high)." << llendl; + llerrs << "Draw batch has vertex buffer index out of range error (index too high)." + << "indicesp["< -{ -public: - U32 mInheritedMask[LLViewerCamera::NUM_CAMERAS]; - - LLOctreeStateCheck() - { - for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) - { - mInheritedMask[i] = 0; - } - } - - virtual void traverse(const LLSpatialGroup::OctreeNode* node) - { - LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0); - - node->accept(this); - - - U32 temp[LLViewerCamera::NUM_CAMERAS]; - - for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) - { - temp[i] = mInheritedMask[i]; - mInheritedMask[i] |= group->mOcclusionState[i] & LLSpatialGroup::OCCLUDED; - } - - for (U32 i = 0; i < node->getChildCount(); i++) - { - traverse(node->getChild(i)); - } - - for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) - { - mInheritedMask[i] = temp[i]; - } - } - - - virtual void visit(const LLOctreeNode* state) - { - LLSpatialGroup* group = (LLSpatialGroup*) state->getListener(0); - - for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++) - { - if (mInheritedMask[i] && !(group->mOcclusionState[i] & mInheritedMask[i])) - { - llerrs << "Spatial group failed inherited mask test." << llendl; - } - } - - if (group->isState(LLSpatialGroup::DIRTY)) - { - assert_parent_state(group, LLSpatialGroup::DIRTY); - } - } - - void assert_parent_state(LLSpatialGroup* group, LLSpatialGroup::eSpatialState state) - { - LLSpatialGroup* parent = group->getParent(); - while (parent) - { - if (!parent->isState(state)) - { - llerrs << "Spatial group failed parent state check." << llendl; - } - parent = parent->getParent(); - } - } -}; - - void LLSpatialPartition::renderDebug() { if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCTREE |