MAINT-646: Don't spend so much time fetching avatar physics params. https://bitbucket.org/davep/viewer-development/changeset/b895285ab0de
This commit is contained in:
@@ -2,31 +2,25 @@
|
|||||||
* @file llphysicsmotion.cpp
|
* @file llphysicsmotion.cpp
|
||||||
* @brief Implementation of LLPhysicsMotion class.
|
* @brief Implementation of LLPhysicsMotion class.
|
||||||
*
|
*
|
||||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
* $LicenseInfo:firstyear=2011&license=viewerlgpl$
|
||||||
*
|
|
||||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
|
||||||
*
|
|
||||||
* Second Life Viewer Source Code
|
* Second Life Viewer Source Code
|
||||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
* Copyright (C) 2011, Linden Research, Inc.
|
||||||
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* it is applied to this Source Code. View the full text of the exception
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
* License as published by the Free Software Foundation;
|
||||||
* online at
|
* version 2.1 of the License only.
|
||||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
|
||||||
*
|
*
|
||||||
* By copying, modifying or distributing this software, you acknowledge
|
* This library is distributed in the hope that it will be useful,
|
||||||
* that you have read and understood your obligations described above,
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* and agree to abide by those obligations.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
* License along with this library; if not, write to the Free Software
|
||||||
* COMPLETENESS OR PERFORMANCE.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||||
* $/LicenseInfo$
|
* $/LicenseInfo$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -74,6 +68,19 @@ inline F64 llsgn(const F64 a)
|
|||||||
class LLPhysicsMotion
|
class LLPhysicsMotion
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SMOOTHING = 0,
|
||||||
|
MASS,
|
||||||
|
GRAVITY,
|
||||||
|
SPRING,
|
||||||
|
GAIN,
|
||||||
|
DAMPING,
|
||||||
|
DRAG,
|
||||||
|
MAX_EFFECT,
|
||||||
|
NUM_PARAMS
|
||||||
|
} eParamName;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
param_driver_name: The param that controls the params that are being affected by the physics.
|
param_driver_name: The param that controls the params that are being affected by the physics.
|
||||||
joint_name: The joint that the body part is attached to. The joint is
|
joint_name: The joint that the body part is attached to. The joint is
|
||||||
@@ -107,8 +114,12 @@ public:
|
|||||||
mVelocity_local(0)
|
mVelocity_local(0)
|
||||||
{
|
{
|
||||||
mJointState = new LLJointState;
|
mJointState = new LLJointState;
|
||||||
}
|
|
||||||
|
|
||||||
|
for (U32 i = 0; i < NUM_PARAMS; ++i)
|
||||||
|
{
|
||||||
|
mParamCache[i] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
void getString(std::ostringstream &oss);
|
void getString(std::ostringstream &oss);
|
||||||
|
|
||||||
BOOL initialize();
|
BOOL initialize();
|
||||||
@@ -124,19 +135,46 @@ public:
|
|||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
protected:
|
protected:
|
||||||
F32 getParamValue(const std::string& controller_key)
|
|
||||||
{
|
F32 getParamValue(eParamName param)
|
||||||
const controller_map_t::const_iterator& entry = mParamControllers.find(controller_key);
|
{
|
||||||
|
static std::string controller_key[] =
|
||||||
|
{
|
||||||
|
"Smoothing",
|
||||||
|
"Mass",
|
||||||
|
"Gravity",
|
||||||
|
"Spring",
|
||||||
|
"Gain",
|
||||||
|
"Damping",
|
||||||
|
"Drag",
|
||||||
|
"MaxEffect"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!mParamCache[param])
|
||||||
|
{
|
||||||
|
const controller_map_t::const_iterator& entry = mParamControllers.find(controller_key[param]);
|
||||||
if (entry == mParamControllers.end())
|
if (entry == mParamControllers.end())
|
||||||
{
|
{
|
||||||
return sDefaultController[controller_key];
|
return sDefaultController[controller_key[param]];
|
||||||
}
|
}
|
||||||
const std::string& param_name = (*entry).second.c_str();
|
const std::string& param_name = (*entry).second.c_str();
|
||||||
return mCharacter->getVisualParamWeight(param_name.c_str());
|
mParamCache[param] = mCharacter->getVisualParam(param_name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mParamCache[param])
|
||||||
|
{
|
||||||
|
return mParamCache[param]->getWeight();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return sDefaultController[controller_key[param]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void setParamValue(LLViewerVisualParam *param,
|
void setParamValue(LLViewerVisualParam *param,
|
||||||
const F32 new_value_local,
|
const F32 new_value_local,
|
||||||
F32 behavior_maxeffect);
|
F32 behavior_maxeffect);
|
||||||
|
|
||||||
F32 toLocal(const LLVector3 &world);
|
F32 toLocal(const LLVector3 &world);
|
||||||
F32 calculateVelocity_local();
|
F32 calculateVelocity_local();
|
||||||
@@ -164,6 +202,8 @@ private:
|
|||||||
|
|
||||||
F32 mLastTime;
|
F32 mLastTime;
|
||||||
|
|
||||||
|
LLVisualParam* mParamCache[NUM_PARAMS];
|
||||||
|
|
||||||
static default_controller_map_t sDefaultController;
|
static default_controller_map_t sDefaultController;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -268,7 +308,7 @@ void LLPhysicsMotion::getString(std::ostringstream &oss)
|
|||||||
oss << " Controllers:" << std::endl;
|
oss << " Controllers:" << std::endl;
|
||||||
for(controller_map_t::const_iterator it = mParamControllers.begin(); it!= mParamControllers.end(); ++it)
|
for(controller_map_t::const_iterator it = mParamControllers.begin(); it!= mParamControllers.end(); ++it)
|
||||||
{
|
{
|
||||||
oss << " mParamControllers[\"" << it->first << "\"] = \"" << it->second << "\" =" << getParamValue(it->first) << std::endl;
|
oss << " mParamControllers[\"" << it->first << "\"] = \"" << it->second << "\" =" << mCharacter->getVisualParamWeight(it->first.c_str()) << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -574,15 +614,16 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
|
|||||||
|
|
||||||
LLJoint *joint = mJointState->getJoint();
|
LLJoint *joint = mJointState->getJoint();
|
||||||
|
|
||||||
const F32 behavior_mass = getParamValue("Mass");
|
const F32 behavior_mass = getParamValue(MASS);
|
||||||
const F32 behavior_gravity = getParamValue("Gravity");
|
const F32 behavior_gravity = getParamValue(GRAVITY);
|
||||||
const F32 behavior_spring = getParamValue("Spring");
|
const F32 behavior_spring = getParamValue(SPRING);
|
||||||
const F32 behavior_gain = getParamValue("Gain");
|
const F32 behavior_gain = getParamValue(GAIN);
|
||||||
const F32 behavior_damping = getParamValue("Damping");
|
const F32 behavior_damping = getParamValue(DAMPING);
|
||||||
const F32 behavior_drag = getParamValue("Drag");
|
const F32 behavior_drag = getParamValue(DRAG);
|
||||||
const BOOL physics_test = FALSE; // Enable this to simulate bouncing on all parts.
|
F32 behavior_maxeffect = getParamValue(MAX_EFFECT);
|
||||||
|
|
||||||
|
const BOOL physics_test = FALSE; // Enable this to simulate bouncing on all parts.
|
||||||
|
|
||||||
F32 behavior_maxeffect = getParamValue("MaxEffect");
|
|
||||||
if (physics_test)
|
if (physics_test)
|
||||||
behavior_maxeffect = 1.0f;
|
behavior_maxeffect = 1.0f;
|
||||||
|
|
||||||
|
|||||||
@@ -2,31 +2,25 @@
|
|||||||
* @file llphysicsmotion.h
|
* @file llphysicsmotion.h
|
||||||
* @brief Implementation of LLPhysicsMotion class.
|
* @brief Implementation of LLPhysicsMotion class.
|
||||||
*
|
*
|
||||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
* $LicenseInfo:firstyear=2011&license=viewerlgpl$
|
||||||
*
|
|
||||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
|
||||||
*
|
|
||||||
* Second Life Viewer Source Code
|
* Second Life Viewer Source Code
|
||||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
* Copyright (C) 2011, Linden Research, Inc.
|
||||||
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* it is applied to this Source Code. View the full text of the exception
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
* License as published by the Free Software Foundation;
|
||||||
* online at
|
* version 2.1 of the License only.
|
||||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
|
||||||
*
|
*
|
||||||
* By copying, modifying or distributing this software, you acknowledge
|
* This library is distributed in the hope that it will be useful,
|
||||||
* that you have read and understood your obligations described above,
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* and agree to abide by those obligations.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
* License along with this library; if not, write to the Free Software
|
||||||
* COMPLETENESS OR PERFORMANCE.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||||
* $/LicenseInfo$
|
* $/LicenseInfo$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -113,6 +107,7 @@ public:
|
|||||||
virtual void onDeactivate();
|
virtual void onDeactivate();
|
||||||
|
|
||||||
LLCharacter* getCharacter() { return mCharacter; }
|
LLCharacter* getCharacter() { return mCharacter; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void addMotion(LLPhysicsMotion *motion);
|
void addMotion(LLPhysicsMotion *motion);
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user