summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/lloctree.h45
-rw-r--r--indra/llmath/llvolume.cpp26
2 files changed, 40 insertions, 31 deletions
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index 8c4a1304b4..2283df1e1a 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -34,6 +34,9 @@
#define OCT_ERRS LL_WARNS("OctreeErrors")
+#define OCTREE_DEBUG_COLOR_REMOVE 0x0000FF // r
+#define OCTREE_DEBUG_COLOR_INSERT 0x00FF00 // g
+#define OCTREE_DEBUG_COLOR_BALANCE 0xFF0000 // b
extern U32 gOctreeMaxCapacity;
extern float gOctreeMinSize;
@@ -92,10 +95,15 @@ public:
typedef LLOctreeNode<T> oct_node;
typedef LLOctreeListener<T> 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 +116,7 @@ public:
mSize = size;
updateMinMax();
- if ((mOctant == 255) && mParent)
+ if ((mOctant == NO_CHILD_NODES) && mParent)
{
mOctant = ((oct_node*) mParent)->getOctant(mCenter);
}
@@ -118,9 +126,9 @@ public:
clearChildren();
}
- virtual ~LLOctreeNode()
+ virtual ~LLOctreeNode()
{
- BaseType::destroyListeners();
+ BaseType::destroyListeners();
for (U32 i = 0; i < mElementCount; ++i)
{
@@ -159,7 +167,7 @@ public:
return rad <= mSize[0]*2.f && isInside(pos);
}
- inline bool isInside(T* data) const
+ inline bool isInside(T* data) const
{
return isInside(data->getPositionGroup(), data->getBinRadius());
}
@@ -253,7 +261,7 @@ public:
for (U32 i = 0; i < 8; i++)
{
U8 idx = mChildMap[i];
- if (idx != 255)
+ if (idx != NO_CHILD_NODES)
{
LLOctreeNode<T>* child = mChild[idx];
@@ -276,7 +284,7 @@ public:
LLOctreeNode<T>* node = this;
if (node->isInside(pos, rad))
- {
+ {
//do a quick search by octant
U8 octant = node->getOctant(pos);
@@ -286,7 +294,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);
@@ -303,6 +311,8 @@ public:
virtual bool insert(T* data)
{
+ //LL_PROFILE_ZONE_NAMED_COLOR("Octree::insert()",OCTREE_DEBUG_COLOR_INSERT);
+
if (data == NULL || data->getBinIndex() != -1)
{
OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE BRANCH !!!" << LL_ENDL;
@@ -449,6 +459,8 @@ public:
bool remove(T* data)
{
+ //LL_PROFILE_ZONE_NAMED_COLOR("Octree::remove()", OCTREE_DEBUG_COLOR_REMOVE);
+
S32 i = data->getBinIndex();
if (i >= 0 && i < mElementCount)
@@ -514,9 +526,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 +617,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)
{
@@ -647,7 +655,7 @@ public:
OCT_ERRS << "Octree failed to delete requested child." << LL_ENDL;
}
-protected:
+protected:
typedef enum
{
CENTER = 0,
@@ -671,7 +679,6 @@ protected:
element_list mData;
element_iter mDataEnd;
U32 mElementCount;
-
};
//just like a regular node, except it might expand on insert and compress on balance
@@ -680,7 +687,7 @@ class LLOctreeRoot : public LLOctreeNode<T>
{
public:
typedef LLOctreeNode<T> BaseType;
- typedef LLOctreeNode<T> oct_node;
+ typedef LLOctreeNode<T> oct_node;
LLOctreeRoot(const LLVector4a& center,
const LLVector4a& size,
@@ -691,9 +698,11 @@ public:
bool balance()
{
+ //LL_PROFILE_ZONE_NAMED_COLOR("Octree::balance()",OCTREE_DEBUG_COLOR_BALANCE);
+
if (this->getChildCount() == 1 &&
!(this->mChild[0]->isLeaf()) &&
- this->mChild[0]->getElementCount() == 0)
+ this->mChild[0]->getElementCount() == 0)
{ //if we have only one child and that child is an empty branch, make that child the root
oct_node* child = this->mChild[0];
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index c226315e5c..e9ccde5fae 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -383,7 +383,7 @@ public:
virtual void visit(const LLOctreeNode<LLVolumeTriangle>* branch)
{ //this is a depth first traversal, so it's safe to assum all children have complete
//bounding data
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
LLVolumeOctreeListener* node = (LLVolumeOctreeListener*) branch->getListener(0);
@@ -823,7 +823,7 @@ S32 LLProfile::getNumPoints(const LLProfileParams& params, BOOL path_open,F32 de
BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detail, S32 split,
BOOL is_sculpted, S32 sculpt_size)
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
if ((!mDirty) && (!is_sculpted))
{
@@ -1305,7 +1305,7 @@ S32 LLPath::getNumNGonPoints(const LLPathParams& params, S32 sides, F32 startOff
void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 end_scale, F32 twist_scale)
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
// Generates a circular path, starting at (1, 0, 0), counterclockwise along the xz plane.
static const F32 tableScale[] = { 1, 1, 1, 0.5f, 0.707107f, 0.53f, 0.525f, 0.5f };
@@ -1541,7 +1541,7 @@ S32 LLPath::getNumPoints(const LLPathParams& params, F32 detail)
BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
BOOL is_sculpted, S32 sculpt_size)
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
if ((!mDirty) && (!is_sculpted))
{
@@ -2119,7 +2119,7 @@ LLVolume::~LLVolume()
BOOL LLVolume::generate()
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
LL_CHECK_MEMORY
llassert_always(mProfilep);
@@ -2379,7 +2379,7 @@ bool LLVolumeFace::VertexData::compareNormal(const LLVolumeFace::VertexData& rhs
bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
//input stream is now pointing at a zlib compressed block of LLSD
//decompress block
@@ -2766,7 +2766,7 @@ S32 LLVolume::getNumFaces() const
void LLVolume::createVolumeFaces()
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
if (mGenerateSingleFace)
{
@@ -3733,7 +3733,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
const LLMatrix3& norm_mat_in,
S32 face_mask)
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
LLMatrix4a mat;
mat.loadu(mat_in);
@@ -4861,7 +4861,7 @@ void LLVolumeFace::freeData()
BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
//tree for this face is no longer valid
delete mOctree;
@@ -5531,7 +5531,7 @@ bool LLVolumeFace::cacheOptimize()
void LLVolumeFace::createOctree(F32 scaler, const LLVector4a& center, const LLVector4a& size)
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
if (mOctree)
{
@@ -6306,7 +6306,7 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe
void LLVolumeFace::createTangents()
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
if (!mTangents)
{
@@ -6503,7 +6503,7 @@ void LLVolumeFace::fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v,
BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
LL_CHECK_MEMORY
BOOL flat = mTypeMask & FLAT_MASK;
@@ -6997,7 +6997,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVector4a *normal,
const LLVector2 *texcoord, U32 triangleCount, const U16* index_array, LLVector4a *tangent)
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
//LLVector4a *tan1 = new LLVector4a[vertexCount * 2];
LLVector4a* tan1 = (LLVector4a*) ll_aligned_malloc_16(vertexCount*2*sizeof(LLVector4a));