summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
authorKelly Washington <kelly@lindenlab.com>2007-06-21 22:40:22 +0000
committerKelly Washington <kelly@lindenlab.com>2007-06-21 22:40:22 +0000
commite03bb0606a10f29c8b94909a713a5bb5c69e88b7 (patch)
tree6d8d07894579438c8cc70e08f5730c3c95dfe768 /indra/llmath
parent2638f12f95eea692502836cf6548b4a0b234d009 (diff)
merge -r62831:64079 branches/maintenance to release
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/camera.h2
-rw-r--r--indra/llmath/coordframe.h2
-rw-r--r--indra/llmath/llquaternion.cpp2
-rw-r--r--indra/llmath/llvolume.cpp193
-rw-r--r--indra/llmath/llvolume.h6
-rw-r--r--indra/llmath/v3color.cpp2
6 files changed, 144 insertions, 63 deletions
diff --git a/indra/llmath/camera.h b/indra/llmath/camera.h
index f130a036a1..63af2d794d 100644
--- a/indra/llmath/camera.h
+++ b/indra/llmath/camera.h
@@ -2,7 +2,7 @@
* @file camera.h
* @brief Legacy wrapper header.
*
- * Copyright (c) 2000-$CurrentYear$ Linden Research, Inc.
+ * Copyright (c) 2000-$CurrentYear$, Linden Research, Inc.
* $License$
*/
diff --git a/indra/llmath/coordframe.h b/indra/llmath/coordframe.h
index 5efab4b63e..a9a1ad9606 100644
--- a/indra/llmath/coordframe.h
+++ b/indra/llmath/coordframe.h
@@ -2,7 +2,7 @@
* @file coordframe.h
* @brief Legacy wrapper header.
*
- * Copyright (c) 2000-$CurrentYear$ Linden Research, Inc.
+ * Copyright (c) 2000-$CurrentYear$, Linden Research, Inc.
* $License$
*/
diff --git a/indra/llmath/llquaternion.cpp b/indra/llmath/llquaternion.cpp
index 56a3830bb3..8b2808164f 100644
--- a/indra/llmath/llquaternion.cpp
+++ b/indra/llmath/llquaternion.cpp
@@ -1,5 +1,5 @@
/**
- * @file qmath.cpp
+ * @file llquaternion.cpp
* @brief LLQuaternion class implementation.
*
* Copyright (c) 2000-$CurrentYear$, Linden Research, Inc.
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 0d95c0492c..67ffb6d628 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1779,6 +1779,8 @@ void LLVolume::createVolumeFaces()
// sculpt replaces generate() for sculpted surfaces
void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level)
{
+ U8 sculpt_type = mParams.getSculptType();
+
BOOL data_is_empty = FALSE;
if (sculpt_width == 0 || sculpt_height == 0 || sculpt_data == NULL)
@@ -1860,6 +1862,7 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
line += sizeT;
}
}
+
else
{
S32 line = 0;
@@ -1874,18 +1877,52 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
U32 x = (U32) ((F32)t/(sizeT-1) * (F32) sculpt_width);
U32 y = (U32) ((F32)s/(sizeS-1) * (F32) sculpt_height);
- if (y == sculpt_height) // stitch bottom row
+ if (y == 0) // top row stitching
{
- y = sculpt_height - 1;
- x = sculpt_width / 2;
+ // pinch?
+ if (sculpt_type == LL_SCULPT_TYPE_SPHERE)
+ {
+ x = sculpt_width / 2;
+ }
}
- if (x == sculpt_width) // stitch sides
- x = 0;
+ if (y == sculpt_height) // bottom row stitching
+ {
+ // wrap?
+ if (sculpt_type == LL_SCULPT_TYPE_TORUS)
+ {
+ y = 0;
+ }
+ else
+ {
+ y = sculpt_height - 1;
+ }
- if (y == 0) // stitch top row
- x = sculpt_width / 2;
-
+ // pinch?
+ if (sculpt_type == LL_SCULPT_TYPE_SPHERE)
+ {
+ x = sculpt_width / 2;
+ }
+ }
+
+ if (x == sculpt_width) // side stitching
+ {
+ // wrap?
+ if ((sculpt_type == LL_SCULPT_TYPE_SPHERE) ||
+ (sculpt_type == LL_SCULPT_TYPE_TORUS) ||
+ (sculpt_type == LL_SCULPT_TYPE_CYLINDER))
+ {
+ x = 0;
+ }
+
+ else
+ {
+ x = sculpt_width - 1;
+ }
+ }
+
+
+
U32 index = (x + y * sculpt_width) * sculpt_components;
pt.mPos.mV[0] = sculpt_data[index ] / 256.f - 0.5f;
pt.mPos.mV[1] = sculpt_data[index+1] / 256.f - 0.5f;
@@ -4595,82 +4632,130 @@ BOOL LLVolumeFace::createSide()
}
}
+ // adjust normals based on wrapping and stitching
+
BOOL s_bottom_converges = ((mVertices[0].mPosition - mVertices[mNumS*(mNumT-2)].mPosition).magVecSquared() < 0.000001f);
BOOL s_top_converges = ((mVertices[mNumS-1].mPosition - mVertices[mNumS*(mNumT-2)+mNumS-1].mPosition).magVecSquared() < 0.000001f);
-
- if (mVolumep->getPath().isOpen() == FALSE) { //wrap normals on T
- for (S32 i = 0; i < mNumS; i++) {
- LLVector3 norm = mVertices[i].mNormal + mVertices[mNumS*(mNumT-1)+i].mNormal;
- mVertices[i].mNormal = norm;
- mVertices[mNumS*(mNumT-1)+i].mNormal = norm;
+ U8 sculpt_type = mVolumep->getParams().getSculptType();
+
+ if (sculpt_type == LL_SCULPT_TYPE_NONE) // logic for non-sculpt volumes
+ {
+ if (mVolumep->getPath().isOpen() == FALSE)
+ { //wrap normals on T
+ for (S32 i = 0; i < mNumS; i++)
+ {
+ LLVector3 norm = mVertices[i].mNormal + mVertices[mNumS*(mNumT-1)+i].mNormal;
+ mVertices[i].mNormal = norm;
+ mVertices[mNumS*(mNumT-1)+i].mNormal = norm;
+ }
}
- }
- if ((mVolumep->getProfile().isOpen() == FALSE) &&
- !(s_bottom_converges))
+ if ((mVolumep->getProfile().isOpen() == FALSE) && !(s_bottom_converges))
{ //wrap normals on S
- for (S32 i = 0; i < mNumT; i++) {
+ for (S32 i = 0; i < mNumT; i++)
+ {
LLVector3 norm = mVertices[mNumS*i].mNormal + mVertices[mNumS*i+mNumS-1].mNormal;
mVertices[mNumS * i].mNormal = norm;
mVertices[mNumS * i+mNumS-1].mNormal = norm;
}
}
- if (mVolumep->getPathType() == LL_PCODE_PATH_CIRCLE &&
- ((mVolumep->getProfileType() & LL_PCODE_PROFILE_MASK) == LL_PCODE_PROFILE_CIRCLE_HALF))
- {
- if (s_bottom_converges)
- { //all lower S have same normal
- for (S32 i = 0; i < mNumT; i++) {
- mVertices[mNumS*i].mNormal = LLVector3(1,0,0);
+ if (mVolumep->getPathType() == LL_PCODE_PATH_CIRCLE &&
+ ((mVolumep->getProfileType() & LL_PCODE_PROFILE_MASK) == LL_PCODE_PROFILE_CIRCLE_HALF))
+ {
+ if (s_bottom_converges)
+ { //all lower S have same normal
+ for (S32 i = 0; i < mNumT; i++)
+ {
+ mVertices[mNumS*i].mNormal = LLVector3(1,0,0);
+ }
}
- }
- if (s_top_converges)
- { //all upper S have same normal
- for (S32 i = 0; i < mNumT; i++) {
- mVertices[mNumS*i+mNumS-1].mNormal = LLVector3(-1,0,0);
+ if (s_top_converges)
+ { //all upper S have same normal
+ for (S32 i = 0; i < mNumT; i++)
+ {
+ mVertices[mNumS*i+mNumS-1].mNormal = LLVector3(-1,0,0);
+ }
}
}
}
-
- U8 sculpt_type = mVolumep->getParams().getSculptType();
- if (sculpt_type == LL_SCULPT_TYPE_SPHERE)
+ else // logic for sculpt volumes
{
- // average normals for north pole
+ BOOL average_poles = FALSE;
+ BOOL wrap_s = FALSE;
+ BOOL wrap_t = FALSE;
+
+ if (sculpt_type == LL_SCULPT_TYPE_SPHERE)
+ average_poles = TRUE;
+
+ if ((sculpt_type == LL_SCULPT_TYPE_SPHERE) ||
+ (sculpt_type == LL_SCULPT_TYPE_TORUS) ||
+ (sculpt_type == LL_SCULPT_TYPE_CYLINDER))
+ wrap_s = TRUE;
+
+ if (sculpt_type == LL_SCULPT_TYPE_TORUS)
+ wrap_t = TRUE;
+
- LLVector3 average(0.0, 0.0, 0.0);
- for (S32 i = 0; i < mNumS; i++)
+ if (average_poles)
{
- average += mVertices[i].mNormal;
- }
+ // average normals for north pole
+
+ LLVector3 average(0.0, 0.0, 0.0);
+ for (S32 i = 0; i < mNumS; i++)
+ {
+ average += mVertices[i].mNormal;
+ }
+
+ // set average
+ for (S32 i = 0; i < mNumS; i++)
+ {
+ mVertices[i].mNormal = average;
+ }
+
+ // average normals for south pole
+
+ average = LLVector3(0.0, 0.0, 0.0);
+ for (S32 i = 0; i < mNumS; i++)
+ {
+ average += mVertices[i + mNumS * (mNumT - 1)].mNormal;
+ }
+
+ // set average
+ for (S32 i = 0; i < mNumS; i++)
+ {
+ mVertices[i + mNumS * (mNumT - 1)].mNormal = average;
+ }
- // set average
- for (S32 i = 0; i < mNumS; i++)
- {
- mVertices[i].mNormal = average;
}
- }
-
- if (sculpt_type == LL_SCULPT_TYPE_SPHERE)
- {
- // average normals for south pole
- LLVector3 average(0.0, 0.0, 0.0);
- for (S32 i = 0; i < mNumS; i++)
+ if (wrap_s)
{
- average += mVertices[i + mNumS * (mNumT - 1)].mNormal;
+ for (S32 i = 0; i < mNumT; i++)
+ {
+ LLVector3 norm = mVertices[mNumS*i].mNormal + mVertices[mNumS*i+mNumS-1].mNormal;
+ mVertices[mNumS * i].mNormal = norm;
+ mVertices[mNumS * i+mNumS-1].mNormal = norm;
+ }
}
- // set average
- for (S32 i = 0; i < mNumS; i++)
+
+
+ if (wrap_t)
{
- mVertices[i + mNumS * (mNumT - 1)].mNormal = average;
+ for (S32 i = 0; i < mNumS; i++)
+ {
+ LLVector3 norm = mVertices[i].mNormal + mVertices[mNumS*(mNumT-1)+i].mNormal;
+ mVertices[i].mNormal = norm;
+ mVertices[mNumS*(mNumT-1)+i].mNormal = norm;
+ }
+
}
- }
+ }
//normalize normals and binormals here so the meshes that reference
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 23c29ae310..a7d07bc712 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -154,7 +154,7 @@ const LLFaceID LL_FACE_OUTER_SIDE_3 = 0x1 << 8;
const U8 LL_SCULPT_TYPE_NONE = 0;
const U8 LL_SCULPT_TYPE_SPHERE = 1;
const U8 LL_SCULPT_TYPE_TORUS = 2;
-const U8 LL_SCULPT_TYPE_PLAIN = 3;
+const U8 LL_SCULPT_TYPE_PLANE = 3;
const U8 LL_SCULPT_TYPE_CYLINDER = 4;
@@ -840,9 +840,6 @@ public:
BOOL isUnique() const { return mUnique; }
S32 getSculptLevel() const { return mSculptLevel; }
- void setSculptLevel(S32 level) { mSculptLevel = level; }
-
- U8 getSculptType() const { return mSculptType; }
S32 *getTriangleIndices(U32 &num_indices) const;
void generateSilhouetteVertices(std::vector<LLVector3> &vertices, std::vector<LLVector3> &normals, std::vector<S32> &segments, const LLVector3& view_vec,
@@ -888,7 +885,6 @@ protected:
BOOL mUnique;
F32 mDetail;
S32 mSculptLevel;
- U8 mSculptType;
LLVolumeParams mParams;
LLPath *mPathp;
diff --git a/indra/llmath/v3color.cpp b/indra/llmath/v3color.cpp
index d85006fa9c..7d5769bffc 100644
--- a/indra/llmath/v3color.cpp
+++ b/indra/llmath/v3color.cpp
@@ -90,4 +90,4 @@ void LLColor3::calcHSL(F32* hue, F32* saturation, F32* luminance) const
if (hue) *hue = H;
if (saturation) *saturation = S;
if (luminance) *luminance = L;
-} \ No newline at end of file
+}