aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmath')
-rw-r--r--linden/indra/llmath/llcamera.cpp16
-rw-r--r--linden/indra/llmath/llcoordframe.cpp16
-rw-r--r--linden/indra/llmath/llcrc.cpp25
-rw-r--r--linden/indra/llmath/llmath.vcproj9
-rw-r--r--linden/indra/llmath/llmath_vc8.vcproj453
-rw-r--r--linden/indra/llmath/llmd5.cpp71
-rw-r--r--linden/indra/llmath/llmd5.h2
-rw-r--r--linden/indra/llmath/lloctree.h94
-rw-r--r--linden/indra/llmath/llrand.cpp18
-rw-r--r--linden/indra/llmath/llrand.h6
-rw-r--r--linden/indra/llmath/lltreenode.h5
-rw-r--r--linden/indra/llmath/lluuid.cpp32
-rw-r--r--linden/indra/llmath/lluuid.h7
-rw-r--r--linden/indra/llmath/llvolume.cpp220
-rw-r--r--linden/indra/llmath/llvolume.h3
-rw-r--r--linden/indra/llmath/llvolumemgr.cpp4
-rw-r--r--linden/indra/llmath/m3math.cpp95
-rw-r--r--linden/indra/llmath/m3math.h9
-rw-r--r--linden/indra/llmath/m4math.h9
-rw-r--r--linden/indra/llmath/v2math.h15
-rw-r--r--linden/indra/llmath/v3color.h6
-rw-r--r--linden/indra/llmath/v3math.cpp31
-rw-r--r--linden/indra/llmath/v3math.h43
-rw-r--r--linden/indra/llmath/v4math.h11
24 files changed, 852 insertions, 348 deletions
diff --git a/linden/indra/llmath/llcamera.cpp b/linden/indra/llmath/llcamera.cpp
index 13666ba..bc13c90 100644
--- a/linden/indra/llmath/llcamera.cpp
+++ b/linden/indra/llmath/llcamera.cpp
@@ -121,25 +121,25 @@ void LLCamera::setFar(F32 far_plane)
121 121
122size_t LLCamera::writeFrustumToBuffer(char *buffer) const 122size_t LLCamera::writeFrustumToBuffer(char *buffer) const
123{ 123{
124 memcpy(buffer, &mView, sizeof(F32)); 124 memcpy(buffer, &mView, sizeof(F32)); /* Flawfinder: ignore */
125 buffer += sizeof(F32); 125 buffer += sizeof(F32);
126 memcpy(buffer, &mAspect, sizeof(F32)); 126 memcpy(buffer, &mAspect, sizeof(F32)); /* Flawfinder: ignore */
127 buffer += sizeof(F32); 127 buffer += sizeof(F32);
128 memcpy(buffer, &mNearPlane, sizeof(F32)); 128 memcpy(buffer, &mNearPlane, sizeof(F32)); /* Flawfinder: ignore */
129 buffer += sizeof(F32); 129 buffer += sizeof(F32);
130 memcpy(buffer, &mFarPlane, sizeof(F32)); 130 memcpy(buffer, &mFarPlane, sizeof(F32)); /* Flawfinder: ignore */
131 return 4*sizeof(F32); 131 return 4*sizeof(F32);
132} 132}
133 133
134size_t LLCamera::readFrustumFromBuffer(const char *buffer) 134size_t LLCamera::readFrustumFromBuffer(const char *buffer)
135{ 135{
136 memcpy(&mView, buffer, sizeof(F32)); 136 memcpy(&mView, buffer, sizeof(F32)); /* Flawfinder: ignore */
137 buffer += sizeof(F32); 137 buffer += sizeof(F32);
138 memcpy(&mAspect, buffer, sizeof(F32)); 138 memcpy(&mAspect, buffer, sizeof(F32)); /* Flawfinder: ignore */
139 buffer += sizeof(F32); 139 buffer += sizeof(F32);
140 memcpy(&mNearPlane, buffer, sizeof(F32)); 140 memcpy(&mNearPlane, buffer, sizeof(F32)); /* Flawfinder: ignore */
141 buffer += sizeof(F32); 141 buffer += sizeof(F32);
142 memcpy(&mFarPlane, buffer, sizeof(F32)); 142 memcpy(&mFarPlane, buffer, sizeof(F32)); /* Flawfinder: ignore */
143 return 4*sizeof(F32); 143 return 4*sizeof(F32);
144} 144}
145 145
diff --git a/linden/indra/llmath/llcoordframe.cpp b/linden/indra/llmath/llcoordframe.cpp
index 552854d..c7d18bb 100644
--- a/linden/indra/llmath/llcoordframe.cpp
+++ b/linden/indra/llmath/llcoordframe.cpp
@@ -460,26 +460,26 @@ void LLCoordFrame::getRotMatrixToParent(LLMatrix4& mat) const
460 460
461size_t LLCoordFrame::writeOrientation(char *buffer) const 461size_t LLCoordFrame::writeOrientation(char *buffer) const
462{ 462{
463 memcpy(buffer, mOrigin.mV, 3*sizeof(F32)); 463 memcpy(buffer, mOrigin.mV, 3*sizeof(F32)); /*Flawfinder: ignore */
464 buffer += 3*sizeof(F32); 464 buffer += 3*sizeof(F32);
465 memcpy(buffer, mXAxis.mV, 3*sizeof(F32)); 465 memcpy(buffer, mXAxis.mV, 3*sizeof(F32)); /*Flawfinder: ignore */
466 buffer += 3*sizeof(F32); 466 buffer += 3*sizeof(F32);
467 memcpy(buffer, mYAxis.mV, 3*sizeof(F32)); 467 memcpy(buffer, mYAxis.mV, 3*sizeof(F32));/*Flawfinder: ignore */
468 buffer += 3*sizeof(F32); 468 buffer += 3*sizeof(F32);
469 memcpy(buffer, mZAxis.mV, 3*sizeof(F32)); 469 memcpy(buffer, mZAxis.mV, 3*sizeof(F32)); /*Flawfinder: ignore */
470 return 12*sizeof(F32); 470 return 12*sizeof(F32);
471} 471}
472 472
473 473
474size_t LLCoordFrame::readOrientation(const char *buffer) 474size_t LLCoordFrame::readOrientation(const char *buffer)
475{ 475{
476 memcpy(mOrigin.mV, buffer, 3*sizeof(F32)); 476 memcpy(mOrigin.mV, buffer, 3*sizeof(F32)); /*Flawfinder: ignore */
477 buffer += 3*sizeof(F32); 477 buffer += 3*sizeof(F32);
478 memcpy(mXAxis.mV, buffer, 3*sizeof(F32)); 478 memcpy(mXAxis.mV, buffer, 3*sizeof(F32)); /*Flawfinder: ignore */
479 buffer += 3*sizeof(F32); 479 buffer += 3*sizeof(F32);
480 memcpy(mYAxis.mV, buffer, 3*sizeof(F32)); 480 memcpy(mYAxis.mV, buffer, 3*sizeof(F32)); /*Flawfinder: ignore */
481 buffer += 3*sizeof(F32); 481 buffer += 3*sizeof(F32);
482 memcpy(mZAxis.mV, buffer, 3*sizeof(F32)); 482 memcpy(mZAxis.mV, buffer, 3*sizeof(F32)); /*Flawfinder: ignore */
483 483
484 if( !isFinite() ) 484 if( !isFinite() )
485 { 485 {
diff --git a/linden/indra/llmath/llcrc.cpp b/linden/indra/llmath/llcrc.cpp
index 4194432..1c0aa5d 100644
--- a/linden/indra/llmath/llcrc.cpp
+++ b/linden/indra/llmath/llcrc.cpp
@@ -161,9 +161,15 @@ void LLCRC::update(const U8* buffer, U32 buffer_size)
161 } 161 }
162} 162}
163 163
164void LLCRC::update(const char *filename) 164void LLCRC::update(const char* filename)
165{ 165{
166 FILE *fp = LLFile::fopen(filename, "rb"); 166 if (!filename)
167 {
168 llerrs << "No filename specified" << llendl;
169 return;
170 }
171
172 FILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
167 173
168 if (fp) 174 if (fp)
169 { 175 {
@@ -172,12 +178,15 @@ void LLCRC::update(const char *filename)
172 178
173 fseek(fp, 0, SEEK_SET); 179 fseek(fp, 0, SEEK_SET);
174 180
175 U8 *data = new U8[size]; 181 if (size > 0)
176 fread(data, size, 1, fp); 182 {
177 fclose(fp); 183 U8* data = new U8[size];
184 fread(data, size, 1, fp);
185 fclose(fp);
178 186
179 update(data, size); 187 update(data, size);
180 delete[] data; 188 delete[] data;
189 }
181 } 190 }
182} 191}
183 192
@@ -186,7 +195,7 @@ void LLCRC::update(const char *filename)
186BOOL LLCRC::testHarness() 195BOOL LLCRC::testHarness()
187{ 196{
188 const S32 TEST_BUFFER_SIZE = 16; 197 const S32 TEST_BUFFER_SIZE = 16;
189 const char TEST_BUFFER[TEST_BUFFER_SIZE] = "hello &#$)$&Nd0"; 198 const char TEST_BUFFER[TEST_BUFFER_SIZE] = "hello &#$)$&Nd0"; /* Flawfinder: ignore */
190 LLCRC c1, c2; 199 LLCRC c1, c2;
191 c1.update((U8*)TEST_BUFFER, TEST_BUFFER_SIZE - 1); 200 c1.update((U8*)TEST_BUFFER, TEST_BUFFER_SIZE - 1);
192 char* rh = (char*)TEST_BUFFER; 201 char* rh = (char*)TEST_BUFFER;
diff --git a/linden/indra/llmath/llmath.vcproj b/linden/indra/llmath/llmath.vcproj
index 9b6047d..82feb25 100644
--- a/linden/indra/llmath/llmath.vcproj
+++ b/linden/indra/llmath/llmath.vcproj
@@ -224,6 +224,9 @@
224 Filter="h;hpp;hxx;hm;inl;inc;xsd" 224 Filter="h;hpp;hxx;hm;inl;inc;xsd"
225 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 225 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
226 <File 226 <File
227 RelativePath=".\linden_math.h">
228 </File>
229 <File
227 RelativePath=".\llbboxlocal.h"> 230 RelativePath=".\llbboxlocal.h">
228 </File> 231 </File>
229 <File 232 <File
@@ -242,9 +245,6 @@
242 RelativePath=".\llinterp.h"> 245 RelativePath=".\llinterp.h">
243 </File> 246 </File>
244 <File 247 <File
245 RelativePath=".\llmath.h">
246 </File>
247 <File
248 RelativePath=".\llmd5.h"> 248 RelativePath=".\llmd5.h">
249 </File> 249 </File>
250 <File 250 <File
@@ -308,6 +308,9 @@
308 RelativePath=".\v4math.h"> 308 RelativePath=".\v4math.h">
309 </File> 309 </File>
310 <File 310 <File
311 RelativePath=".\vmath.h">
312 </File>
313 <File
311 RelativePath=".\xform.h"> 314 RelativePath=".\xform.h">
312 </File> 315 </File>
313 </Filter> 316 </Filter>
diff --git a/linden/indra/llmath/llmath_vc8.vcproj b/linden/indra/llmath/llmath_vc8.vcproj
new file mode 100644
index 0000000..ea23702
--- /dev/null
+++ b/linden/indra/llmath/llmath_vc8.vcproj
@@ -0,0 +1,453 @@
1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject
3 ProjectType="Visual C++"
4 Version="8.00"
5 Name="llmath"
6 ProjectGUID="{E87FD9BE-BE42-4EA3-BF4D-D992223046D9}"
7 Keyword="Win32Proj"
8 >
9 <Platforms>
10 <Platform
11 Name="Win32"
12 />
13 </Platforms>
14 <ToolFiles>
15 </ToolFiles>
16 <Configurations>
17 <Configuration
18 Name="Debug|Win32"
19 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
20 IntermediateDirectory="$(ConfigurationName)"
21 ConfigurationType="4"
22 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
23 CharacterSet="1"
24 >
25 <Tool
26 Name="VCPreBuildEventTool"
27 />
28 <Tool
29 Name="VCCustomBuildTool"
30 />
31 <Tool
32 Name="VCXMLDataGeneratorTool"
33 />
34 <Tool
35 Name="VCWebServiceProxyGeneratorTool"
36 />
37 <Tool
38 Name="VCMIDLTool"
39 />
40 <Tool
41 Name="VCCLCompilerTool"
42 Optimization="0"
43 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\"
44 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG"
45 MinimalRebuild="true"
46 BasicRuntimeChecks="3"
47 RuntimeLibrary="1"
48 StructMemberAlignment="4"
49 TreatWChar_tAsBuiltInType="false"
50 ForceConformanceInForLoopScope="true"
51 UsePrecompiledHeader="0"
52 WarningLevel="3"
53 WarnAsError="true"
54 Detect64BitPortabilityProblems="false"
55 DebugInformationFormat="4"
56 />
57 <Tool
58 Name="VCManagedResourceCompilerTool"
59 />
60 <Tool
61 Name="VCResourceCompilerTool"
62 />
63 <Tool
64 Name="VCPreLinkEventTool"
65 />
66 <Tool
67 Name="VCLibrarianTool"
68 OutputFile="$(OutDir)/llmath.lib"
69 />
70 <Tool
71 Name="VCALinkTool"
72 />
73 <Tool
74 Name="VCXDCMakeTool"
75 />
76 <Tool
77 Name="VCBscMakeTool"
78 />
79 <Tool
80 Name="VCFxCopTool"
81 />
82 <Tool
83 Name="VCPostBuildEventTool"
84 />
85 </Configuration>
86 <Configuration
87 Name="Release|Win32"
88 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
89 IntermediateDirectory="$(ConfigurationName)"
90 ConfigurationType="4"
91 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
92 CharacterSet="1"
93 >
94 <Tool
95 Name="VCPreBuildEventTool"
96 />
97 <Tool
98 Name="VCCustomBuildTool"
99 />
100 <Tool
101 Name="VCXMLDataGeneratorTool"
102 />
103 <Tool
104 Name="VCWebServiceProxyGeneratorTool"
105 />
106 <Tool
107 Name="VCMIDLTool"
108 />
109 <Tool
110 Name="VCCLCompilerTool"
111 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\"
112 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
113 RuntimeLibrary="0"
114 StructMemberAlignment="0"
115 TreatWChar_tAsBuiltInType="false"
116 ForceConformanceInForLoopScope="true"
117 UsePrecompiledHeader="0"
118 WarningLevel="3"
119 WarnAsError="true"
120 Detect64BitPortabilityProblems="false"
121 DebugInformationFormat="3"
122 />
123 <Tool
124 Name="VCManagedResourceCompilerTool"
125 />
126 <Tool
127 Name="VCResourceCompilerTool"
128 />
129 <Tool
130 Name="VCPreLinkEventTool"
131 />
132 <Tool
133 Name="VCLibrarianTool"
134 OutputFile="$(OutDir)/llmath.lib"
135 />
136 <Tool
137 Name="VCALinkTool"
138 />
139 <Tool
140 Name="VCXDCMakeTool"
141 />
142 <Tool
143 Name="VCBscMakeTool"
144 />
145 <Tool
146 Name="VCFxCopTool"
147 />
148 <Tool
149 Name="VCPostBuildEventTool"
150 />
151 </Configuration>
152 <Configuration
153 Name="ReleaseNoOpt|Win32"
154 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
155 IntermediateDirectory="$(ConfigurationName)"
156 ConfigurationType="4"
157 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
158 CharacterSet="1"
159 >
160 <Tool
161 Name="VCPreBuildEventTool"
162 />
163 <Tool
164 Name="VCCustomBuildTool"
165 />
166 <Tool
167 Name="VCXMLDataGeneratorTool"
168 />
169 <Tool
170 Name="VCWebServiceProxyGeneratorTool"
171 />
172 <Tool
173 Name="VCMIDLTool"
174 />
175 <Tool
176 Name="VCCLCompilerTool"
177 Optimization="0"
178 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\"
179 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
180 RuntimeLibrary="0"
181 StructMemberAlignment="0"
182 TreatWChar_tAsBuiltInType="false"
183 ForceConformanceInForLoopScope="true"
184 UsePrecompiledHeader="0"
185 BrowseInformation="0"
186 WarningLevel="3"
187 WarnAsError="true"
188 Detect64BitPortabilityProblems="false"
189 DebugInformationFormat="3"
190 />
191 <Tool
192 Name="VCManagedResourceCompilerTool"
193 />
194 <Tool
195 Name="VCResourceCompilerTool"
196 />
197 <Tool
198 Name="VCPreLinkEventTool"
199 />
200 <Tool
201 Name="VCLibrarianTool"
202 OutputFile="$(OutDir)/llmath.lib"
203 />
204 <Tool
205 Name="VCALinkTool"
206 />
207 <Tool
208 Name="VCXDCMakeTool"
209 />
210 <Tool
211 Name="VCBscMakeTool"
212 />
213 <Tool
214 Name="VCFxCopTool"
215 />
216 <Tool
217 Name="VCPostBuildEventTool"
218 />
219 </Configuration>
220 </Configurations>
221 <References>
222 </References>
223 <Files>
224 <Filter
225 Name="Source Files"
226 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
227 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
228 >
229 <File
230 RelativePath=".\llbboxlocal.cpp"
231 >
232 </File>
233 <File
234 RelativePath=".\llcamera.cpp"
235 >
236 </File>
237 <File
238 RelativePath=".\llcoordframe.cpp"
239 >
240 </File>
241 <File
242 RelativePath=".\llcrc.cpp"
243 >
244 </File>
245 <File
246 RelativePath=".\llmd5.cpp"
247 >
248 </File>
249 <File
250 RelativePath=".\llperlin.cpp"
251 >
252 </File>
253 <File
254 RelativePath=".\llquaternion.cpp"
255 >
256 </File>
257 <File
258 RelativePath=".\llrand.cpp"
259 >
260 </File>
261 <File
262 RelativePath=".\llrect.cpp"
263 >
264 </File>
265 <File
266 RelativePath=".\lluuid.cpp"
267 >
268 </File>
269 <File
270 RelativePath=".\llvolume.cpp"
271 >
272 </File>
273 <File
274 RelativePath=".\llvolumemgr.cpp"
275 >
276 </File>
277 <File
278 RelativePath=".\m3math.cpp"
279 >
280 </File>
281 <File
282 RelativePath=".\m4math.cpp"
283 >
284 </File>
285 <File
286 RelativePath=".\raytrace.cpp"
287 >
288 </File>
289 <File
290 RelativePath=".\v2math.cpp"
291 >
292 </File>
293 <File
294 RelativePath=".\v3color.cpp"
295 >
296 </File>
297 <File
298 RelativePath=".\v3dmath.cpp"
299 >
300 </File>
301 <File
302 RelativePath=".\v3math.cpp"
303 >
304 </File>
305 <File
306 RelativePath=".\v4color.cpp"
307 >
308 </File>
309 <File
310 RelativePath=".\v4coloru.cpp"
311 >
312 </File>
313 <File
314 RelativePath=".\v4math.cpp"
315 >
316 </File>
317 <File
318 RelativePath=".\xform.cpp"
319 >
320 </File>
321 </Filter>
322 <Filter
323 Name="Header Files"
324 Filter="h;hpp;hxx;hm;inl;inc;xsd"
325 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
326 >
327 <File
328 RelativePath=".\llbboxlocal.h"
329 >
330 </File>
331 <File
332 RelativePath=".\llcamera.h"
333 >
334 </File>
335 <File
336 RelativePath=".\llcoord.h"
337 >
338 </File>
339 <File
340 RelativePath=".\llcoordframe.h"
341 >
342 </File>
343 <File
344 RelativePath=".\llcrc.h"
345 >
346 </File>
347 <File
348 RelativePath=".\llinterp.h"
349 >
350 </File>
351 <File
352 RelativePath=".\llmath.h"
353 >
354 </File>
355 <File
356 RelativePath=".\llmd5.h"
357 >
358 </File>
359 <File
360 RelativePath=".\lloctree.h"
361 >
362 </File>
363 <File
364 RelativePath=".\llperlin.h"
365 >
366 </File>
367 <File
368 RelativePath=".\llquantize.h"
369 >
370 </File>
371 <File
372 RelativePath=".\llquaternion.h"
373 >
374 </File>
375 <File
376 RelativePath=".\llrand.h"
377 >
378 </File>
379 <File
380 RelativePath=".\llrect.h"
381 >
382 </File>
383 <File
384 RelativePath=".\lltreenode.h"
385 >
386 </File>
387 <File
388 RelativePath=".\lluuid.h"
389 >
390 </File>
391 <File
392 RelativePath=".\llvolume.h"
393 >
394 </File>
395 <File
396 RelativePath=".\llvolumemgr.h"
397 >
398 </File>
399 <File
400 RelativePath=".\m3math.h"
401 >
402 </File>
403 <File
404 RelativePath=".\m4math.h"
405 >
406 </File>
407 <File
408 RelativePath=".\raytrace.h"
409 >
410 </File>
411 <File
412 RelativePath=".\v2math.h"
413 >
414 </File>
415 <File
416 RelativePath=".\v3color.h"
417 >
418 </File>
419 <File
420 RelativePath=".\v3dmath.h"
421 >
422 </File>
423 <File
424 RelativePath=".\v3math.h"
425 >
426 </File>
427 <File
428 RelativePath=".\v4color.h"
429 >
430 </File>
431 <File
432 RelativePath=".\v4coloru.h"
433 >
434 </File>
435 <File
436 RelativePath=".\v4math.h"
437 >
438 </File>
439 <File
440 RelativePath=".\xform.h"
441 >
442 </File>
443 </Filter>
444 <Filter
445 Name="Resource Files"
446 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
447 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
448 >
449 </Filter>
450 </Files>
451 <Globals>
452 </Globals>
453</VisualStudioProject>
diff --git a/linden/indra/llmath/llmd5.cpp b/linden/indra/llmath/llmd5.cpp
index 19174af..267381c 100644
--- a/linden/indra/llmath/llmd5.cpp
+++ b/linden/indra/llmath/llmd5.cpp
@@ -122,10 +122,18 @@ void LLMD5::update (const uint1 *input, const uint4 input_length) {
122 // Transform as many times as possible. 122 // Transform as many times as possible.
123 if (input_length >= buffer_space) { // ie. we have enough to fill the buffer 123 if (input_length >= buffer_space) { // ie. we have enough to fill the buffer
124 // fill the rest of the buffer and transform 124 // fill the rest of the buffer and transform
125 memcpy (buffer + buffer_index, input, buffer_space); 125 memcpy( /* Flawfinder: ignore */
126 buffer + buffer_index,
127 input,
128 buffer_space);
126 transform (buffer); 129 transform (buffer);
127 130
128 // now, transform each 64-byte piece of the input, bypassing the buffer 131 // now, transform each 64-byte piece of the input, bypassing the buffer
132 if (input == NULL || input_length == 0){
133 std::cerr << "LLMD5::update: Invalid input!" << std::endl;
134 return;
135 }
136
129 for (input_index = buffer_space; input_index + 63 < input_length; 137 for (input_index = buffer_space; input_index + 63 < input_length;
130 input_index += 64) 138 input_index += 64)
131 transform (input+input_index); 139 transform (input+input_index);
@@ -137,7 +145,7 @@ void LLMD5::update (const uint1 *input, const uint4 input_length) {
137 145
138 146
139 // and here we do the buffering: 147 // and here we do the buffering:
140 memcpy(buffer+buffer_index, input+input_index, input_length-input_index); 148 memcpy(buffer+buffer_index, input+input_index, input_length-input_index); /* Flawfinder: ignore */
141} 149}
142 150
143 151
@@ -145,9 +153,9 @@ void LLMD5::update (const uint1 *input, const uint4 input_length) {
145// MD5 update for files. 153// MD5 update for files.
146// Like above, except that it works on files (and uses above as a primitive.) 154// Like above, except that it works on files (and uses above as a primitive.)
147 155
148void LLMD5::update(FILE *file){ 156void LLMD5::update(FILE* file){
149 157
150 unsigned char buffer[1024]; 158 unsigned char buffer[1024]; /* Flawfinder: ignore */
151 int len; 159 int len;
152 160
153 while ( (len=(int)fread(buffer, 1, 1024, file)) ) 161 while ( (len=(int)fread(buffer, 1, 1024, file)) )
@@ -167,11 +175,11 @@ void LLMD5::update(FILE *file){
167 175
168void LLMD5::update(std::istream& stream){ 176void LLMD5::update(std::istream& stream){
169 177
170 unsigned char buffer[1024]; 178 unsigned char buffer[1024]; /* Flawfinder: ignore */
171 int len; 179 int len;
172 180
173 while (stream.good()){ 181 while (stream.good()){
174 stream.read( (char*)buffer, 1024); // note that return value of read is unusable. 182 stream.read( (char*)buffer, 1024); /* Flawfinder: ignore */ // note that return value of read is unusable.
175 len=stream.gcount(); 183 len=stream.gcount();
176 update(buffer, len); 184 update(buffer, len);
177 } 185 }
@@ -182,35 +190,13 @@ void LLMD5::update(std::istream& stream){
182 190
183 191
184 192
185
186// MD5 update for ifstreams.
187// Like update for files; see above.
188
189void LLMD5::update(llifstream& stream){
190
191 unsigned char buffer[1024];
192 int len;
193
194 while (stream.good()){
195 stream.read( (char*)buffer, 1024); // note that return value of read is unusable.
196 len=stream.gcount();
197 update(buffer, len);
198 }
199
200}
201
202
203
204
205
206
207// MD5 finalization. Ends an MD5 message-digest operation, writing the 193// MD5 finalization. Ends an MD5 message-digest operation, writing the
208// the message digest and zeroizing the context. 194// the message digest and zeroizing the context.
209 195
210 196
211void LLMD5::finalize (){ 197void LLMD5::finalize (){
212 198
213 unsigned char bits[8]; 199 unsigned char bits[8]; /* Flawfinder: ignore */
214 unsigned int index, padLen; 200 unsigned int index, padLen;
215 static uint1 PADDING[64]={ 201 static uint1 PADDING[64]={
216 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -264,25 +250,16 @@ LLMD5::LLMD5(std::istream& stream){
264 finalize(); 250 finalize();
265} 251}
266 252
267
268
269LLMD5::LLMD5(llifstream& stream)
270{
271 init(); // must called by all constructors
272 update (stream);
273 finalize();
274}
275
276// Digest a string of the format ("%s:%i" % (s, number)) 253// Digest a string of the format ("%s:%i" % (s, number))
277LLMD5::LLMD5(const unsigned char *string, const unsigned int number) 254LLMD5::LLMD5(const unsigned char *string, const unsigned int number)
278{ 255{
279 const char *colon = ":"; 256 const char *colon = ":";
280 char tbuf[16]; 257 char tbuf[16]; /* Flawfinder: ignore */
281 init(); 258 init();
282 update(string, (U32)strlen((const char *) string)); 259 update(string, (U32)strlen((const char *) string)); /* Flawfinder: ignore */
283 update((const unsigned char *) colon, (U32)strlen(colon)); 260 update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */
284 sprintf(tbuf, "%i", number); 261 snprintf(tbuf, sizeof(tbuf), "%i", number); /* Flawfinder: ignore */
285 update((const unsigned char *) tbuf, (U32)strlen(tbuf)); 262 update((const unsigned char *) tbuf, (U32)strlen(tbuf)); /* Flawfinder: ignore */
286 finalize(); 263 finalize();
287} 264}
288 265
@@ -290,7 +267,7 @@ LLMD5::LLMD5(const unsigned char *string, const unsigned int number)
290LLMD5::LLMD5(const unsigned char *s) 267LLMD5::LLMD5(const unsigned char *s)
291{ 268{
292 init(); 269 init();
293 update(s, (U32)strlen((const char *) s)); 270 update(s, (U32)strlen((const char *) s)); /* Flawfinder: ignore */
294 finalize(); 271 finalize();
295} 272}
296 273
@@ -304,7 +281,7 @@ void LLMD5::raw_digest(unsigned char *s)
304 return; 281 return;
305 } 282 }
306 283
307 memcpy(s, digest, 16); 284 memcpy(s, digest, 16); /* Flawfinder: ignore */
308 return; 285 return;
309} 286}
310 287
@@ -324,7 +301,7 @@ void LLMD5::hex_digest(char *s)
324 301
325 for (i=0; i<16; i++) 302 for (i=0; i<16; i++)
326 { 303 {
327 sprintf(s+i*2, "%02x", digest[i]); 304 sprintf(s+i*2, "%02x", digest[i]); /* Flawfinder: ignore */
328 } 305 }
329 306
330 s[32]='\0'; 307 s[32]='\0';
@@ -338,7 +315,7 @@ void LLMD5::hex_digest(char *s)
338 315
339std::ostream& operator<<(std::ostream &stream, LLMD5 context) 316std::ostream& operator<<(std::ostream &stream, LLMD5 context)
340{ 317{
341 char s[33]; 318 char s[33]; /* Flawfinder: ignore */
342 context.hex_digest(s); 319 context.hex_digest(s);
343 stream << s; 320 stream << s;
344 return stream; 321 return stream;
diff --git a/linden/indra/llmath/llmd5.h b/linden/indra/llmath/llmd5.h
index 1874b45..7b185b6 100644
--- a/linden/indra/llmath/llmd5.h
+++ b/linden/indra/llmath/llmd5.h
@@ -90,7 +90,6 @@ public:
90 void update (const uint1 *input, const uint4 input_length); 90 void update (const uint1 *input, const uint4 input_length);
91 void update (std::istream& stream); 91 void update (std::istream& stream);
92 void update (FILE *file); 92 void update (FILE *file);
93 void update (llifstream& stream);
94 void finalize (); 93 void finalize ();
95 94
96// constructors for special circumstances. All these constructors finalize 95// constructors for special circumstances. All these constructors finalize
@@ -98,7 +97,6 @@ public:
98 LLMD5 (const unsigned char *string); // digest string, finalize 97 LLMD5 (const unsigned char *string); // digest string, finalize
99 LLMD5 (std::istream& stream); // digest stream, finalize 98 LLMD5 (std::istream& stream); // digest stream, finalize
100 LLMD5 (FILE *file); // digest file, close, finalize 99 LLMD5 (FILE *file); // digest file, close, finalize
101 LLMD5 (llifstream& stream); // digest stream, close, finalize
102 LLMD5 (const unsigned char *string, const unsigned int number); 100 LLMD5 (const unsigned char *string, const unsigned int number);
103 101
104// methods to acquire finalized result 102// methods to acquire finalized result
diff --git a/linden/indra/llmath/lloctree.h b/linden/indra/llmath/lloctree.h
index 6e068cd..22f298c 100644
--- a/linden/indra/llmath/lloctree.h
+++ b/linden/indra/llmath/lloctree.h
@@ -40,6 +40,11 @@
40#endif 40#endif
41 41
42#define LL_OCTREE_PARANOIA_CHECK 0 42#define LL_OCTREE_PARANOIA_CHECK 0
43#if LL_DARWIN
44#define LL_OCTREE_MAX_CAPACITY 32
45#else
46#define LL_OCTREE_MAX_CAPACITY 256
47#endif
43 48
44template <class T> class LLOctreeState; 49template <class T> class LLOctreeState;
45template <class T> class LLOctreeNode; 50template <class T> class LLOctreeNode;
@@ -107,7 +112,8 @@ public:
107 virtual void removeByAddress(T* data) { getOctState()->removeByAddress(data); } 112 virtual void removeByAddress(T* data) { getOctState()->removeByAddress(data); }
108 virtual bool hasLeafState() const { return getOctState()->isLeaf(); } 113 virtual bool hasLeafState() const { return getOctState()->isLeaf(); }
109 virtual void destroy() { getOctState()->destroy(); } 114 virtual void destroy() { getOctState()->destroy(); }
110 virtual oct_node* getNodeAt(T* data) { return getOctState()->getNodeAt(data); } 115 virtual oct_node* getNodeAt(T* data) { return getNodeAt(data->getPositionGroup(), data->getBinRadius()); }
116 virtual oct_node* getNodeAt(const LLVector3d& pos, const F64& rad) { return getOctState()->getNodeAt(pos, rad); }
111 virtual U8 getOctant() const { return mOctant; } 117 virtual U8 getOctant() const { return mOctant; }
112 virtual void setOctant(U8 octant) { mOctant = octant; } 118 virtual void setOctant(U8 octant) { mOctant = octant; }
113 virtual const oct_state* getOctState() const { return (const oct_state*) BaseType::mState; } 119 virtual const oct_state* getOctState() const { return (const oct_state*) BaseType::mState; }
@@ -136,9 +142,14 @@ public:
136 return ret; 142 return ret;
137 } 143 }
138 144
145 virtual bool isInside(const LLVector3d& pos, const F64& rad) const
146 {
147 return rad <= mSize.mdV[0]*2.0 && isInside(pos);
148 }
149
139 virtual bool isInside(T* data) const 150 virtual bool isInside(T* data) const
140 { 151 {
141 return data->getBinRadius() <= mSize.mdV[0]*2.0 && isInside(data->getPositionGroup()); 152 return isInside(data->getPositionGroup(), data->getBinRadius());
142 } 153 }
143 154
144 virtual bool isInside(const LLVector3d& pos) const 155 virtual bool isInside(const LLVector3d& pos) const
@@ -174,6 +185,11 @@ public:
174 185
175 bool contains(T* xform) 186 bool contains(T* xform)
176 { 187 {
188 return contains(xform->getBinRadius());
189 }
190
191 bool contains(F64 radius)
192 {
177 if (mParent == NULL) 193 if (mParent == NULL)
178 { //root node contains nothing 194 { //root node contains nothing
179 return false; 195 return false;
@@ -181,7 +197,6 @@ public:
181 197
182 F64 size = mSize.mdV[0]; 198 F64 size = mSize.mdV[0];
183 F64 p_size = size * 2.0; 199 F64 p_size = size * 2.0;
184 F64 radius = xform->getBinRadius();
185 200
186 return (radius <= 0.001 && size <= 0.001) || 201 return (radius <= 0.001 && size <= 0.001) ||
187 (radius <= p_size && radius > size); 202 (radius <= p_size && radius > size);
@@ -189,17 +204,10 @@ public:
189 204
190 static void pushCenter(LLVector3d &center, LLVector3d &size, T* data) 205 static void pushCenter(LLVector3d &center, LLVector3d &size, T* data)
191 { 206 {
192 LLVector3 pos(data->getPositionGroup()); 207 LLVector3d pos(data->getPositionGroup());
193 F64 p[] =
194 {
195 (F64) pos.mV[0],
196 (F64) pos.mV[1],
197 (F64) pos.mV[2]
198 };
199
200 for (U32 i = 0; i < 3; i++) 208 for (U32 i = 0; i < 3; i++)
201 { 209 {
202 if (p[i] > center.mdV[i]) 210 if (pos.mdV[i] > center.mdV[i])
203 { 211 {
204 center.mdV[i] += size.mdV[i]; 212 center.mdV[i] += size.mdV[i];
205 } 213 }
@@ -273,11 +281,15 @@ public:
273 oct_node* getOctNode() { return (oct_node*) BaseType::getNode(); } 281 oct_node* getOctNode() { return (oct_node*) BaseType::getNode(); }
274 282
275 virtual oct_node* getNodeAt(T* data) 283 virtual oct_node* getNodeAt(T* data)
284 {
285 return getNodeAt(data->getPositionGroup(), data->getBinRadius());
286 }
287
288 virtual oct_node* getNodeAt(const LLVector3d& pos, const F64& rad)
276 { 289 {
277 const LLVector3d& pos = data->getPositionGroup();
278 LLOctreeNode<T>* node = getOctNode(); 290 LLOctreeNode<T>* node = getOctNode();
279 291
280 if (node->isInside(data)) 292 if (node->isInside(pos, rad))
281 { 293 {
282 //do a quick search by octant 294 //do a quick search by octant
283 U8 octant = node->getOctant(pos.mdV); 295 U8 octant = node->getOctant(pos.mdV);
@@ -287,7 +299,7 @@ public:
287 //at the appropriate octant or is smaller than the object. 299 //at the appropriate octant or is smaller than the object.
288 //by definition, that node is the smallest node that contains 300 //by definition, that node is the smallest node that contains
289 // the data 301 // the data
290 while (keep_going && node->getSize().mdV[0] >= data->getBinRadius()) 302 while (keep_going && node->getSize().mdV[0] >= rad)
291 { 303 {
292 keep_going = FALSE; 304 keep_going = FALSE;
293 for (U32 i = 0; i < node->getChildCount() && !keep_going; i++) 305 for (U32 i = 0; i < node->getChildCount() && !keep_going; i++)
@@ -301,9 +313,9 @@ public:
301 } 313 }
302 } 314 }
303 } 315 }
304 else if (!node->contains(data) && node->getParent()) 316 else if (!node->contains(rad) && node->getParent())
305 { //if we got here, data does not exist in this node 317 { //if we got here, data does not exist in this node
306 return ((LLOctreeNode<T>*) node->getParent())->getNodeAt(data); 318 return ((LLOctreeNode<T>*) node->getParent())->getNodeAt(pos, rad);
307 } 319 }
308 320
309 return node; 321 return node;
@@ -317,22 +329,15 @@ public:
317 return false; 329 return false;
318 } 330 }
319 LLOctreeNode<T>* node = getOctNode(); 331 LLOctreeNode<T>* node = getOctNode();
332 LLOctreeNode<T>* parent = node->getOctParent();
320 333
321 if (data->getBinRadius() <= node->getSize().mdV[0]) 334 //is it here?
322 { 335 if (node->isInside(data->getPositionGroup()))
323 oct_node* dest = getNodeAt(data);
324
325 if (dest != node)
326 {
327 dest->insert(data);
328 return false;
329 }
330 }
331
332 //no kid found, is it even here?
333 if (node->isInside(data))
334 { 336 {
335 if (node->contains(data)) 337 if (getElementCount() < LL_OCTREE_MAX_CAPACITY &&
338 (node->contains(data->getBinRadius()) ||
339 (data->getBinRadius() > node->getSize().mdV[0] &&
340 parent && parent->getElementCount() >= LL_OCTREE_MAX_CAPACITY)))
336 { //it belongs here 341 { //it belongs here
337 if (data == NULL) 342 if (data == NULL)
338 { 343 {
@@ -353,7 +358,19 @@ public:
353 return true; 358 return true;
354 } 359 }
355 else 360 else
356 { 361 {
362 //find a child to give it to
363 oct_node* child = NULL;
364 for (U32 i = 0; i < getChildCount(); i++)
365 {
366 child = getChild(i);
367 if (child->isInside(data->getPositionGroup()))
368 {
369 child->insert(data);
370 return false;
371 }
372 }
373
357 //it's here, but no kids are in the right place, make a new kid 374 //it's here, but no kids are in the right place, make a new kid
358 LLVector3d center(node->getCenter()); 375 LLVector3d center(node->getCenter());
359 LLVector3d size(node->getSize()*0.5); 376 LLVector3d size(node->getSize()*0.5);
@@ -385,7 +402,7 @@ public:
385 402
386 //make the new kid 403 //make the new kid
387 LLOctreeState<T>* newstate = new LLOctreeState<T>(); 404 LLOctreeState<T>* newstate = new LLOctreeState<T>();
388 oct_node* child = new LLOctreeNode<T>(center, size, newstate, node); 405 child = new LLOctreeNode<T>(center, size, newstate, node);
389 addChild(child); 406 addChild(child);
390 407
391 child->insert(data); 408 child->insert(data);
@@ -393,8 +410,15 @@ public:
393 } 410 }
394 else 411 else
395 { 412 {
396 //it's not in here, give it to the parent 413 //it's not in here, give it to the root
397 node->getOctParent()->insert(data); 414 LLOctreeNode<T>* parent = node->getOctParent();
415 while (parent)
416 {
417 node = parent;
418 parent = node->getOctParent();
419 }
420
421 node->insert(data);
398 } 422 }
399 423
400 return false; 424 return false;
diff --git a/linden/indra/llmath/llrand.cpp b/linden/indra/llmath/llrand.cpp
index c0f03d2..ae52010 100644
--- a/linden/indra/llmath/llrand.cpp
+++ b/linden/indra/llmath/llrand.cpp
@@ -140,7 +140,14 @@ F32 ll_frand(F32 val)
140{ 140{
141 // The clamping rules are described above. 141 // The clamping rules are described above.
142 F32 rv = ll_internal_random_float() * val; 142 F32 rv = ll_internal_random_float() * val;
143 if(rv >= val) return 0.0f; 143 if(val > 0)
144 {
145 if(rv >= val) return 0.0f;
146 }
147 else
148 {
149 if(rv <= val) return 0.0f;
150 }
144 return rv; 151 return rv;
145} 152}
146 153
@@ -153,6 +160,13 @@ F64 ll_drand(F64 val)
153{ 160{
154 // The clamping rules are described above. 161 // The clamping rules are described above.
155 F64 rv = ll_internal_random_double() * val; 162 F64 rv = ll_internal_random_double() * val;
156 if(rv >= val) return 0.0; 163 if(val > 0)
164 {
165 if(rv >= val) return 0.0;
166 }
167 else
168 {
169 if(rv <= val) return 0.0;
170 }
157 return rv; 171 return rv;
158} 172}
diff --git a/linden/indra/llmath/llrand.h b/linden/indra/llmath/llrand.h
index 47b5651..1bf055e 100644
--- a/linden/indra/llmath/llrand.h
+++ b/linden/indra/llmath/llrand.h
@@ -63,7 +63,7 @@
63S32 ll_rand(); 63S32 ll_rand();
64 64
65/** 65/**
66 *@brief Generate a float from [0, val). 66 *@brief Generate a float from [0, val) or (val, 0].
67 */ 67 */
68S32 ll_rand(S32 val); 68S32 ll_rand(S32 val);
69 69
@@ -73,7 +73,7 @@ S32 ll_rand(S32 val);
73F32 ll_frand(); 73F32 ll_frand();
74 74
75/** 75/**
76 *@brief Generate a float from [0, val). 76 *@brief Generate a float from [0, val) or (val, 0].
77 */ 77 */
78F32 ll_frand(F32 val); 78F32 ll_frand(F32 val);
79 79
@@ -83,7 +83,7 @@ F32 ll_frand(F32 val);
83F64 ll_drand(); 83F64 ll_drand();
84 84
85/** 85/**
86 *@brief Generate a double from [0, val). 86 *@brief Generate a double from [0, val) or (val, 0].
87 */ 87 */
88F64 ll_drand(F64 val); 88F64 ll_drand(F64 val);
89 89
diff --git a/linden/indra/llmath/lltreenode.h b/linden/indra/llmath/lltreenode.h
index 78ff759..ba3c867 100644
--- a/linden/indra/llmath/lltreenode.h
+++ b/linden/indra/llmath/lltreenode.h
@@ -41,7 +41,6 @@ class LLTreeState
41public: 41public:
42 LLTreeState(LLTreeNode<T>* node) { setNode(node); } 42 LLTreeState(LLTreeNode<T>* node) { setNode(node); }
43 virtual ~LLTreeState() { }; 43 virtual ~LLTreeState() { };
44
45 virtual bool insert(T* data) = 0; 44 virtual bool insert(T* data) = 0;
46 virtual bool remove(T* data) = 0; 45 virtual bool remove(T* data) = 0;
47 virtual void setNode(LLTreeNode<T>* node); 46 virtual void setNode(LLTreeNode<T>* node);
@@ -54,7 +53,7 @@ private:
54}; 53};
55 54
56template <class T> 55template <class T>
57class LLTreeListener 56class LLTreeListener: public LLRefCount
58{ 57{
59public: 58public:
60 virtual ~LLTreeListener() { }; 59 virtual ~LLTreeListener() { };
@@ -94,7 +93,7 @@ protected:
94 93
95 LLTreeState<T>* mState; 94 LLTreeState<T>* mState;
96public: 95public:
97 std::vector<LLTreeListener<T>*> mListeners; 96 std::vector<LLPointer<LLTreeListener<T> > > mListeners;
98}; 97};
99 98
100template <class T> 99template <class T>
diff --git a/linden/indra/llmath/lluuid.cpp b/linden/indra/llmath/lluuid.cpp
index 3fb31a6..b943fd9 100644
--- a/linden/indra/llmath/lluuid.cpp
+++ b/linden/indra/llmath/lluuid.cpp
@@ -170,15 +170,15 @@ void LLUUID::toString(char *out) const
170 170
171void LLUUID::toCompressedString(char *out) const 171void LLUUID::toCompressedString(char *out) const
172{ 172{
173 memcpy(out, mData, UUID_BYTES); 173 memcpy(out, mData, UUID_BYTES); /* Flawfinder: ignore */
174 out[UUID_BYTES] = '\0'; 174 out[UUID_BYTES] = '\0';
175} 175}
176 176
177LLString LLUUID::getString() const 177std::string LLUUID::asString() const
178{ 178{
179 char str[UUID_STR_SIZE]; 179 char str[UUID_STR_SIZE]; /* Flawfinder: ignore */
180 toString(str); 180 toString(str);
181 return LLString(str); 181 return std::string(str);
182} 182}
183 183
184BOOL LLUUID::set(const std::string& in_string, BOOL emit) 184BOOL LLUUID::set(const std::string& in_string, BOOL emit)
@@ -203,11 +203,11 @@ BOOL LLUUID::set(const char *in_string, BOOL emit)
203 return TRUE; 203 return TRUE;
204 } 204 }
205 205
206 if (strlen(in_string) != (UUID_STR_LENGTH - 1)) 206 if (strlen(in_string) != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */
207 { 207 {
208 // I'm a moron. First implementation didn't have the right UUID format. 208 // I'm a moron. First implementation didn't have the right UUID format.
209 // Shouldn't see any of these any more 209 // Shouldn't see any of these any more
210 if (strlen(in_string) == (UUID_STR_LENGTH - 2)) 210 if (strlen(in_string) == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */
211 { 211 {
212 if(emit) 212 if(emit)
213 { 213 {
@@ -307,10 +307,10 @@ BOOL LLUUID::validate(const char *in_string)
307 { 307 {
308 return FALSE; 308 return FALSE;
309 } 309 }
310 if (strlen(in_string) != (UUID_STR_LENGTH - 1)) 310 if (strlen(in_string) != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */
311 { 311 {
312 // I'm a moron. First implementation didn't have the right UUID format. 312 // I'm a moron. First implementation didn't have the right UUID format.
313 if (strlen(in_string) == (UUID_STR_LENGTH - 2)) 313 if (strlen(in_string) == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */
314 { 314 {
315 broken_format = TRUE; 315 broken_format = TRUE;
316 } 316 }
@@ -414,7 +414,7 @@ std::ostream& operator<<(std::ostream& s, const LLUUID &uuid)
414std::istream& operator>>(std::istream &s, LLUUID &uuid) 414std::istream& operator>>(std::istream &s, LLUUID &uuid)
415{ 415{
416 U32 i; 416 U32 i;
417 char uuid_str[UUID_STR_LENGTH]; 417 char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */
418 for (i = 0; i < UUID_STR_LENGTH-1; i++) 418 for (i = 0; i < UUID_STR_LENGTH-1; i++)
419 { 419 {
420 s >> uuid_str[i]; 420 s >> uuid_str[i];
@@ -480,7 +480,7 @@ S32 LLUUID::getNodeID(unsigned char * node_id)
480 Ncb.ncb_command = NCBASTAT; 480 Ncb.ncb_command = NCBASTAT;
481 Ncb.ncb_lana_num = lenum.lana[i]; 481 Ncb.ncb_lana_num = lenum.lana[i];
482 482
483 strcpy( (char *)Ncb.ncb_callname, "* " ); 483 strcpy( (char *)Ncb.ncb_callname, "* " ); /* Flawfinder: ignore */
484 Ncb.ncb_buffer = (unsigned char *)&Adapter; 484 Ncb.ncb_buffer = (unsigned char *)&Adapter;
485 Ncb.ncb_length = sizeof(Adapter); 485 Ncb.ncb_length = sizeof(Adapter);
486 486
@@ -497,7 +497,7 @@ S32 LLUUID::getNodeID(unsigned char * node_id)
497// Adapter.adapt.adapter_address[3], 497// Adapter.adapt.adapter_address[3],
498// Adapter.adapt.adapter_address[4], 498// Adapter.adapt.adapter_address[4],
499// Adapter.adapt.adapter_address[5] ); 499// Adapter.adapt.adapter_address[5] );
500 memcpy(node_id,Adapter.adapt.adapter_address,6); 500 memcpy(node_id,Adapter.adapt.adapter_address,6); /* Flawfinder: ignore */
501 retval = 1; 501 retval = 1;
502 502
503 } 503 }
@@ -652,7 +652,7 @@ S32 LLUUID::getNodeID(unsigned char *node_id)
652 n = ifc.ifc_len; 652 n = ifc.ifc_len;
653 for (i = 0; i < n; i+= ifreq_size(*ifr) ) { 653 for (i = 0; i < n; i+= ifreq_size(*ifr) ) {
654 ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i); 654 ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i);
655 strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ); 655 strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ); /* Flawfinder: ignore */
656#ifdef SIOCGIFHWADDR 656#ifdef SIOCGIFHWADDR
657 if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0) 657 if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0)
658 continue; 658 continue;
@@ -674,7 +674,7 @@ S32 LLUUID::getNodeID(unsigned char *node_id)
674 if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5]) 674 if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
675 continue; 675 continue;
676 if (node_id) { 676 if (node_id) {
677 memcpy(node_id, a, 6); 677 memcpy(node_id, a, 6); /* Flawfinder: ignore */
678 close(sd); 678 close(sd);
679 return 1; 679 return 1;
680 } 680 }
@@ -783,7 +783,7 @@ void LLUUID::generate()
783 // Create a UUID. 783 // Create a UUID.
784 uuid_time_t timestamp; 784 uuid_time_t timestamp;
785 785
786 static unsigned char node_id[6]; 786 static unsigned char node_id[6]; /* Flawfinder: ignore */
787 static int has_init = 0; 787 static int has_init = 0;
788 788
789 // Create a UUID. 789 // Create a UUID.
@@ -827,7 +827,7 @@ void LLUUID::generate()
827 if (clock_seq == 0) clock_seq++; 827 if (clock_seq == 0) clock_seq++;
828 } 828 }
829 829
830 memcpy(mData+10, node_id, 6); 830 memcpy(mData+10, node_id, 6); /* Flawfinder: ignore */
831 U32 tmp; 831 U32 tmp;
832 tmp = timestamp.low; 832 tmp = timestamp.low;
833 mData[3] = (unsigned char) tmp; 833 mData[3] = (unsigned char) tmp;
@@ -865,7 +865,7 @@ void LLUUID::generate()
865 865
866U32 LLUUID::getRandomSeed() 866U32 LLUUID::getRandomSeed()
867{ 867{
868 static unsigned char seed[16]; 868 static unsigned char seed[16]; /* Flawfinder: ignore */
869 869
870 getNodeID(&seed[0]); 870 getNodeID(&seed[0]);
871 seed[6]='\0'; 871 seed[6]='\0';
diff --git a/linden/indra/llmath/lluuid.h b/linden/indra/llmath/lluuid.h
index b8288eb..aeda734 100644
--- a/linden/indra/llmath/lluuid.h
+++ b/linden/indra/llmath/lluuid.h
@@ -29,8 +29,7 @@
29 29
30#include <iostream> 30#include <iostream>
31#include <set> 31#include <set>
32 32#include "stdtypes.h"
33#include "llstring.h"
34 33
35const S32 UUID_BYTES = 16; 34const S32 UUID_BYTES = 16;
36const S32 UUID_WORDS = 4; 35const S32 UUID_WORDS = 4;
@@ -103,7 +102,9 @@ public:
103 102
104 void toString(char *out) const; // Does not allocate memory, needs 36 characters (including \0) 103 void toString(char *out) const; // Does not allocate memory, needs 36 characters (including \0)
105 void toCompressedString(char *out) const; // Does not allocate memory, needs 17 characters (including \0) 104 void toCompressedString(char *out) const; // Does not allocate memory, needs 17 characters (including \0)
106 LLString getString() const; 105
106 std::string asString() const;
107
107 U16 getCRC16() const; 108 U16 getCRC16() const;
108 U32 getCRC32() const; 109 U32 getCRC32() const;
109 110
diff --git a/linden/indra/llmath/llvolume.cpp b/linden/indra/llmath/llvolume.cpp
index c527e85..e42413a 100644
--- a/linden/indra/llmath/llvolume.cpp
+++ b/linden/indra/llmath/llvolume.cpp
@@ -724,11 +724,11 @@ BOOL LLProfile::generate(BOOL path_open,F32 detail, S32 split)
724BOOL LLProfileParams::importFile(FILE *fp) 724BOOL LLProfileParams::importFile(FILE *fp)
725{ 725{
726 const S32 BUFSIZE = 16384; 726 const S32 BUFSIZE = 16384;
727 char buffer[BUFSIZE]; 727 char buffer[BUFSIZE]; /* Flawfinder: ignore */
728 // *NOTE: changing the size or type of these buffers will require 728 // *NOTE: changing the size or type of these buffers will require
729 // changing the sscanf below. 729 // changing the sscanf below.
730 char keyword[256]; 730 char keyword[256]; /* Flawfinder: ignore */
731 char valuestr[256]; 731 char valuestr[256]; /* Flawfinder: ignore */
732 keyword[0] = 0; 732 keyword[0] = 0;
733 valuestr[0] = 0; 733 valuestr[0] = 0;
734 F32 tempF32; 734 F32 tempF32;
@@ -737,7 +737,10 @@ BOOL LLProfileParams::importFile(FILE *fp)
737 while (!feof(fp)) 737 while (!feof(fp))
738 { 738 {
739 fgets(buffer, BUFSIZE, fp); 739 fgets(buffer, BUFSIZE, fp);
740 sscanf(buffer, " %255s %255s", keyword, valuestr); 740 sscanf( /* Flawfinder: ignore */
741 buffer,
742 " %255s %255s",
743 keyword, valuestr);
741 if (!keyword) 744 if (!keyword)
742 { 745 {
743 continue; 746 continue;
@@ -796,11 +799,11 @@ BOOL LLProfileParams::exportFile(FILE *fp) const
796BOOL LLProfileParams::importLegacyStream(std::istream& input_stream) 799BOOL LLProfileParams::importLegacyStream(std::istream& input_stream)
797{ 800{
798 const S32 BUFSIZE = 16384; 801 const S32 BUFSIZE = 16384;
799 char buffer[BUFSIZE]; 802 char buffer[BUFSIZE]; /* Flawfinder: ignore */
800 // *NOTE: changing the size or type of these buffers will require 803 // *NOTE: changing the size or type of these buffers will require
801 // changing the sscanf below. 804 // changing the sscanf below.
802 char keyword[256]; 805 char keyword[256]; /* Flawfinder: ignore */
803 char valuestr[256]; 806 char valuestr[256]; /* Flawfinder: ignore */
804 keyword[0] = 0; 807 keyword[0] = 0;
805 valuestr[0] = 0; 808 valuestr[0] = 0;
806 F32 tempF32; 809 F32 tempF32;
@@ -809,7 +812,11 @@ BOOL LLProfileParams::importLegacyStream(std::istream& input_stream)
809 while (input_stream.good()) 812 while (input_stream.good())
810 { 813 {
811 input_stream.getline(buffer, BUFSIZE); 814 input_stream.getline(buffer, BUFSIZE);
812 sscanf(buffer, " %255s %255s", keyword, valuestr); 815 sscanf( /* Flawfinder: ignore */
816 buffer,
817 " %255s %255s",
818 keyword,
819 valuestr);
813 if (!keyword) 820 if (!keyword)
814 { 821 {
815 continue; 822 continue;
@@ -1218,11 +1225,11 @@ BOOL LLDynamicPath::generate(F32 detail, S32 split)
1218BOOL LLPathParams::importFile(FILE *fp) 1225BOOL LLPathParams::importFile(FILE *fp)
1219{ 1226{
1220 const S32 BUFSIZE = 16384; 1227 const S32 BUFSIZE = 16384;
1221 char buffer[BUFSIZE]; 1228 char buffer[BUFSIZE]; /* Flawfinder: ignore */
1222 // *NOTE: changing the size or type of these buffers will require 1229 // *NOTE: changing the size or type of these buffers will require
1223 // changing the sscanf below. 1230 // changing the sscanf below.
1224 char keyword[256]; 1231 char keyword[256]; /* Flawfinder: ignore */
1225 char valuestr[256]; 1232 char valuestr[256]; /* Flawfinder: ignore */
1226 keyword[0] = 0; 1233 keyword[0] = 0;
1227 valuestr[0] = 0; 1234 valuestr[0] = 0;
1228 1235
@@ -1233,7 +1240,10 @@ BOOL LLPathParams::importFile(FILE *fp)
1233 while (!feof(fp)) 1240 while (!feof(fp))
1234 { 1241 {
1235 fgets(buffer, BUFSIZE, fp); 1242 fgets(buffer, BUFSIZE, fp);
1236 sscanf(buffer, " %255s %255s", keyword, valuestr); 1243 sscanf( /* Flawfinder: ignore */
1244 buffer,
1245 " %255s %255s",
1246 keyword, valuestr);
1237 if (!keyword) 1247 if (!keyword)
1238 { 1248 {
1239 continue; 1249 continue;
@@ -1359,11 +1369,11 @@ BOOL LLPathParams::exportFile(FILE *fp) const
1359BOOL LLPathParams::importLegacyStream(std::istream& input_stream) 1369BOOL LLPathParams::importLegacyStream(std::istream& input_stream)
1360{ 1370{
1361 const S32 BUFSIZE = 16384; 1371 const S32 BUFSIZE = 16384;
1362 char buffer[BUFSIZE]; 1372 char buffer[BUFSIZE]; /* Flawfinder: ignore */
1363 // *NOTE: changing the size or type of these buffers will require 1373 // *NOTE: changing the size or type of these buffers will require
1364 // changing the sscanf below. 1374 // changing the sscanf below.
1365 char keyword[256]; 1375 char keyword[256]; /* Flawfinder: ignore */
1366 char valuestr[256]; 1376 char valuestr[256]; /* Flawfinder: ignore */
1367 keyword[0] = 0; 1377 keyword[0] = 0;
1368 valuestr[0] = 0; 1378 valuestr[0] = 0;
1369 1379
@@ -1374,7 +1384,10 @@ BOOL LLPathParams::importLegacyStream(std::istream& input_stream)
1374 while (input_stream.good()) 1384 while (input_stream.good())
1375 { 1385 {
1376 input_stream.getline(buffer, BUFSIZE); 1386 input_stream.getline(buffer, BUFSIZE);
1377 sscanf(buffer, " %255s %255s", keyword, valuestr); 1387 sscanf( /* Flawfinder: ignore */
1388 buffer,
1389 " %255s %255s",
1390 keyword, valuestr);
1378 if (!keyword) 1391 if (!keyword)
1379 { 1392 {
1380 continue; 1393 continue;
@@ -1771,9 +1784,6 @@ void LLVolume::createVolumeFaces()
1771 mVolumeFaces[i].create(); 1784 mVolumeFaces[i].create();
1772 } 1785 }
1773 } 1786 }
1774
1775 mBounds[1] = LLVector3(0,0,0);
1776 mBounds[0] = LLVector3(512,512,512);
1777} 1787}
1778 1788
1779 1789
@@ -1818,21 +1828,28 @@ void LLVolumeParams::copyParams(const LLVolumeParams &params)
1818 mPathParams.copyParams(params.mPathParams); 1828 mPathParams.copyParams(params.mPathParams);
1819} 1829}
1820 1830
1831// Less restricitve approx 0 for volumes
1832const F32 APPROXIMATELY_ZERO = 0.001f;
1833bool approx_zero( F32 f, F32 tolerance = APPROXIMATELY_ZERO)
1834{
1835 return (f >= -tolerance) && (f <= tolerance);
1836}
1837
1821// return true if in range (or nearly so) 1838// return true if in range (or nearly so)
1822static bool limit_range(F32& v, F32 min, F32 max) 1839static bool limit_range(F32& v, F32 min, F32 max, F32 tolerance = APPROXIMATELY_ZERO)
1823{ 1840{
1824 F32 min_delta = v - min; 1841 F32 min_delta = v - min;
1825 if (min_delta < 0.f) 1842 if (min_delta < 0.f)
1826 { 1843 {
1827 v = min; 1844 v = min;
1828 if (!is_approx_zero(min_delta)) 1845 if (!approx_zero(min_delta, tolerance))
1829 return false; 1846 return false;
1830 } 1847 }
1831 F32 max_delta = max - v; 1848 F32 max_delta = max - v;
1832 if (max_delta < 0.f) 1849 if (max_delta < 0.f)
1833 { 1850 {
1834 v = max; 1851 v = max;
1835 if (!is_approx_zero(max_delta)) 1852 if (!approx_zero(max_delta, tolerance))
1836 return false; 1853 return false;
1837 } 1854 }
1838 return true; 1855 return true;
@@ -1847,9 +1864,10 @@ bool LLVolumeParams::setBeginAndEndS(const F32 b, const F32 e)
1847 valid &= limit_range(begin, 0.f, 1.f - MIN_CUT_DELTA); 1864 valid &= limit_range(begin, 0.f, 1.f - MIN_CUT_DELTA);
1848 1865
1849 F32 end = e; 1866 F32 end = e;
1867 if (end >= .0149f && end < MIN_CUT_DELTA) end = MIN_CUT_DELTA; // eliminate warning for common rounding error
1850 valid &= limit_range(end, MIN_CUT_DELTA, 1.f); 1868 valid &= limit_range(end, MIN_CUT_DELTA, 1.f);
1851 1869
1852 valid &= limit_range(begin, 0.f, end - MIN_CUT_DELTA); 1870 valid &= limit_range(begin, 0.f, end - MIN_CUT_DELTA, .01f);
1853 1871
1854 // Now set them. 1872 // Now set them.
1855 mProfileParams.setBegin(begin); 1873 mProfileParams.setBegin(begin);
@@ -1869,7 +1887,7 @@ bool LLVolumeParams::setBeginAndEndT(const F32 b, const F32 e)
1869 F32 end = e; 1887 F32 end = e;
1870 valid &= limit_range(end, MIN_CUT_DELTA, 1.f); 1888 valid &= limit_range(end, MIN_CUT_DELTA, 1.f);
1871 1889
1872 valid &= limit_range(begin, 0.f, end - MIN_CUT_DELTA); 1890 valid &= limit_range(begin, 0.f, end - MIN_CUT_DELTA, .01f);
1873 1891
1874 // Now set them. 1892 // Now set them.
1875 mPathParams.setBegin(begin); 1893 mPathParams.setBegin(begin);
@@ -2026,7 +2044,7 @@ bool LLVolumeParams::setRadiusOffset(const F32 offset)
2026 { 2044 {
2027 radius_offset = max_radius_mag; 2045 radius_offset = max_radius_mag;
2028 } 2046 }
2029 valid = is_approx_zero(delta); 2047 valid = approx_zero(delta, .1f);
2030 } 2048 }
2031 2049
2032 mPathParams.setRadiusOffset(radius_offset); 2050 mPathParams.setRadiusOffset(radius_offset);
@@ -2060,7 +2078,7 @@ bool LLVolumeParams::setSkew(const F32 skew_value)
2060 { 2078 {
2061 skew = min_skew_mag; 2079 skew = min_skew_mag;
2062 } 2080 }
2063 valid = is_approx_zero(delta); 2081 valid = approx_zero(delta, .01f);
2064 } 2082 }
2065 2083
2066 mPathParams.setSkew(skew); 2084 mPathParams.setSkew(skew);
@@ -2185,7 +2203,7 @@ S32 *LLVolume::getTriangleIndices(U32 &num_indices) const
2185 size_s_out = getProfile().getTotalOut(); 2203 size_s_out = getProfile().getTotalOut();
2186 size_t = getPath().mPath.size(); 2204 size_t = getPath().mPath.size();
2187 2205
2188 if (open) 2206 if (open) /* Flawfinder: ignore */
2189 { 2207 {
2190 if (hollow) 2208 if (hollow)
2191 { 2209 {
@@ -2807,7 +2825,7 @@ noindices:
2807 return NULL; 2825 return NULL;
2808 } 2826 }
2809 num_indices = count; 2827 num_indices = count;
2810 memcpy(indices, index, count * sizeof(S32)); 2828 memcpy(indices, index, count * sizeof(S32)); /* Flawfinder: ignore */
2811 return indices; 2829 return indices;
2812} 2830}
2813 2831
@@ -2986,10 +3004,15 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
2986 S32 v2 = face.mIndices[j*3+((k+1)%3)]; 3004 S32 v2 = face.mIndices[j*3+((k+1)%3)];
2987 3005
2988 vertices.push_back(face.mVertices[v1].mPosition*mat); 3006 vertices.push_back(face.mVertices[v1].mPosition*mat);
2989 normals.push_back(face.mVertices[v1].mNormal*norm_mat); 3007 LLVector3 norm1 = face.mVertices[v1].mNormal * norm_mat;
3008 norm1.normVec();
3009 normals.push_back(norm1);
2990 3010
2991 vertices.push_back(face.mVertices[v2].mPosition*mat); 3011 vertices.push_back(face.mVertices[v2].mPosition*mat);
2992 normals.push_back(face.mVertices[v2].mNormal*norm_mat); 3012 LLVector3 norm2 = face.mVertices[v2].mNormal * norm_mat;
3013 norm2.normVec();
3014 normals.push_back(norm2);
3015
2993 segments.push_back(vertices.size()); 3016 segments.push_back(vertices.size());
2994 } 3017 }
2995 } 3018 }
@@ -3310,7 +3333,7 @@ BOOL LLVolume::cleanupTriangleData( const S32 num_input_vertices,
3310 3333
3311 *output_triangles = new S32[cur_tri*3]; 3334 *output_triangles = new S32[cur_tri*3];
3312 num_output_triangles = cur_tri; 3335 num_output_triangles = cur_tri;
3313 memcpy(*output_triangles, sorted_tris, 3*cur_tri*sizeof(S32)); 3336 memcpy(*output_triangles, sorted_tris, 3*cur_tri*sizeof(S32)); /* Flawfinder: ignore */
3314 3337
3315 /* 3338 /*
3316 llinfos << "Out vertices: " << num_output_vertices << llendl; 3339 llinfos << "Out vertices: " << num_output_vertices << llendl;
@@ -3347,16 +3370,16 @@ BOOL LLVolumeParams::importFile(FILE *fp)
3347{ 3370{
3348 //llinfos << "importing volume" << llendl; 3371 //llinfos << "importing volume" << llendl;
3349 const S32 BUFSIZE = 16384; 3372 const S32 BUFSIZE = 16384;
3350 char buffer[BUFSIZE]; 3373 char buffer[BUFSIZE]; /* Flawfinder: ignore */
3351 // *NOTE: changing the size or type of this buffer will require 3374 // *NOTE: changing the size or type of this buffer will require
3352 // changing the sscanf below. 3375 // changing the sscanf below.
3353 char keyword[256]; 3376 char keyword[256]; /* Flawfinder: ignore */
3354 keyword[0] = 0; 3377 keyword[0] = 0;
3355 3378
3356 while (!feof(fp)) 3379 while (!feof(fp))
3357 { 3380 {
3358 fgets(buffer, BUFSIZE, fp); 3381 fgets(buffer, BUFSIZE, fp);
3359 sscanf(buffer, " %255s", keyword); 3382 sscanf(buffer, " %255s", keyword); /* Flawfinder: ignore */
3360 if (!keyword) 3383 if (!keyword)
3361 { 3384 {
3362 continue; 3385 continue;
@@ -3403,8 +3426,8 @@ BOOL LLVolumeParams::importLegacyStream(std::istream& input_stream)
3403 const S32 BUFSIZE = 16384; 3426 const S32 BUFSIZE = 16384;
3404 // *NOTE: changing the size or type of this buffer will require 3427 // *NOTE: changing the size or type of this buffer will require
3405 // changing the sscanf below. 3428 // changing the sscanf below.
3406 char buffer[BUFSIZE]; 3429 char buffer[BUFSIZE]; /* Flawfinder: ignore */
3407 char keyword[256]; 3430 char keyword[256]; /* Flawfinder: ignore */
3408 keyword[0] = 0; 3431 keyword[0] = 0;
3409 3432
3410 while (input_stream.good()) 3433 while (input_stream.good())
@@ -3753,6 +3776,9 @@ BOOL LLVolumeFace::createUnCutCubeCap()
3753 num_vertices = (grid_size+1)*(grid_size+1); 3776 num_vertices = (grid_size+1)*(grid_size+1);
3754 num_indices = quad_count * 4; 3777 num_indices = quad_count * 4;
3755 3778
3779 LLVector3& min = mExtents[0];
3780 LLVector3& max = mExtents[1];
3781
3756 S32 offset = 0; 3782 S32 offset = 0;
3757 if (mTypeMask & TOP_MASK) 3783 if (mTypeMask & TOP_MASK)
3758 offset = (max_t-1) * max_s; 3784 offset = (max_t-1) * max_s;
@@ -3792,32 +3818,6 @@ BOOL LLVolumeFace::createUnCutCubeCap()
3792 } 3818 }
3793 3819
3794 S32 vtop = mVertices.size(); 3820 S32 vtop = mVertices.size();
3795// S32 itop = mIndices.size();
3796/// vector_append(mVertices,4);
3797// vector_append(mIndices,4);
3798// LLVector3 new_pt = lerp(pt1, pt2, t_fraction);
3799#if 0
3800 for(int t=0;t<4;t++){
3801 VertexData vd;
3802 vd.mPosition = corners[t].mPosition;
3803 vd.mNormal =
3804 ((corners[(t+1)%4].mPosition-corners[t].mPosition)%
3805 (corners[(t+2)%4].mPosition-corners[(t+1)%4].mPosition));
3806 vd.mNormal.normVec();
3807
3808 if (mTypeMask & TOP_MASK)
3809 vd.mNormal *= -1.0f;
3810 vd.mBinormal = vd.mNormal;
3811 vd.mTexCoord = corners[t].mTexCoord;
3812 mVertices.push_back(vd);
3813 }
3814 int idxs[] = {0,1,2,2,3,0};
3815 if (mTypeMask & TOP_MASK){
3816 for(int i=0;i<6;i++)mIndices.push_back(vtop+idxs[i]);
3817 }else{
3818 for(int i=5;i>=0;i--)mIndices.push_back(vtop+idxs[i]);
3819 }
3820#else
3821 for(int gx = 0;gx<grid_size+1;gx++){ 3821 for(int gx = 0;gx<grid_size+1;gx++){
3822 for(int gy = 0;gy<grid_size+1;gy++){ 3822 for(int gy = 0;gy<grid_size+1;gy++){
3823 VertexData newVert; 3823 VertexData newVert;
@@ -3829,8 +3829,20 @@ BOOL LLVolumeFace::createUnCutCubeCap()
3829 (F32)gx/(F32)grid_size, 3829 (F32)gx/(F32)grid_size,
3830 (F32)gy/(F32)grid_size); 3830 (F32)gy/(F32)grid_size);
3831 mVertices.push_back(newVert); 3831 mVertices.push_back(newVert);
3832
3833 if (gx == 0 && gy == 0)
3834 {
3835 min = max = newVert.mPosition;
3836 }
3837 else
3838 {
3839 update_min_max(min,max,newVert.mPosition);
3840 }
3832 } 3841 }
3833 } 3842 }
3843
3844 mCenter = (min + max) * 0.5f;
3845
3834 int idxs[] = {0,1,(grid_size+1)+1,(grid_size+1)+1,(grid_size+1),0}; 3846 int idxs[] = {0,1,(grid_size+1)+1,(grid_size+1)+1,(grid_size+1),0};
3835 for(int gx = 0;gx<grid_size;gx++){ 3847 for(int gx = 0;gx<grid_size;gx++){
3836 for(int gy = 0;gy<grid_size;gy++){ 3848 for(int gy = 0;gy<grid_size;gy++){
@@ -3841,7 +3853,7 @@ BOOL LLVolumeFace::createUnCutCubeCap()
3841 } 3853 }
3842 } 3854 }
3843 } 3855 }
3844#endif 3856
3845 return TRUE; 3857 return TRUE;
3846} 3858}
3847 3859
@@ -3888,12 +3900,15 @@ BOOL LLVolumeFace::createCap()
3888 // Figure out the normal, assume all caps are flat faces. 3900 // Figure out the normal, assume all caps are flat faces.
3889 // Cross product to get normals. 3901 // Cross product to get normals.
3890 3902
3891 LLVector2 cuv = LLVector2(0,0); 3903 LLVector2 cuv;
3892 3904 LLVector2 min_uv, max_uv;
3905
3906 LLVector3& min = mExtents[0];
3907 LLVector3& max = mExtents[1];
3908
3893 // Copy the vertices into the array 3909 // Copy the vertices into the array
3894 for (i = 0; i < num_vertices; i++) 3910 for (i = 0; i < num_vertices; i++)
3895 { 3911 {
3896
3897 if (mTypeMask & TOP_MASK) 3912 if (mTypeMask & TOP_MASK)
3898 { 3913 {
3899 mVertices[i].mTexCoord.mV[0] = profile[i].mV[0]+0.5f; 3914 mVertices[i].mTexCoord.mV[0] = profile[i].mV[0]+0.5f;
@@ -3906,17 +3921,22 @@ BOOL LLVolumeFace::createCap()
3906 mVertices[i].mTexCoord.mV[1] = 0.5f - profile[i].mV[1]; 3921 mVertices[i].mTexCoord.mV[1] = 0.5f - profile[i].mV[1];
3907 } 3922 }
3908 3923
3909 if(i){ 3924 mVertices[i].mPosition = mesh[i + offset].mPos;
3910 //Dont include the first point of the profile in the average 3925
3911 cuv += mVertices[i].mTexCoord; 3926 if (i == 0)
3912 mCenter += mVertices[i].mPosition = mesh[i + offset].mPos; 3927 {
3928 min = max = mVertices[i].mPosition;
3929 min_uv = max_uv = mVertices[i].mTexCoord;
3930 }
3931 else
3932 {
3933 update_min_max(min,max, mVertices[i].mPosition);
3934 update_min_max(min_uv, max_uv, mVertices[i].mTexCoord);
3913 } 3935 }
3914 else mVertices[i].mPosition = mesh[i + offset].mPos;
3915 //mVertices[i].mNormal = normal;
3916 } 3936 }
3917 3937
3918 mCenter /= (F32)(num_vertices-1); 3938 mCenter = (min+max)*0.5f;
3919 cuv /= (F32)(num_vertices-1); 3939 cuv = (min_uv + max_uv)*0.5f;
3920 3940
3921 LLVector3 binormal = calc_binormal_from_triangle( 3941 LLVector3 binormal = calc_binormal_from_triangle(
3922 mCenter, cuv, 3942 mCenter, cuv,
@@ -4221,13 +4241,11 @@ BOOL LLVolumeFace::createCap()
4221 return TRUE; 4241 return TRUE;
4222} 4242}
4223 4243
4224
4225BOOL LLVolumeFace::createSide() 4244BOOL LLVolumeFace::createSide()
4226{ 4245{
4227 BOOL flat = mTypeMask & FLAT_MASK; 4246 BOOL flat = mTypeMask & FLAT_MASK;
4228 S32 num_vertices, num_indices; 4247 S32 num_vertices, num_indices;
4229 4248
4230
4231 const std::vector<LLVolume::Point>& mesh = mVolumep->getMesh(); 4249 const std::vector<LLVolume::Point>& mesh = mVolumep->getMesh();
4232 const std::vector<LLVector3>& profile = mVolumep->getProfile().mProfile; 4250 const std::vector<LLVector3>& profile = mVolumep->getProfile().mProfile;
4233 const std::vector<LLPath::PathPt>& path_data = mVolumep->getPath().mPath; 4251 const std::vector<LLPath::PathPt>& path_data = mVolumep->getPath().mPath;
@@ -4243,6 +4261,9 @@ BOOL LLVolumeFace::createSide()
4243 vector_append(mIndices,num_indices); 4261 vector_append(mIndices,num_indices);
4244 vector_append(mEdge, num_indices); 4262 vector_append(mEdge, num_indices);
4245 4263
4264 LLVector3& face_min = mExtents[0];
4265 LLVector3& face_max = mExtents[1];
4266
4246 mCenter.clearVec(); 4267 mCenter.clearVec();
4247 4268
4248 S32 begin_stex = llfloor( profile[mBeginS].mV[2] ); 4269 S32 begin_stex = llfloor( profile[mBeginS].mV[2] );
@@ -4290,17 +4311,26 @@ BOOL LLVolumeFace::createSide()
4290 i = mBeginS + s + max_s*t; 4311 i = mBeginS + s + max_s*t;
4291 } 4312 }
4292 4313
4293 mCenter += mVertices[cur_vertex].mPosition = mesh[i].mPos; 4314 mVertices[cur_vertex].mPosition = mesh[i].mPos;
4294 mVertices[cur_vertex].mTexCoord = LLVector2(ss,tt); 4315 mVertices[cur_vertex].mTexCoord = LLVector2(ss,tt);
4295 4316
4296 mVertices[cur_vertex].mNormal = LLVector3(0,0,0); 4317 mVertices[cur_vertex].mNormal = LLVector3(0,0,0);
4297 mVertices[cur_vertex].mBinormal = LLVector3(0,0,0); 4318 mVertices[cur_vertex].mBinormal = LLVector3(0,0,0);
4298 4319
4320 if (cur_vertex == 0)
4321 {
4322 face_min = face_max = mesh[i].mPos;
4323 }
4324 else
4325 {
4326 update_min_max(face_min, face_max, mesh[i].mPos);
4327 }
4328
4299 cur_vertex++; 4329 cur_vertex++;
4300 4330
4301 if ((mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2 && s > 0) 4331 if ((mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2 && s > 0)
4302 { 4332 {
4303 mCenter += mVertices[cur_vertex].mPosition = mesh[i].mPos; 4333 mVertices[cur_vertex].mPosition = mesh[i].mPos;
4304 mVertices[cur_vertex].mTexCoord = LLVector2(ss,tt); 4334 mVertices[cur_vertex].mTexCoord = LLVector2(ss,tt);
4305 4335
4306 mVertices[cur_vertex].mNormal = LLVector3(0,0,0); 4336 mVertices[cur_vertex].mNormal = LLVector3(0,0,0);
@@ -4322,15 +4352,19 @@ BOOL LLVolumeFace::createSide()
4322 4352
4323 i = mBeginS + s + max_s*t; 4353 i = mBeginS + s + max_s*t;
4324 ss = profile[mBeginS + s].mV[2] - begin_stex; 4354 ss = profile[mBeginS + s].mV[2] - begin_stex;
4325 mCenter += mVertices[cur_vertex].mPosition = mesh[i].mPos; 4355 mVertices[cur_vertex].mPosition = mesh[i].mPos;
4326 mVertices[cur_vertex].mTexCoord = LLVector2(ss,tt); 4356 mVertices[cur_vertex].mTexCoord = LLVector2(ss,tt);
4327 4357
4328 mVertices[cur_vertex].mNormal = LLVector3(0,0,0); 4358 mVertices[cur_vertex].mNormal = LLVector3(0,0,0);
4329 mVertices[cur_vertex].mBinormal = LLVector3(0,0,0); 4359 mVertices[cur_vertex].mBinormal = LLVector3(0,0,0);
4360
4361 update_min_max(face_min,face_max,mesh[i].mPos);
4362
4330 cur_vertex++; 4363 cur_vertex++;
4331 } 4364 }
4332 } 4365 }
4333 mCenter /= (F32)num_vertices; 4366
4367 mCenter = (face_min + face_max) * 0.5f;
4334 4368
4335 S32 cur_index = 0; 4369 S32 cur_index = 0;
4336 S32 cur_edge = 0; 4370 S32 cur_edge = 0;
@@ -4454,32 +4488,14 @@ BOOL LLVolumeFace::createSide()
4454 } 4488 }
4455 } 4489 }
4456 4490
4457 //this loop would LOVE OpenMP 4491 //normalize normals and binormals here so the meshes that reference
4458 LLVector3 min = mVolumep->mBounds[0] - mVolumep->mBounds[1]; 4492 //this volume data don't have to
4459 LLVector3 max = mVolumep->mBounds[0] + mVolumep->mBounds[1]; 4493 for (U32 i = 0; i < mVertices.size(); i++)
4460
4461 if (min == max && min == LLVector3(512,512,512))
4462 { 4494 {
4463 min = max = mVertices[0].mPosition;
4464 }
4465
4466 for (U32 i = 0; i < mVertices.size(); i++) {
4467 mVertices[i].mNormal.normVec(); 4495 mVertices[i].mNormal.normVec();
4468 mVertices[i].mBinormal.normVec(); 4496 mVertices[i].mBinormal.normVec();
4469
4470 for (U32 j = 0; j < 3; j++) {
4471 if (mVertices[i].mPosition.mV[j] > max.mV[j]) {
4472 max.mV[j] = mVertices[i].mPosition.mV[j];
4473 }
4474 if (mVertices[i].mPosition.mV[j] < min.mV[j]) {
4475 min.mV[j] = mVertices[i].mPosition.mV[j];
4476 }
4477 }
4478 } 4497 }
4479 4498
4480 mVolumep->mBounds[0] = (min + max) * 0.5f; //center
4481 mVolumep->mBounds[1] = (max - min) * 0.5f; //half-height
4482
4483 return TRUE; 4499 return TRUE;
4484} 4500}
4485 4501
@@ -4578,7 +4594,7 @@ LLVector3 calc_binormal_from_triangle(
4578 -r0.mV[VZ] / r0.mV[VX], 4594 -r0.mV[VZ] / r0.mV[VX],
4579 -r1.mV[VZ] / r1.mV[VX], 4595 -r1.mV[VZ] / r1.mV[VX],
4580 -r2.mV[VZ] / r2.mV[VX]); 4596 -r2.mV[VZ] / r2.mV[VX]);
4581 //binormal.normVec(); 4597 // binormal.normVec();
4582 return binormal; 4598 return binormal;
4583 } 4599 }
4584 else 4600 else
diff --git a/linden/indra/llmath/llvolume.h b/linden/indra/llmath/llvolume.h
index 63981da..91f7c9b 100644
--- a/linden/indra/llmath/llvolume.h
+++ b/linden/indra/llmath/llvolume.h
@@ -775,6 +775,8 @@ public:
775 S32 mNumS; 775 S32 mNumS;
776 S32 mNumT; 776 S32 mNumT;
777 777
778 LLVector3 mExtents[2]; //minimum and maximum point of face
779
778 std::vector<VertexData> mVertices; 780 std::vector<VertexData> mVertices;
779 std::vector<S32> mIndices; 781 std::vector<S32> mIndices;
780 std::vector<S32> mEdge; 782 std::vector<S32> mEdge;
@@ -868,7 +870,6 @@ public:
868 const LLVolumeFace &getVolumeFace(const S32 f) const {return mVolumeFaces[f];} // DO NOT DELETE VOLUME WHILE USING THIS REFERENCE, OR HOLD A POINTER TO THIS VOLUMEFACE 870 const LLVolumeFace &getVolumeFace(const S32 f) const {return mVolumeFaces[f];} // DO NOT DELETE VOLUME WHILE USING THIS REFERENCE, OR HOLD A POINTER TO THIS VOLUMEFACE
869 871
870 U32 mFaceMask; // bit array of which faces exist in this volume 872 U32 mFaceMask; // bit array of which faces exist in this volume
871 LLVector3 mBounds[2]; // bounding box (center, half-height)
872 LLVector3 mLODScaleBias; // vector for biasing LOD based on scale 873 LLVector3 mLODScaleBias; // vector for biasing LOD based on scale
873 874
874protected: 875protected:
diff --git a/linden/indra/llmath/llvolumemgr.cpp b/linden/indra/llmath/llvolumemgr.cpp
index 6b6182a..2aa480c 100644
--- a/linden/indra/llmath/llvolumemgr.cpp
+++ b/linden/indra/llmath/llvolumemgr.cpp
@@ -286,7 +286,7 @@ F32 LLVolumeLODGroup::getVolumeScaleFromDetail(const S32 detail)
286 286
287F32 LLVolumeLODGroup::dump() 287F32 LLVolumeLODGroup::dump()
288{ 288{
289 char dump_str[255]; 289 char dump_str[255]; /* Flawfinder: ignore */
290 F32 usage = 0.f; 290 F32 usage = 0.f;
291 for (S32 i = 0; i < NUM_LODS; i++) 291 for (S32 i = 0; i < NUM_LODS; i++)
292 { 292 {
@@ -297,7 +297,7 @@ F32 LLVolumeLODGroup::dump()
297 } 297 }
298 usage = usage / (F32)NUM_LODS; 298 usage = usage / (F32)NUM_LODS;
299 299
300 sprintf(dump_str, "%.3f %d %d %d %d", usage, mAccessCount[0], mAccessCount[1], mAccessCount[2], mAccessCount[3]); 300 snprintf(dump_str, sizeof(dump_str), "%.3f %d %d %d %d", usage, mAccessCount[0], mAccessCount[1], mAccessCount[2], mAccessCount[3]); /* Flawfinder: ignore */
301 301
302 llinfos << dump_str << llendl; 302 llinfos << dump_str << llendl;
303 return usage; 303 return usage;
diff --git a/linden/indra/llmath/m3math.cpp b/linden/indra/llmath/m3math.cpp
index c5d2c2d..4d93af6 100644
--- a/linden/indra/llmath/m3math.cpp
+++ b/linden/indra/llmath/m3math.cpp
@@ -52,14 +52,14 @@
52 52
53LLMatrix3::LLMatrix3(const LLQuaternion &q) 53LLMatrix3::LLMatrix3(const LLQuaternion &q)
54{ 54{
55 *this = q.getMatrix3(); 55 setRot(q);
56} 56}
57 57
58 58
59LLMatrix3::LLMatrix3(const F32 angle, const LLVector3 &vec) 59LLMatrix3::LLMatrix3(const F32 angle, const LLVector3 &vec)
60{ 60{
61 LLQuaternion quat(angle, vec); 61 LLQuaternion quat(angle, vec);
62 *this = setRot(quat); 62 setRot(quat);
63} 63}
64 64
65LLMatrix3::LLMatrix3(const F32 angle, const LLVector3d &vec) 65LLMatrix3::LLMatrix3(const F32 angle, const LLVector3d &vec)
@@ -67,60 +67,25 @@ LLMatrix3::LLMatrix3(const F32 angle, const LLVector3d &vec)
67 LLVector3 vec_f; 67 LLVector3 vec_f;
68 vec_f.setVec(vec); 68 vec_f.setVec(vec);
69 LLQuaternion quat(angle, vec_f); 69 LLQuaternion quat(angle, vec_f);
70 *this = setRot(quat); 70 setRot(quat);
71} 71}
72 72
73LLMatrix3::LLMatrix3(const F32 angle, const LLVector4 &vec) 73LLMatrix3::LLMatrix3(const F32 angle, const LLVector4 &vec)
74{ 74{
75 LLQuaternion quat(angle, vec); 75 LLQuaternion quat(angle, vec);
76 *this = setRot(quat); 76 setRot(quat);
77} 77}
78 78
79LLMatrix3::LLMatrix3(const F32 angle, const F32 x, const F32 y, const F32 z) 79LLMatrix3::LLMatrix3(const F32 angle, const F32 x, const F32 y, const F32 z)
80{ 80{
81 LLVector3 vec(x, y, z); 81 LLVector3 vec(x, y, z);
82 LLQuaternion quat(angle, vec); 82 LLQuaternion quat(angle, vec);
83 *this = setRot(quat); 83 setRot(quat);
84} 84}
85 85
86LLMatrix3::LLMatrix3(const F32 roll, const F32 pitch, const F32 yaw) 86LLMatrix3::LLMatrix3(const F32 roll, const F32 pitch, const F32 yaw)
87{ 87{
88 // Rotates RH about x-axis by 'roll' then 88 setRot(roll,pitch,yaw);
89 // rotates RH about the old y-axis by 'pitch' then
90 // rotates RH about the original z-axis by 'yaw'.
91 // .
92 // /|\ yaw axis
93 // | __.
94 // ._ ___| /| pitch axis
95 // _||\ \\ |-. /
96 // \|| \_______\_|__\_/_______
97 // | _ _ o o o_o_o_o o /_\_ ________\ roll axis
98 // // /_______/ /__________> /
99 // /_,-' // /
100 // /__,-'
101
102 F32 cx, sx, cy, sy, cz, sz;
103 F32 cxsy, sxsy;
104
105 cx = (F32)cos(roll); //A
106 sx = (F32)sin(roll); //B
107 cy = (F32)cos(pitch); //C
108 sy = (F32)sin(pitch); //D
109 cz = (F32)cos(yaw); //E
110 sz = (F32)sin(yaw); //F
111
112 cxsy = cx * sy; //AD
113 sxsy = sx * sy; //BD
114
115 mMatrix[0][0] = cy * cz;
116 mMatrix[1][0] = -cy * sz;
117 mMatrix[2][0] = sy;
118 mMatrix[0][1] = sxsy * cz + cx * sz;
119 mMatrix[1][1] = -sxsy * sz + cx * cz;
120 mMatrix[2][1] = -sx * cy;
121 mMatrix[0][2] = -cxsy * cz + sx * sz;
122 mMatrix[1][2] = cxsy * sz + sx * cz;
123 mMatrix[2][2] = cx * cy;
124} 89}
125 90
126// From Matrix and Quaternion FAQ 91// From Matrix and Quaternion FAQ
@@ -307,34 +272,64 @@ LLQuaternion LLMatrix3::quaternion() const
307// These functions take Rotation arguments 272// These functions take Rotation arguments
308const LLMatrix3& LLMatrix3::setRot(const F32 angle, const F32 x, const F32 y, const F32 z) 273const LLMatrix3& LLMatrix3::setRot(const F32 angle, const F32 x, const F32 y, const F32 z)
309{ 274{
310 LLMatrix3 mat(angle, x, y, z); 275 setRot(LLQuaternion(angle,x,y,z));
311 *this = mat;
312 return *this; 276 return *this;
313} 277}
314 278
315const LLMatrix3& LLMatrix3::setRot(const F32 angle, const LLVector3 &vec) 279const LLMatrix3& LLMatrix3::setRot(const F32 angle, const LLVector3 &vec)
316{ 280{
317 LLMatrix3 mat(angle, vec); 281 setRot(LLQuaternion(angle, vec));
318 *this = mat;
319 return *this; 282 return *this;
320} 283}
321 284
322const LLMatrix3& LLMatrix3::setRot(const F32 roll, const F32 pitch, const F32 yaw) 285const LLMatrix3& LLMatrix3::setRot(const F32 roll, const F32 pitch, const F32 yaw)
323{ 286{
324 LLMatrix3 mat(roll, pitch, yaw); 287 // Rotates RH about x-axis by 'roll' then
325 *this = mat; 288 // rotates RH about the old y-axis by 'pitch' then
289 // rotates RH about the original z-axis by 'yaw'.
290 // .
291 // /|\ yaw axis
292 // | __.
293 // ._ ___| /| pitch axis
294 // _||\ \\ |-. /
295 // \|| \_______\_|__\_/_______
296 // | _ _ o o o_o_o_o o /_\_ ________\ roll axis
297 // // /_______/ /__________> /
298 // /_,-' // /
299 // /__,-'
300
301 F32 cx, sx, cy, sy, cz, sz;
302 F32 cxsy, sxsy;
303
304 cx = (F32)cos(roll); //A
305 sx = (F32)sin(roll); //B
306 cy = (F32)cos(pitch); //C
307 sy = (F32)sin(pitch); //D
308 cz = (F32)cos(yaw); //E
309 sz = (F32)sin(yaw); //F
310
311 cxsy = cx * sy; //AD
312 sxsy = sx * sy; //BD
313
314 mMatrix[0][0] = cy * cz;
315 mMatrix[1][0] = -cy * sz;
316 mMatrix[2][0] = sy;
317 mMatrix[0][1] = sxsy * cz + cx * sz;
318 mMatrix[1][1] = -sxsy * sz + cx * cz;
319 mMatrix[2][1] = -sx * cy;
320 mMatrix[0][2] = -cxsy * cz + sx * sz;
321 mMatrix[1][2] = cxsy * sz + sx * cz;
322 mMatrix[2][2] = cx * cy;
326 return *this; 323 return *this;
327} 324}
328 325
329 326
330const LLMatrix3& LLMatrix3::setRot(const LLQuaternion &q) 327const LLMatrix3& LLMatrix3::setRot(const LLQuaternion &q)
331{ 328{
332 LLMatrix3 mat(q); 329 *this = q.getMatrix3();
333 *this = mat;
334 return *this; 330 return *this;
335} 331}
336 332
337
338const LLMatrix3& LLMatrix3::setRows(const LLVector3 &fwd, const LLVector3 &left, const LLVector3 &up) 333const LLMatrix3& LLMatrix3::setRows(const LLVector3 &fwd, const LLVector3 &left, const LLVector3 &up)
339{ 334{
340 mMatrix[0][0] = fwd.mV[0]; 335 mMatrix[0][0] = fwd.mV[0];
diff --git a/linden/indra/llmath/m3math.h b/linden/indra/llmath/m3math.h
index 74c5203..494856a 100644
--- a/linden/indra/llmath/m3math.h
+++ b/linden/indra/llmath/m3math.h
@@ -51,9 +51,6 @@ class LLQuaternion;
51 51
52 52
53static const U32 NUM_VALUES_IN_MAT3 = 3; 53static const U32 NUM_VALUES_IN_MAT3 = 3;
54#if LL_WINDOWS
55__declspec( align(16) )
56#endif
57class LLMatrix3 54class LLMatrix3
58{ 55{
59 public: 56 public:
@@ -138,11 +135,7 @@ class LLMatrix3
138 friend const LLMatrix3& operator*=(LLMatrix3 &a, const LLMatrix3 &b); // Return a * b 135 friend const LLMatrix3& operator*=(LLMatrix3 &a, const LLMatrix3 &b); // Return a * b
139 136
140 friend std::ostream& operator<<(std::ostream& s, const LLMatrix3 &a); // Stream a 137 friend std::ostream& operator<<(std::ostream& s, const LLMatrix3 &a); // Stream a
141} 138};
142#if LL_DARWIN
143__attribute__ ((aligned (16)))
144#endif
145;
146 139
147inline LLMatrix3::LLMatrix3(void) 140inline LLMatrix3::LLMatrix3(void)
148{ 141{
diff --git a/linden/indra/llmath/m4math.h b/linden/indra/llmath/m4math.h
index fe9b26a..7de29ed 100644
--- a/linden/indra/llmath/m4math.h
+++ b/linden/indra/llmath/m4math.h
@@ -92,9 +92,6 @@ class LLQuaternion;
92 92
93static const U32 NUM_VALUES_IN_MAT4 = 4; 93static const U32 NUM_VALUES_IN_MAT4 = 4;
94 94
95#if LL_WINDOWS
96__declspec(align(16))
97#endif
98class LLMatrix4 95class LLMatrix4
99{ 96{
100public: 97public:
@@ -237,11 +234,7 @@ public:
237 friend const LLMatrix4& operator*=(LLMatrix4 &a, const F32 &b); // Return a * b 234 friend const LLMatrix4& operator*=(LLMatrix4 &a, const F32 &b); // Return a * b
238 235
239 friend std::ostream& operator<<(std::ostream& s, const LLMatrix4 &a); // Stream a 236 friend std::ostream& operator<<(std::ostream& s, const LLMatrix4 &a); // Stream a
240} 237};
241#if LL_DARWIN
242__attribute__ ((aligned (16)))
243#endif
244;
245 238
246 239
247inline LLMatrix4::LLMatrix4() 240inline LLMatrix4::LLMatrix4()
diff --git a/linden/indra/llmath/v2math.h b/linden/indra/llmath/v2math.h
index 1832403..c978fc0 100644
--- a/linden/indra/llmath/v2math.h
+++ b/linden/indra/llmath/v2math.h
@@ -317,6 +317,21 @@ inline LLVector2 operator-(const LLVector2 &a)
317 return LLVector2( -a.mV[0], -a.mV[1] ); 317 return LLVector2( -a.mV[0], -a.mV[1] );
318} 318}
319 319
320inline void update_min_max(LLVector2& min, LLVector2& max, const LLVector2& pos)
321{
322 for (U32 i = 0; i < 2; i++)
323 {
324 if (min.mV[i] > pos.mV[i])
325 {
326 min.mV[i] = pos.mV[i];
327 }
328 if (max.mV[i] < pos.mV[i])
329 {
330 max.mV[i] = pos.mV[i];
331 }
332 }
333}
334
320inline std::ostream& operator<<(std::ostream& s, const LLVector2 &a) 335inline std::ostream& operator<<(std::ostream& s, const LLVector2 &a)
321{ 336{
322 s << "{ " << a.mV[VX] << ", " << a.mV[VY] << " }"; 337 s << "{ " << a.mV[VX] << ", " << a.mV[VY] << " }";
diff --git a/linden/indra/llmath/v3color.h b/linden/indra/llmath/v3color.h
index 606a810..06a94db 100644
--- a/linden/indra/llmath/v3color.h
+++ b/linden/indra/llmath/v3color.h
@@ -166,7 +166,7 @@ inline LLColor3::LLColor3(const F32 *vec)
166 166
167inline LLColor3::LLColor3(char* color_string) // takes a string of format "RRGGBB" where RR is hex 00..FF 167inline LLColor3::LLColor3(char* color_string) // takes a string of format "RRGGBB" where RR is hex 00..FF
168{ 168{
169 if (strlen(color_string) < 6) 169 if (strlen(color_string) < 6) /* Flawfinder: ignore */
170 { 170 {
171 mV[0] = 0.f; 171 mV[0] = 0.f;
172 mV[1] = 0.f; 172 mV[1] = 0.f;
@@ -174,8 +174,8 @@ inline LLColor3::LLColor3(char* color_string) // takes a string of format "RRGGB
174 return; 174 return;
175 } 175 }
176 176
177 static char tempstr[7]; 177 static char tempstr[7]; /* Flawfinder: ignore */
178 strncpy(tempstr,color_string,6); 178 strncpy(tempstr,color_string,6); /* Flawfinder: ignore */
179 tempstr[6] = '\0'; 179 tempstr[6] = '\0';
180 mV[VZ] = (F32)strtol(&tempstr[4],NULL,16)/255.f; 180 mV[VZ] = (F32)strtol(&tempstr[4],NULL,16)/255.f;
181 tempstr[4] = '\0'; 181 tempstr[4] = '\0';
diff --git a/linden/indra/llmath/v3math.cpp b/linden/indra/llmath/v3math.cpp
index 39d3b70..a97b6d8 100644
--- a/linden/indra/llmath/v3math.cpp
+++ b/linden/indra/llmath/v3math.cpp
@@ -137,7 +137,7 @@ const LLVector3& LLVector3::rotVec(F32 angle, const LLVector3 &vec)
137{ 137{
138 if ( !vec.isExactlyZero() && angle ) 138 if ( !vec.isExactlyZero() && angle )
139 { 139 {
140 *this = *this * LLMatrix3(angle, vec); 140 *this = *this * LLQuaternion(angle, vec);
141 } 141 }
142 return *this; 142 return *this;
143} 143}
@@ -147,7 +147,7 @@ const LLVector3& LLVector3::rotVec(F32 angle, F32 x, F32 y, F32 z)
147 LLVector3 vec(x, y, z); 147 LLVector3 vec(x, y, z);
148 if ( !vec.isExactlyZero() && angle ) 148 if ( !vec.isExactlyZero() && angle )
149 { 149 {
150 *this = *this * LLMatrix3(angle, vec); 150 *this = *this * LLQuaternion(angle, vec);
151 } 151 }
152 return *this; 152 return *this;
153} 153}
@@ -198,6 +198,33 @@ LLVector3::LLVector3(const LLVector4 &vec)
198 mV[VZ] = (F32)vec.mV[VZ]; 198 mV[VZ] = (F32)vec.mV[VZ];
199} 199}
200 200
201LLVector3::LLVector3(const LLSD& sd)
202{
203 setValue(sd);
204}
205
206LLSD LLVector3::getValue() const
207{
208 LLSD ret;
209 ret[0] = mV[0];
210 ret[1] = mV[1];
211 ret[2] = mV[2];
212 return ret;
213}
214
215void LLVector3::setValue(const LLSD& sd)
216{
217 mV[0] = (F32) sd[0].asReal();
218 mV[1] = (F32) sd[1].asReal();
219 mV[2] = (F32) sd[2].asReal();
220}
221
222const LLVector3& LLVector3::operator=(const LLSD& sd)
223{
224 setValue(sd);
225 return *this;
226}
227
201const LLVector3& operator*=(LLVector3 &a, const LLQuaternion &rot) 228const LLVector3& operator*=(LLVector3 &a, const LLQuaternion &rot)
202{ 229{
203 const F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ]; 230 const F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ];
diff --git a/linden/indra/llmath/v3math.h b/linden/indra/llmath/v3math.h
index 68e60de..e7134eb 100644
--- a/linden/indra/llmath/v3math.h
+++ b/linden/indra/llmath/v3math.h
@@ -37,7 +37,7 @@ class LLMatrix3;
37class LLVector3d; 37class LLVector3d;
38class LLQuaternion; 38class LLQuaternion;
39 39
40// Llvector3 = |x y z w| 40// LLvector3 = |x y z w|
41 41
42static const U32 LENGTHOFVECTOR3 = 3; 42static const U32 LENGTHOFVECTOR3 = 3;
43 43
@@ -60,32 +60,13 @@ class LLVector3
60 inline explicit LLVector3(const F32 *vec); // Initializes LLVector3 to (vec[0]. vec[1], vec[2]) 60 inline explicit LLVector3(const F32 *vec); // Initializes LLVector3 to (vec[0]. vec[1], vec[2])
61 explicit LLVector3(const LLVector3d &vec); // Initializes LLVector3 to (vec[0]. vec[1], vec[2]) 61 explicit LLVector3(const LLVector3d &vec); // Initializes LLVector3 to (vec[0]. vec[1], vec[2])
62 explicit LLVector3(const LLVector4 &vec); // Initializes LLVector4 to (vec[0]. vec[1], vec[2]) 62 explicit LLVector3(const LLVector4 &vec); // Initializes LLVector4 to (vec[0]. vec[1], vec[2])
63 LLVector3(const LLSD& sd) 63 LLVector3(const LLSD& sd);
64 {
65 setValue(sd);
66 }
67 64
68 LLSD getValue() const 65 LLSD getValue() const;
69 {
70 LLSD ret;
71 ret[0] = mV[0];
72 ret[1] = mV[1];
73 ret[2] = mV[2];
74 return ret;
75 }
76 66
77 void setValue(const LLSD& sd) 67 void setValue(const LLSD& sd);
78 {
79 mV[0] = (F32) sd[0].asReal();
80 mV[1] = (F32) sd[1].asReal();
81 mV[2] = (F32) sd[2].asReal();
82 }
83 68
84 const LLVector3& operator=(const LLSD& sd) 69 const LLVector3& operator=(const LLSD& sd);
85 {
86 setValue(sd);
87 return *this;
88 }
89 70
90 inline BOOL isFinite() const; // checks to see if all values of LLVector3 are finite 71 inline BOOL isFinite() const; // checks to see if all values of LLVector3 are finite
91 BOOL clamp(F32 min, F32 max); // Clamps all values to (min,max), returns TRUE if data changed 72 BOOL clamp(F32 min, F32 max); // Clamps all values to (min,max), returns TRUE if data changed
@@ -434,6 +415,20 @@ inline BOOL LLVector3::isNull() const
434 return FALSE; 415 return FALSE;
435} 416}
436 417
418inline void update_min_max(LLVector3& min, LLVector3& max, const LLVector3& pos)
419{
420 for (U32 i = 0; i < 3; i++)
421 {
422 if (min.mV[i] > pos.mV[i])
423 {
424 min.mV[i] = pos.mV[i];
425 }
426 if (max.mV[i] < pos.mV[i])
427 {
428 max.mV[i] = pos.mV[i];
429 }
430 }
431}
437 432
438inline F32 angle_between(const LLVector3& a, const LLVector3& b) 433inline F32 angle_between(const LLVector3& a, const LLVector3& b)
439{ 434{
diff --git a/linden/indra/llmath/v4math.h b/linden/indra/llmath/v4math.h
index 06ac777..f768ba7 100644
--- a/linden/indra/llmath/v4math.h
+++ b/linden/indra/llmath/v4math.h
@@ -40,10 +40,6 @@ class LLQuaternion;
40 40
41static const U32 LENGTHOFVECTOR4 = 4; 41static const U32 LENGTHOFVECTOR4 = 4;
42 42
43#if LL_WINDOWS
44__declspec( align(16) )
45#endif
46
47class LLVector4 43class LLVector4
48{ 44{
49 public: 45 public:
@@ -114,12 +110,7 @@ class LLVector4
114 friend const LLVector4& operator/=(LLVector4 &a, F32 k); // Return a divided by scaler k 110 friend const LLVector4& operator/=(LLVector4 &a, F32 k); // Return a divided by scaler k
115 111
116 friend LLVector4 operator-(const LLVector4 &a); // Return vector -a 112 friend LLVector4 operator-(const LLVector4 &a); // Return vector -a
117} 113};
118#if LL_DARWIN
119__attribute__ ((aligned (16)))
120#endif
121;
122
123 114
124// Non-member functions 115// Non-member functions
125F32 angle_between(const LLVector4 &a, const LLVector4 &b); // Returns angle (radians) between a and b 116F32 angle_between(const LLVector4 &a, const LLVector4 &b); // Returns angle (radians) between a and b