Annotation of /trunk/indra/llcharacter/llmotion.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llmotion.cpp | ||
| 3 : | * @brief Implementation of LLMotion class. | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | mjm | 137 | * Copyright (c) 2001-2010, Linden Research, Inc. |
| 8 : | mjm | 135 | * |
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 17 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 18 : | * it is applied to this Source Code. View the full text of the exception | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at | ||
| 21 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | //----------------------------------------------------------------------------- | ||
| 34 : | // Header Files | ||
| 35 : | //----------------------------------------------------------------------------- | ||
| 36 : | #include "linden_common.h" | ||
| 37 : | |||
| 38 : | #include "llmotion.h" | ||
| 39 : | #include "llcriticaldamp.h" | ||
| 40 : | |||
| 41 : | //----------------------------------------------------------------------------- | ||
| 42 : | //----------------------------------------------------------------------------- | ||
| 43 : | // LLMotion class | ||
| 44 : | //----------------------------------------------------------------------------- | ||
| 45 : | //----------------------------------------------------------------------------- | ||
| 46 : | |||
| 47 : | //----------------------------------------------------------------------------- | ||
| 48 : | // LLMotion() | ||
| 49 : | // Class Constructor | ||
| 50 : | //----------------------------------------------------------------------------- | ||
| 51 : | LLMotion::LLMotion( const LLUUID &id ) : | ||
| 52 : | mStopped(TRUE), | ||
| 53 : | mActive(FALSE), | ||
| 54 : | mID(id), | ||
| 55 : | mActivationTimestamp(0.f), | ||
| 56 : | mStopTimestamp(0.f), | ||
| 57 : | mSendStopTimestamp(F32_MAX), | ||
| 58 : | mResidualWeight(0.f), | ||
| 59 : | mFadeWeight(1.f), | ||
| 60 : | mDeactivateCallback(NULL), | ||
| 61 : | mDeactivateCallbackUserData(NULL) | ||
| 62 : | { | ||
| 63 : | for (int i=0; i<3; ++i) | ||
| 64 : | memset(&mJointSignature[i][0], 0, sizeof(U8) * LL_CHARACTER_MAX_JOINTS); | ||
| 65 : | } | ||
| 66 : | |||
| 67 : | //----------------------------------------------------------------------------- | ||
| 68 : | // ~LLMotion() | ||
| 69 : | // Class Destructor | ||
| 70 : | //----------------------------------------------------------------------------- | ||
| 71 : | LLMotion::~LLMotion() | ||
| 72 : | { | ||
| 73 : | } | ||
| 74 : | |||
| 75 : | //----------------------------------------------------------------------------- | ||
| 76 : | // fadeOut() | ||
| 77 : | //----------------------------------------------------------------------------- | ||
| 78 : | void LLMotion::fadeOut() | ||
| 79 : | { | ||
| 80 : | if (mFadeWeight > 0.01f) | ||
| 81 : | { | ||
| 82 : | mFadeWeight = lerp(mFadeWeight, 0.f, LLCriticalDamp::getInterpolant(0.15f)); | ||
| 83 : | } | ||
| 84 : | else | ||
| 85 : | { | ||
| 86 : | mFadeWeight = 0.f; | ||
| 87 : | } | ||
| 88 : | } | ||
| 89 : | |||
| 90 : | //----------------------------------------------------------------------------- | ||
| 91 : | // fadeIn() | ||
| 92 : | //----------------------------------------------------------------------------- | ||
| 93 : | void LLMotion::fadeIn() | ||
| 94 : | { | ||
| 95 : | if (mFadeWeight < 0.99f) | ||
| 96 : | { | ||
| 97 : | mFadeWeight = lerp(mFadeWeight, 1.f, LLCriticalDamp::getInterpolant(0.15f)); | ||
| 98 : | } | ||
| 99 : | else | ||
| 100 : | { | ||
| 101 : | mFadeWeight = 1.f; | ||
| 102 : | } | ||
| 103 : | } | ||
| 104 : | |||
| 105 : | //----------------------------------------------------------------------------- | ||
| 106 : | // addJointState() | ||
| 107 : | //----------------------------------------------------------------------------- | ||
| 108 : | void LLMotion::addJointState(const LLPointer<LLJointState>& jointState) | ||
| 109 : | { | ||
| 110 : | mPose.addJointState(jointState); | ||
| 111 : | S32 priority = jointState->getPriority(); | ||
| 112 : | if (priority == LLJoint::USE_MOTION_PRIORITY) | ||
| 113 : | { | ||
| 114 : | priority = getPriority(); | ||
| 115 : | } | ||
| 116 : | |||
| 117 : | U32 usage = jointState->getUsage(); | ||
| 118 : | |||
| 119 : | // for now, usage is everything | ||
| 120 : | mJointSignature[0][jointState->getJoint()->getJointNum()] = (usage & LLJointState::POS) ? (0xff >> (7 - priority)) : 0; | ||
| 121 : | mJointSignature[1][jointState->getJoint()->getJointNum()] = (usage & LLJointState::ROT) ? (0xff >> (7 - priority)) : 0; | ||
| 122 : | mJointSignature[2][jointState->getJoint()->getJointNum()] = (usage & LLJointState::SCALE) ? (0xff >> (7 - priority)) : 0; | ||
| 123 : | } | ||
| 124 : | |||
| 125 : | void LLMotion::setDeactivateCallback( void (*cb)(void *), void* userdata ) | ||
| 126 : | { | ||
| 127 : | mDeactivateCallback = cb; | ||
| 128 : | mDeactivateCallbackUserData = userdata; | ||
| 129 : | } | ||
| 130 : | |||
| 131 : | //virtual | ||
| 132 : | void LLMotion::setStopTime(F32 time) | ||
| 133 : | { | ||
| 134 : | mStopTimestamp = time; | ||
| 135 : | mStopped = TRUE; | ||
| 136 : | } | ||
| 137 : | |||
| 138 : | BOOL LLMotion::isBlending() | ||
| 139 : | { | ||
| 140 : | return mPose.getWeight() < 1.f; | ||
| 141 : | } | ||
| 142 : | |||
| 143 : | //----------------------------------------------------------------------------- | ||
| 144 : | // activate() | ||
| 145 : | //----------------------------------------------------------------------------- | ||
| 146 : | void LLMotion::activate(F32 time) | ||
| 147 : | { | ||
| 148 : | mActivationTimestamp = time; | ||
| 149 : | mStopped = FALSE; | ||
| 150 : | mActive = TRUE; | ||
| 151 : | onActivate(); | ||
| 152 : | } | ||
| 153 : | |||
| 154 : | //----------------------------------------------------------------------------- | ||
| 155 : | // deactivate() | ||
| 156 : | //----------------------------------------------------------------------------- | ||
| 157 : | void LLMotion::deactivate() | ||
| 158 : | { | ||
| 159 : | mActive = FALSE; | ||
| 160 : | mPose.setWeight(0.f); | ||
| 161 : | |||
| 162 : | if (mDeactivateCallback) | ||
| 163 : | { | ||
| 164 : | (*mDeactivateCallback)(mDeactivateCallbackUserData); | ||
| 165 : | mDeactivateCallback = NULL; // only call callback once | ||
| 166 : | mDeactivateCallbackUserData = NULL; | ||
| 167 : | } | ||
| 168 : | |||
| 169 : | onDeactivate(); | ||
| 170 : | } | ||
| 171 : | |||
| 172 : | BOOL LLMotion::canDeprecate() | ||
| 173 : | { | ||
| 174 : | return TRUE; | ||
| 175 : | } | ||
| 176 : | |||
| 177 : | // End |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

