DRTVWR-542 WIP #5
parent
17131ac203
commit
eb13133e3e
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue