summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelvolume.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpanelvolume.cpp')
-rw-r--r--indra/newview/llpanelvolume.cpp134
1 files changed, 134 insertions, 0 deletions
diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp
index 065c4d0b92..c443814c89 100644
--- a/indra/newview/llpanelvolume.cpp
+++ b/indra/newview/llpanelvolume.cpp
@@ -71,6 +71,11 @@
#include "lldrawpool.h"
#include "lluictrlfactory.h"
+// For mesh physics
+#include "llagent.h"
+#include "llviewercontrol.h"
+#include "llmeshrepository.h"
+
// "Features" Tab
BOOL LLPanelVolume::postBuild()
@@ -129,6 +134,29 @@ BOOL LLPanelVolume::postBuild()
getChild<LLUICtrl>("Light Ambiance")->setValidateBeforeCommit( precommitValidate);
}
+ // PHYSICS Parameters
+ {
+ // PhysicsShapeType combobox
+ mComboPhysicsShapeType = getChild<LLComboBox>("Physics Shape Type Combo Ctrl");
+ mComboPhysicsShapeType->setCommitCallback(boost::bind(&LLPanelVolume::sendPhysicsShapeType, this, _1, mComboPhysicsShapeType));
+
+ // PhysicsGravity
+ mSpinPhysicsGravity = getChild<LLSpinCtrl>("Physics Gravity");
+ mSpinPhysicsGravity->setCommitCallback(boost::bind(&LLPanelVolume::sendPhysicsGravity, this, _1, mSpinPhysicsGravity));
+
+ // PhysicsFriction
+ mSpinPhysicsFriction = getChild<LLSpinCtrl>("Physics Friction");
+ mSpinPhysicsFriction->setCommitCallback(boost::bind(&LLPanelVolume::sendPhysicsFriction, this, _1, mSpinPhysicsFriction));
+
+ // PhysicsDensity
+ mSpinPhysicsDensity = getChild<LLSpinCtrl>("Physics Density");
+ mSpinPhysicsDensity->setCommitCallback(boost::bind(&LLPanelVolume::sendPhysicsDensity, this, _1, mSpinPhysicsDensity));
+
+ // PhysicsRestitution
+ mSpinPhysicsRestitution = getChild<LLSpinCtrl>("Physics Restitution");
+ mSpinPhysicsRestitution->setCommitCallback(boost::bind(&LLPanelVolume::sendPhysicsRestitution, this, _1, mSpinPhysicsRestitution));
+ }
+
// Start with everyone disabled
clearCtrls();
@@ -351,6 +379,54 @@ void LLPanelVolume::getState( )
getChildView("FlexForceZ")->setEnabled(false);
}
+ // Physics properties
+
+ mSpinPhysicsGravity->set(objectp->getPhysicsGravity());
+ mSpinPhysicsGravity->setEnabled(editable);
+
+ mSpinPhysicsFriction->set(objectp->getPhysicsFriction());
+ mSpinPhysicsFriction->setEnabled(editable);
+
+ mSpinPhysicsDensity->set(objectp->getPhysicsDensity());
+ mSpinPhysicsDensity->setEnabled(editable);
+
+ mSpinPhysicsRestitution->set(objectp->getPhysicsRestitution());
+ mSpinPhysicsRestitution->setEnabled(editable);
+
+ // update the physics shape combo to include allowed physics shapes
+ mComboPhysicsShapeType->removeall();
+ mComboPhysicsShapeType->add(getString("None"), LLSD(1));
+
+ BOOL isMesh = FALSE;
+ LLSculptParams *sculpt_params = (LLSculptParams *)objectp->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
+ if (sculpt_params)
+ {
+ U8 sculpt_type = sculpt_params->getSculptType();
+ U8 sculpt_stitching = sculpt_type & LL_SCULPT_TYPE_MASK;
+ isMesh = (sculpt_stitching == LL_SCULPT_TYPE_MESH);
+ }
+
+ 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));
+ }
+ }
+ else
+ {
+ // simple prims always allow physics shape prim
+ mComboPhysicsShapeType->add(getString("Prim"), LLSD(0));
+ }
+
+ mComboPhysicsShapeType->add(getString("Convex Hull"), LLSD(2));
+ mComboPhysicsShapeType->setValue(LLSD(objectp->getPhysicsShapeType()));
+ mComboPhysicsShapeType->setEnabled(editable);
+
mObject = objectp;
mRootObject = root_objectp;
}
@@ -384,6 +460,17 @@ void LLPanelVolume::refresh()
getChildView("Light Ambiance")->setVisible( visible);
getChildView("light texture control")->setVisible( visible);
+ bool enable_mesh = gSavedSettings.getBOOL("MeshEnabled") &&
+ gAgent.getRegion() &&
+ !gAgent.getRegion()->getCapability("GetMesh").empty();
+
+ getChildView("label physicsshapetype")->setVisible(enable_mesh);
+ getChildView("Physics Shape Type Combo Ctrl")->setVisible(enable_mesh);
+ getChildView("Physics Gravity")->setVisible(enable_mesh);
+ getChildView("Physics Material Override")->setVisible(enable_mesh);
+ getChildView("Physics Friction")->setVisible(enable_mesh);
+ getChildView("Physics Density")->setVisible(enable_mesh);
+ getChildView("Physics Restitution")->setVisible(enable_mesh);
}
@@ -430,6 +517,11 @@ void LLPanelVolume::clearCtrls()
getChildView("FlexForceX")->setEnabled(false);
getChildView("FlexForceY")->setEnabled(false);
getChildView("FlexForceZ")->setEnabled(false);
+
+ mSpinPhysicsGravity->setEnabled(FALSE);
+ mSpinPhysicsFriction->setEnabled(FALSE);
+ mSpinPhysicsDensity->setEnabled(FALSE);
+ mSpinPhysicsRestitution->setEnabled(FALSE);
}
//
@@ -482,6 +574,48 @@ void LLPanelVolume::sendIsFlexible()
llinfos << "update flexible sent" << llendl;
}
+void LLPanelVolume::sendPhysicsShapeType(LLUICtrl* ctrl, void* userdata)
+{
+ U8 type = ctrl->getValue().asInteger();
+ LLSelectMgr::getInstance()->selectionSetPhysicsType(type);
+
+ refreshCost();
+}
+
+void LLPanelVolume::sendPhysicsGravity(LLUICtrl* ctrl, void* userdata)
+{
+ F32 val = ctrl->getValue().asReal();
+ LLSelectMgr::getInstance()->selectionSetGravity(val);
+}
+
+void LLPanelVolume::sendPhysicsFriction(LLUICtrl* ctrl, void* userdata)
+{
+ F32 val = ctrl->getValue().asReal();
+ LLSelectMgr::getInstance()->selectionSetFriction(val);
+}
+
+void LLPanelVolume::sendPhysicsRestitution(LLUICtrl* ctrl, void* userdata)
+{
+ F32 val = ctrl->getValue().asReal();
+ LLSelectMgr::getInstance()->selectionSetRestitution(val);
+}
+
+void LLPanelVolume::sendPhysicsDensity(LLUICtrl* ctrl, void* userdata)
+{
+ F32 val = ctrl->getValue().asReal();
+ LLSelectMgr::getInstance()->selectionSetDensity(val);
+}
+
+void LLPanelVolume::refreshCost()
+{
+ LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
+
+ if (obj)
+ {
+ obj->getObjectCost();
+ }
+}
+
void LLPanelVolume::onLightCancelColor(const LLSD& data)
{
LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");