From d6e10ba4b0e08c29b16ea62e0f8b7d1835418903 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 25 Mar 2024 15:50:47 +0200 Subject: viewer#1016 Incorrect behavior of Physics Shapes rendering --- indra/newview/llphysicsshapebuilderutil.cpp | 385 +++++++++++++++------------- indra/newview/llphysicsshapebuilderutil.h | 2 + 2 files changed, 211 insertions(+), 176 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llphysicsshapebuilderutil.cpp b/indra/newview/llphysicsshapebuilderutil.cpp index 37534feadc..a79cc984c1 100644 --- a/indra/newview/llphysicsshapebuilderutil.cpp +++ b/indra/newview/llphysicsshapebuilderutil.cpp @@ -1,25 +1,25 @@ -/** +/** * @file llphysicsshapebuilder.cpp * @brief Generic system to convert LL(Physics)VolumeParams to physics shapes * * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, 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$ */ @@ -28,194 +28,227 @@ #include "llphysicsshapebuilderutil.h" -/* static */ -void LLPhysicsShapeBuilderUtil::determinePhysicsShape( const LLPhysicsVolumeParams& volume_params, const LLVector3& scale, PhysicsShapeSpecification& specOut) -{ - const LLProfileParams& profile_params = volume_params.getProfileParams(); - const LLPathParams& path_params = volume_params.getPathParams(); - - specOut.mScale = scale; - - const F32 avgScale = ( scale[VX] + scale[VY] + scale[VZ] )/3.0f; +#include "llmeshrepository.h" - // count the scale elements that are small - S32 min_size_counts = 0; - for (S32 i = 0; i < 3; ++i) +bool LLPhysicsVolumeParams::hasDecomposition() const + { + if (!isMeshSculpt()) { - if (scale[i] < SHAPE_BUILDER_CONVEXIFICATION_SIZE) - { - ++min_size_counts; - } + return false; } - const bool profile_complete = ( profile_params.getBegin() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale ) && - ( profile_params.getEnd() >= (1.0f - SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale) ); - - const bool path_complete = ( path_params.getBegin() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale ) && - ( path_params.getEnd() >= (1.0f - SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale) ); - - const bool simple_params = ( volume_params.getHollow() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_HOLLOW/avgScale ) - && ( fabs(path_params.getShearX()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_SHEAR/avgScale ) - && ( fabs(path_params.getShearY()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_SHEAR/avgScale ) - && ( !volume_params.isMeshSculpt() && !volume_params.isSculpt() ); - - if (simple_params && profile_complete) + LLUUID mesh_id = getSculptID(); + if (mesh_id.isNull()) { - // Try to create an implicit shape or convexified - bool no_taper = ( fabs(path_params.getScaleX() - 1.0f) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TAPER/avgScale ) - && ( fabs(path_params.getScaleY() - 1.0f) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TAPER/avgScale ); - - bool no_twist = ( fabs(path_params.getTwistBegin()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TWIST/avgScale ) - && ( fabs(path_params.getTwistEnd()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TWIST/avgScale); - - // Box - if( - ( profile_params.getCurveType() == LL_PCODE_PROFILE_SQUARE ) - && ( path_params.getCurveType() == LL_PCODE_PATH_LINE ) - && no_taper - && no_twist - ) - { - specOut.mType = PhysicsShapeSpecification::BOX; - if ( path_complete ) - { - return; - } - else - { - // Side lengths - specOut.mScale[VX] = llmax( scale[VX], SHAPE_BUILDER_MIN_GEOMETRY_SIZE ); - specOut.mScale[VY] = llmax( scale[VY], SHAPE_BUILDER_MIN_GEOMETRY_SIZE ); - specOut.mScale[VZ] = llmax( scale[VZ] * (path_params.getEnd() - path_params.getBegin()), SHAPE_BUILDER_MIN_GEOMETRY_SIZE ); + return false; + } - specOut.mCenter.set( 0.f, 0.f, 0.5f * scale[VZ] * ( path_params.getEnd() + path_params.getBegin() - 1.0f ) ); - return; - } - } + LLModel::Decomposition* decomp = gMeshRepo.getDecomposition(mesh_id); - // Sphere - if( path_complete - && ( profile_params.getCurveType() == LL_PCODE_PROFILE_CIRCLE_HALF ) - && ( path_params.getCurveType() == LL_PCODE_PATH_CIRCLE ) - && ( fabs(volume_params.getTaper()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TAPER/avgScale ) - && no_twist - ) - { - if ( ( scale[VX] == scale[VZ] ) - && ( scale[VY] == scale[VZ] ) ) - { - // perfect sphere - specOut.mType = PhysicsShapeSpecification::SPHERE; - specOut.mScale = scale; - return; - } - else if (min_size_counts > 1) - { - // small or narrow sphere -- we can boxify - for (S32 i=0; i<3; ++i) - { - if (specOut.mScale[i] < SHAPE_BUILDER_CONVEXIFICATION_SIZE) - { - // reduce each small dimension size to split the approximation errors - specOut.mScale[i] *= 0.75f; - } - } - specOut.mType = PhysicsShapeSpecification::BOX; - return; - } - } + return decomp != NULL; +} - // Cylinder - if( (scale[VX] == scale[VY]) - && ( profile_params.getCurveType() == LL_PCODE_PROFILE_CIRCLE ) - && ( path_params.getCurveType() == LL_PCODE_PATH_LINE ) - && ( volume_params.getBeginS() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale ) - && ( volume_params.getEndS() >= (1.0f - SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale) ) - && no_taper +/* static */ +void LLPhysicsShapeBuilderUtil::determinePhysicsShape( const LLPhysicsVolumeParams& volume_params, const LLVector3& scale, PhysicsShapeSpecification& specOut) +{ + const LLProfileParams& profile_params = volume_params.getProfileParams(); + const LLPathParams& path_params = volume_params.getPathParams(); + + specOut.mScale = scale; + + const F32 avgScale = ( scale[VX] + scale[VY] + scale[VZ] )/3.0f; + + // count the scale elements that are small + S32 min_size_counts = 0; + for (S32 i = 0; i < 3; ++i) + { + if (scale[i] < SHAPE_BUILDER_CONVEXIFICATION_SIZE) + { + ++min_size_counts; + } + } + + const bool profile_complete = ( profile_params.getBegin() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale ) && + ( profile_params.getEnd() >= (1.0f - SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale) ); + + const bool path_complete = ( path_params.getBegin() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale ) && + ( path_params.getEnd() >= (1.0f - SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale) ); + + const bool simple_params = ( volume_params.getHollow() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_HOLLOW/avgScale ) + && ( fabs(path_params.getShearX()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_SHEAR/avgScale ) + && ( fabs(path_params.getShearY()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_SHEAR/avgScale ) + && ( !volume_params.isMeshSculpt() && !volume_params.isSculpt() ); + + if (simple_params && profile_complete) + { + // Try to create an implicit shape or convexified + bool no_taper = ( fabs(path_params.getScaleX() - 1.0f) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TAPER/avgScale ) + && ( fabs(path_params.getScaleY() - 1.0f) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TAPER/avgScale ); + + bool no_twist = ( fabs(path_params.getTwistBegin()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TWIST/avgScale ) + && ( fabs(path_params.getTwistEnd()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TWIST/avgScale); + + // Box + if( + ( profile_params.getCurveType() == LL_PCODE_PROFILE_SQUARE ) + && ( path_params.getCurveType() == LL_PCODE_PATH_LINE ) + && no_taper + && no_twist + ) + { + specOut.mType = PhysicsShapeSpecification::BOX; + if ( path_complete ) + { + return; + } + else + { + // Side lengths + specOut.mScale[VX] = llmax( scale[VX], SHAPE_BUILDER_MIN_GEOMETRY_SIZE ); + specOut.mScale[VY] = llmax( scale[VY], SHAPE_BUILDER_MIN_GEOMETRY_SIZE ); + specOut.mScale[VZ] = llmax( scale[VZ] * (path_params.getEnd() - path_params.getBegin()), SHAPE_BUILDER_MIN_GEOMETRY_SIZE ); + + specOut.mCenter.set( 0.f, 0.f, 0.5f * scale[VZ] * ( path_params.getEnd() + path_params.getBegin() - 1.0f ) ); + return; + } + } + + // Sphere + if( path_complete + && ( profile_params.getCurveType() == LL_PCODE_PROFILE_CIRCLE_HALF ) + && ( path_params.getCurveType() == LL_PCODE_PATH_CIRCLE ) + && ( fabs(volume_params.getTaper()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TAPER/avgScale ) + && no_twist + ) + { + if ( ( scale[VX] == scale[VZ] ) + && ( scale[VY] == scale[VZ] ) ) + { + // perfect sphere + specOut.mType = PhysicsShapeSpecification::SPHERE; + specOut.mScale = scale; + return; + } + else if (min_size_counts > 1) + { + // small or narrow sphere -- we can boxify + for (S32 i=0; i<3; ++i) + { + if (specOut.mScale[i] < SHAPE_BUILDER_CONVEXIFICATION_SIZE) + { + // reduce each small dimension size to split the approximation errors + specOut.mScale[i] *= 0.75f; + } + } + specOut.mType = PhysicsShapeSpecification::BOX; + return; + } + } + + // Cylinder + if( (scale[VX] == scale[VY]) + && ( profile_params.getCurveType() == LL_PCODE_PROFILE_CIRCLE ) + && ( path_params.getCurveType() == LL_PCODE_PATH_LINE ) + && ( volume_params.getBeginS() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale ) + && ( volume_params.getEndS() >= (1.0f - SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale) ) + && no_taper + ) + { + if (min_size_counts > 1) + { + // small or narrow sphere -- we can boxify + for (S32 i=0; i<3; ++i) + { + if (specOut.mScale[i] < SHAPE_BUILDER_CONVEXIFICATION_SIZE) + { + // reduce each small dimension size to split the approximation errors + specOut.mScale[i] *= 0.75f; + } + } + + specOut.mType = PhysicsShapeSpecification::BOX; + } + else + { + specOut.mType = PhysicsShapeSpecification::CYLINDER; + F32 length = (volume_params.getPathParams().getEnd() - volume_params.getPathParams().getBegin()) * scale[VZ]; + + specOut.mScale[VY] = specOut.mScale[VX]; + specOut.mScale[VZ] = length; + // The minus one below fixes the fact that begin and end range from 0 to 1 not -1 to 1. + specOut.mCenter.set( 0.f, 0.f, 0.5f * (volume_params.getPathParams().getBegin() + volume_params.getPathParams().getEnd() - 1.f) * scale[VZ] ); + } + + return; + } + } + + if ( (min_size_counts == 3 ) + // Possible dead code here--who wants to take it out? + || (path_complete + && profile_complete + && ( path_params.getCurveType() == LL_PCODE_PATH_LINE ) + && (min_size_counts > 1 ) ) + ) + { + // it isn't simple but + // we might be able to convexify this shape if the path and profile are complete + // or the path is linear and both path and profile are complete --> we can boxify it + specOut.mType = PhysicsShapeSpecification::BOX; + specOut.mScale = scale; + return; + } + + // Special case for big, very thin objects - bump the small dimensions up to the COLLISION_TOLERANCE + if (min_size_counts == 1 // One dimension is small + && avgScale > 3.f) // ... but others are fairly large + { + for (S32 i = 0; i < 3; ++i) + { + specOut.mScale[i] = llmax( specOut.mScale[i], COLLISION_TOLERANCE ); + } + } + + if ( volume_params.shouldForceConvex() ) + { + // Server distinguishes between convex of a prim vs isSculpt, but we don't care. + specOut.mType = PhysicsShapeSpecification::USER_CONVEX; + } + // Make a simpler convex shape if we can. + else if (volume_params.isConvex() // is convex + || min_size_counts > 1 ) // two or more small dimensions + { + specOut.mType = PhysicsShapeSpecification::PRIM_CONVEX; + } + else if (volume_params.isMeshSculpt()) + { + // Check overall dimensions, not individual triangles. + if (scale.mV[0] < SHAPE_BUILDER_USER_MESH_CONVEXIFICATION_SIZE + || scale.mV[1] < SHAPE_BUILDER_USER_MESH_CONVEXIFICATION_SIZE + || scale.mV[2] < SHAPE_BUILDER_USER_MESH_CONVEXIFICATION_SIZE ) { - if (min_size_counts > 1) + if (volume_params.hasDecomposition()) { - // small or narrow sphere -- we can boxify - for (S32 i=0; i<3; ++i) - { - if (specOut.mScale[i] < SHAPE_BUILDER_CONVEXIFICATION_SIZE) - { - // reduce each small dimension size to split the approximation errors - specOut.mScale[i] *= 0.75f; - } - } - - specOut.mType = PhysicsShapeSpecification::BOX; + specOut.mType = PhysicsShapeSpecification::USER_MESH; } else { - specOut.mType = PhysicsShapeSpecification::CYLINDER; - F32 length = (volume_params.getPathParams().getEnd() - volume_params.getPathParams().getBegin()) * scale[VZ]; - - specOut.mScale[VY] = specOut.mScale[VX]; - specOut.mScale[VZ] = length; - // The minus one below fixes the fact that begin and end range from 0 to 1 not -1 to 1. - specOut.mCenter.set( 0.f, 0.f, 0.5f * (volume_params.getPathParams().getBegin() + volume_params.getPathParams().getEnd() - 1.f) * scale[VZ] ); + // Server distinguishes between user-specified or default convex mesh, vs server's thin-triangle override, but we don't. + specOut.mType = PhysicsShapeSpecification::PRIM_CONVEX; } - - return; } - } - - if ( (min_size_counts == 3 ) - // Possible dead code here--who wants to take it out? - || (path_complete - && profile_complete - && ( path_params.getCurveType() == LL_PCODE_PATH_LINE ) - && (min_size_counts > 1 ) ) - ) - { - // it isn't simple but - // we might be able to convexify this shape if the path and profile are complete - // or the path is linear and both path and profile are complete --> we can boxify it - specOut.mType = PhysicsShapeSpecification::BOX; - specOut.mScale = scale; - return; - } - - // Special case for big, very thin objects - bump the small dimensions up to the COLLISION_TOLERANCE - if (min_size_counts == 1 // One dimension is small - && avgScale > 3.f) // ... but others are fairly large - { - for (S32 i = 0; i < 3; ++i) + else { - specOut.mScale[i] = llmax( specOut.mScale[i], COLLISION_TOLERANCE ); + specOut.mType = PhysicsShapeSpecification::USER_MESH; } } - - if ( volume_params.shouldForceConvex() ) - { - // Server distinguishes between convex of a prim vs isSculpt, but we don't care. - specOut.mType = PhysicsShapeSpecification::USER_CONVEX; - } - // Make a simpler convex shape if we can. - else if (volume_params.isConvex() // is convex - || min_size_counts > 1 ) // two or more small dimensions - { - specOut.mType = PhysicsShapeSpecification::PRIM_CONVEX; - } - else if (volume_params.isMeshSculpt() && - // Check overall dimensions, not individual triangles. - (scale.mV[0] < SHAPE_BUILDER_USER_MESH_CONVEXIFICATION_SIZE || - scale.mV[1] < SHAPE_BUILDER_USER_MESH_CONVEXIFICATION_SIZE || - scale.mV[2] < SHAPE_BUILDER_USER_MESH_CONVEXIFICATION_SIZE - ) ) - { - // Server distinguishes between user-specified or default convex mesh, vs server's thin-triangle override, but we don't. - specOut.mType = PhysicsShapeSpecification::PRIM_CONVEX; - } - else if ( volume_params.isSculpt() ) // Is a sculpt of any kind (mesh or legacy) - { - specOut.mType = volume_params.isMeshSculpt() ? PhysicsShapeSpecification::USER_MESH : PhysicsShapeSpecification::SCULPT; - } - else // Resort to mesh - { - specOut.mType = PhysicsShapeSpecification::PRIM_MESH; - } + else if ( volume_params.isSculpt() ) + { + specOut.mType = PhysicsShapeSpecification::SCULPT; + } + else // Resort to mesh + { + specOut.mType = PhysicsShapeSpecification::PRIM_MESH; + } } diff --git a/indra/newview/llphysicsshapebuilderutil.h b/indra/newview/llphysicsshapebuilderutil.h index 33c2d0a8b6..01c173523b 100644 --- a/indra/newview/llphysicsshapebuilderutil.h +++ b/indra/newview/llphysicsshapebuilderutil.h @@ -79,6 +79,8 @@ public: bool shouldForceConvex() const { return mForceConvex; } + bool hasDecomposition() const; + private: bool mForceConvex; }; -- cgit v1.2.3 From 5370a6d323e14d7b4e32a3f41ef78f7744e361c5 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Wed, 18 Sep 2024 12:23:14 -0700 Subject: fix whitespace --- indra/newview/llphysicsshapebuilderutil.cpp | 360 ++++++++++++++-------------- 1 file changed, 180 insertions(+), 180 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llphysicsshapebuilderutil.cpp b/indra/newview/llphysicsshapebuilderutil.cpp index a79cc984c1..eb0df1194e 100644 --- a/indra/newview/llphysicsshapebuilderutil.cpp +++ b/indra/newview/llphysicsshapebuilderutil.cpp @@ -1,25 +1,25 @@ -/** +/** * @file llphysicsshapebuilder.cpp * @brief Generic system to convert LL(Physics)VolumeParams to physics shapes * * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, 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$ */ @@ -51,175 +51,175 @@ bool LLPhysicsVolumeParams::hasDecomposition() const /* static */ void LLPhysicsShapeBuilderUtil::determinePhysicsShape( const LLPhysicsVolumeParams& volume_params, const LLVector3& scale, PhysicsShapeSpecification& specOut) { - const LLProfileParams& profile_params = volume_params.getProfileParams(); - const LLPathParams& path_params = volume_params.getPathParams(); - - specOut.mScale = scale; - - const F32 avgScale = ( scale[VX] + scale[VY] + scale[VZ] )/3.0f; - - // count the scale elements that are small - S32 min_size_counts = 0; - for (S32 i = 0; i < 3; ++i) - { - if (scale[i] < SHAPE_BUILDER_CONVEXIFICATION_SIZE) - { - ++min_size_counts; - } - } - - const bool profile_complete = ( profile_params.getBegin() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale ) && - ( profile_params.getEnd() >= (1.0f - SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale) ); - - const bool path_complete = ( path_params.getBegin() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale ) && - ( path_params.getEnd() >= (1.0f - SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale) ); - - const bool simple_params = ( volume_params.getHollow() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_HOLLOW/avgScale ) - && ( fabs(path_params.getShearX()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_SHEAR/avgScale ) - && ( fabs(path_params.getShearY()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_SHEAR/avgScale ) - && ( !volume_params.isMeshSculpt() && !volume_params.isSculpt() ); - - if (simple_params && profile_complete) - { - // Try to create an implicit shape or convexified - bool no_taper = ( fabs(path_params.getScaleX() - 1.0f) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TAPER/avgScale ) - && ( fabs(path_params.getScaleY() - 1.0f) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TAPER/avgScale ); - - bool no_twist = ( fabs(path_params.getTwistBegin()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TWIST/avgScale ) - && ( fabs(path_params.getTwistEnd()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TWIST/avgScale); - - // Box - if( - ( profile_params.getCurveType() == LL_PCODE_PROFILE_SQUARE ) - && ( path_params.getCurveType() == LL_PCODE_PATH_LINE ) - && no_taper - && no_twist - ) - { - specOut.mType = PhysicsShapeSpecification::BOX; - if ( path_complete ) - { - return; - } - else - { - // Side lengths - specOut.mScale[VX] = llmax( scale[VX], SHAPE_BUILDER_MIN_GEOMETRY_SIZE ); - specOut.mScale[VY] = llmax( scale[VY], SHAPE_BUILDER_MIN_GEOMETRY_SIZE ); - specOut.mScale[VZ] = llmax( scale[VZ] * (path_params.getEnd() - path_params.getBegin()), SHAPE_BUILDER_MIN_GEOMETRY_SIZE ); - - specOut.mCenter.set( 0.f, 0.f, 0.5f * scale[VZ] * ( path_params.getEnd() + path_params.getBegin() - 1.0f ) ); - return; - } - } - - // Sphere - if( path_complete - && ( profile_params.getCurveType() == LL_PCODE_PROFILE_CIRCLE_HALF ) - && ( path_params.getCurveType() == LL_PCODE_PATH_CIRCLE ) - && ( fabs(volume_params.getTaper()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TAPER/avgScale ) - && no_twist - ) - { - if ( ( scale[VX] == scale[VZ] ) - && ( scale[VY] == scale[VZ] ) ) - { - // perfect sphere - specOut.mType = PhysicsShapeSpecification::SPHERE; - specOut.mScale = scale; - return; - } - else if (min_size_counts > 1) - { - // small or narrow sphere -- we can boxify - for (S32 i=0; i<3; ++i) - { - if (specOut.mScale[i] < SHAPE_BUILDER_CONVEXIFICATION_SIZE) - { - // reduce each small dimension size to split the approximation errors - specOut.mScale[i] *= 0.75f; - } - } - specOut.mType = PhysicsShapeSpecification::BOX; - return; - } - } - - // Cylinder - if( (scale[VX] == scale[VY]) - && ( profile_params.getCurveType() == LL_PCODE_PROFILE_CIRCLE ) - && ( path_params.getCurveType() == LL_PCODE_PATH_LINE ) - && ( volume_params.getBeginS() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale ) - && ( volume_params.getEndS() >= (1.0f - SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale) ) - && no_taper - ) - { - if (min_size_counts > 1) - { - // small or narrow sphere -- we can boxify - for (S32 i=0; i<3; ++i) - { - if (specOut.mScale[i] < SHAPE_BUILDER_CONVEXIFICATION_SIZE) - { - // reduce each small dimension size to split the approximation errors - specOut.mScale[i] *= 0.75f; - } - } - - specOut.mType = PhysicsShapeSpecification::BOX; - } - else - { - specOut.mType = PhysicsShapeSpecification::CYLINDER; - F32 length = (volume_params.getPathParams().getEnd() - volume_params.getPathParams().getBegin()) * scale[VZ]; - - specOut.mScale[VY] = specOut.mScale[VX]; - specOut.mScale[VZ] = length; - // The minus one below fixes the fact that begin and end range from 0 to 1 not -1 to 1. - specOut.mCenter.set( 0.f, 0.f, 0.5f * (volume_params.getPathParams().getBegin() + volume_params.getPathParams().getEnd() - 1.f) * scale[VZ] ); - } - - return; - } - } - - if ( (min_size_counts == 3 ) - // Possible dead code here--who wants to take it out? - || (path_complete - && profile_complete - && ( path_params.getCurveType() == LL_PCODE_PATH_LINE ) - && (min_size_counts > 1 ) ) - ) - { - // it isn't simple but - // we might be able to convexify this shape if the path and profile are complete - // or the path is linear and both path and profile are complete --> we can boxify it - specOut.mType = PhysicsShapeSpecification::BOX; - specOut.mScale = scale; - return; - } - - // Special case for big, very thin objects - bump the small dimensions up to the COLLISION_TOLERANCE - if (min_size_counts == 1 // One dimension is small - && avgScale > 3.f) // ... but others are fairly large - { - for (S32 i = 0; i < 3; ++i) - { - specOut.mScale[i] = llmax( specOut.mScale[i], COLLISION_TOLERANCE ); - } - } - - if ( volume_params.shouldForceConvex() ) - { + const LLProfileParams& profile_params = volume_params.getProfileParams(); + const LLPathParams& path_params = volume_params.getPathParams(); + + specOut.mScale = scale; + + const F32 avgScale = ( scale[VX] + scale[VY] + scale[VZ] )/3.0f; + + // count the scale elements that are small + S32 min_size_counts = 0; + for (S32 i = 0; i < 3; ++i) + { + if (scale[i] < SHAPE_BUILDER_CONVEXIFICATION_SIZE) + { + ++min_size_counts; + } + } + + const bool profile_complete = ( profile_params.getBegin() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale ) && + ( profile_params.getEnd() >= (1.0f - SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale) ); + + const bool path_complete = ( path_params.getBegin() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale ) && + ( path_params.getEnd() >= (1.0f - SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale) ); + + const bool simple_params = ( volume_params.getHollow() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_HOLLOW/avgScale ) + && ( fabs(path_params.getShearX()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_SHEAR/avgScale ) + && ( fabs(path_params.getShearY()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_SHEAR/avgScale ) + && ( !volume_params.isMeshSculpt() && !volume_params.isSculpt() ); + + if (simple_params && profile_complete) + { + // Try to create an implicit shape or convexified + bool no_taper = ( fabs(path_params.getScaleX() - 1.0f) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TAPER/avgScale ) + && ( fabs(path_params.getScaleY() - 1.0f) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TAPER/avgScale ); + + bool no_twist = ( fabs(path_params.getTwistBegin()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TWIST/avgScale ) + && ( fabs(path_params.getTwistEnd()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TWIST/avgScale); + + // Box + if( + ( profile_params.getCurveType() == LL_PCODE_PROFILE_SQUARE ) + && ( path_params.getCurveType() == LL_PCODE_PATH_LINE ) + && no_taper + && no_twist + ) + { + specOut.mType = PhysicsShapeSpecification::BOX; + if ( path_complete ) + { + return; + } + else + { + // Side lengths + specOut.mScale[VX] = llmax( scale[VX], SHAPE_BUILDER_MIN_GEOMETRY_SIZE ); + specOut.mScale[VY] = llmax( scale[VY], SHAPE_BUILDER_MIN_GEOMETRY_SIZE ); + specOut.mScale[VZ] = llmax( scale[VZ] * (path_params.getEnd() - path_params.getBegin()), SHAPE_BUILDER_MIN_GEOMETRY_SIZE ); + + specOut.mCenter.set( 0.f, 0.f, 0.5f * scale[VZ] * ( path_params.getEnd() + path_params.getBegin() - 1.0f ) ); + return; + } + } + + // Sphere + if( path_complete + && ( profile_params.getCurveType() == LL_PCODE_PROFILE_CIRCLE_HALF ) + && ( path_params.getCurveType() == LL_PCODE_PATH_CIRCLE ) + && ( fabs(volume_params.getTaper()) <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_TAPER/avgScale ) + && no_twist + ) + { + if ( ( scale[VX] == scale[VZ] ) + && ( scale[VY] == scale[VZ] ) ) + { + // perfect sphere + specOut.mType = PhysicsShapeSpecification::SPHERE; + specOut.mScale = scale; + return; + } + else if (min_size_counts > 1) + { + // small or narrow sphere -- we can boxify + for (S32 i=0; i<3; ++i) + { + if (specOut.mScale[i] < SHAPE_BUILDER_CONVEXIFICATION_SIZE) + { + // reduce each small dimension size to split the approximation errors + specOut.mScale[i] *= 0.75f; + } + } + specOut.mType = PhysicsShapeSpecification::BOX; + return; + } + } + + // Cylinder + if( (scale[VX] == scale[VY]) + && ( profile_params.getCurveType() == LL_PCODE_PROFILE_CIRCLE ) + && ( path_params.getCurveType() == LL_PCODE_PATH_LINE ) + && ( volume_params.getBeginS() <= SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale ) + && ( volume_params.getEndS() >= (1.0f - SHAPE_BUILDER_IMPLICIT_THRESHOLD_PATH_CUT/avgScale) ) + && no_taper + ) + { + if (min_size_counts > 1) + { + // small or narrow sphere -- we can boxify + for (S32 i=0; i<3; ++i) + { + if (specOut.mScale[i] < SHAPE_BUILDER_CONVEXIFICATION_SIZE) + { + // reduce each small dimension size to split the approximation errors + specOut.mScale[i] *= 0.75f; + } + } + + specOut.mType = PhysicsShapeSpecification::BOX; + } + else + { + specOut.mType = PhysicsShapeSpecification::CYLINDER; + F32 length = (volume_params.getPathParams().getEnd() - volume_params.getPathParams().getBegin()) * scale[VZ]; + + specOut.mScale[VY] = specOut.mScale[VX]; + specOut.mScale[VZ] = length; + // The minus one below fixes the fact that begin and end range from 0 to 1 not -1 to 1. + specOut.mCenter.set( 0.f, 0.f, 0.5f * (volume_params.getPathParams().getBegin() + volume_params.getPathParams().getEnd() - 1.f) * scale[VZ] ); + } + + return; + } + } + + if ( (min_size_counts == 3 ) + // Possible dead code here--who wants to take it out? + || (path_complete + && profile_complete + && ( path_params.getCurveType() == LL_PCODE_PATH_LINE ) + && (min_size_counts > 1 ) ) + ) + { + // it isn't simple but + // we might be able to convexify this shape if the path and profile are complete + // or the path is linear and both path and profile are complete --> we can boxify it + specOut.mType = PhysicsShapeSpecification::BOX; + specOut.mScale = scale; + return; + } + + // Special case for big, very thin objects - bump the small dimensions up to the COLLISION_TOLERANCE + if (min_size_counts == 1 // One dimension is small + && avgScale > 3.f) // ... but others are fairly large + { + for (S32 i = 0; i < 3; ++i) + { + specOut.mScale[i] = llmax( specOut.mScale[i], COLLISION_TOLERANCE ); + } + } + + if ( volume_params.shouldForceConvex() ) + { // Server distinguishes between convex of a prim vs isSculpt, but we don't care. - specOut.mType = PhysicsShapeSpecification::USER_CONVEX; - } - // Make a simpler convex shape if we can. - else if (volume_params.isConvex() // is convex - || min_size_counts > 1 ) // two or more small dimensions - { - specOut.mType = PhysicsShapeSpecification::PRIM_CONVEX; - } + specOut.mType = PhysicsShapeSpecification::USER_CONVEX; + } + // Make a simpler convex shape if we can. + else if (volume_params.isConvex() // is convex + || min_size_counts > 1 ) // two or more small dimensions + { + specOut.mType = PhysicsShapeSpecification::PRIM_CONVEX; + } else if (volume_params.isMeshSculpt()) { // Check overall dimensions, not individual triangles. @@ -243,12 +243,12 @@ void LLPhysicsShapeBuilderUtil::determinePhysicsShape( const LLPhysicsVolumePara specOut.mType = PhysicsShapeSpecification::USER_MESH; } } - else if ( volume_params.isSculpt() ) - { + else if ( volume_params.isSculpt() ) + { specOut.mType = PhysicsShapeSpecification::SCULPT; - } - else // Resort to mesh - { - specOut.mType = PhysicsShapeSpecification::PRIM_MESH; - } + } + else // Resort to mesh + { + specOut.mType = PhysicsShapeSpecification::PRIM_MESH; + } } -- cgit v1.2.3 From 52091a6097cd4e68f3fc1b0972080867ceb09122 Mon Sep 17 00:00:00 2001 From: Roxie Linden Date: Wed, 18 Sep 2024 13:01:43 -0700 Subject: Mute other / set volume level for other is not working. As part of the boost::json conversion, the json that mutes and sets peer gain was not being formed correctly. Also, tweaked the peer gain default. --- indra/newview/llvoicewebrtc.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 3d684e5a1b..aabf897050 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -87,6 +87,8 @@ namespace { const F32 SPEAKING_AUDIO_LEVEL = 0.30; + const uint32_t PEER_GAIN_CONVERSION_FACTOR = 220; + static const std::string REPORTED_VOICE_SERVER_TYPE = "Secondlife WebRTC Gateway"; // Don't send positional updates more frequently than this: @@ -2443,7 +2445,7 @@ void LLVoiceWebRTCConnection::setSpeakerVolume(F32 volume) void LLVoiceWebRTCConnection::setUserVolume(const LLUUID& id, F32 volume) { - boost::json::object root = {{"ug", {id.asString(), (uint32_t) (volume * 200)}}}; + boost::json::object root = { { "ug", { { id.asString(), (uint32_t)(volume * PEER_GAIN_CONVERSION_FACTOR) } } } }; std::string json_data = boost::json::serialize(root); if (mWebRTCDataInterface) { @@ -2453,7 +2455,7 @@ void LLVoiceWebRTCConnection::setUserVolume(const LLUUID& id, F32 volume) void LLVoiceWebRTCConnection::setUserMute(const LLUUID& id, bool mute) { - boost::json::object root = {{"m", {id.asString(), mute}}}; + boost::json::object root = { { "m", { { id.asString(), mute } } } }; std::string json_data = boost::json::serialize(root); if (mWebRTCDataInterface) { -- cgit v1.2.3 From b31fd167c00a288656ea82d239a9ce379f382c22 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 18 Sep 2024 15:23:20 -0500 Subject: Fix for particles not loading textures (#2598) Also fix assert while prepping GLTF assets --- indra/newview/gltfscenemanager.cpp | 59 ++++++++++++++++++++------------------ indra/newview/llface.cpp | 8 ++++++ 2 files changed, 39 insertions(+), 28 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp index ce54fa4c12..ed66753267 100644 --- a/indra/newview/gltfscenemanager.cpp +++ b/indra/newview/gltfscenemanager.cpp @@ -371,43 +371,46 @@ void GLTFSceneManager::addGLTFObject(LLViewerObject* obj, LLUUID gltf_id) //static void GLTFSceneManager::onGLTFBinLoadComplete(const LLUUID& id, LLAssetType::EType asset_type, void* user_data, S32 status, LLExtStat ext_status) { - LLViewerObject* obj = (LLViewerObject*)user_data; - llassert(asset_type == LLAssetType::AT_GLTF_BIN); - - if (status == LL_ERR_NOERR) - { - if (obj) + LLAppViewer::instance()->postToMainCoro([=]() { - // find the Buffer with the given id in the asset - if (obj->mGLTFAsset) - { - obj->mGLTFAsset->mPendingBuffers--; - + LLViewerObject* obj = (LLViewerObject*)user_data; + llassert(asset_type == LLAssetType::AT_GLTF_BIN); - if (obj->mGLTFAsset->mPendingBuffers == 0) + if (status == LL_ERR_NOERR) + { + if (obj) { - if (obj->mGLTFAsset->prep()) + // find the Buffer with the given id in the asset + if (obj->mGLTFAsset) { - GLTFSceneManager& mgr = GLTFSceneManager::instance(); - if (std::find(mgr.mObjects.begin(), mgr.mObjects.end(), obj) == mgr.mObjects.end()) + obj->mGLTFAsset->mPendingBuffers--; + + + if (obj->mGLTFAsset->mPendingBuffers == 0) { - GLTFSceneManager::instance().mObjects.push_back(obj); + if (obj->mGLTFAsset->prep()) + { + GLTFSceneManager& mgr = GLTFSceneManager::instance(); + if (std::find(mgr.mObjects.begin(), mgr.mObjects.end(), obj) == mgr.mObjects.end()) + { + GLTFSceneManager::instance().mObjects.push_back(obj); + } + } + else + { + LL_WARNS("GLTF") << "Failed to prepare GLTF asset: " << id << LL_ENDL; + obj->mGLTFAsset = nullptr; + } } } - else - { - LL_WARNS("GLTF") << "Failed to prepare GLTF asset: " << id << LL_ENDL; - obj->mGLTFAsset = nullptr; - } } } - } - } - else - { - LL_WARNS("GLTF") << "Failed to load GLTF asset: " << id << LL_ENDL; - obj->unref(); - } + else + { + LL_WARNS("GLTF") << "Failed to load GLTF asset: " << id << LL_ENDL; + obj->unref(); + } + }); } //static diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index ce68474211..297661effd 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -2268,6 +2268,14 @@ bool LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) center.mul(0.5f); size.setSub(mRiggedExtents[1], mRiggedExtents[0]); } + else if (mDrawablep && mVObjp.notNull() && mVObjp->getPartitionType() == LLViewerRegion::PARTITION_PARTICLE && mDrawablep->getSpatialGroup()) + { // use box of spatial group for particles (over approximates size, but we don't actually have a good size per particle) + LLSpatialGroup* group = mDrawablep->getSpatialGroup(); + const LLVector4a* extents = group->getExtents(); + size.setSub(extents[1], extents[0]); + center.setAdd(extents[1], extents[0]); + center.mul(0.5f); + } else { center.load3(getPositionAgent().mV); -- cgit v1.2.3 From 743a1a6d8eabf069d95777c96e5b657cb8702593 Mon Sep 17 00:00:00 2001 From: Roxie Linden Date: Wed, 18 Sep 2024 14:14:26 -0700 Subject: fix trailing whitespace --- indra/newview/llvoicewebrtc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index aabf897050..ad8f6927ed 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -2445,7 +2445,7 @@ void LLVoiceWebRTCConnection::setSpeakerVolume(F32 volume) void LLVoiceWebRTCConnection::setUserVolume(const LLUUID& id, F32 volume) { - boost::json::object root = { { "ug", { { id.asString(), (uint32_t)(volume * PEER_GAIN_CONVERSION_FACTOR) } } } }; + boost::json::object root = { { "ug", { { id.asString(), (uint32_t)(volume * PEER_GAIN_CONVERSION_FACTOR) } } } }; std::string json_data = boost::json::serialize(root); if (mWebRTCDataInterface) { -- cgit v1.2.3 From 9fa95dd0b21f323b7d8f60a826bcc128ad4e7ef2 Mon Sep 17 00:00:00 2001 From: Brad Linden <46733234+brad-linden@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:53:36 -0700 Subject: Fix crash in LLImProcessing when message comes in before region is fully init (#2604) secondlife/viewer#2603 --- indra/newview/llimprocessing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp index c1e68e0288..590cd09a31 100644 --- a/indra/newview/llimprocessing.cpp +++ b/indra/newview/llimprocessing.cpp @@ -488,7 +488,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id, case IM_NOTHING_SPECIAL: // p2p IM // Don't show dialog, just do IM if (!gAgent.isGodlike() - && gAgent.getRegion()->isPrelude() + && gAgent.inPrelude() && to_id.isNull()) { // do nothing -- don't distract newbies in -- cgit v1.2.3 From 2fd18ee162824e449dc893c66d7dd8c56518ee7c Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Thu, 19 Sep 2024 00:21:22 +0200 Subject: Fix copy&paste error in llfloaterimagepreview.cpp (#2596) --- indra/newview/llfloaterimagepreview.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp index 236725bd45..989e1d8d04 100644 --- a/indra/newview/llfloaterimagepreview.cpp +++ b/indra/newview/llfloaterimagepreview.cpp @@ -288,18 +288,18 @@ void LLFloaterImagePreview::draw() gGL.begin(LLRender::TRIANGLES); { gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mTop); - gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mTop); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mBottom); - gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mBottom); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); gGL.texCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mBottom); - gGL.vertex2i(mPreviewRect.mRight, mPreviewRect.mBottom); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); - gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mTop); - gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mTop); gGL.texCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mBottom); - gGL.vertex2i(mPreviewRect.mRight, mPreviewRect.mBottom); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); + gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mTop); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); gGL.texCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mTop); - gGL.vertex2i(mPreviewRect.mRight, mPreviewRect.mTop); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); } gGL.end(); @@ -325,18 +325,18 @@ void LLFloaterImagePreview::draw() gGL.begin(LLRender::TRIANGLES); { gGL.texCoord2f(0.f, 1.f); - gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mTop); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); gGL.texCoord2f(0.f, 0.f); - gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mBottom); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); gGL.texCoord2f(1.f, 0.f); - gGL.vertex2i(mPreviewRect.mRight, mPreviewRect.mBottom); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); - gGL.texCoord2f(0.f, 1.f); - gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mTop); gGL.texCoord2f(1.f, 0.f); - gGL.vertex2i(mPreviewRect.mRight, mPreviewRect.mBottom); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); gGL.texCoord2f(1.f, 1.f); - gGL.vertex2i(mPreviewRect.mRight, mPreviewRect.mTop); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); } gGL.end(); -- cgit v1.2.3 From ee3645ac961aec171cc56ec962723ac5fd28cf38 Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Thu, 19 Sep 2024 00:22:48 +0200 Subject: Fix possible dereferencing of nullptr in llglsandbox.cpp (#2597) --- indra/newview/llglsandbox.cpp | 120 ++++++------------------------------------ 1 file changed, 17 insertions(+), 103 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 731e711cd1..af025d5879 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -68,7 +68,7 @@ #include // Height of the yellow selection highlight posts for land -const F32 PARCEL_POST_HEIGHT = 0.666f; +constexpr F32 PARCEL_POST_HEIGHT = 0.666f; // Returns true if you got at least one object void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) @@ -178,27 +178,27 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) { std::vector potentials; - for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); - iter != LLWorld::getInstance()->getRegionList().end(); ++iter) + for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList()) { - LLViewerRegion* region = *iter; for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) { - LLSpatialPartition* part = region->getSpatialPartition(i); - if (part) + if (LLSpatialPartition* part = region->getSpatialPartition(i)) { part->cull(*LLViewerCamera::getInstance(), &potentials, true); } } } - for (std::vector::iterator iter = potentials.begin(); - iter != potentials.end(); iter++) + for (LLDrawable* drawable : potentials) { - LLDrawable* drawable = *iter; + if (!drawable) + { + continue; + } + LLViewerObject* vobjp = drawable->getVObj(); - if (!drawable || !vobjp || + if (!vobjp || vobjp->getPCode() != LL_PCODE_VOLUME || vobjp->isAttachment() || (deselect && !vobjp->isSelected())) @@ -244,7 +244,7 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) gViewerWindow->setup3DRender(); } -const F32 WIND_RELATIVE_ALTITUDE = 25.f; +constexpr F32 WIND_RELATIVE_ALTITUDE = 25.f; void LLWind::renderVectors() { @@ -266,14 +266,14 @@ void LLWind::renderVectors() x = mVelX[i + j*mSize] * WIND_SCALE_HACK; y = mVelY[i + j*mSize] * WIND_SCALE_HACK; gGL.pushMatrix(); - gGL.translatef((F32)i * region_width_meters/mSize, (F32)j * region_width_meters/mSize, 0.0); - gGL.color3f(0,1,0); + gGL.translatef((F32)i * region_width_meters/mSize, (F32)j * region_width_meters/mSize, 0.f); + gGL.color3f(0.f, 1.f, 0.f); gGL.begin(LLRender::POINTS); - gGL.vertex3f(0,0,0); + gGL.vertex3f(0.f, 0.f, 0.f); gGL.end(); - gGL.color3f(1,0,0); + gGL.color3f(1.f, 0.f, 0.f); gGL.begin(LLRender::LINES); - gGL.vertex3f(x * 0.1f, y * 0.1f ,0.f); + gGL.vertex3f(x * 0.1f, y * 0.1f, 0.f); gGL.vertex3f(x, y, 0.f); gGL.end(); gGL.popMatrix(); @@ -287,7 +287,7 @@ void LLWind::renderVectors() // Used by lltoolselectland void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global, - const LLVector3d &east_north_top_global ) + const LLVector3d &east_north_top_global) { LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -356,92 +356,6 @@ void LLViewerParcelMgr::renderRect(const LLVector3d &west_south_bottom_global, LLUI::setLineWidth(1.f); } -/* -void LLViewerParcelMgr::renderParcel(LLParcel* parcel ) -{ - S32 i; - S32 count = parcel->getBoxCount(); - for (i = 0; i < count; i++) - { - const LLParcelBox& box = parcel->getBox(i); - - F32 west = box.mMin.mV[VX]; - F32 south = box.mMin.mV[VY]; - - F32 east = box.mMax.mV[VX]; - F32 north = box.mMax.mV[VY]; - - // HACK: At edge of last region of world, we need to make sure the region - // resolves correctly so we can get a height value. - const F32 FUDGE = 0.01f; - - F32 sw_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( west, south, 0.f ) ); - F32 se_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( east-FUDGE, south, 0.f ) ); - F32 ne_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( east-FUDGE, north-FUDGE, 0.f ) ); - F32 nw_bottom = LLWorld::getInstance()->resolveLandHeightAgent( LLVector3( west, north-FUDGE, 0.f ) ); - - // little hack to make nearby lines not Z-fight - east -= 0.1f; - north -= 0.1f; - - F32 sw_top = sw_bottom + POST_HEIGHT; - F32 se_top = se_bottom + POST_HEIGHT; - F32 ne_top = ne_bottom + POST_HEIGHT; - F32 nw_top = nw_bottom + POST_HEIGHT; - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLGLDepthTest gls_depth(GL_TRUE); - - LLUI::setLineWidth(2.f); - gGL.color4f(0.f, 1.f, 1.f, 1.f); - - // Cheat and give this the same pick-name as land - gGL.begin(LLRender::LINES); - - gGL.vertex3f(west, north, nw_bottom); - gGL.vertex3f(west, north, nw_top); - - gGL.vertex3f(east, north, ne_bottom); - gGL.vertex3f(east, north, ne_top); - - gGL.vertex3f(east, south, se_bottom); - gGL.vertex3f(east, south, se_top); - - gGL.vertex3f(west, south, sw_bottom); - gGL.vertex3f(west, south, sw_top); - - gGL.end(); - - gGL.color4f(0.f, 1.f, 1.f, 0.2f); - gGL.begin(LLRender::QUADS); - - gGL.vertex3f(west, north, nw_bottom); - gGL.vertex3f(west, north, nw_top); - gGL.vertex3f(east, north, ne_top); - gGL.vertex3f(east, north, ne_bottom); - - gGL.vertex3f(east, north, ne_bottom); - gGL.vertex3f(east, north, ne_top); - gGL.vertex3f(east, south, se_top); - gGL.vertex3f(east, south, se_bottom); - - gGL.vertex3f(east, south, se_bottom); - gGL.vertex3f(east, south, se_top); - gGL.vertex3f(west, south, sw_top); - gGL.vertex3f(west, south, sw_bottom); - - gGL.vertex3f(west, south, sw_bottom); - gGL.vertex3f(west, south, sw_top); - gGL.vertex3f(west, north, nw_top); - gGL.vertex3f(west, north, nw_bottom); - - gGL.end(); - - LLUI::setLineWidth(1.f); - } -} -*/ - // north = a wall going north/south. Need that info to set up texture // coordinates correctly. -- cgit v1.2.3 From 6d842ac0af814a088c56f437dc885e4ce58b61a8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 18 Sep 2024 17:11:03 +0300 Subject: Expose LLVector4a in LLRender Avoid using a bunch of allocators. Make sure we use LLVector4a's SSE logic instead of LLVector3's. Some minor optimizations. --- indra/newview/llviewermedia.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 9739cac311..4e7416bb63 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -688,10 +688,10 @@ void LLViewerMedia::updateMedia(void *dummy_arg) static LLCachedControl inworld_media_enabled(gSavedSettings, "AudioStreamingMedia", true); static LLCachedControl inworld_audio_enabled(gSavedSettings, "AudioStreamingMusic", true); - U32 max_instances = gSavedSettings.getU32("PluginInstancesTotal"); - U32 max_normal = gSavedSettings.getU32("PluginInstancesNormal"); - U32 max_low = gSavedSettings.getU32("PluginInstancesLow"); - F32 max_cpu = gSavedSettings.getF32("PluginInstancesCPULimit"); + static LLCachedControl max_instances(gSavedSettings, "PluginInstancesTotal", 8); + static LLCachedControl max_normal(gSavedSettings, "PluginInstancesNormal", 2); + static LLCachedControl max_low(gSavedSettings, "PluginInstancesLow", 4); + static LLCachedControl max_cpu(gSavedSettings, "PluginInstancesCPULimit", 0.9); // Setting max_cpu to 0.0 disables CPU usage checking. bool check_cpu_usage = (max_cpu != 0.0f); @@ -829,7 +829,8 @@ void LLViewerMedia::updateMedia(void *dummy_arg) } else { - if(gAudiop && LLViewerMedia::hasParcelAudio() && restore_parcel_audio && gSavedSettings.getBOOL("MediaTentativeAutoPlay")) + static LLCachedControl auto_play(gSavedSettings, "MediaTentativeAutoPlay", true); + if(gAudiop && LLViewerMedia::hasParcelAudio() && restore_parcel_audio && auto_play()) { LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLViewerMedia::getParcelAudioURL()); restore_parcel_audio = false; @@ -880,7 +881,8 @@ void LLViewerMedia::updateMedia(void *dummy_arg) } } - if(gSavedSettings.getBOOL("MediaPerformanceManagerDebug")) + static LLCachedControl perf_debug(gSavedSettings, "MediaPerformanceManagerDebug", false); + if(perf_debug()) { // Give impls the same ordering as the priority list // they're already in the right order for this. -- cgit v1.2.3