A bit of rearchitecture so that we can have edit wearables that don't have associated snapshots. Needed to support physics wearables, which don't use a snapshot.

meow-7.2.2
Loren Shih 2011-03-29 20:57:17 -04:00
parent 6ba971982e
commit 4773f49afb
8 changed files with 236 additions and 60 deletions

View File

@ -401,6 +401,7 @@ set(viewer_SOURCE_FILES
llscreenchannel.cpp
llscriptfloater.cpp
llscrollingpanelparam.cpp
llscrollingpanelparambase.cpp
llsearchcombobox.cpp
llsearchhistory.cpp
llsecapi.cpp
@ -938,6 +939,7 @@ set(viewer_HEADER_FILES
llscreenchannel.h
llscriptfloater.h
llscrollingpanelparam.h
llscrollingpanelparambase.h
llsearchcombobox.h
llsearchhistory.h
llsecapi.h

View File

@ -1415,7 +1415,16 @@ void LLPanelEditWearable::buildParamList(LLScrollingPanelList *panel_list, value
{
LLPanel::Params p;
p.name("LLScrollingPanelParam");
LLScrollingPanelParam* panel_param = new LLScrollingPanelParam( p, NULL, (*it).second, TRUE, this->getWearable(), jointp);
LLWearable *wearable = this->getWearable();
LLScrollingPanelParamBase *panel_param = NULL;
if (wearable && wearable->getType() == LLWearableType::WT_PHYSICS) // Hack to show a different panel for physics. Should generalize this later.
{
panel_param = new LLScrollingPanelParamBase( p, NULL, (*it).second, TRUE, this->getWearable(), jointp);
}
else
{
panel_param = new LLScrollingPanelParam( p, NULL, (*it).second, TRUE, this->getWearable(), jointp);
}
height = panel_list->addPanel( panel_param );
}
}

View File

@ -448,8 +448,16 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
const F32 behavior_spring = getParamValue("Spring");
const F32 behavior_gain = getParamValue("Gain");
const F32 behavior_damping = getParamValue("Damping");
const F32 behavior_maxspeed = getParamValue("MaxSpeed");
const F32 behavior_drag = getParamValue("Drag");
const BOOL physics_test = gSavedSettings.getBOOL("AvatarPhysicsTest");
F32 behavior_maxspeed = getParamValue("MaxSpeed");
if (physics_test)
behavior_maxspeed = 100.0f;
/*
if (behavior_maxspeed == 0)
return FALSE;
*/
F32 position_current_local = mPosition_local; // Normalized [0,1] range
@ -526,9 +534,9 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
-behavior_maxspeed, behavior_maxspeed);
// Temporary debugging setting to cause all avatars to move, for profiling purposes.
if (gSavedSettings.getBOOL("AvatarPhysicsTest"))
if (physics_test)
{
velocity_new_local = sin(time*4.0)*5.0;
velocity_new_local = sin(time*4.0);
}
// Calculate the new parameters, or remain unchanged if max speed is 0.
const F32 position_new_local = (behavior_maxspeed != 0) ?

View File

@ -50,14 +50,9 @@ const S32 LLScrollingPanelParam::PARAM_HINT_HEIGHT = 128;
S32 LLScrollingPanelParam::sUpdateDelayFrames = 0;
LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_params,
LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp )
: LLScrollingPanel( panel_params ),
mParam(param),
mAllowModify(allow_modify),
mWearable(wearable)
LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp, BOOL use_hints )
: LLScrollingPanelParamBase( panel_params, mesh, param, allow_modify, wearable, jointp, use_hints)
{
buildFromFile( "panel_scrolling_param.xml");
// *HACK To avoid hard coding texture position, lets use border's position for texture.
LLViewBorder* left_border = getChild<LLViewBorder>("left_border");
@ -73,17 +68,6 @@ LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_param
mHintMin->setAllowsUpdates( FALSE );
mHintMax->setAllowsUpdates( FALSE );
getChild<LLUICtrl>("param slider")->setValue(weightToPercent(param->getWeight()));
std::string display_name = LLTrans::getString(param->getDisplayName());
getChild<LLUICtrl>("param slider")->setLabelArg("[DESC]", display_name);
getChildView("param slider")->setEnabled(mAllowModify);
childSetCommitCallback("param slider", LLScrollingPanelParam::onSliderMoved, this);
std::string min_name = LLTrans::getString(param->getMinDisplayName());
std::string max_name = LLTrans::getString(param->getMaxDisplayName());
getChild<LLUICtrl>("min param text")->setValue(min_name);
getChild<LLUICtrl>("max param text")->setValue(max_name);
LLButton* less = getChild<LLButton>("less");
if (less)
@ -112,20 +96,15 @@ LLScrollingPanelParam::~LLScrollingPanelParam()
}
void LLScrollingPanelParam::updatePanel(BOOL allow_modify)
{
LLViewerVisualParam* param = mHintMin->getVisualParam();
if (!mWearable)
{
// not editing a wearable just now, no update necessary
return;
}
F32 current_weight = mWearable->getVisualParamWeight( param->getID() );
getChild<LLUICtrl>("param slider")->setValue(weightToPercent( current_weight ) );
LLScrollingPanelParamBase::updatePanel(allow_modify);
mHintMin->requestUpdate( sUpdateDelayFrames++ );
mHintMax->requestUpdate( sUpdateDelayFrames++ );
mAllowModify = allow_modify;
getChildView("param slider")->setEnabled(mAllowModify);
getChildView("less")->setEnabled(mAllowModify);
getChildView("more")->setEnabled(mAllowModify);
}
@ -135,13 +114,17 @@ void LLScrollingPanelParam::setVisible( BOOL visible )
if( getVisible() != visible )
{
LLPanel::setVisible( visible );
mHintMin->setAllowsUpdates( visible );
mHintMax->setAllowsUpdates( visible );
if (mHintMin)
mHintMin->setAllowsUpdates( visible );
if (mHintMax)
mHintMax->setAllowsUpdates( visible );
if( visible )
{
mHintMin->setUpdateDelayFrames( sUpdateDelayFrames++ );
mHintMax->setUpdateDelayFrames( sUpdateDelayFrames++ );
if (mHintMin)
mHintMin->setUpdateDelayFrames( sUpdateDelayFrames++ );
if (mHintMax)
mHintMax->setUpdateDelayFrames( sUpdateDelayFrames++ );
}
}
}
@ -164,7 +147,7 @@ void LLScrollingPanelParam::draw()
getChildView("min param text")->setVisible( FALSE );
getChildView("max param text")->setVisible( FALSE );
LLPanel::draw();
// If we're in a focused floater, don't apply the floater's alpha to visual param hint,
// making its behavior similar to texture controls'.
F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency();
@ -195,23 +178,6 @@ void LLScrollingPanelParam::draw()
drawChild(getChild<LLView>("max param text"));
}
// static
void LLScrollingPanelParam::onSliderMoved(LLUICtrl* ctrl, void* userdata)
{
LLSliderCtrl* slider = (LLSliderCtrl*) ctrl;
LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata;
LLViewerVisualParam* param = self->mParam;
F32 current_weight = self->mWearable->getVisualParamWeight( param->getID() );
F32 new_weight = self->percentToWeight( (F32)slider->getValue().asReal() );
if (current_weight != new_weight )
{
self->mWearable->setVisualParamWeight( param->getID(), new_weight, FALSE );
self->mWearable->writeToAvatar();
gAgentAvatarp->updateVisualParams();
}
}
// static
void LLScrollingPanelParam::onSliderMouseDown(LLUICtrl* ctrl, void* userdata)
{
@ -221,7 +187,6 @@ void LLScrollingPanelParam::onSliderMouseDown(LLUICtrl* ctrl, void* userdata)
void LLScrollingPanelParam::onSliderMouseUp(LLUICtrl* ctrl, void* userdata)
{
LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata;
LLVisualParamHint::requestHintUpdates( self->mHintMin, self->mHintMax );
}

View File

@ -28,8 +28,7 @@
#ifndef LL_SCROLLINGPANELPARAM_H
#define LL_SCROLLINGPANELPARAM_H
#include "llpanel.h"
#include "llscrollingpanellist.h"
#include "llscrollingpanelparambase.h"
class LLViewerJointMesh;
class LLViewerVisualParam;
@ -38,11 +37,11 @@ class LLVisualParamHint;
class LLViewerVisualParam;
class LLJoint;
class LLScrollingPanelParam : public LLScrollingPanel
class LLScrollingPanelParam : public LLScrollingPanelParamBase
{
public:
LLScrollingPanelParam( const LLPanel::Params& panel_params,
LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp );
LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp, BOOL use_hints = TRUE );
virtual ~LLScrollingPanelParam();
virtual void draw();
@ -50,7 +49,6 @@ public:
virtual void updatePanel(BOOL allow_modify);
static void onSliderMouseDown(LLUICtrl* ctrl, void* userdata);
static void onSliderMoved(LLUICtrl* ctrl, void* userdata);
static void onSliderMouseUp(LLUICtrl* ctrl, void* userdata);
static void onHintMinMouseDown(void* userdata);
@ -74,7 +72,6 @@ public:
const static S32 PARAM_HINT_HEIGHT;
public:
LLViewerVisualParam* mParam;
LLPointer<LLVisualParamHint> mHintMin;
LLPointer<LLVisualParamHint> mHintMax;
static S32 sUpdateDelayFrames;
@ -82,9 +79,7 @@ public:
protected:
LLTimer mMouseDownTimer; // timer for how long mouse has been held down on a hint.
F32 mLastHeldTime;
BOOL mAllowModify;
LLWearable *mWearable;
};
#endif

View File

@ -0,0 +1,112 @@
/**
* @file llscrollingpanelparam.cpp
* @brief UI panel for a list of visual param panels
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llscrollingpanelparambase.h"
#include "llviewerjointmesh.h"
#include "llviewervisualparam.h"
#include "llwearable.h"
#include "llviewervisualparam.h"
#include "lltoolmorph.h"
#include "lltrans.h"
#include "llbutton.h"
#include "llsliderctrl.h"
#include "llagent.h"
#include "llviewborder.h"
#include "llvoavatarself.h"
LLScrollingPanelParamBase::LLScrollingPanelParamBase( const LLPanel::Params& panel_params,
LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp, BOOL use_hints)
: LLScrollingPanel( panel_params ),
mParam(param),
mAllowModify(allow_modify),
mWearable(wearable)
{
if (use_hints)
buildFromFile( "panel_scrolling_param.xml");
else
buildFromFile( "panel_scrolling_param_base.xml");
getChild<LLUICtrl>("param slider")->setValue(weightToPercent(param->getWeight()));
std::string display_name = LLTrans::getString(param->getDisplayName());
getChild<LLUICtrl>("param slider")->setLabelArg("[DESC]", display_name);
getChildView("param slider")->setEnabled(mAllowModify);
childSetCommitCallback("param slider", LLScrollingPanelParamBase::onSliderMoved, this);
setVisible(FALSE);
setBorderVisible( FALSE );
}
LLScrollingPanelParamBase::~LLScrollingPanelParamBase()
{
}
void LLScrollingPanelParamBase::updatePanel(BOOL allow_modify)
{
LLViewerVisualParam* param = mParam;
if (!mWearable)
{
// not editing a wearable just now, no update necessary
return;
}
F32 current_weight = mWearable->getVisualParamWeight( param->getID() );
getChild<LLUICtrl>("param slider")->setValue(weightToPercent( current_weight ) );
mAllowModify = allow_modify;
getChildView("param slider")->setEnabled(mAllowModify);
}
// static
void LLScrollingPanelParamBase::onSliderMoved(LLUICtrl* ctrl, void* userdata)
{
LLSliderCtrl* slider = (LLSliderCtrl*) ctrl;
LLScrollingPanelParamBase* self = (LLScrollingPanelParamBase*) userdata;
LLViewerVisualParam* param = self->mParam;
F32 current_weight = self->mWearable->getVisualParamWeight( param->getID() );
F32 new_weight = self->percentToWeight( (F32)slider->getValue().asReal() );
if (current_weight != new_weight )
{
self->mWearable->setVisualParamWeight( param->getID(), new_weight, FALSE );
self->mWearable->writeToAvatar();
gAgentAvatarp->updateVisualParams();
}
}
F32 LLScrollingPanelParamBase::weightToPercent( F32 weight )
{
LLViewerVisualParam* param = mParam;
return (weight - param->getMinWeight()) / (param->getMaxWeight() - param->getMinWeight()) * 100.f;
}
F32 LLScrollingPanelParamBase::percentToWeight( F32 percent )
{
LLViewerVisualParam* param = mParam;
return percent / 100.f * (param->getMaxWeight() - param->getMinWeight()) + param->getMinWeight();
}

View File

@ -0,0 +1,62 @@
/**
* @file llscrollingpanelparam.h
* @brief the scrolling panel containing a list of visual param
* panels
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_SCROLLINGPANELPARAMBASE_H
#define LL_SCROLLINGPANELPARAMBASE_H
#include "llpanel.h"
#include "llscrollingpanellist.h"
class LLViewerJointMesh;
class LLViewerVisualParam;
class LLWearable;
class LLVisualParamHint;
class LLViewerVisualParam;
class LLJoint;
class LLScrollingPanelParamBase : public LLScrollingPanel
{
public:
LLScrollingPanelParamBase( const LLPanel::Params& panel_params,
LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp, BOOL use_hints = FALSE );
virtual ~LLScrollingPanelParamBase();
virtual void updatePanel(BOOL allow_modify);
static void onSliderMoved(LLUICtrl* ctrl, void* userdata);
F32 weightToPercent( F32 weight );
F32 percentToWeight( F32 percent );
public:
LLViewerVisualParam* mParam;
protected:
BOOL mAllowModify;
LLWearable *mWearable;
};
#endif

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<panel
layout="topleft"
left="0"
name="LLScrollingPanelParamBase"
height="20"
width="290">
<slider
can_edit_text="true"
decimal_digits="0"
enabled="false"
height="16"
increment="1"
initial_value="0"
label="[DESC]"
layout="bottom|left"
left="6"
max_val="100"
name="param slider"
bottom="1"
width="274"
slider_label.font.style="BOLD" />
</panel>