aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/llmath
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/llmath')
-rw-r--r--linden/indra/llmath/llcamera.cpp127
-rw-r--r--linden/indra/llmath/llcamera.h22
-rw-r--r--linden/indra/llmath/llcoordframe.cpp6
-rw-r--r--linden/indra/llmath/llmath.h16
-rw-r--r--linden/indra/llmath/llmath_vc8.vcproj944
-rw-r--r--linden/indra/llmath/llmath_vc9.vcproj946
-rw-r--r--linden/indra/llmath/lloctree.h382
-rw-r--r--linden/indra/llmath/llrect.h32
-rw-r--r--linden/indra/llmath/lltreenode.h89
-rw-r--r--linden/indra/llmath/llvolume.cpp546
-rw-r--r--linden/indra/llmath/llvolume.h18
-rw-r--r--linden/indra/llmath/llvolumemgr.cpp23
-rw-r--r--linden/indra/llmath/llvolumemgr.h1
-rw-r--r--linden/indra/llmath/v3color.cpp8
-rw-r--r--linden/indra/llmath/v3color.h10
-rw-r--r--linden/indra/llmath/v4color.cpp10
-rw-r--r--linden/indra/llmath/v4color.h4
-rw-r--r--linden/indra/llmath/v4math.h3
18 files changed, 1701 insertions, 1486 deletions
diff --git a/linden/indra/llmath/llcamera.cpp b/linden/indra/llmath/llcamera.cpp
index 82c401f..7a9d576 100644
--- a/linden/indra/llmath/llcamera.cpp
+++ b/linden/indra/llmath/llcamera.cpp
@@ -43,7 +43,8 @@ LLCamera::LLCamera() :
43 mViewHeightInPixels( -1 ), // invalid height 43 mViewHeightInPixels( -1 ), // invalid height
44 mNearPlane(DEFAULT_NEAR_PLANE), 44 mNearPlane(DEFAULT_NEAR_PLANE),
45 mFarPlane(DEFAULT_FAR_PLANE), 45 mFarPlane(DEFAULT_FAR_PLANE),
46 mFixedDistance(-1.f) 46 mFixedDistance(-1.f),
47 mPlaneCount(6)
47{ 48{
48 calculateFrustumPlanes(); 49 calculateFrustumPlanes();
49} 50}
@@ -56,7 +57,8 @@ LLCamera::LLCamera(F32 z_field_of_view, F32 aspect_ratio, S32 view_height_in_pix
56 mViewHeightInPixels(view_height_in_pixels), 57 mViewHeightInPixels(view_height_in_pixels),
57 mNearPlane(near_plane), 58 mNearPlane(near_plane),
58 mFarPlane(far_plane), 59 mFarPlane(far_plane),
59 mFixedDistance(-1.f) 60 mFixedDistance(-1.f),
61 mPlaneCount(6)
60{ 62{
61 if (mView < MIN_FIELD_OF_VIEW) { mView = MIN_FIELD_OF_VIEW; } 63 if (mView < MIN_FIELD_OF_VIEW) { mView = MIN_FIELD_OF_VIEW; }
62 else if (mView > MAX_FIELD_OF_VIEW) { mView = MAX_FIELD_OF_VIEW; } 64 else if (mView > MAX_FIELD_OF_VIEW) { mView = MAX_FIELD_OF_VIEW; }
@@ -78,6 +80,18 @@ LLCamera::LLCamera(F32 z_field_of_view, F32 aspect_ratio, S32 view_height_in_pix
78 80
79// ---------------- LLCamera::setFoo() member functions ---------------- 81// ---------------- LLCamera::setFoo() member functions ----------------
80 82
83void LLCamera::setUserClipPlane(LLPlane plane)
84{
85 mPlaneCount = 7;
86 mAgentPlanes[6].p = plane;
87 mAgentPlanes[6].mask = calcPlaneMask(plane);
88}
89
90void LLCamera::disableUserClipPlane()
91{
92 mPlaneCount = 6;
93}
94
81void LLCamera::setView(F32 field_of_view) 95void LLCamera::setView(F32 field_of_view)
82{ 96{
83 mView = field_of_view; 97 mView = field_of_view;
@@ -150,7 +164,7 @@ size_t LLCamera::readFrustumFromBuffer(const char *buffer)
150 164
151// ---------------- test methods ---------------- 165// ---------------- test methods ----------------
152 166
153int LLCamera::AABBInFrustum(const LLVector3 &center, const LLVector3& radius) 167S32 LLCamera::AABBInFrustum(const LLVector3 &center, const LLVector3& radius)
154{ 168{
155 static const LLVector3 scaler[] = { 169 static const LLVector3 scaler[] = {
156 LLVector3(-1,-1,-1), 170 LLVector3(-1,-1,-1),
@@ -166,10 +180,56 @@ int LLCamera::AABBInFrustum(const LLVector3 &center, const LLVector3& radius)
166 U8 mask = 0; 180 U8 mask = 0;
167 S32 result = 2; 181 S32 result = 2;
168 182
169 for (int i = 0; i < 6; i++) 183 for (U32 i = 0; i < mPlaneCount; i++)
184 {
185 mask = mAgentPlanes[i].mask;
186 LLPlane p = mAgentPlanes[i].p;
187 LLVector3 n = LLVector3(p);
188 float d = p.mV[3];
189 LLVector3 rscale = radius.scaledVec(scaler[mask]);
190
191 LLVector3 minp = center - rscale;
192 LLVector3 maxp = center + rscale;
193
194 if (n * minp > -d)
195 {
196 return 0;
197 }
198
199 if (n * maxp > -d)
200 {
201 result = 1;
202 }
203 }
204
205 return result;
206}
207
208S32 LLCamera::AABBInFrustumNoFarClip(const LLVector3 &center, const LLVector3& radius)
209{
210 static const LLVector3 scaler[] = {
211 LLVector3(-1,-1,-1),
212 LLVector3( 1,-1,-1),
213 LLVector3(-1, 1,-1),
214 LLVector3( 1, 1,-1),
215 LLVector3(-1,-1, 1),
216 LLVector3( 1,-1, 1),
217 LLVector3(-1, 1, 1),
218 LLVector3( 1, 1, 1)
219 };
220
221 U8 mask = 0;
222 S32 result = 2;
223
224 for (U32 i = 0; i < mPlaneCount; i++)
170 { 225 {
171 mask = mAgentPlaneMask[i]; 226 if (i == 5)
172 LLPlane p = mAgentPlanes[i]; 227 {
228 continue;
229 }
230
231 mask = mAgentPlanes[i].mask;
232 LLPlane p = mAgentPlanes[i].p;
173 LLVector3 n = LLVector3(p); 233 LLVector3 n = LLVector3(p);
174 float d = p.mV[3]; 234 float d = p.mV[3];
175 LLVector3 rscale = radius.scaledVec(scaler[mask]); 235 LLVector3 rscale = radius.scaledVec(scaler[mask]);
@@ -312,7 +372,7 @@ int LLCamera::sphereInFrustum(const LLVector3 &sphere_center, const F32 radius)
312 int res = 2; 372 int res = 2;
313 for (int i = 0; i < 6; i++) 373 for (int i = 0; i < 6; i++)
314 { 374 {
315 float d = mAgentPlanes[i].dist(sphere_center); 375 float d = mAgentPlanes[i].p.dist(sphere_center);
316 376
317 if (d > radius) 377 if (d > radius)
318 { 378 {
@@ -477,6 +537,25 @@ LLPlane planeFromPoints(LLVector3 p1, LLVector3 p2, LLVector3 p3)
477 return LLPlane(p1, n); 537 return LLPlane(p1, n);
478} 538}
479 539
540U8 LLCamera::calcPlaneMask(const LLPlane& plane)
541{
542 U8 mask = 0;
543
544 if (plane.mV[0] >= 0)
545 {
546 mask |= 1;
547 }
548 if (plane.mV[1] >= 0)
549 {
550 mask |= 2;
551 }
552 if (plane.mV[2] >= 0)
553 {
554 mask |= 4;
555 }
556
557 return mask;
558}
480 559
481void LLCamera::calcAgentFrustumPlanes(LLVector3* frust) 560void LLCamera::calcAgentFrustumPlanes(LLVector3* frust)
482{ 561{
@@ -486,48 +565,34 @@ void LLCamera::calcAgentFrustumPlanes(LLVector3* frust)
486 mAgentFrustum[i] = frust[i]; 565 mAgentFrustum[i] = frust[i];
487 } 566 }
488 567
568 mFrustumCornerDist = (frust[5] - getOrigin()).magVec();
569
489 //frust contains the 8 points of the frustum, calculate 6 planes 570 //frust contains the 8 points of the frustum, calculate 6 planes
490 571
491 //order of planes is important, keep most likely to fail in the front of the list 572 //order of planes is important, keep most likely to fail in the front of the list
492 573
493 //near - frust[0], frust[1], frust[2] 574 //near - frust[0], frust[1], frust[2]
494 mAgentPlanes[2] = planeFromPoints(frust[0], frust[1], frust[2]); 575 mAgentPlanes[2].p = planeFromPoints(frust[0], frust[1], frust[2]);
495 576
496 //far 577 //far
497 mAgentPlanes[5] = planeFromPoints(frust[5], frust[4], frust[6]); 578 mAgentPlanes[5].p = planeFromPoints(frust[5], frust[4], frust[6]);
498 579
499 //left 580 //left
500 mAgentPlanes[0] = planeFromPoints(frust[4], frust[0], frust[7]); 581 mAgentPlanes[0].p = planeFromPoints(frust[4], frust[0], frust[7]);
501 582
502 //right 583 //right
503 mAgentPlanes[1] = planeFromPoints(frust[1], frust[5], frust[6]); 584 mAgentPlanes[1].p = planeFromPoints(frust[1], frust[5], frust[6]);
504 585
505 //top 586 //top
506 mAgentPlanes[4] = planeFromPoints(frust[3], frust[2], frust[6]); 587 mAgentPlanes[4].p = planeFromPoints(frust[3], frust[2], frust[6]);
507 588
508 //bottom 589 //bottom
509 mAgentPlanes[3] = planeFromPoints(frust[1], frust[0], frust[4]); 590 mAgentPlanes[3].p = planeFromPoints(frust[1], frust[0], frust[4]);
510 591
511 //cache plane octant facing mask for use in AABBInFrustum 592 //cache plane octant facing mask for use in AABBInFrustum
512 for (int i = 0; i < 6; i++) 593 for (U32 i = 0; i < mPlaneCount; i++)
513 { 594 {
514 U8 mask = 0; 595 mAgentPlanes[i].mask = calcPlaneMask(mAgentPlanes[i].p);
515 LLPlane p = mAgentPlanes[i];
516 LLVector3 n = LLVector3(p);
517
518 if (n.mV[0] >= 0)
519 {
520 mask |= 1;
521 }
522 if (n.mV[1] >= 0)
523 {
524 mask |= 2;
525 }
526 if (n.mV[2] >= 0)
527 {
528 mask |= 4;
529 }
530 mAgentPlaneMask[i] = mask;
531 } 596 }
532} 597}
533 598
diff --git a/linden/indra/llmath/llcamera.h b/linden/indra/llmath/llcamera.h
index 0e20798..7066b9f 100644
--- a/linden/indra/llmath/llcamera.h
+++ b/linden/indra/llmath/llcamera.h
@@ -46,7 +46,7 @@ const F32 MAX_FIELD_OF_VIEW = F_PI;
46const F32 MAX_ASPECT_RATIO = 50.0f; 46const F32 MAX_ASPECT_RATIO = 50.0f;
47const F32 MAX_NEAR_PLANE = 10.f; 47const F32 MAX_NEAR_PLANE = 10.f;
48const F32 MAX_FAR_PLANE = 100000.0f; //1000000.0f; // Max allowed. Not good Z precision though. 48const F32 MAX_FAR_PLANE = 100000.0f; //1000000.0f; // Max allowed. Not good Z precision though.
49const F32 MAX_FAR_CLIP = 1024.0f; 49const F32 MAX_FAR_CLIP = 512.0f;
50 50
51const F32 MIN_FIELD_OF_VIEW = 0.1f; 51const F32 MIN_FIELD_OF_VIEW = 0.1f;
52const F32 MIN_ASPECT_RATIO = 0.02f; 52const F32 MIN_ASPECT_RATIO = 0.02f;
@@ -114,16 +114,28 @@ protected:
114 114
115 LLPlane mWorldPlanes[PLANE_NUM]; 115 LLPlane mWorldPlanes[PLANE_NUM];
116 LLPlane mHorizPlanes[HORIZ_PLANE_NUM]; 116 LLPlane mHorizPlanes[HORIZ_PLANE_NUM];
117 LLPlane mAgentPlanes[6]; //frustum in agent space a la gluUnproject (I'm a bastard, I know) - DaveP 117
118 U8 mAgentPlaneMask[6]; 118 typedef struct
119 {
120 LLPlane p;
121 U8 mask;
122 } frustum_plane;
123 frustum_plane mAgentPlanes[7]; //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP
124
125 U32 mPlaneCount; //defaults to 6, if setUserClipPlane is called, uses user supplied clip plane in
126
119 LLVector3 mWorldPlanePos; // Position of World Planes (may be offset from camera) 127 LLVector3 mWorldPlanePos; // Position of World Planes (may be offset from camera)
120public: 128public:
121 LLVector3 mAgentFrustum[8]; 129 LLVector3 mAgentFrustum[8]; //8 corners of 6-plane frustum
130 F32 mFrustumCornerDist; //distance to corner of frustum against far clip plane
122 131
123public: 132public:
124 LLCamera(); 133 LLCamera();
125 LLCamera(F32 z_field_of_view, F32 aspect_ratio, S32 view_height_in_pixels, F32 near_plane, F32 far_plane); 134 LLCamera(F32 z_field_of_view, F32 aspect_ratio, S32 view_height_in_pixels, F32 near_plane, F32 far_plane);
126 135
136 void setUserClipPlane(LLPlane plane);
137 void disableUserClipPlane();
138 U8 calcPlaneMask(const LLPlane& plane);
127 void setView(F32 new_view); 139 void setView(F32 new_view);
128 void setViewHeightInPixels(S32 height); 140 void setViewHeightInPixels(S32 height);
129 void setAspect(F32 new_aspect); 141 void setAspect(F32 new_aspect);
@@ -164,6 +176,8 @@ public:
164 S32 pointInFrustum(const LLVector3 &point) const { return sphereInFrustum(point, 0.0f); } 176 S32 pointInFrustum(const LLVector3 &point) const { return sphereInFrustum(point, 0.0f); }
165 S32 sphereInFrustumFull(const LLVector3 &center, const F32 radius) const { return sphereInFrustum(center, radius); } 177 S32 sphereInFrustumFull(const LLVector3 &center, const F32 radius) const { return sphereInFrustum(center, radius); }
166 S32 AABBInFrustum(const LLVector3 &center, const LLVector3& radius); 178 S32 AABBInFrustum(const LLVector3 &center, const LLVector3& radius);
179 S32 AABBInFrustumNoFarClip(const LLVector3 &center, const LLVector3& radius);
180
167 //does a quick 'n dirty sphere-sphere check 181 //does a quick 'n dirty sphere-sphere check
168 S32 sphereInFrustumQuick(const LLVector3 &sphere_center, const F32 radius); 182 S32 sphereInFrustumQuick(const LLVector3 &sphere_center, const F32 radius);
169 183
diff --git a/linden/indra/llmath/llcoordframe.cpp b/linden/indra/llmath/llcoordframe.cpp
index 6d18c8b..0196424 100644
--- a/linden/indra/llmath/llcoordframe.cpp
+++ b/linden/indra/llmath/llcoordframe.cpp
@@ -730,7 +730,11 @@ void LLCoordFrame::lookDir(const LLVector3 &at, const LLVector3 &up_direction)
730 left.normVec(); 730 left.normVec();
731 731
732 LLVector3 up = at % left; 732 LLVector3 up = at % left;
733 setAxes(at, left, up); 733
734 if (at.isFinite() && left.isFinite() && up.isFinite())
735 {
736 setAxes(at, left, up);
737 }
734} 738}
735 739
736void LLCoordFrame::lookDir(const LLVector3 &xuv) 740void LLCoordFrame::lookDir(const LLVector3 &xuv)
diff --git a/linden/indra/llmath/llmath.h b/linden/indra/llmath/llmath.h
index affdbf1..d3c0d86 100644
--- a/linden/indra/llmath/llmath.h
+++ b/linden/indra/llmath/llmath.h
@@ -440,4 +440,20 @@ inline F32 llsimple_angle(F32 angle)
440 return angle; 440 return angle;
441} 441}
442 442
443//calculate the nearesr power of two number for val, bounded by max_power_two
444inline U32 get_nearest_power_two(U32 val, U32 max_power_two)
445{
446 if(!max_power_two)
447 {
448 max_power_two = 1 << 31 ;
449 }
450 if(max_power_two & (max_power_two - 1))
451 {
452 return 0 ;
453 }
454
455 for(; val < max_power_two ; max_power_two >>= 1) ;
456
457 return max_power_two ;
458}
443#endif 459#endif
diff --git a/linden/indra/llmath/llmath_vc8.vcproj b/linden/indra/llmath/llmath_vc8.vcproj
index ed4193d..e85a852 100644
--- a/linden/indra/llmath/llmath_vc8.vcproj
+++ b/linden/indra/llmath/llmath_vc8.vcproj
@@ -1,472 +1,472 @@
1<?xml version="1.0" encoding="Windows-1252"?> 1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject 2<VisualStudioProject
3 ProjectType="Visual C++" 3 ProjectType="Visual C++"
4 Version="8.00" 4 Version="8.00"
5 Name="llmath" 5 Name="llmath"
6 ProjectGUID="{E87FD9BE-BE42-4EA3-BF4D-D992223046D9}" 6 ProjectGUID="{E87FD9BE-BE42-4EA3-BF4D-D992223046D9}"
7 RootNamespace="llmath" 7 RootNamespace="llmath"
8 Keyword="Win32Proj" 8 Keyword="Win32Proj"
9 > 9 >
10 <Platforms> 10 <Platforms>
11 <Platform 11 <Platform
12 Name="Win32" 12 Name="Win32"
13 /> 13 />
14 </Platforms> 14 </Platforms>
15 <ToolFiles> 15 <ToolFiles>
16 </ToolFiles> 16 </ToolFiles>
17 <Configurations> 17 <Configurations>
18 <Configuration 18 <Configuration
19 Name="Debug|Win32" 19 Name="Debug|Win32"
20 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 20 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
21 IntermediateDirectory="$(ConfigurationName)" 21 IntermediateDirectory="$(ConfigurationName)"
22 ConfigurationType="4" 22 ConfigurationType="4"
23 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 23 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
24 CharacterSet="1" 24 CharacterSet="1"
25 > 25 >
26 <Tool 26 <Tool
27 Name="VCPreBuildEventTool" 27 Name="VCPreBuildEventTool"
28 /> 28 />
29 <Tool 29 <Tool
30 Name="VCCustomBuildTool" 30 Name="VCCustomBuildTool"
31 /> 31 />
32 <Tool 32 <Tool
33 Name="VCXMLDataGeneratorTool" 33 Name="VCXMLDataGeneratorTool"
34 /> 34 />
35 <Tool 35 <Tool
36 Name="VCWebServiceProxyGeneratorTool" 36 Name="VCWebServiceProxyGeneratorTool"
37 /> 37 />
38 <Tool 38 <Tool
39 Name="VCMIDLTool" 39 Name="VCMIDLTool"
40 /> 40 />
41 <Tool 41 <Tool
42 Name="VCCLCompilerTool" 42 Name="VCCLCompilerTool"
43 Optimization="0" 43 Optimization="0"
44 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\" 44 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\"
45 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG" 45 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG"
46 MinimalRebuild="true" 46 MinimalRebuild="true"
47 BasicRuntimeChecks="3" 47 BasicRuntimeChecks="3"
48 RuntimeLibrary="1" 48 RuntimeLibrary="1"
49 StructMemberAlignment="4" 49 StructMemberAlignment="4"
50 TreatWChar_tAsBuiltInType="false" 50 TreatWChar_tAsBuiltInType="false"
51 ForceConformanceInForLoopScope="true" 51 ForceConformanceInForLoopScope="true"
52 UsePrecompiledHeader="0" 52 UsePrecompiledHeader="0"
53 WarningLevel="3" 53 WarningLevel="3"
54 WarnAsError="true" 54 WarnAsError="true"
55 Detect64BitPortabilityProblems="false" 55 Detect64BitPortabilityProblems="false"
56 DebugInformationFormat="4" 56 DebugInformationFormat="4"
57 /> 57 />
58 <Tool 58 <Tool
59 Name="VCManagedResourceCompilerTool" 59 Name="VCManagedResourceCompilerTool"
60 /> 60 />
61 <Tool 61 <Tool
62 Name="VCResourceCompilerTool" 62 Name="VCResourceCompilerTool"
63 /> 63 />
64 <Tool 64 <Tool
65 Name="VCPreLinkEventTool" 65 Name="VCPreLinkEventTool"
66 /> 66 />
67 <Tool 67 <Tool
68 Name="VCLibrarianTool" 68 Name="VCLibrarianTool"
69 OutputFile="$(OutDir)/llmath.lib" 69 OutputFile="$(OutDir)/llmath.lib"
70 /> 70 />
71 <Tool 71 <Tool
72 Name="VCALinkTool" 72 Name="VCALinkTool"
73 /> 73 />
74 <Tool 74 <Tool
75 Name="VCXDCMakeTool" 75 Name="VCXDCMakeTool"
76 /> 76 />
77 <Tool 77 <Tool
78 Name="VCBscMakeTool" 78 Name="VCBscMakeTool"
79 /> 79 />
80 <Tool 80 <Tool
81 Name="VCFxCopTool" 81 Name="VCFxCopTool"
82 /> 82 />
83 <Tool 83 <Tool
84 Name="VCPostBuildEventTool" 84 Name="VCPostBuildEventTool"
85 /> 85 />
86 </Configuration> 86 </Configuration>
87 <Configuration 87 <Configuration
88 Name="Release|Win32" 88 Name="Release|Win32"
89 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 89 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
90 IntermediateDirectory="$(ConfigurationName)" 90 IntermediateDirectory="$(ConfigurationName)"
91 ConfigurationType="4" 91 ConfigurationType="4"
92 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 92 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
93 CharacterSet="1" 93 CharacterSet="1"
94 > 94 >
95 <Tool 95 <Tool
96 Name="VCPreBuildEventTool" 96 Name="VCPreBuildEventTool"
97 /> 97 />
98 <Tool 98 <Tool
99 Name="VCCustomBuildTool" 99 Name="VCCustomBuildTool"
100 /> 100 />
101 <Tool 101 <Tool
102 Name="VCXMLDataGeneratorTool" 102 Name="VCXMLDataGeneratorTool"
103 /> 103 />
104 <Tool 104 <Tool
105 Name="VCWebServiceProxyGeneratorTool" 105 Name="VCWebServiceProxyGeneratorTool"
106 /> 106 />
107 <Tool 107 <Tool
108 Name="VCMIDLTool" 108 Name="VCMIDLTool"
109 /> 109 />
110 <Tool 110 <Tool
111 Name="VCCLCompilerTool" 111 Name="VCCLCompilerTool"
112 AdditionalOptions="/Oy-" 112 AdditionalOptions="/Oy-"
113 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\" 113 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\"
114 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE" 114 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
115 RuntimeLibrary="0" 115 RuntimeLibrary="0"
116 StructMemberAlignment="0" 116 StructMemberAlignment="0"
117 TreatWChar_tAsBuiltInType="false" 117 TreatWChar_tAsBuiltInType="false"
118 ForceConformanceInForLoopScope="true" 118 ForceConformanceInForLoopScope="true"
119 UsePrecompiledHeader="0" 119 UsePrecompiledHeader="0"
120 WarningLevel="3" 120 WarningLevel="3"
121 WarnAsError="true" 121 WarnAsError="true"
122 Detect64BitPortabilityProblems="false" 122 Detect64BitPortabilityProblems="false"
123 DebugInformationFormat="3" 123 DebugInformationFormat="3"
124 /> 124 />
125 <Tool 125 <Tool
126 Name="VCManagedResourceCompilerTool" 126 Name="VCManagedResourceCompilerTool"
127 /> 127 />
128 <Tool 128 <Tool
129 Name="VCResourceCompilerTool" 129 Name="VCResourceCompilerTool"
130 /> 130 />
131 <Tool 131 <Tool
132 Name="VCPreLinkEventTool" 132 Name="VCPreLinkEventTool"
133 /> 133 />
134 <Tool 134 <Tool
135 Name="VCLibrarianTool" 135 Name="VCLibrarianTool"
136 OutputFile="$(OutDir)/llmath.lib" 136 OutputFile="$(OutDir)/llmath.lib"
137 /> 137 />
138 <Tool 138 <Tool
139 Name="VCALinkTool" 139 Name="VCALinkTool"
140 /> 140 />
141 <Tool 141 <Tool
142 Name="VCXDCMakeTool" 142 Name="VCXDCMakeTool"
143 /> 143 />
144 <Tool 144 <Tool
145 Name="VCBscMakeTool" 145 Name="VCBscMakeTool"
146 /> 146 />
147 <Tool 147 <Tool
148 Name="VCFxCopTool" 148 Name="VCFxCopTool"
149 /> 149 />
150 <Tool 150 <Tool
151 Name="VCPostBuildEventTool" 151 Name="VCPostBuildEventTool"
152 /> 152 />
153 </Configuration> 153 </Configuration>
154 <Configuration 154 <Configuration
155 Name="ReleaseNoOpt|Win32" 155 Name="ReleaseNoOpt|Win32"
156 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 156 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
157 IntermediateDirectory="$(ConfigurationName)" 157 IntermediateDirectory="$(ConfigurationName)"
158 ConfigurationType="4" 158 ConfigurationType="4"
159 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 159 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
160 CharacterSet="1" 160 CharacterSet="1"
161 > 161 >
162 <Tool 162 <Tool
163 Name="VCPreBuildEventTool" 163 Name="VCPreBuildEventTool"
164 /> 164 />
165 <Tool 165 <Tool
166 Name="VCCustomBuildTool" 166 Name="VCCustomBuildTool"
167 /> 167 />
168 <Tool 168 <Tool
169 Name="VCXMLDataGeneratorTool" 169 Name="VCXMLDataGeneratorTool"
170 /> 170 />
171 <Tool 171 <Tool
172 Name="VCWebServiceProxyGeneratorTool" 172 Name="VCWebServiceProxyGeneratorTool"
173 /> 173 />
174 <Tool 174 <Tool
175 Name="VCMIDLTool" 175 Name="VCMIDLTool"
176 /> 176 />
177 <Tool 177 <Tool
178 Name="VCCLCompilerTool" 178 Name="VCCLCompilerTool"
179 AdditionalOptions="/Oy-" 179 AdditionalOptions="/Oy-"
180 Optimization="0" 180 Optimization="0"
181 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\" 181 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\"
182 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE" 182 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
183 RuntimeLibrary="0" 183 RuntimeLibrary="0"
184 StructMemberAlignment="0" 184 StructMemberAlignment="0"
185 TreatWChar_tAsBuiltInType="false" 185 TreatWChar_tAsBuiltInType="false"
186 ForceConformanceInForLoopScope="true" 186 ForceConformanceInForLoopScope="true"
187 UsePrecompiledHeader="0" 187 UsePrecompiledHeader="0"
188 BrowseInformation="0" 188 BrowseInformation="0"
189 WarningLevel="3" 189 WarningLevel="3"
190 WarnAsError="true" 190 WarnAsError="true"
191 Detect64BitPortabilityProblems="false" 191 Detect64BitPortabilityProblems="false"
192 DebugInformationFormat="3" 192 DebugInformationFormat="3"
193 /> 193 />
194 <Tool 194 <Tool
195 Name="VCManagedResourceCompilerTool" 195 Name="VCManagedResourceCompilerTool"
196 /> 196 />
197 <Tool 197 <Tool
198 Name="VCResourceCompilerTool" 198 Name="VCResourceCompilerTool"
199 /> 199 />
200 <Tool 200 <Tool
201 Name="VCPreLinkEventTool" 201 Name="VCPreLinkEventTool"
202 /> 202 />
203 <Tool 203 <Tool
204 Name="VCLibrarianTool" 204 Name="VCLibrarianTool"
205 OutputFile="$(OutDir)/llmath.lib" 205 OutputFile="$(OutDir)/llmath.lib"
206 /> 206 />
207 <Tool 207 <Tool
208 Name="VCALinkTool" 208 Name="VCALinkTool"
209 /> 209 />
210 <Tool 210 <Tool
211 Name="VCXDCMakeTool" 211 Name="VCXDCMakeTool"
212 /> 212 />
213 <Tool 213 <Tool
214 Name="VCBscMakeTool" 214 Name="VCBscMakeTool"
215 /> 215 />
216 <Tool 216 <Tool
217 Name="VCFxCopTool" 217 Name="VCFxCopTool"
218 /> 218 />
219 <Tool 219 <Tool
220 Name="VCPostBuildEventTool" 220 Name="VCPostBuildEventTool"
221 /> 221 />
222 </Configuration> 222 </Configuration>
223 </Configurations> 223 </Configurations>
224 <References> 224 <References>
225 </References> 225 </References>
226 <Files> 226 <Files>
227 <Filter 227 <Filter
228 Name="Source Files" 228 Name="Source Files"
229 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" 229 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
230 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" 230 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
231 > 231 >
232 <File 232 <File
233 RelativePath=".\llbboxlocal.cpp" 233 RelativePath=".\llbboxlocal.cpp"
234 > 234 >
235 </File> 235 </File>
236 <File 236 <File
237 RelativePath=".\llcamera.cpp" 237 RelativePath=".\llcamera.cpp"
238 > 238 >
239 </File> 239 </File>
240 <File 240 <File
241 RelativePath=".\llcoordframe.cpp" 241 RelativePath=".\llcoordframe.cpp"
242 > 242 >
243 </File> 243 </File>
244 <File 244 <File
245 RelativePath=".\llcrc.cpp" 245 RelativePath=".\llcrc.cpp"
246 > 246 >
247 </File> 247 </File>
248 <File 248 <File
249 RelativePath=".\llmd5.cpp" 249 RelativePath=".\llmd5.cpp"
250 > 250 >
251 </File> 251 </File>
252 <File 252 <File
253 RelativePath=".\llperlin.cpp" 253 RelativePath=".\llperlin.cpp"
254 > 254 >
255 </File> 255 </File>
256 <File 256 <File
257 RelativePath=".\llquaternion.cpp" 257 RelativePath=".\llquaternion.cpp"
258 > 258 >
259 </File> 259 </File>
260 <File 260 <File
261 RelativePath=".\llrand.cpp" 261 RelativePath=".\llrand.cpp"
262 > 262 >
263 </File> 263 </File>
264 <File 264 <File
265 RelativePath=".\llrect.cpp" 265 RelativePath=".\llrect.cpp"
266 > 266 >
267 </File> 267 </File>
268 <File 268 <File
269 RelativePath=".\lluuid.cpp" 269 RelativePath=".\lluuid.cpp"
270 > 270 >
271 </File> 271 </File>
272 <File 272 <File
273 RelativePath=".\llvolume.cpp" 273 RelativePath=".\llvolume.cpp"
274 > 274 >
275 </File> 275 </File>
276 <File 276 <File
277 RelativePath=".\llvolumemgr.cpp" 277 RelativePath=".\llvolumemgr.cpp"
278 > 278 >
279 </File> 279 </File>
280 <File 280 <File
281 RelativePath=".\m3math.cpp" 281 RelativePath=".\m3math.cpp"
282 > 282 >
283 </File> 283 </File>
284 <File 284 <File
285 RelativePath=".\m4math.cpp" 285 RelativePath=".\m4math.cpp"
286 > 286 >
287 </File> 287 </File>
288 <File 288 <File
289 RelativePath=".\raytrace.cpp" 289 RelativePath=".\raytrace.cpp"
290 > 290 >
291 </File> 291 </File>
292 <File 292 <File
293 RelativePath=".\v2math.cpp" 293 RelativePath=".\v2math.cpp"
294 > 294 >
295 </File> 295 </File>
296 <File 296 <File
297 RelativePath=".\v3color.cpp" 297 RelativePath=".\v3color.cpp"
298 > 298 >
299 </File> 299 </File>
300 <File 300 <File
301 RelativePath=".\v3dmath.cpp" 301 RelativePath=".\v3dmath.cpp"
302 > 302 >
303 </File> 303 </File>
304 <File 304 <File
305 RelativePath=".\v3math.cpp" 305 RelativePath=".\v3math.cpp"
306 > 306 >
307 </File> 307 </File>
308 <File 308 <File
309 RelativePath=".\v4color.cpp" 309 RelativePath=".\v4color.cpp"
310 > 310 >
311 </File> 311 </File>
312 <File 312 <File
313 RelativePath=".\v4coloru.cpp" 313 RelativePath=".\v4coloru.cpp"
314 > 314 >
315 </File> 315 </File>
316 <File 316 <File
317 RelativePath=".\v4math.cpp" 317 RelativePath=".\v4math.cpp"
318 > 318 >
319 </File> 319 </File>
320 <File 320 <File
321 RelativePath=".\xform.cpp" 321 RelativePath=".\xform.cpp"
322 > 322 >
323 </File> 323 </File>
324 </Filter> 324 </Filter>
325 <Filter 325 <Filter
326 Name="Header Files" 326 Name="Header Files"
327 Filter="h;hpp;hxx;hm;inl;inc;xsd" 327 Filter="h;hpp;hxx;hm;inl;inc;xsd"
328 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" 328 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
329 > 329 >
330 <File 330 <File
331 RelativePath=".\llbboxlocal.h" 331 RelativePath=".\llbboxlocal.h"
332 > 332 >
333 </File> 333 </File>
334 <File 334 <File
335 RelativePath=".\llcamera.h" 335 RelativePath=".\llcamera.h"
336 > 336 >
337 </File> 337 </File>
338 <File 338 <File
339 RelativePath=".\llcoord.h" 339 RelativePath=".\llcoord.h"
340 > 340 >
341 </File> 341 </File>
342 <File 342 <File
343 RelativePath=".\llcoordframe.h" 343 RelativePath=".\llcoordframe.h"
344 > 344 >
345 </File> 345 </File>
346 <File 346 <File
347 RelativePath=".\llcrc.h" 347 RelativePath=".\llcrc.h"
348 > 348 >
349 </File> 349 </File>
350 <File 350 <File
351 RelativePath=".\llinterp.h" 351 RelativePath=".\llinterp.h"
352 > 352 >
353 </File> 353 </File>
354 <File 354 <File
355 RelativePath=".\llmath.h" 355 RelativePath=".\llmath.h"
356 > 356 >
357 </File> 357 </File>
358 <File 358 <File
359 RelativePath=".\llmd5.h" 359 RelativePath=".\llmd5.h"
360 > 360 >
361 </File> 361 </File>
362 <File 362 <File
363 RelativePath=".\lloctree.h" 363 RelativePath=".\lloctree.h"
364 > 364 >
365 </File> 365 </File>
366 <File 366 <File
367 RelativePath=".\llperlin.h" 367 RelativePath=".\llperlin.h"
368 > 368 >
369 </File> 369 </File>
370 <File 370 <File
371 RelativePath=".\llquantize.h" 371 RelativePath=".\llquantize.h"
372 > 372 >
373 </File> 373 </File>
374 <File 374 <File
375 RelativePath=".\llquaternion.h" 375 RelativePath=".\llquaternion.h"
376 > 376 >
377 </File> 377 </File>
378 <File 378 <File
379 RelativePath=".\llrand.h" 379 RelativePath=".\llrand.h"
380 > 380 >
381 </File> 381 </File>
382 <File 382 <File
383 RelativePath=".\llrect.h" 383 RelativePath=".\llrect.h"
384 > 384 >
385 </File> 385 </File>
386 <File 386 <File
387 RelativePath=".\lltreenode.h" 387 RelativePath=".\lltreenode.h"
388 > 388 >
389 </File> 389 </File>
390 <File 390 <File
391 RelativePath=".\lluuid.h" 391 RelativePath=".\lluuid.h"
392 > 392 >
393 </File> 393 </File>
394 <File 394 <File
395 RelativePath=".\llv4math.h" 395 RelativePath=".\llv4math.h"
396 > 396 >
397 </File> 397 </File>
398 <File 398 <File
399 RelativePath=".\llv4matrix3.h" 399 RelativePath=".\llv4matrix3.h"
400 > 400 >
401 </File> 401 </File>
402 <File 402 <File
403 RelativePath=".\llv4matrix4.h" 403 RelativePath=".\llv4matrix4.h"
404 > 404 >
405 </File> 405 </File>
406 <File 406 <File
407 RelativePath=".\llv4vector3.h" 407 RelativePath=".\llv4vector3.h"
408 > 408 >
409 </File> 409 </File>
410 <File 410 <File
411 RelativePath=".\llvolume.h" 411 RelativePath=".\llvolume.h"
412 > 412 >
413 </File> 413 </File>
414 <File 414 <File
415 RelativePath=".\llvolumemgr.h" 415 RelativePath=".\llvolumemgr.h"
416 > 416 >
417 </File> 417 </File>
418 <File 418 <File
419 RelativePath=".\m3math.h" 419 RelativePath=".\m3math.h"
420 > 420 >
421 </File> 421 </File>
422 <File 422 <File
423 RelativePath=".\m4math.h" 423 RelativePath=".\m4math.h"
424 > 424 >
425 </File> 425 </File>
426 <File 426 <File
427 RelativePath=".\raytrace.h" 427 RelativePath=".\raytrace.h"
428 > 428 >
429 </File> 429 </File>
430 <File 430 <File
431 RelativePath=".\v2math.h" 431 RelativePath=".\v2math.h"
432 > 432 >
433 </File> 433 </File>
434 <File 434 <File
435 RelativePath=".\v3color.h" 435 RelativePath=".\v3color.h"
436 > 436 >
437 </File> 437 </File>
438 <File 438 <File
439 RelativePath=".\v3dmath.h" 439 RelativePath=".\v3dmath.h"
440 > 440 >
441 </File> 441 </File>
442 <File 442 <File
443 RelativePath=".\v3math.h" 443 RelativePath=".\v3math.h"
444 > 444 >
445 </File> 445 </File>
446 <File 446 <File
447 RelativePath=".\v4color.h" 447 RelativePath=".\v4color.h"
448 > 448 >
449 </File> 449 </File>
450 <File 450 <File
451 RelativePath=".\v4coloru.h" 451 RelativePath=".\v4coloru.h"
452 > 452 >
453 </File> 453 </File>
454 <File 454 <File
455 RelativePath=".\v4math.h" 455 RelativePath=".\v4math.h"
456 > 456 >
457 </File> 457 </File>
458 <File 458 <File
459 RelativePath=".\xform.h" 459 RelativePath=".\xform.h"
460 > 460 >
461 </File> 461 </File>
462 </Filter> 462 </Filter>
463 <Filter 463 <Filter
464 Name="Resource Files" 464 Name="Resource Files"
465 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" 465 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
466 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" 466 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
467 > 467 >
468 </Filter> 468 </Filter>
469 </Files> 469 </Files>
470 <Globals> 470 <Globals>
471 </Globals> 471 </Globals>
472</VisualStudioProject> 472</VisualStudioProject>
diff --git a/linden/indra/llmath/llmath_vc9.vcproj b/linden/indra/llmath/llmath_vc9.vcproj
index 1f6d05b..6d60d1e 100644
--- a/linden/indra/llmath/llmath_vc9.vcproj
+++ b/linden/indra/llmath/llmath_vc9.vcproj
@@ -1,473 +1,473 @@
1<?xml version="1.0" encoding="Windows-1252"?> 1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject 2<VisualStudioProject
3 ProjectType="Visual C++" 3 ProjectType="Visual C++"
4 Version="9.00" 4 Version="9.00"
5 Name="llmath" 5 Name="llmath"
6 ProjectGUID="{E87FD9BE-BE42-4EA3-BF4D-D992223046D9}" 6 ProjectGUID="{E87FD9BE-BE42-4EA3-BF4D-D992223046D9}"
7 RootNamespace="llmath" 7 RootNamespace="llmath"
8 Keyword="Win32Proj" 8 Keyword="Win32Proj"
9 TargetFrameworkVersion="131072" 9 TargetFrameworkVersion="131072"
10 > 10 >
11 <Platforms> 11 <Platforms>
12 <Platform 12 <Platform
13 Name="Win32" 13 Name="Win32"
14 /> 14 />
15 </Platforms> 15 </Platforms>
16 <ToolFiles> 16 <ToolFiles>
17 </ToolFiles> 17 </ToolFiles>
18 <Configurations> 18 <Configurations>
19 <Configuration 19 <Configuration
20 Name="Debug|Win32" 20 Name="Debug|Win32"
21 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 21 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
22 IntermediateDirectory="$(ConfigurationName)" 22 IntermediateDirectory="$(ConfigurationName)"
23 ConfigurationType="4" 23 ConfigurationType="4"
24 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 24 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
25 CharacterSet="1" 25 CharacterSet="1"
26 > 26 >
27 <Tool 27 <Tool
28 Name="VCPreBuildEventTool" 28 Name="VCPreBuildEventTool"
29 /> 29 />
30 <Tool 30 <Tool
31 Name="VCCustomBuildTool" 31 Name="VCCustomBuildTool"
32 /> 32 />
33 <Tool 33 <Tool
34 Name="VCXMLDataGeneratorTool" 34 Name="VCXMLDataGeneratorTool"
35 /> 35 />
36 <Tool 36 <Tool
37 Name="VCWebServiceProxyGeneratorTool" 37 Name="VCWebServiceProxyGeneratorTool"
38 /> 38 />
39 <Tool 39 <Tool
40 Name="VCMIDLTool" 40 Name="VCMIDLTool"
41 /> 41 />
42 <Tool 42 <Tool
43 Name="VCCLCompilerTool" 43 Name="VCCLCompilerTool"
44 Optimization="0" 44 Optimization="0"
45 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\" 45 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\"
46 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG" 46 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG"
47 MinimalRebuild="true" 47 MinimalRebuild="true"
48 BasicRuntimeChecks="3" 48 BasicRuntimeChecks="3"
49 RuntimeLibrary="1" 49 RuntimeLibrary="1"
50 StructMemberAlignment="4" 50 StructMemberAlignment="4"
51 TreatWChar_tAsBuiltInType="false" 51 TreatWChar_tAsBuiltInType="false"
52 ForceConformanceInForLoopScope="true" 52 ForceConformanceInForLoopScope="true"
53 UsePrecompiledHeader="0" 53 UsePrecompiledHeader="0"
54 WarningLevel="3" 54 WarningLevel="3"
55 WarnAsError="true" 55 WarnAsError="true"
56 Detect64BitPortabilityProblems="false" 56 Detect64BitPortabilityProblems="false"
57 DebugInformationFormat="4" 57 DebugInformationFormat="4"
58 /> 58 />
59 <Tool 59 <Tool
60 Name="VCManagedResourceCompilerTool" 60 Name="VCManagedResourceCompilerTool"
61 /> 61 />
62 <Tool 62 <Tool
63 Name="VCResourceCompilerTool" 63 Name="VCResourceCompilerTool"
64 /> 64 />
65 <Tool 65 <Tool
66 Name="VCPreLinkEventTool" 66 Name="VCPreLinkEventTool"
67 /> 67 />
68 <Tool 68 <Tool
69 Name="VCLibrarianTool" 69 Name="VCLibrarianTool"
70 OutputFile="$(OutDir)/llmath.lib" 70 OutputFile="$(OutDir)/llmath.lib"
71 /> 71 />
72 <Tool 72 <Tool
73 Name="VCALinkTool" 73 Name="VCALinkTool"
74 /> 74 />
75 <Tool 75 <Tool
76 Name="VCXDCMakeTool" 76 Name="VCXDCMakeTool"
77 /> 77 />
78 <Tool 78 <Tool
79 Name="VCBscMakeTool" 79 Name="VCBscMakeTool"
80 /> 80 />
81 <Tool 81 <Tool
82 Name="VCFxCopTool" 82 Name="VCFxCopTool"
83 /> 83 />
84 <Tool 84 <Tool
85 Name="VCPostBuildEventTool" 85 Name="VCPostBuildEventTool"
86 /> 86 />
87 </Configuration> 87 </Configuration>
88 <Configuration 88 <Configuration
89 Name="Release|Win32" 89 Name="Release|Win32"
90 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 90 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
91 IntermediateDirectory="$(ConfigurationName)" 91 IntermediateDirectory="$(ConfigurationName)"
92 ConfigurationType="4" 92 ConfigurationType="4"
93 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 93 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
94 CharacterSet="1" 94 CharacterSet="1"
95 > 95 >
96 <Tool 96 <Tool
97 Name="VCPreBuildEventTool" 97 Name="VCPreBuildEventTool"
98 /> 98 />
99 <Tool 99 <Tool
100 Name="VCCustomBuildTool" 100 Name="VCCustomBuildTool"
101 /> 101 />
102 <Tool 102 <Tool
103 Name="VCXMLDataGeneratorTool" 103 Name="VCXMLDataGeneratorTool"
104 /> 104 />
105 <Tool 105 <Tool
106 Name="VCWebServiceProxyGeneratorTool" 106 Name="VCWebServiceProxyGeneratorTool"
107 /> 107 />
108 <Tool 108 <Tool
109 Name="VCMIDLTool" 109 Name="VCMIDLTool"
110 /> 110 />
111 <Tool 111 <Tool
112 Name="VCCLCompilerTool" 112 Name="VCCLCompilerTool"
113 AdditionalOptions="/Oy-" 113 AdditionalOptions="/Oy-"
114 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\" 114 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\"
115 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE" 115 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
116 RuntimeLibrary="0" 116 RuntimeLibrary="0"
117 StructMemberAlignment="0" 117 StructMemberAlignment="0"
118 TreatWChar_tAsBuiltInType="false" 118 TreatWChar_tAsBuiltInType="false"
119 ForceConformanceInForLoopScope="true" 119 ForceConformanceInForLoopScope="true"
120 UsePrecompiledHeader="0" 120 UsePrecompiledHeader="0"
121 WarningLevel="3" 121 WarningLevel="3"
122 WarnAsError="true" 122 WarnAsError="true"
123 Detect64BitPortabilityProblems="false" 123 Detect64BitPortabilityProblems="false"
124 DebugInformationFormat="3" 124 DebugInformationFormat="3"
125 /> 125 />
126 <Tool 126 <Tool
127 Name="VCManagedResourceCompilerTool" 127 Name="VCManagedResourceCompilerTool"
128 /> 128 />
129 <Tool 129 <Tool
130 Name="VCResourceCompilerTool" 130 Name="VCResourceCompilerTool"
131 /> 131 />
132 <Tool 132 <Tool
133 Name="VCPreLinkEventTool" 133 Name="VCPreLinkEventTool"
134 /> 134 />
135 <Tool 135 <Tool
136 Name="VCLibrarianTool" 136 Name="VCLibrarianTool"
137 OutputFile="$(OutDir)/llmath.lib" 137 OutputFile="$(OutDir)/llmath.lib"
138 /> 138 />
139 <Tool 139 <Tool
140 Name="VCALinkTool" 140 Name="VCALinkTool"
141 /> 141 />
142 <Tool 142 <Tool
143 Name="VCXDCMakeTool" 143 Name="VCXDCMakeTool"
144 /> 144 />
145 <Tool 145 <Tool
146 Name="VCBscMakeTool" 146 Name="VCBscMakeTool"
147 /> 147 />
148 <Tool 148 <Tool
149 Name="VCFxCopTool" 149 Name="VCFxCopTool"
150 /> 150 />
151 <Tool 151 <Tool
152 Name="VCPostBuildEventTool" 152 Name="VCPostBuildEventTool"
153 /> 153 />
154 </Configuration> 154 </Configuration>
155 <Configuration 155 <Configuration
156 Name="ReleaseNoOpt|Win32" 156 Name="ReleaseNoOpt|Win32"
157 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 157 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
158 IntermediateDirectory="$(ConfigurationName)" 158 IntermediateDirectory="$(ConfigurationName)"
159 ConfigurationType="4" 159 ConfigurationType="4"
160 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 160 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
161 CharacterSet="1" 161 CharacterSet="1"
162 > 162 >
163 <Tool 163 <Tool
164 Name="VCPreBuildEventTool" 164 Name="VCPreBuildEventTool"
165 /> 165 />
166 <Tool 166 <Tool
167 Name="VCCustomBuildTool" 167 Name="VCCustomBuildTool"
168 /> 168 />
169 <Tool 169 <Tool
170 Name="VCXMLDataGeneratorTool" 170 Name="VCXMLDataGeneratorTool"
171 /> 171 />
172 <Tool 172 <Tool
173 Name="VCWebServiceProxyGeneratorTool" 173 Name="VCWebServiceProxyGeneratorTool"
174 /> 174 />
175 <Tool 175 <Tool
176 Name="VCMIDLTool" 176 Name="VCMIDLTool"
177 /> 177 />
178 <Tool 178 <Tool
179 Name="VCCLCompilerTool" 179 Name="VCCLCompilerTool"
180 AdditionalOptions="/Oy-" 180 AdditionalOptions="/Oy-"
181 Optimization="0" 181 Optimization="0"
182 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\" 182 AdditionalIncludeDirectories="..\llcommon;..\..\libraries\i686-win32\include;..\..\libraries\include\"
183 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE" 183 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
184 RuntimeLibrary="0" 184 RuntimeLibrary="0"
185 StructMemberAlignment="0" 185 StructMemberAlignment="0"
186 TreatWChar_tAsBuiltInType="false" 186 TreatWChar_tAsBuiltInType="false"
187 ForceConformanceInForLoopScope="true" 187 ForceConformanceInForLoopScope="true"
188 UsePrecompiledHeader="0" 188 UsePrecompiledHeader="0"
189 BrowseInformation="0" 189 BrowseInformation="0"
190 WarningLevel="3" 190 WarningLevel="3"
191 WarnAsError="true" 191 WarnAsError="true"
192 Detect64BitPortabilityProblems="false" 192 Detect64BitPortabilityProblems="false"
193 DebugInformationFormat="3" 193 DebugInformationFormat="3"
194 /> 194 />
195 <Tool 195 <Tool
196 Name="VCManagedResourceCompilerTool" 196 Name="VCManagedResourceCompilerTool"
197 /> 197 />
198 <Tool 198 <Tool
199 Name="VCResourceCompilerTool" 199 Name="VCResourceCompilerTool"
200 /> 200 />
201 <Tool 201 <Tool
202 Name="VCPreLinkEventTool" 202 Name="VCPreLinkEventTool"
203 /> 203 />
204 <Tool 204 <Tool
205 Name="VCLibrarianTool" 205 Name="VCLibrarianTool"
206 OutputFile="$(OutDir)/llmath.lib" 206 OutputFile="$(OutDir)/llmath.lib"
207 /> 207 />
208 <Tool 208 <Tool
209 Name="VCALinkTool" 209 Name="VCALinkTool"
210 /> 210 />
211 <Tool 211 <Tool
212 Name="VCXDCMakeTool" 212 Name="VCXDCMakeTool"
213 /> 213 />
214 <Tool 214 <Tool
215 Name="VCBscMakeTool" 215 Name="VCBscMakeTool"
216 /> 216 />
217 <Tool 217 <Tool
218 Name="VCFxCopTool" 218 Name="VCFxCopTool"
219 /> 219 />
220 <Tool 220 <Tool
221 Name="VCPostBuildEventTool" 221 Name="VCPostBuildEventTool"
222 /> 222 />
223 </Configuration> 223 </Configuration>
224 </Configurations> 224 </Configurations>
225 <References> 225 <References>
226 </References> 226 </References>
227 <Files> 227 <Files>
228 <Filter 228 <Filter
229 Name="Source Files" 229 Name="Source Files"
230 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" 230 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
231 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" 231 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
232 > 232 >
233 <File 233 <File
234 RelativePath=".\llbboxlocal.cpp" 234 RelativePath=".\llbboxlocal.cpp"
235 > 235 >
236 </File> 236 </File>
237 <File 237 <File
238 RelativePath=".\llcamera.cpp" 238 RelativePath=".\llcamera.cpp"
239 > 239 >
240 </File> 240 </File>
241 <File 241 <File
242 RelativePath=".\llcoordframe.cpp" 242 RelativePath=".\llcoordframe.cpp"
243 > 243 >
244 </File> 244 </File>
245 <File 245 <File
246 RelativePath=".\llcrc.cpp" 246 RelativePath=".\llcrc.cpp"
247 > 247 >
248 </File> 248 </File>
249 <File 249 <File
250 RelativePath=".\llmd5.cpp" 250 RelativePath=".\llmd5.cpp"
251 > 251 >
252 </File> 252 </File>
253 <File 253 <File
254 RelativePath=".\llperlin.cpp" 254 RelativePath=".\llperlin.cpp"
255 > 255 >
256 </File> 256 </File>
257 <File 257 <File
258 RelativePath=".\llquaternion.cpp" 258 RelativePath=".\llquaternion.cpp"
259 > 259 >
260 </File> 260 </File>
261 <File 261 <File
262 RelativePath=".\llrand.cpp" 262 RelativePath=".\llrand.cpp"
263 > 263 >
264 </File> 264 </File>
265 <File 265 <File
266 RelativePath=".\llrect.cpp" 266 RelativePath=".\llrect.cpp"
267 > 267 >
268 </File> 268 </File>
269 <File 269 <File
270 RelativePath=".\lluuid.cpp" 270 RelativePath=".\lluuid.cpp"
271 > 271 >
272 </File> 272 </File>
273 <File 273 <File
274 RelativePath=".\llvolume.cpp" 274 RelativePath=".\llvolume.cpp"
275 > 275 >
276 </File> 276 </File>
277 <File 277 <File
278 RelativePath=".\llvolumemgr.cpp" 278 RelativePath=".\llvolumemgr.cpp"
279 > 279 >
280 </File> 280 </File>
281 <File 281 <File
282 RelativePath=".\m3math.cpp" 282 RelativePath=".\m3math.cpp"
283 > 283 >
284 </File> 284 </File>
285 <File 285 <File
286 RelativePath=".\m4math.cpp" 286 RelativePath=".\m4math.cpp"
287 > 287 >
288 </File> 288 </File>
289 <File 289 <File
290 RelativePath=".\raytrace.cpp" 290 RelativePath=".\raytrace.cpp"
291 > 291 >
292 </File> 292 </File>
293 <File 293 <File
294 RelativePath=".\v2math.cpp" 294 RelativePath=".\v2math.cpp"
295 > 295 >
296 </File> 296 </File>
297 <File 297 <File
298 RelativePath=".\v3color.cpp" 298 RelativePath=".\v3color.cpp"
299 > 299 >
300 </File> 300 </File>
301 <File 301 <File
302 RelativePath=".\v3dmath.cpp" 302 RelativePath=".\v3dmath.cpp"
303 > 303 >
304 </File> 304 </File>
305 <File 305 <File
306 RelativePath=".\v3math.cpp" 306 RelativePath=".\v3math.cpp"
307 > 307 >
308 </File> 308 </File>
309 <File 309 <File
310 RelativePath=".\v4color.cpp" 310 RelativePath=".\v4color.cpp"
311 > 311 >
312 </File> 312 </File>
313 <File 313 <File
314 RelativePath=".\v4coloru.cpp" 314 RelativePath=".\v4coloru.cpp"
315 > 315 >
316 </File> 316 </File>
317 <File 317 <File
318 RelativePath=".\v4math.cpp" 318 RelativePath=".\v4math.cpp"
319 > 319 >
320 </File> 320 </File>
321 <File 321 <File
322 RelativePath=".\xform.cpp" 322 RelativePath=".\xform.cpp"
323 > 323 >
324 </File> 324 </File>
325 </Filter> 325 </Filter>
326 <Filter 326 <Filter
327 Name="Header Files" 327 Name="Header Files"
328 Filter="h;hpp;hxx;hm;inl;inc;xsd" 328 Filter="h;hpp;hxx;hm;inl;inc;xsd"
329 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" 329 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
330 > 330 >
331 <File 331 <File
332 RelativePath=".\llbboxlocal.h" 332 RelativePath=".\llbboxlocal.h"
333 > 333 >
334 </File> 334 </File>
335 <File 335 <File
336 RelativePath=".\llcamera.h" 336 RelativePath=".\llcamera.h"
337 > 337 >
338 </File> 338 </File>
339 <File 339 <File
340 RelativePath=".\llcoord.h" 340 RelativePath=".\llcoord.h"
341 > 341 >
342 </File> 342 </File>
343 <File 343 <File
344 RelativePath=".\llcoordframe.h" 344 RelativePath=".\llcoordframe.h"
345 > 345 >
346 </File> 346 </File>
347 <File 347 <File
348 RelativePath=".\llcrc.h" 348 RelativePath=".\llcrc.h"
349 > 349 >
350 </File> 350 </File>
351 <File 351 <File
352 RelativePath=".\llinterp.h" 352 RelativePath=".\llinterp.h"
353 > 353 >
354 </File> 354 </File>
355 <File 355 <File
356 RelativePath=".\llmath.h" 356 RelativePath=".\llmath.h"
357 > 357 >
358 </File> 358 </File>
359 <File 359 <File
360 RelativePath=".\llmd5.h" 360 RelativePath=".\llmd5.h"
361 > 361 >
362 </File> 362 </File>
363 <File 363 <File
364 RelativePath=".\lloctree.h" 364 RelativePath=".\lloctree.h"
365 > 365 >
366 </File> 366 </File>
367 <File 367 <File
368 RelativePath=".\llperlin.h" 368 RelativePath=".\llperlin.h"
369 > 369 >
370 </File> 370 </File>
371 <File 371 <File
372 RelativePath=".\llquantize.h" 372 RelativePath=".\llquantize.h"
373 > 373 >
374 </File> 374 </File>
375 <File 375 <File
376 RelativePath=".\llquaternion.h" 376 RelativePath=".\llquaternion.h"
377 > 377 >
378 </File> 378 </File>
379 <File 379 <File
380 RelativePath=".\llrand.h" 380 RelativePath=".\llrand.h"
381 > 381 >
382 </File> 382 </File>
383 <File 383 <File
384 RelativePath=".\llrect.h" 384 RelativePath=".\llrect.h"
385 > 385 >
386 </File> 386 </File>
387 <File 387 <File
388 RelativePath=".\lltreenode.h" 388 RelativePath=".\lltreenode.h"
389 > 389 >
390 </File> 390 </File>
391 <File 391 <File
392 RelativePath=".\lluuid.h" 392 RelativePath=".\lluuid.h"
393 > 393 >
394 </File> 394 </File>
395 <File 395 <File
396 RelativePath=".\llv4math.h" 396 RelativePath=".\llv4math.h"
397 > 397 >
398 </File> 398 </File>
399 <File 399 <File
400 RelativePath=".\llv4matrix3.h" 400 RelativePath=".\llv4matrix3.h"
401 > 401 >
402 </File> 402 </File>
403 <File 403 <File
404 RelativePath=".\llv4matrix4.h" 404 RelativePath=".\llv4matrix4.h"
405 > 405 >
406 </File> 406 </File>
407 <File 407 <File
408 RelativePath=".\llv4vector3.h" 408 RelativePath=".\llv4vector3.h"
409 > 409 >
410 </File> 410 </File>
411 <File 411 <File
412 RelativePath=".\llvolume.h" 412 RelativePath=".\llvolume.h"
413 > 413 >
414 </File> 414 </File>
415 <File 415 <File
416 RelativePath=".\llvolumemgr.h" 416 RelativePath=".\llvolumemgr.h"
417 > 417 >
418 </File> 418 </File>
419 <File 419 <File
420 RelativePath=".\m3math.h" 420 RelativePath=".\m3math.h"
421 > 421 >
422 </File> 422 </File>
423 <File 423 <File
424 RelativePath=".\m4math.h" 424 RelativePath=".\m4math.h"
425 > 425 >
426 </File> 426 </File>
427 <File 427 <File
428 RelativePath=".\raytrace.h" 428 RelativePath=".\raytrace.h"
429 > 429 >
430 </File> 430 </File>
431 <File 431 <File
432 RelativePath=".\v2math.h" 432 RelativePath=".\v2math.h"
433 > 433 >
434 </File> 434 </File>
435 <File 435 <File
436 RelativePath=".\v3color.h" 436 RelativePath=".\v3color.h"
437 > 437 >
438 </File> 438 </File>
439 <File 439 <File
440 RelativePath=".\v3dmath.h" 440 RelativePath=".\v3dmath.h"
441 > 441 >
442 </File> 442 </File>
443 <File 443 <File
444 RelativePath=".\v3math.h" 444 RelativePath=".\v3math.h"
445 > 445 >
446 </File> 446 </File>
447 <File 447 <File
448 RelativePath=".\v4color.h" 448 RelativePath=".\v4color.h"
449 > 449 >
450 </File> 450 </File>
451 <File 451 <File
452 RelativePath=".\v4coloru.h" 452 RelativePath=".\v4coloru.h"
453 > 453 >
454 </File> 454 </File>
455 <File 455 <File
456 RelativePath=".\v4math.h" 456 RelativePath=".\v4math.h"
457 > 457 >
458 </File> 458 </File>
459 <File 459 <File
460 RelativePath=".\xform.h" 460 RelativePath=".\xform.h"
461 > 461 >
462 </File> 462 </File>
463 </Filter> 463 </Filter>
464 <Filter 464 <Filter
465 Name="Resource Files" 465 Name="Resource Files"
466 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" 466 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
467 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" 467 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
468 > 468 >
469 </Filter> 469 </Filter>
470 </Files> 470 </Files>
471 <Globals> 471 <Globals>
472 </Globals> 472 </Globals>
473</VisualStudioProject> 473</VisualStudioProject>
diff --git a/linden/indra/llmath/lloctree.h b/linden/indra/llmath/lloctree.h
index 6eee9fb..203cb41 100644
--- a/linden/indra/llmath/lloctree.h
+++ b/linden/indra/llmath/lloctree.h
@@ -47,10 +47,9 @@
47#if LL_DARWIN 47#if LL_DARWIN
48#define LL_OCTREE_MAX_CAPACITY 32 48#define LL_OCTREE_MAX_CAPACITY 32
49#else 49#else
50#define LL_OCTREE_MAX_CAPACITY 256 50#define LL_OCTREE_MAX_CAPACITY 128
51#endif 51#endif
52 52
53template <class T> class LLOctreeState;
54template <class T> class LLOctreeNode; 53template <class T> class LLOctreeNode;
55 54
56template <class T> 55template <class T>
@@ -64,15 +63,27 @@ public:
64 virtual void handleChildRemoval(const oct_node* parent, const oct_node* child) = 0; 63 virtual void handleChildRemoval(const oct_node* parent, const oct_node* child) = 0;
65}; 64};
66 65
66template <class T>
67class LLOctreeTraveler : public LLTreeTraveler<T>
68{
69public:
70 virtual void traverse(const LLTreeNode<T>* node);
71 virtual void visit(const LLTreeNode<T>* state) { }
72 virtual void visit(const LLOctreeNode<T>* branch) = 0;
73};
67 74
68template <class T> 75template <class T>
69class LLOctreeNode : public LLTreeNode<T> 76class LLOctreeNode : public LLTreeNode<T>
70{ 77{
71public: 78public:
72 79 typedef LLOctreeTraveler<T> oct_traveler;
80 typedef LLTreeTraveler<T> tree_traveler;
81 typedef typename std::set<LLPointer<T> > element_list;
82 typedef typename std::set<LLPointer<T> >::iterator element_iter;
83 typedef typename std::set<LLPointer<T> >::const_iterator const_element_iter;
84 typedef typename std::vector<LLTreeListener<T>*>::iterator tree_listener_iter;
85 typedef typename std::vector<LLOctreeNode<T>* > child_list;
73 typedef LLTreeNode<T> BaseType; 86 typedef LLTreeNode<T> BaseType;
74 typedef LLTreeState<T> tree_state;
75 typedef LLOctreeState<T> oct_state;
76 typedef LLOctreeNode<T> oct_node; 87 typedef LLOctreeNode<T> oct_node;
77 typedef LLOctreeListener<T> oct_listener; 88 typedef LLOctreeListener<T> oct_listener;
78 89
@@ -82,11 +93,9 @@ public:
82 93
83 LLOctreeNode( LLVector3d center, 94 LLOctreeNode( LLVector3d center,
84 LLVector3d size, 95 LLVector3d size,
85 tree_state* state,
86 BaseType* parent, 96 BaseType* parent,
87 U8 octant = 255) 97 U8 octant = 255)
88 : BaseType(state), 98 : mParent((oct_node*)parent),
89 mParent((oct_node*)parent),
90 mCenter(center), 99 mCenter(center),
91 mSize(size), 100 mSize(size),
92 mOctant(octant) 101 mOctant(octant)
@@ -96,9 +105,19 @@ public:
96 { 105 {
97 mOctant = ((oct_node*) mParent)->getOctant(mCenter.mdV); 106 mOctant = ((oct_node*) mParent)->getOctant(mCenter.mdV);
98 } 107 }
108
109 clearChildren();
99 } 110 }
100 111
101 ~LLOctreeNode() { BaseType::destroyListeners(); delete this->mState; } 112 virtual ~LLOctreeNode()
113 {
114 BaseType::destroyListeners();
115
116 for (U32 i = 0; i < getChildCount(); i++)
117 {
118 delete getChild(i);
119 }
120 }
102 121
103 inline const BaseType* getParent() const { return mParent; } 122 inline const BaseType* getParent() const { return mParent; }
104 inline void setParent(BaseType* parent) { mParent = (oct_node*) parent; } 123 inline void setParent(BaseType* parent) { mParent = (oct_node*) parent; }
@@ -106,25 +125,12 @@ public:
106 inline const LLVector3d& getSize() const { return mSize; } 125 inline const LLVector3d& getSize() const { return mSize; }
107 inline void setCenter(LLVector3d center) { mCenter = center; } 126 inline void setCenter(LLVector3d center) { mCenter = center; }
108 inline void setSize(LLVector3d size) { mSize = size; } 127 inline void setSize(LLVector3d size) { mSize = size; }
109 inline bool balance() { return getOctState()->balance(); } 128 inline oct_node* getNodeAt(T* data) { return getNodeAt(data->getPositionGroup(), data->getBinRadius()); }
110 inline void validate() { getOctState()->validate(); }
111 inline U32 getChildCount() const { return getOctState()->getChildCount(); }
112 inline oct_node* getChild(U32 index) { return getOctState()->getChild(index); }
113 inline const oct_node* getChild(U32 index) const { return getOctState()->getChild(index); }
114 inline U32 getElementCount() const { return getOctState()->getElementCount(); }
115 inline void removeByAddress(T* data) { getOctState()->removeByAddress(data); }
116 inline bool hasLeafState() const { return getOctState()->isLeaf(); }
117 inline void destroy() { getOctState()->destroy(); }
118 inline oct_node* getNodeAt(T* data) { return getNodeAt(data->getPositionGroup(), data->getBinRadius()); }
119 inline oct_node* getNodeAt(const LLVector3d& pos, const F64& rad) { return getOctState()->getNodeAt(pos, rad); }
120 inline U8 getOctant() const { return mOctant; } 129 inline U8 getOctant() const { return mOctant; }
121 inline void setOctant(U8 octant) { mOctant = octant; } 130 inline void setOctant(U8 octant) { mOctant = octant; }
122 inline const oct_state* getOctState() const { return (const oct_state*) BaseType::mState; }
123 inline oct_state* getOctState() { return (oct_state*) BaseType::mState; }
124 inline const oct_node* getOctParent() const { return (const oct_node*) getParent(); } 131 inline const oct_node* getOctParent() const { return (const oct_node*) getParent(); }
125 inline oct_node* getOctParent() { return (oct_node*) getParent(); } 132 inline oct_node* getOctParent() { return (oct_node*) getParent(); }
126 inline void deleteChild(oct_node* child) { getOctState()->deleteChild(child); } 133
127
128 U8 getOctant(const F64 pos[]) const //get the octant pos is in 134 U8 getOctant(const F64 pos[]) const //get the octant pos is in
129 { 135 {
130 U8 ret = 0; 136 U8 ret = 0;
@@ -205,9 +211,9 @@ public:
205 (radius <= p_size && radius > size); 211 (radius <= p_size && radius > size);
206 } 212 }
207 213
208 static void pushCenter(LLVector3d &center, LLVector3d &size, T* data) 214 static void pushCenter(LLVector3d &center, const LLVector3d &size, const T* data)
209 { 215 {
210 LLVector3d pos(data->getPositionGroup()); 216 const LLVector3d& pos = data->getPositionGroup();
211 for (U32 i = 0; i < 3; i++) 217 for (U32 i = 0; i < 3; i++)
212 { 218 {
213 if (pos.mdV[i] > center.mdV[i]) 219 if (pos.mdV[i] > center.mdV[i])
@@ -221,76 +227,25 @@ public:
221 } 227 }
222 } 228 }
223 229
224protected: 230 void accept(oct_traveler* visitor) { visitor->visit(this); }
225 oct_node* mParent; 231 virtual bool isLeaf() const { return mChild.empty(); }
226 LLVector3d mCenter;
227 LLVector3d mSize;
228 LLVector3d mMax;
229 LLVector3d mMin;
230 U8 mOctant;
231};
232
233template <class T>
234class LLOctreeTraveler : public LLTreeTraveler<T>
235{
236public:
237 virtual void traverse(const LLTreeNode<T>* node);
238 virtual void visit(const LLTreeState<T>* state) { }
239 virtual void visit(const LLOctreeState<T>* branch) = 0;
240};
241
242//will pass requests to a child, might make a new child
243template <class T>
244class LLOctreeState : public LLTreeState<T>
245{
246public:
247 typedef LLTreeState<T> BaseType;
248 typedef LLOctreeTraveler<T> oct_traveler;
249 typedef LLOctreeNode<T> oct_node;
250 typedef LLOctreeListener<T> oct_listener;
251 typedef LLTreeTraveler<T> tree_traveler;
252 typedef typename std::set<LLPointer<T> > element_list;
253 typedef typename std::set<LLPointer<T> >::iterator element_iter;
254 typedef typename std::set<LLPointer<T> >::const_iterator const_element_iter;
255 typedef typename std::vector<LLTreeListener<T>*>::iterator tree_listener_iter;
256 typedef typename std::vector<LLOctreeNode<T>* > child_list;
257 232
258 LLOctreeState(oct_node* node = NULL): BaseType(node) { this->clearChildren(); } 233 U32 getElementCount() const { return mData.size(); }
259 virtual ~LLOctreeState() 234 element_list& getData() { return mData; }
260 { 235 const element_list& getData() const { return mData; }
261 for (U32 i = 0; i < getChildCount(); i++)
262 {
263 delete getChild(i);
264 }
265 }
266
267 236
268 virtual void accept(oct_traveler* visitor) { visitor->visit(this); } 237 U32 getChildCount() const { return mChild.size(); }
269 virtual bool isLeaf() const { return mChild.empty(); } 238 oct_node* getChild(U32 index) { return mChild[index]; }
239 const oct_node* getChild(U32 index) const { return mChild[index]; }
240 child_list& getChildren() { return mChild; }
241 const child_list& getChildren() const { return mChild; }
270 242
271 virtual U32 getElementCount() const { return mData.size(); } 243 void accept(tree_traveler* visitor) const { visitor->visit(this); }
272 virtual element_list& getData() { return mData; } 244 void accept(oct_traveler* visitor) const { visitor->visit(this); }
273 virtual const element_list& getData() const { return mData; }
274 245
275 virtual U32 getChildCount() const { return mChild.size(); } 246 oct_node* getNodeAt(const LLVector3d& pos, const F64& rad)
276 virtual oct_node* getChild(U32 index) { return mChild[index]; }
277 virtual const oct_node* getChild(U32 index) const { return mChild[index]; }
278 virtual child_list& getChildren() { return mChild; }
279 virtual const child_list& getChildren() const { return mChild; }
280
281 virtual void accept(tree_traveler* visitor) const { visitor->visit(this); }
282 virtual void accept(oct_traveler* visitor) const { visitor->visit(this); }
283 const oct_node* getOctNode() const { return (const oct_node*) BaseType::getNode(); }
284 oct_node* getOctNode() { return (oct_node*) BaseType::getNode(); }
285
286 virtual oct_node* getNodeAt(T* data)
287 {
288 return getNodeAt(data->getPositionGroup(), data->getBinRadius());
289 }
290
291 virtual oct_node* getNodeAt(const LLVector3d& pos, const F64& rad)
292 { 247 {
293 LLOctreeNode<T>* node = getOctNode(); 248 LLOctreeNode<T>* node = this;
294 249
295 if (node->isInside(pos, rad)) 250 if (node->isInside(pos, rad))
296 { 251 {
@@ -328,26 +283,19 @@ public:
328 { 283 {
329 if (data == NULL) 284 if (data == NULL)
330 { 285 {
331 OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE BRANCH !!!" << llendl; 286 //OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE BRANCH !!!" << llendl;
332 return false; 287 return false;
333 } 288 }
334 LLOctreeNode<T>* node = getOctNode(); 289 LLOctreeNode<T>* parent = getOctParent();
335 LLOctreeNode<T>* parent = node->getOctParent();
336 290
337 //is it here? 291 //is it here?
338 if (node->isInside(data->getPositionGroup())) 292 if (isInside(data->getPositionGroup()))
339 { 293 {
340 if (getElementCount() < LL_OCTREE_MAX_CAPACITY && 294 if (getElementCount() < LL_OCTREE_MAX_CAPACITY &&
341 (node->contains(data->getBinRadius()) || 295 (contains(data->getBinRadius()) ||
342 (data->getBinRadius() > node->getSize().mdV[0] && 296 (data->getBinRadius() > getSize().mdV[0] &&
343 parent && parent->getElementCount() >= LL_OCTREE_MAX_CAPACITY))) 297 parent && parent->getElementCount() >= LL_OCTREE_MAX_CAPACITY)))
344 { //it belongs here 298 { //it belongs here
345 if (data == NULL)
346 {
347 OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE LEAF !!!" << llendl;
348 return false;
349 }
350
351#if LL_OCTREE_PARANOIA_CHECK 299#if LL_OCTREE_PARANOIA_CHECK
352 //if this is a redundant insertion, error out (should never happen) 300 //if this is a redundant insertion, error out (should never happen)
353 if (mData.find(data) != mData.end()) 301 if (mData.find(data) != mData.end())
@@ -358,6 +306,7 @@ public:
358#endif 306#endif
359 307
360 mData.insert(data); 308 mData.insert(data);
309 BaseType::insert(data);
361 return true; 310 return true;
362 } 311 }
363 else 312 else
@@ -375,8 +324,8 @@ public:
375 } 324 }
376 325
377 //it's here, but no kids are in the right place, make a new kid 326 //it's here, but no kids are in the right place, make a new kid
378 LLVector3d center(node->getCenter()); 327 LLVector3d center(getCenter());
379 LLVector3d size(node->getSize()*0.5); 328 LLVector3d size(getSize()*0.5);
380 329
381 //push center in direction of data 330 //push center in direction of data
382 LLOctreeNode<T>::pushCenter(center, size, data); 331 LLOctreeNode<T>::pushCenter(center, size, data);
@@ -386,7 +335,6 @@ public:
386 { 335 {
387 //this really isn't possible, something bad has happened 336 //this really isn't possible, something bad has happened
388 OCT_ERRS << "Octree detected floating point error and gave up." << llendl; 337 OCT_ERRS << "Octree detected floating point error and gave up." << llendl;
389 //bool check = node->isInside(data);
390 return false; 338 return false;
391 } 339 }
392 340
@@ -396,25 +344,25 @@ public:
396 if (mChild[i]->getCenter() == center) 344 if (mChild[i]->getCenter() == center)
397 { 345 {
398 OCT_ERRS << "Octree detected duplicate child center and gave up." << llendl; 346 OCT_ERRS << "Octree detected duplicate child center and gave up." << llendl;
399 //bool check = node->isInside(data);
400 //check = getChild(i)->isInside(data);
401 return false; 347 return false;
402 } 348 }
403 } 349 }
404#endif 350#endif
405 351
406 //make the new kid 352 //make the new kid
407 LLOctreeState<T>* newstate = new LLOctreeState<T>(); 353 child = new LLOctreeNode<T>(center, size, this);
408 child = new LLOctreeNode<T>(center, size, newstate, node);
409 addChild(child); 354 addChild(child);
410 355
411 child->insert(data); 356 child->insert(data);
412 } 357 }
413 } 358 }
414 else 359 else
415 { 360 {
416 //it's not in here, give it to the root 361 //it's not in here, give it to the root
417 LLOctreeNode<T>* parent = node->getOctParent(); 362 //OCT_ERRS << "Octree insertion failed, starting over from root!" << llendl;
363
364 oct_node* node = this;
365
418 while (parent) 366 while (parent)
419 { 367 {
420 node = parent; 368 node = parent;
@@ -427,22 +375,20 @@ public:
427 return false; 375 return false;
428 } 376 }
429 377
430 virtual bool remove(T* data) 378 bool remove(T* data)
431 { 379 {
432 oct_node* node = getOctNode();
433
434 if (mData.find(data) != mData.end()) 380 if (mData.find(data) != mData.end())
435 { //we have data 381 { //we have data
436 mData.erase(data); 382 mData.erase(data);
437 node->notifyRemoval(data); 383 notifyRemoval(data);
438 checkAlive(); 384 checkAlive();
439 return true; 385 return true;
440 } 386 }
441 else if (node->isInside(data)) 387 else if (isInside(data))
442 { 388 {
443 oct_node* dest = getNodeAt(data); 389 oct_node* dest = getNodeAt(data);
444 390
445 if (dest != node) 391 if (dest != this)
446 { 392 {
447 return dest->remove(data); 393 return dest->remove(data);
448 } 394 }
@@ -451,7 +397,9 @@ public:
451 //SHE'S GONE MISSING... 397 //SHE'S GONE MISSING...
452 //none of the children have it, let's just brute force this bastard out 398 //none of the children have it, let's just brute force this bastard out
453 //starting with the root node (UGLY CODE COMETH!) 399 //starting with the root node (UGLY CODE COMETH!)
454 oct_node* parent = node->getOctParent(); 400 oct_node* parent = getOctParent();
401 oct_node* node = this;
402
455 while (parent != NULL) 403 while (parent != NULL)
456 { 404 {
457 node = parent; 405 node = parent;
@@ -464,12 +412,12 @@ public:
464 return true; 412 return true;
465 } 413 }
466 414
467 virtual void removeByAddress(T* data) 415 void removeByAddress(T* data)
468 { 416 {
469 if (mData.find(data) != mData.end()) 417 if (mData.find(data) != mData.end())
470 { 418 {
471 mData.erase(data); 419 mData.erase(data);
472 getOctNode()->notifyRemoval(data); 420 notifyRemoval(data);
473 llwarns << "FOUND!" << llendl; 421 llwarns << "FOUND!" << llendl;
474 checkAlive(); 422 checkAlive();
475 return; 423 return;
@@ -482,20 +430,18 @@ public:
482 } 430 }
483 } 431 }
484 432
485 virtual void clearChildren() 433 void clearChildren()
486 { 434 {
487 mChild.clear(); 435 mChild.clear();
488 } 436 }
489 437
490 virtual void validate() 438 void validate()
491 { 439 {
492#if LL_OCTREE_PARANOIA_CHECK 440#if LL_OCTREE_PARANOIA_CHECK
493 LLOctreeNode<T>* node = this->getOctNode();
494
495 for (U32 i = 0; i < getChildCount(); i++) 441 for (U32 i = 0; i < getChildCount(); i++)
496 { 442 {
497 mChild[i]->validate(); 443 mChild[i]->validate();
498 if (mChild[i]->getParent() != node) 444 if (mChild[i]->getParent() != this)
499 { 445 {
500 llerrs << "Octree child has invalid parent." << llendl; 446 llerrs << "Octree child has invalid parent." << llendl;
501 } 447 }
@@ -508,7 +454,7 @@ public:
508 return false; 454 return false;
509 } 455 }
510 456
511 virtual void destroy() 457 void destroy()
512 { 458 {
513 for (U32 i = 0; i < getChildCount(); i++) 459 for (U32 i = 0; i < getChildCount(); i++)
514 { 460 {
@@ -517,7 +463,7 @@ public:
517 } 463 }
518 } 464 }
519 465
520 virtual void addChild(oct_node* child, BOOL silent = FALSE) 466 void addChild(oct_node* child, BOOL silent = FALSE)
521 { 467 {
522#if LL_OCTREE_PARANOIA_CHECK 468#if LL_OCTREE_PARANOIA_CHECK
523 for (U32 i = 0; i < getChildCount(); i++) 469 for (U32 i = 0; i < getChildCount(); i++)
@@ -539,27 +485,24 @@ public:
539#endif 485#endif
540 486
541 mChild.push_back(child); 487 mChild.push_back(child);
542 child->setParent(getOctNode()); 488 child->setParent(this);
543 489
544 if (!silent) 490 if (!silent)
545 { 491 {
546 oct_node* node = getOctNode(); 492 for (U32 i = 0; i < this->getListenerCount(); i++)
547
548 for (U32 i = 0; i < node->getListenerCount(); i++)
549 { 493 {
550 oct_listener* listener = node->getOctListener(i); 494 oct_listener* listener = getOctListener(i);
551 listener->handleChildAddition(node, child); 495 listener->handleChildAddition(this, child);
552 } 496 }
553 } 497 }
554 } 498 }
555 499
556 virtual void removeChild(U8 index, BOOL destroy = FALSE) 500 void removeChild(U8 index, BOOL destroy = FALSE)
557 { 501 {
558 oct_node* node = getOctNode(); 502 for (U32 i = 0; i < this->getListenerCount(); i++)
559 for (U32 i = 0; i < node->getListenerCount(); i++)
560 { 503 {
561 oct_listener* listener = node->getOctListener(i); 504 oct_listener* listener = getOctListener(i);
562 listener->handleChildRemoval(node, getChild(index)); 505 listener->handleChildRemoval(this, getChild(index));
563 } 506 }
564 507
565 if (destroy) 508 if (destroy)
@@ -572,20 +515,19 @@ public:
572 checkAlive(); 515 checkAlive();
573 } 516 }
574 517
575 virtual void checkAlive() 518 void checkAlive()
576 { 519 {
577 if (getChildCount() == 0 && getElementCount() == 0) 520 if (getChildCount() == 0 && getElementCount() == 0)
578 { 521 {
579 oct_node* node = getOctNode(); 522 oct_node* parent = getOctParent();
580 oct_node* parent = node->getOctParent();
581 if (parent) 523 if (parent)
582 { 524 {
583 parent->deleteChild(node); 525 parent->deleteChild(this);
584 } 526 }
585 } 527 }
586 } 528 }
587 529
588 virtual void deleteChild(oct_node* node) 530 void deleteChild(oct_node* node)
589 { 531 {
590 for (U32 i = 0; i < getChildCount(); i++) 532 for (U32 i = 0; i < getChildCount(); i++)
591 { 533 {
@@ -596,55 +538,62 @@ public:
596 } 538 }
597 } 539 }
598 540
599 OCT_ERRS << "Octree failed to delete requested child." << llendl; 541 //OCT_ERRS << "Octree failed to delete requested child." << llendl;
600 } 542 }
601 543
602protected: 544protected:
603 child_list mChild; 545 child_list mChild;
604 element_list mData; 546 element_list mData;
547 oct_node* mParent;
548 LLVector3d mCenter;
549 LLVector3d mSize;
550 LLVector3d mMax;
551 LLVector3d mMin;
552 U8 mOctant;
605}; 553};
606 554
607//just like a branch, except it might expand the node it points to 555//just like a regular node, except it might expand on insert and compress on balance
608template <class T> 556template <class T>
609class LLOctreeRoot : public LLOctreeState<T> 557class LLOctreeRoot : public LLOctreeNode<T>
610{ 558{
611public: 559public:
612 typedef LLOctreeState<T> BaseType; 560 typedef LLOctreeNode<T> BaseType;
613 typedef LLOctreeNode<T> oct_node; 561 typedef LLOctreeNode<T> oct_node;
562
563 LLOctreeRoot( LLVector3d center,
564 LLVector3d size,
565 BaseType* parent)
566 : BaseType(center, size, parent)
567 {
568 }
614 569
615 LLOctreeRoot(oct_node* node = NULL) : BaseType(node) { } 570 bool isLeaf() { return false; }
616
617 oct_node* getOctNode() { return BaseType::getOctNode(); }
618 virtual bool isLeaf() { return false; }
619 571
620 virtual bool balance() 572 bool balance()
621 { 573 {
622 //the cached node might be invalid, so don't reference it
623 if (this->getChildCount() == 1 && 574 if (this->getChildCount() == 1 &&
624 !(this->mChild[0]->hasLeafState()) && 575 !(this->mChild[0]->isLeaf()) &&
625 this->mChild[0]->getElementCount() == 0) 576 this->mChild[0]->getElementCount() == 0)
626 { //if we have only one child and that child is an empty branch, make that child the root 577 { //if we have only one child and that child is an empty branch, make that child the root
627 BaseType* state = this->mChild[0]->getOctState();
628 oct_node* child = this->mChild[0]; 578 oct_node* child = this->mChild[0];
629 oct_node* root = getOctNode(); 579
630
631 //make the root node look like the child 580 //make the root node look like the child
632 root->setCenter(this->mChild[0]->getCenter()); 581 this->setCenter(this->mChild[0]->getCenter());
633 root->setSize(this->mChild[0]->getSize()); 582 this->setSize(this->mChild[0]->getSize());
634 root->updateMinMax(); 583 this->updateMinMax();
635 584
636 //reset root node child list 585 //reset root node child list
637 this->clearChildren(); 586 this->clearChildren();
638 587
639 //copy the child's children into the root node silently 588 //copy the child's children into the root node silently
640 //(don't notify listeners of addition) 589 //(don't notify listeners of addition)
641 for (U32 i = 0; i < state->getChildCount(); i++) 590 for (U32 i = 0; i < child->getChildCount(); i++)
642 { 591 {
643 addChild(state->getChild(i), TRUE); 592 addChild(child->getChild(i), TRUE);
644 } 593 }
645 594
646 //destroy child 595 //destroy child
647 state->clearChildren(); 596 child->clearChildren();
648 delete child; 597 delete child;
649 } 598 }
650 599
@@ -652,69 +601,90 @@ public:
652 } 601 }
653 602
654 // LLOctreeRoot::insert 603 // LLOctreeRoot::insert
655 virtual bool insert(T* data) 604 bool insert(T* data)
656 { 605 {
657 if (data == NULL) 606 if (data == NULL)
658 { 607 {
659 OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE ROOT !!!" << llendl; 608 //OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE ROOT !!!" << llendl;
660 return false; 609 return false;
661 } 610 }
662 611
663 if (data->getBinRadius() > 4096.0) 612 if (data->getBinRadius() > 4096.0)
664 { 613 {
665 OCT_ERRS << "!!! ELEMENT EXCEDES MAXIMUM SIZE IN OCTREE ROOT !!!" << llendl; 614 //OCT_ERRS << "!!! ELEMENT EXCEEDS MAXIMUM SIZE IN OCTREE ROOT !!!" << llendl;
615 return false;
666 } 616 }
667 617
668 LLOctreeNode<T>* node = getOctNode(); 618 const F64 MAX_MAG = 1024.0*1024.0;
669 if (node->getSize().mdV[0] > data->getBinRadius() && node->isInside(data->getPositionGroup())) 619
620 const LLVector3d& v = data->getPositionGroup();
621 if (!(fabs(v.mdV[0]-this->mCenter.mdV[0]) < MAX_MAG &&
622 fabs(v.mdV[1]-this->mCenter.mdV[1]) < MAX_MAG &&
623 fabs(v.mdV[2]-this->mCenter.mdV[2]) < MAX_MAG))
624 {
625 //OCT_ERRS << "!!! ELEMENT EXCEEDS RANGE OF SPATIAL PARTITION !!!" << llendl;
626 return false;
627 }
628
629 if (this->getSize().mdV[0] > data->getBinRadius() && isInside(data->getPositionGroup()))
670 { 630 {
671 //we got it, just act like a branch 631 //we got it, just act like a branch
672 LLOctreeState<T>::insert(data); 632 oct_node* node = getNodeAt(data);
633 if (node == this)
634 {
635 LLOctreeNode<T>::insert(data);
636 }
637 else
638 {
639 node->insert(data);
640 }
673 } 641 }
674 else if (this->getChildCount() == 0) 642 else if (this->getChildCount() == 0)
675 { 643 {
676 //first object being added, just wrap it up 644 //first object being added, just wrap it up
677 while (!(node->getSize().mdV[0] > data->getBinRadius() && node->isInside(data->getPositionGroup()))) 645 while (!(this->getSize().mdV[0] > data->getBinRadius() && isInside(data->getPositionGroup())))
678 { 646 {
679 LLVector3d center, size; 647 LLVector3d center, size;
680 center = node->getCenter(); 648 center = this->getCenter();
681 size = node->getSize(); 649 size = this->getSize();
682 LLOctreeNode<T>::pushCenter(center, size, data); 650 LLOctreeNode<T>::pushCenter(center, size, data);
683 node->setCenter(center); 651 this->setCenter(center);
684 node->setSize(size*2); 652 this->setSize(size*2);
685 node->updateMinMax(); 653 this->updateMinMax();
686 } 654 }
687 LLOctreeState<T>::insert(data); 655 LLOctreeNode<T>::insert(data);
688 } 656 }
689 else 657 else
690 { 658 {
691 //the data is outside the root node, we need to grow 659 while (!(this->getSize().mdV[0] > data->getBinRadius() && isInside(data->getPositionGroup())))
692 LLVector3d center(node->getCenter());
693 LLVector3d size(node->getSize());
694
695 //expand this node
696 LLVector3d newcenter(center);
697 LLOctreeNode<T>::pushCenter(newcenter, size, data);
698 node->setCenter(newcenter);
699 node->setSize(size*2);
700 node->updateMinMax();
701
702 //copy our children to a new branch
703 LLOctreeState<T>* newstate = new LLOctreeState<T>();
704 LLOctreeNode<T>* newnode = new LLOctreeNode<T>(center, size, newstate, node);
705
706 for (U32 i = 0; i < this->getChildCount(); i++)
707 { 660 {
708 LLOctreeNode<T>* child = this->getChild(i); 661 //the data is outside the root node, we need to grow
709 newstate->addChild(child); 662 LLVector3d center(this->getCenter());
710 } 663 LLVector3d size(this->getSize());
664
665 //expand this node
666 LLVector3d newcenter(center);
667 LLOctreeNode<T>::pushCenter(newcenter, size, data);
668 this->setCenter(newcenter);
669 this->setSize(size*2);
670 this->updateMinMax();
671
672 //copy our children to a new branch
673 LLOctreeNode<T>* newnode = new LLOctreeNode<T>(center, size, this);
674
675 for (U32 i = 0; i < this->getChildCount(); i++)
676 {
677 LLOctreeNode<T>* child = this->getChild(i);
678 newnode->addChild(child);
679 }
711 680
712 //clear our children and add the root copy 681 //clear our children and add the root copy
713 this->clearChildren(); 682 this->clearChildren();
714 addChild(newnode); 683 addChild(newnode);
684 }
715 685
716 //insert the data 686 //insert the data
717 node->insert(data); 687 insert(data);
718 } 688 }
719 689
720 return false; 690 return false;
@@ -726,13 +696,13 @@ public:
726// LLOctreeTraveler 696// LLOctreeTraveler
727//======================== 697//========================
728template <class T> 698template <class T>
729void LLOctreeTraveler<T>::traverse(const LLTreeNode<T>* node) 699void LLOctreeTraveler<T>::traverse(const LLTreeNode<T>* tree_node)
730{ 700{
731 const LLOctreeState<T>* state = (const LLOctreeState<T>*) node->getState(); 701 const LLOctreeNode<T>* node = (const LLOctreeNode<T>*) tree_node;
732 state->accept(this); 702 node->accept(this);
733 for (U32 i = 0; i < state->getChildCount(); i++) 703 for (U32 i = 0; i < node->getChildCount(); i++)
734 { 704 {
735 traverse(state->getChild(i)); 705 traverse(node->getChild(i));
736 } 706 }
737} 707}
738 708
diff --git a/linden/indra/llmath/llrect.h b/linden/indra/llmath/llrect.h
index 76b5a27..9aadf9f 100644
--- a/linden/indra/llmath/llrect.h
+++ b/linden/indra/llmath/llrect.h
@@ -152,68 +152,74 @@ public:
152 mBottom <= rect->mTop && rect->mBottom <= mTop ; 152 mBottom <= rect->mTop && rect->mBottom <= mTop ;
153 } 153 }
154 154
155 void set(Type left, Type top, Type right, Type bottom) 155 LLRectBase& set(Type left, Type top, Type right, Type bottom)
156 { 156 {
157 mLeft = left; 157 mLeft = left;
158 mTop = top; 158 mTop = top;
159 mRight = right; 159 mRight = right;
160 mBottom = bottom; 160 mBottom = bottom;
161 return *this;
161 } 162 }
162 163
163 // Note: follows GL_QUAD conventions: the top and right edges are not considered part of the rect 164 // Note: follows GL_QUAD conventions: the top and right edges are not considered part of the rect
164 void setOriginAndSize( Type left, Type bottom, Type width, Type height) 165 LLRectBase& setOriginAndSize( Type left, Type bottom, Type width, Type height)
165 { 166 {
166 mLeft = left; 167 mLeft = left;
167 mTop = bottom + height; 168 mTop = bottom + height;
168 mRight = left + width; 169 mRight = left + width;
169 mBottom = bottom; 170 mBottom = bottom;
171 return *this;
170 } 172 }
171 173
172 // Note: follows GL_QUAD conventions: the top and right edges are not considered part of the rect 174 // Note: follows GL_QUAD conventions: the top and right edges are not considered part of the rect
173 void setLeftTopAndSize( Type left, Type top, Type width, Type height) 175 LLRectBase& setLeftTopAndSize( Type left, Type top, Type width, Type height)
174 { 176 {
175 mLeft = left; 177 mLeft = left;
176 mTop = top; 178 mTop = top;
177 mRight = left + width; 179 mRight = left + width;
178 mBottom = top - height; 180 mBottom = top - height;
181 return *this;
179 } 182 }
180 183
181 void setCenterAndSize(Type x, Type y, Type width, Type height) 184 LLRectBase& setCenterAndSize(Type x, Type y, Type width, Type height)
182 { 185 {
183 mLeft = x - width/2; 186 mLeft = x - width/2;
184 mTop = y + height/2; 187 mTop = y + height/2;
185 mRight = x + width/2; 188 mRight = x + width/2;
186 mBottom = y - height/2; 189 mBottom = y - height/2;
190 return *this;
187 } 191 }
188 192
189 193
190 void translate(Type horiz, Type vertical) 194 LLRectBase& translate(Type horiz, Type vertical)
191 { 195 {
192 mLeft += horiz; 196 mLeft += horiz;
193 mRight += horiz; 197 mRight += horiz;
194 mTop += vertical; 198 mTop += vertical;
195 mBottom += vertical; 199 mBottom += vertical;
200 return *this;
196 } 201 }
197 202
198 void stretch( Type dx, Type dy) 203 LLRectBase& stretch( Type dx, Type dy)
199 { 204 {
200 mLeft -= dx; 205 mLeft -= dx;
201 mRight += dx; 206 mRight += dx;
202 mTop += dy; 207 mTop += dy;
203 mBottom -= dy; 208 mBottom -= dy;
204 makeValid(); 209 return makeValid();
205 } 210 }
206 211
207 void stretch( Type delta ) 212 LLRectBase& stretch( Type delta )
208 { 213 {
209 stretch(delta, delta); 214 stretch(delta, delta);
210 215 return *this;
211 } 216 }
212 217
213 void makeValid() 218 LLRectBase& makeValid()
214 { 219 {
215 mLeft = llmin(mLeft, mRight); 220 mLeft = llmin(mLeft, mRight);
216 mBottom = llmin(mBottom, mTop); 221 mBottom = llmin(mBottom, mTop);
222 return *this;
217 } 223 }
218 224
219 bool isNull() const 225 bool isNull() const
@@ -221,15 +227,16 @@ public:
221 return mLeft == mRight || mBottom == mTop; 227 return mLeft == mRight || mBottom == mTop;
222 } 228 }
223 229
224 void unionWith(const LLRectBase &other) 230 LLRectBase& unionWith(const LLRectBase &other)
225 { 231 {
226 mLeft = llmin(mLeft, other.mLeft); 232 mLeft = llmin(mLeft, other.mLeft);
227 mRight = llmax(mRight, other.mRight); 233 mRight = llmax(mRight, other.mRight);
228 mBottom = llmin(mBottom, other.mBottom); 234 mBottom = llmin(mBottom, other.mBottom);
229 mTop = llmax(mTop, other.mTop); 235 mTop = llmax(mTop, other.mTop);
236 return *this;
230 } 237 }
231 238
232 void intersectWith(const LLRectBase &other) 239 LLRectBase& intersectWith(const LLRectBase &other)
233 { 240 {
234 mLeft = llmax(mLeft, other.mLeft); 241 mLeft = llmax(mLeft, other.mLeft);
235 mRight = llmin(mRight, other.mRight); 242 mRight = llmin(mRight, other.mRight);
@@ -243,6 +250,7 @@ public:
243 { 250 {
244 mBottom = mTop; 251 mBottom = mTop;
245 } 252 }
253 return *this;
246 } 254 }
247 255
248 friend std::ostream &operator<<(std::ostream &s, const LLRectBase &rect) 256 friend std::ostream &operator<<(std::ostream &s, const LLRectBase &rect)
diff --git a/linden/indra/llmath/lltreenode.h b/linden/indra/llmath/lltreenode.h
index 160a5bd..64beed8 100644
--- a/linden/indra/llmath/lltreenode.h
+++ b/linden/indra/llmath/lltreenode.h
@@ -40,23 +40,6 @@ template <class T> class LLTreeTraveler;
40template <class T> class LLTreeListener; 40template <class T> class LLTreeListener;
41 41
42template <class T> 42template <class T>
43class LLTreeState
44{
45public:
46 LLTreeState(LLTreeNode<T>* node) { setNode(node); }
47 virtual ~LLTreeState() { };
48 virtual bool insert(T* data) = 0;
49 virtual bool remove(T* data) = 0;
50 virtual void setNode(LLTreeNode<T>* node);
51 virtual const LLTreeNode<T>* getNode() const { return mNode; }
52 virtual LLTreeNode<T>* getNode() { return mNode; }
53 virtual void accept(LLTreeTraveler<T>* traveler) const = 0;
54 virtual LLTreeListener<T>* getListener(U32 index) const;
55private:
56 LLTreeNode<T>* mNode;
57};
58
59template <class T>
60class LLTreeListener: public LLRefCount 43class LLTreeListener: public LLRefCount
61{ 44{
62public: 45public:
@@ -70,19 +53,14 @@ template <class T>
70class LLTreeNode 53class LLTreeNode
71{ 54{
72public: 55public:
73 LLTreeNode(LLTreeState<T>* state) { setState(state); }
74 virtual ~LLTreeNode(); 56 virtual ~LLTreeNode();
75 LLTreeState<T>* getState() { return mState; } 57
76 const LLTreeState<T>* getState() const { return mState; } 58 virtual bool insert(T* data);
77 59 virtual bool remove(T* data);
78 void setState(LLTreeState<T>* state); 60 virtual void notifyRemoval(T* data);
79 void insert(T* data); 61 virtual U32 getListenerCount() { return mListeners.size(); }
80 bool remove(T* data); 62 virtual LLTreeListener<T>* getListener(U32 index) const { return mListeners[index]; }
81 void notifyRemoval(T* data); 63 virtual void addListener(LLTreeListener<T>* listener) { mListeners.push_back(listener); }
82 inline U32 getListenerCount() { return mListeners.size(); }
83 inline LLTreeListener<T>* getListener(U32 index) const { return mListeners[index]; }
84 inline void addListener(LLTreeListener<T>* listener) { mListeners.push_back(listener); }
85 inline void removeListener(U32 index) { mListeners.erase(mListeners.begin()+index); }
86 64
87protected: 65protected:
88 void destroyListeners() 66 void destroyListeners()
@@ -94,7 +72,6 @@ protected:
94 mListeners.clear(); 72 mListeners.clear();
95 } 73 }
96 74
97 LLTreeState<T>* mState;
98public: 75public:
99 std::vector<LLPointer<LLTreeListener<T> > > mListeners; 76 std::vector<LLPointer<LLTreeListener<T> > > mListeners;
100}; 77};
@@ -105,7 +82,7 @@ class LLTreeTraveler
105public: 82public:
106 virtual ~LLTreeTraveler() { }; 83 virtual ~LLTreeTraveler() { };
107 virtual void traverse(const LLTreeNode<T>* node) = 0; 84 virtual void traverse(const LLTreeNode<T>* node) = 0;
108 virtual void visit(const LLTreeState<T>* state) = 0; 85 virtual void visit(const LLTreeNode<T>* node) = 0;
109}; 86};
110 87
111template <class T> 88template <class T>
@@ -115,25 +92,19 @@ LLTreeNode<T>::~LLTreeNode()
115}; 92};
116 93
117template <class T> 94template <class T>
118void LLTreeNode<T>::insert(T* data) 95bool LLTreeNode<T>::insert(T* data)
119{ 96{
120 if (mState->insert(data)) 97 for (U32 i = 0; i < mListeners.size(); i++)
121 { 98 {
122 for (U32 i = 0; i < mListeners.size(); i++) 99 mListeners[i]->handleInsertion(this, data);
123 {
124 mListeners[i]->handleInsertion(this, data);
125 }
126 } 100 }
101 return true;
127}; 102};
128 103
129template <class T> 104template <class T>
130bool LLTreeNode<T>::remove(T* data) 105bool LLTreeNode<T>::remove(T* data)
131{ 106{
132 if (mState->remove(data)) 107 return true;
133 {
134 return true;
135 }
136 return false;
137}; 108};
138 109
139template <class T> 110template <class T>
@@ -145,38 +116,4 @@ void LLTreeNode<T>::notifyRemoval(T* data)
145 } 116 }
146} 117}
147 118
148template <class T>
149void LLTreeNode<T>::setState(LLTreeState<T>* state)
150{
151 mState = state;
152 if (state)
153 {
154 if (state->getNode() != this)
155 {
156 state->setNode(this);
157 }
158
159 for (U32 i = 0; i < mListeners.size(); i++)
160 {
161 mListeners[i]->handleStateChange(this);
162 }
163 }
164};
165
166template <class T>
167void LLTreeState<T>::setNode(LLTreeNode<T>* node)
168{
169 mNode = node;
170 if (node && node->getState() != this)
171 {
172 node->setState(this);
173 }
174};
175
176template <class T>
177LLTreeListener<T>* LLTreeState<T>::getListener(U32 index) const
178{
179 return mNode->getListener(index);
180}
181
182#endif 119#endif
diff --git a/linden/indra/llmath/llvolume.cpp b/linden/indra/llmath/llvolume.cpp
index 3316168..266ec08 100644
--- a/linden/indra/llmath/llvolume.cpp
+++ b/linden/indra/llmath/llvolume.cpp
@@ -1639,12 +1639,27 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
1639 } 1639 }
1640} 1640}
1641 1641
1642void LLVolume::resizePath(S32 length)
1643{
1644 mPathp->resizePath(length);
1645 if (mVolumeFaces != NULL)
1646 {
1647 delete[] mVolumeFaces;
1648 mVolumeFaces = NULL;
1649 }
1650}
1651
1642void LLVolume::regen() 1652void LLVolume::regen()
1643{ 1653{
1644 generate(); 1654 generate();
1645 createVolumeFaces(); 1655 createVolumeFaces();
1646} 1656}
1647 1657
1658void LLVolume::genBinormals(S32 face)
1659{
1660 mVolumeFaces[face].createBinormals();
1661}
1662
1648LLVolume::~LLVolume() 1663LLVolume::~LLVolume()
1649{ 1664{
1650 sNumMeshPoints -= mMesh.size(); 1665 sNumMeshPoints -= mMesh.size();
@@ -1746,12 +1761,6 @@ void LLVolume::createVolumeFaces()
1746{ 1761{
1747 S32 i; 1762 S32 i;
1748 1763
1749 if (mVolumeFaces != NULL)
1750 {
1751 delete[] mVolumeFaces;
1752 mVolumeFaces = NULL;
1753 }
1754
1755 if (mGenerateSingleFace) 1764 if (mGenerateSingleFace)
1756 { 1765 {
1757 mNumVolumeFaces = 0; 1766 mNumVolumeFaces = 0;
@@ -1760,7 +1769,12 @@ void LLVolume::createVolumeFaces()
1760 { 1769 {
1761 S32 num_faces = getNumFaces(); 1770 S32 num_faces = getNumFaces();
1762 mNumVolumeFaces = num_faces; 1771 mNumVolumeFaces = num_faces;
1763 mVolumeFaces = new LLVolumeFace[num_faces]; 1772 BOOL partial_build = TRUE;
1773 if (!mVolumeFaces)
1774 {
1775 partial_build = FALSE;
1776 mVolumeFaces = new LLVolumeFace[num_faces];
1777 }
1764 // Initialize volume faces with parameter data 1778 // Initialize volume faces with parameter data
1765 for (i = 0; i < num_faces; i++) 1779 for (i = 0; i < num_faces; i++)
1766 { 1780 {
@@ -1823,7 +1837,7 @@ void LLVolume::createVolumeFaces()
1823 1837
1824 for (i = 0; i < mNumVolumeFaces; i++) 1838 for (i = 0; i < mNumVolumeFaces; i++)
1825 { 1839 {
1826 mVolumeFaces[i].create(); 1840 mVolumeFaces[i].create(partial_build);
1827 } 1841 }
1828 } 1842 }
1829} 1843}
@@ -1840,55 +1854,70 @@ inline LLVector3 sculpt_rgb_to_vector(U8 r, U8 g, U8 b)
1840 return value; 1854 return value;
1841} 1855}
1842 1856
1857inline U32 sculpt_xy_to_index(U32 x, U32 y, U16 sculpt_width, U16 sculpt_height, S8 sculpt_components)
1858{
1859 U32 index = (x + y * sculpt_width) * sculpt_components;
1843 1860
1844// sculpt replaces generate() for sculpted surfaces 1861 // attempt to resolve DEV-11158 - remove assert later.
1845void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level) 1862 llassert(index < sculpt_width * sculpt_height * sculpt_components);
1863
1864 return index;
1865}
1866
1867
1868inline U32 sculpt_st_to_index(S32 s, S32 t, S32 size_s, S32 size_t, U16 sculpt_width, U16 sculpt_height, S8 sculpt_components)
1846{ 1869{
1847 U8 sculpt_type = mParams.getSculptType(); 1870 U32 x = (U32) ((F32)s/(size_s) * (F32) sculpt_width);
1871 U32 y = (U32) ((F32)t/(size_t) * (F32) sculpt_height);
1848 1872
1849 BOOL data_is_empty = FALSE; 1873 return sculpt_xy_to_index(x, y, sculpt_width, sculpt_height, sculpt_components);
1874}
1850 1875
1851 if (sculpt_width == 0 || sculpt_height == 0 || sculpt_data == NULL)
1852 {
1853 sculpt_level = -1;
1854 data_is_empty = TRUE;
1855 }
1856 1876
1857 mPathp->generate(mDetail, 0, TRUE); 1877inline LLVector3 sculpt_index_to_vector(U32 index, const U8* sculpt_data)
1858 mProfilep->generate(mPathp->isOpen(), mDetail, 0, TRUE); 1878{
1859 1879 LLVector3 v = sculpt_rgb_to_vector(sculpt_data[index], sculpt_data[index+1], sculpt_data[index+2]);
1880
1881 return v;
1882}
1883
1884inline LLVector3 sculpt_st_to_vector(S32 s, S32 t, S32 size_s, S32 size_t, U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data)
1885{
1886 U32 index = sculpt_st_to_index(s, t, size_s, size_t, sculpt_width, sculpt_height, sculpt_components);
1887
1888 return sculpt_index_to_vector(index, sculpt_data);
1889}
1890
1891inline LLVector3 sculpt_xy_to_vector(U32 x, U32 y, U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data)
1892{
1893 U32 index = sculpt_xy_to_index(x, y, sculpt_width, sculpt_height, sculpt_components);
1894
1895 return sculpt_index_to_vector(index, sculpt_data);
1896}
1897
1898
1899F32 LLVolume::sculptGetSurfaceArea(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data)
1900{
1901 // test to see if image has enough variation to create non-degenerate geometry
1902
1860 S32 sizeS = mPathp->mPath.size(); 1903 S32 sizeS = mPathp->mPath.size();
1861 S32 sizeT = mProfilep->mProfile.size(); 1904 S32 sizeT = mProfilep->mProfile.size();
1862 1905
1863 sNumMeshPoints -= mMesh.size();
1864 mMesh.resize(sizeS * sizeT);
1865 sNumMeshPoints += mMesh.size();
1866
1867 F32 area = 0; 1906 F32 area = 0;
1868 // first test to see if image has enough variation to create non-degenerate geometry 1907
1869 if (!data_is_empty) 1908 if ((sculpt_width != 0) &&
1909 (sculpt_height != 0) &&
1910 (sculpt_components != 0) &&
1911 (sculpt_data != NULL))
1870 { 1912 {
1871 for (S32 s = 0; s < sizeS - 1; s++) 1913 for (S32 s = 0; s < sizeS - 1; s++)
1872 { 1914 {
1873 for (S32 t = 0; t < sizeT - 1; t++) 1915 for (S32 t = 0; t < sizeT - 1; t++)
1874 { 1916 {
1875 // first coordinate
1876 U32 x = (U32) ((F32)s/(sizeS) * (F32) sculpt_width);
1877 U32 y = (U32) ((F32)t/(sizeT) * (F32) sculpt_height);
1878
1879 // coordinate offset by 1
1880 U32 x2 = (U32) ((F32)(s+1)/(sizeS) * (F32) sculpt_width);
1881 U32 y2 = (U32) ((F32)(t+1)/(sizeT) * (F32) sculpt_height);
1882
1883 // three points on a triagle - find the image indices first
1884 U32 p1_index = (x + y * sculpt_width) * sculpt_components;
1885 U32 p2_index = (x2 + y * sculpt_width) * sculpt_components;
1886 U32 p3_index = (x + y2 * sculpt_width) * sculpt_components;
1887
1888 // convert image data to vectors 1917 // convert image data to vectors
1889 LLVector3 p1 = sculpt_rgb_to_vector(sculpt_data[p1_index], sculpt_data[p1_index+1], sculpt_data[p1_index+2]); 1918 LLVector3 p1 = sculpt_st_to_vector(s, t, sizeS, sizeT, sculpt_width, sculpt_height, sculpt_components, sculpt_data);
1890 LLVector3 p2 = sculpt_rgb_to_vector(sculpt_data[p2_index], sculpt_data[p2_index+1], sculpt_data[p2_index+2]); 1919 LLVector3 p2 = sculpt_st_to_vector(s+1, t, sizeS, sizeT, sculpt_width, sculpt_height, sculpt_components, sculpt_data);
1891 LLVector3 p3 = sculpt_rgb_to_vector(sculpt_data[p3_index], sculpt_data[p3_index+1], sculpt_data[p3_index+2]); 1920 LLVector3 p3 = sculpt_st_to_vector(s, t+1, sizeS, sizeT, sculpt_width, sculpt_height, sculpt_components, sculpt_data);
1892 1921
1893 // compute the area of the parallelogram by taking the length of the cross product: 1922 // compute the area of the parallelogram by taking the length of the cross product:
1894 // (parallegram is an approximation of two triangles) 1923 // (parallegram is an approximation of two triangles)
@@ -1896,99 +1925,151 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
1896 area += cross.magVec(); 1925 area += cross.magVec();
1897 } 1926 }
1898 } 1927 }
1899 if (area < SCULPT_MIN_AREA)
1900 data_is_empty = TRUE;
1901 } 1928 }
1902 1929
1903 //generate vertex positions 1930 return area;
1904 if (data_is_empty) // if empty, make a sphere 1931}
1905 { 1932
1906 S32 line = 0; 1933// create placeholder shape
1934void LLVolume::sculptGeneratePlaceholder()
1935{
1936 S32 sizeS = mPathp->mPath.size();
1937 S32 sizeT = mProfilep->mProfile.size();
1938
1939 S32 line = 0;
1907 1940
1908 for (S32 s = 0; s < sizeS; s++) 1941 // for now, this is a sphere.
1942 for (S32 s = 0; s < sizeS; s++)
1943 {
1944 for (S32 t = 0; t < sizeT; t++)
1909 { 1945 {
1910 for (S32 t = 0; t < sizeT; t++) 1946 S32 i = t + line;
1911 { 1947 Point& pt = mMesh[i];
1912 S32 i = t + line;
1913 Point& pt = mMesh[i];
1914 1948
1915 1949
1916 F32 u = (F32)s/(sizeS-1); 1950 F32 u = (F32)s/(sizeS-1);
1917 F32 v = (F32)t/(sizeT-1); 1951 F32 v = (F32)t/(sizeT-1);
1918 1952
1919 const F32 RADIUS = (F32) 0.3; 1953 const F32 RADIUS = (F32) 0.3;
1920 1954
1921 pt.mPos.mV[0] = (F32)(sin(F_PI * v) * cos(2.0 * F_PI * u) * RADIUS); 1955 pt.mPos.mV[0] = (F32)(sin(F_PI * v) * cos(2.0 * F_PI * u) * RADIUS);
1922 pt.mPos.mV[1] = (F32)(sin(F_PI * v) * sin(2.0 * F_PI * u) * RADIUS); 1956 pt.mPos.mV[1] = (F32)(sin(F_PI * v) * sin(2.0 * F_PI * u) * RADIUS);
1923 pt.mPos.mV[2] = (F32)(cos(F_PI * v) * RADIUS); 1957 pt.mPos.mV[2] = (F32)(cos(F_PI * v) * RADIUS);
1924 1958
1925 }
1926 line += sizeT;
1927 } 1959 }
1928 } 1960 line += sizeT;
1929 else 1961 }
1962}
1963
1964// create the vertices from the map
1965void LLVolume::sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, U8 sculpt_type)
1966{
1967 S32 sizeS = mPathp->mPath.size();
1968 S32 sizeT = mProfilep->mProfile.size();
1969
1970 S32 line = 0;
1971 for (S32 s = 0; s < sizeS; s++)
1930 { 1972 {
1931 S32 line = 0; 1973 // Run along the profile.
1932 for (S32 s = 0; s < sizeS; s++) 1974 for (S32 t = 0; t < sizeT; t++)
1933 { 1975 {
1934 // Run along the profile. 1976 S32 i = t + line;
1935 for (S32 t = 0; t < sizeT; t++) 1977 Point& pt = mMesh[i];
1936 {
1937 S32 i = t + line;
1938 Point& pt = mMesh[i];
1939 1978
1940 U32 x = (U32) ((F32)t/(sizeT-1) * (F32) sculpt_width); 1979 U32 x = (U32) ((F32)t/(sizeT-1) * (F32) sculpt_width);
1941 U32 y = (U32) ((F32)s/(sizeS-1) * (F32) sculpt_height); 1980 U32 y = (U32) ((F32)s/(sizeS-1) * (F32) sculpt_height);
1942 1981
1943 if (y == 0) // top row stitching 1982 if (y == 0) // top row stitching
1983 {
1984 // pinch?
1985 if (sculpt_type == LL_SCULPT_TYPE_SPHERE)
1944 { 1986 {
1945 // pinch? 1987 x = sculpt_width / 2;
1946 if (sculpt_type == LL_SCULPT_TYPE_SPHERE)
1947 {
1948 x = sculpt_width / 2;
1949 }
1950 } 1988 }
1989 }
1951 1990
1952 if (y == sculpt_height) // bottom row stitching 1991 if (y == sculpt_height) // bottom row stitching
1992 {
1993 // wrap?
1994 if (sculpt_type == LL_SCULPT_TYPE_TORUS)
1953 { 1995 {
1954 // wrap? 1996 y = 0;
1955 if (sculpt_type == LL_SCULPT_TYPE_TORUS) 1997 }
1956 { 1998 else
1957 y = 0; 1999 {
1958 } 2000 y = sculpt_height - 1;
1959 else 2001 }
1960 {
1961 y = sculpt_height - 1;
1962 }
1963 2002
1964 // pinch? 2003 // pinch?
1965 if (sculpt_type == LL_SCULPT_TYPE_SPHERE) 2004 if (sculpt_type == LL_SCULPT_TYPE_SPHERE)
1966 { 2005 {
1967 x = sculpt_width / 2; 2006 x = sculpt_width / 2;
1968 }
1969 } 2007 }
2008 }
1970 2009
1971 if (x == sculpt_width) // side stitching 2010 if (x == sculpt_width) // side stitching
2011 {
2012 // wrap?
2013 if ((sculpt_type == LL_SCULPT_TYPE_SPHERE) ||
2014 (sculpt_type == LL_SCULPT_TYPE_TORUS) ||
2015 (sculpt_type == LL_SCULPT_TYPE_CYLINDER))
1972 { 2016 {
1973 // wrap? 2017 x = 0;
1974 if ((sculpt_type == LL_SCULPT_TYPE_SPHERE) || 2018 }
1975 (sculpt_type == LL_SCULPT_TYPE_TORUS) ||
1976 (sculpt_type == LL_SCULPT_TYPE_CYLINDER))
1977 {
1978 x = 0;
1979 }
1980 2019
1981 else 2020 else
1982 { 2021 {
1983 x = sculpt_width - 1; 2022 x = sculpt_width - 1;
1984 }
1985 } 2023 }
1986
1987 U32 index = (x + y * sculpt_width) * sculpt_components;
1988 pt.mPos = sculpt_rgb_to_vector(sculpt_data[index], sculpt_data[index+1], sculpt_data[index+2]);
1989 } 2024 }
1990 line += sizeT; 2025
2026 pt.mPos = sculpt_xy_to_vector(x, y, sculpt_width, sculpt_height, sculpt_components, sculpt_data);
1991 } 2027 }
2028 line += sizeT;
2029 }
2030}
2031
2032
2033// sculpt replaces generate() for sculpted surfaces
2034void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level)
2035{
2036 U8 sculpt_type = mParams.getSculptType();
2037
2038 BOOL data_is_empty = FALSE;
2039
2040 if (sculpt_width == 0 || sculpt_height == 0 || sculpt_components == 0 || sculpt_data == NULL)
2041 {
2042 sculpt_level = -1;
2043 data_is_empty = TRUE;
2044 }
2045
2046 mPathp->generate(mDetail, 0, TRUE);
2047 mProfilep->generate(mPathp->isOpen(), mDetail, 0, TRUE);
2048
2049 S32 sizeS = mPathp->mPath.size();
2050 S32 sizeT = mProfilep->mProfile.size();
2051
2052 // weird crash bug - DEV-11158 - trying to collect more data:
2053 if ((sizeS == 0) || (sizeT == 0))
2054 {
2055 llwarns << "sculpt bad mesh size " << sizeS << " " << sizeT << llendl;
2056 }
2057
2058 sNumMeshPoints -= mMesh.size();
2059 mMesh.resize(sizeS * sizeT);
2060 sNumMeshPoints += mMesh.size();
2061
2062 if (sculptGetSurfaceArea(sculpt_width, sculpt_height, sculpt_components, sculpt_data) < SCULPT_MIN_AREA)
2063 data_is_empty = TRUE;
2064
2065 //generate vertex positions
2066 if (data_is_empty) // if empty, make a placeholder mesh
2067 {
2068 sculptGeneratePlaceholder();
2069 }
2070 else
2071 {
2072 sculptGenerateMapVertices(sculpt_width, sculpt_height, sculpt_components, sculpt_data, sculpt_type);
1992 } 2073 }
1993 2074
1994 for (S32 i = 0; i < (S32)mProfilep->mFaces.size(); i++) 2075 for (S32 i = 0; i < (S32)mProfilep->mFaces.size(); i++)
@@ -3967,18 +4048,19 @@ LLVolumeFace::LLVolumeFace()
3967 mBeginT = 0; 4048 mBeginT = 0;
3968 mNumS = 0; 4049 mNumS = 0;
3969 mNumT = 0; 4050 mNumT = 0;
4051 mHasBinormals = FALSE;
3970} 4052}
3971 4053
3972 4054
3973BOOL LLVolumeFace::create() 4055BOOL LLVolumeFace::create(BOOL partial_build)
3974{ 4056{
3975 if (mTypeMask & CAP_MASK) 4057 if (mTypeMask & CAP_MASK)
3976 { 4058 {
3977 return createCap(); 4059 return createCap(partial_build);
3978 } 4060 }
3979 else if ((mTypeMask & END_MASK) || (mTypeMask & SIDE_MASK)) 4061 else if ((mTypeMask & END_MASK) || (mTypeMask & SIDE_MASK))
3980 { 4062 {
3981 return createSide(); 4063 return createSide(partial_build);
3982 } 4064 }
3983 else 4065 else
3984 { 4066 {
@@ -4000,7 +4082,7 @@ void LerpPlanarVertex(LLVolumeFace::VertexData& v0,
4000 vout.mBinormal = v0.mBinormal; 4082 vout.mBinormal = v0.mBinormal;
4001} 4083}
4002 4084
4003BOOL LLVolumeFace::createUnCutCubeCap() 4085BOOL LLVolumeFace::createUnCutCubeCap(BOOL partial_build)
4004{ 4086{
4005 const std::vector<LLVolume::Point>& mesh = mVolumep->getMesh(); 4087 const std::vector<LLVolume::Point>& mesh = mVolumep->getMesh();
4006 const std::vector<LLVector3>& profile = mVolumep->getProfile().mProfile; 4088 const std::vector<LLVector3>& profile = mVolumep->getProfile().mProfile;
@@ -4055,6 +4137,12 @@ BOOL LLVolumeFace::createUnCutCubeCap()
4055 corners[t].mBinormal = baseVert.mBinormal; 4137 corners[t].mBinormal = baseVert.mBinormal;
4056 corners[t].mNormal = baseVert.mNormal; 4138 corners[t].mNormal = baseVert.mNormal;
4057 } 4139 }
4140 mHasBinormals = TRUE;
4141
4142 if (partial_build)
4143 {
4144 mVertices.clear();
4145 }
4058 4146
4059 S32 vtop = mVertices.size(); 4147 S32 vtop = mVertices.size();
4060 for(int gx = 0;gx<grid_size+1;gx++){ 4148 for(int gx = 0;gx<grid_size+1;gx++){
@@ -4082,22 +4170,25 @@ BOOL LLVolumeFace::createUnCutCubeCap()
4082 4170
4083 mCenter = (min + max) * 0.5f; 4171 mCenter = (min + max) * 0.5f;
4084 4172
4085 int idxs[] = {0,1,(grid_size+1)+1,(grid_size+1)+1,(grid_size+1),0}; 4173 if (!partial_build)
4086 for(int gx = 0;gx<grid_size;gx++){ 4174 {
4087 for(int gy = 0;gy<grid_size;gy++){ 4175 int idxs[] = {0,1,(grid_size+1)+1,(grid_size+1)+1,(grid_size+1),0};
4088 if (mTypeMask & TOP_MASK){ 4176 for(int gx = 0;gx<grid_size;gx++){
4089 for(int i=5;i>=0;i--)mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]); 4177 for(int gy = 0;gy<grid_size;gy++){
4090 }else{ 4178 if (mTypeMask & TOP_MASK){
4091 for(int i=0;i<6;i++)mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]); 4179 for(int i=5;i>=0;i--)mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
4180 }else{
4181 for(int i=0;i<6;i++)mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
4182 }
4092 } 4183 }
4093 } 4184 }
4094 } 4185 }
4095 4186
4096 return TRUE; 4187 return TRUE;
4097} 4188}
4098 4189
4099 4190
4100BOOL LLVolumeFace::createCap() 4191BOOL LLVolumeFace::createCap(BOOL partial_build)
4101{ 4192{
4102 if (!(mTypeMask & HOLLOW_MASK) && 4193 if (!(mTypeMask & HOLLOW_MASK) &&
4103 !(mTypeMask & OPEN_MASK) && 4194 !(mTypeMask & OPEN_MASK) &&
@@ -4106,7 +4197,7 @@ BOOL LLVolumeFace::createCap()
4106 (mVolumep->getProfile().mParams.getCurveType()==LL_PCODE_PROFILE_SQUARE && 4197 (mVolumep->getProfile().mParams.getCurveType()==LL_PCODE_PROFILE_SQUARE &&
4107 mVolumep->getPath().mParams.getCurveType()==LL_PCODE_PATH_LINE) 4198 mVolumep->getPath().mParams.getCurveType()==LL_PCODE_PATH_LINE)
4108 ){ 4199 ){
4109 return createUnCutCubeCap(); 4200 return createUnCutCubeCap(partial_build);
4110 } 4201 }
4111 4202
4112 S32 i; 4203 S32 i;
@@ -4118,8 +4209,13 @@ BOOL LLVolumeFace::createCap()
4118 // All types of caps have the same number of vertices and indices 4209 // All types of caps have the same number of vertices and indices
4119 num_vertices = profile.size(); 4210 num_vertices = profile.size();
4120 num_indices = (profile.size() - 2)*3; 4211 num_indices = (profile.size() - 2)*3;
4121 vector_append(mVertices,num_vertices); 4212
4122 vector_append(mIndices,num_indices); 4213 mVertices.resize(num_vertices);
4214
4215 if (!partial_build)
4216 {
4217 mIndices.resize(num_indices);
4218 }
4123 4219
4124 S32 max_s = mVolumep->getProfile().getTotal(); 4220 S32 max_s = mVolumep->getProfile().getTotal();
4125 S32 max_t = mVolumep->getPath().mPath.size(); 4221 S32 max_t = mVolumep->getPath().mPath.size();
@@ -4203,7 +4299,10 @@ BOOL LLVolumeFace::createCap()
4203 { 4299 {
4204 mVertices.push_back(vd); 4300 mVertices.push_back(vd);
4205 num_vertices++; 4301 num_vertices++;
4206 vector_append(mIndices, 3); 4302 if (!partial_build)
4303 {
4304 vector_append(mIndices, 3);
4305 }
4207 } 4306 }
4208 4307
4209 4308
@@ -4213,6 +4312,13 @@ BOOL LLVolumeFace::createCap()
4213 mVertices[i].mNormal = normal; 4312 mVertices[i].mNormal = normal;
4214 } 4313 }
4215 4314
4315 mHasBinormals = TRUE;
4316
4317 if (partial_build)
4318 {
4319 return TRUE;
4320 }
4321
4216 if (mTypeMask & HOLLOW_MASK) 4322 if (mTypeMask & HOLLOW_MASK)
4217 { 4323 {
4218 if (mTypeMask & TOP_MASK) 4324 if (mTypeMask & TOP_MASK)
@@ -4480,7 +4586,50 @@ BOOL LLVolumeFace::createCap()
4480 return TRUE; 4586 return TRUE;
4481} 4587}
4482 4588
4483BOOL LLVolumeFace::createSide() 4589void LLVolumeFace::createBinormals()
4590{
4591 if (!mHasBinormals)
4592 {
4593 //generate binormals
4594 for (U32 i = 0; i < mIndices.size()/3; i++)
4595 { //for each triangle
4596 const VertexData& v0 = mVertices[mIndices[i*3+0]];
4597 const VertexData& v1 = mVertices[mIndices[i*3+1]];
4598 const VertexData& v2 = mVertices[mIndices[i*3+2]];
4599
4600 //calculate binormal
4601 LLVector3 binorm = calc_binormal_from_triangle(v0.mPosition, v0.mTexCoord,
4602 v1.mPosition, v1.mTexCoord,
4603 v2.mPosition, v2.mTexCoord);
4604
4605 for (U32 j = 0; j < 3; j++)
4606 { //add triangle normal to vertices
4607 mVertices[mIndices[i*3+j]].mBinormal += binorm; // * (weight_sum - d[j])/weight_sum;
4608 }
4609
4610 //even out quad contributions
4611 if (i % 2 == 0)
4612 {
4613 mVertices[mIndices[i*3+2]].mBinormal += binorm;
4614 }
4615 else
4616 {
4617 mVertices[mIndices[i*3+1]].mBinormal += binorm;
4618 }
4619 }
4620
4621 //normalize binormals
4622 for (U32 i = 0; i < mVertices.size(); i++)
4623 {
4624 mVertices[i].mBinormal.normVec();
4625 mVertices[i].mNormal.normVec();
4626 }
4627
4628 mHasBinormals = TRUE;
4629 }
4630}
4631
4632BOOL LLVolumeFace::createSide(BOOL partial_build)
4484{ 4633{
4485 BOOL flat = mTypeMask & FLAT_MASK; 4634 BOOL flat = mTypeMask & FLAT_MASK;
4486 S32 num_vertices, num_indices; 4635 S32 num_vertices, num_indices;
@@ -4496,9 +4645,14 @@ BOOL LLVolumeFace::createSide()
4496 4645
4497 num_vertices = mNumS*mNumT; 4646 num_vertices = mNumS*mNumT;
4498 num_indices = (mNumS-1)*(mNumT-1)*6; 4647 num_indices = (mNumS-1)*(mNumT-1)*6;
4499 vector_append(mVertices,num_vertices); 4648
4500 vector_append(mIndices,num_indices); 4649 mVertices.resize(num_vertices);
4501 vector_append(mEdge, num_indices); 4650
4651 if (!partial_build)
4652 {
4653 mIndices.resize(num_indices);
4654 mEdge.resize(num_indices);
4655 }
4502 4656
4503 LLVector3& face_min = mExtents[0]; 4657 LLVector3& face_min = mExtents[0];
4504 LLVector3& face_max = mExtents[1]; 4658 LLVector3& face_max = mExtents[1];
@@ -4609,61 +4763,63 @@ BOOL LLVolumeFace::createSide()
4609 S32 cur_edge = 0; 4763 S32 cur_edge = 0;
4610 BOOL flat_face = mTypeMask & FLAT_MASK; 4764 BOOL flat_face = mTypeMask & FLAT_MASK;
4611 4765
4612 // Now we generate the indices. 4766 if (!partial_build)
4613 for (t = 0; t < (mNumT-1); t++) 4767 {
4614 { 4768 // Now we generate the indices.
4615 for (s = 0; s < (mNumS-1); s++) 4769 for (t = 0; t < (mNumT-1); t++)
4616 { 4770 {
4617 mIndices[cur_index++] = s + mNumS*t; //bottom left 4771 for (s = 0; s < (mNumS-1); s++)
4618 mIndices[cur_index++] = s+1 + mNumS*(t+1); //top right 4772 {
4619 mIndices[cur_index++] = s + mNumS*(t+1); //top left 4773 mIndices[cur_index++] = s + mNumS*t; //bottom left
4620 mIndices[cur_index++] = s + mNumS*t; //bottom left 4774 mIndices[cur_index++] = s+1 + mNumS*(t+1); //top right
4621 mIndices[cur_index++] = s+1 + mNumS*t; //bottom right 4775 mIndices[cur_index++] = s + mNumS*(t+1); //top left
4622 mIndices[cur_index++] = s+1 + mNumS*(t+1); //top right 4776 mIndices[cur_index++] = s + mNumS*t; //bottom left
4623 4777 mIndices[cur_index++] = s+1 + mNumS*t; //bottom right
4624 mEdge[cur_edge++] = (mNumS-1)*2*t+s*2+1; //bottom left/top right neighbor face 4778 mIndices[cur_index++] = s+1 + mNumS*(t+1); //top right
4625 if (t < mNumT-2) { //top right/top left neighbor face 4779
4626 mEdge[cur_edge++] = (mNumS-1)*2*(t+1)+s*2+1; 4780 mEdge[cur_edge++] = (mNumS-1)*2*t+s*2+1; //bottom left/top right neighbor face
4627 } 4781 if (t < mNumT-2) { //top right/top left neighbor face
4628 else if (mNumT <= 3 || mVolumep->getPath().isOpen() == TRUE) { //no neighbor 4782 mEdge[cur_edge++] = (mNumS-1)*2*(t+1)+s*2+1;
4629 mEdge[cur_edge++] = -1; 4783 }
4630 } 4784 else if (mNumT <= 3 || mVolumep->getPath().isOpen() == TRUE) { //no neighbor
4631 else { //wrap on T 4785 mEdge[cur_edge++] = -1;
4632 mEdge[cur_edge++] = s*2+1; 4786 }
4633 } 4787 else { //wrap on T
4634 if (s > 0) { //top left/bottom left neighbor face 4788 mEdge[cur_edge++] = s*2+1;
4635 mEdge[cur_edge++] = (mNumS-1)*2*t+s*2-1; 4789 }
4636 } 4790 if (s > 0) { //top left/bottom left neighbor face
4637 else if (flat_face || mVolumep->getProfile().isOpen() == TRUE) { //no neighbor 4791 mEdge[cur_edge++] = (mNumS-1)*2*t+s*2-1;
4638 mEdge[cur_edge++] = -1; 4792 }
4639 } 4793 else if (flat_face || mVolumep->getProfile().isOpen() == TRUE) { //no neighbor
4640 else { //wrap on S 4794 mEdge[cur_edge++] = -1;
4641 mEdge[cur_edge++] = (mNumS-1)*2*t+(mNumS-2)*2+1; 4795 }
4642 } 4796 else { //wrap on S
4643 4797 mEdge[cur_edge++] = (mNumS-1)*2*t+(mNumS-2)*2+1;
4644 if (t > 0) { //bottom left/bottom right neighbor face 4798 }
4645 mEdge[cur_edge++] = (mNumS-1)*2*(t-1)+s*2; 4799
4646 } 4800 if (t > 0) { //bottom left/bottom right neighbor face
4647 else if (mNumT <= 3 || mVolumep->getPath().isOpen() == TRUE) { //no neighbor 4801 mEdge[cur_edge++] = (mNumS-1)*2*(t-1)+s*2;
4648 mEdge[cur_edge++] = -1; 4802 }
4649 } 4803 else if (mNumT <= 3 || mVolumep->getPath().isOpen() == TRUE) { //no neighbor
4650 else { //wrap on T 4804 mEdge[cur_edge++] = -1;
4651 mEdge[cur_edge++] = (mNumS-1)*2*(mNumT-2)+s*2; 4805 }
4652 } 4806 else { //wrap on T
4653 if (s < mNumS-2) { //bottom right/top right neighbor face 4807 mEdge[cur_edge++] = (mNumS-1)*2*(mNumT-2)+s*2;
4654 mEdge[cur_edge++] = (mNumS-1)*2*t+(s+1)*2; 4808 }
4655 } 4809 if (s < mNumS-2) { //bottom right/top right neighbor face
4656 else if (flat_face || mVolumep->getProfile().isOpen() == TRUE) { //no neighbor 4810 mEdge[cur_edge++] = (mNumS-1)*2*t+(s+1)*2;
4657 mEdge[cur_edge++] = -1; 4811 }
4658 } 4812 else if (flat_face || mVolumep->getProfile().isOpen() == TRUE) { //no neighbor
4659 else { //wrap on S 4813 mEdge[cur_edge++] = -1;
4660 mEdge[cur_edge++] = (mNumS-1)*2*t; 4814 }
4815 else { //wrap on S
4816 mEdge[cur_edge++] = (mNumS-1)*2*t;
4817 }
4818 mEdge[cur_edge++] = (mNumS-1)*2*t+s*2; //top right/bottom left neighbor face
4661 } 4819 }
4662 mEdge[cur_edge++] = (mNumS-1)*2*t+s*2; //top right/bottom left neighbor face
4663 } 4820 }
4664 } 4821 }
4665 4822
4666
4667 //generate normals 4823 //generate normals
4668 for (U32 i = 0; i < mIndices.size()/3; i++) { //for each triangle 4824 for (U32 i = 0; i < mIndices.size()/3; i++) { //for each triangle
4669 const VertexData& v0 = mVertices[mIndices[i*3+0]]; 4825 const VertexData& v0 = mVertices[mIndices[i*3+0]];
@@ -4674,27 +4830,22 @@ BOOL LLVolumeFace::createSide()
4674 LLVector3 norm = (v0.mPosition-v1.mPosition)% 4830 LLVector3 norm = (v0.mPosition-v1.mPosition)%
4675 (v0.mPosition-v2.mPosition); 4831 (v0.mPosition-v2.mPosition);
4676 4832
4677 //calculate binormal 4833 for (U32 j = 0; j < 3; j++)
4678 LLVector3 binorm = calc_binormal_from_triangle(v0.mPosition, v0.mTexCoord, 4834 { //add triangle normal to vertices
4679 v1.mPosition, v1.mTexCoord,
4680 v2.mPosition, v2.mTexCoord);
4681
4682 for (U32 j = 0; j < 3; j++) { //add triangle normal to vertices
4683 mVertices[mIndices[i*3+j]].mNormal += norm; // * (weight_sum - d[j])/weight_sum; 4835 mVertices[mIndices[i*3+j]].mNormal += norm; // * (weight_sum - d[j])/weight_sum;
4684 mVertices[mIndices[i*3+j]].mBinormal += binorm; // * (weight_sum - d[j])/weight_sum;
4685 } 4836 }
4686 4837
4687 //even out quad contributions 4838 //even out quad contributions
4688 if (i % 2 == 0) { 4839 if (i % 2 == 0)
4840 {
4689 mVertices[mIndices[i*3+2]].mNormal += norm; 4841 mVertices[mIndices[i*3+2]].mNormal += norm;
4690 mVertices[mIndices[i*3+2]].mBinormal += binorm;
4691 } 4842 }
4692 else { 4843 else
4844 {
4693 mVertices[mIndices[i*3+1]].mNormal += norm; 4845 mVertices[mIndices[i*3+1]].mNormal += norm;
4694 mVertices[mIndices[i*3+1]].mBinormal += binorm;
4695 } 4846 }
4696 } 4847 }
4697 4848
4698 // adjust normals based on wrapping and stitching 4849 // adjust normals based on wrapping and stitching
4699 4850
4700 BOOL s_bottom_converges = ((mVertices[0].mPosition - mVertices[mNumS*(mNumT-2)].mPosition).magVecSquared() < 0.000001f); 4851 BOOL s_bottom_converges = ((mVertices[0].mPosition - mVertices[mNumS*(mNumT-2)].mPosition).magVecSquared() < 0.000001f);
@@ -4820,15 +4971,6 @@ BOOL LLVolumeFace::createSide()
4820 4971
4821 } 4972 }
4822 4973
4823
4824 //normalize normals and binormals here so the meshes that reference
4825 //this volume data don't have to
4826 for (U32 i = 0; i < mVertices.size(); i++)
4827 {
4828 mVertices[i].mNormal.normVec();
4829 mVertices[i].mBinormal.normVec();
4830 }
4831
4832 return TRUE; 4974 return TRUE;
4833} 4975}
4834 4976
diff --git a/linden/indra/llmath/llvolume.h b/linden/indra/llmath/llvolume.h
index 7b384f2..5ec7997 100644
--- a/linden/indra/llmath/llvolume.h
+++ b/linden/indra/llmath/llvolume.h
@@ -762,7 +762,8 @@ class LLVolumeFace
762{ 762{
763public: 763public:
764 LLVolumeFace(); 764 LLVolumeFace();
765 BOOL create(); 765 BOOL create(BOOL partial_build = FALSE);
766 void createBinormals();
766 767
767 class VertexData 768 class VertexData
768 { 769 {
@@ -792,6 +793,7 @@ public:
792 S32 mID; 793 S32 mID;
793 U32 mTypeMask; 794 U32 mTypeMask;
794 LLVector3 mCenter; 795 LLVector3 mCenter;
796 BOOL mHasBinormals;
795 797
796 // Only used for INNER/OUTER faces 798 // Only used for INNER/OUTER faces
797 S32 mBeginS; 799 S32 mBeginS;
@@ -802,7 +804,7 @@ public:
802 LLVector3 mExtents[2]; //minimum and maximum point of face 804 LLVector3 mExtents[2]; //minimum and maximum point of face
803 805
804 std::vector<VertexData> mVertices; 806 std::vector<VertexData> mVertices;
805 std::vector<S32> mIndices; 807 std::vector<U16> mIndices;
806 std::vector<S32> mEdge; 808 std::vector<S32> mEdge;
807 LLVolume *mVolumep; // Deliberately NOT reference counted - djs 11/20/03 - otherwise would make an annoying circular reference 809 LLVolume *mVolumep; // Deliberately NOT reference counted - djs 11/20/03 - otherwise would make an annoying circular reference
808 810
@@ -811,9 +813,9 @@ public:
811 LLStrider<LLColor4U> &new_colors, const S32 num_new, const LLVolumeFace &new_face); 813 LLStrider<LLColor4U> &new_colors, const S32 num_new, const LLVolumeFace &new_face);
812 814
813protected: 815protected:
814 BOOL createUnCutCubeCap(); 816 BOOL createUnCutCubeCap(BOOL partial_build = FALSE);
815 BOOL createCap(); 817 BOOL createCap(BOOL partial_build = FALSE);
816 BOOL createSide(); 818 BOOL createSide(BOOL partial_build = FALSE);
817}; 819};
818 820
819class LLVolume : public LLRefCount 821class LLVolume : public LLRefCount
@@ -850,12 +852,14 @@ public:
850 LLVolumeParams getCopyOfParams() const { return mParams; } 852 LLVolumeParams getCopyOfParams() const { return mParams; }
851 const LLProfile& getProfile() const { return *mProfilep; } 853 const LLProfile& getProfile() const { return *mProfilep; }
852 LLPath& getPath() const { return *mPathp; } 854 LLPath& getPath() const { return *mPathp; }
855 void resizePath(S32 length);
853 const std::vector<Point>& getMesh() const { return mMesh; } 856 const std::vector<Point>& getMesh() const { return mMesh; }
854 const LLVector3& getMeshPt(const U32 i) const { return mMesh[i].mPos; } 857 const LLVector3& getMeshPt(const U32 i) const { return mMesh[i].mPos; }
855 858
856 void setDirty() { mPathp->setDirty(); mProfilep->setDirty(); } 859 void setDirty() { mPathp->setDirty(); mProfilep->setDirty(); }
857 860
858 void regen(); 861 void regen();
862 void genBinormals(S32 face);
859 863
860 BOOL isConvex() const; 864 BOOL isConvex() const;
861 BOOL isCap(S32 face); 865 BOOL isCap(S32 face);
@@ -899,6 +903,10 @@ public:
899 LLVector3 mLODScaleBias; // vector for biasing LOD based on scale 903 LLVector3 mLODScaleBias; // vector for biasing LOD based on scale
900 904
901 void sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level); 905 void sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level);
906private:
907 F32 sculptGetSurfaceArea(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data);
908 void sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, U8 sculpt_type);
909 void sculptGeneratePlaceholder();
902 910
903protected: 911protected:
904 BOOL generate(); 912 BOOL generate();
diff --git a/linden/indra/llmath/llvolumemgr.cpp b/linden/indra/llmath/llvolumemgr.cpp
index 17bafcd..4bf7ca6 100644
--- a/linden/indra/llmath/llvolumemgr.cpp
+++ b/linden/indra/llmath/llvolumemgr.cpp
@@ -283,6 +283,29 @@ S32 LLVolumeLODGroup::getDetailFromTan(const F32 tan_angle)
283 return NUM_LODS - 1; 283 return NUM_LODS - 1;
284} 284}
285 285
286void LLVolumeLODGroup::getDetailProximity(const F32 tan_angle, F32 &to_lower, F32& to_higher)
287{
288 S32 detail = getDetailFromTan(tan_angle);
289
290 if (detail > 0)
291 {
292 to_lower = tan_angle - mDetailThresholds[detail];
293 }
294 else
295 {
296 to_lower = 1024.f*1024.f;
297 }
298
299 if (detail < NUM_LODS-1)
300 {
301 to_higher = mDetailThresholds[detail+1] - tan_angle;
302 }
303 else
304 {
305 to_higher = 1024.f*1024.f;
306 }
307}
308
286F32 LLVolumeLODGroup::getVolumeScaleFromDetail(const S32 detail) 309F32 LLVolumeLODGroup::getVolumeScaleFromDetail(const S32 detail)
287{ 310{
288 return mDetailScales[detail]; 311 return mDetailScales[detail];
diff --git a/linden/indra/llmath/llvolumemgr.h b/linden/indra/llmath/llvolumemgr.h
index 0688163..0d6aa56 100644
--- a/linden/indra/llmath/llvolumemgr.h
+++ b/linden/indra/llmath/llvolumemgr.h
@@ -56,6 +56,7 @@ public:
56 56
57 BOOL derefLOD(LLVolume *volumep); 57 BOOL derefLOD(LLVolume *volumep);
58 static S32 getDetailFromTan(const F32 tan_angle); 58 static S32 getDetailFromTan(const F32 tan_angle);
59 static void getDetailProximity(const F32 tan_angle, F32 &to_lower, F32& to_higher);
59 static F32 getVolumeScaleFromDetail(const S32 detail); 60 static F32 getVolumeScaleFromDetail(const S32 detail);
60 61
61 LLVolume *getLOD(const S32 detail); 62 LLVolume *getLOD(const S32 detail);
diff --git a/linden/indra/llmath/v3color.cpp b/linden/indra/llmath/v3color.cpp
index cc4f874..9bdcd27 100644
--- a/linden/indra/llmath/v3color.cpp
+++ b/linden/indra/llmath/v3color.cpp
@@ -33,6 +33,7 @@
33 33
34#include "v3color.h" 34#include "v3color.h"
35#include "v4color.h" 35#include "v4color.h"
36#include "v4math.h"
36 37
37LLColor3 LLColor3::white(1.0f, 1.0f, 1.0f); 38LLColor3 LLColor3::white(1.0f, 1.0f, 1.0f);
38LLColor3 LLColor3::black(0.0f, 0.0f, 0.0f); 39LLColor3 LLColor3::black(0.0f, 0.0f, 0.0f);
@@ -45,6 +46,13 @@ LLColor3::LLColor3(const LLColor4 &a)
45 mV[2] = a.mV[2]; 46 mV[2] = a.mV[2];
46} 47}
47 48
49LLColor3::LLColor3(const LLVector4 &a)
50{
51 mV[0] = a.mV[0];
52 mV[1] = a.mV[1];
53 mV[2] = a.mV[2];
54}
55
48LLColor3::LLColor3(const LLSD &sd) 56LLColor3::LLColor3(const LLSD &sd)
49{ 57{
50 mV[0] = (F32) sd[0].asReal(); 58 mV[0] = (F32) sd[0].asReal();
diff --git a/linden/indra/llmath/v3color.h b/linden/indra/llmath/v3color.h
index 782ccd7..a3bf385 100644
--- a/linden/indra/llmath/v3color.h
+++ b/linden/indra/llmath/v3color.h
@@ -33,6 +33,7 @@
33#define LL_V3COLOR_H 33#define LL_V3COLOR_H
34 34
35class LLColor4; 35class LLColor4;
36class LLVector4;
36 37
37#include "llerror.h" 38#include "llerror.h"
38#include "llmath.h" 39#include "llmath.h"
@@ -57,6 +58,7 @@ public:
57 LLColor3(const F32 *vec); // Initializes LLColor3 to (vec[0]. vec[1], vec[2]) 58 LLColor3(const F32 *vec); // Initializes LLColor3 to (vec[0]. vec[1], vec[2])
58 LLColor3(char *color_string); // html format color ie "#FFDDEE" 59 LLColor3(char *color_string); // html format color ie "#FFDDEE"
59 explicit LLColor3(const LLColor4& color4); // "explicit" to avoid automatic conversion 60 explicit LLColor3(const LLColor4& color4); // "explicit" to avoid automatic conversion
61 explicit LLColor3(const LLVector4& vector4); // "explicit" to avoid automatic conversion
60 LLColor3(const LLSD& sd); 62 LLColor3(const LLSD& sd);
61 63
62 64
@@ -87,6 +89,7 @@ public:
87 F32 magVec() const; // Returns magnitude of LLColor3 89 F32 magVec() const; // Returns magnitude of LLColor3
88 F32 magVecSquared() const; // Returns magnitude squared of LLColor3 90 F32 magVecSquared() const; // Returns magnitude squared of LLColor3
89 F32 normVec(); // Normalizes and returns the magnitude of LLColor3 91 F32 normVec(); // Normalizes and returns the magnitude of LLColor3
92 F32 brightness() const; // Returns brightness of LLColor3
90 93
91 const LLColor3& operator=(const LLColor4 &a); 94 const LLColor3& operator=(const LLColor4 &a);
92 95
@@ -98,7 +101,7 @@ public:
98 friend const LLColor3& operator-=(LLColor3 &a, const LLColor3 &b); // Return vector a minus b 101 friend const LLColor3& operator-=(LLColor3 &a, const LLColor3 &b); // Return vector a minus b
99 friend const LLColor3& operator*=(LLColor3 &a, const LLColor3 &b); 102 friend const LLColor3& operator*=(LLColor3 &a, const LLColor3 &b);
100 103
101 friend LLColor3 operator*(const LLColor3 &a, const LLColor3 &b); // Return a dot b 104 friend LLColor3 operator*(const LLColor3 &a, const LLColor3 &b); // Return component wise a * b
102 friend LLColor3 operator*(const LLColor3 &a, F32 k); // Return a times scaler k 105 friend LLColor3 operator*(const LLColor3 &a, F32 k); // Return a times scaler k
103 friend LLColor3 operator*(F32 k, const LLColor3 &a); // Return a times scaler k 106 friend LLColor3 operator*(F32 k, const LLColor3 &a); // Return a times scaler k
104 107
@@ -231,6 +234,11 @@ inline const LLColor3& LLColor3::setVec(const F32 *vec)
231 return (*this); 234 return (*this);
232} 235}
233 236
237inline F32 LLColor3::brightness(void) const
238{
239 return (mV[0] + mV[1] + mV[2]) / 3.0f;
240}
241
234inline F32 LLColor3::magVec(void) const 242inline F32 LLColor3::magVec(void) const
235{ 243{
236 return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]); 244 return fsqrtf(mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]);
diff --git a/linden/indra/llmath/v4color.cpp b/linden/indra/llmath/v4color.cpp
index b1884b7..8e6907e 100644
--- a/linden/indra/llmath/v4color.cpp
+++ b/linden/indra/llmath/v4color.cpp
@@ -36,7 +36,7 @@
36#include "v4color.h" 36#include "v4color.h"
37#include "v4coloru.h" 37#include "v4coloru.h"
38#include "v3color.h" 38#include "v3color.h"
39//#include "vmath.h" 39#include "v4math.h"
40#include "llmath.h" 40#include "llmath.h"
41 41
42// LLColor4 42// LLColor4
@@ -153,6 +153,14 @@ LLColor4::LLColor4(const LLColor4U& color4u)
153 mV[VW] = color4u.mV[VW] * SCALE; 153 mV[VW] = color4u.mV[VW] * SCALE;
154} 154}
155 155
156LLColor4::LLColor4(const LLVector4& vector4)
157{
158 mV[VX] = vector4.mV[VX];
159 mV[VY] = vector4.mV[VY];
160 mV[VZ] = vector4.mV[VZ];
161 mV[VW] = vector4.mV[VW];
162}
163
156const LLColor4& LLColor4::setVec(const LLColor4U& color4u) 164const LLColor4& LLColor4::setVec(const LLColor4U& color4u)
157{ 165{
158 const F32 SCALE = 1.f/255.f; 166 const F32 SCALE = 1.f/255.f;
diff --git a/linden/indra/llmath/v4color.h b/linden/indra/llmath/v4color.h
index 9ba2690..a2c0fb6 100644
--- a/linden/indra/llmath/v4color.h
+++ b/linden/indra/llmath/v4color.h
@@ -39,6 +39,7 @@
39 39
40class LLColor3; 40class LLColor3;
41class LLColor4U; 41class LLColor4U;
42class LLVector4;
42 43
43// LLColor4 = |x y z w| 44// LLColor4 = |x y z w|
44 45
@@ -58,6 +59,7 @@ class LLColor4
58 LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a) 59 LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a)
59 LLColor4(const LLSD& sd); 60 LLColor4(const LLSD& sd);
60 explicit LLColor4(const LLColor4U& color4u); // "explicit" to avoid automatic conversion 61 explicit LLColor4(const LLColor4U& color4u); // "explicit" to avoid automatic conversion
62 explicit LLColor4(const LLVector4& vector4); // "explicit" to avoid automatic conversion
61 63
62 LLSD getValue() const 64 LLSD getValue() const
63 { 65 {
@@ -107,7 +109,7 @@ class LLColor4
107 friend std::ostream& operator<<(std::ostream& s, const LLColor4 &a); // Print a 109 friend std::ostream& operator<<(std::ostream& s, const LLColor4 &a); // Print a
108 friend LLColor4 operator+(const LLColor4 &a, const LLColor4 &b); // Return vector a + b 110 friend LLColor4 operator+(const LLColor4 &a, const LLColor4 &b); // Return vector a + b
109 friend LLColor4 operator-(const LLColor4 &a, const LLColor4 &b); // Return vector a minus b 111 friend LLColor4 operator-(const LLColor4 &a, const LLColor4 &b); // Return vector a minus b
110 friend LLColor4 operator*(const LLColor4 &a, const LLColor4 &b); // Return a * b 112 friend LLColor4 operator*(const LLColor4 &a, const LLColor4 &b); // Return component wise a * b
111 friend LLColor4 operator*(const LLColor4 &a, F32 k); // Return rgb times scaler k (no alpha change) 113 friend LLColor4 operator*(const LLColor4 &a, F32 k); // Return rgb times scaler k (no alpha change)
112 friend LLColor4 operator*(F32 k, const LLColor4 &a); // Return rgb times scaler k (no alpha change) 114 friend LLColor4 operator*(F32 k, const LLColor4 &a); // Return rgb times scaler k (no alpha change)
113 friend LLColor4 operator%(const LLColor4 &a, F32 k); // Return alpha times scaler k (no rgb change) 115 friend LLColor4 operator%(const LLColor4 &a, F32 k); // Return alpha times scaler k (no rgb change)
diff --git a/linden/indra/llmath/v4math.h b/linden/indra/llmath/v4math.h
index f9d0c43..60e30e3 100644
--- a/linden/indra/llmath/v4math.h
+++ b/linden/indra/llmath/v4math.h
@@ -312,7 +312,8 @@ inline bool operator!=(const LLVector4 &a, const LLVector4 &b)
312{ 312{
313 return ( (a.mV[VX] != b.mV[VX]) 313 return ( (a.mV[VX] != b.mV[VX])
314 ||(a.mV[VY] != b.mV[VY]) 314 ||(a.mV[VY] != b.mV[VY])
315 ||(a.mV[VZ] != b.mV[VZ])); 315 ||(a.mV[VZ] != b.mV[VZ])
316 ||(a.mV[VW] != b.mV[VW]) );
316} 317}
317 318
318inline const LLVector4& operator+=(LLVector4 &a, const LLVector4 &b) 319inline const LLVector4& operator+=(LLVector4 &a, const LLVector4 &b)