summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/cmake/MESHOPTIMIZER.cmake2
-rw-r--r--indra/llmeshoptimizer/llmeshoptimizer.cpp7
-rw-r--r--indra/newview/llmodelpreview.cpp23
3 files changed, 17 insertions, 15 deletions
diff --git a/indra/cmake/MESHOPTIMIZER.cmake b/indra/cmake/MESHOPTIMIZER.cmake
index 6a31dc5569..1c5b47b9bd 100644
--- a/indra/cmake/MESHOPTIMIZER.cmake
+++ b/indra/cmake/MESHOPTIMIZER.cmake
@@ -10,7 +10,7 @@ if (WINDOWS)
elseif (LINUX)
set(MESHOPTIMIZER_LIBRARIES meshoptimizer.o)
elseif (DARWIN)
- set(MESHOPTIMIZER_LIBRARIES libmeshoptimizer.o)
+ set(MESHOPTIMIZER_LIBRARIES libmeshoptimizer.a)
endif (WINDOWS)
set(MESHOPTIMIZER_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/meshoptimizer)
diff --git a/indra/llmeshoptimizer/llmeshoptimizer.cpp b/indra/llmeshoptimizer/llmeshoptimizer.cpp
index 02e97ef984..dbf8e5b631 100644
--- a/indra/llmeshoptimizer/llmeshoptimizer.cpp
+++ b/indra/llmeshoptimizer/llmeshoptimizer.cpp
@@ -50,12 +50,17 @@ U64 LLMeshOptimizer::simplify(U16 *destination,
F32* result_error
)
{
+ const size_t vertex_stride = 4; // should be either 0 or 4
+
+ // Consider running meshopt_generateShadowIndexBuffer<unsigned short> first.
+ // meshopt_generateShadowIndexBuffer is only needed if models don't use some of the vertices,
+ // but since we call optimize() in a lot of cases, it likely isn't needed
return meshopt_simplify<unsigned short>(destination,
indices,
index_count,
(const float*)vertex_positions, // verify that it is correct to convert to float
vertex_count,
- sizeof(LLVector4a), // should be either 0 or 4
+ vertex_stride,
target_index_count,
target_error,
result_error
diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp
index 27341eff3c..5eb49ee938 100644
--- a/indra/newview/llmodelpreview.cpp
+++ b/indra/newview/llmodelpreview.cpp
@@ -1767,7 +1767,7 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, U32 decimation, bool en
}
// meshoptimizer doesn't use triangle limit, it uses indices limit, so convert it to aproximate ratio
- indices_ratio = (F32)triangle_limit / (F32)base_triangle_count;
+ indices_ratio = triangle_limit / (F32)base_triangle_count;
}
else
{
@@ -1849,7 +1849,7 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, U32 decimation, bool en
// todo: run generateShadowIndexBuffer, at some stage, potentially inside simplify
- F32 target_indices = llmax((F32)3, num_indices * indices_ratio); // leave at least one triangle
+ S32 target_indices = llmax(3, llfloor(num_indices * indices_ratio)); // leave at least one triangle
F32 result_code = 0; // how far from original the model is
S32 new_indices = LLMeshOptimizer::simplify(&output[0],
face.mIndices,
@@ -1868,9 +1868,16 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, U32 decimation, bool en
LLVolumeFace &new_face = target_model->getVolumeFace(face_idx);
// Copy old values
- // todo: no point copying faces?
new_face = face;
+ // Assign new values
+ S32 idx_size = (new_indices * sizeof(U16) + 0xF) & ~0xF;
+ LLVector4a::memcpyNonAliased16((F32*)new_face.mIndices, (F32*)(&output[0]), idx_size);
+ new_face.mNumIndices = new_indices;
+
+ // clear unused values
+ new_face.optimize();
+
if (new_indices == 0)
{
LL_WARNS() << "No indices generated for face " << face_idx
@@ -1878,16 +1885,6 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, U32 decimation, bool en
<< " target Indices: " << target_indices
<< " original count: " << num_indices << LL_ENDL;
}
- else
- {
- // Assign new values
- S32 idx_size = (new_indices * sizeof(U16) + 0xF) & ~0xF;
- LLVector4a::memcpyNonAliased16((F32*)new_face.mIndices, (F32*)(&output[0]), idx_size);
- new_face.mNumIndices = new_indices;
-
- // clear unused values
- new_face.optimize();
- }
}
//blind copy skin weights and just take closest skin weight to point on