From e3c64429b961170fb12289d82825f39af707a8e2 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 28 Oct 2013 12:10:30 -0700 Subject: [PATCH] added SIMPLE_CHILD_ARRAY implementation to temporarily work around memory corruption --- libraries/voxels/src/VoxelNode.cpp | 21 ++++++++++++++++++++- libraries/voxels/src/VoxelNode.h | 5 +++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libraries/voxels/src/VoxelNode.cpp b/libraries/voxels/src/VoxelNode.cpp index e83ffc1c16..456a2d8e58 100644 --- a/libraries/voxels/src/VoxelNode.cpp +++ b/libraries/voxels/src/VoxelNode.cpp @@ -75,7 +75,12 @@ void VoxelNode::init(unsigned char * octalCode) { _childrenArray[i] = NULL; } #endif // def HAS_AUDIT_CHILDREN - + +#ifdef SIMPLE_CHILD_ARRAY + for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { + _simpleChildArray[i] = NULL; + } +#endif _unknownBufferIndex = true; setBufferIndex(GLBUFFER_INDEX_UNKNOWN); @@ -320,6 +325,9 @@ uint64_t VoxelNode::_couldStoreFourChildrenInternally = 0; uint64_t VoxelNode::_couldNotStoreFourChildrenInternally = 0; VoxelNode* VoxelNode::getChildAtIndex(int childIndex) const { +#ifdef SIMPLE_CHILD_ARRAY + return _simpleChildArray[childIndex]; +#else PerformanceWarning warn(false,"getChildAtIndex",false,&_getChildAtIndexTime,&_getChildAtIndexCalls); VoxelNode* result = NULL; int childCount = getChildCount(); @@ -428,6 +436,7 @@ VoxelNode* VoxelNode::getChildAtIndex(int childIndex) const { } #endif // def HAS_AUDIT_CHILDREN return result; +#endif } void VoxelNode::storeTwoChildren(VoxelNode* childOne, VoxelNode* childTwo) { @@ -680,6 +689,14 @@ void VoxelNode::deleteAllChildren() { } void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) { +#ifdef SIMPLE_CHILD_ARRAY + if (child) { + setAtBit(_childBitmask, childIndex); + } else { + clearAtBit(_childBitmask, childIndex); + } + _simpleChildArray[childIndex] = child; +#else PerformanceWarning warn(false,"setChildAtIndex",false,&_setChildAtIndexTime,&_setChildAtIndexCalls); // Here's how we store things... @@ -1020,6 +1037,8 @@ void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) { _childrenArray[childIndex] = child; auditChildren("setChildAtIndex()"); #endif // def HAS_AUDIT_CHILDREN + +#endif } diff --git a/libraries/voxels/src/VoxelNode.h b/libraries/voxels/src/VoxelNode.h index f76be6227f..c9e892ebb9 100644 --- a/libraries/voxels/src/VoxelNode.h +++ b/libraries/voxels/src/VoxelNode.h @@ -10,6 +10,7 @@ #define __hifi__VoxelNode__ //#define HAS_AUDIT_CHILDREN +#define SIMPLE_CHILD_ARRAY #include #include "AABox.h" @@ -172,6 +173,10 @@ private: uint64_t _lastChanged; /// Client and server, timestamp this node was last changed, 8 bytes /// Client and server, pointers to child nodes, various encodings +#ifdef SIMPLE_CHILD_ARRAY + VoxelNode* _simpleChildArray[8]; /// Only used when HAS_AUDIT_CHILDREN is enabled to help debug children encoding +#endif + union children_t { VoxelNode* single; int32_t offsetsTwoChildren[2];