From b277cc6a8fd2a48ed3ba6498734d9fae209d181e Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 18 Sep 2025 13:38:54 -0400 Subject: Initial VHACD based llconvexdecomposition --- indra/llprimitive/CMakeLists.txt | 6 ++++++ indra/llprimitive/llmodel.cpp | 4 ++-- indra/llprimitive/llmodel.h | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index e13f0bbd96..9e90314a51 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -70,6 +70,12 @@ target_link_libraries(llprimitive ll::glm ) +if (TARGET llconvexdecomposition) + target_link_libraries(llprimitive + llconvexdecomposition + ) +endif () + #add unit tests if (LL_TESTS) INCLUDE(LLAddBuildTest) diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 00ef79ce7f..8055bffd32 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1296,10 +1296,10 @@ LLModel::weight_list& LLModel::getJointInfluences(const LLVector3& pos) } void LLModel::setConvexHullDecomposition( - const LLModel::convex_hull_decomposition& decomp) + const LLModel::convex_hull_decomposition& decomp, const std::vector& decomp_mesh) { mPhysics.mHull = decomp; - mPhysics.mMesh.clear(); + mPhysics.mMesh = decomp_mesh; updateHullCenters(); } diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index 6501b3dc50..ac88af18f0 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -305,7 +305,8 @@ public: S32 mDecompID; void setConvexHullDecomposition( - const convex_hull_decomposition& decomp); + const convex_hull_decomposition& decomp, + const std::vector& decomp_mesh); void updateHullCenters(); LLVector3 mCenterOfHullCenters; -- cgit v1.2.3 From 5fe152cfea87c04c1edf2caa7d419a056a7916a2 Mon Sep 17 00:00:00 2001 From: Aqil Ahmad Date: Mon, 6 Oct 2025 18:52:33 +0500 Subject: Fix #4195: Preserve transforms when switching PBR materials (#4725) Fixes texture transforms being reset when switching from Blinn-Phong to PBR materials and between PBR. Previously, custom scale, offset, and rotation settings would be lost, making it tedious to switch between PBR materials. --- indra/llprimitive/llgltfmaterial.cpp | 31 +++++++++++++++++++++++++++++++ indra/llprimitive/llgltfmaterial.h | 8 ++++++++ 2 files changed, 39 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp index cc4921416f..930222e3db 100644 --- a/indra/llprimitive/llgltfmaterial.cpp +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -923,3 +923,34 @@ void LLGLTFMaterial::updateTextureTracking() // setTEGLTFMaterialOverride is responsible for tracking // for material overrides editor will set it } + +void LLGLTFMaterial::convertTextureTransformToPBR( + F32 tex_scale_s, + F32 tex_scale_t, + F32 tex_offset_s, + F32 tex_offset_t, + F32 tex_rotation, + LLVector2& pbr_scale, + LLVector2& pbr_offset, + F32& pbr_rotation) +{ + pbr_scale.set(tex_scale_s, tex_scale_t); + pbr_rotation = -(tex_rotation) / 2.f; + const F32 adjusted_offset_s = tex_offset_s; + const F32 adjusted_offset_t = -tex_offset_t; + F32 center_adjust_s = 0.5f * (1.0f - tex_scale_s); + F32 center_adjust_t = 0.5f * (1.0f - tex_scale_t); + + if (pbr_rotation != 0.0f) + { + const F32 c = cosf(pbr_rotation); + const F32 s = sinf(pbr_rotation); + const F32 tmp_s = center_adjust_s * c - center_adjust_t * s; + const F32 tmp_t = center_adjust_s * s + center_adjust_t * c; + center_adjust_s = tmp_s; + center_adjust_t = tmp_t; + } + + pbr_offset.set(adjusted_offset_s + center_adjust_s, + adjusted_offset_t + center_adjust_t); +} diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index 10df4c8ee1..8d45cb6185 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -214,6 +214,14 @@ public: bool hasLocalTextures() { return !mTrackingIdToLocalTexture.empty(); } virtual bool replaceLocalTexture(const LLUUID& tracking_id, const LLUUID &old_id, const LLUUID& new_id); virtual void updateTextureTracking(); + + // Convert legacy TE transform values to PBR transform values. + static void convertTextureTransformToPBR(F32 tex_scale_s, F32 tex_scale_t, + F32 tex_offset_s, F32 tex_offset_t, + F32 tex_rotation, + LLVector2& pbr_scale, + LLVector2& pbr_offset, + F32& pbr_rotation); protected: static LLVector2 vec2FromJson(const std::map& object, const char* key, const LLVector2& default_value); static F32 floatFromJson(const std::map& object, const char* key, const F32 default_value); -- cgit v1.2.3 From 41e9595522c71534219158609e97186e4bfeac69 Mon Sep 17 00:00:00 2001 From: Rye Date: Mon, 20 Oct 2025 13:10:19 -0400 Subject: Rework new convex decomp into a physicsextensions stub package and fix havok and havok_tpv builds for darwin universal to utilize new vhacd stub (#4858) --- indra/llprimitive/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 9e90314a51..ff0cad58d6 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -65,15 +65,18 @@ target_link_libraries(llprimitive llxml llcharacter llrender - llphysicsextensions_impl ll::colladadom ll::glm ) -if (TARGET llconvexdecomposition) +if (HAVOK OR HAVOK_TPV) target_link_libraries(llprimitive - llconvexdecomposition - ) + llphysicsextensions_impl + ) +else() + target_link_libraries(llprimitive + llphysicsextensionsos + ) endif () #add unit tests -- cgit v1.2.3