diff options
Diffstat (limited to 'linden/indra/llmath')
-rw-r--r-- | linden/indra/llmath/llcamera.cpp | 1 | ||||
-rw-r--r-- | linden/indra/llmath/llcamera.h | 9 | ||||
-rw-r--r-- | linden/indra/llmath/llmath.h | 10 | ||||
-rw-r--r-- | linden/indra/llmath/lloctree.h | 6 | ||||
-rw-r--r-- | linden/indra/llmath/llrect.h | 4 | ||||
-rwxr-xr-x | linden/indra/llmath/llsdutil_math.h | 70 | ||||
-rw-r--r-- | linden/indra/llmath/lltreenode.h | 2 | ||||
-rw-r--r-- | linden/indra/llmath/llvolume.cpp | 12 | ||||
-rw-r--r-- | linden/indra/llmath/llvolume.h | 17 | ||||
-rw-r--r-- | linden/indra/llmath/llvolumemgr.cpp | 4 | ||||
-rw-r--r-- | linden/indra/llmath/v3math.h | 4 |
11 files changed, 105 insertions, 34 deletions
diff --git a/linden/indra/llmath/llcamera.cpp b/linden/indra/llmath/llcamera.cpp index 0f343bc..e6b6797 100644 --- a/linden/indra/llmath/llcamera.cpp +++ b/linden/indra/llmath/llcamera.cpp | |||
@@ -684,6 +684,7 @@ void LLCamera::calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom) | |||
684 | mLocalPlanes[PLANE_BOTTOM].setVec( a, c, b); | 684 | mLocalPlanes[PLANE_BOTTOM].setVec( a, c, b); |
685 | 685 | ||
686 | //calculate center and radius squared of frustum in world absolute coordinates | 686 | //calculate center and radius squared of frustum in world absolute coordinates |
687 | static LLVector3 const X_AXIS(1.f, 0.f, 0.f); | ||
687 | mFrustCenter = X_AXIS*mFarPlane*0.5f; | 688 | mFrustCenter = X_AXIS*mFarPlane*0.5f; |
688 | mFrustCenter = transformToAbsolute(mFrustCenter); | 689 | mFrustCenter = transformToAbsolute(mFrustCenter); |
689 | mFrustRadiusSquared = mFarPlane*0.5f; | 690 | mFrustRadiusSquared = mFarPlane*0.5f; |
diff --git a/linden/indra/llmath/llcamera.h b/linden/indra/llmath/llcamera.h index 23ee115..85b93df 100644 --- a/linden/indra/llmath/llcamera.h +++ b/linden/indra/llmath/llcamera.h | |||
@@ -56,15 +56,6 @@ const F32 MIN_FAR_PLANE = 0.2f; | |||
56 | static const F32 MIN_FIELD_OF_VIEW = 5.0f * DEG_TO_RAD; | 56 | static const F32 MIN_FIELD_OF_VIEW = 5.0f * DEG_TO_RAD; |
57 | static const F32 MAX_FIELD_OF_VIEW = 175.f * DEG_TO_RAD; | 57 | static const F32 MAX_FIELD_OF_VIEW = 175.f * DEG_TO_RAD; |
58 | 58 | ||
59 | static const LLVector3 X_AXIS(1.f,0.f,0.f); | ||
60 | static const LLVector3 Y_AXIS(0.f,1.f,0.f); | ||
61 | static const LLVector3 Z_AXIS(0.f,0.f,1.f); | ||
62 | |||
63 | static const LLVector3 NEG_X_AXIS(-1.f,0.f,0.f); | ||
64 | static const LLVector3 NEG_Y_AXIS(0.f,-1.f,0.f); | ||
65 | static const LLVector3 NEG_Z_AXIS(0.f,0.f,-1.f); | ||
66 | |||
67 | |||
68 | // An LLCamera is an LLCoorFrame with a view frustum. | 59 | // An LLCamera is an LLCoorFrame with a view frustum. |
69 | // This means that it has several methods for moving it around | 60 | // This means that it has several methods for moving it around |
70 | // that are inherited from the LLCoordFrame() class : | 61 | // that are inherited from the LLCoordFrame() class : |
diff --git a/linden/indra/llmath/llmath.h b/linden/indra/llmath/llmath.h index 9f8e539..0de568c 100644 --- a/linden/indra/llmath/llmath.h +++ b/linden/indra/llmath/llmath.h | |||
@@ -35,6 +35,7 @@ | |||
35 | 35 | ||
36 | #include <cmath> | 36 | #include <cmath> |
37 | #include <cstdlib> | 37 | #include <cstdlib> |
38 | #include <complex> | ||
38 | #include "lldefs.h" | 39 | #include "lldefs.h" |
39 | #include "llstl.h" // *TODO: Remove when LLString is gone | 40 | #include "llstl.h" // *TODO: Remove when LLString is gone |
40 | #include "llstring.h" // *TODO: Remove when LLString is gone | 41 | #include "llstring.h" // *TODO: Remove when LLString is gone |
@@ -60,7 +61,9 @@ | |||
60 | #endif | 61 | #endif |
61 | 62 | ||
62 | // Single Precision Floating Point Routines | 63 | // Single Precision Floating Point Routines |
63 | #if _MSC_VER < 1400 | 64 | #ifndef fsqrtf |
65 | #define fsqrtf(x) ((F32)sqrt((F64)(x))) | ||
66 | #endif | ||
64 | #ifndef sqrtf | 67 | #ifndef sqrtf |
65 | #define sqrtf(x) ((F32)sqrt((F64)(x))) | 68 | #define sqrtf(x) ((F32)sqrt((F64)(x))) |
66 | #endif | 69 | #endif |
@@ -81,11 +84,6 @@ | |||
81 | #ifndef powf | 84 | #ifndef powf |
82 | #define powf(x,y) ((F32)pow((F64)(x),(F64)(y))) | 85 | #define powf(x,y) ((F32)pow((F64)(x),(F64)(y))) |
83 | #endif | 86 | #endif |
84 | #endif | ||
85 | |||
86 | #ifndef fsqrtf | ||
87 | #define fsqrtf(x) sqrtf(x) | ||
88 | #endif | ||
89 | 87 | ||
90 | const F32 GRAVITY = -9.8f; | 88 | const F32 GRAVITY = -9.8f; |
91 | 89 | ||
diff --git a/linden/indra/llmath/lloctree.h b/linden/indra/llmath/lloctree.h index bced84c..2029554 100644 --- a/linden/indra/llmath/lloctree.h +++ b/linden/indra/llmath/lloctree.h | |||
@@ -68,8 +68,7 @@ template <class T> | |||
68 | class LLOctreeTraveler : public LLTreeTraveler<T> | 68 | class LLOctreeTraveler : public LLTreeTraveler<T> |
69 | { | 69 | { |
70 | public: | 70 | public: |
71 | virtual void traverse(const LLTreeNode<T>* node); | 71 | virtual void traverse(const LLOctreeNode<T>* node); |
72 | virtual void visit(const LLTreeNode<T>* state) { } | ||
73 | virtual void visit(const LLOctreeNode<T>* branch) = 0; | 72 | virtual void visit(const LLOctreeNode<T>* branch) = 0; |
74 | }; | 73 | }; |
75 | 74 | ||
@@ -705,9 +704,8 @@ public: | |||
705 | // LLOctreeTraveler | 704 | // LLOctreeTraveler |
706 | //======================== | 705 | //======================== |
707 | template <class T> | 706 | template <class T> |
708 | void LLOctreeTraveler<T>::traverse(const LLTreeNode<T>* tree_node) | 707 | void LLOctreeTraveler<T>::traverse(const LLOctreeNode<T>* node) |
709 | { | 708 | { |
710 | const LLOctreeNode<T>* node = (const LLOctreeNode<T>*) tree_node; | ||
711 | node->accept(this); | 709 | node->accept(this); |
712 | for (U32 i = 0; i < node->getChildCount(); i++) | 710 | for (U32 i = 0; i < node->getChildCount(); i++) |
713 | { | 711 | { |
diff --git a/linden/indra/llmath/llrect.h b/linden/indra/llmath/llrect.h index 9eb58db..33070c4 100644 --- a/linden/indra/llmath/llrect.h +++ b/linden/indra/llmath/llrect.h | |||
@@ -229,14 +229,14 @@ public: | |||
229 | return mLeft <= mRight && mBottom <= mTop; | 229 | return mLeft <= mRight && mBottom <= mTop; |
230 | } | 230 | } |
231 | 231 | ||
232 | bool isNull() const | 232 | bool isEmpty() const |
233 | { | 233 | { |
234 | return mLeft == mRight || mBottom == mTop; | 234 | return mLeft == mRight || mBottom == mTop; |
235 | } | 235 | } |
236 | 236 | ||
237 | bool notNull() const | 237 | bool notNull() const |
238 | { | 238 | { |
239 | return !isNull(); | 239 | return !isEmpty(); |
240 | } | 240 | } |
241 | 241 | ||
242 | LLRectBase& unionWith(const LLRectBase &other) | 242 | LLRectBase& unionWith(const LLRectBase &other) |
diff --git a/linden/indra/llmath/llsdutil_math.h b/linden/indra/llmath/llsdutil_math.h new file mode 100755 index 0000000..5b64942 --- /dev/null +++ b/linden/indra/llmath/llsdutil_math.h | |||
@@ -0,0 +1,70 @@ | |||
1 | /** | ||
2 | * @file llsdutil_math.h | ||
3 | * @author Brad | ||
4 | * @date 2009-05-19 | ||
5 | * @brief Utility classes, functions, etc, for using structured data with math classes. | ||
6 | * | ||
7 | * $LicenseInfo:firstyear=2009&license=viewergpl$ | ||
8 | * | ||
9 | * Copyright (c) 2009-2010, Linden Research, Inc. | ||
10 | * | ||
11 | * Second Life Viewer Source Code | ||
12 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
13 | * to you under the terms of the GNU General Public License, version 2.0 | ||
14 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
15 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
16 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
17 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
18 | * | ||
19 | * There are special exceptions to the terms and conditions of the GPL as | ||
20 | * it is applied to this Source Code. View the full text of the exception | ||
21 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
22 | * online at | ||
23 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
24 | * | ||
25 | * By copying, modifying or distributing this software, you acknowledge | ||
26 | * that you have read and understood your obligations described above, | ||
27 | * and agree to abide by those obligations. | ||
28 | * | ||
29 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
30 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
31 | * COMPLETENESS OR PERFORMANCE. | ||
32 | * $/LicenseInfo$ | ||
33 | */ | ||
34 | |||
35 | #ifndef LL_LLSDUTIL_MATH_H | ||
36 | #define LL_LLSDUTIL_MATH_H | ||
37 | |||
38 | class LL_COMMON_API LLSD; | ||
39 | |||
40 | // vector3 | ||
41 | class LLVector3; | ||
42 | LLSD ll_sd_from_vector3(const LLVector3& vec); | ||
43 | LLVector3 ll_vector3_from_sd(const LLSD& sd, S32 start_index = 0); | ||
44 | |||
45 | // vector4 | ||
46 | class LLVector4; | ||
47 | LLSD ll_sd_from_vector4(const LLVector4& vec); | ||
48 | LLVector4 ll_vector4_from_sd(const LLSD& sd, S32 start_index = 0); | ||
49 | |||
50 | // vector3d (double) | ||
51 | class LLVector3d; | ||
52 | LLSD ll_sd_from_vector3d(const LLVector3d& vec); | ||
53 | LLVector3d ll_vector3d_from_sd(const LLSD& sd, S32 start_index = 0); | ||
54 | |||
55 | // vector2 | ||
56 | class LLVector2; | ||
57 | LLSD ll_sd_from_vector2(const LLVector2& vec); | ||
58 | LLVector2 ll_vector2_from_sd(const LLSD& sd); | ||
59 | |||
60 | // Quaternion | ||
61 | class LLQuaternion; | ||
62 | LLSD ll_sd_from_quaternion(const LLQuaternion& quat); | ||
63 | LLQuaternion ll_quaternion_from_sd(const LLSD& sd); | ||
64 | |||
65 | // color4 | ||
66 | class LLColor4; | ||
67 | LLSD ll_sd_from_color4(const LLColor4& c); | ||
68 | LLColor4 ll_color4_from_sd(const LLSD& sd); | ||
69 | |||
70 | #endif // LL_LLSDUTIL_MATH_H | ||
diff --git a/linden/indra/llmath/lltreenode.h b/linden/indra/llmath/lltreenode.h index ee98362..ccbeda5 100644 --- a/linden/indra/llmath/lltreenode.h +++ b/linden/indra/llmath/lltreenode.h | |||
@@ -82,8 +82,6 @@ class LLTreeTraveler | |||
82 | { | 82 | { |
83 | public: | 83 | public: |
84 | virtual ~LLTreeTraveler() { }; | 84 | virtual ~LLTreeTraveler() { }; |
85 | virtual void traverse(const LLTreeNode<T>* node) = 0; | ||
86 | virtual void visit(const LLTreeNode<T>* node) = 0; | ||
87 | }; | 85 | }; |
88 | 86 | ||
89 | template <class T> | 87 | template <class T> |
diff --git a/linden/indra/llmath/llvolume.cpp b/linden/indra/llmath/llvolume.cpp index 4c94a52..618048c 100644 --- a/linden/indra/llmath/llvolume.cpp +++ b/linden/indra/llmath/llvolume.cpp | |||
@@ -3376,7 +3376,8 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices, | |||
3376 | std::vector<S32> &segments, | 3376 | std::vector<S32> &segments, |
3377 | const LLVector3& obj_cam_vec, | 3377 | const LLVector3& obj_cam_vec, |
3378 | const LLMatrix4& mat, | 3378 | const LLMatrix4& mat, |
3379 | const LLMatrix3& norm_mat) | 3379 | const LLMatrix3& norm_mat, |
3380 | S32 face_mask) | ||
3380 | { | 3381 | { |
3381 | LLMemType m1(LLMemType::MTYPE_VOLUME); | 3382 | LLMemType m1(LLMemType::MTYPE_VOLUME); |
3382 | 3383 | ||
@@ -3384,12 +3385,17 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices, | |||
3384 | normals.clear(); | 3385 | normals.clear(); |
3385 | segments.clear(); | 3386 | segments.clear(); |
3386 | 3387 | ||
3388 | S32 cur_index = 0; | ||
3387 | //for each face | 3389 | //for each face |
3388 | for (face_list_t::iterator iter = mVolumeFaces.begin(); | 3390 | for (face_list_t::iterator iter = mVolumeFaces.begin(); |
3389 | iter != mVolumeFaces.end(); ++iter) | 3391 | iter != mVolumeFaces.end(); ++iter) |
3390 | { | 3392 | { |
3391 | const LLVolumeFace& face = *iter; | 3393 | const LLVolumeFace& face = *iter; |
3392 | 3394 | ||
3395 | if (!(face_mask & (0x1 << cur_index++))) | ||
3396 | { | ||
3397 | continue; | ||
3398 | } | ||
3393 | if (face.mTypeMask & (LLVolumeFace::CAP_MASK)) { | 3399 | if (face.mTypeMask & (LLVolumeFace::CAP_MASK)) { |
3394 | 3400 | ||
3395 | } | 3401 | } |
@@ -3577,7 +3583,7 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, | |||
3577 | if (face == -1) // ALL_SIDES | 3583 | if (face == -1) // ALL_SIDES |
3578 | { | 3584 | { |
3579 | start_face = 0; | 3585 | start_face = 0; |
3580 | end_face = getNumFaces() - 1; | 3586 | end_face = getNumVolumeFaces() - 1; |
3581 | } | 3587 | } |
3582 | else | 3588 | else |
3583 | { | 3589 | { |
@@ -4268,7 +4274,7 @@ LLFaceID LLVolume::generateFaceMask() | |||
4268 | } | 4274 | } |
4269 | break; | 4275 | break; |
4270 | default: | 4276 | default: |
4271 | llerrs << "Unknown profile!" << llendl | 4277 | llerrs << "Unknown profile!" << llendl; |
4272 | break; | 4278 | break; |
4273 | } | 4279 | } |
4274 | 4280 | ||
diff --git a/linden/indra/llmath/llvolume.h b/linden/indra/llmath/llvolume.h index e55fe52..77af2c4 100644 --- a/linden/indra/llmath/llvolume.h +++ b/linden/indra/llmath/llvolume.h | |||
@@ -154,6 +154,9 @@ const U8 LL_PCODE_PATH_IGNORE = 0x00; | |||
154 | const U8 LL_PCODE_PATH_MIN = 0x01; // min/max needs to be >> 4 of real min/max | 154 | const U8 LL_PCODE_PATH_MIN = 0x01; // min/max needs to be >> 4 of real min/max |
155 | const U8 LL_PCODE_PATH_LINE = 0x10; | 155 | const U8 LL_PCODE_PATH_LINE = 0x10; |
156 | const U8 LL_PCODE_PATH_CIRCLE = 0x20; | 156 | const U8 LL_PCODE_PATH_CIRCLE = 0x20; |
157 | //<-- Working33 by Gregory Maurer | ||
158 | const U8 LL_PCODE_PATH_CIRCLE_33 = 0x21; | ||
159 | //Working33 --> | ||
157 | const U8 LL_PCODE_PATH_CIRCLE2 = 0x30; | 160 | const U8 LL_PCODE_PATH_CIRCLE2 = 0x30; |
158 | const U8 LL_PCODE_PATH_TEST = 0x40; | 161 | const U8 LL_PCODE_PATH_TEST = 0x40; |
159 | const U8 LL_PCODE_PATH_FLEXIBLE = 0x80; | 162 | const U8 LL_PCODE_PATH_FLEXIBLE = 0x80; |
@@ -902,9 +905,13 @@ public: | |||
902 | // returns number of triangle indeces required for path/profile mesh | 905 | // returns number of triangle indeces required for path/profile mesh |
903 | S32 getNumTriangleIndices() const; | 906 | S32 getNumTriangleIndices() const; |
904 | 907 | ||
905 | void generateSilhouetteVertices(std::vector<LLVector3> &vertices, std::vector<LLVector3> &normals, std::vector<S32> &segments, const LLVector3& view_vec, | 908 | void generateSilhouetteVertices(std::vector<LLVector3> &vertices, |
906 | const LLMatrix4& mat, | 909 | std::vector<LLVector3> &normals, |
907 | const LLMatrix3& norm_mat); | 910 | std::vector<S32> &segments, |
911 | const LLVector3& view_vec, | ||
912 | const LLMatrix4& mat, | ||
913 | const LLMatrix3& norm_mat, | ||
914 | S32 face_index); | ||
908 | 915 | ||
909 | //get the face index of the face that intersects with the given line segment at the point | 916 | //get the face index of the face that intersects with the given line segment at the point |
910 | //closest to start. Moves end to the point of intersection. Returns -1 if no intersection. | 917 | //closest to start. Moves end to the point of intersection. Returns -1 if no intersection. |
@@ -942,9 +949,11 @@ public: | |||
942 | LLVector3 mLODScaleBias; // vector for biasing LOD based on scale | 949 | LLVector3 mLODScaleBias; // vector for biasing LOD based on scale |
943 | 950 | ||
944 | void sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level); | 951 | void sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level); |
952 | |||
953 | F32 sculptGetSurfaceArea(); | ||
954 | |||
945 | private: | 955 | private: |
946 | void sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, U8 sculpt_type); | 956 | void sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, U8 sculpt_type); |
947 | F32 sculptGetSurfaceArea(); | ||
948 | void sculptGeneratePlaceholder(); | 957 | void sculptGeneratePlaceholder(); |
949 | void sculptCalcMeshResolution(U16 width, U16 height, U8 type, S32& s, S32& t); | 958 | void sculptCalcMeshResolution(U16 width, U16 height, U8 type, S32& s, S32& t); |
950 | 959 | ||
diff --git a/linden/indra/llmath/llvolumemgr.cpp b/linden/indra/llmath/llvolumemgr.cpp index 53641fc..8bfebcb 100644 --- a/linden/indra/llmath/llvolumemgr.cpp +++ b/linden/indra/llmath/llvolumemgr.cpp | |||
@@ -55,7 +55,7 @@ LLVolumeMgr::LLVolumeMgr() | |||
55 | { | 55 | { |
56 | // the LLMutex magic interferes with easy unit testing, | 56 | // the LLMutex magic interferes with easy unit testing, |
57 | // so you now must manually call useMutex() to use it | 57 | // so you now must manually call useMutex() to use it |
58 | //mDataMutex = new LLMutex(gAPRPoolp); | 58 | //mDataMutex = new LLMutex; |
59 | } | 59 | } |
60 | 60 | ||
61 | LLVolumeMgr::~LLVolumeMgr() | 61 | LLVolumeMgr::~LLVolumeMgr() |
@@ -222,7 +222,7 @@ void LLVolumeMgr::useMutex() | |||
222 | { | 222 | { |
223 | if (!mDataMutex) | 223 | if (!mDataMutex) |
224 | { | 224 | { |
225 | mDataMutex = new LLMutex(gAPRPoolp); | 225 | mDataMutex = new LLMutex; |
226 | } | 226 | } |
227 | } | 227 | } |
228 | 228 | ||
diff --git a/linden/indra/llmath/v3math.h b/linden/indra/llmath/v3math.h index 7f96800..8c65d93 100644 --- a/linden/indra/llmath/v3math.h +++ b/linden/indra/llmath/v3math.h | |||
@@ -411,8 +411,8 @@ inline bool operator<(const LLVector3 &a, const LLVector3 &b) | |||
411 | return (a.mV[0] < b.mV[0] | 411 | return (a.mV[0] < b.mV[0] |
412 | || (a.mV[0] == b.mV[0] | 412 | || (a.mV[0] == b.mV[0] |
413 | && (a.mV[1] < b.mV[1] | 413 | && (a.mV[1] < b.mV[1] |
414 | || (a.mV[1] == b.mV[1]) | 414 | || ((a.mV[1] == b.mV[1]) |
415 | && a.mV[2] < b.mV[2]))); | 415 | && a.mV[2] < b.mV[2])))); |
416 | } | 416 | } |
417 | 417 | ||
418 | inline const LLVector3& operator+=(LLVector3 &a, const LLVector3 &b) | 418 | inline const LLVector3& operator+=(LLVector3 &a, const LLVector3 &b) |