Subject: added new physics parameters to prims

From: "Karl Stiefvater (qarl)" <[email-masked]>
Date: Thu, 1 Jul 2010 17:18:55 -0500

---
 indra/newview/llpanelobject.cpp                    | 76 +++++++++++++++------
 indra/newview/llpanelobject.h                      | 15 +++--
 indra/newview/llselectmgr.cpp                      | 33 +++++++--
 indra/newview/llselectmgr.h                        |  3 +-
 indra/newview/llviewerobject.cpp                   | 64 +++++++++++++++---
 indra/newview/llviewerobject.h                     | 16 +++++
 .../newview/skins/default/xui/en/floater_tools.xml | 78 +++++++++++++++++++++-
 indra/newview/viewer_manifest.py                   |  4 ++
 scripts/messages/message_template.msg              |  5 ++
 9 files changed, 249 insertions(+), 45 deletions(-)

(limited to 'scripts/messages/message_template.msg')

diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 77f3984ecb..e972e17894 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -140,7 +140,28 @@ BOOL	LLPanelObject::postBuild()
 
 	// PhysicsShapeType combobox
 	mComboPhysicsShapeType = getChild<LLComboBox>("Physics Shape Type Combo Ctrl");
-	childSetCommitCallback("Physics Shape Type Combo Ctrl", onCommitPhysicsShapeType,this);
+	childSetCommitCallback("Physics Shape Type Combo Ctrl", onCommitPhysicsParam, this);
+
+	// PhysicsGravity
+	mSpinPhysicsGravity = getChild<LLSpinCtrl>("Physics Gravity");
+	childSetCommitCallback("Physics Gravity", onCommitPhysicsParam, this);
+
+	// PhysicsMaterialOverride
+	mCheckPhysicsMaterialOverride = getChild<LLCheckBoxCtrl>("Physics Material Override");
+	childSetCommitCallback("Physics Material Override", onCommitPhysicsParam, this);
+
+	// PhysicsFriction
+	mSpinPhysicsFriction = getChild<LLSpinCtrl>("Physics Friction");
+	childSetCommitCallback("Physics Friction", onCommitPhysicsParam, this);
+	
+	// PhysicsDensity
+	mSpinPhysicsDensity = getChild<LLSpinCtrl>("Physics Density");
+	childSetCommitCallback("Physics Density", onCommitPhysicsParam, this);
+
+	// PhysicsRestitution
+	mSpinPhysicsRestitution = getChild<LLSpinCtrl>("Physics Restitution");
+	childSetCommitCallback("Physics Restitution", onCommitPhysicsParam, this);
+
 	
 	// Position
 	mLabelPosition = getChild<LLTextBox>("label position");
@@ -324,7 +345,6 @@ LLPanelObject::LLPanelObject()
 	mIsPhysical(FALSE),
 	mIsTemporary(FALSE),
 	mIsPhantom(FALSE),
-	mPhysicsShapeType(0),
 	mCastShadows(TRUE),
 	mSelectedType(MI_BOX),
 	mSculptTextureRevert(LLUUID::null),
@@ -532,9 +552,23 @@ void LLPanelObject::getState( )
 	mCheckPhantom->set( mIsPhantom );
 	mCheckPhantom->setEnabled( roots_selected>0 && editable && !is_flexible );
 
-	mPhysicsShapeType = objectp->getPhysicsShapeType();
-	mComboPhysicsShapeType->setCurrentByIndex(mPhysicsShapeType);
+	mComboPhysicsShapeType->setCurrentByIndex(objectp->getPhysicsShapeType());
 	mComboPhysicsShapeType->setEnabled(editable);
+	
+	mSpinPhysicsGravity->set(objectp->getPhysicsGravity());
+	mSpinPhysicsGravity->setEnabled(editable);
+
+	mCheckPhysicsMaterialOverride->set(objectp->getPhysicsMaterialOverride());
+	mCheckPhysicsMaterialOverride->setEnabled(editable);
+	
+	mSpinPhysicsFriction->set(objectp->getPhysicsFriction());
+	mSpinPhysicsFriction->setEnabled(editable);
+	
+	mSpinPhysicsDensity->set(objectp->getPhysicsDensity());
+	mSpinPhysicsDensity->setEnabled(editable);
+	
+	mSpinPhysicsRestitution->set(objectp->getPhysicsRestitution());
+	mSpinPhysicsRestitution->setEnabled(editable);
 
 #if 0 // 1.9.2
 	mCastShadows = root_objectp->flagCastShadows();
@@ -1251,20 +1285,17 @@ public:
 	U32 mID;
 };
 
-void LLPanelObject::sendPhysicsShapeType()
+void LLPanelObject::sendPhysicsParam()
 {
-	U8 value = (U8)mComboPhysicsShapeType->getCurrentIndex();
-	if (mPhysicsShapeType != value)
-	{
-		LLSelectMgr::getInstance()->selectionUpdatePhysicsShapeType(value);
-		mPhysicsShapeType = value;
-		
-		llinfos << "update physics shape type sent" << llendl;
-	}
-	else
-	{
-		llinfos << "update physics shape type not changed" << llendl;
-	}
+	U8 type = (U8)mComboPhysicsShapeType->getCurrentIndex();
+	F32 gravity = mSpinPhysicsGravity->get();
+	BOOL material_override = mCheckPhysicsMaterialOverride->get();
+	F32 friction = mSpinPhysicsFriction->get();
+	F32 density = mSpinPhysicsDensity->get();
+	F32 restitution = mSpinPhysicsRestitution->get();
+	
+	LLSelectMgr::getInstance()->selectionUpdatePhysicsParam(type, gravity, material_override,
+															friction, density, restitution);
 
 	std::string url = gAgent.getRegion()->getCapability("GetObjectCost");
 	LLSD body = LLSD::emptyArray();
@@ -1947,8 +1978,15 @@ void LLPanelObject::clearCtrls()
 	mCheckTemporary	->setEnabled( FALSE );
 	mCheckPhantom	->set(FALSE);
 	mCheckPhantom	->setEnabled( FALSE );
+	
 	mComboPhysicsShapeType->setCurrentByIndex(0);
 	mComboPhysicsShapeType->setEnabled(FALSE);
+	mSpinPhysicsGravity->setEnabled(FALSE);
+	mCheckPhysicsMaterialOverride->setEnabled(FALSE);
+	mSpinPhysicsFriction->setEnabled(FALSE);
+	mSpinPhysicsDensity->setEnabled(FALSE);
+	mSpinPhysicsRestitution->setEnabled(FALSE);
+							 
 #if 0 // 1.9.2
 	mCheckCastShadows->set(FALSE);
 	mCheckCastShadows->setEnabled( FALSE );
@@ -2044,10 +2082,10 @@ void LLPanelObject::onCommitPhantom( LLUICtrl* ctrl, void* userdata )
 }
 
 // static
-void LLPanelObject::onCommitPhysicsShapeType(LLUICtrl* ctrl, void* userdata )
+void LLPanelObject::onCommitPhysicsParam(LLUICtrl* ctrl, void* userdata )
 {
 	LLPanelObject* self = (LLPanelObject*) userdata;
-	self->sendPhysicsShapeType();
+	self->sendPhysicsParam();
 }
 
 // static
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index 7f368c38c7..2c62002ac6 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -71,7 +71,7 @@ public:
 	static void 	onCommitPhysics(			LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitTemporary(			LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitPhantom(			LLUICtrl* ctrl, void* userdata);
-	static void     onCommitPhysicsShapeType(   LLUICtrl* ctrl, void* userdata);
+	static void     onCommitPhysicsParam(       LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitCastShadows(		LLUICtrl* ctrl, void* userdata);
 
 	static void 	onCommitParametric(LLUICtrl* ctrl, void* userdata);
@@ -94,7 +94,7 @@ protected:
 	void			sendIsPhysical();
 	void			sendIsTemporary();
 	void			sendIsPhantom();
-	void            sendPhysicsShapeType();
+	void            sendPhysicsParam();
 	void			sendCastShadows();
 	void            sendSculpt();
 	
@@ -167,9 +167,15 @@ protected:
 	LLCheckBoxCtrl	*mCheckPhysics;
 	LLCheckBoxCtrl	*mCheckTemporary;
 	LLCheckBoxCtrl	*mCheckPhantom;
-	LLComboBox      *mComboPhysicsShapeType;
 	LLCheckBoxCtrl	*mCheckCastShadows;
-	
+
+	LLComboBox*     mComboPhysicsShapeType;
+	LLSpinCtrl*     mSpinPhysicsGravity;
+	LLCheckBoxCtrl* mCheckPhysicsMaterialOverride;
+	LLSpinCtrl*     mSpinPhysicsFriction;
+	LLSpinCtrl*     mSpinPhysicsDensity;
+	LLSpinCtrl*     mSpinPhysicsRestitution;
+
 	LLTextureCtrl   *mCtrlSculptTexture;
 	LLTextBox       *mLabelSculptType;
 	LLComboBox      *mCtrlSculptType;
@@ -180,7 +186,6 @@ protected:
 	BOOL			mIsPhysical;			// to avoid sending "physical" when not changed
 	BOOL			mIsTemporary;			// to avoid sending "temporary" when not changed
 	BOOL			mIsPhantom;				// to avoid sending "phantom" when not changed
-	U8              mPhysicsShapeType;		// to avoid sending "physics shape type" when not changed
 	BOOL			mCastShadows;			// to avoid sending "cast shadows" when not changed
 	S32				mSelectedType;			// So we know what selected type we last were
 
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 559c802f51..8ab9910f67 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -3937,15 +3937,33 @@ void LLSelectMgr::selectionUpdateCastShadows(BOOL cast_shadows)
 	getSelection()->applyToObjects(&func);	
 }
 
-struct LLSelectMgrApplyPhysicsShapeType : public LLSelectedObjectFunctor
-{
-	LLSelectMgrApplyPhysicsShapeType(U8 value) : mValue(value) {}
-	U8 mValue;
+struct LLSelectMgrApplyPhysicsParam : public LLSelectedObjectFunctor
+{
+	LLSelectMgrApplyPhysicsParam(U8 type, F32 gravity, BOOL material_override,
+								 F32 friction, F32 density, F32 restitution) :
+		mType(type),
+		mGravity(gravity),
+		mMaterialOverride(material_override),
+		mFriction(friction),
+		mDensity(density),
+		mRestitution(restitution)
+	{}
+	U8 mType;
+	F32 mGravity;
+	BOOL mMaterialOverride;
+	F32 mFriction;
+	F32 mDensity;
+	F32 mRestitution;
 	virtual bool apply(LLViewerObject* object)
 	{
 		if ( object->permModify() ) 	// preemptive permissions check
 		{
-			object->setPhysicsShapeType( mValue );
+			object->setPhysicsShapeType( mType );
+			object->setPhysicsGravity(mGravity);
+			object->setPhysicsMaterialOverride(mMaterialOverride);
+			object->setPhysicsFriction(mFriction);
+			object->setPhysicsDensity(mDensity);
+			object->setPhysicsRestitution(mRestitution);
 			object->updateFlags();
 		}
 		return true;
@@ -3953,10 +3971,11 @@ struct LLSelectMgrApplyPhysicsShapeType : public LLSelectedObjectFunctor
 };

-void LLSelectMgr::selectionUpdatePhysicsShapeType(U8 type)
+void LLSelectMgr::selectionUpdatePhysicsParam(U8 type, F32 gravity, BOOL material_override,
+											  F32 friction, F32 density, F32 restitution)
 {
 	llwarns << "physics shape type ->" << (U32)type << llendl;
-	LLSelectMgrApplyPhysicsShapeType func(type);
+	LLSelectMgrApplyPhysicsParam func(type, gravity, material_override, friction, density, restitution);
 	getSelection()->applyToObjects(&func);	
 }
 
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 5302cfae68..e5db0b6df1 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -485,9 +485,10 @@ public:
 	void saveSelectedObjectTextures();
 
 	void selectionUpdatePhysics(BOOL use_physics);
+	void selectionUpdatePhysicsParam(U8 type, F32 gravity, BOOL material_override,
+									 F32 friction, F32 density, F32 restitution);
 	void selectionUpdateTemporary(BOOL is_temporary);
 	void selectionUpdatePhantom(BOOL is_ghost);
-	void selectionUpdatePhysicsShapeType(U8 type);
 	void selectionUpdateCastShadows(BOOL cast_shadows);
 	void selectionDump();
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 03e524268d..82147dd339 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -201,6 +201,11 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mbCanSelect(TRUE),
 	mFlags(0),
 	mPhysicsShapeType(0),
+	mPhysicsGravity(0),
+	mPhysicsMaterialOverride(FALSE),
+	mPhysicsFriction(0),
+	mPhysicsDensity(0),
+	mPhysicsRestitution(0),
 	mDrawable(),
 	mCreateSelected(FALSE),
 	mRenderMedia(FALSE),
@@ -5022,6 +5027,11 @@ void LLViewerObject::updateFlags()
 	gMessageSystem->addBOOL("CastsShadows", flagCastShadows() );
 	gMessageSystem->nextBlock("ExtraPhysics");
 	gMessageSystem->addU8("PhysicsShapeType", getPhysicsShapeType() );
+	gMessageSystem->addF32("PhysicsGravity", getPhysicsGravity() );
+	gMessageSystem->addBOOL("PhysicsMaterialOverride", getPhysicsMaterialOverride() );
+	gMessageSystem->addF32("PhysicsFriction", getPhysicsFriction() );
+	gMessageSystem->addF32("PhysicsDensity", getPhysicsDensity() );
+	gMessageSystem->addF32("PhysicsRestitution", getPhysicsRestitution() );
 	gMessageSystem->sendReliable( regionp->getHost() );
 
 	if (getPhysicsShapeType() != 0)
@@ -5062,7 +5072,31 @@ BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
 void LLViewerObject::setPhysicsShapeType(U8 type)
 {
 	mPhysicsShapeType = type;
-	updateFlags();
+}
+
+void LLViewerObject::setPhysicsGravity(F32 gravity)
+{
+	mPhysicsGravity = gravity;
+}
+
+void LLViewerObject::setPhysicsMaterialOverride(BOOL material_override)
+{
+	mPhysicsMaterialOverride = material_override;
+}
+
+void LLViewerObject::setPhysicsFriction(F32 friction)
+{
+	mPhysicsFriction = friction;
+}
+
+void LLViewerObject::setPhysicsDensity(F32 density)
+{
+	mPhysicsDensity = density;
+}
+
+void LLViewerObject::setPhysicsRestitution(F32 restitution)
+{
+	mPhysicsRestitution = restitution;
 }
 
 void LLViewerObject::applyAngularVelocity(F32 dt)
@@ -5303,13 +5337,13 @@ public:
 		const LLSD& context,
 		const LLSD& input) const
 	{
-		LLSD objectData = input["body"]["ObjectData"];
-		S32 numEntries = objectData.size();
+		LLSD object_data = input["body"]["ObjectData"];
+		S32 num_entries = object_data.size();
 		
-		for ( S32 i = 0; i < numEntries; i++ )
+		for ( S32 i = 0; i < num_entries; i++ )
 		{
-			LLSD& currObjectData = objectData[i];
-			U32 localID = currObjectData["LocalID"].asInteger();
+			LLSD& curr_object_data = object_data[i];
+			U32 local_id = curr_object_data["LocalID"].asInteger();
 
 			// Iterate through nodes at end, since it can be on both the regular AND hover list
 			struct f : public LLSelectedNodeFunctor
@@ -5320,16 +5354,26 @@ public:
 				{
 					return (node->getObject() && node->getObject()->mLocalID == mID );
 				}
-			} func(localID);
+			} func(local_id);
 
 			LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func);
 
 			if (node)
 			{
 				// The LLSD message builder doesn't know how to handle U8, so we need to send as S8 and cast
-				U8 physicsShapeType = (U8)currObjectData["PhysicsShapeType"].asInteger();
-
-				node->getObject()->setPhysicsShapeType(physicsShapeType);
+				U8 type = (U8)curr_object_data["PhysicsShapeType"].asInteger();
+				F32 gravity = (F32)curr_object_data["PhysicsGravity"].asReal();
+				BOOL material_override = curr_object_data["PhysicsMaterialOverride"].asBoolean();
+				F32 friction = (F32)curr_object_data["PhysicsFriction"].asReal();
+				F32 density = (F32)curr_object_data["PhysicsDensity"].asReal();
+				F32 restitution = (F32)curr_object_data["PhysicsRestitution"].asReal();
+
+				node->getObject()->setPhysicsShapeType(type);
+				node->getObject()->setPhysicsGravity(gravity);
+				node->getObject()->setPhysicsMaterialOverride(material_override);
+				node->getObject()->setPhysicsFriction(friction);
+				node->getObject()->setPhysicsDensity(density);
+				node->getObject()->setPhysicsRestitution(restitution);
 			}	
 		}
 		
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 092d8fdc82..90c9ba0f7a 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -468,6 +468,11 @@ public:
 	inline BOOL		flagObjectMove() const			{ return ((mFlags & FLAGS_OBJECT_MOVE) != 0); }
 
 	inline U8       getPhysicsShapeType() const     { return mPhysicsShapeType; }
+	inline F32      getPhysicsGravity() const       { return mPhysicsGravity; }
+	inline BOOL     getPhysicsMaterialOverride() const { return mPhysicsMaterialOverride; }
+	inline F32      getPhysicsFriction() const      { return mPhysicsFriction; }
+	inline F32      getPhysicsDensity() const       { return mPhysicsDensity; }
+	inline F32      getPhysicsRestitution() const   { return mPhysicsRestitution; }
 	
 	bool getIncludeInSearch() const;
 	void setIncludeInSearch(bool include_in_search);
@@ -485,6 +490,11 @@ public:
 	void updateFlags();
 	BOOL setFlags(U32 flag, BOOL state);
 	void setPhysicsShapeType(U8 type);
+	void setPhysicsGravity(F32 gravity);
+	void setPhysicsMaterialOverride(BOOL material_override);
+	void setPhysicsFriction(F32 friction);
+	void setPhysicsDensity(F32 density);
+	void setPhysicsRestitution(F32 restitution);
 	
 	virtual void dump() const;
 	static U32		getNumZombieObjects()			{ return sNumZombieObjects; }
@@ -566,6 +576,12 @@ public:
 
 	// Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties
 	U8              mPhysicsShapeType;
+	F32             mPhysicsGravity;
+	BOOL            mPhysicsMaterialOverride;
+	F32             mPhysicsFriction;
+	F32             mPhysicsDensity;
+	F32             mPhysicsRestitution;
+	
 
 	// Pipeline classes
 	LLPointer<LLDrawable> mDrawable;
diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml
index b83ac3282b..808ba22dbb 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -2,7 +2,7 @@
 <floater
  legacy_header_height="18"
  follows="left|top|right"
- height="580"
+ height="780"
  layout="topleft"
  bg_opaque_image="Window_NoTitle_Foreground"
  bg_alpha_image="Window_NoTitle_Background"
@@ -751,7 +751,7 @@
     </text>
     <tab_container
      follows="left|top"
-     height="410"
+     height="610"
      halign="center"
      left="0"
      name="Object Info Tabs"
@@ -1217,7 +1217,7 @@ even though the user gets a free copy.
       <panel
          border="false"
          follows="all"
-         height="367"
+         height="567"
          label="Object"
          layout="topleft"
          left_delta="0"
@@ -1466,6 +1466,78 @@ even though the user gets a free copy.
 				 value="Convex Hull" />
 			</combo_box>
 
+            <spinner
+             follows="left|top"
+             height="19"
+             increment="1"
+             initial_value="1"
+             label="Gravity"
+             label_width="70"
+             layout="topleft"
+             left="10"
+             min_val="-1"
+             max_val="10"
+             name="Physics Gravity"
+             top_pad="10"
+             width="128" />
+
+            <check_box
+             height="19"
+             label="Override material"
+             layout="topleft"
+             left_delta="0"
+             name="Physics Material Override"
+             tool_tip="Override Material"
+             top_pad="10"
+             width="121" />
+
+            <spinner
+             follows="left|top"
+             height="19"
+             increment="0.1"
+             initial_value="0"
+             label="Friction"
+             label_width="70"
+             layout="topleft"
+             left_delta="0"
+             max_val="255"
+             min_val="0"
+             name="Physics Friction"
+             top_pad="4"
+             width="128" />
+
+            <spinner
+             follows="left|top"
+             height="19"
+             increment="0.1"
+             initial_value="0"
+             label="Density"
+             label_width="70"
+             layout="topleft"
+             left_delta="0"
+             max_val="10"
+             min_val="0"
+             name="Physics Density"
+             top_pad="4"
+             width="128" />
+
+            <spinner
+             follows="left|top"
+             height="19"
+             increment="0.01"
+             initial_value="0"
+             label="Restitution"
+             label_width="70"
+             layout="topleft"
+             left_delta="0"
+             max_val="1"
+             min_val="0"
+             name="Physics Restitution"
+             top_pad="4"
+             width="128" />
+
+
+
  <!--           <text
              type="string"
              length="1"
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 06050db627..bb091731db 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -568,6 +568,10 @@ class WindowsManifest(ViewerManifest):

 class DarwinManifest(ViewerManifest):
+    def is_packaging_viewer(self):
+        # darwin requires full app bundle packaging even for debugging.
+        return True
+
     def construct(self):
         # copy over the build result (this is a no-op if run within the xcode script)
         self.path(self.args['configuration'] + "/Second Life.app", dst="")
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index 6043542877..8cfd3c5ce6 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -2064,6 +2064,11 @@ version 2.0
     {
 		ExtraPhysics        Variable
 		{   PhysicsShapeType U8     }
+		{   PhysicsGravity   F32    }
+		{   PhysicsMaterialOverride BOOL }
+		{   PhysicsFriction  F32    }
+		{   PhysicsDensity   F32    }
+		{   PhysicsRestitution F32  }
 	}
 }
 
-- 
cgit v1.3