From 97c954dd84d50ec7b739d2dd3adb7365589f3034 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 6 Jul 2021 21:26:15 +0300 Subject: SL-15522 Initial addition of meshoptimizer --- indra/llmeshoptimizer/CMakeLists.txt | 41 +++++++++++++++++++++++++++++ indra/llmeshoptimizer/llmeshoptimizer.cpp | 43 +++++++++++++++++++++++++++++++ indra/llmeshoptimizer/llmeshoptimizer.h | 37 ++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 indra/llmeshoptimizer/CMakeLists.txt create mode 100644 indra/llmeshoptimizer/llmeshoptimizer.cpp create mode 100644 indra/llmeshoptimizer/llmeshoptimizer.h (limited to 'indra/llmeshoptimizer') diff --git a/indra/llmeshoptimizer/CMakeLists.txt b/indra/llmeshoptimizer/CMakeLists.txt new file mode 100644 index 0000000000..1eea19de66 --- /dev/null +++ b/indra/llmeshoptimizer/CMakeLists.txt @@ -0,0 +1,41 @@ +# -*- cmake -*- + +project(llmeshoptimizer) + +include(MESHOPTIMIZER) + +include(00-Common) +include(LLCommon) + +include_directories( + ${LLCOMMON_INCLUDE_DIRS} + ${LLMESHOPTIMIZER_INCLUDE_DIR} + ${MESHOPTIMIZER_INCLUDE_DIRS} + ${LIBS_PREBUILT_DIR}/include #access to boost headers, needed for LLError + ) + +set(llmeshoptimizer_SOURCE_FILES + llmeshoptimizer.cpp + ) + +set(llmeshoptimizer_HEADER_FILES + CMakeLists.txt + + llmeshoptimizer.h + ) + +set_source_files_properties(${llmeshoptimizer_HEADER_FILES} + PROPERTIES HEADER_FILE_ONLY TRUE) + +list(APPEND llmeshoptimizer_SOURCE_FILES ${llmeshoptimizer_HEADER_FILES}) + +#if (USE_MESHOPT) + add_library (llmeshoptimizer ${llmeshoptimizer_SOURCE_FILES}) + + target_link_libraries(llmeshoptimizer + ${LLCOMMON_LIBRARIES} + ${MESHOPTIMIZER_LIBRARY}) + + # Add tests + +#endif (USE_MESHOPT) diff --git a/indra/llmeshoptimizer/llmeshoptimizer.cpp b/indra/llmeshoptimizer/llmeshoptimizer.cpp new file mode 100644 index 0000000000..770cd5aa3c --- /dev/null +++ b/indra/llmeshoptimizer/llmeshoptimizer.cpp @@ -0,0 +1,43 @@ + /** +* @file llmeshoptimizer.cpp +* @brief Wrapper around meshoptimizer +* +* $LicenseInfo:firstyear=2021&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2021, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llmeshoptimizer.h" + +#include "linden_common.h" + +#include "meshoptimizer.h" +#include "llmath.h" + + +LLMeshOptimizer::LLMeshOptimizer() +{ + +} + +LLMeshOptimizer::~LLMeshOptimizer() +{ + +} diff --git a/indra/llmeshoptimizer/llmeshoptimizer.h b/indra/llmeshoptimizer/llmeshoptimizer.h new file mode 100644 index 0000000000..edce4edf05 --- /dev/null +++ b/indra/llmeshoptimizer/llmeshoptimizer.h @@ -0,0 +1,37 @@ +/** +* @file llmeshoptimizer.h +* @brief Wrapper around meshoptimizer +* +* $LicenseInfo:firstyear=2021&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2021, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ +#ifndef LLMESHOPTIMIZER_H +#define LLMESHOPTIMIZER_H + +class LLMeshOptimizer +{ +public: + LLMeshOptimizer(); + ~LLMeshOptimizer(); +private: +}; + +#endif //LLMESHOPTIMIZER_H -- cgit v1.2.3 From 7b7b8a8da8f3a7e726b7de2b152cd00c67df0f18 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 7 Jul 2021 22:34:26 +0300 Subject: DRTVWR-542 WIP --- indra/llmeshoptimizer/llmeshoptimizer.cpp | 14 ++++++++++---- indra/llmeshoptimizer/llmeshoptimizer.h | 5 +++++ 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'indra/llmeshoptimizer') diff --git a/indra/llmeshoptimizer/llmeshoptimizer.cpp b/indra/llmeshoptimizer/llmeshoptimizer.cpp index 770cd5aa3c..c46fa8dcf3 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.cpp +++ b/indra/llmeshoptimizer/llmeshoptimizer.cpp @@ -26,18 +26,24 @@ #include "llmeshoptimizer.h" -#include "linden_common.h" - #include "meshoptimizer.h" -#include "llmath.h" LLMeshOptimizer::LLMeshOptimizer() { - + // Todo: Looks like for memory management, we can add allocator and deallocator callbacks + // Should be one time + // meshopt_setAllocator(allocate, deallocate); } LLMeshOptimizer::~LLMeshOptimizer() { } + +//static +U32 LLMeshOptimizer::simplifyModel() +{ + LL_WARNS() << "NOT IMPLEMENTED" << LL_ENDL; + return 0; +} diff --git a/indra/llmeshoptimizer/llmeshoptimizer.h b/indra/llmeshoptimizer/llmeshoptimizer.h index edce4edf05..d53ec2e24c 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.h +++ b/indra/llmeshoptimizer/llmeshoptimizer.h @@ -26,11 +26,16 @@ #ifndef LLMESHOPTIMIZER_H #define LLMESHOPTIMIZER_H +#include "linden_common.h" + class LLMeshOptimizer { public: LLMeshOptimizer(); ~LLMeshOptimizer(); + + // returns state + static U32 simplifyModel(); private: }; -- cgit v1.2.3 From 1a17e19a610b598650624fb0ae3e67352f00e499 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 8 Jul 2021 20:29:28 +0300 Subject: DRTVWR-542 WIP #2 --- indra/llmeshoptimizer/CMakeLists.txt | 5 ++++- indra/llmeshoptimizer/llmeshoptimizer.cpp | 24 +++++++++++++++++++----- indra/llmeshoptimizer/llmeshoptimizer.h | 12 +++++++++++- 3 files changed, 34 insertions(+), 7 deletions(-) (limited to 'indra/llmeshoptimizer') diff --git a/indra/llmeshoptimizer/CMakeLists.txt b/indra/llmeshoptimizer/CMakeLists.txt index 1eea19de66..016794cfad 100644 --- a/indra/llmeshoptimizer/CMakeLists.txt +++ b/indra/llmeshoptimizer/CMakeLists.txt @@ -6,9 +6,11 @@ include(MESHOPTIMIZER) include(00-Common) include(LLCommon) +include(LLMath) include_directories( ${LLCOMMON_INCLUDE_DIRS} + ${LLMATH_INCLUDE_DIRS} ${LLMESHOPTIMIZER_INCLUDE_DIR} ${MESHOPTIMIZER_INCLUDE_DIRS} ${LIBS_PREBUILT_DIR}/include #access to boost headers, needed for LLError @@ -34,7 +36,8 @@ list(APPEND llmeshoptimizer_SOURCE_FILES ${llmeshoptimizer_HEADER_FILES}) target_link_libraries(llmeshoptimizer ${LLCOMMON_LIBRARIES} - ${MESHOPTIMIZER_LIBRARY}) + ${LLMATH_LIBRARIES} + ${MESHOPTIMIZER_LIBRARIES}) # Add tests diff --git a/indra/llmeshoptimizer/llmeshoptimizer.cpp b/indra/llmeshoptimizer/llmeshoptimizer.cpp index c46fa8dcf3..02e97ef984 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.cpp +++ b/indra/llmeshoptimizer/llmeshoptimizer.cpp @@ -28,7 +28,6 @@ #include "meshoptimizer.h" - LLMeshOptimizer::LLMeshOptimizer() { // Todo: Looks like for memory management, we can add allocator and deallocator callbacks @@ -38,12 +37,27 @@ LLMeshOptimizer::LLMeshOptimizer() LLMeshOptimizer::~LLMeshOptimizer() { - } //static -U32 LLMeshOptimizer::simplifyModel() +U64 LLMeshOptimizer::simplify(U16 *destination, + const U16 *indices, + U64 index_count, + const LLVector4a *vertex_positions, + U64 vertex_count, + U64 target_index_count, + F32 target_error, + F32* result_error + ) { - LL_WARNS() << "NOT IMPLEMENTED" << LL_ENDL; - return 0; + return meshopt_simplify(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 + target_index_count, + target_error, + result_error + ); } diff --git a/indra/llmeshoptimizer/llmeshoptimizer.h b/indra/llmeshoptimizer/llmeshoptimizer.h index d53ec2e24c..a0c53ed9e1 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.h +++ b/indra/llmeshoptimizer/llmeshoptimizer.h @@ -28,6 +28,8 @@ #include "linden_common.h" +#include "llmath.h" + class LLMeshOptimizer { public: @@ -35,7 +37,15 @@ public: ~LLMeshOptimizer(); // returns state - static U32 simplifyModel(); + static U64 simplify( + U16 *destination, + const U16 *indices, + U64 index_count, + const LLVector4a *vertex_positions, + U64 vertex_count, + U64 target_index_count, + F32 target_error, + F32* result_error); private: }; -- cgit v1.2.3 From 6047b7c4383be53718fc72d7058a7435ccda7785 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 9 Jul 2021 23:42:37 +0300 Subject: DRTVWR-542 WIP #3 First functional meshoptimizer --- indra/llmeshoptimizer/llmeshoptimizer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llmeshoptimizer') diff --git a/indra/llmeshoptimizer/llmeshoptimizer.h b/indra/llmeshoptimizer/llmeshoptimizer.h index a0c53ed9e1..157de0251d 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.h +++ b/indra/llmeshoptimizer/llmeshoptimizer.h @@ -36,7 +36,8 @@ public: LLMeshOptimizer(); ~LLMeshOptimizer(); - // returns state + // returns amount of indices in destiantion + // result_error returns how far from original the model is in % if not NULL static U64 simplify( U16 *destination, const U16 *indices, -- cgit v1.2.3 From eb13133e3e0020c73399414cea4d9b39ef526cd3 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 12 Jul 2021 16:47:45 +0300 Subject: DRTVWR-542 WIP #5 --- indra/llmeshoptimizer/llmeshoptimizer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/llmeshoptimizer') 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 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(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 -- cgit v1.2.3 From 938969c811732a3e2faf0229301de286bd12c1a5 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 12 Jul 2021 19:18:25 +0300 Subject: DRTVWR-542 WIP #6 Trying out 'sloppy' variant --- indra/llmeshoptimizer/llmeshoptimizer.cpp | 24 ++++++++++++++++++++++++ indra/llmeshoptimizer/llmeshoptimizer.h | 12 ++++++++++++ 2 files changed, 36 insertions(+) (limited to 'indra/llmeshoptimizer') diff --git a/indra/llmeshoptimizer/llmeshoptimizer.cpp b/indra/llmeshoptimizer/llmeshoptimizer.cpp index dbf8e5b631..2f3d2491c2 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.cpp +++ b/indra/llmeshoptimizer/llmeshoptimizer.cpp @@ -66,3 +66,27 @@ U64 LLMeshOptimizer::simplify(U16 *destination, result_error ); } + +//static +U64 LLMeshOptimizer::simplifySloppy(U16 *destination, + const U16 *indices, + U64 index_count, + const LLVector4a *vertex_positions, + U64 vertex_count, + U64 target_index_count, + F32 target_error, + F32* result_error + ) +{ + const size_t vertex_stride = 4; // should be either 0 or 4 + return meshopt_simplifySloppy(destination, + indices, + index_count, + (const float*)vertex_positions, // verify that it is correct to convert to float + vertex_count, + vertex_stride, + target_index_count, + target_error, + result_error + ); +} diff --git a/indra/llmeshoptimizer/llmeshoptimizer.h b/indra/llmeshoptimizer/llmeshoptimizer.h index 157de0251d..c4250c537d 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.h +++ b/indra/llmeshoptimizer/llmeshoptimizer.h @@ -47,6 +47,18 @@ public: U64 target_index_count, F32 target_error, F32* result_error); + + // returns amount of indices in destiantion + // result_error returns how far from original the model is in % if not NULL + static U64 simplifySloppy( + U16 *destination, + const U16 *indices, + U64 index_count, + const LLVector4a *vertex_positions, + U64 vertex_count, + U64 target_index_count, + F32 target_error, + F32* result_error); private: }; -- cgit v1.2.3 From 833a82f8593c513b12b59c489760f77d5a806668 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 12 Jul 2021 23:23:08 +0300 Subject: DRTVWR-542 WIP #7 --- indra/llmeshoptimizer/llmeshoptimizer.cpp | 23 ++++++++++++++++++++--- indra/llmeshoptimizer/llmeshoptimizer.h | 7 +++++++ 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'indra/llmeshoptimizer') 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 @@ -39,6 +39,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(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, @@ -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 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(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( -- cgit v1.2.3 From 66ba1c4c8e840bb5e9da23e2b5772cd24b23714f Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 13 Jul 2021 02:14:16 +0300 Subject: DRTVWR-542 WIP Fixed Stride --- indra/llmeshoptimizer/llmeshoptimizer.cpp | 19 +++++++++---------- indra/llmeshoptimizer/llmeshoptimizer.h | 7 +++++-- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'indra/llmeshoptimizer') diff --git a/indra/llmeshoptimizer/llmeshoptimizer.cpp b/indra/llmeshoptimizer/llmeshoptimizer.cpp index 0ddaa82c3d..09fa7cb235 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.cpp +++ b/indra/llmeshoptimizer/llmeshoptimizer.cpp @@ -44,18 +44,17 @@ void LLMeshOptimizer::generateShadowIndexBuffer(U16 *destination, const U16 *indices, U64 index_count, const LLVector4a *vertex_positions, - U64 vertex_count + U64 vertex_count, + U64 vertex_positions_stride ) { - const size_t vertex_stride = 4; // should be either 0 or 4 - meshopt_generateShadowIndexBuffer(destination, indices, index_count, (const float*)vertex_positions, // verify that it is correct to convert to float vertex_count, sizeof(LLVector4a), - vertex_stride + vertex_positions_stride ); } @@ -65,19 +64,19 @@ U64 LLMeshOptimizer::simplify(U16 *destination, U64 index_count, const LLVector4a *vertex_positions, U64 vertex_count, + U64 vertex_positions_stride, U64 target_index_count, F32 target_error, F32* result_error ) { - const size_t vertex_stride = 4; // should be either 0 or 4 return meshopt_simplify(destination, indices, index_count, - (const float*)vertex_positions, // verify that it is correct to convert to float + (const float*)vertex_positions, vertex_count, - vertex_stride, + vertex_positions_stride, target_index_count, target_error, result_error @@ -90,18 +89,18 @@ U64 LLMeshOptimizer::simplifySloppy(U16 *destination, U64 index_count, const LLVector4a *vertex_positions, U64 vertex_count, + U64 vertex_positions_stride, U64 target_index_count, F32 target_error, F32* result_error ) { - const size_t vertex_stride = 4; // should be either 0 or 4 return meshopt_simplifySloppy(destination, indices, index_count, - (const float*)vertex_positions, // verify that it is correct to convert to float + (const float*)vertex_positions, vertex_count, - vertex_stride, + vertex_positions_stride, target_index_count, target_error, result_error diff --git a/indra/llmeshoptimizer/llmeshoptimizer.h b/indra/llmeshoptimizer/llmeshoptimizer.h index 744856361c..1aa02372fa 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.h +++ b/indra/llmeshoptimizer/llmeshoptimizer.h @@ -36,12 +36,13 @@ public: LLMeshOptimizer(); ~LLMeshOptimizer(); - static void LLMeshOptimizer::generateShadowIndexBuffer( + static void generateShadowIndexBuffer( U16 *destination, const U16 *indices, U64 index_count, const LLVector4a *vertex_positions, - U64 vertex_count); + U64 vertex_count, + U64 vertex_positions_stride); // returns amount of indices in destiantion // result_error returns how far from original the model is in % if not NULL @@ -51,6 +52,7 @@ public: U64 index_count, const LLVector4a *vertex_positions, U64 vertex_count, + U64 vertex_positions_stride, U64 target_index_count, F32 target_error, F32* result_error); @@ -63,6 +65,7 @@ public: U64 index_count, const LLVector4a *vertex_positions, U64 vertex_count, + U64 vertex_positions_stride, U64 target_index_count, F32 target_error, F32* result_error); -- cgit v1.2.3 From 9aaac1bb985f5bd65f9b0fe985c47cd30dcfd166 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 23 Jul 2021 21:30:13 +0300 Subject: DRTVWR-542 Attempt to simplify all faces of an object as a whole and split back into faces --- indra/llmeshoptimizer/llmeshoptimizer.cpp | 25 ++++++++++++++++++++++++- indra/llmeshoptimizer/llmeshoptimizer.h | 13 +++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'indra/llmeshoptimizer') diff --git a/indra/llmeshoptimizer/llmeshoptimizer.cpp b/indra/llmeshoptimizer/llmeshoptimizer.cpp index 09fa7cb235..8097a05511 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.cpp +++ b/indra/llmeshoptimizer/llmeshoptimizer.cpp @@ -58,6 +58,30 @@ void LLMeshOptimizer::generateShadowIndexBuffer(U16 *destination, ); } +//static +U64 LLMeshOptimizer::simplifyU32(U32 *destination, + const U32 *indices, + U64 index_count, + const LLVector4a *vertex_positions, + U64 vertex_count, + U64 vertex_positions_stride, + U64 target_index_count, + F32 target_error, + F32* result_error +) +{ + return meshopt_simplify(destination, + indices, + index_count, + (const float*)vertex_positions, + vertex_count, + vertex_positions_stride, + target_index_count, + target_error, + result_error + ); +} + //static U64 LLMeshOptimizer::simplify(U16 *destination, const U16 *indices, @@ -70,7 +94,6 @@ U64 LLMeshOptimizer::simplify(U16 *destination, F32* result_error ) { - return meshopt_simplify(destination, indices, index_count, diff --git a/indra/llmeshoptimizer/llmeshoptimizer.h b/indra/llmeshoptimizer/llmeshoptimizer.h index 1aa02372fa..2696733eb2 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.h +++ b/indra/llmeshoptimizer/llmeshoptimizer.h @@ -44,6 +44,19 @@ public: U64 vertex_count, U64 vertex_positions_stride); + // returns amount of indices in destiantion + // result_error returns how far from original the model is in % if not NULL + static U64 simplifyU32( + U32 *destination, + const U32 *indices, + U64 index_count, + const LLVector4a *vertex_positions, + U64 vertex_count, + U64 vertex_positions_stride, + U64 target_index_count, + F32 target_error, + F32* result_error); + // returns amount of indices in destiantion // result_error returns how far from original the model is in % if not NULL static U64 simplify( -- cgit v1.2.3 From 1531a31cd9907e5294df5cedbda2b9d1e3adb68b Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 28 Jul 2021 21:25:18 +0300 Subject: DRTVWR-542 Rename simplification methods in UI and add a fallback --- indra/llmeshoptimizer/llmeshoptimizer.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/llmeshoptimizer') diff --git a/indra/llmeshoptimizer/llmeshoptimizer.h b/indra/llmeshoptimizer/llmeshoptimizer.h index 2696733eb2..e881ec26c5 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.h +++ b/indra/llmeshoptimizer/llmeshoptimizer.h @@ -46,6 +46,7 @@ public: // returns amount of indices in destiantion // result_error returns how far from original the model is in % if not NULL + // Works with U32 indices (LLFace uses U16 indices) static U64 simplifyU32( U32 *destination, const U32 *indices, @@ -57,8 +58,9 @@ public: F32 target_error, F32* result_error); - // returns amount of indices in destiantion - // result_error returns how far from original the model is in % if not NULL + // Returns amount of indices in destiantion + // Result_error returns how far from original the model is in % if not NULL + // Meant for U16 indices (LLFace uses U16 indices) static U64 simplify( U16 *destination, const U16 *indices, -- cgit v1.2.3 From 1a1793244002effe46cedf63180de60f4bc69a9a Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 4 Aug 2021 21:14:00 +0300 Subject: DRTVWR-542 Automated method selection Normally simplification methods apply for whole upload, but this one selects methods per model or per face. --- indra/llmeshoptimizer/llmeshoptimizer.cpp | 97 +++++++++++++++++-------------- indra/llmeshoptimizer/llmeshoptimizer.h | 21 +++---- 2 files changed, 61 insertions(+), 57 deletions(-) (limited to 'indra/llmeshoptimizer') diff --git a/indra/llmeshoptimizer/llmeshoptimizer.cpp b/indra/llmeshoptimizer/llmeshoptimizer.cpp index 8097a05511..a879389c5a 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.cpp +++ b/indra/llmeshoptimizer/llmeshoptimizer.cpp @@ -67,19 +67,36 @@ U64 LLMeshOptimizer::simplifyU32(U32 *destination, U64 vertex_positions_stride, U64 target_index_count, F32 target_error, + bool sloppy, F32* result_error ) { - return meshopt_simplify(destination, - indices, - index_count, - (const float*)vertex_positions, - vertex_count, - vertex_positions_stride, - target_index_count, - target_error, - result_error - ); + if (sloppy) + { + return meshopt_simplifySloppy(destination, + indices, + index_count, + (const float*)vertex_positions, + vertex_count, + vertex_positions_stride, + target_index_count, + target_error, + result_error + ); + } + else + { + return meshopt_simplify(destination, + indices, + index_count, + (const float*)vertex_positions, + vertex_count, + vertex_positions_stride, + target_index_count, + target_error, + result_error + ); + } } //static @@ -91,41 +108,35 @@ U64 LLMeshOptimizer::simplify(U16 *destination, U64 vertex_positions_stride, U64 target_index_count, F32 target_error, + bool sloppy, F32* result_error ) { - return meshopt_simplify(destination, - indices, - index_count, - (const float*)vertex_positions, - vertex_count, - vertex_positions_stride, - target_index_count, - target_error, - result_error - ); + if (sloppy) + { + return meshopt_simplifySloppy(destination, + indices, + index_count, + (const float*)vertex_positions, + vertex_count, + vertex_positions_stride, + target_index_count, + target_error, + result_error + ); + } + else + { + return meshopt_simplify(destination, + indices, + index_count, + (const float*)vertex_positions, + vertex_count, + vertex_positions_stride, + target_index_count, + target_error, + result_error + ); + } } -//static -U64 LLMeshOptimizer::simplifySloppy(U16 *destination, - const U16 *indices, - U64 index_count, - const LLVector4a *vertex_positions, - U64 vertex_count, - U64 vertex_positions_stride, - U64 target_index_count, - F32 target_error, - F32* result_error - ) -{ - return meshopt_simplifySloppy(destination, - indices, - index_count, - (const float*)vertex_positions, - vertex_count, - vertex_positions_stride, - target_index_count, - target_error, - result_error - ); -} diff --git a/indra/llmeshoptimizer/llmeshoptimizer.h b/indra/llmeshoptimizer/llmeshoptimizer.h index e881ec26c5..e8dd16dae9 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.h +++ b/indra/llmeshoptimizer/llmeshoptimizer.h @@ -45,6 +45,8 @@ public: U64 vertex_positions_stride); // returns amount of indices in destiantion + // sloppy engages a variant of a mechanizm that does not respect topology as much + // but is much more efective for simpler models // result_error returns how far from original the model is in % if not NULL // Works with U32 indices (LLFace uses U16 indices) static U64 simplifyU32( @@ -56,10 +58,13 @@ public: U64 vertex_positions_stride, U64 target_index_count, F32 target_error, + bool sloppy, F32* result_error); // Returns amount of indices in destiantion - // Result_error returns how far from original the model is in % if not NULL + // sloppy engages a variant of a mechanizm that does not respect topology as much + // but is much better for simpler models + // result_error returns how far from original the model is in % if not NULL // Meant for U16 indices (LLFace uses U16 indices) static U64 simplify( U16 *destination, @@ -70,19 +75,7 @@ public: U64 vertex_positions_stride, U64 target_index_count, F32 target_error, - F32* result_error); - - // returns amount of indices in destiantion - // result_error returns how far from original the model is in % if not NULL - static U64 simplifySloppy( - U16 *destination, - const U16 *indices, - U64 index_count, - const LLVector4a *vertex_positions, - U64 vertex_count, - U64 vertex_positions_stride, - U64 target_index_count, - F32 target_error, + bool sloppy, F32* result_error); private: }; -- cgit v1.2.3