From 1be5133116c7e63bc621a4017bedaebf557c83db Mon Sep 17 00:00:00 2001 From: Roxie Linden Date: Wed, 8 Dec 2010 21:24:02 -0800 Subject: SH-541 - Physics mesh display shows inconsistent data. The object UI was allowing the user to set 'prim' physics for meshes for which no user physics had been uploaded, or decomposed. It defaulted to convex hull in that case. The fix is to fix the UI to disallow 'prim' for meshes without physics meshes, limiting those to only convex hull and none. We will also redo the task validation to detect invalid states related to this as part of the 'redo the validation' work --- indra/newview/llmeshrepository.cpp | 6 +++ indra/newview/llmeshrepository.h | 3 +- indra/newview/llpanelobject.cpp | 47 +++++++++++++++++----- indra/newview/llspatialpartition.cpp | 2 +- .../newview/skins/default/xui/en/floater_tools.xml | 18 ++------- 5 files changed, 51 insertions(+), 25 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 1ff11f2c01..8d5ef4ae3d 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -2667,6 +2667,12 @@ void LLMeshRepository::buildHull(const LLVolumeParams& params, S32 detail) LLPrimitive::sVolumeManager->unrefVolume(volume); } +bool LLMeshRepository::hasPhysicsShape(const LLUUID& mesh_id) +{ + LLSD mesh = mThread->getMeshHeader(mesh_id); + return mesh.has("physics_shape") && mesh["physics_shape"].has("size") && (mesh["physics_shape"]["size"].asInteger() > 0); +} + const LLSD& LLMeshRepository::getMeshHeader(const LLUUID& mesh_id) { return mThread->getMeshHeader(mesh_id); diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index df00c6c7aa..8687ac750b 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -458,7 +458,8 @@ public: const LLMeshSkinInfo* getSkinInfo(const LLUUID& mesh_id); const LLMeshDecomposition* getDecomposition(const LLUUID& mesh_id); void fetchPhysicsShape(const LLUUID& mesh_id); - + bool hasPhysicsShape(const LLUUID& mesh_id); + void buildHull(const LLVolumeParams& params, S32 detail); const LLSD& getMeshHeader(const LLUUID& mesh_id); diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp index 4a1385134e..462ec2e75c 100644 --- a/indra/newview/llpanelobject.cpp +++ b/indra/newview/llpanelobject.cpp @@ -67,6 +67,7 @@ #include "pipeline.h" #include "llviewercontrol.h" #include "lluictrlfactory.h" +#include "llmeshrepository.h" //#include "llfirstuse.h" #include "lldrawpool.h" @@ -539,8 +540,6 @@ void LLPanelObject::getState( ) mCheckPhantom->set( mIsPhantom ); mCheckPhantom->setEnabled( roots_selected>0 && editable && !is_flexible ); - mComboPhysicsShapeType->setCurrentByIndex(objectp->getPhysicsShapeType()); - mComboPhysicsShapeType->setEnabled(editable); mSpinPhysicsGravity->set(objectp->getPhysicsGravity()); mSpinPhysicsGravity->setEnabled(editable); @@ -604,6 +603,7 @@ void LLPanelObject::getState( ) BOOL enabled = FALSE; BOOL hole_enabled = FALSE; F32 scale_x=1.f, scale_y=1.f; + BOOL isMesh = FALSE; if( !objectp || !objectp->getVolume() || !editable || !single_volume) { @@ -634,10 +634,9 @@ void LLPanelObject::getState( ) // Only allowed to change these parameters for objects // that you have permissions on AND are not attachments. enabled = root_objectp->permModify(); - - const LLVolumeParams &volume_params = objectp->getVolume()->getParams(); - + // Volume type + const LLVolumeParams &volume_params = objectp->getVolume()->getParams(); U8 path = volume_params.getPathParams().getCurveType(); U8 profile_and_hole = volume_params.getProfileParams().getCurveType(); U8 profile = profile_and_hole & LL_PCODE_PROFILE_MASK; @@ -868,7 +867,7 @@ void LLPanelObject::getState( ) } mSpinSkew->set( skew ); } - + // Compute control visibility, label names, and twist range. // Start with defaults. BOOL cut_visible = TRUE; @@ -1132,6 +1131,10 @@ void LLPanelObject::getState( ) mCtrlSculptInvert->setVisible(sculpt_texture_visible); + // update the physics shape combo to include allowed physics shapes + mComboPhysicsShapeType->removeall(); + mComboPhysicsShapeType->add(getString("None"), LLSD(1)); + // sculpt texture if (selected_item == MI_SCULPT) @@ -1163,6 +1166,7 @@ void LLPanelObject::getState( ) U8 sculpt_stitching = sculpt_type & LL_SCULPT_TYPE_MASK; BOOL sculpt_invert = sculpt_type & LL_SCULPT_FLAG_INVERT; BOOL sculpt_mirror = sculpt_type & LL_SCULPT_FLAG_MIRROR; + isMesh = (sculpt_stitching == LL_SCULPT_TYPE_MESH); if (mCtrlSculptType) { @@ -1179,20 +1183,43 @@ void LLPanelObject::getState( ) if (mCtrlSculptInvert) { mCtrlSculptInvert->set(sculpt_invert); - mCtrlSculptInvert->setEnabled(editable && (sculpt_stitching != LL_SCULPT_TYPE_MESH)); + mCtrlSculptInvert->setEnabled(editable && (!isMesh)); } if (mLabelSculptType) { mLabelSculptType->setEnabled(TRUE); } + } } else { - mSculptTextureRevert = LLUUID::null; + mSculptTextureRevert = LLUUID::null; } + if(isMesh && objectp) + { + const LLVolumeParams &volume_params = objectp->getVolume()->getParams(); + LLUUID mesh_id = volume_params.getSculptID(); + if(gMeshRepo.hasPhysicsShape(mesh_id)) + { + // if a mesh contains an uploaded or decomposed physics mesh, + // allow 'Prim' + mComboPhysicsShapeType->add(getString("Prim"), LLSD(0)); + } + // meshes always allow convex hull + mComboPhysicsShapeType->add(getString("Convex Hull"), LLSD(2)); + } + else + { + // simple prims always allow physics shape prim + mComboPhysicsShapeType->add(getString("Prim"), LLSD(0)); + } + + mComboPhysicsShapeType->setValue(LLSD(objectp->getPhysicsShapeType())); + mComboPhysicsShapeType->setEnabled(editable); + //---------------------------------------------------------------------------- @@ -1268,7 +1295,9 @@ public: void LLPanelObject::sendPhysicsParam() { - U8 type = (U8)mComboPhysicsShapeType->getCurrentIndex(); + LLSD physicsType = mComboPhysicsShapeType->getValue(); + + U8 type = physicsType.asInteger(); F32 gravity = mSpinPhysicsGravity->get(); F32 friction = mSpinPhysicsFriction->get(); F32 density = mSpinPhysicsDensity->get(); diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index bd6be14341..6b77209867 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2900,7 +2900,7 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume) LLVolumeParams volume_params = volume->getVolume()->getParams(); - LLPhysicsVolumeParams physics_params(volume->getVolume()->getParams(), + LLPhysicsVolumeParams physics_params(volume_params, physics_type == LLViewerObject::PHYSICS_SHAPE_CONVEX_HULL); LLPhysicsShapeBuilderUtil::PhysicsShapeSpecification physics_spec; diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index f6f74f2ebd..1f79cf310e 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -1291,6 +1291,9 @@ even though the user gets a free copy. name="Object" top="16" width="295"> + None + Prim + Convex Hull - - - - + width="108"/>