aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmath')
-rw-r--r--linden/indra/llmath/camera.h2
-rw-r--r--linden/indra/llmath/coordframe.h2
-rw-r--r--linden/indra/llmath/llquaternion.cpp2
-rw-r--r--linden/indra/llmath/llrand.h4
-rw-r--r--linden/indra/llmath/llvolume.cpp193
-rw-r--r--linden/indra/llmath/llvolume.h6
-rw-r--r--linden/indra/llmath/v3color.cpp2
7 files changed, 146 insertions, 65 deletions
diff --git a/linden/indra/llmath/camera.h b/linden/indra/llmath/camera.h
index 3aa86d5..be8c711 100644
--- a/linden/indra/llmath/camera.h
+++ b/linden/indra/llmath/camera.h
@@ -2,7 +2,7 @@
2 * @file camera.h 2 * @file camera.h
3 * @brief Legacy wrapper header. 3 * @brief Legacy wrapper header.
4 * 4 *
5 * Copyright (c) 2000-2007 Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code 7 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
diff --git a/linden/indra/llmath/coordframe.h b/linden/indra/llmath/coordframe.h
index 611387d..01d3031 100644
--- a/linden/indra/llmath/coordframe.h
+++ b/linden/indra/llmath/coordframe.h
@@ -2,7 +2,7 @@
2 * @file coordframe.h 2 * @file coordframe.h
3 * @brief Legacy wrapper header. 3 * @brief Legacy wrapper header.
4 * 4 *
5 * Copyright (c) 2000-2007 Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code 7 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
diff --git a/linden/indra/llmath/llquaternion.cpp b/linden/indra/llmath/llquaternion.cpp
index abc9e42..06e34af 100644
--- a/linden/indra/llmath/llquaternion.cpp
+++ b/linden/indra/llmath/llquaternion.cpp
@@ -1,5 +1,5 @@
1/** 1/**
2 * @file qmath.cpp 2 * @file llquaternion.cpp
3 * @brief LLQuaternion class implementation. 3 * @brief LLQuaternion class implementation.
4 * 4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
diff --git a/linden/indra/llmath/llrand.h b/linden/indra/llmath/llrand.h
index 4a3dca6..c5ab7e3 100644
--- a/linden/indra/llmath/llrand.h
+++ b/linden/indra/llmath/llrand.h
@@ -29,8 +29,8 @@
29#ifndef LL_LLRAND_H 29#ifndef LL_LLRAND_H
30#define LL_LLRAND_H 30#define LL_LLRAND_H
31 31
32#include "boost/random/lagged_fibonacci.hpp" 32#include <boost/random/lagged_fibonacci.hpp>
33#include "boost/random/mersenne_twister.hpp" 33#include <boost/random/mersenne_twister.hpp>
34 34
35/** 35/**
36 * Use the boost random number generators if you want a stateful 36 * Use the boost random number generators if you want a stateful
diff --git a/linden/indra/llmath/llvolume.cpp b/linden/indra/llmath/llvolume.cpp
index 327f1bf..5764c38 100644
--- a/linden/indra/llmath/llvolume.cpp
+++ b/linden/indra/llmath/llvolume.cpp
@@ -1799,6 +1799,8 @@ void LLVolume::createVolumeFaces()
1799// sculpt replaces generate() for sculpted surfaces 1799// sculpt replaces generate() for sculpted surfaces
1800void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level) 1800void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level)
1801{ 1801{
1802 U8 sculpt_type = mParams.getSculptType();
1803
1802 BOOL data_is_empty = FALSE; 1804 BOOL data_is_empty = FALSE;
1803 1805
1804 if (sculpt_width == 0 || sculpt_height == 0 || sculpt_data == NULL) 1806 if (sculpt_width == 0 || sculpt_height == 0 || sculpt_data == NULL)
@@ -1880,6 +1882,7 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
1880 line += sizeT; 1882 line += sizeT;
1881 } 1883 }
1882 } 1884 }
1885
1883 else 1886 else
1884 { 1887 {
1885 S32 line = 0; 1888 S32 line = 0;
@@ -1894,18 +1897,52 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
1894 U32 x = (U32) ((F32)t/(sizeT-1) * (F32) sculpt_width); 1897 U32 x = (U32) ((F32)t/(sizeT-1) * (F32) sculpt_width);
1895 U32 y = (U32) ((F32)s/(sizeS-1) * (F32) sculpt_height); 1898 U32 y = (U32) ((F32)s/(sizeS-1) * (F32) sculpt_height);
1896 1899
1897 if (y == sculpt_height) // stitch bottom row 1900 if (y == 0) // top row stitching
1898 { 1901 {
1899 y = sculpt_height - 1; 1902 // pinch?
1900 x = sculpt_width / 2; 1903 if (sculpt_type == LL_SCULPT_TYPE_SPHERE)
1904 {
1905 x = sculpt_width / 2;
1906 }
1901 } 1907 }
1902 1908
1903 if (x == sculpt_width) // stitch sides 1909 if (y == sculpt_height) // bottom row stitching
1904 x = 0; 1910 {
1911 // wrap?
1912 if (sculpt_type == LL_SCULPT_TYPE_TORUS)
1913 {
1914 y = 0;
1915 }
1916 else
1917 {
1918 y = sculpt_height - 1;
1919 }
1905 1920
1906 if (y == 0) // stitch top row 1921 // pinch?
1907 x = sculpt_width / 2; 1922 if (sculpt_type == LL_SCULPT_TYPE_SPHERE)
1908 1923 {
1924 x = sculpt_width / 2;
1925 }
1926 }
1927
1928 if (x == sculpt_width) // side stitching
1929 {
1930 // wrap?
1931 if ((sculpt_type == LL_SCULPT_TYPE_SPHERE) ||
1932 (sculpt_type == LL_SCULPT_TYPE_TORUS) ||
1933 (sculpt_type == LL_SCULPT_TYPE_CYLINDER))
1934 {
1935 x = 0;
1936 }
1937
1938 else
1939 {
1940 x = sculpt_width - 1;
1941 }
1942 }
1943
1944
1945
1909 U32 index = (x + y * sculpt_width) * sculpt_components; 1946 U32 index = (x + y * sculpt_width) * sculpt_components;
1910 pt.mPos.mV[0] = sculpt_data[index ] / 256.f - 0.5f; 1947 pt.mPos.mV[0] = sculpt_data[index ] / 256.f - 0.5f;
1911 pt.mPos.mV[1] = sculpt_data[index+1] / 256.f - 0.5f; 1948 pt.mPos.mV[1] = sculpt_data[index+1] / 256.f - 0.5f;
@@ -4615,82 +4652,130 @@ BOOL LLVolumeFace::createSide()
4615 } 4652 }
4616 } 4653 }
4617 4654
4655 // adjust normals based on wrapping and stitching
4656
4618 BOOL s_bottom_converges = ((mVertices[0].mPosition - mVertices[mNumS*(mNumT-2)].mPosition).magVecSquared() < 0.000001f); 4657 BOOL s_bottom_converges = ((mVertices[0].mPosition - mVertices[mNumS*(mNumT-2)].mPosition).magVecSquared() < 0.000001f);
4619 BOOL s_top_converges = ((mVertices[mNumS-1].mPosition - mVertices[mNumS*(mNumT-2)+mNumS-1].mPosition).magVecSquared() < 0.000001f); 4658 BOOL s_top_converges = ((mVertices[mNumS-1].mPosition - mVertices[mNumS*(mNumT-2)+mNumS-1].mPosition).magVecSquared() < 0.000001f);
4620 4659 U8 sculpt_type = mVolumep->getParams().getSculptType();
4621 if (mVolumep->getPath().isOpen() == FALSE) { //wrap normals on T 4660
4622 for (S32 i = 0; i < mNumS; i++) { 4661 if (sculpt_type == LL_SCULPT_TYPE_NONE) // logic for non-sculpt volumes
4623 LLVector3 norm = mVertices[i].mNormal + mVertices[mNumS*(mNumT-1)+i].mNormal; 4662 {
4624 mVertices[i].mNormal = norm; 4663 if (mVolumep->getPath().isOpen() == FALSE)
4625 mVertices[mNumS*(mNumT-1)+i].mNormal = norm; 4664 { //wrap normals on T
4665 for (S32 i = 0; i < mNumS; i++)
4666 {
4667 LLVector3 norm = mVertices[i].mNormal + mVertices[mNumS*(mNumT-1)+i].mNormal;
4668 mVertices[i].mNormal = norm;
4669 mVertices[mNumS*(mNumT-1)+i].mNormal = norm;
4670 }
4626 } 4671 }
4627 }
4628 4672
4629 if ((mVolumep->getProfile().isOpen() == FALSE) && 4673 if ((mVolumep->getProfile().isOpen() == FALSE) && !(s_bottom_converges))
4630 !(s_bottom_converges))
4631 { //wrap normals on S 4674 { //wrap normals on S
4632 for (S32 i = 0; i < mNumT; i++) { 4675 for (S32 i = 0; i < mNumT; i++)
4676 {
4633 LLVector3 norm = mVertices[mNumS*i].mNormal + mVertices[mNumS*i+mNumS-1].mNormal; 4677 LLVector3 norm = mVertices[mNumS*i].mNormal + mVertices[mNumS*i+mNumS-1].mNormal;
4634 mVertices[mNumS * i].mNormal = norm; 4678 mVertices[mNumS * i].mNormal = norm;
4635 mVertices[mNumS * i+mNumS-1].mNormal = norm; 4679 mVertices[mNumS * i+mNumS-1].mNormal = norm;
4636 } 4680 }
4637 } 4681 }
4638 4682
4639 if (mVolumep->getPathType() == LL_PCODE_PATH_CIRCLE && 4683 if (mVolumep->getPathType() == LL_PCODE_PATH_CIRCLE &&
4640 ((mVolumep->getProfileType() & LL_PCODE_PROFILE_MASK) == LL_PCODE_PROFILE_CIRCLE_HALF)) 4684 ((mVolumep->getProfileType() & LL_PCODE_PROFILE_MASK) == LL_PCODE_PROFILE_CIRCLE_HALF))
4641 { 4685 {
4642 if (s_bottom_converges) 4686 if (s_bottom_converges)
4643 { //all lower S have same normal 4687 { //all lower S have same normal
4644 for (S32 i = 0; i < mNumT; i++) { 4688 for (S32 i = 0; i < mNumT; i++)
4645 mVertices[mNumS*i].mNormal = LLVector3(1,0,0); 4689 {
4690 mVertices[mNumS*i].mNormal = LLVector3(1,0,0);
4691 }
4646 } 4692 }
4647 }
4648 4693
4649 if (s_top_converges) 4694 if (s_top_converges)
4650 { //all upper S have same normal 4695 { //all upper S have same normal
4651 for (S32 i = 0; i < mNumT; i++) { 4696 for (S32 i = 0; i < mNumT; i++)
4652 mVertices[mNumS*i+mNumS-1].mNormal = LLVector3(-1,0,0); 4697 {
4698 mVertices[mNumS*i+mNumS-1].mNormal = LLVector3(-1,0,0);
4699 }
4653 } 4700 }
4654 } 4701 }
4655 } 4702 }
4656
4657 U8 sculpt_type = mVolumep->getParams().getSculptType();
4658 4703
4659 if (sculpt_type == LL_SCULPT_TYPE_SPHERE) 4704 else // logic for sculpt volumes
4660 { 4705 {
4661 // average normals for north pole 4706 BOOL average_poles = FALSE;
4707 BOOL wrap_s = FALSE;
4708 BOOL wrap_t = FALSE;
4709
4710 if (sculpt_type == LL_SCULPT_TYPE_SPHERE)
4711 average_poles = TRUE;
4712
4713 if ((sculpt_type == LL_SCULPT_TYPE_SPHERE) ||
4714 (sculpt_type == LL_SCULPT_TYPE_TORUS) ||
4715 (sculpt_type == LL_SCULPT_TYPE_CYLINDER))
4716 wrap_s = TRUE;
4717
4718 if (sculpt_type == LL_SCULPT_TYPE_TORUS)
4719 wrap_t = TRUE;
4720
4662 4721
4663 LLVector3 average(0.0, 0.0, 0.0); 4722 if (average_poles)
4664 for (S32 i = 0; i < mNumS; i++)
4665 { 4723 {
4666 average += mVertices[i].mNormal; 4724 // average normals for north pole
4667 } 4725
4726 LLVector3 average(0.0, 0.0, 0.0);
4727 for (S32 i = 0; i < mNumS; i++)
4728 {
4729 average += mVertices[i].mNormal;
4730 }
4731
4732 // set average
4733 for (S32 i = 0; i < mNumS; i++)
4734 {
4735 mVertices[i].mNormal = average;
4736 }
4737
4738 // average normals for south pole
4739
4740 average = LLVector3(0.0, 0.0, 0.0);
4741 for (S32 i = 0; i < mNumS; i++)
4742 {
4743 average += mVertices[i + mNumS * (mNumT - 1)].mNormal;
4744 }
4745
4746 // set average
4747 for (S32 i = 0; i < mNumS; i++)
4748 {
4749 mVertices[i + mNumS * (mNumT - 1)].mNormal = average;
4750 }
4668 4751
4669 // set average
4670 for (S32 i = 0; i < mNumS; i++)
4671 {
4672 mVertices[i].mNormal = average;
4673 } 4752 }
4674 }
4675 4753
4676
4677 if (sculpt_type == LL_SCULPT_TYPE_SPHERE)
4678 {
4679 // average normals for south pole
4680 4754
4681 LLVector3 average(0.0, 0.0, 0.0); 4755 if (wrap_s)
4682 for (S32 i = 0; i < mNumS; i++)
4683 { 4756 {
4684 average += mVertices[i + mNumS * (mNumT - 1)].mNormal; 4757 for (S32 i = 0; i < mNumT; i++)
4758 {
4759 LLVector3 norm = mVertices[mNumS*i].mNormal + mVertices[mNumS*i+mNumS-1].mNormal;
4760 mVertices[mNumS * i].mNormal = norm;
4761 mVertices[mNumS * i+mNumS-1].mNormal = norm;
4762 }
4685 } 4763 }
4686 4764
4687 // set average 4765
4688 for (S32 i = 0; i < mNumS; i++) 4766
4767 if (wrap_t)
4689 { 4768 {
4690 mVertices[i + mNumS * (mNumT - 1)].mNormal = average; 4769 for (S32 i = 0; i < mNumS; i++)
4770 {
4771 LLVector3 norm = mVertices[i].mNormal + mVertices[mNumS*(mNumT-1)+i].mNormal;
4772 mVertices[i].mNormal = norm;
4773 mVertices[mNumS*(mNumT-1)+i].mNormal = norm;
4774 }
4775
4691 } 4776 }
4692 }
4693 4777
4778 }
4694 4779
4695 4780
4696 //normalize normals and binormals here so the meshes that reference 4781 //normalize normals and binormals here so the meshes that reference
diff --git a/linden/indra/llmath/llvolume.h b/linden/indra/llmath/llvolume.h
index 6ac07f5..3973f70 100644
--- a/linden/indra/llmath/llvolume.h
+++ b/linden/indra/llmath/llvolume.h
@@ -174,7 +174,7 @@ const LLFaceID LL_FACE_OUTER_SIDE_3 = 0x1 << 8;
174const U8 LL_SCULPT_TYPE_NONE = 0; 174const U8 LL_SCULPT_TYPE_NONE = 0;
175const U8 LL_SCULPT_TYPE_SPHERE = 1; 175const U8 LL_SCULPT_TYPE_SPHERE = 1;
176const U8 LL_SCULPT_TYPE_TORUS = 2; 176const U8 LL_SCULPT_TYPE_TORUS = 2;
177const U8 LL_SCULPT_TYPE_PLAIN = 3; 177const U8 LL_SCULPT_TYPE_PLANE = 3;
178const U8 LL_SCULPT_TYPE_CYLINDER = 4; 178const U8 LL_SCULPT_TYPE_CYLINDER = 4;
179 179
180 180
@@ -860,9 +860,6 @@ public:
860 BOOL isUnique() const { return mUnique; } 860 BOOL isUnique() const { return mUnique; }
861 861
862 S32 getSculptLevel() const { return mSculptLevel; } 862 S32 getSculptLevel() const { return mSculptLevel; }
863 void setSculptLevel(S32 level) { mSculptLevel = level; }
864
865 U8 getSculptType() const { return mSculptType; }
866 863
867 S32 *getTriangleIndices(U32 &num_indices) const; 864 S32 *getTriangleIndices(U32 &num_indices) const;
868 void generateSilhouetteVertices(std::vector<LLVector3> &vertices, std::vector<LLVector3> &normals, std::vector<S32> &segments, const LLVector3& view_vec, 865 void generateSilhouetteVertices(std::vector<LLVector3> &vertices, std::vector<LLVector3> &normals, std::vector<S32> &segments, const LLVector3& view_vec,
@@ -908,7 +905,6 @@ protected:
908 BOOL mUnique; 905 BOOL mUnique;
909 F32 mDetail; 906 F32 mDetail;
910 S32 mSculptLevel; 907 S32 mSculptLevel;
911 U8 mSculptType;
912 908
913 LLVolumeParams mParams; 909 LLVolumeParams mParams;
914 LLPath *mPathp; 910 LLPath *mPathp;
diff --git a/linden/indra/llmath/v3color.cpp b/linden/indra/llmath/v3color.cpp
index 5464a0b..5378bc5 100644
--- a/linden/indra/llmath/v3color.cpp
+++ b/linden/indra/llmath/v3color.cpp
@@ -110,4 +110,4 @@ void LLColor3::calcHSL(F32* hue, F32* saturation, F32* luminance) const
110 if (hue) *hue = H; 110 if (hue) *hue = H;
111 if (saturation) *saturation = S; 111 if (saturation) *saturation = S;
112 if (luminance) *luminance = L; 112 if (luminance) *luminance = L;
113} \ No newline at end of file 113}