1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480 |
- /**
- * @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, (c)2009-2023 Henri Beauchamp
- *
- * 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"
- #include "llpanelvolume.h"
- #include "llbutton.h"
- #include "llcheckboxctrl.h"
- #include "llcombobox.h"
- #include "lleconomy.h"
- #include "llnotifications.h"
- #include "llpermissionsflags.h"
- #include "llspinctrl.h"
- #include "lltextbox.h"
- #include "lltrans.h"
- #include "llscrolllistctrl.h"
- #include "lluictrlfactory.h"
- #include "llvolume.h"
- #include "llagent.h"
- #include "llcolorswatch.h"
- #include "lldrawpool.h"
- #include "llflexibleobject.h"
- #include "llmanipscale.h"
- #include "llmeshrepository.h"
- #include "llpipeline.h"
- #include "llpreviewscript.h"
- #include "llselectmgr.h"
- #include "lltexturectrl.h"
- #include "lltooldraganddrop.h"
- #include "lltool.h"
- #include "lltoolcomp.h"
- #include "lltoolmgr.h"
- #include "llviewermenu.h" // For handle_refresh_probes()
- #include "llviewerobject.h"
- #include "llviewerregion.h"
- #include "llvoavatarself.h"
- #include "llvovolume.h"
- #include "llworld.h"
- constexpr F32 DEFAULT_GRAVITY_MULTIPLIER = 1.f;
- constexpr F32 DEFAULT_DENSITY = 1000.f;
- ///////////////////////////////////////////////////////////////////////////////
- // HBReflectionProbe class
- ///////////////////////////////////////////////////////////////////////////////
- // Floater for adjusting reflection probe parameters. Using a separate floater
- // for this rarely used feature avoids cluttering excessively the already
- // crowded "Features" tab, without having to enlarge the Build tools floater to
- // fit the new controls. HB
- class HBReflectionProbe final : public LLFloater
- {
- protected:
- LOG_CLASS(HBReflectionProbe);
- public:
- static void show(LLView* ownerp);
- static void hide();
- static void update();
- private:
- HBReflectionProbe(LLView* ownerp); // Use show()
- ~HBReflectionProbe() override; // Use hide()
- bool postBuild() override;
- void draw() override;
- void refresh() override;
- LLVOVolume* getEditedVolume();
- void setProbeParams(bool force);
- static void onProbeCheck(LLUICtrl*, void* userdata);
- static void onCommitProbe(LLUICtrl*, void* userdata);
- private:
- LLFloater* mParentFloater;
- LLCheckBoxCtrl* mProbeCheck;
- LLComboBox* mTypeCombo;
- LLComboBox* mVolumeCombo;
- LLSpinCtrl* mAmbianceSpin;
- LLSpinCtrl* mNearClipSpin;
- bool mMustClose;
- static HBReflectionProbe* sInstance;
- };
- //static
- HBReflectionProbe* HBReflectionProbe::sInstance = NULL;
- //static
- void HBReflectionProbe::show(LLView* ownerp)
- {
- if (!sInstance)
- {
- sInstance = new HBReflectionProbe(ownerp);
- }
- sInstance->open();
- sInstance->setFocus(true);
- }
- //static
- void HBReflectionProbe::hide()
- {
- if (sInstance)
- {
- sInstance->close();
- }
- }
- //static
- void HBReflectionProbe::update()
- {
- if (sInstance)
- {
- sInstance->refresh();
- }
- }
- HBReflectionProbe::HBReflectionProbe(LLView* ownerp)
- : mParentFloater(NULL),
- mMustClose(false)
- {
- llassert_always(!sInstance);
- sInstance = this;
- LLUICtrlFactory* factoryp = LLUICtrlFactory::getInstance();
- factoryp->buildFloater(this, "floater_reflection_probe.xml");
- // Note: at this point postBuild() has been called and returned.
- LLView* parentp = ownerp;
- // Search for our owner's parent floater and register as dependent of
- // it if found.
- while (parentp)
- {
- LLFloater* floaterp = parentp->asFloater();
- if (floaterp)
- {
- mParentFloater = floaterp;
- floaterp->addDependentFloater(this);
- break;
- }
- parentp = parentp->getParent();
- }
- }
- //virtual
- HBReflectionProbe::~HBReflectionProbe()
- {
- sInstance = NULL;
- }
- //virtual
- bool HBReflectionProbe::postBuild()
- {
- mProbeCheck = getChild<LLCheckBoxCtrl>("probe_check");
- mProbeCheck->setCommitCallback(onProbeCheck);
- mProbeCheck->setCallbackUserData(this);
- mVolumeCombo = getChild<LLComboBox>("volume_combo");
- mVolumeCombo->setCommitCallback(onCommitProbe);
- mVolumeCombo->setCallbackUserData(this);
- mTypeCombo = getChild<LLComboBox>("type_combo");
- mTypeCombo->setCommitCallback(onCommitProbe);
- mTypeCombo->setCallbackUserData(this);
- // These are the two "Mirror" items.
- LLScrollListItem* itemp = mTypeCombo->getItemByIndex(2);
- if (itemp)
- {
- itemp->setEnabled(LLPipeline::sRenderMirrors);
- }
- itemp = mTypeCombo->getItemByIndex(3);
- if (itemp)
- {
- itemp->setEnabled(LLPipeline::sRenderMirrors);
- }
- mAmbianceSpin = getChild<LLSpinCtrl>("ambiance_ctrl");
- mAmbianceSpin->setCommitCallback(onCommitProbe);
- mAmbianceSpin->setCallbackUserData(this);
- mNearClipSpin = getChild<LLSpinCtrl>("near_clip_ctrl");
- mNearClipSpin->setCommitCallback(onCommitProbe);
- mNearClipSpin->setCallbackUserData(this);
- refresh();
- return true;
- }
- LLVOVolume* HBReflectionProbe::getEditedVolume()
- {
- LLObjectSelectionHandle selection = gSelectMgr.getSelection();
- if (selection->getObjectCount() != 1 || !gAgent.hasInventoryMaterial())
- {
- mMustClose = true;
- return NULL;
- }
-
- LLViewerObject* objectp = selection->getFirstObject();
- LLVOVolume* vovolp = objectp->asVolume();
- if (!vovolp || vovolp->getPCode() != LL_PCODE_VOLUME || vovolp->isMesh())
- {
- mMustClose = true;
- return NULL;
- }
- return vovolp;
- }
- //virtual
- void HBReflectionProbe::draw()
- {
- if (mMustClose || (mParentFloater && !mParentFloater->getVisible()))
- {
- close();
- return;
- }
- LLFloater::draw();
- }
- //virtual
- void HBReflectionProbe::refresh()
- {
- LLVOVolume* volobjp = getEditedVolume();
- if (!volobjp)
- {
- return;
- }
- bool enabled = volobjp->permModify() && !volobjp->isPermanentEnforced();
- mProbeCheck->setEnabled(enabled);
- bool is_probe = volobjp->isReflectionProbe();
- bool is_dynamic = volobjp->getReflectionProbeIsDynamic();
- bool is_mirror = volobjp->getReflectionProbeIsMirror();
- mProbeCheck->set(is_probe);
- // Other controls enabled when actually a probe
- enabled &= is_probe;
- mTypeCombo->setEnabled(enabled);
- mAmbianceSpin->setEnabled(enabled && !is_mirror);
- mNearClipSpin->setEnabled(enabled && !is_mirror);
- // For now, mirrors are only working properly with box probes.
- mVolumeCombo->setEnabled(enabled && !is_mirror);
- if (enabled)
- {
- // For now, mirrors are only working properly with box probes.
- bool is_box = is_mirror || volobjp->getReflectionProbeIsBox();
- mVolumeCombo->setValue(is_box ? "Box" : "Sphere");
- if (is_dynamic)
- {
- mTypeCombo->setValue(is_mirror ? "Mirror (dynamic)" : "Dynamic");
- }
- else
- {
- mTypeCombo->setValue(is_mirror ? "Mirror (static)" : "Static");
- }
- mAmbianceSpin->setEnabled(!is_mirror);
- mNearClipSpin->setEnabled(!is_mirror);
- if (is_mirror)
- {
- mAmbianceSpin->clear();
- mNearClipSpin->clear();
- }
- else
- {
- mAmbianceSpin->setValue(volobjp->getReflectionProbeAmbiance());
- mNearClipSpin->setValue(volobjp->getReflectionProbeNearClip());
- }
- }
- else
- {
- mVolumeCombo->clear();
- mTypeCombo->clear();
- mAmbianceSpin->clear();
- mNearClipSpin->clear();
- }
- }
- void HBReflectionProbe::setProbeParams(bool force)
- {
- LLVOVolume* volobjp = getEditedVolume();
- if (!volobjp)
- {
- return;
- }
- if (!volobjp->permModify() || volobjp->isPermanentEnforced())
- {
- return;
- }
- F32 ambiance = mAmbianceSpin->getValue().asReal();
- F32 nearclip = mNearClipSpin->getValue().asReal();
- std::string type = mTypeCombo->getValue().asString();
- bool is_dynamic = type.find("ynamic") != std::string::npos;
- bool is_mirror = type.find("Mirror") != std::string::npos;
- bool is_box = mVolumeCombo->getValue().asString() == "Box";
- if (is_mirror && !is_box)
- {
- // For now, mirrors are only working properly with box probes.
- is_box = true;
- mVolumeCombo->setValue("Box");
- }
- if (force)
- {
- // Do not change the shape to a sphere when turning a primitve for the
- // first time into a reflection probe and the primitive is already a
- // box: the user wanted it that way in the first place, and likely
- // sized it appropriately (turning it into a sphere makes us loose any
- // non cubic sizes, ruining the user's work).
- const LLVolumeParams& volparams = volobjp->getVolume()->getParams();
- if (volparams.getPathParams().getCurveType() != LL_PCODE_PATH_CIRCLE)
- {
- is_box = true;
- }
- }
- volobjp->setReflectionProbeIsDynamic(is_dynamic);
- volobjp->setReflectionProbeIsMirror(is_mirror);
- if (!is_mirror)
- {
- volobjp->setReflectionProbeAmbiance(ambiance);
- volobjp->setReflectionProbeNearClip(nearclip);
- }
- if (volobjp->setReflectionProbeIsBox(is_box) || force)
- {
- if (volobjp->getRootEdit() == (LLViewerObject*)volobjp)
- {
- gSelectMgr.selectionUpdatePhantom(true);
- }
- else // This is a child primitive: cannot set it phantom.
- {
- // Remove its physics hull.
- gSelectMgr.selectionSetPhysicsType(1); // 1 = None
- // And prevent any accidental interaction for non-PBR viewers.
- gSelectMgr.selectionSetClickAction(9); // 9 = Ignore object
- }
- gSelectMgr.selectionSetGLTFMaterial(LLUUID::null);
- gSelectMgr.selectionSetAlphaOnly(0.f);
- U8 profile, path;
- if (is_box)
- {
- profile = LL_PCODE_PROFILE_SQUARE;
- path = LL_PCODE_PATH_LINE;
- }
- else
- {
- profile = LL_PCODE_PROFILE_CIRCLE_HALF;
- path = LL_PCODE_PATH_CIRCLE;
- F32 scale = volobjp->getScale().mV[0];
- volobjp->setScale(LLVector3(scale, scale, scale), false);
- constexpr U8 updates = UPD_ROTATION | UPD_POSITION | UPD_SCALE;
- gSelectMgr.sendMultipleUpdate(updates);
- }
- LLVolumeParams params;
- params.setType(profile, path);
- volobjp->updateVolume(params);
- }
- handle_refresh_probes(NULL);
- refresh();
- }
- //static
- void HBReflectionProbe::onProbeCheck(LLUICtrl*, void* userdata)
- {
- HBReflectionProbe* self = (HBReflectionProbe*)userdata;
- if (!self)
- {
- return;
- }
- LLVOVolume* volobjp = self->getEditedVolume();
- if (!volobjp)
- {
- return;
- }
- bool is_probe = volobjp->isReflectionProbe();
- bool set_probe = self->mProbeCheck->get();
- volobjp->setIsReflectionProbe(set_probe);
- if (!is_probe && set_probe)
- {
- self->setProbeParams(true); // true = force volume changes to match
- }
- else
- {
- self->refresh();
- }
- }
- //static
- void HBReflectionProbe::onCommitProbe(LLUICtrl*, void* userdata)
- {
- HBReflectionProbe* self = (HBReflectionProbe*)userdata;
- if (self)
- {
- self->setProbeParams(false);
- }
- }
- ///////////////////////////////////////////////////////////////////////////////
- // LLPanelVolume class
- ///////////////////////////////////////////////////////////////////////////////
- // "Features" Tab
- LLPanelVolume::LLPanelVolume(const std::string& name)
- : LLPanel(name),
- mIsPhysical(false),
- mComboMaterialItemCount(0)
- {
- setMouseOpaque(false);
- }
- LLPanelVolume::~LLPanelVolume()
- {
- HBReflectionProbe::hide();
- }
- bool LLPanelVolume::postBuild()
- {
- mLabelSelectSingle = getChild<LLTextBox>("select_single");
- mLabelEditObject = getChild<LLTextBox>("edit_object");
- // Flexible objects parameters
- mCheckFlexiblePath = getChild<LLCheckBoxCtrl>("Flexible1D Checkbox Ctrl");
- mCheckFlexiblePath->setCommitCallback(onCommitIsFlexible);
- mCheckFlexiblePath->setCallbackUserData(this);
- mSpinFlexSections = getChild<LLSpinCtrl>("FlexNumSections");
- mSpinFlexSections->setCommitCallback(onCommitFlexible);
- mSpinFlexSections->setCallbackUserData(this);
- mSpinFlexGravity = getChild<LLSpinCtrl>("FlexGravity");
- mSpinFlexGravity->setCommitCallback(onCommitFlexible);
- mSpinFlexGravity->setCallbackUserData(this);
- mSpinFlexFriction = getChild<LLSpinCtrl>("FlexFriction");
- mSpinFlexFriction->setCommitCallback(onCommitFlexible);
- mSpinFlexFriction->setCallbackUserData(this);
- mSpinFlexWind = getChild<LLSpinCtrl>("FlexWind");
- mSpinFlexWind->setCommitCallback(onCommitFlexible);
- mSpinFlexWind->setCallbackUserData(this);
- mSpinFlexTension = getChild<LLSpinCtrl>("FlexTension");
- mSpinFlexTension->setCommitCallback(onCommitFlexible);
- mSpinFlexTension->setCallbackUserData(this);
- mSpinFlexForceX = getChild<LLSpinCtrl>("FlexForceX");
- mSpinFlexForceX->setCommitCallback(onCommitFlexible);
- mSpinFlexForceX->setCallbackUserData(this);
- mSpinFlexForceY = getChild<LLSpinCtrl>("FlexForceY");
- mSpinFlexForceY->setCommitCallback(onCommitFlexible);
- mSpinFlexForceY->setCallbackUserData(this);
- mSpinFlexForceZ = getChild<LLSpinCtrl>("FlexForceZ");
- mSpinFlexForceZ->setCommitCallback(onCommitFlexible);
- mSpinFlexForceZ->setCallbackUserData(this);
- // Light parameters
- mCheckEmitLight = getChild<LLCheckBoxCtrl>("Light Checkbox Ctrl");
- mCheckEmitLight->setCommitCallback(onCommitIsLight);
- mCheckEmitLight->setCallbackUserData(this);
- mSwatchLightColor = getChild<LLColorSwatchCtrl>("colorswatch");
- mSwatchLightColor->setOnCancelCallback(onLightCancelColor);
- mSwatchLightColor->setOnSelectCallback(onLightSelectColor);
- mSwatchLightColor->setCommitCallback(onCommitLight);
- mSwatchLightColor->setCallbackUserData(this);
- mTextureLight = getChild<LLTextureCtrl>("light texture control");
- mTextureLight->setCommitCallback(onCommitLight);
- mTextureLight->setCallbackUserData(this);
- mTextureLight->setOnCancelCallback(onLightCancelTexture);
- mTextureLight->setOnSelectCallback(onLightSelectTexture);
- mTextureLight->setDragCallback(onDragTexture);
- mSpinLightIntensity = getChild<LLSpinCtrl>("Light Intensity");
- mSpinLightIntensity->setCommitCallback(onCommitLight);
- mSpinLightIntensity->setCallbackUserData(this);
- mSpinLightRadius = getChild<LLSpinCtrl>("Light Radius");
- mSpinLightRadius->setCommitCallback(onCommitLight);
- mSpinLightRadius->setCallbackUserData(this);
- mSpinLightFalloff = getChild<LLSpinCtrl>("Light Falloff");
- mSpinLightFalloff->setCommitCallback(onCommitLight);
- mSpinLightFalloff->setCallbackUserData(this);
- mSpinLightFOV = getChild<LLSpinCtrl>("Light FOV");
- mSpinLightFOV->setCommitCallback(onCommitLight);
- mSpinLightFOV->setCallbackUserData(this);
- mSpinLightFocus = getChild<LLSpinCtrl>("Light Focus");
- mSpinLightFocus->setCommitCallback(onCommitLight);
- mSpinLightFocus->setCallbackUserData(this);
- mSpinLightAmbiance = getChild<LLSpinCtrl>("Light Ambiance");
- mSpinLightAmbiance->setCommitCallback(onCommitLight);
- mSpinLightAmbiance->setCallbackUserData(this);
- // Physics parameters
- mLabelPhysicsShape = getChild<LLTextBox>("label physicsshapetype");
- // Physical checkbox
- mCheckPhysics = getChild<LLCheckBoxCtrl>("Physical Checkbox Ctrl");
- mCheckPhysics->setCommitCallback(onCommitPhysics);
- mCheckPhysics->setCallbackUserData(this);
- mComboPhysicsShape = getChild<LLComboBox>("Physics Shape Type Combo Ctrl");
- mComboPhysicsShape->setCommitCallback(sendPhysicsShapeType);
- mComboPhysicsShape->setCallbackUserData(this);
- mSpinPhysicsGravity = getChild<LLSpinCtrl>("Physics Gravity");
- mSpinPhysicsGravity->setCommitCallback(sendPhysicsGravity);
- mSpinPhysicsGravity->setCallbackUserData(this);
- mSpinPhysicsFriction = getChild<LLSpinCtrl>("Physics Friction");
- mSpinPhysicsFriction->setCommitCallback(sendPhysicsFriction);
- mSpinPhysicsFriction->setCallbackUserData(this);
- mSpinPhysicsDensity = getChild<LLSpinCtrl>("Physics Density");
- mSpinPhysicsDensity->setCommitCallback(sendPhysicsDensity);
- mSpinPhysicsDensity->setCallbackUserData(this);
- mSpinPhysicsRestitution = getChild<LLSpinCtrl>("Physics Restitution");
- mSpinPhysicsRestitution->setCommitCallback(sendPhysicsRestitution);
- mSpinPhysicsRestitution->setCallbackUserData(this);
- mPhysicsNone = getString("None");
- mPhysicsPrim = getString("Prim");
- mPhysicsHull = getString("Convex Hull");
- // Material parameters
- mFullBright = LLTrans::getString("Fullbright");
- std::map<std::string, std::string> material_name_map;
- material_name_map["Stone"]= LLTrans::getString("Stone");
- material_name_map["Metal"]= LLTrans::getString("Metal");
- material_name_map["Glass"]= LLTrans::getString("Glass");
- material_name_map["Wood"]= LLTrans::getString("Wood");
- material_name_map["Flesh"]= LLTrans::getString("Flesh");
- material_name_map["Plastic"]= LLTrans::getString("Plastic");
- material_name_map["Rubber"]= LLTrans::getString("Rubber");
- material_name_map["Light"]= LLTrans::getString("Light");
- gMaterialTable.initTableTransNames(material_name_map);
- mLabelMaterial = getChild<LLTextBox>("label material");
- mComboMaterial = getChild<LLComboBox>("material");
- childSetCommitCallback("material", onCommitMaterial, this);
- mComboMaterial->removeall();
- for (LLMaterialTable::info_list_t::const_iterator
- iter = gMaterialTable.mMaterialInfoList.begin(),
- end = gMaterialTable.mMaterialInfoList.end();
- iter != end; ++iter)
- {
- const LLMaterialInfo& minfo = *iter;
- if (minfo.mMCode != LL_MCODE_LIGHT)
- {
- mComboMaterial->add(minfo.mName);
- }
- }
- mComboMaterialItemCount = mComboMaterial->getItemCount();
- // Animated mesh/puppet parameter
- mCheckAnimatedMesh = getChild<LLCheckBoxCtrl>("AniMesh Checkbox Ctrl");
- mCheckAnimatedMesh->setCommitCallback(onCommitAnimatedMesh);
- mCheckAnimatedMesh->setCallbackUserData(this);
- // Reflection probe
- mReflectionProbe = getChild<LLButton>("reflection_probe");
- mReflectionProbe->setClickedCallback(onClickProbe, this);
- // Start with everyone disabled
- clearCtrls();
- return true;
- }
- void LLPanelVolume::getState()
- {
- HBReflectionProbe::update();
- LLObjectSelectionHandle selection = gSelectMgr.getSelection();
- LLViewerObject* objectp = selection->getFirstRootObject();
- LLViewerObject* root_objectp = objectp;
- if (!objectp)
- {
- objectp = selection->getFirstObject();
- // *FIX: should not we just keep the child ?
- if (objectp)
- {
- LLViewerObject* parentp = objectp->getRootEdit();
- root_objectp = parentp ? parentp : objectp;
- }
- }
- LLVOVolume* volobjp = NULL;
- if (objectp && objectp->getPCode() == LL_PCODE_VOLUME)
- {
- volobjp = (LLVOVolume*)objectp;
- }
- LLVOVolume* root_volobjp = NULL;
- if (root_objectp && root_objectp->getPCode() == LL_PCODE_VOLUME)
- {
- root_volobjp = (LLVOVolume*)root_objectp;
- }
- if (!objectp)
- {
- // Forfeit focus
- if (gFocusMgr.childHasKeyboardFocus(this))
- {
- gFocusMgr.setKeyboardFocus(NULL);
- }
- // Disable all text input fields
- clearCtrls();
- return;
- }
- LLUUID owner_id;
- std::string owner_name;
- gSelectMgr.selectGetOwner(owner_id, owner_name);
- // BUG ? Check for all objects being editable ?
- bool editable = root_objectp->permModify() &&
- !root_objectp->isPermanentEnforced();
- bool visible_params = (editable || gAgent.isGodlikeWithoutAdminMenuFakery());
- bool single_volume = gSelectMgr.selectionAllPCode(LL_PCODE_VOLUME) &&
- selection->getObjectCount() == 1;
- bool single_root_volume = gSelectMgr.selectionAllPCode(LL_PCODE_VOLUME) &&
- gSelectMgr.getSelection()->getRootObjectCount() == 1;
- // Select Single Message
- if (single_volume)
- {
- mLabelSelectSingle->setVisible(false);
- mLabelEditObject->setVisible(true);
- mLabelEditObject->setEnabled(true);
- }
- else
- {
- mLabelSelectSingle->setVisible(true);
- mLabelSelectSingle->setEnabled(true);
- mLabelEditObject->setVisible(false);
- }
- // Light properties
- bool is_light = volobjp && volobjp->getIsLight();
- mCheckEmitLight->setValue(is_light);
- mCheckEmitLight->setEnabled(editable && single_volume && volobjp);
- if (is_light && single_volume && visible_params)
- {
- mLightSavedColor = volobjp->getLightSRGBBaseColor();
- mSwatchLightColor->setEnabled(editable);
- mSwatchLightColor->setValid(true);
- mSwatchLightColor->set(mLightSavedColor);
- mTextureLight->setEnabled(editable);
- mTextureLight->setValid(true);
- mTextureLight->setImageAssetID(volobjp->getLightTextureID());
- LLAggregatePermissions tex_perms;
- if (gSelectMgr.selectGetAggregateTexturePermissions(tex_perms))
- {
- bool can_copy =
- tex_perms.getValue(PERM_COPY) == LLAggregatePermissions::AP_EMPTY ||
- tex_perms.getValue(PERM_COPY) == LLAggregatePermissions::AP_ALL;
- bool can_transfer =
- tex_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_EMPTY ||
- tex_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_ALL;
- mTextureLight->setCanApplyImmediately(can_copy && can_transfer);
- }
- else
- {
- mTextureLight->setCanApplyImmediately(false);
- }
- if (objectp && objectp->isAttachment())
- {
- mTextureLight->setImmediateFilterPermMask(PERM_COPY |
- PERM_TRANSFER);
- }
- else
- {
- mTextureLight->setImmediateFilterPermMask(PERM_NONE);
- }
- mSpinLightIntensity->setEnabled(editable);
- mSpinLightRadius->setEnabled(true);
- mSpinLightFalloff->setEnabled(true);
- mSpinLightFOV->setEnabled(editable);
- mSpinLightFocus->setEnabled(true);
- mSpinLightAmbiance->setEnabled(true);
- mSpinLightIntensity->setValue(volobjp->getLightIntensity());
- mSpinLightRadius->setValue(volobjp->getLightRadius());
- mSpinLightFalloff->setValue(volobjp->getLightFalloff());
- LLVector3 params = volobjp->getSpotLightParams();
- mSpinLightFOV->setValue(params.mV[0]);
- mSpinLightFocus->setValue(params.mV[1]);
- mSpinLightAmbiance->setValue(params.mV[2]);
- }
- else
- {
- mSpinLightIntensity->clear();
- mSpinLightRadius->clear();
- mSpinLightFalloff->clear();
- mSwatchLightColor->setEnabled(false);
- mSwatchLightColor->setValid(false);
- mTextureLight->setEnabled(false);
- mTextureLight->setValid(false);
- mSpinLightIntensity->setEnabled(false);
- mSpinLightRadius->setEnabled(false);
- mSpinLightFalloff->setEnabled(false);
- mSpinLightFOV->setEnabled(false);
- mSpinLightFocus->setEnabled(false);
- mSpinLightAmbiance->setEnabled(false);
- }
- // Animated mesh property
- bool is_animated_mesh = single_root_volume && root_volobjp &&
- root_volobjp->isAnimatedObject();
- mCheckAnimatedMesh->setValue(is_animated_mesh);
- bool enabled_animated_mesh = false;
- if (editable && single_root_volume && root_volobjp &&
- root_volobjp == volobjp)
- {
- enabled_animated_mesh = root_volobjp->canBeAnimatedObject();
- if (enabled_animated_mesh && !is_animated_mesh &&
- root_volobjp->isAttachment())
- {
- enabled_animated_mesh =
- isAgentAvatarValid() &&
- gAgentAvatarp->canAttachMoreAnimatedObjects();
- }
- }
- mCheckAnimatedMesh->setEnabled(enabled_animated_mesh);
- // Refresh any bake on mesh texture
- if (root_volobjp)
- {
- root_volobjp->refreshBakeTexture();
- LLViewerObject::const_child_list_t& child_list =
- root_volobjp->getChildren();
- for (LLViewerObject::child_list_t::const_iterator
- it = child_list.begin(), end = child_list.end();
- it != end; ++it)
- {
- LLViewerObject* childp = *it;
- if (childp)
- {
- childp->refreshBakeTexture();
- }
- }
- if (isAgentAvatarValid())
- {
- gAgentAvatarp->updateMeshVisibility();
- }
- }
- // Flexible properties
- bool is_flexible = volobjp && volobjp->isFlexible();
- mCheckFlexiblePath->setValue(is_flexible);
- if (is_flexible || (volobjp && volobjp->canBeFlexible()))
- {
- mCheckFlexiblePath->setEnabled(editable && single_volume && volobjp &&
- !volobjp->isMesh() &&
- !objectp->isPermanentEnforced());
- }
- else
- {
- mCheckFlexiblePath->setEnabled(false);
- }
- if (is_flexible && single_volume && visible_params)
- {
- mSpinFlexSections->setVisible(true);
- mSpinFlexGravity->setVisible(true);
- mSpinFlexFriction->setVisible(true);
- mSpinFlexWind->setVisible(true);
- mSpinFlexTension->setVisible(true);
- mSpinFlexForceX->setVisible(true);
- mSpinFlexForceY->setVisible(true);
- mSpinFlexForceZ->setVisible(true);
- mSpinFlexSections->setEnabled(editable);
- mSpinFlexGravity->setEnabled(editable);
- mSpinFlexFriction->setEnabled(editable);
- mSpinFlexWind->setEnabled(editable);
- mSpinFlexTension->setEnabled(editable);
- mSpinFlexForceX->setEnabled(editable);
- mSpinFlexForceY->setEnabled(editable);
- mSpinFlexForceZ->setEnabled(editable);
- const LLFlexibleObjectData* params = objectp->getFlexibleObjectData();
- mSpinFlexSections->setValue((F32)params->getSimulateLOD());
- mSpinFlexGravity->setValue(params->getGravity());
- mSpinFlexFriction->setValue(params->getAirFriction());
- mSpinFlexWind->setValue(params->getWindSensitivity());
- mSpinFlexTension->setValue(params->getTension());
- mSpinFlexForceX->setValue(params->getUserForce().mV[VX]);
- mSpinFlexForceY->setValue(params->getUserForce().mV[VY]);
- mSpinFlexForceZ->setValue(params->getUserForce().mV[VZ]);
- }
- else
- {
- mSpinFlexSections->clear();
- mSpinFlexGravity->clear();
- mSpinFlexFriction->clear();
- mSpinFlexWind->clear();
- mSpinFlexTension->clear();
- mSpinFlexForceX->clear();
- mSpinFlexForceY->clear();
- mSpinFlexForceZ->clear();
- mSpinFlexSections->setEnabled(false);
- mSpinFlexGravity->setEnabled(false);
- mSpinFlexFriction->setEnabled(false);
- mSpinFlexWind->setEnabled(false);
- mSpinFlexTension->setEnabled(false);
- mSpinFlexForceX->setEnabled(false);
- mSpinFlexForceY->setEnabled(false);
- mSpinFlexForceZ->setEnabled(false);
- }
- // Material properties
- // Update material part
- // slightly inefficient - materials are unique per object, not per TE
- U8 mcode = 0;
- struct f : public LLSelectedTEGetFunctor<U8>
- {
- U8 get(LLViewerObject* object, S32 te)
- {
- return object->getMaterial();
- }
- } func;
- bool material_same = selection->getSelectedTEValue(&func, mcode);
- if (single_volume && material_same && visible_params)
- {
- mComboMaterial->setEnabled(editable);
- mLabelMaterial->setEnabled(editable);
- if (mcode == LL_MCODE_LIGHT)
- {
- if (mComboMaterial->getItemCount() == mComboMaterialItemCount)
- {
- mComboMaterial->add(mFullBright);
- }
- mComboMaterial->setSimple(mFullBright);
- }
- else
- {
- if (mComboMaterial->getItemCount() != mComboMaterialItemCount)
- {
- mComboMaterial->remove(mFullBright);
- }
- // *TODO:Translate
- mComboMaterial->setSimple(gMaterialTable.getName(mcode));
- }
- }
- else
- {
- mComboMaterial->setEnabled(false);
- mLabelMaterial->setEnabled(false);
- }
- // Physics properties
- mIsPhysical = root_objectp && root_objectp->flagUsePhysics();
- // Physics checkbox
- mCheckPhysics->set(mIsPhysical);
- bool is_permanent = root_objectp->flagObjectPermanent();
- if (is_permanent && mIsPhysical)
- {
- // *TODO: Pop up a one-time warning with object details
- llwarns_sparse << "PATHFINDING BUG: editing a Permanent object that is also Physical !"
- << llendl;
- }
- bool enable_physics = !is_flexible && !is_permanent &&
- selection->getRootObjectCount();
- mCheckPhysics->setEnabled(enable_physics &&
- (editable || gAgent.isGodlike()));
- if (mIsPhysical && enable_physics && visible_params)
- {
- mSpinPhysicsGravity->setValue(objectp->getPhysicsGravity());
- mSpinPhysicsGravity->setEnabled(editable);
- mSpinPhysicsFriction->setValue(objectp->getPhysicsFriction());
- mSpinPhysicsFriction->setEnabled(editable);
- mSpinPhysicsDensity->setValue(objectp->getPhysicsDensity());
- mSpinPhysicsDensity->setEnabled(editable);
- mSpinPhysicsRestitution->setValue(objectp->getPhysicsRestitution());
- mSpinPhysicsRestitution->setEnabled(editable);
- }
- else
- {
- mSpinPhysicsGravity->clear();
- mSpinPhysicsGravity->setEnabled(false);
- mSpinPhysicsFriction->clear();
- mSpinPhysicsFriction->setEnabled(false);
- mSpinPhysicsDensity->clear();
- mSpinPhysicsDensity->setEnabled(false);
- mSpinPhysicsRestitution->clear();
- mSpinPhysicsRestitution->setEnabled(false);
- }
- // Update the physics shape combo to include allowed physics shapes
- mComboPhysicsShape->removeall();
- mComboPhysicsShape->add(mPhysicsNone, LLSD(1));
- bool is_mesh = false;
- if (objectp)
- {
- const LLSculptParams* sculpt_paramsp = objectp->getSculptParams();
- is_mesh = sculpt_paramsp &&
- (sculpt_paramsp->getSculptType() &
- LL_SCULPT_TYPE_MASK) == LL_SCULPT_TYPE_MESH;
- }
- if (is_mesh)
- {
- const LLVolumeParams& volume_params =
- objectp->getVolume()->getParams();
- const LLUUID& mesh_id = volume_params.getSculptID();
- if (gMeshRepo.hasPhysicsShape(mesh_id))
- {
- // If a mesh contains an uploaded or decomposed physics mesh,
- // allow 'Prim'
- mComboPhysicsShape->add(mPhysicsPrim, LLSD(0));
- }
- }
- else
- {
- // Simple prims always allow physics shape prim
- mComboPhysicsShape->add(mPhysicsPrim, LLSD(0));
- }
- mComboPhysicsShape->add(mPhysicsHull, LLSD(2));
- mComboPhysicsShape->setValue(LLSD(objectp->getPhysicsShapeType()));
- bool enabled = editable && !objectp->isPermanentEnforced() &&
- (!root_objectp || !root_objectp->isPermanentEnforced());
- mComboPhysicsShape->setEnabled(enabled);
- mLabelPhysicsShape->setEnabled(enabled);
- mReflectionProbe->setEnabled(single_volume && enabled &&
- volobjp && !volobjp->isMesh() &&
- gAgent.hasInventoryMaterial());
- mObject = objectp;
- mRootObject = root_objectp;
- }
- void LLPanelVolume::refresh()
- {
- getState();
- if (mObject.notNull() && mObject->isDead())
- {
- mObject = NULL;
- }
- if (mRootObject.notNull() && mRootObject->isDead())
- {
- mRootObject = NULL;
- }
- bool enable_physics = false;
- LLSD sim_features;
- LLViewerRegion* region = gAgent.getRegion();
- if (region)
- {
- enable_physics = region->physicsShapeTypes();
- }
- mLabelPhysicsShape->setVisible(enable_physics);
- mComboPhysicsShape->setVisible(enable_physics);
- mSpinPhysicsGravity->setVisible(enable_physics);
- mSpinPhysicsFriction->setVisible(enable_physics);
- mSpinPhysicsDensity->setVisible(enable_physics);
- mSpinPhysicsRestitution->setVisible(enable_physics);
- // *TODO: add/remove individual physics shape types as per the
- // PhysicsShapeTypes simulator features
- }
- // virtual
- void LLPanelVolume::clearCtrls()
- {
- LLPanel::clearCtrls();
- mLabelSelectSingle->setEnabled(false);
- mLabelSelectSingle->setVisible(true);
- mLabelEditObject->setEnabled(false);
- mLabelEditObject->setVisible(false);
- mCheckEmitLight->setEnabled(false);
- mSwatchLightColor->setEnabled(false);
- mSwatchLightColor->setValid(false);
- mTextureLight->setEnabled(false);
- mTextureLight->setValid(false);
- mSpinLightIntensity->setEnabled(false);
- mSpinLightRadius->setEnabled(false);
- mSpinLightFalloff->setEnabled(false);
- mSpinLightFOV->setEnabled(false);
- mSpinLightFocus->setEnabled(false);
- mSpinLightAmbiance->setEnabled(false);
- mCheckFlexiblePath->setEnabled(false);
- mSpinFlexSections->setEnabled(false);
- mSpinFlexGravity->setEnabled(false);
- mSpinFlexFriction->setEnabled(false);
- mSpinFlexWind->setEnabled(false);
- mSpinFlexTension->setEnabled(false);
- mSpinFlexForceX->setEnabled(false);
- mSpinFlexForceY->setEnabled(false);
- mSpinFlexForceZ->setEnabled(false);
- mCheckPhysics->set(false);
- mSpinPhysicsGravity->setEnabled(false);
- mSpinPhysicsFriction->setEnabled(false);
- mSpinPhysicsDensity->setEnabled(false);
- mSpinPhysicsRestitution->setEnabled(false);
- mComboMaterial->setEnabled(false);
- mLabelMaterial->setEnabled(false);
- mCheckAnimatedMesh->setEnabled(false);
- }
- //
- // Static functions
- //
- void LLPanelVolume::sendIsLight()
- {
- LLViewerObject* objectp = mObject;
- if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
- {
- return;
- }
- LLVOVolume* volobjp = (LLVOVolume*)objectp;
- bool value = mCheckEmitLight->getValue();
- 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 = mCheckFlexiblePath->getValue();
- if (is_flexible && objectp->getClickAction() == CLICK_ACTION_SIT)
- {
- gSelectMgr.selectionSetClickAction(CLICK_ACTION_NONE);
- }
- if (volobjp->setIsFlexible(is_flexible))
- {
- mObject->sendShapeUpdate();
- gSelectMgr.selectionUpdatePhantom(volobjp->flagPhantom());
- }
- llinfos << "update flexible sent" << llendl;
- }
- void LLPanelVolume::sendIsPhysical()
- {
- bool value = mCheckPhysics->get();
- if (mIsPhysical != value)
- {
- gSelectMgr.selectionUpdatePhysics(value);
- mIsPhysical = value;
- llinfos << "Update physics sent" << llendl;
- }
- }
- //static
- void LLPanelVolume::onCommitPhysics(LLUICtrl* ctrl, void* userdata)
- {
- LLPanelVolume* self = (LLPanelVolume*)userdata;
- if (self)
- {
- self->sendIsPhysical();
- }
- }
- //static
- void LLPanelVolume::sendPhysicsShapeType(LLUICtrl* ctrl, void* userdata)
- {
- LLPanelVolume* self = (LLPanelVolume*) userdata;
- if (!self || !ctrl) return;
- U8 type = ctrl->getValue().asInteger();
- gSelectMgr.selectionSetPhysicsType(type);
- self->refreshCost();
- }
- //static
- void LLPanelVolume::sendPhysicsGravity(LLUICtrl* ctrl, void* userdata)
- {
- F32 val = ctrl->getValue().asReal();
- gSelectMgr.selectionSetGravity(val);
- }
- //static
- void LLPanelVolume::sendPhysicsFriction(LLUICtrl* ctrl, void* userdata)
- {
- F32 val = ctrl->getValue().asReal();
- gSelectMgr.selectionSetFriction(val);
- }
- //static
- void LLPanelVolume::sendPhysicsRestitution(LLUICtrl* ctrl, void* userdata)
- {
- F32 val = ctrl->getValue().asReal();
- gSelectMgr.selectionSetRestitution(val);
- }
- //static
- void LLPanelVolume::sendPhysicsDensity(LLUICtrl* ctrl, void* userdata)
- {
- F32 val = ctrl->getValue().asReal();
- gSelectMgr.selectionSetDensity(val);
- }
- //static
- void LLPanelVolume::refreshCost()
- {
- LLViewerObject* obj = gSelectMgr.getSelection()->getFirstObject();
- if (obj)
- {
- obj->getObjectCost();
- }
- }
- void LLPanelVolume::onLightCancelColor(LLUICtrl* ctrl, void* userdata)
- {
- LLPanelVolume* self = (LLPanelVolume*)userdata;
- if (self)
- {
- self->mSwatchLightColor->setColor(self->mLightSavedColor);
- onLightSelectColor(NULL, userdata);
- }
- }
- void LLPanelVolume::onLightCancelTexture(LLUICtrl* ctrl, void* userdata)
- {
- LLPanelVolume* self = (LLPanelVolume*)userdata;
- if (self)
- {
- self->mTextureLight->setImageAssetID(self->mLightSavedTexture);
- }
- }
- void LLPanelVolume::onLightSelectColor(LLUICtrl* ctrl, void* userdata)
- {
- LLPanelVolume* self = (LLPanelVolume*)userdata;
- if (!self || !self->mObject ||
- self->mObject->getPCode() != LL_PCODE_VOLUME)
- {
- return;
- }
- LLVOVolume* volobjp = (LLVOVolume*)self->mObject.get();
- if (!volobjp) return;
- LLColor4 clr = self->mSwatchLightColor->get();
- LLColor3 clr3(clr);
- volobjp->setLightSRGBColor(clr3);
- self->mLightSavedColor = clr;
- }
- void LLPanelVolume::onLightSelectTexture(LLUICtrl* ctrl, void* userdata)
- {
- LLPanelVolume* self = (LLPanelVolume*)userdata;
- if (!self || !self->mObject ||
- self->mObject->getPCode() != LL_PCODE_VOLUME)
- {
- return;
- }
- LLVOVolume* volobjp = (LLVOVolume*)self->mObject.get();
- if (!volobjp) return;
- LLUUID id = self->mTextureLight->getImageAssetID();
- volobjp->setLightTextureID(id);
- self->mLightSavedTexture = id;
- }
- //static
- bool LLPanelVolume::onDragTexture(LLUICtrl* ctrl, LLInventoryItem* item,
- void* userdata)
- {
- bool accept = true;
- for (LLObjectSelection::root_iterator
- iter = gSelectMgr.getSelection()->root_begin(),
- end = gSelectMgr.getSelection()->root_end();
- iter != end; ++iter)
- {
- LLSelectNode* node = *iter;
- LLViewerObject* obj = node->getObject();
- if (!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item))
- {
- accept = false;
- break;
- }
- }
- return accept;
- }
- //static
- void LLPanelVolume::onCommitMaterial(LLUICtrl* ctrl, void* userdata)
- {
- if (!userdata || !ctrl)
- {
- return;
- }
- LLPanelVolume* self = (LLPanelVolume*)userdata;
- LLComboBox* combop = (LLComboBox*)ctrl;
- const std::string& material_name = combop->getSimple();
- if (material_name == self->mFullBright)
- {
- return;
- }
- // Apply the currently selected material to the object
- U8 mcode = gMaterialTable.getMCode(material_name);
- LLViewerObject* objectp = self->mObject;
- if (objectp)
- {
- objectp->setPhysicsGravity(DEFAULT_GRAVITY_MULTIPLIER);
- objectp->setPhysicsFriction(gMaterialTable.getFriction(mcode));
- // Currently density is always set to 1000 server side regardless of
- // chosen material, actual material density should be used here, if
- // this behavior changes.
- objectp->setPhysicsDensity(DEFAULT_DENSITY);
- objectp->setPhysicsRestitution(gMaterialTable.getRestitution(mcode));
- }
- gSelectMgr.selectionSetMaterial(mcode);
- }
- //static
- void LLPanelVolume::onCommitLight(LLUICtrl* ctrl, void* userdata)
- {
- LLPanelVolume* self = (LLPanelVolume*)userdata;
- if (!self || !self->mObject ||
- self->mObject->getPCode() != LL_PCODE_VOLUME)
- {
- return;
- }
- LLVOVolume* volobjp = (LLVOVolume*)self->mObject.get();
- if (!volobjp) return;
- volobjp->setLightIntensity((F32)self->mSpinLightIntensity->getValue().asReal());
- volobjp->setLightRadius((F32)self->mSpinLightRadius->getValue().asReal());
- volobjp->setLightFalloff((F32)self->mSpinLightFalloff->getValue().asReal());
- LLColor4 clr = self->mSwatchLightColor->get();
- volobjp->setLightSRGBColor(LLColor3(clr));
- LLUUID id = self->mTextureLight->getImageAssetID();
- if (id.notNull())
- {
- if (!volobjp->isLightSpotlight())
- {
- // This commit is making this a spot light; set UI to
- // default params
- volobjp->setLightTextureID(id);
- LLVector3 spot_params = volobjp->getSpotLightParams();
- self->mSpinLightFOV->setValue(spot_params.mV[0]);
- self->mSpinLightFocus->setValue(spot_params.mV[1]);
- self->mSpinLightAmbiance->setValue(spot_params.mV[2]);
- }
- else
- {
- // Modifying existing params
- LLVector3 spot_params;
- spot_params.mV[0] = (F32)self->mSpinLightFOV->getValue().asReal();
- spot_params.mV[1] =
- (F32)self->mSpinLightFocus->getValue().asReal();
- spot_params.mV[2] =
- (F32)self->mSpinLightAmbiance->getValue().asReal();
- volobjp->setSpotLightParams(spot_params);
- }
- }
- else if (volobjp->isLightSpotlight())
- {
- // No longer a spot light
- volobjp->setLightTextureID(id);
- #if 0
- self->mSpinLightFOV->setEnabled(false);
- self->mSpinLightFocus->setEnabled(false);
- self->mSpinLightAmbiance->setEnabled(false);
- #endif
- }
- }
- //static
- void LLPanelVolume::onCommitIsLight(LLUICtrl* ctrl, void* userdata)
- {
- LLPanelVolume* self = (LLPanelVolume*)userdata;
- if (self)
- {
- self->sendIsLight();
- }
- }
- //static
- void LLPanelVolume::onCommitFlexible(LLUICtrl* ctrl, void* userdata)
- {
- LLPanelVolume* self = (LLPanelVolume*)userdata;
- if (!self) return;
- LLViewerObject* objectp = self->mObject;
- if (!objectp || objectp->getPCode() != LL_PCODE_VOLUME)
- {
- return;
- }
- const LLFlexibleObjectData* params = objectp->getFlexibleObjectData();
- if (params)
- {
- LLFlexibleObjectData new_params(*params);
- new_params.setSimulateLOD(self->mSpinFlexSections->getValue().asInteger());
- new_params.setGravity((F32)self->mSpinFlexGravity->getValue().asReal());
- new_params.setAirFriction((F32)self->mSpinFlexFriction->getValue().asReal());
- new_params.setWindSensitivity((F32)self->mSpinFlexWind->getValue().asReal());
- new_params.setTension((F32)self->mSpinFlexTension->getValue().asReal());
- F32 fx = (F32)self->mSpinFlexForceX->getValue().asReal();
- F32 fy = (F32)self->mSpinFlexForceY->getValue().asReal();
- F32 fz = (F32)self->mSpinFlexForceZ->getValue().asReal();
- LLVector3 force(fx, fy, fz);
- new_params.setUserForce(force);
- objectp->setParameterEntry(LLNetworkData::PARAMS_FLEXIBLE, new_params, true);
- }
- // Values may fail validation
- self->refresh();
- }
- bool handleResponseChangeToFlexible(const LLSD& notification,
- const LLSD& response,
- LLPanelVolume* self)
- {
- S32 option = LLNotification::getSelectedOption(notification, response);
- if (self && option == 0)
- {
- self->sendIsFlexible();
- }
- return false;
- }
- //static
- void LLPanelVolume::onCommitIsFlexible(LLUICtrl* ctrl, void* userdata)
- {
- LLPanelVolume* self = (LLPanelVolume*)userdata;
- if (self && self->mObject)
- {
- if (self->mObject->flagObjectPermanent())
- {
- gNotifications.add("ChangeToFlexiblePath", LLSD(), LLSD(),
- boost::bind(handleResponseChangeToFlexible,
- _1, _2, self));
- }
- else
- {
- self->sendIsFlexible();
- }
- }
- }
- //static
- void LLPanelVolume::onCommitAnimatedMesh(LLUICtrl* ctrl, void* userdata)
- {
- LLPanelVolume* self = (LLPanelVolume*)userdata;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (!self || !check) return;
- LLViewerObject* objectp = self->mObject;
- if (!objectp || objectp->getPCode() != LL_PCODE_VOLUME)
- {
- return;
- }
- LLVOVolume* volobjp = (LLVOVolume*)objectp;
- U32 flags = volobjp->getExtendedMeshFlags();
- U32 new_flags = flags;
- if (check->get())
- {
- new_flags |= LLExtendedMeshParams::ANIMATED_MESH_ENABLED_FLAG;
- }
- else
- {
- new_flags &= ~LLExtendedMeshParams::ANIMATED_MESH_ENABLED_FLAG;
- }
- if (new_flags != flags)
- {
- volobjp->setExtendedMeshFlags(new_flags);
- }
- // Refresh any bake on mesh texture
- volobjp->refreshBakeTexture();
- LLViewerObject::const_child_list_t& child_list = volobjp->getChildren();
- for (LLViewerObject::child_list_t::const_iterator
- it = child_list.begin(), end = child_list.end();
- it != end; ++it)
- {
- LLViewerObject* childp = *it;
- if (childp)
- {
- childp->refreshBakeTexture();
- }
- }
- if (isAgentAvatarValid())
- {
- gAgentAvatarp->updateMeshVisibility();
- }
- }
- //static
- void LLPanelVolume::onClickProbe(void* userdata)
- {
- HBReflectionProbe::show((LLView*)userdata);
- }
|