aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmath')
-rw-r--r--linden/indra/llmath/llcamera.cpp2
-rw-r--r--linden/indra/llmath/llmath.h21
-rw-r--r--linden/indra/llmath/llrand.cpp4
-rw-r--r--linden/indra/llmath/lluuid.cpp2
-rw-r--r--linden/indra/llmath/llvolume.cpp27
5 files changed, 28 insertions, 28 deletions
diff --git a/linden/indra/llmath/llcamera.cpp b/linden/indra/llmath/llcamera.cpp
index 2197066..c32bb67 100644
--- a/linden/indra/llmath/llcamera.cpp
+++ b/linden/indra/llmath/llcamera.cpp
@@ -506,7 +506,7 @@ void LLCamera::calcAgentFrustumPlanes(LLVector3* frust)
506 mAgentPlanes[3] = planeFromPoints(frust[1], frust[0], frust[4]); 506 mAgentPlanes[3] = planeFromPoints(frust[1], frust[0], frust[4]);
507 507
508 //cache plane octant facing mask for use in AABBInFrustum 508 //cache plane octant facing mask for use in AABBInFrustum
509 for (int i = 0; i < 8; i++) 509 for (int i = 0; i < 6; i++)
510 { 510 {
511 U8 mask = 0; 511 U8 mask = 0;
512 LLPlane p = mAgentPlanes[i]; 512 LLPlane p = mAgentPlanes[i];
diff --git a/linden/indra/llmath/llmath.h b/linden/indra/llmath/llmath.h
index dbd825d..dd44e0c 100644
--- a/linden/indra/llmath/llmath.h
+++ b/linden/indra/llmath/llmath.h
@@ -99,6 +99,27 @@ inline BOOL is_approx_equal(F32 x, F32 y)
99 return (abs((S32) ((U32&)x - (U32&)y) ) < COMPARE_MANTISSA_UP_TO_BIT); 99 return (abs((S32) ((U32&)x - (U32&)y) ) < COMPARE_MANTISSA_UP_TO_BIT);
100} 100}
101 101
102inline BOOL is_approx_equal_fraction(F32 x, F32 y, U32 frac_bits)
103{
104 BOOL ret = TRUE;
105 F32 diff = (F32) fabs(x - y);
106
107 S32 diffInt = (S32) diff;
108 S32 diffFracTolerance = (S32) ((diff - (F32) diffInt) * (1 << frac_bits));
109
110 // if integer portion is not equal, not enough bits were used for packing
111 // so error out since either the use case is not correct OR there is
112 // an issue with pack/unpack. should fail in either case.
113 // for decimal portion, make sure that the delta is no more than 1
114 // based on the number of bits used for packing decimal portion.
115 if (diffInt != 0 || diffFracTolerance > 1)
116 {
117 ret = FALSE;
118 }
119
120 return ret;
121}
122
102inline S32 llabs(const S32 a) 123inline S32 llabs(const S32 a)
103{ 124{
104 return S32(labs(a)); 125 return S32(labs(a));
diff --git a/linden/indra/llmath/llrand.cpp b/linden/indra/llmath/llrand.cpp
index f62bd71..e6c4cc5 100644
--- a/linden/indra/llmath/llrand.cpp
+++ b/linden/indra/llmath/llrand.cpp
@@ -106,7 +106,7 @@ inline F64 ll_internal_random_double()
106 // occasionally give an obviously incorrect random number -- like 106 // occasionally give an obviously incorrect random number -- like
107 // 5^15 or something. Sooooo, clamp it as described above. 107 // 5^15 or something. Sooooo, clamp it as described above.
108 F64 rv = gRandomGenerator(); 108 F64 rv = gRandomGenerator();
109 if(!((rv >= 0.0) && (rv < 1.0))) return 0.0; 109 if(!((rv >= 0.0) && (rv < 1.0))) return fmod(rv, 1.0);
110 return rv; 110 return rv;
111} 111}
112 112
@@ -114,7 +114,7 @@ inline F32 ll_internal_random_float()
114{ 114{
115 // The clamping rules are described above. 115 // The clamping rules are described above.
116 F32 rv = (F32)gRandomGenerator(); 116 F32 rv = (F32)gRandomGenerator();
117 if(!((rv >= 0.0f) && (rv < 1.0f))) return 0.0f; 117 if(!((rv >= 0.0f) && (rv < 1.0f))) return fmod(rv, 1.f);
118 return rv; 118 return rv;
119} 119}
120#endif 120#endif
diff --git a/linden/indra/llmath/lluuid.cpp b/linden/indra/llmath/lluuid.cpp
index 78dc8e6..0fed6b3 100644
--- a/linden/indra/llmath/lluuid.cpp
+++ b/linden/indra/llmath/lluuid.cpp
@@ -486,7 +486,7 @@ S32 LLUUID::getNodeID(unsigned char * node_id)
486 Ncb.ncb_command = NCBASTAT; 486 Ncb.ncb_command = NCBASTAT;
487 Ncb.ncb_lana_num = lenum.lana[i]; 487 Ncb.ncb_lana_num = lenum.lana[i];
488 488
489 strcpy( (char *)Ncb.ncb_callname, "* " ); /* Flawfinder: ignore */ 489 strcpy( (char *)Ncb.ncb_callname, "* " ); /* Flawfinder: ignore */
490 Ncb.ncb_buffer = (unsigned char *)&Adapter; 490 Ncb.ncb_buffer = (unsigned char *)&Adapter;
491 Ncb.ncb_length = sizeof(Adapter); 491 Ncb.ncb_length = sizeof(Adapter);
492 492
diff --git a/linden/indra/llmath/llvolume.cpp b/linden/indra/llmath/llvolume.cpp
index bb3b24d..89644a5 100644
--- a/linden/indra/llmath/llvolume.cpp
+++ b/linden/indra/llmath/llvolume.cpp
@@ -742,10 +742,6 @@ BOOL LLProfileParams::importFile(FILE *fp)
742 buffer, 742 buffer,
743 " %255s %255s", 743 " %255s %255s",
744 keyword, valuestr); 744 keyword, valuestr);
745 if (!keyword)
746 {
747 continue;
748 }
749 if (!strcmp("{", keyword)) 745 if (!strcmp("{", keyword))
750 { 746 {
751 continue; 747 continue;
@@ -818,10 +814,6 @@ BOOL LLProfileParams::importLegacyStream(std::istream& input_stream)
818 " %255s %255s", 814 " %255s %255s",
819 keyword, 815 keyword,
820 valuestr); 816 valuestr);
821 if (!keyword)
822 {
823 continue;
824 }
825 if (!strcmp("{", keyword)) 817 if (!strcmp("{", keyword))
826 { 818 {
827 continue; 819 continue;
@@ -1245,10 +1237,6 @@ BOOL LLPathParams::importFile(FILE *fp)
1245 buffer, 1237 buffer,
1246 " %255s %255s", 1238 " %255s %255s",
1247 keyword, valuestr); 1239 keyword, valuestr);
1248 if (!keyword)
1249 {
1250 continue;
1251 }
1252 if (!strcmp("{", keyword)) 1240 if (!strcmp("{", keyword))
1253 { 1241 {
1254 continue; 1242 continue;
@@ -1389,10 +1377,6 @@ BOOL LLPathParams::importLegacyStream(std::istream& input_stream)
1389 buffer, 1377 buffer,
1390 " %255s %255s", 1378 " %255s %255s",
1391 keyword, valuestr); 1379 keyword, valuestr);
1392 if (!keyword)
1393 {
1394 continue;
1395 }
1396 if (!strcmp("{", keyword)) 1380 if (!strcmp("{", keyword))
1397 { 1381 {
1398 continue; 1382 continue;
@@ -3287,6 +3271,9 @@ BOOL LLVolume::cleanupTriangleData( const S32 num_input_vertices,
3287 if (new_num_triangles == 0) 3271 if (new_num_triangles == 0)
3288 { 3272 {
3289 llwarns << "Created volume object with 0 faces." << llendl; 3273 llwarns << "Created volume object with 0 faces." << llendl;
3274 delete[] new_triangles;
3275 delete[] vertex_mapping;
3276 delete[] new_vertices;
3290 return FALSE; 3277 return FALSE;
3291 } 3278 }
3292 3279
@@ -3381,10 +3368,6 @@ BOOL LLVolumeParams::importFile(FILE *fp)
3381 { 3368 {
3382 fgets(buffer, BUFSIZE, fp); 3369 fgets(buffer, BUFSIZE, fp);
3383 sscanf(buffer, " %255s", keyword); /* Flawfinder: ignore */ 3370 sscanf(buffer, " %255s", keyword); /* Flawfinder: ignore */
3384 if (!keyword)
3385 {
3386 continue;
3387 }
3388 if (!strcmp("{", keyword)) 3371 if (!strcmp("{", keyword))
3389 { 3372 {
3390 continue; 3373 continue;
@@ -3435,10 +3418,6 @@ BOOL LLVolumeParams::importLegacyStream(std::istream& input_stream)
3435 { 3418 {
3436 input_stream.getline(buffer, BUFSIZE); 3419 input_stream.getline(buffer, BUFSIZE);
3437 sscanf(buffer, " %255s", keyword); 3420 sscanf(buffer, " %255s", keyword);
3438 if (!keyword)
3439 {
3440 continue;
3441 }
3442 if (!strcmp("{", keyword)) 3421 if (!strcmp("{", keyword))
3443 { 3422 {
3444 continue; 3423 continue;