Rename all member variables to follow the style guidelines (prefixed with the 'm') - class TSThread

This commit is contained in:
bank 2014-05-13 16:44:16 +04:00
parent a310983e49
commit bcb0b8e088
3 changed files with 184 additions and 184 deletions

View file

@ -157,9 +157,9 @@ void TSShapeInstance::animateNodes(S32 ss)
if (!rotBeenSet.test(nodeIndex))
{
QuatF q1,q2;
mShape->getRotation(*th->getSequence(),th->keyNum1,j,&q1);
mShape->getRotation(*th->getSequence(),th->keyNum2,j,&q2);
TSTransform::interpolate(q1,q2,th->keyPos,&smNodeCurrentRotations[nodeIndex]);
mShape->getRotation(*th->getSequence(),th->mKeyNum1,j,&q1);
mShape->getRotation(*th->getSequence(),th->mKeyNum2,j,&q2);
TSTransform::interpolate(q1,q2,th->mKeyPos,&smNodeCurrentRotations[nodeIndex]);
rotBeenSet.set(nodeIndex);
smRotationThreads[nodeIndex] = th;
}
@ -178,9 +178,9 @@ void TSShapeInstance::animateNodes(S32 ss)
handleMaskedPositionNode(th,nodeIndex,j);
else
{
const Point3F & p1 = mShape->getTranslation(*th->getSequence(),th->keyNum1,j);
const Point3F & p2 = mShape->getTranslation(*th->getSequence(),th->keyNum2,j);
TSTransform::interpolate(p1,p2,th->keyPos,&smNodeCurrentTranslations[nodeIndex]);
const Point3F & p1 = mShape->getTranslation(*th->getSequence(),th->mKeyNum1,j);
const Point3F & p2 = mShape->getTranslation(*th->getSequence(),th->mKeyNum2,j);
TSTransform::interpolate(p1,p2,th->mKeyPos,&smNodeCurrentTranslations[nodeIndex]);
smTranslationThreads[nodeIndex] = th;
}
tranBeenSet.set(nodeIndex);
@ -222,7 +222,7 @@ void TSShapeInstance::animateNodes(S32 ss)
for (i=firstBlend; i<mThreadList.size(); i++)
{
TSThread * th = mThreadList[i];
if (th->blendDisabled)
if (th->mBlendDisabled)
continue;
handleBlendSequence(th,a,b);
@ -330,7 +330,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
if (nodeIndex<a)
continue;
TSThread * thread = smRotationThreads[nodeIndex];
thread = thread && thread->transitionData.inTransition ? thread : NULL;
thread = thread && thread->mTransitionData.inTransition ? thread : NULL;
if (!thread)
{
// if not controlled by a sequence in transition then there must be
@ -338,7 +338,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
// transition now...use that thread to control interpolation
for (S32 i=0; i<mTransitionThreads.size(); i++)
{
if (mTransitionThreads[i]->transitionData.oldRotationNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->rotationMatters.test(nodeIndex))
if (mTransitionThreads[i]->mTransitionData.oldRotationNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->rotationMatters.test(nodeIndex))
{
thread = mTransitionThreads[i];
break;
@ -347,7 +347,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
AssertFatal(thread!=NULL,"TSShapeInstance::handleRotTransitionNodes (rotation)");
}
QuatF tmpQ;
TSTransform::interpolate(mNodeReferenceRotations[nodeIndex].getQuatF(&tmpQ),smNodeCurrentRotations[nodeIndex],thread->transitionData.pos,&smNodeCurrentRotations[nodeIndex]);
TSTransform::interpolate(mNodeReferenceRotations[nodeIndex].getQuatF(&tmpQ),smNodeCurrentRotations[nodeIndex],thread->mTransitionData.pos,&smNodeCurrentRotations[nodeIndex]);
}
// then translation
@ -356,7 +356,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
for (nodeIndex=start; nodeIndex<end; mTransitionTranslationNodes.next(nodeIndex))
{
TSThread * thread = smTranslationThreads[nodeIndex];
thread = thread && thread->transitionData.inTransition ? thread : NULL;
thread = thread && thread->mTransitionData.inTransition ? thread : NULL;
if (!thread)
{
// if not controlled by a sequence in transition then there must be
@ -364,7 +364,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
// transition now...use that thread to control interpolation
for (S32 i=0; i<mTransitionThreads.size(); i++)
{
if (mTransitionThreads[i]->transitionData.oldTranslationNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->translationMatters.test(nodeIndex))
if (mTransitionThreads[i]->mTransitionData.oldTranslationNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->translationMatters.test(nodeIndex))
{
thread = mTransitionThreads[i];
break;
@ -375,7 +375,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
Point3F & p = smNodeCurrentTranslations[nodeIndex];
Point3F & p1 = mNodeReferenceTranslations[nodeIndex];
Point3F & p2 = p;
F32 k = thread->transitionData.pos;
F32 k = thread->mTransitionData.pos;
p.x = p1.x + k * (p2.x-p1.x);
p.y = p1.y + k * (p2.y-p1.y);
p.z = p1.z + k * (p2.z-p1.z);
@ -389,7 +389,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
for (nodeIndex=start; nodeIndex<end; mTransitionScaleNodes.next(nodeIndex))
{
TSThread * thread = smScaleThreads[nodeIndex];
thread = thread && thread->transitionData.inTransition ? thread : NULL;
thread = thread && thread->mTransitionData.inTransition ? thread : NULL;
if (!thread)
{
// if not controlled by a sequence in transition then there must be
@ -397,7 +397,7 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
// transition now...use that thread to control interpolation
for (S32 i=0; i<mTransitionThreads.size(); i++)
{
if (mTransitionThreads[i]->transitionData.oldScaleNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->scaleMatters.test(nodeIndex))
if (mTransitionThreads[i]->mTransitionData.oldScaleNodes.test(nodeIndex) || mTransitionThreads[i]->getSequence()->scaleMatters.test(nodeIndex))
{
thread = mTransitionThreads[i];
break;
@ -406,14 +406,14 @@ void TSShapeInstance::handleTransitionNodes(S32 a, S32 b)
AssertFatal(thread!=NULL,"TSShapeInstance::handleTransitionNodes (scale).");
}
if (animatesUniformScale())
smNodeCurrentUniformScales[nodeIndex] += thread->transitionData.pos * (mNodeReferenceUniformScales[nodeIndex]-smNodeCurrentUniformScales[nodeIndex]);
smNodeCurrentUniformScales[nodeIndex] += thread->mTransitionData.pos * (mNodeReferenceUniformScales[nodeIndex]-smNodeCurrentUniformScales[nodeIndex]);
else if (animatesAlignedScale())
TSTransform::interpolate(mNodeReferenceScaleFactors[nodeIndex],smNodeCurrentAlignedScales[nodeIndex],thread->transitionData.pos,&smNodeCurrentAlignedScales[nodeIndex]);
TSTransform::interpolate(mNodeReferenceScaleFactors[nodeIndex],smNodeCurrentAlignedScales[nodeIndex],thread->mTransitionData.pos,&smNodeCurrentAlignedScales[nodeIndex]);
else
{
QuatF q;
TSTransform::interpolate(mNodeReferenceScaleFactors[nodeIndex],smNodeCurrentArbitraryScales[nodeIndex].mScale,thread->transitionData.pos,&smNodeCurrentArbitraryScales[nodeIndex].mScale);
TSTransform::interpolate(mNodeReferenceArbitraryScaleRots[nodeIndex].getQuatF(&q),smNodeCurrentArbitraryScales[nodeIndex].mRotate,thread->transitionData.pos,&smNodeCurrentArbitraryScales[nodeIndex].mRotate);
TSTransform::interpolate(mNodeReferenceScaleFactors[nodeIndex],smNodeCurrentArbitraryScales[nodeIndex].mScale,thread->mTransitionData.pos,&smNodeCurrentArbitraryScales[nodeIndex].mScale);
TSTransform::interpolate(mNodeReferenceArbitraryScaleRots[nodeIndex].getQuatF(&q),smNodeCurrentArbitraryScales[nodeIndex].mRotate,thread->mTransitionData.pos,&smNodeCurrentArbitraryScales[nodeIndex].mRotate);
}
}
}
@ -498,26 +498,26 @@ void TSShapeInstance::handleAnimatedScale(TSThread * thread, S32 a, S32 b, TSInt
case 4: // uniform -> aligned
case 8: // uniform -> arbitrary
{
F32 s1 = mShape->getUniformScale(*thread->getSequence(),thread->keyNum1,j);
F32 s2 = mShape->getUniformScale(*thread->getSequence(),thread->keyNum2,j);
uniformScale = TSTransform::interpolate(s1,s2,thread->keyPos);
F32 s1 = mShape->getUniformScale(*thread->getSequence(),thread->mKeyNum1,j);
F32 s2 = mShape->getUniformScale(*thread->getSequence(),thread->mKeyNum2,j);
uniformScale = TSTransform::interpolate(s1,s2,thread->mKeyPos);
alignedScale.set(uniformScale,uniformScale,uniformScale);
break;
}
case 5: // aligned -> aligned
case 9: // aligned -> arbitrary
{
const Point3F & s1 = mShape->getAlignedScale(*thread->getSequence(),thread->keyNum1,j);
const Point3F & s2 = mShape->getAlignedScale(*thread->getSequence(),thread->keyNum2,j);
TSTransform::interpolate(s1,s2,thread->keyPos,&alignedScale);
const Point3F & s1 = mShape->getAlignedScale(*thread->getSequence(),thread->mKeyNum1,j);
const Point3F & s2 = mShape->getAlignedScale(*thread->getSequence(),thread->mKeyNum2,j);
TSTransform::interpolate(s1,s2,thread->mKeyPos,&alignedScale);
break;
}
case 10: // arbitrary -> arbitary
{
TSScale s1,s2;
mShape->getArbitraryScale(*thread->getSequence(),thread->keyNum1,j,&s1);
mShape->getArbitraryScale(*thread->getSequence(),thread->keyNum2,j,&s2);
TSTransform::interpolate(s1,s2,thread->keyPos,&arbitraryScale);
mShape->getArbitraryScale(*thread->getSequence(),thread->mKeyNum1,j,&s1);
mShape->getArbitraryScale(*thread->getSequence(),thread->mKeyNum2,j,&s2);
TSTransform::interpolate(s1,s2,thread->mKeyPos,&arbitraryScale);
break;
}
default: AssertFatal(0,"TSShapeInstance::handleAnimatedScale"); break;
@ -556,10 +556,10 @@ void TSShapeInstance::handleAnimatedScale(TSThread * thread, S32 a, S32 b, TSInt
void TSShapeInstance::handleMaskedPositionNode(TSThread * th, S32 nodeIndex, S32 offset)
{
const Point3F & p1 = mShape->getTranslation(*th->getSequence(),th->keyNum1,offset);
const Point3F & p2 = mShape->getTranslation(*th->getSequence(),th->keyNum2,offset);
const Point3F & p1 = mShape->getTranslation(*th->getSequence(),th->mKeyNum1,offset);
const Point3F & p2 = mShape->getTranslation(*th->getSequence(),th->mKeyNum2,offset);
Point3F p;
TSTransform::interpolate(p1,p2,th->keyPos,&p);
TSTransform::interpolate(p1,p2,th->mKeyPos,&p);
if (!mMaskPosXNodes.test(nodeIndex))
smNodeCurrentTranslations[nodeIndex].x = p.x;
@ -600,20 +600,20 @@ void TSShapeInstance::handleBlendSequence(TSThread * thread, S32 a, S32 b)
if (thread->getSequence()->rotationMatters.test(nodeIndex))
{
QuatF q1,q2;
mShape->getRotation(*thread->getSequence(),thread->keyNum1,jrot,&q1);
mShape->getRotation(*thread->getSequence(),thread->keyNum2,jrot,&q2);
mShape->getRotation(*thread->getSequence(),thread->mKeyNum1,jrot,&q1);
mShape->getRotation(*thread->getSequence(),thread->mKeyNum2,jrot,&q2);
QuatF quat;
TSTransform::interpolate(q1,q2,thread->keyPos,&quat);
TSTransform::interpolate(q1,q2,thread->mKeyPos,&quat);
TSTransform::setMatrix(quat,&mat);
jrot++;
}
if (thread->getSequence()->translationMatters.test(nodeIndex))
{
const Point3F & p1 = mShape->getTranslation(*thread->getSequence(),thread->keyNum1,jtrans);
const Point3F & p2 = mShape->getTranslation(*thread->getSequence(),thread->keyNum2,jtrans);
const Point3F & p1 = mShape->getTranslation(*thread->getSequence(),thread->mKeyNum1,jtrans);
const Point3F & p2 = mShape->getTranslation(*thread->getSequence(),thread->mKeyNum2,jtrans);
Point3F p;
TSTransform::interpolate(p1,p2,thread->keyPos,&p);
TSTransform::interpolate(p1,p2,thread->mKeyPos,&p);
mat.setColumn(3,p);
jtrans++;
}
@ -622,26 +622,26 @@ void TSShapeInstance::handleBlendSequence(TSThread * thread, S32 a, S32 b)
{
if (thread->getSequence()->animatesUniformScale())
{
F32 s1 = mShape->getUniformScale(*thread->getSequence(),thread->keyNum1,jscale);
F32 s2 = mShape->getUniformScale(*thread->getSequence(),thread->keyNum2,jscale);
F32 scale = TSTransform::interpolate(s1,s2,thread->keyPos);
F32 s1 = mShape->getUniformScale(*thread->getSequence(),thread->mKeyNum1,jscale);
F32 s2 = mShape->getUniformScale(*thread->getSequence(),thread->mKeyNum2,jscale);
F32 scale = TSTransform::interpolate(s1,s2,thread->mKeyPos);
TSTransform::applyScale(scale,&mat);
}
else if (animatesAlignedScale())
{
Point3F s1 = mShape->getAlignedScale(*thread->getSequence(),thread->keyNum1,jscale);
Point3F s2 = mShape->getAlignedScale(*thread->getSequence(),thread->keyNum2,jscale);
Point3F s1 = mShape->getAlignedScale(*thread->getSequence(),thread->mKeyNum1,jscale);
Point3F s2 = mShape->getAlignedScale(*thread->getSequence(),thread->mKeyNum2,jscale);
Point3F scale;
TSTransform::interpolate(s1,s2,thread->keyPos,&scale);
TSTransform::interpolate(s1,s2,thread->mKeyPos,&scale);
TSTransform::applyScale(scale,&mat);
}
else
{
TSScale s1,s2;
mShape->getArbitraryScale(*thread->getSequence(),thread->keyNum1,jscale,&s1);
mShape->getArbitraryScale(*thread->getSequence(),thread->keyNum2,jscale,&s2);
mShape->getArbitraryScale(*thread->getSequence(),thread->mKeyNum1,jscale,&s1);
mShape->getArbitraryScale(*thread->getSequence(),thread->mKeyNum2,jscale,&s2);
TSScale scale;
TSTransform::interpolate(s1,s2,thread->keyPos,&scale);
TSTransform::interpolate(s1,s2,thread->mKeyPos,&scale);
TSTransform::applyScale(scale,&mat);
}
jscale++;
@ -704,14 +704,14 @@ void TSShapeInstance::animateVisibility(S32 ss)
{
if (!beenSet.test(objectIndex) && th->getSequence()->visMatters.test(objectIndex))
{
F32 state1 = mShape->getObjectState(*th->getSequence(),th->keyNum1,j).vis;
F32 state2 = mShape->getObjectState(*th->getSequence(),th->keyNum2,j).vis;
F32 state1 = mShape->getObjectState(*th->getSequence(),th->mKeyNum1,j).vis;
F32 state2 = mShape->getObjectState(*th->getSequence(),th->mKeyNum2,j).vis;
if ((state1-state2) * (state1-state2) > 0.99f)
// goes from 0 to 1 -- discreet jump
mMeshObjects[objectIndex].visible = th->keyPos<0.5f ? state1 : state2;
mMeshObjects[objectIndex].visible = th->mKeyPos<0.5f ? state1 : state2;
else
// interpolate between keyframes when visibility change is gradual
mMeshObjects[objectIndex].visible = (1.0f-th->keyPos) * state1 + th->keyPos * state2;
mMeshObjects[objectIndex].visible = (1.0f-th->mKeyPos) * state1 + th->mKeyPos * state2;
// record change so that later threads don't over-write us...
beenSet.set(objectIndex);
@ -765,7 +765,7 @@ void TSShapeInstance::animateFrame(S32 ss)
{
if (!beenSet.test(objectIndex) && th->getSequence()->frameMatters.test(objectIndex))
{
S32 key = (th->keyPos<0.5f) ? th->keyNum1 : th->keyNum2;
S32 key = (th->mKeyPos<0.5f) ? th->mKeyNum1 : th->mKeyNum2;
mMeshObjects[objectIndex].frame = mShape->getObjectState(*th->getSequence(),key,j).frameIndex;
// record change so that later threads don't over-write us...
@ -820,7 +820,7 @@ void TSShapeInstance::animateMatFrame(S32 ss)
{
if (!beenSet.test(objectIndex) && th->getSequence()->matFrameMatters.test(objectIndex))
{
S32 key = (th->keyPos<0.5f) ? th->keyNum1 : th->keyNum2;
S32 key = (th->mKeyPos<0.5f) ? th->mKeyNum1 : th->mKeyNum2;
mMeshObjects[objectIndex].matFrame = mShape->getObjectState(*th->getSequence(),key,j).matFrameIndex;
// record change so that later threads don't over-write us...
@ -909,7 +909,7 @@ void TSShapeInstance::animateSubtrees(bool forceFull)
void TSShapeInstance::addPath(TSThread *gt, F32 start, F32 end, MatrixF *mat)
{
// never get here while in transition...
AssertFatal(!gt->transitionData.inTransition,"TSShapeInstance::addPath");
AssertFatal(!gt->mTransitionData.inTransition,"TSShapeInstance::addPath");
if (!mat)
mat = &mGroundTransform;
@ -932,7 +932,7 @@ bool TSShapeInstance::initGround()
for (S32 i=0; i<mThreadList.size(); i++)
{
TSThread * th = mThreadList[i];
if (!th->transitionData.inTransition && th->getSequence()->numGroundFrames>0)
if (!th->mTransitionData.inTransition && th->getSequence()->numGroundFrames>0)
{
mGroundThread = th;
return true;
@ -950,9 +950,9 @@ void TSShapeInstance::animateGround()
if (!mGroundThread && !initGround())
return;
S32 & loop = mGroundThread->path.loop;
F32 & start = mGroundThread->path.start;
F32 & end = mGroundThread->path.end;
S32 & loop = mGroundThread->mPath.loop;
F32 & start = mGroundThread->mPath.start;
F32 & end = mGroundThread->mPath.end;
// accumulate path transform
if (loop>0)
@ -980,7 +980,7 @@ void TSShapeInstance::deltaGround(TSThread * thread, F32 start, F32 end, MatrixF
mat = &mGroundTransform;
mat->identity();
if (thread->transitionData.inTransition)
if (thread->mTransitionData.inTransition)
return;
F32 invDuration = 1.0f / thread->getDuration();
@ -994,7 +994,7 @@ void TSShapeInstance::deltaGround(TSThread * thread, F32 start, F32 end, MatrixF
void TSShapeInstance::deltaGround1(TSThread * thread, F32 start, F32 end, MatrixF& mat)
{
mat.identity();
if (thread->transitionData.inTransition)
if (thread->mTransitionData.inTransition)
return;
addPath(thread, start, end, &mat);
}

View file

@ -696,20 +696,20 @@ class TSThread
{
friend class TSShapeInstance;
S32 priority;
S32 mPriority;
TSShapeInstance * mShapeInstance; ///< Instance of the shape that this thread animates
S32 sequence; ///< Sequence this thread will perform
F32 pos;
S32 mSequence; ///< Sequence this thread will perform
F32 mPos;
F32 timeScale; ///< How fast to play through the sequence
F32 mTimeScale; ///< How fast to play through the sequence
S32 keyNum1; ///< Keyframe at or before current position
S32 keyNum2; ///< Keyframe at or after current position
F32 keyPos;
S32 mKeyNum1; ///< Keyframe at or before current position
S32 mKeyNum2; ///< Keyframe at or after current position
F32 mKeyPos;
bool blendDisabled; ///< Blend with other sequences?
bool mBlendDisabled; ///< Blend with other sequences?
/// if in transition...
struct TransitionData
@ -726,15 +726,15 @@ class TSThread
TSIntegerSet oldScaleNodes; ///< nodes controlled by this thread pre-transition
U32 oldSequence; ///< sequence that was set before transition began
F32 oldPos; ///< position of sequence before transition began
} transitionData;
} mTransitionData;
struct
{
F32 start;
F32 end;
S32 loop;
} path;
bool makePath;
} mPath;
bool mMakePath;
/// given a position on the thread, choose correct keyframes
/// slight difference between one-shot and cyclic sequences -- see comments below for details
@ -783,10 +783,10 @@ class TSThread
public:
TSShapeInstance * getShapeInstance() { return mShapeInstance; }
bool hasSequence() const { return sequence >= 0; }
U32 getSeqIndex() const { return sequence; }
const TSSequence* getSequence() const { return &(mShapeInstance->mShape->mSequences[sequence]); }
const String& getSequenceName() const { return mShapeInstance->mShape->getSequenceName(sequence); }
bool hasSequence() const { return mSequence >= 0; }
U32 getSeqIndex() const { return mSequence; }
const TSSequence* getSequence() const { return &(mShapeInstance->mShape->mSequences[mSequence]); }
const String& getSequenceName() const { return mShapeInstance->mShape->getSequenceName(mSequence); }
S32 operator<(const TSThread &) const;
};

View file

@ -168,19 +168,19 @@ void TSThread::setSequence(S32 seq, F32 toPos)
mShapeInstance->clearTransition(this);
sequence = seq;
priority = getSequence()->priority;
pos = toPos;
makePath = getSequence()->makePath();
path.start = path.end = 0;
path.loop = 0;
mSequence = seq;
mPriority = getSequence()->priority;
mPos = toPos;
mMakePath = getSequence()->makePath();
mPath.start = mPath.end = 0;
mPath.loop = 0;
// 1.0f doesn't exist on cyclic sequences
if (pos>0.9999f && getSequence()->isCyclic())
pos = 0.9999f;
if (mPos>0.9999f && getSequence()->isCyclic())
mPos = 0.9999f;
// select keyframes
selectKeyframes(pos,getSequence(),&keyNum1,&keyNum2,&keyPos);
selectKeyframes(mPos,getSequence(),&mKeyNum1,&mKeyNum2,&mKeyPos);
}
void TSThread::transitionToSequence(S32 seq, F32 toPos, F32 duration, bool continuePlay)
@ -192,49 +192,49 @@ void TSThread::transitionToSequence(S32 seq, F32 toPos, F32 duration, bool conti
// of the transition is interpolated. If we start to transtion from A to B,
// but before reaching B we transtion to C, we interpolate all nodes controlled
// by A, B, or C to their new position.
if (transitionData.inTransition)
if (mTransitionData.inTransition)
{
transitionData.oldRotationNodes.overlap(getSequence()->rotationMatters);
transitionData.oldTranslationNodes.overlap(getSequence()->translationMatters);
transitionData.oldScaleNodes.overlap(getSequence()->scaleMatters);
mTransitionData.oldRotationNodes.overlap(getSequence()->rotationMatters);
mTransitionData.oldTranslationNodes.overlap(getSequence()->translationMatters);
mTransitionData.oldScaleNodes.overlap(getSequence()->scaleMatters);
}
else
{
transitionData.oldRotationNodes = getSequence()->rotationMatters;
transitionData.oldTranslationNodes = getSequence()->translationMatters;
transitionData.oldScaleNodes = getSequence()->scaleMatters;
mTransitionData.oldRotationNodes = getSequence()->rotationMatters;
mTransitionData.oldTranslationNodes = getSequence()->translationMatters;
mTransitionData.oldScaleNodes = getSequence()->scaleMatters;
}
// set time characteristics of transition
transitionData.oldSequence = sequence;
transitionData.oldPos = pos;
transitionData.duration = duration;
transitionData.pos = 0.0f;
transitionData.direction = timeScale>0.0f ? 1.0f : -1.0f;
transitionData.targetScale = continuePlay ? 1.0f : 0.0f;
mTransitionData.oldSequence = mSequence;
mTransitionData.oldPos = mPos;
mTransitionData.duration = duration;
mTransitionData.pos = 0.0f;
mTransitionData.direction = mTimeScale>0.0f ? 1.0f : -1.0f;
mTransitionData.targetScale = continuePlay ? 1.0f : 0.0f;
// in transition...
transitionData.inTransition = true;
mTransitionData.inTransition = true;
// set target sequence data
sequence = seq;
priority = getSequence()->priority;
pos = toPos;
makePath = getSequence()->makePath();
path.start = path.end = 0;
path.loop = 0;
mSequence = seq;
mPriority = getSequence()->priority;
mPos = toPos;
mMakePath = getSequence()->makePath();
mPath.start = mPath.end = 0;
mPath.loop = 0;
// 1.0f doesn't exist on cyclic sequences
if (pos>0.9999f && getSequence()->isCyclic())
pos = 0.9999f;
if (mPos>0.9999f && getSequence()->isCyclic())
mPos = 0.9999f;
// select keyframes
selectKeyframes(pos,getSequence(),&keyNum1,&keyNum2,&keyPos);
selectKeyframes(mPos,getSequence(),&mKeyNum1,&mKeyNum2,&mKeyPos);
}
bool TSThread::isInTransition()
{
return transitionData.inTransition;
return mTransitionData.inTransition;
}
void TSThread::animateTriggers()
@ -242,30 +242,30 @@ void TSThread::animateTriggers()
if (!getSequence()->numTriggers)
return;
switch (path.loop)
switch (mPath.loop)
{
case -1 :
activateTriggers(path.start,0);
activateTriggers(1,path.end);
activateTriggers(mPath.start,0);
activateTriggers(1,mPath.end);
break;
case 0 :
activateTriggers(path.start,path.end);
activateTriggers(mPath.start,mPath.end);
break;
case 1 :
activateTriggers(path.start,1);
activateTriggers(0,path.end);
activateTriggers(mPath.start,1);
activateTriggers(0,mPath.end);
break;
default:
{
if (path.loop>0)
if (mPath.loop>0)
{
activateTriggers(path.end,1);
activateTriggers(0,path.end);
activateTriggers(mPath.end,1);
activateTriggers(0,mPath.end);
}
else
{
activateTriggers(path.end,0);
activateTriggers(1,path.end);
activateTriggers(mPath.end,0);
activateTriggers(1,mPath.end);
}
}
}
@ -320,32 +320,32 @@ void TSThread::activateTriggers(F32 a, F32 b)
F32 TSThread::getPos()
{
return transitionData.inTransition ? transitionData.pos : pos;
return mTransitionData.inTransition ? mTransitionData.pos : mPos;
}
F32 TSThread::getTime()
{
return transitionData.inTransition ? transitionData.pos * transitionData.duration : pos * getSequence()->duration;
return mTransitionData.inTransition ? mTransitionData.pos * mTransitionData.duration : mPos * getSequence()->duration;
}
F32 TSThread::getDuration()
{
return transitionData.inTransition ? transitionData.duration : getSequence()->duration;
return mTransitionData.inTransition ? mTransitionData.duration : getSequence()->duration;
}
F32 TSThread::getScaledDuration()
{
return getDuration() / mFabs(timeScale);
return getDuration() / mFabs(mTimeScale);
}
F32 TSThread::getTimeScale()
{
return timeScale;
return mTimeScale;
}
void TSThread::setTimeScale(F32 ts)
{
timeScale = ts;
mTimeScale = ts;
}
void TSThread::advancePos(F32 delta)
@ -353,76 +353,76 @@ void TSThread::advancePos(F32 delta)
if (mFabs(delta)>0.00001f)
{
// make dirty what this thread changes
U32 dirtyFlags = getSequence()->dirtyFlags | (transitionData.inTransition ? TSShapeInstance::TransformDirty : 0);
U32 dirtyFlags = getSequence()->dirtyFlags | (mTransitionData.inTransition ? TSShapeInstance::TransformDirty : 0);
for (S32 i=0; i<mShapeInstance->getShape()->mSubShapeFirstNode.size(); i++)
mShapeInstance->mDirtyFlags[i] |= dirtyFlags;
}
if (transitionData.inTransition)
if (mTransitionData.inTransition)
{
transitionData.pos += transitionData.direction * delta;
if (transitionData.pos<0 || transitionData.pos>=1.0f)
mTransitionData.pos += mTransitionData.direction * delta;
if (mTransitionData.pos<0 || mTransitionData.pos>=1.0f)
{
mShapeInstance->clearTransition(this);
if (transitionData.pos<0.0f)
if (mTransitionData.pos<0.0f)
// return to old sequence
mShapeInstance->setSequence(this,transitionData.oldSequence,transitionData.oldPos);
mShapeInstance->setSequence(this,mTransitionData.oldSequence,mTransitionData.oldPos);
}
// re-adjust delta to be correct time-wise
delta *= transitionData.targetScale * transitionData.duration / getSequence()->duration;
delta *= mTransitionData.targetScale * mTransitionData.duration / getSequence()->duration;
}
// even if we are in a transition, keep playing the sequence
if (makePath)
if (mMakePath)
{
path.start = pos;
pos += delta;
mPath.start = mPos;
mPos += delta;
if (!getSequence()->isCyclic())
{
pos = mClampF(pos , 0.0f, 1.0f);
path.loop = 0;
mPos = mClampF(mPos , 0.0f, 1.0f);
mPath.loop = 0;
}
else
{
path.loop = (S32)pos;
if (pos < 0.0f)
path.loop--;
pos -= path.loop;
mPath.loop = (S32)mPos;
if (mPos < 0.0f)
mPath.loop--;
mPos -= mPath.loop;
// following necessary because of floating point roundoff errors
if (pos < 0.0f) pos += 1.0f;
if (pos >= 1.0f) pos -= 1.0f;
if (mPos < 0.0f) mPos += 1.0f;
if (mPos >= 1.0f) mPos -= 1.0f;
}
path.end = pos;
mPath.end = mPos;
animateTriggers(); // do this automatically...no need for user to call it
AssertFatal(pos>=0.0f && pos<=1.0f,"TSThread::advancePos (1)");
AssertFatal(!getSequence()->isCyclic() || pos<1.0f,"TSThread::advancePos (2)");
AssertFatal(mPos>=0.0f && mPos<=1.0f,"TSThread::advancePos (1)");
AssertFatal(!getSequence()->isCyclic() || mPos<1.0f,"TSThread::advancePos (2)");
}
else
{
pos += delta;
mPos += delta;
if (!getSequence()->isCyclic())
pos = mClampF(pos, 0.0f, 1.0f);
mPos = mClampF(mPos, 0.0f, 1.0f);
else
{
pos -= S32(pos);
mPos -= S32(mPos);
// following necessary because of floating point roundoff errors
if (pos < 0.0f) pos += 1.0f;
if (pos >= 1.0f) pos -= 1.0f;
if (mPos < 0.0f) mPos += 1.0f;
if (mPos >= 1.0f) mPos -= 1.0f;
}
AssertFatal(pos>=0.0f && pos<=1.0f,"TSThread::advancePos (3)");
AssertFatal(!getSequence()->isCyclic() || pos<1.0f,"TSThread::advancePos (4)");
AssertFatal(mPos>=0.0f && mPos<=1.0f,"TSThread::advancePos (3)");
AssertFatal(!getSequence()->isCyclic() || mPos<1.0f,"TSThread::advancePos (4)");
}
// select keyframes
selectKeyframes(pos,getSequence(),&keyNum1,&keyNum2,&keyPos);
selectKeyframes(mPos,getSequence(),&mKeyNum1,&mKeyNum2,&mKeyPos);
}
void TSThread::advanceTime(F32 delta)
{
advancePos(timeScale * delta / getDuration());
advancePos(mTimeScale * delta / getDuration());
}
void TSThread::setPos(F32 pos)
@ -432,40 +432,40 @@ void TSThread::setPos(F32 pos)
void TSThread::setTime(F32 time)
{
setPos(timeScale * time/getDuration());
setPos(mTimeScale * time/getDuration());
}
S32 TSThread::getKeyframeCount()
{
AssertFatal(!transitionData.inTransition,"TSThread::getKeyframeCount: not while in transition");
AssertFatal(!mTransitionData.inTransition,"TSThread::getKeyframeCount: not while in transition");
return getSequence()->numKeyframes + 1;
}
S32 TSThread::getKeyframeNumber()
{
AssertFatal(!transitionData.inTransition,"TSThread::getKeyframeNumber: not while in transition");
AssertFatal(!mTransitionData.inTransition,"TSThread::getKeyframeNumber: not while in transition");
return keyNum1;
return mKeyNum1;
}
void TSThread::setKeyframeNumber(S32 kf)
{
AssertFatal(kf>=0 && kf<= getSequence()->numKeyframes,
"TSThread::setKeyframeNumber: invalid frame specified.");
AssertFatal(!transitionData.inTransition,"TSThread::setKeyframeNumber: not while in transition");
AssertFatal(!mTransitionData.inTransition,"TSThread::setKeyframeNumber: not while in transition");
keyNum1 = keyNum2 = kf;
keyPos = 0;
pos = 0;
mKeyNum1 = mKeyNum2 = kf;
mKeyPos = 0;
mPos = 0;
}
TSThread::TSThread(TSShapeInstance * _shapeInst)
{
timeScale = 1.0f;
mTimeScale = 1.0f;
mShapeInstance = _shapeInst;
transitionData.inTransition = false;
blendDisabled = false;
mTransitionData.inTransition = false;
mBlendDisabled = false;
setSequence(0,0.0f);
}
@ -475,9 +475,9 @@ S32 TSThread::operator<(const TSThread & th2) const
{
// both blend or neither blend, sort based on priority only -- higher priority first
S32 ret = 0; // do it this way to (hopefully) take advantage of 'conditional move' assembly instruction
if (priority > th2.priority)
if (mPriority > th2.mPriority)
ret = -1;
if (th2.priority > priority)
if (th2.mPriority > mPriority)
ret = 1;
return ret;
}
@ -542,7 +542,7 @@ U32 TSShapeInstance::threadCount()
void TSShapeInstance::setSequence(TSThread * thread, S32 seq, F32 pos)
{
if ( (thread->transitionData.inTransition && mTransitionThreads.size()>1) || mTransitionThreads.size()>0)
if ( (thread->mTransitionData.inTransition && mTransitionThreads.size()>1) || mTransitionThreads.size()>0)
{
// if we have transitions, make sure transforms are up to date...
sortThreads();
@ -565,7 +565,7 @@ U32 TSShapeInstance::getSequence(TSThread * thread)
{
//AssertFatal( thread->sequence >= 0, "TSShapeInstance::getSequence: range error A");
//AssertFatal( thread->sequence < mShape->sequences.size(), "TSShapeInstance::getSequence: range error B");
return (U32)thread->sequence;
return (U32)thread->mSequence;
}
void TSShapeInstance::transitionToSequence(TSThread * thread, S32 seq, F32 pos, F32 duration, bool continuePlay)
@ -583,13 +583,13 @@ void TSShapeInstance::transitionToSequence(TSThread * thread, S32 seq, F32 pos,
else if (!mScaleCurrentlyAnimated && thread->getSequence()->animatesScale())
mScaleCurrentlyAnimated=true;
mTransitionRotationNodes.overlap(thread->transitionData.oldRotationNodes);
mTransitionRotationNodes.overlap(thread->mTransitionData.oldRotationNodes);
mTransitionRotationNodes.overlap(thread->getSequence()->rotationMatters);
mTransitionTranslationNodes.overlap(thread->transitionData.oldTranslationNodes);
mTransitionTranslationNodes.overlap(thread->mTransitionData.oldTranslationNodes);
mTransitionTranslationNodes.overlap(thread->getSequence()->translationMatters);
mTransitionScaleNodes.overlap(thread->transitionData.oldScaleNodes);
mTransitionScaleNodes.overlap(thread->mTransitionData.oldScaleNodes);
mTransitionScaleNodes.overlap(thread->getSequence()->scaleMatters);
// if we aren't already in the list of transition threads, add us now
@ -605,7 +605,7 @@ void TSShapeInstance::transitionToSequence(TSThread * thread, S32 seq, F32 pos,
void TSShapeInstance::clearTransition(TSThread * thread)
{
if (!thread->transitionData.inTransition)
if (!thread->mTransitionData.inTransition)
return;
// if other transitions are still playing,
@ -614,7 +614,7 @@ void TSShapeInstance::clearTransition(TSThread * thread)
animateNodeSubtrees();
// turn off transition...
thread->transitionData.inTransition = false;
thread->mTransitionData.inTransition = false;
// remove us from transition list
S32 i;
@ -632,13 +632,13 @@ void TSShapeInstance::clearTransition(TSThread * thread)
mTransitionScaleNodes.clearAll();
for (i=0; i<mTransitionThreads.size(); i++)
{
mTransitionRotationNodes.overlap(mTransitionThreads[i]->transitionData.oldRotationNodes);
mTransitionRotationNodes.overlap(mTransitionThreads[i]->mTransitionData.oldRotationNodes);
mTransitionRotationNodes.overlap(mTransitionThreads[i]->getSequence()->rotationMatters);
mTransitionTranslationNodes.overlap(mTransitionThreads[i]->transitionData.oldTranslationNodes);
mTransitionTranslationNodes.overlap(mTransitionThreads[i]->mTransitionData.oldTranslationNodes);
mTransitionTranslationNodes.overlap(mTransitionThreads[i]->getSequence()->translationMatters);
mTransitionScaleNodes.overlap(mTransitionThreads[i]->transitionData.oldScaleNodes);
mTransitionScaleNodes.overlap(mTransitionThreads[i]->mTransitionData.oldScaleNodes);
mTransitionScaleNodes.overlap(mTransitionThreads[i]->getSequence()->scaleMatters);
}
@ -709,10 +709,10 @@ void TSShapeInstance::updateTransitions()
for (i=0; i<mTransitionThreads.size(); i++)
{
TSThread * th = mTransitionThreads[i];
if (th->transitionData.inTransition)
if (th->mTransitionData.inTransition)
{
th->transitionData.duration *= 1.0f - th->transitionData.pos;
th->transitionData.pos = 0.0f;
th->mTransitionData.duration *= 1.0f - th->mTransitionData.pos;
th->mTransitionData.pos = 0.0f;
}
}
}
@ -728,22 +728,22 @@ void TSShapeInstance::checkScaleCurrentlyAnimated()
void TSShapeInstance::setBlendEnabled(TSThread * thread, bool blendOn)
{
thread->blendDisabled = !blendOn;
thread->mBlendDisabled = !blendOn;
}
bool TSShapeInstance::getBlendEnabled(TSThread * thread)
{
return !thread->blendDisabled;
return !thread->mBlendDisabled;
}
void TSShapeInstance::setPriority(TSThread * thread, F32 priority)
{
thread->priority = priority;
thread->mPriority = priority;
}
F32 TSShapeInstance::getPriority(TSThread * thread)
{
return thread->priority;
return thread->mPriority;
}
F32 TSShapeInstance::getTime(TSThread * thread)