From 70f8dc7a4f4be217fea5439e474fc75e567c23c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Sat, 10 Feb 2024 22:37:52 +0100 Subject: miscellaneous: BOOL (int) to real bool --- indra/llcharacter/lltargetingmotion.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcharacter/lltargetingmotion.cpp') diff --git a/indra/llcharacter/lltargetingmotion.cpp b/indra/llcharacter/lltargetingmotion.cpp index ec75212a40..0697d04fd3 100644 --- a/indra/llcharacter/lltargetingmotion.cpp +++ b/indra/llcharacter/lltargetingmotion.cpp @@ -95,7 +95,7 @@ LLMotion::LLMotionInitStatus LLTargetingMotion::onInitialize(LLCharacter *charac //----------------------------------------------------------------------------- BOOL LLTargetingMotion::onActivate() { - return TRUE; + return true; } //----------------------------------------------------------------------------- @@ -113,7 +113,7 @@ BOOL LLTargetingMotion::onUpdate(F32 time, U8* joint_mask) if (!lookAtPoint) { - return TRUE; + return true; } else { -- cgit v1.2.3 From 9e854b697a06abed2a0917fb6120445f176764f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Fri, 16 Feb 2024 19:29:51 +0100 Subject: misc: BOOL to bool --- indra/llcharacter/lltargetingmotion.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llcharacter/lltargetingmotion.cpp') diff --git a/indra/llcharacter/lltargetingmotion.cpp b/indra/llcharacter/lltargetingmotion.cpp index 0697d04fd3..87d61a2d36 100644 --- a/indra/llcharacter/lltargetingmotion.cpp +++ b/indra/llcharacter/lltargetingmotion.cpp @@ -93,7 +93,7 @@ LLMotion::LLMotionInitStatus LLTargetingMotion::onInitialize(LLCharacter *charac //----------------------------------------------------------------------------- // LLTargetingMotion::onActivate() //----------------------------------------------------------------------------- -BOOL LLTargetingMotion::onActivate() +bool LLTargetingMotion::onActivate() { return true; } @@ -101,7 +101,7 @@ BOOL LLTargetingMotion::onActivate() //----------------------------------------------------------------------------- // LLTargetingMotion::onUpdate() //----------------------------------------------------------------------------- -BOOL LLTargetingMotion::onUpdate(F32 time, U8* joint_mask) +bool LLTargetingMotion::onUpdate(F32 time, U8* joint_mask) { LL_PROFILE_ZONE_SCOPED; F32 slerp_amt = LLSmoothInterpolation::getInterpolant(TORSO_TARGET_HALF_LIFE); @@ -109,7 +109,7 @@ BOOL LLTargetingMotion::onUpdate(F32 time, U8* joint_mask) LLVector3 target; LLVector3* lookAtPoint = (LLVector3*)mCharacter->getAnimationData("LookAtPoint"); - BOOL result = TRUE; + bool result = true; if (!lookAtPoint) { -- cgit v1.2.3 From e2e37cced861b98de8c1a7c9c0d3a50d2d90e433 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 22 May 2024 21:25:21 +0200 Subject: Fix line endlings --- indra/llcharacter/lltargetingmotion.cpp | 340 ++++++++++++++++---------------- 1 file changed, 170 insertions(+), 170 deletions(-) (limited to 'indra/llcharacter/lltargetingmotion.cpp') diff --git a/indra/llcharacter/lltargetingmotion.cpp b/indra/llcharacter/lltargetingmotion.cpp index 1029ba40eb..0683a1125c 100644 --- a/indra/llcharacter/lltargetingmotion.cpp +++ b/indra/llcharacter/lltargetingmotion.cpp @@ -1,170 +1,170 @@ -/** - * @file lltargetingmotion.cpp - * @brief Implementation of LLTargetingMotion class. - * - * $LicenseInfo:firstyear=2001&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$ - */ - -//----------------------------------------------------------------------------- -// Header Files -//----------------------------------------------------------------------------- -#include "linden_common.h" - -#include "lltargetingmotion.h" -#include "llcharacter.h" -#include "v3dmath.h" -#include "llcriticaldamp.h" - -//----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- -const F32 TORSO_TARGET_HALF_LIFE = 0.25f; - -//----------------------------------------------------------------------------- -// LLTargetingMotion() -// Class Constructor -//----------------------------------------------------------------------------- -LLTargetingMotion::LLTargetingMotion(const LLUUID &id) : LLMotion(id) -{ - mCharacter = NULL; - mName = "targeting"; - - mTorsoState = new LLJointState; -} - - -//----------------------------------------------------------------------------- -// ~LLTargetingMotion() -// Class Destructor -//----------------------------------------------------------------------------- -LLTargetingMotion::~LLTargetingMotion() -{ -} - -//----------------------------------------------------------------------------- -// LLTargetingMotion::onInitialize(LLCharacter *character) -//----------------------------------------------------------------------------- -LLMotion::LLMotionInitStatus LLTargetingMotion::onInitialize(LLCharacter *character) -{ - // save character for future use - mCharacter = character; - - mPelvisJoint = mCharacter->getJoint("mPelvis"); - mTorsoJoint = mCharacter->getJoint("mTorso"); - mRightHandJoint = mCharacter->getJoint("mWristRight"); - - // make sure character skeleton is copacetic - if (!mPelvisJoint || - !mTorsoJoint || - !mRightHandJoint) - { - LL_WARNS() << "Invalid skeleton for targeting motion!" << LL_ENDL; - return STATUS_FAILURE; - } - - mTorsoState->setJoint( mTorsoJoint ); - - // add joint states to the pose - mTorsoState->setUsage(LLJointState::ROT); - addJointState( mTorsoState ); - - return STATUS_SUCCESS; -} - -//----------------------------------------------------------------------------- -// LLTargetingMotion::onActivate() -//----------------------------------------------------------------------------- -bool LLTargetingMotion::onActivate() -{ - return true; -} - -//----------------------------------------------------------------------------- -// LLTargetingMotion::onUpdate() -//----------------------------------------------------------------------------- -bool LLTargetingMotion::onUpdate(F32 time, U8* joint_mask) -{ - LL_PROFILE_ZONE_SCOPED; - F32 slerp_amt = LLSmoothInterpolation::getInterpolant(TORSO_TARGET_HALF_LIFE); - - LLVector3 target; - LLVector3* lookAtPoint = (LLVector3*)mCharacter->getAnimationData("LookAtPoint"); - - bool result = true; - - if (!lookAtPoint) - { - return true; - } - else - { - target = *lookAtPoint; - target.normVec(); - } - - //LLVector3 target_plane_normal = LLVector3(1.f, 0.f, 0.f) * mPelvisJoint->getWorldRotation(); - //LLVector3 torso_dir = LLVector3(1.f, 0.f, 0.f) * (mTorsoJoint->getWorldRotation() * mTorsoState->getRotation()); - - LLVector3 skyward(0.f, 0.f, 1.f); - LLVector3 left(skyward % target); - left.normVec(); - LLVector3 up(target % left); - up.normVec(); - LLQuaternion target_aim_rot(target, left, up); - - LLQuaternion cur_torso_rot = mTorsoJoint->getWorldRotation(); - - LLVector3 right_hand_at = LLVector3(0.f, -1.f, 0.f) * mRightHandJoint->getWorldRotation(); - left.setVec(skyward % right_hand_at); - left.normVec(); - up.setVec(right_hand_at % left); - up.normVec(); - LLQuaternion right_hand_rot(right_hand_at, left, up); - - LLQuaternion new_torso_rot = (cur_torso_rot * ~right_hand_rot) * target_aim_rot; - - // find ideal additive rotation to make torso point in correct direction - new_torso_rot = new_torso_rot * ~cur_torso_rot; - - // slerp from current additive rotation to ideal additive rotation - new_torso_rot = nlerp(slerp_amt, mTorsoState->getRotation(), new_torso_rot); - - // constraint overall torso rotation - LLQuaternion total_rot = new_torso_rot * mTorsoJoint->getRotation(); - total_rot.constrain(F_PI_BY_TWO * 0.8f); - new_torso_rot = total_rot * ~mTorsoJoint->getRotation(); - - mTorsoState->setRotation(new_torso_rot); - - return result; -} - -//----------------------------------------------------------------------------- -// LLTargetingMotion::onDeactivate() -//----------------------------------------------------------------------------- -void LLTargetingMotion::onDeactivate() -{ -} - - -// End - +/** + * @file lltargetingmotion.cpp + * @brief Implementation of LLTargetingMotion class. + * + * $LicenseInfo:firstyear=2001&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$ + */ + +//----------------------------------------------------------------------------- +// Header Files +//----------------------------------------------------------------------------- +#include "linden_common.h" + +#include "lltargetingmotion.h" +#include "llcharacter.h" +#include "v3dmath.h" +#include "llcriticaldamp.h" + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- +const F32 TORSO_TARGET_HALF_LIFE = 0.25f; + +//----------------------------------------------------------------------------- +// LLTargetingMotion() +// Class Constructor +//----------------------------------------------------------------------------- +LLTargetingMotion::LLTargetingMotion(const LLUUID &id) : LLMotion(id) +{ + mCharacter = NULL; + mName = "targeting"; + + mTorsoState = new LLJointState; +} + + +//----------------------------------------------------------------------------- +// ~LLTargetingMotion() +// Class Destructor +//----------------------------------------------------------------------------- +LLTargetingMotion::~LLTargetingMotion() +{ +} + +//----------------------------------------------------------------------------- +// LLTargetingMotion::onInitialize(LLCharacter *character) +//----------------------------------------------------------------------------- +LLMotion::LLMotionInitStatus LLTargetingMotion::onInitialize(LLCharacter *character) +{ + // save character for future use + mCharacter = character; + + mPelvisJoint = mCharacter->getJoint("mPelvis"); + mTorsoJoint = mCharacter->getJoint("mTorso"); + mRightHandJoint = mCharacter->getJoint("mWristRight"); + + // make sure character skeleton is copacetic + if (!mPelvisJoint || + !mTorsoJoint || + !mRightHandJoint) + { + LL_WARNS() << "Invalid skeleton for targeting motion!" << LL_ENDL; + return STATUS_FAILURE; + } + + mTorsoState->setJoint( mTorsoJoint ); + + // add joint states to the pose + mTorsoState->setUsage(LLJointState::ROT); + addJointState( mTorsoState ); + + return STATUS_SUCCESS; +} + +//----------------------------------------------------------------------------- +// LLTargetingMotion::onActivate() +//----------------------------------------------------------------------------- +bool LLTargetingMotion::onActivate() +{ + return true; +} + +//----------------------------------------------------------------------------- +// LLTargetingMotion::onUpdate() +//----------------------------------------------------------------------------- +bool LLTargetingMotion::onUpdate(F32 time, U8* joint_mask) +{ + LL_PROFILE_ZONE_SCOPED; + F32 slerp_amt = LLSmoothInterpolation::getInterpolant(TORSO_TARGET_HALF_LIFE); + + LLVector3 target; + LLVector3* lookAtPoint = (LLVector3*)mCharacter->getAnimationData("LookAtPoint"); + + bool result = true; + + if (!lookAtPoint) + { + return true; + } + else + { + target = *lookAtPoint; + target.normVec(); + } + + //LLVector3 target_plane_normal = LLVector3(1.f, 0.f, 0.f) * mPelvisJoint->getWorldRotation(); + //LLVector3 torso_dir = LLVector3(1.f, 0.f, 0.f) * (mTorsoJoint->getWorldRotation() * mTorsoState->getRotation()); + + LLVector3 skyward(0.f, 0.f, 1.f); + LLVector3 left(skyward % target); + left.normVec(); + LLVector3 up(target % left); + up.normVec(); + LLQuaternion target_aim_rot(target, left, up); + + LLQuaternion cur_torso_rot = mTorsoJoint->getWorldRotation(); + + LLVector3 right_hand_at = LLVector3(0.f, -1.f, 0.f) * mRightHandJoint->getWorldRotation(); + left.setVec(skyward % right_hand_at); + left.normVec(); + up.setVec(right_hand_at % left); + up.normVec(); + LLQuaternion right_hand_rot(right_hand_at, left, up); + + LLQuaternion new_torso_rot = (cur_torso_rot * ~right_hand_rot) * target_aim_rot; + + // find ideal additive rotation to make torso point in correct direction + new_torso_rot = new_torso_rot * ~cur_torso_rot; + + // slerp from current additive rotation to ideal additive rotation + new_torso_rot = nlerp(slerp_amt, mTorsoState->getRotation(), new_torso_rot); + + // constraint overall torso rotation + LLQuaternion total_rot = new_torso_rot * mTorsoJoint->getRotation(); + total_rot.constrain(F_PI_BY_TWO * 0.8f); + new_torso_rot = total_rot * ~mTorsoJoint->getRotation(); + + mTorsoState->setRotation(new_torso_rot); + + return result; +} + +//----------------------------------------------------------------------------- +// LLTargetingMotion::onDeactivate() +//----------------------------------------------------------------------------- +void LLTargetingMotion::onDeactivate() +{ +} + + +// End + -- cgit v1.2.3