summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llmath/llvolume.cpp59
-rw-r--r--indra/llmath/llvolume.h7
-rw-r--r--indra/newview/llvovolume.cpp7
3 files changed, 62 insertions, 11 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);
}
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index e3ab648fe3..0bc64f4487 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -183,12 +183,11 @@ const U8 LL_SCULPT_TYPE_SPHERE = 1;
const U8 LL_SCULPT_TYPE_TORUS = 2;
const U8 LL_SCULPT_TYPE_PLANE = 3;
const U8 LL_SCULPT_TYPE_CYLINDER = 4;
-
-const U8 LL_SCULPT_TYPE_MASK = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE | LL_SCULPT_TYPE_CYLINDER;
-
-// need to change this (these) names
const U8 LL_SCULPT_TYPE_MESH = 5;
+const U8 LL_SCULPT_TYPE_MASK = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE |
+ LL_SCULPT_TYPE_CYLINDER | LL_SCULPT_TYPE_MESH;
+
const U8 LL_SCULPT_FLAG_INVERT = 64;
const U8 LL_SCULPT_FLAG_MIRROR = 128;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 4acf3cb6fb..3f1ddc0ee7 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -905,14 +905,13 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
// if it's a mesh
if ((volume_params.getSculptType() & LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH)
{ //meshes might not have all LODs, get the force detail to best existing LOD
+
LLUUID mesh_id = params.getSculptID();
//profile and path params don't matter for meshes
- volume_params = LLVolumeParams();
volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
- volume_params.setSculptID(mesh_id, LL_SCULPT_TYPE_MESH);
- lod = gMeshRepo.getActualMeshLOD(mesh_id, lod);
+ lod = gMeshRepo.getActualMeshLOD(volume_params, lod);
}
}
@@ -963,7 +962,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &params, const S32 detail, bool
{
//load request not yet issued, request pipeline load this mesh
LLUUID asset_id = volume_params.getSculptID();
- S32 available_lod = gMeshRepo.loadMesh(this, asset_id, lod);
+ S32 available_lod = gMeshRepo.loadMesh(this, volume_params, lod);
if (available_lod != lod)
{
LLPrimitive::setVolume(volume_params, available_lod);