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