diff options
Diffstat (limited to 'indra/newview/llpanelvolume.cpp')
-rw-r--r-- | indra/newview/llpanelvolume.cpp | 167 |
1 files changed, 166 insertions, 1 deletions
diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 39f4c7485b..0cbc2b0bad 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -48,6 +48,7 @@ #include "lltexturectrl.h" #include "llcombobox.h" //#include "llfirstuse.h" +#include "llfloaterreg.h" #include "llfocusmgr.h" #include "llmanipscale.h" #include "llinventorymodel.h" @@ -146,6 +147,15 @@ BOOL LLPanelVolume::postBuild() getChild<LLUICtrl>("Light Ambiance")->setValidateBeforeCommit( precommitValidate); } + // REFLECTION PROBE Parameters + { + childSetCommitCallback("Reflection Probe", onCommitIsReflectionProbe, this); + childSetCommitCallback("Probe Dynamic", onCommitProbe, this); + childSetCommitCallback("Probe Volume Type", onCommitProbe, this); + childSetCommitCallback("Probe Ambiance", onCommitProbe, this); + childSetCommitCallback("Probe Near Clip", onCommitProbe, this); + } + // PHYSICS Parameters { // PhysicsShapeType combobox @@ -366,6 +376,43 @@ void LLPanelVolume::getState( ) getChildView("Light Ambiance")->setEnabled(false); } + // Reflection Probe + BOOL is_probe = volobjp && volobjp->isReflectionProbe(); + getChild<LLUICtrl>("Reflection Probe")->setValue(is_probe); + getChildView("Reflection Probe")->setEnabled(editable && single_volume && volobjp && !volobjp->isMesh()); + + bool probe_enabled = is_probe && editable && single_volume; + + getChildView("Probe Dynamic")->setEnabled(probe_enabled); + getChildView("Probe Volume Type")->setEnabled(probe_enabled); + getChildView("Probe Ambiance")->setEnabled(probe_enabled); + getChildView("Probe Near Clip")->setEnabled(probe_enabled); + + if (!probe_enabled) + { + getChild<LLComboBox>("Probe Volume Type", true)->clear(); + getChild<LLSpinCtrl>("Probe Ambiance", true)->clear(); + getChild<LLSpinCtrl>("Probe Near Clip", true)->clear(); + getChild<LLCheckBoxCtrl>("Probe Dynamic", true)->clear(); + } + else + { + std::string volume_type; + if (volobjp->getReflectionProbeIsBox()) + { + volume_type = "Box"; + } + else + { + volume_type = "Sphere"; + } + + getChild<LLComboBox>("Probe Volume Type", true)->setValue(volume_type); + getChild<LLSpinCtrl>("Probe Ambiance", true)->setValue(volobjp->getReflectionProbeAmbiance()); + getChild<LLSpinCtrl>("Probe Near Clip", true)->setValue(volobjp->getReflectionProbeNearClip()); + getChild<LLCheckBoxCtrl>("Probe Dynamic", true)->setValue(volobjp->getReflectionProbeIsDynamic()); + } + // Animated Mesh BOOL is_animated_mesh = single_root_volume && root_volobjp && root_volobjp->isAnimatedObject(); getChild<LLUICtrl>("Animated Mesh Checkbox Ctrl")->setValue(is_animated_mesh); @@ -648,6 +695,11 @@ void LLPanelVolume::clearCtrls() getChildView("Light Radius")->setEnabled(false); getChildView("Light Falloff")->setEnabled(false); + getChildView("Reflection Probe")->setEnabled(false);; + getChildView("Probe Volume Type")->setEnabled(false); + getChildView("Probe Dynamic")->setEnabled(false); + getChildView("Probe Ambiance")->setEnabled(false); + getChildView("Probe Near Clip")->setEnabled(false); getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(false); getChildView("Flexible1D Checkbox Ctrl")->setEnabled(false); getChildView("FlexNumSections")->setEnabled(false); @@ -685,6 +737,42 @@ void LLPanelVolume::sendIsLight() LL_INFOS() << "update light sent" << LL_ENDL; } +void LLPanelVolume::sendIsReflectionProbe() +{ + LLViewerObject* objectp = mObject; + if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME)) + { + return; + } + LLVOVolume* volobjp = (LLVOVolume*)objectp; + + BOOL value = getChild<LLUICtrl>("Reflection Probe")->getValue(); + BOOL old_value = volobjp->isReflectionProbe(); + + volobjp->setIsReflectionProbe(value); + LL_INFOS() << "update reflection probe sent" << LL_ENDL; + + if (value && !old_value) + { // has become a reflection probe, slam to a 10m sphere and pop up a message + // warning people about the pitfalls of reflection probes + auto* select_mgr = LLSelectMgr::getInstance(); + + mObject->setScale(LLVector3(10.f, 10.f, 10.f)); + select_mgr->sendMultipleUpdate(UPD_ROTATION | UPD_POSITION | UPD_SCALE); + + select_mgr->selectionUpdatePhantom(true); + select_mgr->selectionSetGLTFMaterial(LLUUID::null); + select_mgr->selectionSetAlphaOnly(0.f); + + LLVolumeParams params; + params.getPathParams().setCurveType(LL_PCODE_PATH_CIRCLE); + params.getProfileParams().setCurveType(LL_PCODE_PROFILE_CIRCLE_HALF); + mObject->updateVolume(params); + + LLNotificationsUtil::add("ReflectionProbeApplied"); + } +} + void LLPanelVolume::sendIsFlexible() { LLViewerObject* objectp = mObject; @@ -1026,6 +1114,14 @@ void LLPanelVolume::onCopyLight() } } + if (volobjp && volobjp->isReflectionProbe()) + { + clipboard["reflection_probe"]["is_box"] = volobjp->getReflectionProbeIsBox(); + clipboard["reflection_probe"]["ambiance"] = volobjp->getReflectionProbeAmbiance(); + clipboard["reflection_probe"]["near_clip"] = volobjp->getReflectionProbeNearClip(); + clipboard["reflection_probe"]["dynamic"] = volobjp->getReflectionProbeIsDynamic(); + } + mClipboardParams["light"] = clipboard; } @@ -1073,6 +1169,19 @@ void LLPanelVolume::onPasteLight() spot_params.mV[2] = (F32)clipboard["spot"]["ambiance"].asReal(); volobjp->setSpotLightParams(spot_params); } + + if (clipboard.has("reflection_probe")) + { + volobjp->setIsReflectionProbe(TRUE); + volobjp->setReflectionProbeIsBox(clipboard["reflection_probe"]["is_box"].asBoolean()); + volobjp->setReflectionProbeAmbiance((F32)clipboard["reflection_probe"]["ambiance"].asReal()); + volobjp->setReflectionProbeNearClip((F32)clipboard["reflection_probe"]["near_clip"].asReal()); + volobjp->setReflectionProbeIsDynamic(clipboard["reflection_probe"]["dynamic"].asBoolean()); + } + else + { + volobjp->setIsReflectionProbe(false); + } } } @@ -1212,6 +1321,53 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata ) } +//static +void LLPanelVolume::onCommitProbe(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->setReflectionProbeAmbiance((F32)self->getChild<LLUICtrl>("Probe Ambiance")->getValue().asReal()); + volobjp->setReflectionProbeNearClip((F32)self->getChild<LLUICtrl>("Probe Near Clip")->getValue().asReal()); + volobjp->setReflectionProbeIsDynamic(self->getChild<LLUICtrl>("Probe Dynamic")->getValue().asBoolean()); + + std::string shape_type = self->getChild<LLUICtrl>("Probe Volume Type")->getValue().asString(); + + bool is_box = shape_type == "Box"; + + if (volobjp->setReflectionProbeIsBox(is_box)) + { + // make the volume match the probe + U8 profile, path; + + if (!is_box) + { + profile = LL_PCODE_PROFILE_CIRCLE_HALF; + path = LL_PCODE_PATH_CIRCLE; + + F32 scale = volobjp->getScale().mV[0]; + volobjp->setScale(LLVector3(scale, scale, scale), FALSE); + LLSelectMgr::getInstance()->sendMultipleUpdate(UPD_ROTATION | UPD_POSITION | UPD_SCALE); + } + else + { + profile = LL_PCODE_PROFILE_SQUARE; + path = LL_PCODE_PATH_LINE; + } + + LLVolumeParams params; + params.getProfileParams().setCurveType(profile); + params.getPathParams().setCurveType(path); + objectp->updateVolume(params); + } + +} + // static void LLPanelVolume::onCommitIsLight( LLUICtrl* ctrl, void* userdata ) { @@ -1227,7 +1383,7 @@ void LLPanelVolume::setLightTextureID(const LLUUID &asset_id, const LLUUID &item LLViewerInventoryItem* item = gInventory.getItem(item_id); if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) { - LLToolDragAndDrop::handleDropTextureProtections(volobjp, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); + LLToolDragAndDrop::handleDropMaterialProtections(volobjp, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } volobjp->setLightTextureID(asset_id); } @@ -1235,6 +1391,15 @@ void LLPanelVolume::setLightTextureID(const LLUUID &asset_id, const LLUUID &item //---------------------------------------------------------------------------- // static +void LLPanelVolume::onCommitIsReflectionProbe(LLUICtrl* ctrl, void* userdata) +{ + LLPanelVolume* self = (LLPanelVolume*)userdata; + self->sendIsReflectionProbe(); +} + +//---------------------------------------------------------------------------- + +// static void LLPanelVolume::onCommitFlexible( LLUICtrl* ctrl, void* userdata ) { LLPanelVolume* self = (LLPanelVolume*) userdata; |