MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / getGround

Method getGround

Engine/source/ts/tsThread.cpp:115–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115void TSThread::getGround(F32 t, MatrixF * pMat)
116{
117 static const QuatF unitRotation(0,0,0,1);
118 static const Point3F unitTranslation = Point3F::Zero;
119
120 const QuatF * q1, * q2;
121 QuatF rot1,rot2;
122 const Point3F * p1, * p2;
123
124 // if N = sequence->numGroundFrames, then there are N+1 positions we
125 // interpolate betweeen: 0/N, 1/N ... N/N
126 // we need to convert the p passed to us into 2 ground keyframes:
127
128 // the 0.99999f is in case 'p' is exactly 1.0f, which is legal but 'kf'
129 // needs to be strictly less than 'sequence->numGroundFrames'
130 F32 kf = 0.999999f * t * (F32) getSequence()->numGroundFrames;
131
132 // get frame number and interp param (kpos)
133 S32 frame = (S32)kf;
134 F32 kpos = kf - (F32)frame;
135
136 // now point pT1 and pT2 at transforms for keyframes 'frame' and 'frame+1'
137
138 // following a little strange: first ground keyframe (0/N in comment above) is
139 // assumed to be ident. and not found in the list.
140 if (frame)
141 {
142 p1 = &mShapeInstance->mShape->groundTranslations[getSequence()->firstGroundFrame + frame - 1];
143 q1 = &mShapeInstance->mShape->groundRotations[getSequence()->firstGroundFrame + frame - 1].getQuatF(&rot1);
144 }
145 else
146 {
147 p1 = &unitTranslation;
148 q1 = &unitRotation;
149 }
150
151 // similar to above, ground keyframe number 'frame+1' is actually offset by 'frame'
152 p2 = &mShapeInstance->mShape->groundTranslations[getSequence()->firstGroundFrame + frame];
153 q2 = &mShapeInstance->mShape->groundRotations[getSequence()->firstGroundFrame + frame].getQuatF(&rot2);
154
155 QuatF q;
156 Point3F p;
157 TSTransform::interpolate(*q1,*q2,kpos,&q);
158 TSTransform::interpolate(*p1,*p2,kpos,&p);
159 TSTransform::setMatrix(q,p,pMat);
160}
161
162void TSThread::setSequence(S32 seq, F32 toPos)
163{

Callers 1

addPathMethod · 0.80

Calls 2

setMatrixFunction · 0.85
getQuatFMethod · 0.80

Tested by

no test coverage detected