summaryrefslogtreecommitdiff
path: root/indra/newview/llphysicsmotion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llphysicsmotion.cpp')
-rw-r--r--indra/newview/llphysicsmotion.cpp97
1 files changed, 49 insertions, 48 deletions
diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp
index 9c6a4a7f10..86291708b0 100644
--- a/indra/newview/llphysicsmotion.cpp
+++ b/indra/newview/llphysicsmotion.cpp
@@ -120,11 +120,11 @@ public:
}
}
- BOOL initialize();
+ bool initialize();
~LLPhysicsMotion() {}
- BOOL onUpdate(F32 time);
+ bool onUpdate(F32 time);
LLPointer<LLJointState> getJointState()
{
@@ -217,20 +217,20 @@ default_controller_map_t initDefaultController()
default_controller_map_t LLPhysicsMotion::sDefaultController = initDefaultController();
-BOOL LLPhysicsMotion::initialize()
+bool LLPhysicsMotion::initialize()
{
if (!mJointState->setJoint(mCharacter->getJoint(mJointName.c_str())))
- return FALSE;
+ return false;
mJointState->setUsage(LLJointState::ROT);
mParamDriver = (LLViewerVisualParam*)mCharacter->getVisualParam(mParamDriverName.c_str());
if (mParamDriver == NULL)
{
LL_INFOS() << "Failure reading in [ " << mParamDriverName << " ]" << LL_ENDL;
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
LLPhysicsMotionController::LLPhysicsMotionController(const LLUUID &id) :
@@ -250,9 +250,9 @@ LLPhysicsMotionController::~LLPhysicsMotionController()
}
}
-BOOL LLPhysicsMotionController::onActivate()
+bool LLPhysicsMotionController::onActivate()
{
- return TRUE;
+ return true;
}
void LLPhysicsMotionController::onDeactivate()
@@ -282,7 +282,7 @@ LLMotion::LLMotionInitStatus LLPhysicsMotionController::onInitialize(LLCharacter
controller);
if (!motion->initialize())
{
- llassert_always(FALSE);
+ llassert_always(false);
return STATUS_FAILURE;
}
addMotion(motion);
@@ -305,7 +305,7 @@ LLMotion::LLMotionInitStatus LLPhysicsMotionController::onInitialize(LLCharacter
controller);
if (!motion->initialize())
{
- llassert_always(FALSE);
+ llassert_always(false);
return STATUS_FAILURE;
}
addMotion(motion);
@@ -328,7 +328,7 @@ LLMotion::LLMotionInitStatus LLPhysicsMotionController::onInitialize(LLCharacter
controller);
if (!motion->initialize())
{
- llassert_always(FALSE);
+ llassert_always(false);
return STATUS_FAILURE;
}
addMotion(motion);
@@ -350,7 +350,7 @@ LLMotion::LLMotionInitStatus LLPhysicsMotionController::onInitialize(LLCharacter
controller);
if (!motion->initialize())
{
- llassert_always(FALSE);
+ llassert_always(false);
return STATUS_FAILURE;
}
addMotion(motion);
@@ -373,7 +373,7 @@ LLMotion::LLMotionInitStatus LLPhysicsMotionController::onInitialize(LLCharacter
controller);
if (!motion->initialize())
{
- llassert_always(FALSE);
+ llassert_always(false);
return STATUS_FAILURE;
}
addMotion(motion);
@@ -396,7 +396,7 @@ LLMotion::LLMotionInitStatus LLPhysicsMotionController::onInitialize(LLCharacter
controller);
if (!motion->initialize())
{
- llassert_always(FALSE);
+ llassert_always(false);
return STATUS_FAILURE;
}
addMotion(motion);
@@ -445,48 +445,49 @@ F32 LLPhysicsMotion::calculateAcceleration_local(const F32 velocity_local, const
const F32 acceleration_local = (velocity_local - mVelocityJoint_local) / time_delta;
const F32 smoothed_acceleration_local =
- acceleration_local * 1.0/smoothing +
- mAccelerationJoint_local * (smoothing-1.0)/smoothing;
+ acceleration_local * 1.0f/smoothing +
+ mAccelerationJoint_local * (smoothing-1.0f)/smoothing;
return smoothed_acceleration_local;
}
-BOOL LLPhysicsMotionController::onUpdate(F32 time, U8* joint_mask)
+bool LLPhysicsMotionController::onUpdate(F32 time, U8* joint_mask)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR;
- // Skip if disabled globally.
- if (!gSavedSettings.getBOOL("AvatarPhysics"))
- {
- return TRUE;
- }
+ // Skip if disabled globally.
+ static LLCachedControl<bool> av_physics(gSavedSettings, "AvatarPhysics");
+ if (!av_physics)
+ {
+ return true;
+ }
- BOOL update_visuals = FALSE;
- for (motion_vec_t::iterator iter = mMotions.begin();
- iter != mMotions.end();
- ++iter)
- {
- LLPhysicsMotion *motion = (*iter);
- update_visuals |= motion->onUpdate(time);
- }
+ bool update_visuals = false;
+ for (motion_vec_t::iterator iter = mMotions.begin();
+ iter != mMotions.end();
+ ++iter)
+ {
+ LLPhysicsMotion *motion = (*iter);
+ update_visuals |= motion->onUpdate(time);
+ }
- if (update_visuals)
- mCharacter->updateVisualParams();
+ if (update_visuals)
+ mCharacter->updateVisualParams();
- return TRUE;
+ return true;
}
-// Return TRUE if character has to update visual params.
-BOOL LLPhysicsMotion::onUpdate(F32 time)
+// Return true if character has to update visual params.
+bool LLPhysicsMotion::onUpdate(F32 time)
{
// static FILE *mFileWrite = fopen("c:\\temp\\avatar_data.txt","w");
if (!mParamDriver)
- return FALSE;
+ return false;
if (!mLastTime || mLastTime >= time)
{
mLastTime = time;
- return FALSE;
+ return false;
}
////////////////////////////////////////////////////////////////////////////////
@@ -499,7 +500,7 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
if (time_delta > 1.0)
{
mLastTime = time;
- return FALSE;
+ return false;
}
// Higher LOD is better. This controls the granularity
@@ -507,7 +508,7 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
const F32 lod_factor = LLVOAvatar::sPhysicsLODFactor;
if (lod_factor == 0)
{
- return TRUE;
+ return true;
}
LLJoint *joint = mJointState->getJoint();
@@ -520,7 +521,7 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
const F32 behavior_drag = getParamValue(DRAG);
F32 behavior_maxeffect = getParamValue(MAX_EFFECT);
- const BOOL physics_test = FALSE; // Enable this to simulate bouncing on all parts.
+ const bool physics_test = false; // Enable this to simulate bouncing on all parts.
if (physics_test)
behavior_maxeffect = 1.0f;
@@ -548,7 +549,7 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
// End velocity and acceleration
////////////////////////////////////////////////////////////////////////////////
- BOOL update_visuals = FALSE;
+ bool update_visuals = false;
// Break up the physics into a bunch of iterations so that differing framerates will show
// roughly the same behavior.
@@ -603,7 +604,7 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
// Drag is a force imparted by velocity (intuitively it is similar to wind resistance)
// F = .5kv^2
- const F32 force_drag = .5*behavior_drag*velocity_joint_local*velocity_joint_local*llsgn(velocity_joint_local);
+ const F32 force_drag = (F32)(.5 * behavior_drag * velocity_joint_local * velocity_joint_local * llsgn(velocity_joint_local));
const F32 force_net = (force_accel +
force_gravity +
@@ -631,7 +632,7 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
// Temporary debugging setting to cause all avatars to move, for profiling purposes.
if (physics_test)
{
- velocity_new_local = sin(time*4.0);
+ velocity_new_local = sin(time*4.0f);
}
// Calculate the new parameters, or remain unchanged if max speed is 0.
F32 position_new_local = position_current_local + velocity_new_local*time_iteration_step;
@@ -697,17 +698,17 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
// For non-self, if the avatar is small enough visually, then don't update.
const F32 area_for_max_settings = 0.0;
const F32 area_for_min_settings = 1400.0;
- const F32 area_for_this_setting = area_for_max_settings + (area_for_min_settings-area_for_max_settings)*(1.0-lod_factor);
+ const F32 area_for_this_setting = area_for_max_settings + (area_for_min_settings-area_for_max_settings)*(1.0f-lod_factor);
const F32 pixel_area = sqrtf(mCharacter->getPixelArea());
- const BOOL is_self = (dynamic_cast<LLVOAvatarSelf *>(mCharacter) != NULL);
+ const bool is_self = (dynamic_cast<LLVOAvatarSelf *>(mCharacter) != NULL);
if ((pixel_area > area_for_this_setting) || is_self)
{
const F32 position_diff_local = llabs(mPositionLastUpdate_local-position_new_local_clamped);
const F32 min_delta = (1.0001f-lod_factor)*0.4f;
if (llabs(position_diff_local) > min_delta)
{
- update_visuals = TRUE;
+ update_visuals = true;
mPositionLastUpdate_local = position_new_local;
}
}
@@ -763,8 +764,8 @@ void LLPhysicsMotion::setParamValue(const LLViewerVisualParam *param,
{
const F32 value_min_local = param->getMinWeight();
const F32 value_max_local = param->getMaxWeight();
- const F32 min_val = 0.5f-behavior_maxeffect/2.0;
- const F32 max_val = 0.5f+behavior_maxeffect/2.0;
+ const F32 min_val = 0.5f-behavior_maxeffect/2.0f;
+ const F32 max_val = 0.5f+behavior_maxeffect/2.0f;
// Scale from [0,1] to [min_val,max_val]
const F32 new_value_rescaled = min_val + (max_val-min_val) * new_value_normalized;