diff -Nur indra.orig/llcharacter/llkeyframemotion.cpp indra/llcharacter/llkeyframemotion.cpp --- indra.orig/llcharacter/llkeyframemotion.cpp 2015-01-10 00:49:30.814895800 +0900 +++ indra/llcharacter/llkeyframemotion.cpp 2015-01-10 11:41:24.077539000 +0900 @@ -396,8 +396,10 @@ //----------------------------------------------------------------------------- // JointMotion::update() +// modified by Fumi.Iseki for External Animation //----------------------------------------------------------------------------- -void LLKeyframeMotion::JointMotion::update(LLJointState* joint_state, F32 time, F32 duration) +//void LLKeyframeMotion::JointMotion::update(LLJointState* joint_state, F32 time, F32 duration) +void LLKeyframeMotion::JointMotion::update(LLJointState* joint_state, F32 time, F32 duration, LLKeyframeMotion* motion) { // this value being 0 is the cause of https://jira.lindenlab.com/browse/SL-22678 but I haven't // managed to get a stack to see how it got here. Testing for 0 here will stop the crash. @@ -408,12 +410,26 @@ U32 usage = joint_state->getUsage(); + // added by Fumi.Iseki for External Animation + if (motion!=NULL) motion->externalAnimation.CheckChannelIndexShm(); + //------------------------------------------------------------------------- // update scale component of joint state //------------------------------------------------------------------------- if ((usage & LLJointState::SCALE) && mScaleCurve.mNumKeys) { - joint_state->setScale( mScaleCurve.getValue( time, duration ) ); + // modified by Fumi.Iseki for External Animation + LLVector3 vect; + + if (motion!=NULL && motion->externalAnimation.isExternal) { + vect = motion->externalAnimation.GetAnimationScale(joint_state->getJoint()->getName()); + } + else { + vect = mScaleCurve.getValue( time, duration ); + } + + joint_state->setScale( vect ); + //joint_state->setScale( mScaleCurve.getValue( time, duration ) ); } //------------------------------------------------------------------------- @@ -421,7 +437,18 @@ //------------------------------------------------------------------------- if ((usage & LLJointState::ROT) && mRotationCurve.mNumKeys) { - joint_state->setRotation( mRotationCurve.getValue( time, duration ) ); + // modified by Fumi.Iseki for External Animation + LLQuaternion quat; + + if (motion!=NULL && motion->externalAnimation.isExternal) { + quat = motion->externalAnimation.GetAnimationRotation(joint_state->getJoint()->getName()); + } + else { + quat = mRotationCurve.getValue( time, duration ); + } + + joint_state->setRotation( quat ); + //joint_state->setRotation( mRotationCurve.getValue( time, duration ) ); } //------------------------------------------------------------------------- @@ -429,7 +456,18 @@ //------------------------------------------------------------------------- if ((usage & LLJointState::POS) && mPositionCurve.mNumKeys) { - joint_state->setPosition( mPositionCurve.getValue( time, duration ) ); + // modified by Fumi.Iseki for External Animation + LLVector3 vect; + + if (motion!=NULL && motion->externalAnimation.isExternal) { + vect = motion->externalAnimation.GetAnimationPosition(joint_state->getJoint()->getName()); + } + else { + vect = mPositionCurve.getValue( time, duration ); + } + + joint_state->setPosition( vect ); + //joint_state->setPosition( mPositionCurve.getValue( time, duration ) ); } } @@ -452,7 +490,8 @@ mLastLoopedTime(0.f), mAssetStatus(ASSET_UNDEFINED) { - + // added by Fumi.Iseki for External Animation + externalAnimation.init(id); } @@ -753,9 +792,10 @@ llassert_always (mJointMotionList->getNumJointMotions() <= mJointStates.size()); for (U32 i=0; igetNumJointMotions(); i++) { + // modified by Fumi.Iseki for External Animation mJointMotionList->getJointMotion(i)->update(mJointStates[i], time, - mJointMotionList->mDuration ); + mJointMotionList->mDuration, this ); } LLJoint::JointPriority* pose_priority = (LLJoint::JointPriority* )mCharacter->getAnimationData("Hand Pose Priority"); diff -Nur indra.orig/llcharacter/llkeyframemotion.h indra/llcharacter/llkeyframemotion.h --- indra.orig/llcharacter/llkeyframemotion.h 2015-01-10 00:49:30.814895800 +0900 +++ indra/llcharacter/llkeyframemotion.h 2015-01-10 11:44:03.290645500 +0900 @@ -51,6 +51,9 @@ #include "llbvhconsts.h" #include +// added by Fumi.Iseki for External Animation +#include "nslExternalAnimation.h" + class LLKeyframeDataCache; class LLVFS; class LLDataPacker; @@ -269,6 +272,8 @@ BOOL deserialize(LLDataPacker& dp); BOOL isLoaded() { return !!mJointMotionList; } + // added by Fumi.Iseki for External Animation + nsl::ExternalAnimation externalAnimation; // setters for modifying a keyframe animation void setLoop(BOOL loop); @@ -496,7 +501,9 @@ U32 mUsage; LLJoint::JointPriority mPriority; - void update(LLJointState* joint_state, F32 time, F32 duration); + // modified by Fumi.Iseki for External Animation + //void update(LLJointState* joint_state, F32 time, F32 duration); + void update(LLJointState* joint_state, F32 time, F32 duration, LLKeyframeMotion* motion=NULL); }; //------------------------------------------------------------------------- diff -Nur indra.orig/llcharacter/nslExternalAnimation.cpp indra/llcharacter/nslExternalAnimation.cpp --- indra.orig/llcharacter/nslExternalAnimation.cpp 1970-01-01 09:00:00.000000000 +0900 +++ indra/llcharacter/nslExternalAnimation.cpp 2013-07-01 23:50:35.956956800 +0900 @@ -0,0 +1,270 @@ +/** + * nslExternalAnimation.cpp v2.0 + * + * Copyright (c) 2011, Fumi.Iseki + * + */ + +#include "linden_common.h" +#include "llcharacter.h" + +#include "nslExternalAnimation.h" + + + +using namespace nsl; + + + +static std::string SLJointName[] = +{ + "mPelvis", + "mTorso", + "mChest", + "mNeck", + "mHead", + "mCollarLeft", + "mShoulderLeft", + "mElbowLeft", + "mWristLeft", + "mCollarRight", + "mShoulderRight", + "mElbowRight", + "mWristRight", + "mHipLeft", + "mKneeLeft", + "mAnkleLeft", + "mHipRight", + "mKneeRight", + "mAnkleRight" +}; + + + + + + +void ExternalAnimation::init(LLUUID id) +{ + uuid = id; + isExternal = FALSE; + indexHandle = NULL; + ptrIndex = NULL; + + for (int i=0; i=EXANIM_JOINT_NUM ) return; + + if (ptrShm[n]==NULL) { + if (mapHandle[n]==NULL) { + mapHandle[n] = OpenFileMappingA(FILE_MAP_READ, FALSE, SLJointName[n].c_str()); + } + + if (mapHandle[n]!=NULL) { + ptrShm[n] = (double*)MapViewOfFile(mapHandle[n], FILE_MAP_READ, 0, 0, EXANIM_DATA_SIZE *EXANIM_CHANNEL_NUM); + } + } +} + + + + +void ExternalAnimation::CloseShm(void) +{ + CloseIndexShm(); + + for (int i=0; i=0) isExternal = TRUE; + else isExternal = FALSE; +} + + + + + + +///////////////////////////////////////////////////////////////////////////////////// +// Get Joint Data + +LLQuaternion ExternalAnimation::GetAnimationRotation(std::string joint_name) +{ + LLQuaternion quat(0.0, 0.0, 0.0, 1.0); + + char* ptr = NULL; + for (int i=0; i