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

Method value

Engine/source/T3D/cameraSpline.cpp:296–399  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

294
295//-----------------------------------------------------------------------------
296void CameraSpline::value(F32 t, CameraSpline::Knot *result, bool skip_rotation)
297{
298 // Do some easing in and out for t.
299 if(!gBuilding)
300 {
301 F32 oldT = t;
302 if(oldT < 0.5f)
303 {
304 t = 0.5f - (mSin( (0.5 - oldT) * M_PI ) / 2.f);
305 }
306
307 if((F32(size()) - 1.5f) > 0.f && oldT - (F32(size()) - 1.5f) > 0.f)
308 {
309 oldT -= (F32(size()) - 1.5f);
310 t = (F32(size()) - 1.5f) + (mCos( (0.5f - oldT) * F32(M_PI) ) / 2.f);
311 }
312 }
313
314 // Verify that t is in range [0 >= t > size]
315// AssertFatal(t >= 0.0f && t < (F32)size(), "t out of range");
316 Knot *p1 = getKnot((S32)mFloor(t));
317 Knot *p2 = next(p1);
318
319 F32 i = t - mFloor(t); // adjust t to 0 to 1 on p1-p2 interval
320
321 if (p1->mPath == Knot::SPLINE)
322 {
323 Knot *p0 = (p1->mType == Knot::KINK) ? p1 : prev(p1);
324 Knot *p3 = (p2->mType == Knot::KINK) ? p2 : next(p2);
325 result->mPosition.x = mCatmullrom(i, p0->mPosition.x, p1->mPosition.x, p2->mPosition.x, p3->mPosition.x);
326 result->mPosition.y = mCatmullrom(i, p0->mPosition.y, p1->mPosition.y, p2->mPosition.y, p3->mPosition.y);
327 result->mPosition.z = mCatmullrom(i, p0->mPosition.z, p1->mPosition.z, p2->mPosition.z, p3->mPosition.z);
328 }
329 else
330 { // Linear
331 result->mPosition.interpolate(p1->mPosition, p2->mPosition, i);
332 }
333
334 if (skip_rotation)
335 return;
336
337 buildTimeMap();
338
339 // find the two knots to interpolate rotation and velocity through since some
340 // knots are only positional
341 S32 start = (S32)mFloor(t);
342 S32 end = (p2 == p1) ? start : (start + 1);
343 while (p1->mType == Knot::POSITION_ONLY && p1 != front())
344 {
345 p1 = prev(p1);
346 start--;
347 }
348
349 while (p2->mType == Knot::POSITION_ONLY && p2 != back())
350 {
351 p2 = next(p2);
352 end++;
353 }

Callers 7

interpolateMatMethod · 0.45
resetMethod · 0.45
interpolateMatMethod · 0.45
resetMethod · 0.45
loadImportConfigMethod · 0.45
loadSISFileMethod · 0.45
resetImportConfigMethod · 0.45

Calls 9

mSinFunction · 0.85
mCosFunction · 0.85
mFloorFunction · 0.85
mCatmullromFunction · 0.85
backClass · 0.85
sizeFunction · 0.50
nextFunction · 0.50
prevFunction · 0.50
interpolateMethod · 0.45

Tested by

no test coverage detected