From 1566c01ad16a973f22990653b3dab8e5bd476db8 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 13 Jan 2022 21:09:52 -0800 Subject: SL-16607: Cleanup magic number for no child nodes --- indra/llmath/lloctree.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'indra') diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index 8c4a1304b4..80eca781a9 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -92,10 +92,15 @@ public: typedef LLOctreeNode oct_node; typedef LLOctreeListener oct_listener; + enum + { + NO_CHILD_NODES = 255 // Note: This is an U8 to match the max value in mChildMap[] + }; + LLOctreeNode( const LLVector4a& center, const LLVector4a& size, BaseType* parent, - U8 octant = 255) + U8 octant = NO_CHILD_NODES) : mParent((oct_node*)parent), mOctant(octant) { @@ -108,7 +113,7 @@ public: mSize = size; updateMinMax(); - if ((mOctant == 255) && mParent) + if ((mOctant == NO_CHILD_NODES) && mParent) { mOctant = ((oct_node*) mParent)->getOctant(mCenter); } @@ -253,7 +258,7 @@ public: for (U32 i = 0; i < 8; i++) { U8 idx = mChildMap[i]; - if (idx != 255) + if (idx != NO_CHILD_NODES) { LLOctreeNode* child = mChild[idx]; @@ -286,7 +291,7 @@ public: // the data U8 next_node = node->mChildMap[octant]; - while (next_node != 255 && node->getSize()[0] >= rad) + while (next_node != NO_CHILD_NODES && node->getSize()[0] >= rad) { node = node->getChild(next_node); octant = node->getOctant(pos); @@ -514,9 +519,7 @@ public: void clearChildren() { mChildCount = 0; - - U32* foo = (U32*) mChildMap; - foo[0] = foo[1] = 0xFFFFFFFF; + memset(mChildMap, NO_CHILD_NODES, sizeof(mChildMap)); } void validate() @@ -607,11 +610,9 @@ public: --mChildCount; mChild[index] = mChild[mChildCount]; - //rebuild child map - U32* foo = (U32*) mChildMap; - foo[0] = foo[1] = 0xFFFFFFFF; + memset(mChildMap, NO_CHILD_NODES, sizeof(mChildMap)); for (U32 i = 0; i < mChildCount; ++i) { -- cgit v1.2.3