diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-07-12 23:23:08 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-07-13 00:08:41 +0300 |
commit | 833a82f8593c513b12b59c489760f77d5a806668 (patch) | |
tree | e72f97afdf7554c6f579b80f8432d35991fbebca /indra | |
parent | 4372913f59a39dcf6b4818eaea64369c7c7242d5 (diff) |
DRTVWR-542 WIP #7
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llmeshoptimizer/llmeshoptimizer.cpp | 23 | ||||
-rw-r--r-- | indra/llmeshoptimizer/llmeshoptimizer.h | 7 | ||||
-rw-r--r-- | indra/newview/llmodelpreview.cpp | 16 |
3 files changed, 39 insertions, 7 deletions
diff --git a/indra/llmeshoptimizer/llmeshoptimizer.cpp b/indra/llmeshoptimizer/llmeshoptimizer.cpp index 2f3d2491c2..0ddaa82c3d 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.cpp +++ b/indra/llmeshoptimizer/llmeshoptimizer.cpp @@ -40,6 +40,26 @@ LLMeshOptimizer::~LLMeshOptimizer() } //static +void LLMeshOptimizer::generateShadowIndexBuffer(U16 *destination, + const U16 *indices, + U64 index_count, + const LLVector4a *vertex_positions, + U64 vertex_count +) +{ + const size_t vertex_stride = 4; // should be either 0 or 4 + + meshopt_generateShadowIndexBuffer<unsigned short>(destination, + indices, + index_count, + (const float*)vertex_positions, // verify that it is correct to convert to float + vertex_count, + sizeof(LLVector4a), + vertex_stride + ); +} + +//static U64 LLMeshOptimizer::simplify(U16 *destination, const U16 *indices, U64 index_count, @@ -52,9 +72,6 @@ U64 LLMeshOptimizer::simplify(U16 *destination, { 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, diff --git a/indra/llmeshoptimizer/llmeshoptimizer.h b/indra/llmeshoptimizer/llmeshoptimizer.h index c4250c537d..744856361c 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.h +++ b/indra/llmeshoptimizer/llmeshoptimizer.h @@ -36,6 +36,13 @@ public: LLMeshOptimizer(); ~LLMeshOptimizer(); + static void LLMeshOptimizer::generateShadowIndexBuffer( + U16 *destination, + const U16 *indices, + U64 index_count, + const LLVector4a *vertex_positions, + U64 vertex_count); + // returns amount of indices in destiantion // result_error returns how far from original the model is in % if not NULL static U64 simplify( diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index c33b48c16e..471b29d850 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -1847,10 +1847,18 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, U32 decimation, bool en S32 num_indices = face.mNumIndices; std::vector<U16> output(num_indices); //todo: do not allocate per each face, add one large buffer somewhere - // todo: run generateShadowIndexBuffer, at some stage, potentially inside simplify + /* + generateShadowIndexBuffer appears to deform model + LLMeshOptimizer::generateShadowIndexBuffer( + &shadow[0], + face.mIndices, + num_indices, + &face.mPositions[0], + face.mNumVertices); + */ 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 + F32 result_code = 0; // how far from original the model is, 1 == 100% S32 new_indices = 0; if (sloppy) @@ -1859,7 +1867,7 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, U32 decimation, bool en &output[0], face.mIndices, num_indices, - &face.mPositions[0], + face.mPositions, face.mNumVertices, target_indices, lod_error_threshold, @@ -1872,7 +1880,7 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, U32 decimation, bool en &output[0], face.mIndices, num_indices, - &face.mPositions[0], + face.mPositions, face.mNumVertices, target_indices, lod_error_threshold, |