PageRenderTime 129ms CodeModel.GetById 2ms app.highlight 114ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/newview/llpanelvolume.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 882 lines | 676 code | 127 blank | 79 comment | 95 complexity | 8ffa7188675c1bcfce3e3acc0b84d251 MD5 | raw file
  1/** 
  2 * @file llpanelvolume.cpp
  3 * @brief Object editing (position, scale, etc.) in the tools floater
  4 *
  5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#include "llviewerprecompiledheaders.h"
 28
 29// file include
 30#include "llpanelvolume.h"
 31
 32// linden library includes
 33#include "llclickaction.h"
 34#include "lleconomy.h"
 35#include "llerror.h"
 36#include "llfontgl.h"
 37#include "llflexibleobject.h"
 38#include "llmaterialtable.h"
 39#include "llpermissionsflags.h"
 40#include "llstring.h"
 41#include "llvolume.h"
 42#include "m3math.h"
 43#include "material_codes.h"
 44
 45// project includes
 46#include "llbutton.h"
 47#include "llcheckboxctrl.h"
 48#include "llcolorswatch.h"
 49#include "lltexturectrl.h"
 50#include "llcombobox.h"
 51//#include "llfirstuse.h"
 52#include "llfocusmgr.h"
 53#include "llmanipscale.h"
 54#include "llpreviewscript.h"
 55#include "llresmgr.h"
 56#include "llselectmgr.h"
 57#include "llspinctrl.h"
 58#include "lltextbox.h"
 59#include "lltool.h"
 60#include "lltoolcomp.h"
 61#include "lltoolmgr.h"
 62#include "lltrans.h"
 63#include "llui.h"
 64#include "llviewerobject.h"
 65#include "llviewerregion.h"
 66#include "llviewerwindow.h"
 67#include "llvovolume.h"
 68#include "llworld.h"
 69#include "pipeline.h"
 70#include "llviewershadermgr.h"
 71
 72#include "lldrawpool.h"
 73#include "lluictrlfactory.h"
 74
 75// For mesh physics
 76#include "llagent.h"
 77#include "llviewercontrol.h"
 78#include "llmeshrepository.h"
 79
 80// "Features" Tab
 81
 82BOOL	LLPanelVolume::postBuild()
 83{
 84	// Flexible Objects Parameters
 85	{
 86		childSetCommitCallback("Flexible1D Checkbox Ctrl",onCommitIsFlexible,this);
 87		childSetCommitCallback("FlexNumSections",onCommitFlexible,this);
 88		getChild<LLUICtrl>("FlexNumSections")->setValidateBeforeCommit(precommitValidate);
 89		childSetCommitCallback("FlexGravity",onCommitFlexible,this);
 90		getChild<LLUICtrl>("FlexGravity")->setValidateBeforeCommit(precommitValidate);
 91		childSetCommitCallback("FlexFriction",onCommitFlexible,this);
 92		getChild<LLUICtrl>("FlexFriction")->setValidateBeforeCommit(precommitValidate);
 93		childSetCommitCallback("FlexWind",onCommitFlexible,this);
 94		getChild<LLUICtrl>("FlexWind")->setValidateBeforeCommit(precommitValidate);
 95		childSetCommitCallback("FlexTension",onCommitFlexible,this);
 96		getChild<LLUICtrl>("FlexTension")->setValidateBeforeCommit(precommitValidate);
 97		childSetCommitCallback("FlexForceX",onCommitFlexible,this);
 98		getChild<LLUICtrl>("FlexForceX")->setValidateBeforeCommit(precommitValidate);
 99		childSetCommitCallback("FlexForceY",onCommitFlexible,this);
100		getChild<LLUICtrl>("FlexForceY")->setValidateBeforeCommit(precommitValidate);
101		childSetCommitCallback("FlexForceZ",onCommitFlexible,this);
102		getChild<LLUICtrl>("FlexForceZ")->setValidateBeforeCommit(precommitValidate);
103	}
104
105	// LIGHT Parameters
106	{
107		childSetCommitCallback("Light Checkbox Ctrl",onCommitIsLight,this);
108		LLColorSwatchCtrl*	LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
109		if(LightColorSwatch){
110			LightColorSwatch->setOnCancelCallback(boost::bind(&LLPanelVolume::onLightCancelColor, this, _2));
111			LightColorSwatch->setOnSelectCallback(boost::bind(&LLPanelVolume::onLightSelectColor, this, _2));
112			childSetCommitCallback("colorswatch",onCommitLight,this);
113		}
114
115		LLTextureCtrl* LightTexPicker = getChild<LLTextureCtrl>("light texture control");
116		if (LightTexPicker)
117		{
118			LightTexPicker->setOnCancelCallback(boost::bind(&LLPanelVolume::onLightCancelTexture, this, _2));
119			LightTexPicker->setOnSelectCallback(boost::bind(&LLPanelVolume::onLightSelectTexture, this, _2));
120			childSetCommitCallback("light texture control", onCommitLight, this);
121		}
122
123		childSetCommitCallback("Light Intensity",onCommitLight,this);
124		getChild<LLUICtrl>("Light Intensity")->setValidateBeforeCommit(precommitValidate);
125		childSetCommitCallback("Light Radius",onCommitLight,this);
126		getChild<LLUICtrl>("Light Radius")->setValidateBeforeCommit(precommitValidate);
127		childSetCommitCallback("Light Falloff",onCommitLight,this);
128		getChild<LLUICtrl>("Light Falloff")->setValidateBeforeCommit(precommitValidate);
129		
130		childSetCommitCallback("Light FOV", onCommitLight, this);
131		getChild<LLUICtrl>("Light FOV")->setValidateBeforeCommit( precommitValidate);
132		childSetCommitCallback("Light Focus", onCommitLight, this);
133		getChild<LLUICtrl>("Light Focus")->setValidateBeforeCommit( precommitValidate);
134		childSetCommitCallback("Light Ambiance", onCommitLight, this);
135		getChild<LLUICtrl>("Light Ambiance")->setValidateBeforeCommit( precommitValidate);
136	}
137	
138	// PHYSICS Parameters
139	{
140		// PhysicsShapeType combobox
141		mComboPhysicsShapeType = getChild<LLComboBox>("Physics Shape Type Combo Ctrl");
142		mComboPhysicsShapeType->setCommitCallback(boost::bind(&LLPanelVolume::sendPhysicsShapeType, this, _1, mComboPhysicsShapeType));
143	
144		// PhysicsGravity
145		mSpinPhysicsGravity = getChild<LLSpinCtrl>("Physics Gravity");
146		mSpinPhysicsGravity->setCommitCallback(boost::bind(&LLPanelVolume::sendPhysicsGravity, this, _1, mSpinPhysicsGravity));
147
148		// PhysicsFriction
149		mSpinPhysicsFriction = getChild<LLSpinCtrl>("Physics Friction");
150		mSpinPhysicsFriction->setCommitCallback(boost::bind(&LLPanelVolume::sendPhysicsFriction, this, _1, mSpinPhysicsFriction));
151
152		// PhysicsDensity
153		mSpinPhysicsDensity = getChild<LLSpinCtrl>("Physics Density");
154		mSpinPhysicsDensity->setCommitCallback(boost::bind(&LLPanelVolume::sendPhysicsDensity, this, _1, mSpinPhysicsDensity));
155
156		// PhysicsRestitution
157		mSpinPhysicsRestitution = getChild<LLSpinCtrl>("Physics Restitution");
158		mSpinPhysicsRestitution->setCommitCallback(boost::bind(&LLPanelVolume::sendPhysicsRestitution, this, _1, mSpinPhysicsRestitution));
159	}
160
161	std::map<std::string, std::string> material_name_map;
162	material_name_map["Stone"]= LLTrans::getString("Stone");
163	material_name_map["Metal"]= LLTrans::getString("Metal");	
164	material_name_map["Glass"]= LLTrans::getString("Glass");	
165	material_name_map["Wood"]= LLTrans::getString("Wood");	
166	material_name_map["Flesh"]= LLTrans::getString("Flesh");
167	material_name_map["Plastic"]= LLTrans::getString("Plastic");
168	material_name_map["Rubber"]= LLTrans::getString("Rubber");	
169	material_name_map["Light"]= LLTrans::getString("Light");		
170	
171	LLMaterialTable::basic.initTableTransNames(material_name_map);
172
173	// material type popup
174	mComboMaterial = getChild<LLComboBox>("material");
175	childSetCommitCallback("material",onCommitMaterial,this);
176	mComboMaterial->removeall();
177
178	for (LLMaterialTable::info_list_t::iterator iter = LLMaterialTable::basic.mMaterialInfoList.begin();
179		 iter != LLMaterialTable::basic.mMaterialInfoList.end(); ++iter)
180	{
181		LLMaterialInfo* minfop = *iter;
182		if (minfop->mMCode != LL_MCODE_LIGHT)
183		{
184			mComboMaterial->add(minfop->mName);  
185		}
186	}
187	mComboMaterialItemCount = mComboMaterial->getItemCount();
188	
189	// Start with everyone disabled
190	clearCtrls();
191
192	return TRUE;
193}
194
195LLPanelVolume::LLPanelVolume()
196	: LLPanel(),
197	  mComboMaterialItemCount(0)
198{
199	setMouseOpaque(FALSE);
200
201}
202
203
204LLPanelVolume::~LLPanelVolume()
205{
206	// Children all cleaned up by default view destructor.
207}
208
209void LLPanelVolume::getState( )
210{
211	LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject();
212	LLViewerObject* root_objectp = objectp;
213	if(!objectp)
214	{
215		objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
216		// *FIX: shouldn't we just keep the child?
217		if (objectp)
218		{
219			LLViewerObject* parentp = objectp->getRootEdit();
220
221			if (parentp)
222			{
223				root_objectp = parentp;
224			}
225			else
226			{
227				root_objectp = objectp;
228			}
229		}
230	}
231
232	LLVOVolume *volobjp = NULL;
233	if ( objectp && (objectp->getPCode() == LL_PCODE_VOLUME))
234	{
235		volobjp = (LLVOVolume *)objectp;
236	}
237	
238	if( !objectp )
239	{
240		//forfeit focus
241		if (gFocusMgr.childHasKeyboardFocus(this))
242		{
243			gFocusMgr.setKeyboardFocus(NULL);
244		}
245
246		// Disable all text input fields
247		clearCtrls();
248
249		return;
250	}
251
252	BOOL owners_identical;
253	LLUUID owner_id;
254	std::string owner_name;
255	owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name);
256
257	// BUG? Check for all objects being editable?
258	BOOL editable = root_objectp->permModify();
259	BOOL single_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME )
260		&& LLSelectMgr::getInstance()->getSelection()->getObjectCount() == 1;
261
262	// Select Single Message
263	if (single_volume)
264	{
265		getChildView("edit_object")->setVisible(true);
266		getChildView("edit_object")->setEnabled(true);
267		getChildView("select_single")->setVisible(false);
268	}
269	else
270	{	
271		getChildView("edit_object")->setVisible(false);
272		getChildView("select_single")->setVisible(true);
273		getChildView("select_single")->setEnabled(true);
274	}
275	
276	// Light properties
277	BOOL is_light = volobjp && volobjp->getIsLight();
278	getChild<LLUICtrl>("Light Checkbox Ctrl")->setValue(is_light);
279	getChildView("Light Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp);
280	
281	if (is_light && editable && single_volume)
282	{
283		getChildView("label color")->setEnabled(true);
284		//mLabelColor		 ->setEnabled( TRUE );
285		LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
286		if(LightColorSwatch)
287		{
288			LightColorSwatch->setEnabled( TRUE );
289			LightColorSwatch->setValid( TRUE );
290			LightColorSwatch->set(volobjp->getLightBaseColor());
291		}
292
293		LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
294		if (LightTextureCtrl)
295		{
296			LightTextureCtrl->setEnabled(TRUE);
297			LightTextureCtrl->setValid(TRUE);
298			LightTextureCtrl->setImageAssetID(volobjp->getLightTextureID());
299		}
300
301		getChildView("Light Intensity")->setEnabled(true);
302		getChildView("Light Radius")->setEnabled(true);
303		getChildView("Light Falloff")->setEnabled(true);
304
305		getChildView("Light FOV")->setEnabled(true);
306		getChildView("Light Focus")->setEnabled(true);
307		getChildView("Light Ambiance")->setEnabled(true);
308		
309		getChild<LLUICtrl>("Light Intensity")->setValue(volobjp->getLightIntensity());
310		getChild<LLUICtrl>("Light Radius")->setValue(volobjp->getLightRadius());
311		getChild<LLUICtrl>("Light Falloff")->setValue(volobjp->getLightFalloff());
312
313		LLVector3 params = volobjp->getSpotLightParams();
314		getChild<LLUICtrl>("Light FOV")->setValue(params.mV[0]);
315		getChild<LLUICtrl>("Light Focus")->setValue(params.mV[1]);
316		getChild<LLUICtrl>("Light Ambiance")->setValue(params.mV[2]);
317
318		mLightSavedColor = volobjp->getLightColor();
319	}
320	else
321	{
322		getChild<LLSpinCtrl>("Light Intensity", true)->clear();
323		getChild<LLSpinCtrl>("Light Radius", true)->clear();
324		getChild<LLSpinCtrl>("Light Falloff", true)->clear();
325
326		getChildView("label color")->setEnabled(false);	
327		LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
328		if(LightColorSwatch)
329		{
330			LightColorSwatch->setEnabled( FALSE );
331			LightColorSwatch->setValid( FALSE );
332		}
333		LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
334		if (LightTextureCtrl)
335		{
336			LightTextureCtrl->setEnabled(FALSE);
337			LightTextureCtrl->setValid(FALSE);
338		}
339
340		getChildView("Light Intensity")->setEnabled(false);
341		getChildView("Light Radius")->setEnabled(false);
342		getChildView("Light Falloff")->setEnabled(false);
343
344		getChildView("Light FOV")->setEnabled(false);
345		getChildView("Light Focus")->setEnabled(false);
346		getChildView("Light Ambiance")->setEnabled(false);
347	}
348	
349	// Flexible properties
350	BOOL is_flexible = volobjp && volobjp->isFlexible();
351	getChild<LLUICtrl>("Flexible1D Checkbox Ctrl")->setValue(is_flexible);
352	if (is_flexible || (volobjp && volobjp->canBeFlexible()))
353	{
354		getChildView("Flexible1D Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp && !volobjp->isMesh());
355	}
356	else
357	{
358		getChildView("Flexible1D Checkbox Ctrl")->setEnabled(false);
359	}
360	if (is_flexible && editable && single_volume)
361	{
362		getChildView("FlexNumSections")->setVisible(true);
363		getChildView("FlexGravity")->setVisible(true);
364		getChildView("FlexTension")->setVisible(true);
365		getChildView("FlexFriction")->setVisible(true);
366		getChildView("FlexWind")->setVisible(true);
367		getChildView("FlexForceX")->setVisible(true);
368		getChildView("FlexForceY")->setVisible(true);
369		getChildView("FlexForceZ")->setVisible(true);
370
371		getChildView("FlexNumSections")->setEnabled(true);
372		getChildView("FlexGravity")->setEnabled(true);
373		getChildView("FlexTension")->setEnabled(true);
374		getChildView("FlexFriction")->setEnabled(true);
375		getChildView("FlexWind")->setEnabled(true);
376		getChildView("FlexForceX")->setEnabled(true);
377		getChildView("FlexForceY")->setEnabled(true);
378		getChildView("FlexForceZ")->setEnabled(true);
379
380		LLFlexibleObjectData *attributes = (LLFlexibleObjectData *)objectp->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE);
381		
382		getChild<LLUICtrl>("FlexNumSections")->setValue((F32)attributes->getSimulateLOD());
383		getChild<LLUICtrl>("FlexGravity")->setValue(attributes->getGravity());
384		getChild<LLUICtrl>("FlexTension")->setValue(attributes->getTension());
385		getChild<LLUICtrl>("FlexFriction")->setValue(attributes->getAirFriction());
386		getChild<LLUICtrl>("FlexWind")->setValue(attributes->getWindSensitivity());
387		getChild<LLUICtrl>("FlexForceX")->setValue(attributes->getUserForce().mV[VX]);
388		getChild<LLUICtrl>("FlexForceY")->setValue(attributes->getUserForce().mV[VY]);
389		getChild<LLUICtrl>("FlexForceZ")->setValue(attributes->getUserForce().mV[VZ]);
390	}
391	else
392	{
393		getChild<LLSpinCtrl>("FlexNumSections", true)->clear();
394		getChild<LLSpinCtrl>("FlexGravity", true)->clear();
395		getChild<LLSpinCtrl>("FlexTension", true)->clear();
396		getChild<LLSpinCtrl>("FlexFriction", true)->clear();
397		getChild<LLSpinCtrl>("FlexWind", true)->clear();
398		getChild<LLSpinCtrl>("FlexForceX", true)->clear();
399		getChild<LLSpinCtrl>("FlexForceY", true)->clear();
400		getChild<LLSpinCtrl>("FlexForceZ", true)->clear();
401
402		getChildView("FlexNumSections")->setEnabled(false);
403		getChildView("FlexGravity")->setEnabled(false);
404		getChildView("FlexTension")->setEnabled(false);
405		getChildView("FlexFriction")->setEnabled(false);
406		getChildView("FlexWind")->setEnabled(false);
407		getChildView("FlexForceX")->setEnabled(false);
408		getChildView("FlexForceY")->setEnabled(false);
409		getChildView("FlexForceZ")->setEnabled(false);
410	}
411	
412	// Material properties
413
414	// Update material part
415	// slightly inefficient - materials are unique per object, not per TE
416	U8 material_code = 0;
417	struct f : public LLSelectedTEGetFunctor<U8>
418	{
419		U8 get(LLViewerObject* object, S32 te)
420		{
421			return object->getMaterial();
422		}
423	} func;
424	bool material_same = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, material_code );
425	std::string LEGACY_FULLBRIGHT_DESC = LLTrans::getString("Fullbright");
426	if (editable && single_volume && material_same)
427	{
428		mComboMaterial->setEnabled( TRUE );
429		if (material_code == LL_MCODE_LIGHT)
430		{
431			if (mComboMaterial->getItemCount() == mComboMaterialItemCount)
432			{
433				mComboMaterial->add(LEGACY_FULLBRIGHT_DESC);
434			}
435			mComboMaterial->setSimple(LEGACY_FULLBRIGHT_DESC);
436		}
437		else
438		{
439			if (mComboMaterial->getItemCount() != mComboMaterialItemCount)
440			{
441				mComboMaterial->remove(LEGACY_FULLBRIGHT_DESC);
442			}
443			
444			mComboMaterial->setSimple(std::string(LLMaterialTable::basic.getName(material_code)));
445		}
446	}
447	else
448	{
449		mComboMaterial->setEnabled( FALSE );
450	}
451
452	// Physics properties
453	
454	mSpinPhysicsGravity->set(objectp->getPhysicsGravity());
455	mSpinPhysicsGravity->setEnabled(editable);
456
457	mSpinPhysicsFriction->set(objectp->getPhysicsFriction());
458	mSpinPhysicsFriction->setEnabled(editable);
459	
460	mSpinPhysicsDensity->set(objectp->getPhysicsDensity());
461	mSpinPhysicsDensity->setEnabled(editable);
462	
463	mSpinPhysicsRestitution->set(objectp->getPhysicsRestitution());
464	mSpinPhysicsRestitution->setEnabled(editable);
465
466	// update the physics shape combo to include allowed physics shapes
467	mComboPhysicsShapeType->removeall();
468	mComboPhysicsShapeType->add(getString("None"), LLSD(1));
469
470	BOOL isMesh = FALSE;
471	LLSculptParams *sculpt_params = (LLSculptParams *)objectp->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
472	if (sculpt_params)
473	{
474		U8 sculpt_type = sculpt_params->getSculptType();
475		U8 sculpt_stitching = sculpt_type & LL_SCULPT_TYPE_MASK;
476		isMesh = (sculpt_stitching == LL_SCULPT_TYPE_MESH);
477	}
478
479	if(isMesh && objectp)
480	{
481		const LLVolumeParams &volume_params = objectp->getVolume()->getParams();
482		LLUUID mesh_id = volume_params.getSculptID();
483		if(gMeshRepo.hasPhysicsShape(mesh_id))
484		{
485			// if a mesh contains an uploaded or decomposed physics mesh,
486			// allow 'Prim'
487			mComboPhysicsShapeType->add(getString("Prim"), LLSD(0));			
488		}
489	}
490	else
491	{
492		// simple prims always allow physics shape prim
493		mComboPhysicsShapeType->add(getString("Prim"), LLSD(0));	
494	}
495
496	mComboPhysicsShapeType->add(getString("Convex Hull"), LLSD(2));	
497	mComboPhysicsShapeType->setValue(LLSD(objectp->getPhysicsShapeType()));
498	mComboPhysicsShapeType->setEnabled(editable);
499
500	mObject = objectp;
501	mRootObject = root_objectp;
502}
503
504// static
505bool LLPanelVolume::precommitValidate( const LLSD& data )
506{
507	// TODO: Richard will fill this in later.  
508	return TRUE; // FALSE means that validation failed and new value should not be commited.
509}
510
511
512void LLPanelVolume::refresh()
513{
514	getState();
515	if (mObject.notNull() && mObject->isDead())
516	{
517		mObject = NULL;
518	}
519
520	if (mRootObject.notNull() && mRootObject->isDead())
521	{
522		mRootObject = NULL;
523	}
524
525	BOOL visible = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_DEFERRED) > 0 ? TRUE : FALSE;
526
527	getChildView("label texture")->setVisible( visible);
528	getChildView("Light FOV")->setVisible( visible);
529	getChildView("Light Focus")->setVisible( visible);
530	getChildView("Light Ambiance")->setVisible( visible);
531	getChildView("light texture control")->setVisible( visible);
532
533	bool enable_mesh = false;
534
535	LLSD sim_features;
536	LLViewerRegion *region = gAgent.getRegion();
537	if(region)
538	{
539		LLSD sim_features;
540		region->getSimulatorFeatures(sim_features);		 
541		enable_mesh = sim_features.has("PhysicsShapeTypes");
542	}
543	getChildView("label physicsshapetype")->setVisible(enable_mesh);
544	getChildView("Physics Shape Type Combo Ctrl")->setVisible(enable_mesh);
545	getChildView("Physics Gravity")->setVisible(enable_mesh);
546	getChildView("Physics Friction")->setVisible(enable_mesh);
547	getChildView("Physics Density")->setVisible(enable_mesh);
548	getChildView("Physics Restitution")->setVisible(enable_mesh);
549	
550    /* TODO: add/remove individual physics shape types as per the PhysicsShapeTypes simulator features */
551}
552
553
554void LLPanelVolume::draw()
555{
556	LLPanel::draw();
557}
558
559// virtual
560void LLPanelVolume::clearCtrls()
561{
562	LLPanel::clearCtrls();
563
564	getChildView("select_single")->setEnabled(false);
565	getChildView("select_single")->setVisible(true);
566	getChildView("edit_object")->setEnabled(false);
567	getChildView("edit_object")->setVisible(false);
568	getChildView("Light Checkbox Ctrl")->setEnabled(false);
569	getChildView("label color")->setEnabled(false);
570	getChildView("label color")->setEnabled(false);
571	LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
572	if(LightColorSwatch)
573	{
574		LightColorSwatch->setEnabled( FALSE );
575		LightColorSwatch->setValid( FALSE );
576	}
577	LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
578	if(LightTextureCtrl)
579	{
580		LightTextureCtrl->setEnabled( FALSE );
581		LightTextureCtrl->setValid( FALSE );
582	}
583
584	getChildView("Light Intensity")->setEnabled(false);
585	getChildView("Light Radius")->setEnabled(false);
586	getChildView("Light Falloff")->setEnabled(false);
587
588	getChildView("Flexible1D Checkbox Ctrl")->setEnabled(false);
589	getChildView("FlexNumSections")->setEnabled(false);
590	getChildView("FlexGravity")->setEnabled(false);
591	getChildView("FlexTension")->setEnabled(false);
592	getChildView("FlexFriction")->setEnabled(false);
593	getChildView("FlexWind")->setEnabled(false);
594	getChildView("FlexForceX")->setEnabled(false);
595	getChildView("FlexForceY")->setEnabled(false);
596	getChildView("FlexForceZ")->setEnabled(false);
597
598	mSpinPhysicsGravity->setEnabled(FALSE);
599	mSpinPhysicsFriction->setEnabled(FALSE);
600	mSpinPhysicsDensity->setEnabled(FALSE);
601	mSpinPhysicsRestitution->setEnabled(FALSE);
602
603	mComboMaterial->setEnabled( FALSE );
604}
605
606//
607// Static functions
608//
609
610void LLPanelVolume::sendIsLight()
611{
612	LLViewerObject* objectp = mObject;
613	if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
614	{
615		return;
616	}	
617	LLVOVolume *volobjp = (LLVOVolume *)objectp;
618	
619	BOOL value = getChild<LLUICtrl>("Light Checkbox Ctrl")->getValue();
620	volobjp->setIsLight(value);
621	llinfos << "update light sent" << llendl;
622}
623
624void LLPanelVolume::sendIsFlexible()
625{
626	LLViewerObject* objectp = mObject;
627	if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
628	{
629		return;
630	}	
631	LLVOVolume *volobjp = (LLVOVolume *)objectp;
632	
633	BOOL is_flexible = getChild<LLUICtrl>("Flexible1D Checkbox Ctrl")->getValue();
634	//BOOL is_flexible = mCheckFlexible1D->get();
635
636	if (is_flexible)
637	{
638		//LLFirstUse::useFlexible();
639
640		if (objectp->getClickAction() == CLICK_ACTION_SIT)
641		{
642			LLSelectMgr::getInstance()->selectionSetClickAction(CLICK_ACTION_NONE);
643		}
644
645	}
646
647	if (volobjp->setIsFlexible(is_flexible))
648	{
649		mObject->sendShapeUpdate();
650		LLSelectMgr::getInstance()->selectionUpdatePhantom(volobjp->flagPhantom());
651	}
652
653	llinfos << "update flexible sent" << llendl;
654}
655
656void LLPanelVolume::sendPhysicsShapeType(LLUICtrl* ctrl, void* userdata)
657{
658	U8 type = ctrl->getValue().asInteger();
659	LLSelectMgr::getInstance()->selectionSetPhysicsType(type);
660
661	refreshCost();
662}
663
664void LLPanelVolume::sendPhysicsGravity(LLUICtrl* ctrl, void* userdata)
665{
666	F32 val = ctrl->getValue().asReal();
667	LLSelectMgr::getInstance()->selectionSetGravity(val);
668}
669
670void LLPanelVolume::sendPhysicsFriction(LLUICtrl* ctrl, void* userdata)
671{
672	F32 val = ctrl->getValue().asReal();
673	LLSelectMgr::getInstance()->selectionSetFriction(val);
674}
675
676void LLPanelVolume::sendPhysicsRestitution(LLUICtrl* ctrl, void* userdata)
677{
678	F32 val = ctrl->getValue().asReal();
679	LLSelectMgr::getInstance()->selectionSetRestitution(val);
680}
681
682void LLPanelVolume::sendPhysicsDensity(LLUICtrl* ctrl, void* userdata)
683{
684	F32 val = ctrl->getValue().asReal();
685	LLSelectMgr::getInstance()->selectionSetDensity(val);
686}
687
688void LLPanelVolume::refreshCost()
689{
690	LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
691	
692	if (obj)
693	{
694		obj->getObjectCost();
695	}
696}
697
698void LLPanelVolume::onLightCancelColor(const LLSD& data)
699{
700	LLColorSwatchCtrl*	LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
701	if(LightColorSwatch)
702	{
703		LightColorSwatch->setColor(mLightSavedColor);
704	}
705	onLightSelectColor(data);
706}
707
708void LLPanelVolume::onLightCancelTexture(const LLSD& data)
709{
710	LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
711	if (LightTextureCtrl)
712	{
713		LightTextureCtrl->setImageAssetID(mLightSavedTexture);
714	}
715}
716
717void LLPanelVolume::onLightSelectColor(const LLSD& data)
718{
719	LLViewerObject* objectp = mObject;
720	if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
721	{
722		return;
723	}	
724	LLVOVolume *volobjp = (LLVOVolume *)objectp;
725
726
727	LLColorSwatchCtrl*	LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
728	if(LightColorSwatch)
729	{
730		LLColor4	clr = LightColorSwatch->get();
731		LLColor3	clr3( clr );
732		volobjp->setLightColor(clr3);
733		mLightSavedColor = clr;
734	}
735}
736
737void LLPanelVolume::onLightSelectTexture(const LLSD& data)
738{
739	if (mObject.isNull() || (mObject->getPCode() != LL_PCODE_VOLUME))
740	{
741		return;
742	}	
743	LLVOVolume *volobjp = (LLVOVolume *) mObject.get();
744
745
746	LLTextureCtrl*	LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
747	if(LightTextureCtrl)
748	{
749		LLUUID id = LightTextureCtrl->getImageAssetID();
750		volobjp->setLightTextureID(id);
751		mLightSavedTexture = id;
752	}
753}
754
755// static
756void LLPanelVolume::onCommitMaterial( LLUICtrl* ctrl, void* userdata )
757{
758	//LLPanelObject* self = (LLPanelObject*) userdata;
759	LLComboBox* box = (LLComboBox*) ctrl;
760
761	if (box)
762	{
763		// apply the currently selected material to the object
764		const std::string& material_name = box->getSimple();
765		std::string LEGACY_FULLBRIGHT_DESC = LLTrans::getString("Fullbright");
766		if (material_name != LEGACY_FULLBRIGHT_DESC)
767		{
768			U8 material_code = LLMaterialTable::basic.getMCode(material_name);
769			LLSelectMgr::getInstance()->selectionSetMaterial(material_code);
770		}
771	}
772}
773
774// static
775void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata )
776{
777	LLPanelVolume* self = (LLPanelVolume*) userdata;
778	LLViewerObject* objectp = self->mObject;
779	if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
780	{
781		return;
782	}	
783	LLVOVolume *volobjp = (LLVOVolume *)objectp;
784	
785	
786	volobjp->setLightIntensity((F32)self->getChild<LLUICtrl>("Light Intensity")->getValue().asReal());
787	volobjp->setLightRadius((F32)self->getChild<LLUICtrl>("Light Radius")->getValue().asReal());
788	volobjp->setLightFalloff((F32)self->getChild<LLUICtrl>("Light Falloff")->getValue().asReal());
789
790	LLColorSwatchCtrl*	LightColorSwatch = self->getChild<LLColorSwatchCtrl>("colorswatch");
791	if(LightColorSwatch)
792	{
793		LLColor4	clr = LightColorSwatch->get();
794		volobjp->setLightColor(LLColor3(clr));
795	}
796
797	LLTextureCtrl*	LightTextureCtrl = self->getChild<LLTextureCtrl>("light texture control");
798	if(LightTextureCtrl)
799	{
800		LLUUID id = LightTextureCtrl->getImageAssetID();
801		if (id.notNull())
802		{
803			if (!volobjp->isLightSpotlight())
804			{ //this commit is making this a spot light, set UI to default params
805				volobjp->setLightTextureID(id);
806				LLVector3 spot_params = volobjp->getSpotLightParams();
807				self->getChild<LLUICtrl>("Light FOV")->setValue(spot_params.mV[0]);
808				self->getChild<LLUICtrl>("Light Focus")->setValue(spot_params.mV[1]);
809				self->getChild<LLUICtrl>("Light Ambiance")->setValue(spot_params.mV[2]);
810			}
811			else
812			{ //modifying existing params
813				LLVector3 spot_params;
814				spot_params.mV[0] = (F32) self->getChild<LLUICtrl>("Light FOV")->getValue().asReal();
815				spot_params.mV[1] = (F32) self->getChild<LLUICtrl>("Light Focus")->getValue().asReal();
816				spot_params.mV[2] = (F32) self->getChild<LLUICtrl>("Light Ambiance")->getValue().asReal();
817				volobjp->setSpotLightParams(spot_params);
818			}
819		}
820		else if (volobjp->isLightSpotlight())
821		{ //no longer a spot light
822			volobjp->setLightTextureID(id);
823			//self->getChildView("Light FOV")->setEnabled(FALSE);
824			//self->getChildView("Light Focus")->setEnabled(FALSE);
825			//self->getChildView("Light Ambiance")->setEnabled(FALSE);
826		}
827	}
828
829	
830}
831
832// static
833void LLPanelVolume::onCommitIsLight( LLUICtrl* ctrl, void* userdata )
834{
835	LLPanelVolume* self = (LLPanelVolume*) userdata;
836	self->sendIsLight();
837}
838
839//----------------------------------------------------------------------------
840
841// static
842void LLPanelVolume::onCommitFlexible( LLUICtrl* ctrl, void* userdata )
843{
844	LLPanelVolume* self = (LLPanelVolume*) userdata;
845	LLViewerObject* objectp = self->mObject;
846	if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
847	{
848		return;
849	}
850	
851	LLFlexibleObjectData *attributes = (LLFlexibleObjectData *)objectp->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE);
852	if (attributes)
853	{
854		LLFlexibleObjectData new_attributes;
855		new_attributes = *attributes;
856
857
858		new_attributes.setSimulateLOD(self->getChild<LLUICtrl>("FlexNumSections")->getValue().asInteger());//(S32)self->mSpinSections->get());
859		new_attributes.setGravity((F32)self->getChild<LLUICtrl>("FlexGravity")->getValue().asReal());
860		new_attributes.setTension((F32)self->getChild<LLUICtrl>("FlexTension")->getValue().asReal());
861		new_attributes.setAirFriction((F32)self->getChild<LLUICtrl>("FlexFriction")->getValue().asReal());
862		new_attributes.setWindSensitivity((F32)self->getChild<LLUICtrl>("FlexWind")->getValue().asReal());
863		F32 fx = (F32)self->getChild<LLUICtrl>("FlexForceX")->getValue().asReal();
864		F32 fy = (F32)self->getChild<LLUICtrl>("FlexForceY")->getValue().asReal();
865		F32 fz = (F32)self->getChild<LLUICtrl>("FlexForceZ")->getValue().asReal();
866		LLVector3 force(fx,fy,fz);
867
868		new_attributes.setUserForce(force);
869		objectp->setParameterEntry(LLNetworkData::PARAMS_FLEXIBLE, new_attributes, true);
870	}
871
872	// Values may fail validation
873	self->refresh();
874}
875
876// static
877void LLPanelVolume::onCommitIsFlexible( LLUICtrl* ctrl, void* userdata )
878{
879	LLPanelVolume* self = (LLPanelVolume*) userdata;
880	self->sendIsFlexible();
881}
882