summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llpanelobject.cpp79
-rw-r--r--indra/newview/llpanelobject.h8
-rw-r--r--indra/newview/llselectmgr.cpp136
-rw-r--r--indra/newview/llselectmgr.h7
-rw-r--r--indra/newview/llviewerobject.cpp6
5 files changed, 152 insertions, 84 deletions
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 73a8fbe3aa..f1fd47f50e 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -135,23 +135,24 @@ BOOL LLPanelObject::postBuild()
// PhysicsShapeType combobox
mComboPhysicsShapeType = getChild<LLComboBox>("Physics Shape Type Combo Ctrl");
- childSetCommitCallback("Physics Shape Type Combo Ctrl", onCommitPhysicsParam, this);
-
+ mComboPhysicsShapeType->setCommitCallback(boost::bind(&LLPanelObject::sendPhysicsShapeType, this, _1, mComboPhysicsShapeType));
+
// PhysicsGravity
mSpinPhysicsGravity = getChild<LLSpinCtrl>("Physics Gravity");
- childSetCommitCallback("Physics Gravity", onCommitPhysicsParam, this);
+ mSpinPhysicsGravity->setCommitCallback(boost::bind(&LLPanelObject::sendPhysicsGravity, this, _1, mSpinPhysicsGravity));
// PhysicsFriction
mSpinPhysicsFriction = getChild<LLSpinCtrl>("Physics Friction");
- childSetCommitCallback("Physics Friction", onCommitPhysicsParam, this);
-
+ mSpinPhysicsFriction->setCommitCallback(boost::bind(&LLPanelObject::sendPhysicsFriction, this, _1, mSpinPhysicsFriction));
+
// PhysicsDensity
mSpinPhysicsDensity = getChild<LLSpinCtrl>("Physics Density");
- childSetCommitCallback("Physics Density", onCommitPhysicsParam, this);
+ mSpinPhysicsDensity->setCommitCallback(boost::bind(&LLPanelObject::sendPhysicsDensity, this, _1, mSpinPhysicsDensity));
// PhysicsRestitution
mSpinPhysicsRestitution = getChild<LLSpinCtrl>("Physics Restitution");
- childSetCommitCallback("Physics Restitution", onCommitPhysicsParam, this);
+ mSpinPhysicsRestitution->setCommitCallback(boost::bind(&LLPanelObject::sendPhysicsRestitution, this, _1, mSpinPhysicsRestitution));
+
// Position
mLabelPosition = getChild<LLTextBox>("label position");
@@ -1281,35 +1282,46 @@ void LLPanelObject::sendIsPhantom()
}
}
-#include "llsdutil.h"
-class CostResponder : public LLHTTPClient::Responder
+void LLPanelObject::sendPhysicsShapeType(LLUICtrl* ctrl, void* userdata)
{
-public:
- CostResponder(U32 id) { mID = id; }
- virtual void result(const LLSD& content) { llinfos << ll_pretty_print_sd(content) << llendl; }
+ U8 type = ctrl->getValue().asInteger();
+ LLSelectMgr::getInstance()->selectionSetPhysicsType(type);
- U32 mID;
-};
+ refreshCost();
+}
-void LLPanelObject::sendPhysicsParam()
+void LLPanelObject::sendPhysicsGravity(LLUICtrl* ctrl, void* userdata)
{
- LLSD physicsType = mComboPhysicsShapeType->getValue();
-
- U8 type = physicsType.asInteger();
- F32 gravity = mSpinPhysicsGravity->get();
- F32 friction = mSpinPhysicsFriction->get();
- F32 density = mSpinPhysicsDensity->get();
- F32 restitution = mSpinPhysicsRestitution->get();
-
- LLSelectMgr::getInstance()->selectionUpdatePhysicsParam(type, gravity, friction,
- density, restitution);
+ F32 val = ctrl->getValue().asReal();
+ LLSelectMgr::getInstance()->selectionSetGravity(val);
+}
- std::string url = gAgent.getRegion()->getCapability("GetObjectCost");
- LLSD body = LLSD::emptyArray();
-
- body.append(LLSelectMgr::getInstance()->getSelection()->getFirstObject()->getID());
+void LLPanelObject::sendPhysicsFriction(LLUICtrl* ctrl, void* userdata)
+{
+ F32 val = ctrl->getValue().asReal();
+ LLSelectMgr::getInstance()->selectionSetFriction(val);
+}
+
+void LLPanelObject::sendPhysicsRestitution(LLUICtrl* ctrl, void* userdata)
+{
+ F32 val = ctrl->getValue().asReal();
+ LLSelectMgr::getInstance()->selectionSetRestitution(val);
+}
+
+void LLPanelObject::sendPhysicsDensity(LLUICtrl* ctrl, void* userdata)
+{
+ F32 val = ctrl->getValue().asReal();
+ LLSelectMgr::getInstance()->selectionSetDensity(val);
+}
+
+void LLPanelObject::refreshCost()
+{
+ LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
- LLHTTPClient::post( url, body, new CostResponder(body[0].asInteger()) );
+ if (obj)
+ {
+ obj->getObjectCost();
+ }
}
void LLPanelObject::sendCastShadows()
@@ -2121,13 +2133,6 @@ void LLPanelObject::onCommitPhantom( LLUICtrl* ctrl, void* userdata )
}
// static
-void LLPanelObject::onCommitPhysicsParam(LLUICtrl* ctrl, void* userdata )
-{
- LLPanelObject* self = (LLPanelObject*) userdata;
- self->sendPhysicsParam();
-}
-
-// static
void LLPanelObject::onCommitCastShadows( LLUICtrl* ctrl, void* userdata )
{
LLPanelObject* self = (LLPanelObject*) userdata;
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index b43b1cc261..54bb5df8bf 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -81,6 +81,7 @@ public:
protected:
void getState();
+ void refreshCost();
void sendRotation(BOOL btn_down);
void sendScale(BOOL btn_down);
@@ -88,7 +89,12 @@ protected:
void sendIsPhysical();
void sendIsTemporary();
void sendIsPhantom();
- void sendPhysicsParam();
+ void sendPhysicsShapeType(LLUICtrl* ctrl, void* userdata);
+ void sendPhysicsGravity(LLUICtrl* ctrl, void* userdata);
+ void sendPhysicsFriction(LLUICtrl* ctrl, void* userdata);
+ void sendPhysicsRestitution(LLUICtrl* ctrl, void* userdata);
+ void sendPhysicsDensity(LLUICtrl* ctrl, void* userdata);
+
void sendCastShadows();
void sendSculpt();
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 305b629cf7..44ccbe22f7 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -1889,6 +1889,103 @@ BOOL LLSelectMgr::selectionGetGlow(F32 *glow)
return identical;
}
+
+void LLSelectMgr::selectionSetPhysicsType(U8 type)
+{
+ struct f : public LLSelectedObjectFunctor
+ {
+ U8 mType;
+ f(const U8& t) : mType(t) {}
+ virtual bool apply(LLViewerObject* object)
+ {
+ if (object->permModify())
+ {
+ object->setPhysicsShapeType(mType);
+ object->updateFlags();
+ }
+ return true;
+ }
+ } sendfunc(type);
+ getSelection()->applyToObjects(&sendfunc);
+}
+
+void LLSelectMgr::selectionSetFriction(F32 friction)
+{
+ struct f : public LLSelectedObjectFunctor
+ {
+ F32 mFriction;
+ f(const F32& friction) : mFriction(friction) {}
+ virtual bool apply(LLViewerObject* object)
+ {
+ if (object->permModify())
+ {
+ object->setPhysicsFriction(mFriction);
+ object->updateFlags();
+ }
+ return true;
+ }
+ } sendfunc(friction);
+ getSelection()->applyToObjects(&sendfunc);
+}
+
+void LLSelectMgr::selectionSetGravity(F32 gravity )
+{
+ struct f : public LLSelectedObjectFunctor
+ {
+ F32 mGravity;
+ f(const F32& gravity) : mGravity(gravity) {}
+ virtual bool apply(LLViewerObject* object)
+ {
+ if (object->permModify())
+ {
+ object->setPhysicsGravity(mGravity);
+ object->updateFlags();
+ }
+ return true;
+ }
+ } sendfunc(gravity);
+ getSelection()->applyToObjects(&sendfunc);
+}
+
+void LLSelectMgr::selectionSetDensity(F32 density )
+{
+ struct f : public LLSelectedObjectFunctor
+ {
+ F32 mDensity;
+ f(const F32& density ) : mDensity(density) {}
+ virtual bool apply(LLViewerObject* object)
+ {
+ if (object->permModify())
+ {
+ object->setPhysicsDensity(mDensity);
+ object->updateFlags();
+ }
+ return true;
+ }
+ } sendfunc(density);
+ getSelection()->applyToObjects(&sendfunc);
+}
+
+void LLSelectMgr::selectionSetRestitution(F32 restitution)
+{
+ struct f : public LLSelectedObjectFunctor
+ {
+ F32 mRestitution;
+ f(const F32& restitution ) : mRestitution(restitution) {}
+ virtual bool apply(LLViewerObject* object)
+ {
+ if (object->permModify())
+ {
+ object->setPhysicsRestitution(mRestitution);
+ object->updateFlags();
+ }
+ return true;
+ }
+ } sendfunc(restitution);
+ getSelection()->applyToObjects(&sendfunc);
+}
+
+
//-----------------------------------------------------------------------------
// selectionSetMaterial()
//-----------------------------------------------------------------------------
@@ -3936,45 +4033,6 @@ void LLSelectMgr::selectionUpdateCastShadows(BOOL cast_shadows)
getSelection()->applyToObjects(&func);
}
-struct LLSelectMgrApplyPhysicsParam : public LLSelectedObjectFunctor
-{
- LLSelectMgrApplyPhysicsParam(U8 type, F32 gravity, F32 friction,
- F32 density, F32 restitution) :
- mType(type),
- mGravity(gravity),
- mFriction(friction),
- mDensity(density),
- mRestitution(restitution)
- {}
- U8 mType;
- F32 mGravity;
- F32 mFriction;
- F32 mDensity;
- F32 mRestitution;
- virtual bool apply(LLViewerObject* object)
- {
- if ( object->permModify() ) // preemptive permissions check
- {
- object->setPhysicsShapeType( mType );
- object->setPhysicsGravity(mGravity);
- object->setPhysicsFriction(mFriction);
- object->setPhysicsDensity(mDensity);
- object->setPhysicsRestitution(mRestitution);
- object->updateFlags();
- }
- return true;
- }
-};
-
-
-void LLSelectMgr::selectionUpdatePhysicsParam(U8 type, F32 gravity, F32 friction,
- F32 density, F32 restitution)
-{
- llwarns << "physics shape type ->" << (U32)type << llendl;
- LLSelectMgrApplyPhysicsParam func(type, gravity, friction, density, restitution);
- getSelection()->applyToObjects(&func);
-}
-
//----------------------------------------------------------------------
// Helpful packing functions for sendObjectMessage()
//----------------------------------------------------------------------
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 0cf582062d..bb0afd74d0 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -489,8 +489,6 @@ public:
void saveSelectedObjectTextures();
void selectionUpdatePhysics(BOOL use_physics);
- void selectionUpdatePhysicsParam(U8 type, F32 gravity, F32 friction,
- F32 density, F32 restitution);
void selectionUpdateTemporary(BOOL is_temporary);
void selectionUpdatePhantom(BOOL is_ghost);
void selectionUpdateCastShadows(BOOL cast_shadows);
@@ -501,6 +499,11 @@ public:
bool selectionGetIncludeInSearch(bool* include_in_search_out); // true if all selected objects have same
BOOL selectionGetGlow(F32 *glow);
+ void selectionSetPhysicsType(U8 type);
+ void selectionSetGravity(F32 gravity);
+ void selectionSetFriction(F32 friction);
+ void selectionSetDensity(F32 density);
+ void selectionSetRestitution(F32 restitution);
void selectionSetMaterial(U8 material);
void selectionSetImage(const LLUUID& imageid); // could be item or asset id
void selectionSetColor(const LLColor4 &color);
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index bf550e9c70..244de7fed3 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -5306,11 +5306,6 @@ void LLViewerObject::updateFlags()
gMessageSystem->addF32("Restitution", getPhysicsRestitution() );
gMessageSystem->addF32("GravityMultiplier", getPhysicsGravity() );
gMessageSystem->sendReliable( regionp->getHost() );
-
- if (getPhysicsShapeType() != 0)
- {
- llwarns << "sent non default physics rep " << (S32) getPhysicsShapeType() << llendl;
- }
}
BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
@@ -5346,6 +5341,7 @@ void LLViewerObject::setPhysicsShapeType(U8 type)
{
mPhysicsShapeUnknown = false;
mPhysicsShapeType = type;
+ mCostStale = true;
}
void LLViewerObject::setPhysicsGravity(F32 gravity)