aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath/llvolume.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llmath/llvolume.h
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llmath/llvolume.h')
-rw-r--r--linden/indra/llmath/llvolume.h100
1 files changed, 71 insertions, 29 deletions
diff --git a/linden/indra/llmath/llvolume.h b/linden/indra/llmath/llvolume.h
index 5b48cfc..8ac0e71 100644
--- a/linden/indra/llmath/llvolume.h
+++ b/linden/indra/llmath/llvolume.h
@@ -175,7 +175,7 @@ const LLFaceID LL_FACE_OUTER_SIDE_3 = 0x1 << 8;
175 175
176//============================================================================ 176//============================================================================
177 177
178// sculpt types 178// sculpt types + flags
179 179
180const U8 LL_SCULPT_TYPE_NONE = 0; 180const U8 LL_SCULPT_TYPE_NONE = 0;
181const U8 LL_SCULPT_TYPE_SPHERE = 1; 181const U8 LL_SCULPT_TYPE_SPHERE = 1;
@@ -183,21 +183,30 @@ const U8 LL_SCULPT_TYPE_TORUS = 2;
183const U8 LL_SCULPT_TYPE_PLANE = 3; 183const U8 LL_SCULPT_TYPE_PLANE = 3;
184const U8 LL_SCULPT_TYPE_CYLINDER = 4; 184const U8 LL_SCULPT_TYPE_CYLINDER = 4;
185 185
186const U8 LL_SCULPT_TYPE_MASK = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE | LL_SCULPT_TYPE_CYLINDER;
187
188const U8 LL_SCULPT_FLAG_INVERT = 64;
189const U8 LL_SCULPT_FLAG_MIRROR = 128;
186 190
187 191
188class LLProfileParams 192class LLProfileParams
189{ 193{
190public: 194public:
191 LLProfileParams() 195 LLProfileParams()
196 : mCurveType(LL_PCODE_PROFILE_SQUARE),
197 mBegin(0.f),
198 mEnd(1.f),
199 mHollow(0.f),
200 mCRC(0)
192 { 201 {
193 mCurveType = LL_PCODE_PROFILE_SQUARE;
194 mBegin = 0.f;
195 mEnd = 1.f;
196 mHollow = 0.f;
197 } 202 }
198 203
199 LLProfileParams(U8 curve, F32 begin, F32 end, F32 hollow) 204 LLProfileParams(U8 curve, F32 begin, F32 end, F32 hollow)
200 : mCurveType(curve), mBegin(begin), mEnd(end), mHollow(hollow) 205 : mCurveType(curve),
206 mBegin(begin),
207 mEnd(end),
208 mHollow(hollow),
209 mCRC(0)
201 { 210 {
202 } 211 }
203 212
@@ -222,6 +231,7 @@ public:
222 temp_f32 = 1.f; 231 temp_f32 = 1.f;
223 } 232 }
224 mHollow = temp_f32; 233 mHollow = temp_f32;
234 mCRC = 0;
225 } 235 }
226 236
227 bool operator==(const LLProfileParams &params) const; 237 bool operator==(const LLProfileParams &params) const;
@@ -309,27 +319,36 @@ class LLPathParams
309{ 319{
310public: 320public:
311 LLPathParams() 321 LLPathParams()
322 :
323 mCurveType(LL_PCODE_PATH_LINE),
324 mBegin(0.f),
325 mEnd(1.f),
326 mScale(1.f,1.f),
327 mShear(0.f,0.f),
328 mTwistBegin(0.f),
329 mTwistEnd(0.f),
330 mRadiusOffset(0.f),
331 mTaper(0.f,0.f),
332 mRevolutions(1.f),
333 mSkew(0.f),
334 mCRC(0)
312 { 335 {
313 mBegin = 0.f;
314 mEnd = 1.f;
315 mScale.setVec(1.f,1.f);
316 mShear.setVec(0.f,0.f);
317 mCurveType = LL_PCODE_PATH_LINE;
318 mTwistBegin = 0.f;
319 mTwistEnd = 0.f;
320 mRadiusOffset = 0.f;
321 mTaper.setVec(0.f,0.f);
322 mRevolutions = 1.f;
323 mSkew = 0.f;
324 } 336 }
325 337
326 LLPathParams(U8 curve, F32 begin, F32 end, F32 scx, F32 scy, F32 shx, F32 shy, F32 twistend, F32 twistbegin, F32 radiusoffset, F32 tx, F32 ty, F32 revolutions, F32 skew) 338 LLPathParams(U8 curve, F32 begin, F32 end, F32 scx, F32 scy, F32 shx, F32 shy, F32 twistend, F32 twistbegin, F32 radiusoffset, F32 tx, F32 ty, F32 revolutions, F32 skew)
327 : mCurveType(curve), mBegin(begin), mEnd(end), mTwistBegin(twistbegin), mTwistEnd(twistend), 339 : mCurveType(curve),
328 mRadiusOffset(radiusoffset), mRevolutions(revolutions), mSkew(skew) 340 mBegin(begin),
341 mEnd(end),
342 mScale(scx,scy),
343 mShear(shx,shy),
344 mTwistBegin(twistbegin),
345 mTwistEnd(twistend),
346 mRadiusOffset(radiusoffset),
347 mTaper(tx,ty),
348 mRevolutions(revolutions),
349 mSkew(skew),
350 mCRC(0)
329 { 351 {
330 mScale.setVec(scx,scy);
331 mShear.setVec(shx,shy);
332 mTaper.setVec(tx,ty);
333 } 352 }
334 353
335 LLPathParams(U8 curve, U16 begin, U16 end, U8 scx, U8 scy, U8 shx, U8 shy, U8 twistend, U8 twistbegin, U8 radiusoffset, U8 tx, U8 ty, U8 revolutions, U8 skew) 354 LLPathParams(U8 curve, U16 begin, U16 end, U8 scx, U8 scy, U8 shx, U8 shy, U8 twistend, U8 twistbegin, U8 radiusoffset, U8 tx, U8 ty, U8 revolutions, U8 skew)
@@ -347,6 +366,8 @@ public:
347 mTaper.setVec(U8_TO_F32(tx) * TAPER_QUANTA,U8_TO_F32(ty) * TAPER_QUANTA); 366 mTaper.setVec(U8_TO_F32(tx) * TAPER_QUANTA,U8_TO_F32(ty) * TAPER_QUANTA);
348 mRevolutions = ((F32)revolutions) * REV_QUANTA + 1.0f; 367 mRevolutions = ((F32)revolutions) * REV_QUANTA + 1.0f;
349 mSkew = U8_TO_F32(skew) * SCALE_QUANTA; 368 mSkew = U8_TO_F32(skew) * SCALE_QUANTA;
369
370 mCRC = 0;
350 } 371 }
351 372
352 bool operator==(const LLPathParams &params) const; 373 bool operator==(const LLPathParams &params) const;
@@ -525,6 +546,7 @@ class LLVolumeParams
525{ 546{
526public: 547public:
527 LLVolumeParams() 548 LLVolumeParams()
549 : mSculptType(LL_SCULPT_TYPE_NONE)
528 { 550 {
529 } 551 }
530 552
@@ -649,7 +671,9 @@ public:
649 mConcave(FALSE), 671 mConcave(FALSE),
650 mDirty(TRUE), 672 mDirty(TRUE),
651 mTotalOut(0), 673 mTotalOut(0),
652 mTotal(2) 674 mTotal(2),
675 mMinX(0.f),
676 mMaxX(0.f)
653 { 677 {
654 } 678 }
655 679
@@ -660,7 +684,8 @@ public:
660 BOOL isFlat(S32 face) const { return (mFaces[face].mCount == 2); } 684 BOOL isFlat(S32 face) const { return (mFaces[face].mCount == 2); }
661 BOOL isOpen() const { return mOpen; } 685 BOOL isOpen() const { return mOpen; }
662 void setDirty() { mDirty = TRUE; } 686 void setDirty() { mDirty = TRUE; }
663 BOOL generate(const LLProfileParams& params, BOOL path_open, F32 detail = 1.0f, S32 split = 0, BOOL is_sculpted = FALSE); 687 BOOL generate(const LLProfileParams& params, BOOL path_open, F32 detail = 1.0f, S32 split = 0,
688 BOOL is_sculpted = FALSE, S32 sculpt_size = 0);
664 BOOL isConcave() const { return mConcave; } 689 BOOL isConcave() const { return mConcave; }
665public: 690public:
666 struct Face 691 struct Face
@@ -678,8 +703,6 @@ public:
678 std::vector<Face> mFaces; 703 std::vector<Face> mFaces;
679 std::vector<LLVector3> mEdgeNormals; 704 std::vector<LLVector3> mEdgeNormals;
680 std::vector<LLVector3> mEdgeCenters; 705 std::vector<LLVector3> mEdgeCenters;
681 F32 mMaxX;
682 F32 mMinX;
683 706
684 friend std::ostream& operator<<(std::ostream &s, const LLProfile &profile); 707 friend std::ostream& operator<<(std::ostream &s, const LLProfile &profile);
685 708
@@ -698,6 +721,9 @@ protected:
698 721
699 S32 mTotalOut; 722 S32 mTotalOut;
700 S32 mTotal; 723 S32 mTotal;
724
725 F32 mMaxX;
726 F32 mMinX;
701}; 727};
702 728
703//------------------------------------------------------------------- 729//-------------------------------------------------------------------
@@ -728,7 +754,8 @@ public:
728 virtual ~LLPath(); 754 virtual ~LLPath();
729 755
730 void genNGon(const LLPathParams& params, S32 sides, F32 offset=0.0f, F32 end_scale = 1.f, F32 twist_scale = 1.f); 756 void genNGon(const LLPathParams& params, S32 sides, F32 offset=0.0f, F32 end_scale = 1.f, F32 twist_scale = 1.f);
731 virtual BOOL generate(const LLPathParams& params, F32 detail=1.0f, S32 split = 0, BOOL is_sculpted = FALSE); 757 virtual BOOL generate(const LLPathParams& params, F32 detail=1.0f, S32 split = 0,
758 BOOL is_sculpted = FALSE, S32 sculpt_size = 0);
732 759
733 BOOL isOpen() const { return mOpen; } 760 BOOL isOpen() const { return mOpen; }
734 F32 getStep() const { return mStep; } 761 F32 getStep() const { return mStep; }
@@ -754,7 +781,8 @@ class LLDynamicPath : public LLPath
754{ 781{
755public: 782public:
756 LLDynamicPath() : LLPath() { } 783 LLDynamicPath() : LLPath() { }
757 /*virtual*/ BOOL generate(const LLPathParams& params, F32 detail=1.0f, S32 split = 0, BOOL is_sculpted = FALSE); 784 /*virtual*/ BOOL generate(const LLPathParams& params, F32 detail=1.0f, S32 split = 0,
785 BOOL is_sculpted = FALSE, S32 sculpt_size = 0);
758}; 786};
759 787
760// Yet another "face" class - caches volume-specific, but not instance-specific data for faces) 788// Yet another "face" class - caches volume-specific, but not instance-specific data for faces)
@@ -885,7 +913,13 @@ public:
885 //get the face index of the face that intersects with the given line segment at the point 913 //get the face index of the face that intersects with the given line segment at the point
886 //closest to start. Moves end to the point of intersection. Returns -1 if no intersection. 914 //closest to start. Moves end to the point of intersection. Returns -1 if no intersection.
887 //Line segment must be in volume space. 915 //Line segment must be in volume space.
888 S32 lineSegmentIntersect(const LLVector3& start, LLVector3& end) const; 916 S32 lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
917 S32 face = -1, // which face to check, -1 = ALL_SIDES
918 LLVector3* intersection = NULL, // return the intersection point
919 LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
920 LLVector3* normal = NULL, // return the surface normal at the intersection point
921 LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
922 );
889 923
890 // The following cleans up vertices and triangles, 924 // The following cleans up vertices and triangles,
891 // getting rid of degenerate triangles and duplicate vertices, 925 // getting rid of degenerate triangles and duplicate vertices,
@@ -916,6 +950,8 @@ private:
916 F32 sculptGetSurfaceArea(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data); 950 F32 sculptGetSurfaceArea(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data);
917 void sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, U8 sculpt_type); 951 void sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, U8 sculpt_type);
918 void sculptGeneratePlaceholder(); 952 void sculptGeneratePlaceholder();
953 void sculptCalcMeshResolution(U16 width, U16 height, U8 type, S32& s, S32& t);
954
919 955
920protected: 956protected:
921 BOOL generate(); 957 BOOL generate();
@@ -946,4 +982,10 @@ LLVector3 calc_binormal_from_triangle(
946 const LLVector3& pos2, 982 const LLVector3& pos2,
947 const LLVector2& tex2); 983 const LLVector2& tex2);
948 984
985BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size);
986BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir,
987 F32* intersection_a, F32* intersection_b, F32* intersection_t, BOOL two_sided);
988
989
990
949#endif 991#endif