summaryrefslogtreecommitdiff
path: root/indra/llmath/llvolume.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath/llvolume.cpp')
-rw-r--r--indra/llmath/llvolume.cpp608
1 files changed, 294 insertions, 314 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 69138f64f5..8bcfd591b4 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -65,66 +65,66 @@
#define DEBUG_SILHOUETTE_NORMALS 0 // TomY: Use this to display normals using the silhouette
#define DEBUG_SILHOUETTE_EDGE_MAP 0 // DaveP: Use this to display edge map using the silhouette
-const F32 MIN_CUT_DELTA = 0.02f;
+constexpr F32 MIN_CUT_DELTA = 0.02f;
-const F32 HOLLOW_MIN = 0.f;
-const F32 HOLLOW_MAX = 0.95f;
-const F32 HOLLOW_MAX_SQUARE = 0.7f;
+constexpr F32 HOLLOW_MIN = 0.f;
+constexpr F32 HOLLOW_MAX = 0.95f;
+constexpr F32 HOLLOW_MAX_SQUARE = 0.7f;
-const F32 TWIST_MIN = -1.f;
-const F32 TWIST_MAX = 1.f;
+constexpr F32 TWIST_MIN = -1.f;
+constexpr F32 TWIST_MAX = 1.f;
-const F32 RATIO_MIN = 0.f;
-const F32 RATIO_MAX = 2.f; // Tom Y: Inverted sense here: 0 = top taper, 2 = bottom taper
+constexpr F32 RATIO_MIN = 0.f;
+constexpr F32 RATIO_MAX = 2.f; // Tom Y: Inverted sense here: 0 = top taper, 2 = bottom taper
-const F32 HOLE_X_MIN= 0.05f;
-const F32 HOLE_X_MAX= 1.0f;
+constexpr F32 HOLE_X_MIN= 0.05f;
+constexpr F32 HOLE_X_MAX= 1.0f;
-const F32 HOLE_Y_MIN= 0.05f;
-const F32 HOLE_Y_MAX= 0.5f;
+constexpr F32 HOLE_Y_MIN= 0.05f;
+constexpr F32 HOLE_Y_MAX= 0.5f;
-const F32 SHEAR_MIN = -0.5f;
-const F32 SHEAR_MAX = 0.5f;
+constexpr F32 SHEAR_MIN = -0.5f;
+constexpr F32 SHEAR_MAX = 0.5f;
-const F32 REV_MIN = 1.f;
-const F32 REV_MAX = 4.f;
+constexpr F32 REV_MIN = 1.f;
+constexpr F32 REV_MAX = 4.f;
-const F32 TAPER_MIN = -1.f;
-const F32 TAPER_MAX = 1.f;
+constexpr F32 TAPER_MIN = -1.f;
+constexpr F32 TAPER_MAX = 1.f;
-const F32 SKEW_MIN = -0.95f;
-const F32 SKEW_MAX = 0.95f;
+constexpr F32 SKEW_MIN = -0.95f;
+constexpr F32 SKEW_MAX = 0.95f;
-const F32 SCULPT_MIN_AREA = 0.002f;
-const S32 SCULPT_MIN_AREA_DETAIL = 1;
+constexpr F32 SCULPT_MIN_AREA = 0.002f;
+constexpr S32 SCULPT_MIN_AREA_DETAIL = 1;
-BOOL gDebugGL = FALSE; // See settings.xml "RenderDebugGL"
+bool gDebugGL = false; // See settings.xml "RenderDebugGL"
-BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm)
+bool check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm)
{
LLVector3 test = (pt2-pt1)%(pt3-pt2);
//answer
if(test * norm < 0)
{
- return FALSE;
+ return false;
}
else
{
- return TRUE;
+ return true;
}
}
-BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size)
+bool LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size)
{
return LLLineSegmentBoxIntersect(start.mV, end.mV, center.mV, size.mV);
}
-BOOL LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* center, const F32* size)
+bool LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* center, const F32* size)
{
- F32 fAWdU[3];
- F32 dir[3];
- F32 diff[3];
+ F32 fAWdU[3]{};
+ F32 dir[3]{};
+ F32 diff[3]{};
for (U32 i = 0; i < 3; i++)
{
@@ -222,11 +222,11 @@ void calc_tangent_from_triangle(
// intersect test between triangle vert0, vert1, vert2 and a ray from orig in direction dir.
-// returns TRUE if intersecting and returns barycentric coordinates in intersection_a, intersection_b,
+// returns true if intersecting and returns barycentric coordinates in intersection_a, intersection_b,
// and returns the intersection point along dir in intersection_t.
// Moller-Trumbore algorithm
-BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir,
+bool LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir,
F32& intersection_a, F32& intersection_b, F32& intersection_t)
{
@@ -288,15 +288,15 @@ BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, co
intersection_a = u[0];
intersection_b = v[0];
intersection_t = t[0];
- return TRUE;
+ return true;
}
}
}
- return FALSE;
+ return false;
}
-BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir,
+bool LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir,
F32& intersection_a, F32& intersection_b, F32& intersection_t)
{
F32 u, v, t;
@@ -319,7 +319,7 @@ BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& v
if (det > -F_APPROXIMATELY_ZERO && det < F_APPROXIMATELY_ZERO)
{
- return FALSE;
+ return false;
}
F32 inv_det = 1.f / det;
@@ -332,7 +332,7 @@ BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& v
u = (tvec.dot3(pvec).getF32()) * inv_det;
if (u < 0.f || u > 1.f)
{
- return FALSE;
+ return false;
}
/* prepare to test V parameter */
@@ -343,7 +343,7 @@ BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& v
if (v < 0.f || u + v > 1.f)
{
- return FALSE;
+ return false;
}
/* calculate t, ray intersects triangle */
@@ -354,30 +354,7 @@ BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& v
intersection_t = t;
- return TRUE;
-}
-
-//helper for non-aligned vectors
-BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir,
- F32& intersection_a, F32& intersection_b, F32& intersection_t, BOOL two_sided)
-{
- LLVector4a vert0a, vert1a, vert2a, origa, dira;
- vert0a.load3(vert0.mV);
- vert1a.load3(vert1.mV);
- vert2a.load3(vert2.mV);
- origa.load3(orig.mV);
- dira.load3(dir.mV);
-
- if (two_sided)
- {
- return LLTriangleRayIntersectTwoSided(vert0a, vert1a, vert2a, origa, dira,
- intersection_a, intersection_b, intersection_t);
- }
- else
- {
- return LLTriangleRayIntersect(vert0a, vert1a, vert2a, origa, dira,
- intersection_a, intersection_b, intersection_t);
- }
+ return true;
}
//-------------------------------------------------------------------
@@ -394,12 +371,12 @@ LLProfile::Face* LLProfile::addCap(S16 faceID)
face->mIndex = 0;
face->mCount = mTotal;
face->mScaleU= 1.0f;
- face->mCap = TRUE;
+ face->mCap = true;
face->mFaceID = faceID;
return face;
}
-LLProfile::Face* LLProfile::addFace(S32 i, S32 count, F32 scaleU, S16 faceID, BOOL flat)
+LLProfile::Face* LLProfile::addFace(S32 i, S32 count, F32 scaleU, S16 faceID, bool flat)
{
Face *face = vector_append(mFaces, 1);
@@ -408,7 +385,7 @@ LLProfile::Face* LLProfile::addFace(S32 i, S32 count, F32 scaleU, S16 faceID, BO
face->mScaleU= scaleU;
face->mFlat = flat;
- face->mCap = FALSE;
+ face->mCap = false;
face->mFaceID = faceID;
return face;
}
@@ -483,7 +460,7 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3
{
// Generate an n-sided "circular" path.
// 0 is (1,0), and we go counter-clockwise along a circular path from there.
- static const F32 tableScale[] = { 1, 1, 1, 0.5f, 0.707107f, 0.53f, 0.525f, 0.5f };
+ constexpr F32 tableScale[] = { 1, 1, 1, 0.5f, 0.707107f, 0.53f, 0.525f, 0.5f };
F32 scale = 0.5f;
F32 t, t_step, t_first, t_fraction, ang, ang_step;
LLVector4a pt1,pt2;
@@ -583,13 +560,13 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3
{
if ((end - begin)*ang_scale > 0.5f)
{
- mConcave = TRUE;
+ mConcave = true;
}
else
{
- mConcave = FALSE;
+ mConcave = false;
}
- mOpen = TRUE;
+ mOpen = true;
if (params.getHollow() <= 0)
{
// put center point if not hollow.
@@ -599,8 +576,8 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3
else
{
// The profile isn't open.
- mOpen = FALSE;
- mConcave = FALSE;
+ mOpen = false;
+ mConcave = false;
}
mTotal = mProfile.size();
@@ -609,7 +586,7 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3
// Hollow is percent of the original bounding box, not of this particular
// profile's geometry. Thus, a swept triangle needs lower hollow values than
// a swept square.
-LLProfile::Face* LLProfile::addHole(const LLProfileParams& params, BOOL flat, F32 sides, F32 offset, F32 box_hollow, F32 ang_scale, S32 split)
+LLProfile::Face* LLProfile::addHole(const LLProfileParams& params, bool flat, F32 sides, F32 offset, F32 box_hollow, F32 ang_scale, S32 split)
{
// Note that addHole will NOT work for non-"circular" profiles, if we ever decide to use them.
@@ -648,8 +625,8 @@ LLProfile::Face* LLProfile::addHole(const LLProfileParams& params, BOOL flat, F3
}
//static
-S32 LLProfile::getNumPoints(const LLProfileParams& params, BOOL path_open,F32 detail, S32 split,
- BOOL is_sculpted, S32 sculpt_size)
+S32 LLProfile::getNumPoints(const LLProfileParams& params, bool path_open,F32 detail, S32 split,
+ bool is_sculpted, S32 sculpt_size)
{ // this is basically LLProfile::generate stripped down to only operations that influence the number of points
if (detail < MIN_LOD)
{
@@ -758,16 +735,16 @@ 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)
+bool LLProfile::generate(const LLProfileParams& params, bool path_open,F32 detail, S32 split,
+ bool is_sculpted, S32 sculpt_size)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
if ((!mDirty) && (!is_sculpted))
{
- return FALSE;
+ return false;
}
- mDirty = FALSE;
+ mDirty = false;
if (detail < MIN_LOD)
{
@@ -788,7 +765,7 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
if (begin > end - 0.01f)
{
LL_WARNS() << "LLProfile::generate() assertion failed (begin >= end)" << LL_ENDL;
- return FALSE;
+ return false;
}
S32 face_num = 0;
@@ -805,7 +782,7 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
for (i = llfloor(begin * 4.f); i < llfloor(end * 4.f + .999f); i++)
{
- addFace((face_num++) * (split +1), split+2, 1, LL_FACE_OUTER_SIDE_0 << i, TRUE);
+ addFace((face_num++) * (split +1), split+2, 1, LL_FACE_OUTER_SIDE_0 << i, true);
}
LLVector4a scale(1,1,4,1);
@@ -823,16 +800,16 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
{
case LL_PCODE_HOLE_TRIANGLE:
// This offset is not correct, but we can't change it now... DK 11/17/04
- addHole(params, TRUE, 3, -0.375f, hollow, 1.f, split);
+ addHole(params, true, 3, -0.375f, hollow, 1.f, split);
break;
case LL_PCODE_HOLE_CIRCLE:
// TODO: Compute actual detail levels for cubes
- addHole(params, FALSE, MIN_DETAIL_FACES * detail, -0.375f, hollow, 1.f);
+ addHole(params, false, MIN_DETAIL_FACES * detail, -0.375f, hollow, 1.f);
break;
case LL_PCODE_HOLE_SAME:
case LL_PCODE_HOLE_SQUARE:
default:
- addHole(params, TRUE, 4, -0.375f, hollow, 1.f, split);
+ addHole(params, true, 4, -0.375f, hollow, 1.f, split);
break;
}
}
@@ -862,7 +839,7 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
for (i = llfloor(begin * 3.f); i < llfloor(end * 3.f + .999f); i++)
{
- addFace((face_num++) * (split +1), split+2, 1, LL_FACE_OUTER_SIDE_0 << i, TRUE);
+ addFace((face_num++) * (split +1), split+2, 1, LL_FACE_OUTER_SIDE_0 << i, true);
}
if (hollow)
{
@@ -874,15 +851,15 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
{
case LL_PCODE_HOLE_CIRCLE:
// TODO: Actually generate level of detail for triangles
- addHole(params, FALSE, MIN_DETAIL_FACES * detail, 0, triangle_hollow, 1.f);
+ addHole(params, false, MIN_DETAIL_FACES * detail, 0, triangle_hollow, 1.f);
break;
case LL_PCODE_HOLE_SQUARE:
- addHole(params, TRUE, 4, 0, triangle_hollow, 1.f, split);
+ addHole(params, true, 4, 0, triangle_hollow, 1.f, split);
break;
case LL_PCODE_HOLE_SAME:
case LL_PCODE_HOLE_TRIANGLE:
default:
- addHole(params, TRUE, 3, 0, triangle_hollow, 1.f, split);
+ addHole(params, true, 3, 0, triangle_hollow, 1.f, split);
break;
}
}
@@ -919,11 +896,11 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
if (mOpen && !hollow)
{
- addFace(0,mTotal-1,0,LL_FACE_OUTER_SIDE_0, FALSE);
+ addFace(0,mTotal-1,0,LL_FACE_OUTER_SIDE_0, false);
}
else
{
- addFace(0,mTotal,0,LL_FACE_OUTER_SIDE_0, FALSE);
+ addFace(0,mTotal,0,LL_FACE_OUTER_SIDE_0, false);
}
if (hollow)
@@ -931,15 +908,15 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
switch (hole_type)
{
case LL_PCODE_HOLE_SQUARE:
- addHole(params, TRUE, 4, 0, hollow, 1.f, split);
+ addHole(params, true, 4, 0, hollow, 1.f, split);
break;
case LL_PCODE_HOLE_TRIANGLE:
- addHole(params, TRUE, 3, 0, hollow, 1.f, split);
+ addHole(params, true, 3, 0, hollow, 1.f, split);
break;
case LL_PCODE_HOLE_CIRCLE:
case LL_PCODE_HOLE_SAME:
default:
- addHole(params, FALSE, circle_detail, 0, hollow, 1.f);
+ addHole(params, true, circle_detail, 0, hollow, 1.f);
break;
}
}
@@ -969,11 +946,11 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
}
if (mOpen && !params.getHollow())
{
- addFace(0,mTotal-1,0,LL_FACE_OUTER_SIDE_0, FALSE);
+ addFace(0,mTotal-1,0,LL_FACE_OUTER_SIDE_0, false);
}
else
{
- addFace(0,mTotal,0,LL_FACE_OUTER_SIDE_0, FALSE);
+ addFace(0,mTotal,0,LL_FACE_OUTER_SIDE_0, false);
}
if (hollow)
@@ -981,15 +958,15 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
switch (hole_type)
{
case LL_PCODE_HOLE_SQUARE:
- addHole(params, TRUE, 2, 0.5f, hollow, 0.5f, split);
+ addHole(params, true, 2, 0.5f, hollow, 0.5f, split);
break;
case LL_PCODE_HOLE_TRIANGLE:
- addHole(params, TRUE, 3, 0.5f, hollow, 0.5f, split);
+ addHole(params, true, 3, 0.5f, hollow, 0.5f, split);
break;
case LL_PCODE_HOLE_CIRCLE:
case LL_PCODE_HOLE_SAME:
default:
- addHole(params, FALSE, circle_detail, 0.5f, hollow, 0.5f);
+ addHole(params, false, circle_detail, 0.5f, hollow, 0.5f);
break;
}
}
@@ -997,11 +974,11 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
// Special case for openness of sphere
if ((params.getEnd() - params.getBegin()) < 1.f)
{
- mOpen = TRUE;
+ mOpen = true;
}
else if (!hollow)
{
- mOpen = FALSE;
+ mOpen = false;
mProfile.push_back(mProfile[0]);
mTotal++;
}
@@ -1019,24 +996,24 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
if ( mOpen) // interior edge caps
{
- addFace(mTotal-1, 2,0.5,LL_FACE_PROFILE_BEGIN, TRUE);
+ addFace(mTotal-1, 2,0.5,LL_FACE_PROFILE_BEGIN, true);
if (hollow)
{
- addFace(mTotalOut-1, 2,0.5,LL_FACE_PROFILE_END, TRUE);
+ addFace(mTotalOut-1, 2,0.5,LL_FACE_PROFILE_END, true);
}
else
{
- addFace(mTotal-2, 2,0.5,LL_FACE_PROFILE_END, TRUE);
+ addFace(mTotal-2, 2,0.5,LL_FACE_PROFILE_END, true);
}
}
- return TRUE;
+ return true;
}
-BOOL LLProfileParams::importFile(LLFILE *fp)
+bool LLProfileParams::importFile(LLFILE *fp)
{
const S32 BUFSIZE = 16384;
char buffer[BUFSIZE]; /* Flawfinder: ignore */
@@ -1094,11 +1071,11 @@ BOOL LLProfileParams::importFile(LLFILE *fp)
}
}
- return TRUE;
+ return true;
}
-BOOL LLProfileParams::exportFile(LLFILE *fp) const
+bool LLProfileParams::exportFile(LLFILE *fp) const
{
fprintf(fp,"\t\tprofile 0\n");
fprintf(fp,"\t\t{\n");
@@ -1107,11 +1084,11 @@ BOOL LLProfileParams::exportFile(LLFILE *fp) const
fprintf(fp,"\t\t\tend\t%g\n", getEnd());
fprintf(fp,"\t\t\thollow\t%g\n", getHollow());
fprintf(fp, "\t\t}\n");
- return TRUE;
+ return true;
}
-BOOL LLProfileParams::importLegacyStream(std::istream& input_stream)
+bool LLProfileParams::importLegacyStream(std::istream& input_stream)
{
const S32 BUFSIZE = 16384;
char buffer[BUFSIZE]; /* Flawfinder: ignore */
@@ -1166,11 +1143,11 @@ BOOL LLProfileParams::importLegacyStream(std::istream& input_stream)
}
}
- return TRUE;
+ return true;
}
-BOOL LLProfileParams::exportLegacyStream(std::ostream& output_stream) const
+bool LLProfileParams::exportLegacyStream(std::ostream& output_stream) const
{
output_stream <<"\t\tprofile 0\n";
output_stream <<"\t\t{\n";
@@ -1179,7 +1156,7 @@ BOOL LLProfileParams::exportLegacyStream(std::ostream& output_stream) const
output_stream <<"\t\t\tend\t" << getEnd() << "\n";
output_stream <<"\t\t\thollow\t" << getHollow() << "\n";
output_stream << "\t\t}\n";
- return TRUE;
+ return true;
}
LLSD LLProfileParams::asLLSD() const
@@ -1246,7 +1223,7 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en
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 };
+ constexpr F32 tableScale[] = { 1, 1, 1, 0.5f, 0.707107f, 0.53f, 0.525f, 0.5f };
F32 revolutions = params.getRevolutions();
F32 skew = params.getSkew();
@@ -1476,14 +1453,14 @@ S32 LLPath::getNumPoints(const LLPathParams& params, F32 detail)
return np;
}
-BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
- BOOL is_sculpted, S32 sculpt_size)
+bool LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
+ bool is_sculpted, S32 sculpt_size)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
if ((!mDirty) && (!is_sculpted))
{
- return FALSE;
+ return false;
}
if (detail < MIN_LOD)
@@ -1492,11 +1469,11 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
detail = MIN_LOD;
}
- mDirty = FALSE;
+ mDirty = false;
S32 np = 2; // hardcode for line
mPath.resize(0);
- mOpen = TRUE;
+ mOpen = true;
// Is this 0xf0 mask really necessary? DK 03/02/05
switch (params.getCurveType() & 0xf0)
@@ -1556,7 +1533,7 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
if (params.getEnd() - params.getBegin() >= 0.99f &&
params.getScaleX() >= .99f)
{
- mOpen = FALSE;
+ mOpen = false;
}
//genNGon(params, llfloor(MIN_DETAIL_FACES * detail), 4.f, 0.f);
@@ -1600,19 +1577,19 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
break;
};
- if (params.getTwist() != params.getTwistBegin()) mOpen = TRUE;
+ if (params.getTwist() != params.getTwistBegin()) mOpen = true;
//if ((int(fabsf(params.getTwist() - params.getTwistBegin())*100))%100 != 0) {
- // mOpen = TRUE;
+ // mOpen = true;
//}
- return TRUE;
+ return true;
}
-BOOL LLDynamicPath::generate(const LLPathParams& params, F32 detail, S32 split,
- BOOL is_sculpted, S32 sculpt_size)
+bool LLDynamicPath::generate(const LLPathParams& params, F32 detail, S32 split,
+ bool is_sculpted, S32 sculpt_size)
{
- mOpen = TRUE; // Draw end caps
+ mOpen = true; // Draw end caps
if (getPathLength() == 0)
{
// Path hasn't been generated yet.
@@ -1631,11 +1608,11 @@ BOOL LLDynamicPath::generate(const LLPathParams& params, F32 detail, S32 split,
}
}
- return TRUE;
+ return true;
}
-BOOL LLPathParams::importFile(LLFILE *fp)
+bool LLPathParams::importFile(LLFILE *fp)
{
const S32 BUFSIZE = 16384;
char buffer[BUFSIZE]; /* Flawfinder: ignore */
@@ -1750,11 +1727,11 @@ BOOL LLPathParams::importFile(LLFILE *fp)
LL_WARNS() << "unknown keyword " << " in path import" << LL_ENDL;
}
}
- return TRUE;
+ return true;
}
-BOOL LLPathParams::exportFile(LLFILE *fp) const
+bool LLPathParams::exportFile(LLFILE *fp) const
{
fprintf(fp, "\t\tpath 0\n");
fprintf(fp, "\t\t{\n");
@@ -1775,11 +1752,11 @@ BOOL LLPathParams::exportFile(LLFILE *fp) const
fprintf(fp,"\t\t\tskew\t%g\n", getSkew());
fprintf(fp, "\t\t}\n");
- return TRUE;
+ return true;
}
-BOOL LLPathParams::importLegacyStream(std::istream& input_stream)
+bool LLPathParams::importLegacyStream(std::istream& input_stream)
{
const S32 BUFSIZE = 16384;
char buffer[BUFSIZE]; /* Flawfinder: ignore */
@@ -1890,11 +1867,11 @@ BOOL LLPathParams::importLegacyStream(std::istream& input_stream)
LL_WARNS() << "unknown keyword " << " in path import" << LL_ENDL;
}
}
- return TRUE;
+ return true;
}
-BOOL LLPathParams::exportLegacyStream(std::ostream& output_stream) const
+bool LLPathParams::exportLegacyStream(std::ostream& output_stream) const
{
output_stream << "\t\tpath 0\n";
output_stream << "\t\t{\n";
@@ -1915,7 +1892,7 @@ BOOL LLPathParams::exportLegacyStream(std::ostream& output_stream) const
output_stream <<"\t\t\tskew\t" << getSkew() << "\n";
output_stream << "\t\t}\n";
- return TRUE;
+ return true;
}
LLSD LLPathParams::asLLSD() const
@@ -1980,7 +1957,7 @@ LLProfile::~LLProfile()
S32 LLVolume::sNumMeshPoints = 0;
-LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL generate_single_face, const BOOL is_unique)
+LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const bool generate_single_face, const bool is_unique)
: mParams(params)
{
mUnique = is_unique;
@@ -1991,8 +1968,8 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
mIsMeshAssetLoaded = false;
mIsMeshAssetUnavaliable = false;
mLODScaleBias.setVec(1,1,1);
- mHullPoints = NULL;
- mHullIndices = NULL;
+ mHullPoints = nullptr;
+ mHullIndices = nullptr;
mNumHullPoints = 0;
mNumHullIndices = 0;
@@ -2054,7 +2031,7 @@ LLVolume::~LLVolume()
mHullIndices = NULL;
}
-BOOL LLVolume::generate()
+bool LLVolume::generate()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
@@ -2098,8 +2075,8 @@ BOOL LLVolume::generate()
}
}
- BOOL regenPath = mPathp->generate(mParams.getPathParams(), path_detail, split);
- BOOL regenProf = mProfilep->generate(mParams.getProfileParams(), mPathp->isOpen(),profile_detail, split);
+ bool regenPath = mPathp->generate(mParams.getPathParams(), path_detail, split);
+ bool regenProf = mProfilep->generate(mParams.getProfileParams(), mPathp->isOpen(),profile_detail, split);
if (regenPath || regenProf )
{
@@ -2162,11 +2139,11 @@ BOOL LLVolume::generate()
mFaceMask |= id;
}
LL_CHECK_MEMORY
- return TRUE;
+ return true;
}
LL_CHECK_MEMORY
- return FALSE;
+ return false;
}
void LLVolumeFace::VertexData::init()
@@ -2347,7 +2324,7 @@ bool LLVolume::unpackVolumeFaces(U8* in_data, S32 size)
bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl)
{
{
- U32 face_count = mdl.size();
+ auto face_count = mdl.size();
if (face_count == 0)
{ //no faces unpacked, treat as failed decode
@@ -2379,7 +2356,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl)
LLSD::Binary idx = mdl[i]["TriangleList"];
//copy out indices
- S32 num_indices = idx.size() / 2;
+ auto num_indices = idx.size() / 2;
const S32 indices_to_discard = num_indices % 3;
if (indices_to_discard > 0)
{
@@ -2387,7 +2364,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl)
LL_WARNS() << "Incomplete triangle discarded from face! Indices count " << num_indices << " was not divisible by 3. face index: " << i << " Total: " << face_count << LL_ENDL;
num_indices -= indices_to_discard;
}
- face.resizeIndices(num_indices);
+ face.resizeIndices(static_cast<S32>(num_indices));
if (num_indices > 2 && !face.mIndices)
{
@@ -2408,7 +2385,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl)
}
//copy out vertices
- U32 num_verts = pos.size()/(3*2);
+ U32 num_verts = static_cast<U32>(pos.size())/(3*2);
face.resizeVertices(num_verts);
if (num_verts > 0 && !face.mPositions)
@@ -2672,7 +2649,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl)
if (do_reverse_triangles)
{
- for (U32 j = 0; j < face.mNumIndices; j += 3)
+ for (S32 j = 0; j < face.mNumIndices; j += 3)
{
// swap the 2nd and 3rd index
S32 swap = face.mIndices[j+1];
@@ -2709,7 +2686,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl)
min_tc = face.mTexCoords[0];
max_tc = face.mTexCoords[0];
- for (U32 j = 1; j < face.mNumVertices; ++j)
+ for (S32 j = 1; j < face.mNumVertices; ++j)
{
update_min_max(min_tc, max_tc, face.mTexCoords[j]);
}
@@ -2812,10 +2789,10 @@ void LLVolume::createVolumeFaces()
else
{
S32 num_faces = getNumFaces();
- BOOL partial_build = TRUE;
+ bool partial_build = true;
if (num_faces != mVolumeFaces.size())
{
- partial_build = FALSE;
+ partial_build = false;
mVolumeFaces.resize(num_faces);
}
// Initialize volume faces with parameter data
@@ -3050,9 +3027,9 @@ void LLVolume::sculptGenerateSpherePlaceholder()
void LLVolume::sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, U8 sculpt_type)
{
U8 sculpt_stitching = sculpt_type & LL_SCULPT_TYPE_MASK;
- BOOL sculpt_invert = sculpt_type & LL_SCULPT_FLAG_INVERT;
- BOOL sculpt_mirror = sculpt_type & LL_SCULPT_FLAG_MIRROR;
- BOOL reverse_horizontal = (sculpt_invert ? !sculpt_mirror : sculpt_mirror); // XOR
+ bool sculpt_invert = sculpt_type & LL_SCULPT_FLAG_INVERT;
+ bool sculpt_mirror = sculpt_type & LL_SCULPT_FLAG_MIRROR;
+ bool reverse_horizontal = (sculpt_invert ? !sculpt_mirror : sculpt_mirror); // XOR
S32 sizeS = mPathp->mPath.size();
S32 sizeT = mProfilep->mProfile.size();
@@ -3137,14 +3114,13 @@ void LLVolume::sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8
}
-const S32 SCULPT_REZ_1 = 6; // changed from 4 to 6 - 6 looks round whereas 4 looks square
-const S32 SCULPT_REZ_2 = 8;
-const S32 SCULPT_REZ_3 = 16;
-const S32 SCULPT_REZ_4 = 32;
+constexpr S32 SCULPT_REZ_1 = 6; // changed from 4 to 6 - 6 looks round whereas 4 looks square
+constexpr S32 SCULPT_REZ_2 = 8;
+constexpr S32 SCULPT_REZ_3 = 16;
+constexpr S32 SCULPT_REZ_4 = 32;
S32 sculpt_sides(F32 detail)
{
-
// detail is usually one of: 1, 1.5, 2.5, 4.0.
if (detail <= 1.0)
@@ -3207,12 +3183,12 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
{
U8 sculpt_type = mParams.getSculptType();
- BOOL data_is_empty = FALSE;
+ bool data_is_empty = false;
if (sculpt_width == 0 || sculpt_height == 0 || sculpt_components < 3 || sculpt_data == NULL)
{
sculpt_level = -1;
- data_is_empty = TRUE;
+ data_is_empty = true;
}
S32 requested_sizeS = 0;
@@ -3220,8 +3196,8 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
sculpt_calc_mesh_resolution(sculpt_width, sculpt_height, sculpt_type, mDetail, requested_sizeS, requested_sizeT);
- mPathp->generate(mParams.getPathParams(), mDetail, 0, TRUE, requested_sizeS);
- mProfilep->generate(mParams.getProfileParams(), mPathp->isOpen(), mDetail, 0, TRUE, requested_sizeT);
+ mPathp->generate(mParams.getPathParams(), mDetail, 0, true, requested_sizeS);
+ mProfilep->generate(mParams.getProfileParams(), mPathp->isOpen(), mDetail, 0, true, requested_sizeT);
S32 sizeS = mPathp->mPath.size(); // we requested a specific size, now see what we really got
S32 sizeT = mProfilep->mProfile.size(); // we requested a specific size, now see what we really got
@@ -3252,7 +3228,7 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
if (area < SCULPT_MIN_AREA || area > SCULPT_MAX_AREA)
{
- data_is_empty = TRUE;
+ data_is_empty = true;
visible_placeholder = true;
}
}
@@ -3271,8 +3247,6 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
}
}
-
-
for (S32 i = 0; i < (S32)mProfilep->mFaces.size(); i++)
{
mFaceMask |= mProfilep->mFaces[i].mFaceID;
@@ -3289,12 +3263,12 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
-BOOL LLVolume::isCap(S32 face)
+bool LLVolume::isCap(S32 face)
{
return mProfilep->mFaces[face].mCap;
}
-BOOL LLVolume::isFlat(S32 face)
+bool LLVolume::isFlat(S32 face)
{
return mProfilep->mFaces[face].mFlat;
}
@@ -3357,7 +3331,7 @@ void LLVolumeParams::copyParams(const LLVolumeParams &params)
}
// Less restricitve approx 0 for volumes
-const F32 APPROXIMATELY_ZERO = 0.001f;
+constexpr F32 APPROXIMATELY_ZERO = 0.001f;
bool approx_zero( F32 f, F32 tolerance = APPROXIMATELY_ZERO)
{
return (f >= -tolerance) && (f <= tolerance);
@@ -3613,7 +3587,7 @@ bool LLVolumeParams::setSkew(const F32 skew_value)
return valid;
}
-bool LLVolumeParams::setSculptID(const LLUUID sculpt_id, U8 sculpt_type)
+bool LLVolumeParams::setSculptID(const LLUUID& sculpt_id, U8 sculpt_type)
{
mSculptID = sculpt_id;
mSculptType = sculpt_type;
@@ -3808,7 +3782,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
LLVector4a* v = (LLVector4a*)face.mPositions;
LLVector4a* n = (LLVector4a*)face.mNormals;
- for (U32 j = 0; j < face.mNumIndices / 3; j++)
+ for (S32 j = 0; j < face.mNumIndices / 3; j++)
{
for (S32 k = 0; k < 3; k++)
{
@@ -3843,7 +3817,6 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
}
else
{
-
//==============================================
//DEBUG draw edge map instead of silhouette edge
//==============================================
@@ -3925,8 +3898,8 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
//DEBUG
//==============================================
- static const U8 AWAY = 0x01,
- TOWARDS = 0x02;
+ constexpr U8 AWAY = 0x01,
+ TOWARDS = 0x02;
//for each triangle
std::vector<U8> fFacing;
@@ -3935,7 +3908,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
LLVector4a* v = (LLVector4a*) face.mPositions;
LLVector4a* n = (LLVector4a*) face.mNormals;
- for (U32 j = 0; j < face.mNumIndices/3; j++)
+ for (S32 j = 0; j < face.mNumIndices/3; j++)
{
//approximate normal
S32 v1 = face.mIndices[j*3+0];
@@ -3972,7 +3945,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
}
//for each triangle
- for (U32 j = 0; j < face.mNumIndices/3; j++)
+ for (S32 j = 0; j < face.mNumIndices/3; j++)
{
if (fFacing[j] == (AWAY | TOWARDS))
{ //this is a degenerate triangle
@@ -4196,7 +4169,7 @@ LLVertexIndexPair::LLVertexIndexPair(const LLVector3 &vertex, const S32 index)
mIndex = index;
}
-const F32 VERTEX_SLOP = 0.00001f;
+constexpr F32 VERTEX_SLOP = 0.00001f;
struct lessVertex
{
@@ -4206,32 +4179,32 @@ struct lessVertex
if (a->mVertex.mV[0] + slop < b->mVertex.mV[0])
{
- return TRUE;
+ return true;
}
else if (a->mVertex.mV[0] - slop > b->mVertex.mV[0])
{
- return FALSE;
+ return false;
}
if (a->mVertex.mV[1] + slop < b->mVertex.mV[1])
{
- return TRUE;
+ return true;
}
else if (a->mVertex.mV[1] - slop > b->mVertex.mV[1])
{
- return FALSE;
+ return false;
}
if (a->mVertex.mV[2] + slop < b->mVertex.mV[2])
{
- return TRUE;
+ return true;
}
else if (a->mVertex.mV[2] - slop > b->mVertex.mV[2])
{
- return FALSE;
+ return false;
}
- return FALSE;
+ return false;
}
};
@@ -4241,45 +4214,45 @@ struct lessTriangle
{
if (*a < *b)
{
- return TRUE;
+ return true;
}
else if (*a > *b)
{
- return FALSE;
+ return false;
}
if (*(a+1) < *(b+1))
{
- return TRUE;
+ return true;
}
else if (*(a+1) > *(b+1))
{
- return FALSE;
+ return false;
}
if (*(a+2) < *(b+2))
{
- return TRUE;
+ return true;
}
else if (*(a+2) > *(b+2))
{
- return FALSE;
+ return false;
}
- return FALSE;
+ return false;
}
};
-BOOL equalTriangle(const S32 *a, const S32 *b)
+bool equalTriangle(const S32 *a, const S32 *b)
{
if ((*a == *b) && (*(a+1) == *(b+1)) && (*(a+2) == *(b+2)))
{
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-BOOL LLVolumeParams::importFile(LLFILE *fp)
+bool LLVolumeParams::importFile(LLFILE *fp)
{
//LL_INFOS() << "importing volume" << LL_ENDL;
const S32 BUFSIZE = 16384;
@@ -4319,21 +4292,21 @@ BOOL LLVolumeParams::importFile(LLFILE *fp)
}
}
- return TRUE;
+ return true;
}
-BOOL LLVolumeParams::exportFile(LLFILE *fp) const
+bool LLVolumeParams::exportFile(LLFILE *fp) const
{
fprintf(fp,"\tshape 0\n");
fprintf(fp,"\t{\n");
mPathParams.exportFile(fp);
mProfileParams.exportFile(fp);
fprintf(fp, "\t}\n");
- return TRUE;
+ return true;
}
-BOOL LLVolumeParams::importLegacyStream(std::istream& input_stream)
+bool LLVolumeParams::importLegacyStream(std::istream& input_stream)
{
//LL_INFOS() << "importing volume" << LL_ENDL;
const S32 BUFSIZE = 16384;
@@ -4369,17 +4342,17 @@ BOOL LLVolumeParams::importLegacyStream(std::istream& input_stream)
}
}
- return TRUE;
+ return true;
}
-BOOL LLVolumeParams::exportLegacyStream(std::ostream& output_stream) const
+bool LLVolumeParams::exportLegacyStream(std::ostream& output_stream) const
{
output_stream <<"\tshape 0\n";
output_stream <<"\t{\n";
mPathParams.exportLegacyStream(output_stream);
mProfileParams.exportLegacyStream(output_stream);
output_stream << "\t}\n";
- return TRUE;
+ return true;
}
LLSD LLVolumeParams::sculptAsLLSD() const
@@ -4451,14 +4424,14 @@ void LLVolumeParams::reduceT(F32 begin, F32 end)
const F32 MIN_CONCAVE_PROFILE_WEDGE = 0.125f; // 1/8 unity
const F32 MIN_CONCAVE_PATH_WEDGE = 0.111111f; // 1/9 unity
-// returns TRUE if the shape can be approximated with a convex shape
+// returns true if the shape can be approximated with a convex shape
// for collison purposes
-BOOL LLVolumeParams::isConvex() const
+bool LLVolumeParams::isConvex() const
{
if (!getSculptID().isNull())
{
// can't determine, be safe and say no:
- return FALSE;
+ return false;
}
F32 path_length = mPathParams.getEnd() - mPathParams.getBegin();
@@ -4471,11 +4444,11 @@ BOOL LLVolumeParams::isConvex() const
&& LL_PCODE_PATH_LINE != path_type) ) )
{
// twist along a "not too short" path is concave
- return FALSE;
+ return false;
}
F32 profile_length = mProfileParams.getEnd() - mProfileParams.getBegin();
- BOOL same_hole = hollow == 0.f
+ bool same_hole = hollow == 0.f
|| (mProfileParams.getCurveType() & LL_PCODE_HOLE_MASK) == LL_PCODE_HOLE_SAME;
F32 min_profile_wedge = MIN_CONCAVE_PROFILE_WEDGE;
@@ -4486,7 +4459,7 @@ BOOL LLVolumeParams::isConvex() const
min_profile_wedge = 2.f * MIN_CONCAVE_PROFILE_WEDGE;
}
- BOOL convex_profile = ( ( profile_length == 1.f
+ bool convex_profile = ( ( profile_length == 1.f
|| profile_length <= 0.5f )
&& hollow == 0.f ) // trivially convex
|| ( profile_length <= min_profile_wedge
@@ -4495,36 +4468,36 @@ BOOL LLVolumeParams::isConvex() const
if (!convex_profile)
{
// profile is concave
- return FALSE;
+ return false;
}
if ( LL_PCODE_PATH_LINE == path_type )
{
// straight paths with convex profile
- return TRUE;
+ return true;
}
- BOOL concave_path = (path_length < 1.0f) && (path_length > 0.5f);
+ bool concave_path = (path_length < 1.0f) && (path_length > 0.5f);
if (concave_path)
{
- return FALSE;
+ return false;
}
// we're left with spheres, toroids and tubes
if ( LL_PCODE_PROFILE_CIRCLE_HALF == profile_type )
{
// at this stage all spheres must be convex
- return TRUE;
+ return true;
}
// it's a toroid or tube
if ( path_length <= MIN_CONCAVE_PATH_WEDGE )
{
// effectively convex
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
// debug
@@ -4602,7 +4575,7 @@ LLFaceID LLVolume::generateFaceMask()
return new_mask;
}
-BOOL LLVolume::isFaceMaskValid(LLFaceID face_mask)
+bool LLVolume::isFaceMaskValid(LLFaceID face_mask)
{
LLFaceID test_mask = 0;
for(S32 i = 0; i < getNumFaces(); i++)
@@ -4613,9 +4586,9 @@ BOOL LLVolume::isFaceMaskValid(LLFaceID face_mask)
return test_mask == face_mask;
}
-BOOL LLVolume::isConvex() const
+bool LLVolume::isConvex() const
{
- // mParams.isConvex() may return FALSE even though the final
+ // mParams.isConvex() may return false even though the final
// geometry is actually convex due to LOD approximations.
// TODO -- provide LLPath and LLProfile with isConvex() methods
// that correctly determine convexity. -- Leviathan
@@ -4721,10 +4694,10 @@ LLVolumeFace::LLVolumeFace() :
mJustWeights(NULL),
mJointIndices(NULL),
#endif
- mWeightsScrubbed(FALSE),
+ mWeightsScrubbed(false),
mOctree(NULL),
mOctreeTriangles(NULL),
- mOptimized(FALSE)
+ mOptimized(false)
{
mExtents = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*3);
mExtents[0].splat(-0.5f);
@@ -4752,7 +4725,7 @@ LLVolumeFace::LLVolumeFace(const LLVolumeFace& src)
mJustWeights(NULL),
mJointIndices(NULL),
#endif
- mWeightsScrubbed(FALSE),
+ mWeightsScrubbed(false),
mOctree(NULL),
mOctreeTriangles(NULL)
{
@@ -4826,7 +4799,7 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
{
ll_aligned_free_16(mWeights);
mWeights = NULL;
- mWeightsScrubbed = FALSE;
+ mWeightsScrubbed = false;
}
#if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS
@@ -4899,7 +4872,7 @@ void LLVolumeFace::freeData()
destroyOctree();
}
-BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
+bool LLVolumeFace::create(LLVolume* volume, bool partial_build)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
@@ -4907,7 +4880,7 @@ BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
destroyOctree();
LL_CHECK_MEMORY
- BOOL ret = FALSE ;
+ bool ret = false ;
if (mTypeMask & CAP_MASK)
{
ret = createCap(volume, partial_build);
@@ -4974,13 +4947,13 @@ void LLVolumeFace::remap()
{
// Generate a remap buffer
std::vector<unsigned int> remap(mNumVertices);
- S32 remap_vertices_count = LLMeshOptimizer::generateRemapMultiU16(&remap[0],
+ S32 remap_vertices_count = static_cast<S32>(LLMeshOptimizer::generateRemapMultiU16(&remap[0],
mIndices,
mNumIndices,
mPositions,
mNormals,
mTexCoords,
- mNumVertices);
+ mNumVertices));
// Allocate new buffers
S32 size = ((mNumIndices * sizeof(U16)) + 0xF) & ~0xF;
@@ -5025,7 +4998,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
range.setSub(mExtents[1],mExtents[0]);
//remove redundant vertices
- for (U32 i = 0; i < mNumIndices; ++i)
+ for (S32 i = 0; i < mNumIndices; ++i)
{
U16 index = mIndices[i];
@@ -5043,7 +5016,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
LLVolumeFace::VertexData cv;
getVertexData(index, cv);
- BOOL found = FALSE;
+ bool found = false;
LLVector4a pos;
pos.setSub(mPositions[index], mExtents[0]);
@@ -5064,7 +5037,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
LLVolumeFace::VertexData& tv = (point_iter->second)[j];
if (tv.compareNormal(cv, angle_cutoff))
{
- found = TRUE;
+ found = true;
new_face.pushIndex((point_iter->second)[j].mIndex);
break;
}
@@ -5171,12 +5144,12 @@ public:
}
};
-const F64 FindVertexScore_CacheDecayPower = 1.5;
-const F64 FindVertexScore_LastTriScore = 0.75;
-const F64 FindVertexScore_ValenceBoostScale = 2.0;
-const F64 FindVertexScore_ValenceBoostPower = 0.5;
-const U32 MaxSizeVertexCache = 32;
-const F64 FindVertexScore_Scaler = 1.0/(MaxSizeVertexCache-3);
+constexpr F64 FindVertexScore_CacheDecayPower = 1.5;
+constexpr F64 FindVertexScore_LastTriScore = 0.75;
+constexpr F64 FindVertexScore_ValenceBoostScale = 2.0;
+constexpr F64 FindVertexScore_ValenceBoostPower = 0.5;
+constexpr U32 MaxSizeVertexCache = 32;
+constexpr F64 FindVertexScore_Scaler = 1.0/(MaxSizeVertexCache-3);
F64 find_vertex_score(LLVCacheVertexData& data)
{
@@ -5411,7 +5384,7 @@ struct MikktData
LLVector3 inv_scale(1.f / face->mNormalizedScale.mV[0], 1.f / face->mNormalizedScale.mV[1], 1.f / face->mNormalizedScale.mV[2]);
- for (int i = 0; i < face->mNumIndices; ++i)
+ for (S32 i = 0; i < face->mNumIndices; ++i)
{
U32 idx = face->mIndices[i];
@@ -5422,17 +5395,6 @@ struct MikktData
n[i].normalize();
tc[i].set(face->mTexCoords[idx]);
- if (idx >= face->mNumVertices)
- {
- // invalid index
- // replace with a valid index to avoid crashes
- idx = face->mNumVertices - 1;
- face->mIndices[i] = idx;
-
- // Needs better logging
- LL_DEBUGS_ONCE("LLVOLUME") << "Invalid index, substituting" << LL_ENDL;
- }
-
if (face->mWeights)
{
w[i].set(face->mWeights[idx].getF32ptr());
@@ -5479,7 +5441,7 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents)
{ //optimize for vertex cache according to Forsyth method:
LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME;
llassert(!mOptimized);
- mOptimized = TRUE;
+ mOptimized = true;
if (gen_tangents && mNormals && mTexCoords)
{ // generate mikkt space tangents before cache optimizing since the index buffer may change
@@ -5504,7 +5466,7 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents)
U32 stream_count = data.w.empty() ? 4 : 5;
- size_t vert_count = meshopt_generateVertexRemapMulti(&remap[0], nullptr, data.p.size(), data.p.size(), mos, stream_count);
+ S32 vert_count = static_cast<S32>(meshopt_generateVertexRemapMulti(&remap[0], nullptr, data.p.size(), data.p.size(), mos, stream_count));
if (vert_count < 65535 && vert_count != 0)
{
@@ -5518,11 +5480,11 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents)
allocateTangents(mNumVertices);
- for (int i = 0; i < mNumIndices; ++i)
+ for (S32 i = 0; i < mNumIndices; ++i)
{
U32 src_idx = i;
U32 dst_idx = remap[i];
- if (dst_idx >= mNumVertices)
+ if (dst_idx >= (U32)mNumVertices)
{
dst_idx = mNumVertices - 1;
// Shouldn't happen, figure out what gets returned in remap and why.
@@ -5549,7 +5511,7 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents)
scale.load3(mNormalizedScale.mV);
scale.getF32ptr()[3] = 1.f;
- for (int i = 0; i < mNumVertices; ++i)
+ for (S32 i = 0; i < mNumVertices; ++i)
{
mPositions[i].mul(inv_scale);
mNormals[i].mul(scale);
@@ -5710,7 +5672,7 @@ void LerpPlanarVertex(LLVolumeFace::VertexData& v0,
vout.setNormal(v0.getNormal());
}
-BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
+bool LLVolumeFace::createUnCutCubeCap(LLVolume* volume, bool partial_build)
{
LL_CHECK_MEMORY
@@ -5942,11 +5904,11 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
}
LL_CHECK_MEMORY
- return TRUE;
+ return true;
}
-BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
+bool LLVolumeFace::createCap(LLVolume* volume, bool partial_build)
{
if (!(mTypeMask & HOLLOW_MASK) &&
!(mTypeMask & OPEN_MASK) &&
@@ -6103,7 +6065,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
//if (partial_build)
//{
- // return TRUE;
+ // return true;
//}
if (mTypeMask & HOLLOW_MASK)
@@ -6152,36 +6114,36 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
(paV[0]*pbV[1] - pbV[0]*paV[1]) +
(pbV[0]*p2V[1] - p2V[0]*pbV[1]);
- BOOL use_tri1a2 = TRUE;
- BOOL tri_1a2 = TRUE;
- BOOL tri_21b = TRUE;
+ bool use_tri1a2 = true;
+ bool tri_1a2 = true;
+ bool tri_21b = true;
if (area_1a2 < 0)
{
- tri_1a2 = FALSE;
+ tri_1a2 = false;
}
if (area_2ab < 0)
{
// Can't use, because it contains point b
- tri_1a2 = FALSE;
+ tri_1a2 = false;
}
if (area_21b < 0)
{
- tri_21b = FALSE;
+ tri_21b = false;
}
if (area_1ba < 0)
{
// Can't use, because it contains point b
- tri_21b = FALSE;
+ tri_21b = false;
}
if (!tri_1a2)
{
- use_tri1a2 = FALSE;
+ use_tri1a2 = false;
}
else if (!tri_21b)
{
- use_tri1a2 = TRUE;
+ use_tri1a2 = true;
}
else
{
@@ -6193,11 +6155,11 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
if (d1.dot3(d1) < d2.dot3(d2))
{
- use_tri1a2 = TRUE;
+ use_tri1a2 = true;
}
else
{
- use_tri1a2 = FALSE;
+ use_tri1a2 = false;
}
}
@@ -6258,36 +6220,36 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
(paV[0]*pbV[1] - pbV[0]*paV[1]) +
(pbV[0]*p2V[1] - p2V[0]*pbV[1]);
- BOOL use_tri1a2 = TRUE;
- BOOL tri_1a2 = TRUE;
- BOOL tri_21b = TRUE;
+ bool use_tri1a2 = true;
+ bool tri_1a2 = true;
+ bool tri_21b = true;
if (area_1a2 < 0)
{
- tri_1a2 = FALSE;
+ tri_1a2 = false;
}
if (area_2ab < 0)
{
// Can't use, because it contains point b
- tri_1a2 = FALSE;
+ tri_1a2 = false;
}
if (area_21b < 0)
{
- tri_21b = FALSE;
+ tri_21b = false;
}
if (area_1ba < 0)
{
// Can't use, because it contains point b
- tri_21b = FALSE;
+ tri_21b = false;
}
if (!tri_1a2)
{
- use_tri1a2 = FALSE;
+ use_tri1a2 = false;
}
else if (!tri_21b)
{
- use_tri1a2 = TRUE;
+ use_tri1a2 = true;
}
else
{
@@ -6298,11 +6260,11 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
if (d1.dot3(d1) < d2.dot3(d2))
{
- use_tri1a2 = TRUE;
+ use_tri1a2 = true;
}
else
{
- use_tri1a2 = FALSE;
+ use_tri1a2 = false;
}
}
@@ -6381,7 +6343,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
norm[i].load4a(normal.getF32ptr());
}
- return TRUE;
+ return true;
}
void LLVolumeFace::createTangents()
@@ -6404,7 +6366,7 @@ void LLVolumeFace::createTangents()
LLCalculateTangentArray(mNumVertices, mPositions, mNormals, mTexCoords, mNumIndices / 3, mIndices, mTangents);
//normalize normals
- for (U32 i = 0; i < mNumVertices; i++)
+ for (S32 i = 0; i < mNumVertices; i++)
{
//bump map/planar projection code requires normals to be normalized
mNormals[i].normalize3fast();
@@ -6580,8 +6542,8 @@ void LLVolumeFace::pushIndex(const U16& idx)
void LLVolumeFace::fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, std::vector<U16>& idx)
{
- resizeVertices(v.size());
- resizeIndices(idx.size());
+ resizeVertices(static_cast<S32>(v.size()));
+ resizeIndices(static_cast<S32>(idx.size()));
for (U32 i = 0; i < v.size(); ++i)
{
@@ -6596,18 +6558,18 @@ void LLVolumeFace::fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v,
}
}
-BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
+bool LLVolumeFace::createSide(LLVolume* volume, bool partial_build)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME
LL_CHECK_MEMORY
- BOOL flat = mTypeMask & FLAT_MASK;
+ bool flat = mTypeMask & FLAT_MASK;
U8 sculpt_type = volume->getParams().getSculptType();
U8 sculpt_stitching = sculpt_type & LL_SCULPT_TYPE_MASK;
- BOOL sculpt_invert = sculpt_type & LL_SCULPT_FLAG_INVERT;
- BOOL sculpt_mirror = sculpt_type & LL_SCULPT_FLAG_MIRROR;
- BOOL sculpt_reverse_horizontal = (sculpt_invert ? !sculpt_mirror : sculpt_mirror); // XOR
+ bool sculpt_invert = sculpt_type & LL_SCULPT_FLAG_INVERT;
+ bool sculpt_mirror = sculpt_type & LL_SCULPT_FLAG_MIRROR;
+ bool sculpt_reverse_horizontal = (sculpt_invert ? !sculpt_mirror : sculpt_mirror); // XOR
S32 num_vertices, num_indices;
@@ -6623,7 +6585,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
num_vertices = mNumS*mNumT;
num_indices = (mNumS-1)*(mNumT-1)*6;
- partial_build = (num_vertices > mNumVertices || num_indices > mNumIndices) ? FALSE : partial_build;
+ partial_build = (num_vertices > mNumVertices || num_indices > mNumIndices) ? false : partial_build;
if (!partial_build)
{
@@ -6676,7 +6638,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
{
// Get s value for tex-coord.
S32 index = mBeginS + s;
- if (index >= profile.size())
+ if (index >= (S32)profile.size())
{
// edge?
ss = flat ? 1.f - begin_stex : 1.f;
@@ -6794,7 +6756,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
S32 cur_index = 0;
S32 cur_edge = 0;
- BOOL flat_face = mTypeMask & FLAT_MASK;
+ bool flat_face = mTypeMask & FLAT_MASK;
if (!partial_build)
{
@@ -6810,45 +6772,63 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
mIndices[cur_index++] = s+1 + mNumS*t; //bottom right
mIndices[cur_index++] = s+1 + mNumS*(t+1); //top right
- mEdge[cur_edge++] = (mNumS-1)*2*t+s*2+1; //bottom left/top right neighbor face
- if (t < mNumT-2) { //top right/top left neighbor face
+ // bottom left/top right neighbor face
+ mEdge[cur_edge++] = (mNumS-1)*2*t+s*2+1;
+
+ if (t < mNumT-2)
+ { // top right/top left neighbor face
mEdge[cur_edge++] = (mNumS-1)*2*(t+1)+s*2+1;
}
- else if (mNumT <= 3 || volume->getPath().isOpen() == TRUE) { //no neighbor
+ else if (mNumT <= 3 || volume->getPath().isOpen())
+ { // no neighbor
mEdge[cur_edge++] = -1;
}
- else { //wrap on T
+ else
+ { // wrap on T
mEdge[cur_edge++] = s*2+1;
}
- if (s > 0) { //top left/bottom left neighbor face
+
+ if (s > 0)
+ { // top left/bottom left neighbor face
mEdge[cur_edge++] = (mNumS-1)*2*t+s*2-1;
}
- else if (flat_face || volume->getProfile().isOpen() == TRUE) { //no neighbor
+ else if (flat_face || volume->getProfile().isOpen())
+ { // no neighbor
mEdge[cur_edge++] = -1;
}
- else { //wrap on S
+ else
+ { // wrap on S
mEdge[cur_edge++] = (mNumS-1)*2*t+(mNumS-2)*2+1;
}
- if (t > 0) { //bottom left/bottom right neighbor face
+ if (t > 0)
+ { // bottom left/bottom right neighbor face
mEdge[cur_edge++] = (mNumS-1)*2*(t-1)+s*2;
}
- else if (mNumT <= 3 || volume->getPath().isOpen() == TRUE) { //no neighbor
+ else if (mNumT <= 3 || volume->getPath().isOpen())
+ { // no neighbor
mEdge[cur_edge++] = -1;
}
- else { //wrap on T
+ else
+ { // wrap on T
mEdge[cur_edge++] = (mNumS-1)*2*(mNumT-2)+s*2;
}
- if (s < mNumS-2) { //bottom right/top right neighbor face
+
+ if (s < mNumS-2)
+ { // bottom right/top right neighbor face
mEdge[cur_edge++] = (mNumS-1)*2*t+(s+1)*2;
}
- else if (flat_face || volume->getProfile().isOpen() == TRUE) { //no neighbor
+ else if (flat_face || volume->getProfile().isOpen())
+ { // no neighbor
mEdge[cur_edge++] = -1;
}
- else { //wrap on S
+ else
+ { // wrap on S
mEdge[cur_edge++] = (mNumS-1)*2*t;
}
- mEdge[cur_edge++] = (mNumS-1)*2*t+s*2; //top right/bottom left neighbor face
+
+ // top right/bottom left neighbor face
+ mEdge[cur_edge++] = (mNumS-1)*2*t+s*2;
}
}
}
@@ -6978,14 +6958,14 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
LLVector4a top;
top.setSub(pos[0], pos[mNumS*(mNumT-2)]);
- BOOL s_bottom_converges = (top.dot3(top) < 0.000001f);
+ bool s_bottom_converges = (top.dot3(top) < 0.000001f);
top.setSub(pos[mNumS-1], pos[mNumS*(mNumT-2)+mNumS-1]);
- BOOL s_top_converges = (top.dot3(top) < 0.000001f);
+ bool s_top_converges = (top.dot3(top) < 0.000001f);
if (sculpt_stitching == LL_SCULPT_TYPE_NONE) // logic for non-sculpt volumes
{
- if (volume->getPath().isOpen() == FALSE)
+ if (!volume->getPath().isOpen())
{ //wrap normals on T
for (S32 i = 0; i < mNumS; i++)
{
@@ -6996,7 +6976,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
}
}
- if ((volume->getProfile().isOpen() == FALSE) && !(s_bottom_converges))
+ if (!volume->getProfile().isOpen() && !s_bottom_converges)
{ //wrap normals on S
for (S32 i = 0; i < mNumT; i++)
{
@@ -7029,20 +7009,20 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
}
else // logic for sculpt volumes
{
- BOOL average_poles = FALSE;
- BOOL wrap_s = FALSE;
- BOOL wrap_t = FALSE;
+ bool average_poles = false;
+ bool wrap_s = false;
+ bool wrap_t = false;
if (sculpt_stitching == LL_SCULPT_TYPE_SPHERE)
- average_poles = TRUE;
+ average_poles = true;
if ((sculpt_stitching == LL_SCULPT_TYPE_SPHERE) ||
(sculpt_stitching == LL_SCULPT_TYPE_TORUS) ||
(sculpt_stitching == LL_SCULPT_TYPE_CYLINDER))
- wrap_s = TRUE;
+ wrap_s = true;
if (sculpt_stitching == LL_SCULPT_TYPE_TORUS)
- wrap_t = TRUE;
+ wrap_t = true;
if (average_poles)
@@ -7107,7 +7087,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
LL_CHECK_MEMORY
- return TRUE;
+ return true;
}
//adapted from Lengyel, Eric. "Computing Tangent Space Basis Vectors for an Arbitrary Mesh". Terathon Software 3D Graphics Library, 2001. http://www.terathon.com/code/tangent.html