From e4a5d16be1719706e96beb21cc23c512b02c7b33 Mon Sep 17 00:00:00 2001 From: JonathanLinden Date: Tue, 26 Oct 2010 10:31:48 -0700 Subject: Fixed convex hull size incompatibility in mesh assets. --- indra/llprimitive/llmodel.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 7fa72d82e1..e2a33965ea 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1449,9 +1449,7 @@ LLSD LLModel::writeModel( { U32 size = decomp[i].size(); total += size; - // The valid range of sizes is actually 3-256 verts. We need this to fit into a U8, - // So we just subtract 1 - hulls[i] = (U8) (size - 1); + hulls[i] = (U8) size; for (U32 j = 0; j < decomp[i].size(); ++j) { -- cgit v1.2.3 From 0a8d43e84455b48e220a4f6574e42d258b9312d4 Mon Sep 17 00:00:00 2001 From: Jonathan Wolk Date: Tue, 26 Oct 2010 11:11:20 -0700 Subject: Backing out latest change to undo static cache file changes --- indra/llprimitive/llmodel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index e2a33965ea..7fa72d82e1 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1449,7 +1449,9 @@ LLSD LLModel::writeModel( { U32 size = decomp[i].size(); total += size; - hulls[i] = (U8) size; + // The valid range of sizes is actually 3-256 verts. We need this to fit into a U8, + // So we just subtract 1 + hulls[i] = (U8) (size - 1); for (U32 j = 0; j < decomp[i].size(); ++j) { -- cgit v1.2.3 From 57cbcdc9ec9e8edf50bfea82efb63b3f8fab3cdc Mon Sep 17 00:00:00 2001 From: Jonathan Wolk Date: Tue, 26 Oct 2010 11:20:48 -0700 Subject: Adding back in fix for convex hull size incompatibility after backout of previous checkin. --- indra/llprimitive/llmodel.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 7fa72d82e1..1cee5a6e15 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1449,9 +1449,7 @@ LLSD LLModel::writeModel( { U32 size = decomp[i].size(); total += size; - // The valid range of sizes is actually 3-256 verts. We need this to fit into a U8, - // So we just subtract 1 - hulls[i] = (U8) (size - 1); + hulls[i] = (U8) (size); for (U32 j = 0; j < decomp[i].size(); ++j) { -- cgit v1.2.3 From dda21d67e5df62993c57be1d9d5c3195c02ddfef Mon Sep 17 00:00:00 2001 From: JonathanLinden Date: Thu, 28 Oct 2010 14:32:00 -0700 Subject: Fix for CTS-305 'Uploaded meshes have uniform scale' --- indra/llprimitive/llmodel.cpp | 51 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 1cee5a6e15..6baf20a726 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -875,6 +875,15 @@ void LLModel::optimizeVolumeFaces() #endif } +// Shrink the model to fit +// on a 1x1x1 cube centered at the origin. +// The positions and extents +// multiplied by mNormalizedScale +// and offset by mNormalizedTranslation +// to be the "original" extents and position. +// Also, the positions will fit +// within the unit cube and the extents +// to be corners of the unit cube. void LLModel::normalizeVolumeFaces() { @@ -891,6 +900,10 @@ void LLModel::normalizeVolumeFaces() llerrs << "WTF?" << llendl; } + // For all of the volume faces + // in the model, loop over + // them and see what the extents + // of the volume along each axis. min = mVolumeFaces[0].mExtents[0]; max = mVolumeFaces[0].mExtents[1]; @@ -907,33 +920,57 @@ void LLModel::normalizeVolumeFaces() update_min_max(min, max, face.mExtents[1]); } + // Now that we have the extents of the model + // we can compute the offset needed to center + // the model at the origin. + + // Compute center of the model + // and make it negative to get translation + // needed to center at origin. LLVector4a trans; trans.setAdd(min, max); trans.mul(-0.5f); + + // Compute the total size along all + // axes of the model. LLVector4a size; size.setSub(max, min); - F32 scale = 1.f/llmax(llmax(size[0], size[1]), size[2]); + // To make the model's total size + // be the size of the unit cube, compute + // a scale factor that can be applied + // to do that. + LLVector4a scale = LLVector4a(1, 1, 1); + scale.setDiv(scale, size); for (U32 i = 0; i < mVolumeFaces.size(); ++i) { LLVolumeFace& face = mVolumeFaces[i]; - + + // We shrink the extents so + // that they fall on the corners + // of the unit cube. face.mExtents[0].add(trans); - face.mExtents[0].mul(scale); + face.mExtents[0].setMul(face.mExtents[0], scale); face.mExtents[1].add(trans); - face.mExtents[1].mul(scale); + face.mExtents[1].setMul(face.mExtents[1], scale); + // For all the positions, we scale + // the positions to fit within the unit cube. LLVector4a* pos = (LLVector4a*) face.mPositions; for (U32 j = 0; j < face.mNumVertices; ++j) { - pos[j].add(trans); - pos[j].mul(scale); + pos[j].add(trans); + pos[j].setMul(pos[j], scale); } } - mNormalizedScale = LLVector3(1,1,1) / scale; + // mNormalizedScale is the scale at which + // we would need to multiply the model + // by to get the original size of the + // model instead of the normalized size. + mNormalizedScale.set(size.getF32ptr()); mNormalizedTranslation.set(trans.getF32ptr()); mNormalizedTranslation *= -1.f; } -- cgit v1.2.3 From 278dac7ce7c1d010ec24246a668be74a79de0e00 Mon Sep 17 00:00:00 2001 From: JonathanLinden Date: Tue, 2 Nov 2010 16:25:29 -0700 Subject: Reverting code for fixing non-uniform scale for mesh uploads as it breaks rigged meshes. --- indra/llprimitive/llmodel.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'indra/llprimitive/llmodel.cpp') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 6baf20a726..f7eafb2fff 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -882,8 +882,7 @@ void LLModel::optimizeVolumeFaces() // and offset by mNormalizedTranslation // to be the "original" extents and position. // Also, the positions will fit -// within the unit cube and the extents -// to be corners of the unit cube. +// within the unit cube. void LLModel::normalizeVolumeFaces() { @@ -936,25 +935,24 @@ void LLModel::normalizeVolumeFaces() LLVector4a size; size.setSub(max, min); - // To make the model's total size - // be the size of the unit cube, compute - // a scale factor that can be applied - // to do that. - LLVector4a scale = LLVector4a(1, 1, 1); - scale.setDiv(scale, size); + // To make the model fit within + // the unit cube with only the largest + // dimensions fitting on the surface of the cube, + // calculate the largest extent on any axis + F32 scale = 1.f/llmax(llmax(size[0], size[1]), size[2]); for (U32 i = 0; i < mVolumeFaces.size(); ++i) { LLVolumeFace& face = mVolumeFaces[i]; // We shrink the extents so - // that they fall on the corners - // of the unit cube. + // that they fall within + // the unit cube. face.mExtents[0].add(trans); - face.mExtents[0].setMul(face.mExtents[0], scale); + face.mExtents[0].mul(scale); face.mExtents[1].add(trans); - face.mExtents[1].setMul(face.mExtents[1], scale); + face.mExtents[1].mul(scale); // For all the positions, we scale // the positions to fit within the unit cube. @@ -962,7 +960,7 @@ void LLModel::normalizeVolumeFaces() for (U32 j = 0; j < face.mNumVertices; ++j) { pos[j].add(trans); - pos[j].setMul(pos[j], scale); + pos[j].mul(scale); } } @@ -970,7 +968,7 @@ void LLModel::normalizeVolumeFaces() // we would need to multiply the model // by to get the original size of the // model instead of the normalized size. - mNormalizedScale.set(size.getF32ptr()); + mNormalizedScale = LLVector3(1,1,1) / scale; mNormalizedTranslation.set(trans.getF32ptr()); mNormalizedTranslation *= -1.f; } -- cgit v1.2.3