From 006e15495515e6e4c233412a4deed0f34e7b0f12 Mon Sep 17 00:00:00 2001
From: "Matthew Breindel (Falcon)" <falcon@lindenlab.com>
Date: Fri, 26 Mar 2010 18:23:05 -0700
Subject: [PATCH] DEV-47845 Fix to work with TCP/LLSD message. This checkin is
 experimental, so if it breaks a build, just revert to the previous changeset.

---
 etc/message.xml                               |  7 ++
 indra/newview/llpanelobject.cpp               | 77 +++++++++++++++----
 indra/newview/llpanelobject.h                 | 44 +++++++----
 indra/newview/llselectmgr.cpp                 | 23 +++++-
 indra/newview/llselectmgr.h                   |  1 +
 indra/newview/llviewerobject.cpp              | 60 +++++++++++++++
 indra/newview/llviewerobject.h                |  6 ++
 .../skins/default/xui/en/floater_tools.xml    | 33 ++++++++
 scripts/messages/message_template.msg         |  4 +
 9 files changed, 223 insertions(+), 32 deletions(-)

diff --git a/etc/message.xml b/etc/message.xml
index c17ae3656d0..7283d903b9a 100644
--- a/etc/message.xml
+++ b/etc/message.xml
@@ -572,6 +572,13 @@
 					<boolean>false</boolean>
 				</map>
 
+				<key>ObjectPhysicsProperties</key>
+				<map>
+					<key>flavor</key>
+					<string>llsd</string>
+					<key>trusted-sender</key>
+					<boolean>true</boolean>
+				</map>
 
 		  </map>
   	  	<key>capBans</key>
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index bc00d755339..991e97b767e 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -2,25 +2,31 @@
  * @file llpanelobject.cpp
  * @brief Object editing (position, scale, etc.) in the tools floater
  *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, 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.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * 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.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * 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
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -131,6 +137,10 @@ BOOL	LLPanelObject::postBuild()
 	// Phantom checkbox
 	mCheckPhantom = getChild<LLCheckBoxCtrl>("Phantom Checkbox Ctrl");
 	childSetCommitCallback("Phantom Checkbox Ctrl",onCommitPhantom,this);
+
+	// PhysicsRep combobox
+	mComboPhysicsRep = getChild<LLComboBox>("Physics Rep Combo Ctrl");
+	childSetCommitCallback("Physics Rep Combo Ctrl", onCommitPhysicsRep,this);
 	
 	// Position
 	mLabelPosition = getChild<LLTextBox>("label position");
@@ -166,6 +176,7 @@ BOOL	LLPanelObject::postBuild()
 	//--------------------------------------------------------
 		
 	// material type popup
+	mLabelMaterial = getChild<LLTextBox>("label material");
 	mComboMaterial = getChild<LLComboBox>("material");
 	childSetCommitCallback("material",onCommitMaterial,this);
 	mComboMaterial->removeall();
@@ -182,6 +193,7 @@ BOOL	LLPanelObject::postBuild()
 	mComboMaterialItemCount = mComboMaterial->getItemCount();
 
 	// Base Type
+	mLabelBaseType = getChild<LLTextBox>("label basetype");
 	mComboBaseType = getChild<LLComboBox>("comboBaseType");
 	childSetCommitCallback("comboBaseType",onCommitParametric,this);
 
@@ -312,6 +324,7 @@ LLPanelObject::LLPanelObject()
 	mIsPhysical(FALSE),
 	mIsTemporary(FALSE),
 	mIsPhantom(FALSE),
+	mPhysicsRep(0),
 	mCastShadows(TRUE),
 	mSelectedType(MI_BOX),
 	mSculptTextureRevert(LLUUID::null),
@@ -519,6 +532,10 @@ void LLPanelObject::getState( )
 	mCheckPhantom->set( mIsPhantom );
 	mCheckPhantom->setEnabled( roots_selected>0 && editable && !is_flexible );
 
+	mPhysicsRep = objectp->getPhysicsRep();
+	mComboPhysicsRep->setCurrentByIndex(mPhysicsRep);
+	mComboPhysicsRep->setEnabled(editable);
+
 #if 0 // 1.9.2
 	mCastShadows = root_objectp->flagCastShadows();
 	mCheckCastShadows->set( mCastShadows );
@@ -540,6 +557,7 @@ void LLPanelObject::getState( )
 	if (editable && single_volume && material_same)
 	{
 		mComboMaterial->setEnabled( TRUE );
+		mLabelMaterial->setEnabled( TRUE );
 		if (material_code == LL_MCODE_LIGHT)
 		{
 			if (mComboMaterial->getItemCount() == mComboMaterialItemCount)
@@ -561,6 +579,7 @@ void LLPanelObject::getState( )
 	else
 	{
 		mComboMaterial->setEnabled( FALSE );
+		mLabelMaterial->setEnabled( FALSE );	
 	}
 	//----------------------------------------------------------------------------
 
@@ -969,6 +988,7 @@ void LLPanelObject::getState( )
 	}
 
 	// Update field enablement
+	mLabelBaseType	->setEnabled( enabled );
 	mComboBaseType	->setEnabled( enabled );
 
 	mLabelCut		->setEnabled( enabled );
@@ -1221,6 +1241,22 @@ void LLPanelObject::sendIsPhantom()
 	}
 }
 
+void LLPanelObject::sendPhysicsRep()
+{
+	U8 value = (U8)mComboPhysicsRep->getCurrentIndex();
+	if (mPhysicsRep != value)
+	{
+		LLSelectMgr::getInstance()->selectionUpdatePhysicsRep(value);
+		mPhysicsRep = value;
+		
+		llinfos << "update physicsrep sent" << llendl;
+	}
+	else
+	{
+		llinfos << "update physicstep not changed" << llendl;
+	}
+}
+
 void LLPanelObject::sendCastShadows()
 {
 	BOOL value = mCheckCastShadows->get();
@@ -1894,15 +1930,19 @@ void LLPanelObject::clearCtrls()
 	mCheckTemporary	->setEnabled( FALSE );
 	mCheckPhantom	->set(FALSE);
 	mCheckPhantom	->setEnabled( FALSE );
+	mComboPhysicsRep->setCurrentByIndex(0);
+	mComboPhysicsRep->setEnabled(FALSE);
 #if 0 // 1.9.2
 	mCheckCastShadows->set(FALSE);
 	mCheckCastShadows->setEnabled( FALSE );
 #endif
 	mComboMaterial	->setEnabled( FALSE );
+	mLabelMaterial	->setEnabled( FALSE );
 	// Disable text labels
 	mLabelPosition	->setEnabled( FALSE );
 	mLabelSize		->setEnabled( FALSE );
 	mLabelRotation	->setEnabled( FALSE );
+	mLabelBaseType	->setEnabled( FALSE );
 	mLabelCut		->setEnabled( FALSE );
 	mLabelHollow	->setEnabled( FALSE );
 	mLabelHoleType	->setEnabled( FALSE );
@@ -1986,6 +2026,13 @@ void LLPanelObject::onCommitPhantom( LLUICtrl* ctrl, void* userdata )
 	self->sendIsPhantom();
 }
 
+// static
+void LLPanelObject::onCommitPhysicsRep(LLUICtrl* ctrl, void* userdata )
+{
+	LLPanelObject* self = (LLPanelObject*) userdata;
+	self->sendPhysicsRep();
+}
+
 // static
 void LLPanelObject::onCommitCastShadows( LLUICtrl* ctrl, void* userdata )
 {
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index e07bf007ec1..fbc09021415 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -2,25 +2,31 @@
  * @file llpanelobject.h
  * @brief Object editing (position, scale, etc.) in the tools floater
  *
- * $LicenseInfo:firstyear=2004&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * $LicenseInfo:firstyear=2004&license=viewergpl$
+ * 
+ * Copyright (c) 2004-2009, 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.
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  * 
- * 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.
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  * 
- * 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
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
  * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
  * $/LicenseInfo$
  */
 
@@ -65,6 +71,7 @@ class LLPanelObject : public LLPanel
 	static void 	onCommitPhysics(		LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitTemporary(		LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitPhantom(		LLUICtrl* ctrl, void* userdata);
+	static void     onCommitPhysicsRep(     LLUICtrl* ctrl, void* userdata);
 	static void 	onCommitCastShadows(	LLUICtrl* ctrl, void* userdata);
 
 	static void 	onCommitParametric(LLUICtrl* ctrl, void* userdata);
@@ -87,6 +94,7 @@ class LLPanelObject : public LLPanel
 	void			sendIsPhysical();
 	void			sendIsTemporary();
 	void			sendIsPhantom();
+	void            sendPhysicsRep();
 	void			sendCastShadows();
 	void            sendSculpt();
 	
@@ -95,9 +103,11 @@ class LLPanelObject : public LLPanel
 protected:
 	S32				mComboMaterialItemCount;
 
+	LLTextBox*		mLabelMaterial;
 	LLComboBox*		mComboMaterial;
 	
 	// Per-object options
+	LLTextBox*		mLabelBaseType;
 	LLComboBox*		mComboBaseType;
 
 	LLTextBox*		mLabelCut;
@@ -157,8 +167,9 @@ class LLPanelObject : public LLPanel
 	LLCheckBoxCtrl	*mCheckPhysics;
 	LLCheckBoxCtrl	*mCheckTemporary;
 	LLCheckBoxCtrl	*mCheckPhantom;
+	LLComboBox      *mComboPhysicsRep;
 	LLCheckBoxCtrl	*mCheckCastShadows;
-
+	
 	LLTextureCtrl   *mCtrlSculptTexture;
 	LLTextBox       *mLabelSculptType;
 	LLComboBox      *mCtrlSculptType;
@@ -169,6 +180,7 @@ class LLPanelObject : public LLPanel
 	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              mPhysicsRep;			// to avoid sending "physics rep spec" 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 d03a492cd10..d15017e0a19 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -3931,6 +3931,28 @@ void LLSelectMgr::selectionUpdateCastShadows(BOOL cast_shadows)
 	getSelection()->applyToObjects(&func);	
 }
 
+struct LLSelectMgrApplyPhysicsRep : public LLSelectedObjectFunctor
+{
+	LLSelectMgrApplyPhysicsRep(U8 value) : mValue(value) {}
+	U8 mValue;
+	virtual bool apply(LLViewerObject* object)
+	{
+		if ( object->permModify() ) 	// preemptive permissions check
+		{
+			object->setPhysicsRep( mValue );
+			object->updateFlags();
+		}
+		return true;
+	}
+};
+
+
+void LLSelectMgr::selectionUpdatePhysicsRep(U8 rep)
+{
+	llwarns << "physics rep ->" << (U32)rep << llendl;
+	LLSelectMgrApplyPhysicsRep func(rep);
+	getSelection()->applyToObjects(&func);	
+}
 
 //----------------------------------------------------------------------
 // Helpful packing functions for sendObjectMessage()
@@ -4620,7 +4642,6 @@ void LLSelectMgr::processForceObjectSelect(LLMessageSystem* msg, void**)
 	LLSelectMgr::getInstance()->highlightObjectAndFamily(objects);
 }
 
-
 extern LLGLdouble	gGLModelView[16];
 
 void LLSelectMgr::updateSilhouettes()
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index d315f40ff3b..27e0c5dfa9d 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -483,6 +483,7 @@ class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
 	void selectionUpdatePhysics(BOOL use_physics);
 	void selectionUpdateTemporary(BOOL is_temporary);
 	void selectionUpdatePhantom(BOOL is_ghost);
+	void selectionUpdatePhysicsRep(U8 rep);
 	void selectionUpdateCastShadows(BOOL cast_shadows);
 	void selectionDump();
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index bb7933c10e8..f18fee3edec 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -199,6 +199,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
 	mGLName(0),
 	mbCanSelect(TRUE),
 	mFlags(0),
+	mPhysicsRep(0),
 	mDrawable(),
 	mCreateSelected(FALSE),
 	mRenderMedia(FALSE),
@@ -4961,7 +4962,14 @@ void LLViewerObject::updateFlags()
 	gMessageSystem->addBOOL("IsTemporary", flagTemporaryOnRez() );
 	gMessageSystem->addBOOL("IsPhantom", flagPhantom() );
 	gMessageSystem->addBOOL("CastsShadows", flagCastShadows() );
+	gMessageSystem->nextBlock("ExtraPhysics");
+	gMessageSystem->addU8("PhysicsRep", getPhysicsRep() );
 	gMessageSystem->sendReliable( regionp->getHost() );
+
+	if (getPhysicsRep() != 0)
+	{
+		llwarns << "sent non default physics rep" << llendl;
+	}
 }
 
 BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
@@ -4993,6 +5001,12 @@ BOOL LLViewerObject::setFlags(U32 flags, BOOL state)
 	return setit;
 }
 
+void LLViewerObject::setPhysicsRep(U8 rep)
+{
+	mPhysicsRep = rep;
+	updateFlags();
+}
+
 void LLViewerObject::applyAngularVelocity(F32 dt)
 {
 	//do target omega here
@@ -5203,4 +5217,50 @@ void LLViewerObject::resetChildrenPosition(const LLVector3& offset, BOOL simplif
 
 	return ;
 }
+#include "../llcommon/llsdserialize.h"
+class ObjectPhysicsProperties : public LLHTTPNode
+{
+public:
+	virtual void post(
+		ResponsePtr responder,
+		const LLSD& context,
+		const LLSD& input) const
+	{
+		LLSD objectData = input["body"]["ObjectData"];
+		S32 numEntries = objectData.size();
+		
+		for ( S32 i = 0; i < numEntries; i++ )
+		{
+			U32 localID = objectData[i]["LocalID"].asInteger();
+
+			std::ostringstream string;
+			LLSDSerialize::serialize( input, string, LLSDSerialize::LLSD_XML, LLSDFormatter::OPTIONS_PRETTY);
+			llinfos << string.str() << llendl;
+
+			// Iterate through nodes at end, since it can be on both the regular AND hover list
+			struct f : public LLSelectedNodeFunctor
+			{
+				U32 mID;
+				f(const U32& id) : mID(id) {}
+				virtual bool apply(LLSelectNode* node)
+				{
+					return (node->getObject() && node->getObject()->mLocalID == mID );
+				}
+			} func(localID);
+
+			LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func);
+
+			U8 physicsRepSpec = (U8)objectData[i]["PhysicsRepSpec"].asInteger();
+
+			if (node)
+			{
+				node->getObject()->setPhysicsRep(physicsRepSpec);
+			}	
+		}
+		
+	};
+};
+
+LLHTTPRegistration<ObjectPhysicsProperties>
+	gHTTPRegistrationObjectPhysicsProperties("/message/ObjectPhysicsProperties");
 
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index be83fb7ef8a..49709d643a7 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -459,6 +459,8 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	inline BOOL		flagCameraDecoupled() const		{ return ((mFlags & FLAGS_CAMERA_DECOUPLED) != 0); }
 	inline BOOL		flagObjectMove() const			{ return ((mFlags & FLAGS_OBJECT_MOVE) != 0); }
 
+	inline U8       getPhysicsRep() const           { return mPhysicsRep; }
+	
 	bool getIncludeInSearch() const;
 	void setIncludeInSearch(bool include_in_search);
 
@@ -474,6 +476,7 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 
 	void updateFlags();
 	BOOL setFlags(U32 flag, BOOL state);
+	void setPhysicsRep(U8 rep);
 	
 	virtual void dump() const;
 	static U32		getNumZombieObjects()			{ return sNumZombieObjects; }
@@ -553,6 +556,9 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
 	// Grabbed from UPDATE_FLAGS
 	U32				mFlags;
 
+	// Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties
+	U8              mPhysicsRep;
+
 	// 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 cc9e72cfb58..3bb8e9c0554 100644
--- a/indra/newview/skins/default/xui/en/floater_tools.xml
+++ b/indra/newview/skins/default/xui/en/floater_tools.xml
@@ -1418,6 +1418,39 @@ even though the user gets a free copy.
              text_enabled_color="1 1 1 1"
              top_pad="3"
              width="87" />
+            <text
+             type="string"
+             length="1"
+             follows="left|top"
+             height="10"
+             layout="topleft"
+             left_delta="0"
+             name="label physicsrep"
+             top_pad="10"
+             width="121">
+                Physics Rep:
+            </text>
+			<combo_box
+			   height="23"
+			   layout="topleft"
+			   follows="left|top"
+			   name="Physics Rep Combo Ctrl"
+			   tool_tip="Choose the physics representation"
+			   left_pad="0"
+			   width="108">
+			  <combo_box.item
+				 label="Default"
+				 name="Default"
+				 value="Default" />
+			  <combo_box.item
+				 label="No Shape"
+				 name="No Shape"
+				 value="No Shape" />
+			  <combo_box.item
+				 label="Convex Hull"
+				 name="Convex Hull"
+				 value="Convex Hull" />
+			</combo_box>
 
  <!--           <text
              type="string"
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index d4f791c202b..7813bfba833 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -2061,6 +2061,10 @@ version 2.0
 		{	IsPhantom		BOOL	}
 		{	CastsShadows	BOOL	}
 	}
+    {
+		ExtraPhysics        Variable
+		{   PhysicsRep      U8      }
+	}
 }
 
 
-- 
GitLab