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/llmeshoptimizer.h | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 indra/llmeshoptimizer/llmeshoptimizer.h (limited to 'indra/llmeshoptimizer/llmeshoptimizer.h') 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.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llmeshoptimizer/llmeshoptimizer.h') 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/llmeshoptimizer.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'indra/llmeshoptimizer/llmeshoptimizer.h') 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/llmeshoptimizer.h') 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 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.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'indra/llmeshoptimizer/llmeshoptimizer.h') 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.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/llmeshoptimizer/llmeshoptimizer.h') 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.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/llmeshoptimizer/llmeshoptimizer.h') 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.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indra/llmeshoptimizer/llmeshoptimizer.h') 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/llmeshoptimizer.h') 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.h | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'indra/llmeshoptimizer/llmeshoptimizer.h') 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