llpanelvolume.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:19k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llpanelvolume.cpp
  3.  * @brief Object editing (position, scale, etc.) in the tools floater
  4.  *
  5.  * $LicenseInfo:firstyear=2001&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2001-2010, Linden Research, Inc.
  8.  * 
  9.  * Second Life Viewer Source Code
  10.  * The source code in this file ("Source Code") is provided by Linden Lab
  11.  * to you under the terms of the GNU General Public License, version 2.0
  12.  * ("GPL"), unless you have obtained a separate licensing agreement
  13.  * ("Other License"), formally executed by you and Linden Lab.  Terms of
  14.  * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15.  * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16.  * 
  17.  * There are special exceptions to the terms and conditions of the GPL as
  18.  * it is applied to this Source Code. View the full text of the exception
  19.  * in the file doc/FLOSS-exception.txt in this software distribution, or
  20.  * online at
  21.  * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22.  * 
  23.  * By copying, modifying or distributing this software, you acknowledge
  24.  * that you have read and understood your obligations described above,
  25.  * and agree to abide by those obligations.
  26.  * 
  27.  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28.  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29.  * COMPLETENESS OR PERFORMANCE.
  30.  * $/LicenseInfo$
  31.  */
  32. #include "llviewerprecompiledheaders.h"
  33. // file include
  34. #include "llpanelvolume.h"
  35. // linden library includes
  36. #include "llclickaction.h"
  37. #include "lleconomy.h"
  38. #include "llerror.h"
  39. #include "llfontgl.h"
  40. #include "llflexibleobject.h"
  41. #include "llmaterialtable.h"
  42. #include "llpermissionsflags.h"
  43. #include "llstring.h"
  44. #include "llvolume.h"
  45. #include "m3math.h"
  46. #include "material_codes.h"
  47. // project includes
  48. #include "llbutton.h"
  49. #include "llcheckboxctrl.h"
  50. #include "llcolorswatch.h"
  51. #include "lltexturectrl.h"
  52. #include "llcombobox.h"
  53. //#include "llfirstuse.h"
  54. #include "llfocusmgr.h"
  55. #include "llmanipscale.h"
  56. #include "llpreviewscript.h"
  57. #include "llresmgr.h"
  58. #include "llselectmgr.h"
  59. #include "llspinctrl.h"
  60. #include "lltextbox.h"
  61. #include "lltool.h"
  62. #include "lltoolcomp.h"
  63. #include "lltoolmgr.h"
  64. #include "llui.h"
  65. #include "llviewerobject.h"
  66. #include "llviewerregion.h"
  67. #include "llviewerwindow.h"
  68. #include "llvovolume.h"
  69. #include "llworld.h"
  70. #include "pipeline.h"
  71. #include "llviewershadermgr.h"
  72. #include "lldrawpool.h"
  73. #include "lluictrlfactory.h"
  74. // "Features" Tab
  75. BOOL LLPanelVolume::postBuild()
  76. {
  77. // Flexible Objects Parameters
  78. {
  79. childSetCommitCallback("Flexible1D Checkbox Ctrl",onCommitIsFlexible,this);
  80. childSetCommitCallback("FlexNumSections",onCommitFlexible,this);
  81. childSetValidate("FlexNumSections",precommitValidate);
  82. childSetCommitCallback("FlexGravity",onCommitFlexible,this);
  83. childSetValidate("FlexGravity",precommitValidate);
  84. childSetCommitCallback("FlexFriction",onCommitFlexible,this);
  85. childSetValidate("FlexFriction",precommitValidate);
  86. childSetCommitCallback("FlexWind",onCommitFlexible,this);
  87. childSetValidate("FlexWind",precommitValidate);
  88. childSetCommitCallback("FlexTension",onCommitFlexible,this);
  89. childSetValidate("FlexTension",precommitValidate);
  90. childSetCommitCallback("FlexForceX",onCommitFlexible,this);
  91. childSetValidate("FlexForceX",precommitValidate);
  92. childSetCommitCallback("FlexForceY",onCommitFlexible,this);
  93. childSetValidate("FlexForceY",precommitValidate);
  94. childSetCommitCallback("FlexForceZ",onCommitFlexible,this);
  95. childSetValidate("FlexForceZ",precommitValidate);
  96. }
  97. // LIGHT Parameters
  98. {
  99. childSetCommitCallback("Light Checkbox Ctrl",onCommitIsLight,this);
  100. LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
  101. if(LightColorSwatch){
  102. LightColorSwatch->setOnCancelCallback(boost::bind(&LLPanelVolume::onLightCancelColor, this, _2));
  103. LightColorSwatch->setOnSelectCallback(boost::bind(&LLPanelVolume::onLightSelectColor, this, _2));
  104. childSetCommitCallback("colorswatch",onCommitLight,this);
  105. }
  106. LLTextureCtrl* LightTexPicker = getChild<LLTextureCtrl>("light texture control");
  107. if (LightTexPicker)
  108. {
  109. LightTexPicker->setOnCancelCallback(boost::bind(&LLPanelVolume::onLightCancelTexture, this, _2));
  110. LightTexPicker->setOnSelectCallback(boost::bind(&LLPanelVolume::onLightSelectTexture, this, _2));
  111. childSetCommitCallback("light texture control", onCommitLight, this);
  112. }
  113. childSetCommitCallback("Light Intensity",onCommitLight,this);
  114. childSetValidate("Light Intensity",precommitValidate);
  115. childSetCommitCallback("Light Radius",onCommitLight,this);
  116. childSetValidate("Light Radius",precommitValidate);
  117. childSetCommitCallback("Light Falloff",onCommitLight,this);
  118. childSetValidate("Light Falloff",precommitValidate);
  119. childSetCommitCallback("Light FOV", onCommitLight, this);
  120. childSetValidate("Light FOV", precommitValidate);
  121. childSetCommitCallback("Light Focus", onCommitLight, this);
  122. childSetValidate("Light Focus", precommitValidate);
  123. childSetCommitCallback("Light Ambiance", onCommitLight, this);
  124. childSetValidate("Light Ambiance", precommitValidate);
  125. }
  126. // Start with everyone disabled
  127. clearCtrls();
  128. return TRUE;
  129. }
  130. LLPanelVolume::LLPanelVolume()
  131. : LLPanel()
  132. {
  133. setMouseOpaque(FALSE);
  134. }
  135. LLPanelVolume::~LLPanelVolume()
  136. {
  137. // Children all cleaned up by default view destructor.
  138. }
  139. void LLPanelVolume::getState( )
  140. {
  141. LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject();
  142. LLViewerObject* root_objectp = objectp;
  143. if(!objectp)
  144. {
  145. objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
  146. // *FIX: shouldn't we just keep the child?
  147. if (objectp)
  148. {
  149. LLViewerObject* parentp = objectp->getRootEdit();
  150. if (parentp)
  151. {
  152. root_objectp = parentp;
  153. }
  154. else
  155. {
  156. root_objectp = objectp;
  157. }
  158. }
  159. }
  160. LLVOVolume *volobjp = NULL;
  161. if ( objectp && (objectp->getPCode() == LL_PCODE_VOLUME))
  162. {
  163. volobjp = (LLVOVolume *)objectp;
  164. }
  165. if( !objectp )
  166. {
  167. //forfeit focus
  168. if (gFocusMgr.childHasKeyboardFocus(this))
  169. {
  170. gFocusMgr.setKeyboardFocus(NULL);
  171. }
  172. // Disable all text input fields
  173. clearCtrls();
  174. return;
  175. }
  176. BOOL owners_identical;
  177. LLUUID owner_id;
  178. std::string owner_name;
  179. owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name);
  180. // BUG? Check for all objects being editable?
  181. BOOL editable = root_objectp->permModify();
  182. BOOL single_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME )
  183. && LLSelectMgr::getInstance()->getSelection()->getObjectCount() == 1;
  184. // Select Single Message
  185. if (single_volume)
  186. {
  187. childSetVisible("edit_object",true);
  188. childSetEnabled("edit_object",true);
  189. childSetVisible("select_single",false);
  190. }
  191. else
  192. {
  193. childSetVisible("edit_object",false);
  194. childSetVisible("select_single",true);
  195. childSetEnabled("select_single",true);
  196. }
  197. // Light properties
  198. BOOL is_light = volobjp && volobjp->getIsLight();
  199. childSetValue("Light Checkbox Ctrl",is_light);
  200. childSetEnabled("Light Checkbox Ctrl",editable && single_volume && volobjp);
  201. if (is_light && editable && single_volume)
  202. {
  203. childSetEnabled("label color",true);
  204. //mLabelColor  ->setEnabled( TRUE );
  205. LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
  206. if(LightColorSwatch)
  207. {
  208. LightColorSwatch->setEnabled( TRUE );
  209. LightColorSwatch->setValid( TRUE );
  210. LightColorSwatch->set(volobjp->getLightBaseColor());
  211. }
  212. LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
  213. if (LightTextureCtrl)
  214. {
  215. LightTextureCtrl->setEnabled(TRUE);
  216. LightTextureCtrl->setValid(TRUE);
  217. LightTextureCtrl->setImageAssetID(volobjp->getLightTextureID());
  218. }
  219. childSetEnabled("Light Intensity",true);
  220. childSetEnabled("Light Radius",true);
  221. childSetEnabled("Light Falloff",true);
  222. childSetEnabled("Light FOV", true);
  223. childSetEnabled("Light Focus", true);
  224. childSetEnabled("Light Ambiance", true);
  225. childSetValue("Light Intensity",volobjp->getLightIntensity());
  226. childSetValue("Light Radius",volobjp->getLightRadius());
  227. childSetValue("Light Falloff",volobjp->getLightFalloff());
  228. LLVector3 params = volobjp->getSpotLightParams();
  229. childSetValue("Light FOV", params.mV[0]);
  230. childSetValue("Light Focus", params.mV[1]);
  231. childSetValue("Light Ambiance", params.mV[2]);
  232. mLightSavedColor = volobjp->getLightColor();
  233. }
  234. else
  235. {
  236. getChild<LLSpinCtrl>("Light Intensity", true)->clear();
  237. getChild<LLSpinCtrl>("Light Radius", true)->clear();
  238. getChild<LLSpinCtrl>("Light Falloff", true)->clear();
  239. childSetEnabled("label color",false);
  240. LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
  241. if(LightColorSwatch)
  242. {
  243. LightColorSwatch->setEnabled( FALSE );
  244. LightColorSwatch->setValid( FALSE );
  245. }
  246. LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
  247. if (LightTextureCtrl)
  248. {
  249. LightTextureCtrl->setEnabled(FALSE);
  250. LightTextureCtrl->setValid(FALSE);
  251. }
  252. childSetEnabled("Light Intensity",false);
  253. childSetEnabled("Light Radius",false);
  254. childSetEnabled("Light Falloff",false);
  255. childSetEnabled("Light FOV",false);
  256. childSetEnabled("Light Focus",false);
  257. childSetEnabled("Light Ambiance",false);
  258. }
  259. // Flexible properties
  260. BOOL is_flexible = volobjp && volobjp->isFlexible();
  261. childSetValue("Flexible1D Checkbox Ctrl",is_flexible);
  262. if (is_flexible || (volobjp && volobjp->canBeFlexible()))
  263. {
  264. childSetEnabled("Flexible1D Checkbox Ctrl", editable && single_volume && volobjp);
  265. }
  266. else
  267. {
  268. childSetEnabled("Flexible1D Checkbox Ctrl", false);
  269. }
  270. if (is_flexible && editable && single_volume)
  271. {
  272. childSetVisible("FlexNumSections",true);
  273. childSetVisible("FlexGravity",true);
  274. childSetVisible("FlexTension",true);
  275. childSetVisible("FlexFriction",true);
  276. childSetVisible("FlexWind",true);
  277. childSetVisible("FlexForceX",true);
  278. childSetVisible("FlexForceY",true);
  279. childSetVisible("FlexForceZ",true);
  280. childSetEnabled("FlexNumSections",true);
  281. childSetEnabled("FlexGravity",true);
  282. childSetEnabled("FlexTension",true);
  283. childSetEnabled("FlexFriction",true);
  284. childSetEnabled("FlexWind",true);
  285. childSetEnabled("FlexForceX",true);
  286. childSetEnabled("FlexForceY",true);
  287. childSetEnabled("FlexForceZ",true);
  288. LLFlexibleObjectData *attributes = (LLFlexibleObjectData *)objectp->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE);
  289. childSetValue("FlexNumSections",(F32)attributes->getSimulateLOD());
  290. childSetValue("FlexGravity",attributes->getGravity());
  291. childSetValue("FlexTension",attributes->getTension());
  292. childSetValue("FlexFriction",attributes->getAirFriction());
  293. childSetValue("FlexWind",attributes->getWindSensitivity());
  294. childSetValue("FlexForceX",attributes->getUserForce().mV[VX]);
  295. childSetValue("FlexForceY",attributes->getUserForce().mV[VY]);
  296. childSetValue("FlexForceZ",attributes->getUserForce().mV[VZ]);
  297. }
  298. else
  299. {
  300. getChild<LLSpinCtrl>("FlexNumSections", true)->clear();
  301. getChild<LLSpinCtrl>("FlexGravity", true)->clear();
  302. getChild<LLSpinCtrl>("FlexTension", true)->clear();
  303. getChild<LLSpinCtrl>("FlexFriction", true)->clear();
  304. getChild<LLSpinCtrl>("FlexWind", true)->clear();
  305. getChild<LLSpinCtrl>("FlexForceX", true)->clear();
  306. getChild<LLSpinCtrl>("FlexForceY", true)->clear();
  307. getChild<LLSpinCtrl>("FlexForceZ", true)->clear();
  308. childSetEnabled("FlexNumSections",false);
  309. childSetEnabled("FlexGravity",false);
  310. childSetEnabled("FlexTension",false);
  311. childSetEnabled("FlexFriction",false);
  312. childSetEnabled("FlexWind",false);
  313. childSetEnabled("FlexForceX",false);
  314. childSetEnabled("FlexForceY",false);
  315. childSetEnabled("FlexForceZ",false);
  316. }
  317. mObject = objectp;
  318. mRootObject = root_objectp;
  319. }
  320. // static
  321. bool LLPanelVolume::precommitValidate( const LLSD& data )
  322. {
  323. // TODO: Richard will fill this in later.  
  324. return TRUE; // FALSE means that validation failed and new value should not be commited.
  325. }
  326. void LLPanelVolume::refresh()
  327. {
  328. getState();
  329. if (mObject.notNull() && mObject->isDead())
  330. {
  331. mObject = NULL;
  332. }
  333. if (mRootObject.notNull() && mRootObject->isDead())
  334. {
  335. mRootObject = NULL;
  336. }
  337. BOOL visible = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_DEFERRED) > 0 ? TRUE : FALSE;
  338. childSetVisible("label texture", visible);
  339. childSetVisible("Light FOV", visible);
  340. childSetVisible("Light Focus", visible);
  341. childSetVisible("Light Ambiance", visible);
  342. childSetVisible("light texture control", visible);
  343. }
  344. void LLPanelVolume::draw()
  345. {
  346. LLPanel::draw();
  347. }
  348. // virtual
  349. void LLPanelVolume::clearCtrls()
  350. {
  351. LLPanel::clearCtrls();
  352. childSetEnabled("select_single",false);
  353. childSetVisible("select_single",true);
  354. childSetEnabled("edit_object",false);
  355. childSetVisible("edit_object",false);
  356. childSetEnabled("Light Checkbox Ctrl",false);
  357. childSetEnabled("label color",false);
  358. childSetEnabled("label color",false);
  359. LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
  360. if(LightColorSwatch)
  361. {
  362. LightColorSwatch->setEnabled( FALSE );
  363. LightColorSwatch->setValid( FALSE );
  364. }
  365. LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
  366. if(LightTextureCtrl)
  367. {
  368. LightTextureCtrl->setEnabled( FALSE );
  369. LightTextureCtrl->setValid( FALSE );
  370. }
  371. childSetEnabled("Light Intensity",false);
  372. childSetEnabled("Light Radius",false);
  373. childSetEnabled("Light Falloff",false);
  374. childSetEnabled("Flexible1D Checkbox Ctrl",false);
  375. childSetEnabled("FlexNumSections",false);
  376. childSetEnabled("FlexGravity",false);
  377. childSetEnabled("FlexTension",false);
  378. childSetEnabled("FlexFriction",false);
  379. childSetEnabled("FlexWind",false);
  380. childSetEnabled("FlexForceX",false);
  381. childSetEnabled("FlexForceY",false);
  382. childSetEnabled("FlexForceZ",false);
  383. }
  384. //
  385. // Static functions
  386. //
  387. void LLPanelVolume::sendIsLight()
  388. {
  389. LLViewerObject* objectp = mObject;
  390. if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
  391. {
  392. return;
  393. }
  394. LLVOVolume *volobjp = (LLVOVolume *)objectp;
  395. BOOL value = childGetValue("Light Checkbox Ctrl");
  396. volobjp->setIsLight(value);
  397. llinfos << "update light sent" << llendl;
  398. }
  399. void LLPanelVolume::sendIsFlexible()
  400. {
  401. LLViewerObject* objectp = mObject;
  402. if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
  403. {
  404. return;
  405. }
  406. LLVOVolume *volobjp = (LLVOVolume *)objectp;
  407. BOOL is_flexible = childGetValue("Flexible1D Checkbox Ctrl");
  408. //BOOL is_flexible = mCheckFlexible1D->get();
  409. if (is_flexible)
  410. {
  411. //LLFirstUse::useFlexible();
  412. if (objectp->getClickAction() == CLICK_ACTION_SIT)
  413. {
  414. LLSelectMgr::getInstance()->selectionSetClickAction(CLICK_ACTION_NONE);
  415. }
  416. }
  417. if (volobjp->setIsFlexible(is_flexible))
  418. {
  419. mObject->sendShapeUpdate();
  420. LLSelectMgr::getInstance()->selectionUpdatePhantom(volobjp->flagPhantom());
  421. }
  422. llinfos << "update flexible sent" << llendl;
  423. }
  424. void LLPanelVolume::onLightCancelColor(const LLSD& data)
  425. {
  426. LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
  427. if(LightColorSwatch)
  428. {
  429. LightColorSwatch->setColor(mLightSavedColor);
  430. }
  431. onLightSelectColor(data);
  432. }
  433. void LLPanelVolume::onLightCancelTexture(const LLSD& data)
  434. {
  435. LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
  436. if (LightTextureCtrl)
  437. {
  438. LightTextureCtrl->setImageAssetID(mLightSavedTexture);
  439. }
  440. }
  441. void LLPanelVolume::onLightSelectColor(const LLSD& data)
  442. {
  443. LLViewerObject* objectp = mObject;
  444. if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
  445. {
  446. return;
  447. }
  448. LLVOVolume *volobjp = (LLVOVolume *)objectp;
  449. LLColorSwatchCtrl* LightColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
  450. if(LightColorSwatch)
  451. {
  452. LLColor4 clr = LightColorSwatch->get();
  453. LLColor3 clr3( clr );
  454. volobjp->setLightColor(clr3);
  455. mLightSavedColor = clr;
  456. }
  457. }
  458. void LLPanelVolume::onLightSelectTexture(const LLSD& data)
  459. {
  460. if (mObject.isNull() || (mObject->getPCode() != LL_PCODE_VOLUME))
  461. {
  462. return;
  463. }
  464. LLVOVolume *volobjp = (LLVOVolume *) mObject.get();
  465. LLTextureCtrl* LightTextureCtrl = getChild<LLTextureCtrl>("light texture control");
  466. if(LightTextureCtrl)
  467. {
  468. LLUUID id = LightTextureCtrl->getImageAssetID();
  469. volobjp->setLightTextureID(id);
  470. mLightSavedTexture = id;
  471. }
  472. }
  473. // static
  474. void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata )
  475. {
  476. LLPanelVolume* self = (LLPanelVolume*) userdata;
  477. LLViewerObject* objectp = self->mObject;
  478. if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
  479. {
  480. return;
  481. }
  482. LLVOVolume *volobjp = (LLVOVolume *)objectp;
  483. volobjp->setLightIntensity((F32)self->childGetValue("Light Intensity").asReal());
  484. volobjp->setLightRadius((F32)self->childGetValue("Light Radius").asReal());
  485. volobjp->setLightFalloff((F32)self->childGetValue("Light Falloff").asReal());
  486. LLColorSwatchCtrl* LightColorSwatch = self->getChild<LLColorSwatchCtrl>("colorswatch");
  487. if(LightColorSwatch)
  488. {
  489. LLColor4 clr = LightColorSwatch->get();
  490. volobjp->setLightColor(LLColor3(clr));
  491. }
  492. LLTextureCtrl* LightTextureCtrl = self->getChild<LLTextureCtrl>("light texture control");
  493. if(LightTextureCtrl)
  494. {
  495. LLUUID id = LightTextureCtrl->getImageAssetID();
  496. if (id.notNull())
  497. {
  498. if (volobjp->getLightTextureID().isNull())
  499. { //this commit is making this a spot light, set UI to default params
  500. volobjp->setLightTextureID(id);
  501. LLVector3 spot_params = volobjp->getSpotLightParams();
  502. self->childSetValue("Light FOV", spot_params.mV[0]);
  503. self->childSetValue("Light Focus", spot_params.mV[1]);
  504. self->childSetValue("Light Ambiance", spot_params.mV[2]);
  505. }
  506. else
  507. { //modifying existing params
  508. LLVector3 spot_params;
  509. spot_params.mV[0] = (F32) self->childGetValue("Light FOV").asReal();
  510. spot_params.mV[1] = (F32) self->childGetValue("Light Focus").asReal();
  511. spot_params.mV[2] = (F32) self->childGetValue("Light Ambiance").asReal();
  512. volobjp->setSpotLightParams(spot_params);
  513. }
  514. }
  515. else if (volobjp->getLightTextureID().notNull())
  516. { //no longer a spot light
  517. volobjp->setLightTextureID(id);
  518. //self->childDisable("Light FOV");
  519. //self->childDisable("Light Focus");
  520. //self->childDisable("Light Ambiance");
  521. }
  522. }
  523. }
  524. // static
  525. void LLPanelVolume::onCommitIsLight( LLUICtrl* ctrl, void* userdata )
  526. {
  527. LLPanelVolume* self = (LLPanelVolume*) userdata;
  528. self->sendIsLight();
  529. }
  530. //----------------------------------------------------------------------------
  531. // static
  532. void LLPanelVolume::onCommitFlexible( LLUICtrl* ctrl, void* userdata )
  533. {
  534. LLPanelVolume* self = (LLPanelVolume*) userdata;
  535. LLViewerObject* objectp = self->mObject;
  536. if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
  537. {
  538. return;
  539. }
  540. LLFlexibleObjectData *attributes = (LLFlexibleObjectData *)objectp->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE);
  541. if (attributes)
  542. {
  543. LLFlexibleObjectData new_attributes;
  544. new_attributes = *attributes;
  545. new_attributes.setSimulateLOD(self->childGetValue("FlexNumSections").asInteger());//(S32)self->mSpinSections->get());
  546. new_attributes.setGravity((F32)self->childGetValue("FlexGravity").asReal());
  547. new_attributes.setTension((F32)self->childGetValue("FlexTension").asReal());
  548. new_attributes.setAirFriction((F32)self->childGetValue("FlexFriction").asReal());
  549. new_attributes.setWindSensitivity((F32)self->childGetValue("FlexWind").asReal());
  550. F32 fx = (F32)self->childGetValue("FlexForceX").asReal();
  551. F32 fy = (F32)self->childGetValue("FlexForceY").asReal();
  552. F32 fz = (F32)self->childGetValue("FlexForceZ").asReal();
  553. LLVector3 force(fx,fy,fz);
  554. new_attributes.setUserForce(force);
  555. objectp->setParameterEntry(LLNetworkData::PARAMS_FLEXIBLE, new_attributes, true);
  556. }
  557. // Values may fail validation
  558. self->refresh();
  559. }
  560. // static
  561. void LLPanelVolume::onCommitIsFlexible( LLUICtrl* ctrl, void* userdata )
  562. {
  563. LLPanelVolume* self = (LLPanelVolume*) userdata;
  564. self->sendIsFlexible();
  565. }