summaryrefslogtreecommitdiff
path: root/indra/llmath/llvolume.cpp
diff options
context:
space:
mode:
authorKarl Stiefvater (qarl) <qarl@lindenlab.com>2010-01-29 14:33:04 -0600
committerKarl Stiefvater (qarl) <qarl@lindenlab.com>2010-01-29 14:33:04 -0600
commit024c0ebe19588f8452bae7ea01756fd7b4b30540 (patch)
tree90b36c15e3f64f3a6b6fbfa681fcbc0f1a71d0f9 /indra/llmath/llvolume.cpp
parent5a34cf1af83314774f11b0d24279794794bc9147 (diff)
enable mirror and invert flags for meshes.
Diffstat (limited to 'indra/llmath/llvolume.cpp')
-rw-r--r--indra/llmath/llvolume.cpp59
1 files changed, 56 insertions, 3 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index de32070da1..0328c09c9a 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1694,7 +1694,7 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
generate();
- if (mParams.getSculptID().isNull() && params.getSculptType() == LL_SCULPT_TYPE_NONE)
+ if (mParams.getSculptID().isNull() && mParams.getSculptType() == LL_SCULPT_TYPE_NONE)
{
createVolumeFaces();
}
@@ -2142,6 +2142,59 @@ BOOL LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
(F32) t[1] / 65535.f * tc_range.mV[1] + min_tc.mV[1]);
}
+
+ // modifier flags?
+ BOOL do_mirror = (mParams.getSculptType() & LL_SCULPT_FLAG_MIRROR);
+ BOOL do_invert = (mParams.getSculptType() &LL_SCULPT_FLAG_INVERT);
+
+
+ // translate to actions:
+ BOOL do_reflect_x = FALSE;
+ BOOL do_reverse_triangles = FALSE;
+ BOOL do_invert_normals = FALSE;
+
+ if (do_mirror)
+ {
+ do_reflect_x = TRUE;
+ do_reverse_triangles = !do_reverse_triangles;
+ }
+
+ if (do_invert)
+ {
+ do_invert_normals = TRUE;
+ do_reverse_triangles = !do_reverse_triangles;
+ }
+
+ // now do the work
+
+ if (do_reflect_x)
+ {
+ for (S32 i = 0; i < face.mVertices.size(); i++)
+ {
+ face.mVertices[i].mPosition.mV[VX] *= -1.0f;
+ face.mVertices[i].mNormal.mV[VX] *= -1.0f;
+ }
+ }
+
+ if (do_invert_normals)
+ {
+ for (S32 i = 0; i < face.mVertices.size(); i++)
+ {
+ face.mVertices[i].mNormal *= -1.0f;
+ }
+ }
+
+ if (do_reverse_triangles)
+ {
+ for (U32 j = 0; j < face.mIndices.size(); j += 3)
+ {
+ // swap the 2nd and 3rd index
+ S32 swap = face.mIndices[j+1];
+ face.mIndices[j+1] = face.mIndices[j+2];
+ face.mIndices[j+2] = swap;
+ }
+ }
+
}
}
@@ -3838,7 +3891,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
normals.clear();
segments.clear();
- if (mParams.getSculptType() == LL_SCULPT_TYPE_MESH)
+ if ((mParams.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
{
return;
}
@@ -5500,7 +5553,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
{
mIndices.resize(num_indices);
- if (volume->getParams().getSculptType() != LL_SCULPT_TYPE_MESH)
+ if ((volume->getParams().getSculptType() & LL_SCULPT_TYPE_MASK) != LL_SCULPT_TYPE_MESH)
{
mEdge.resize(num_indices);
}