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

Method setSequenceGroundSpeed

Engine/source/ts/tsShapeEdit.cpp:2104–2161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2102}
2103
2104bool TSShape::setSequenceGroundSpeed(const String& seqName, const Point3F& trans, const Point3F& rot)
2105{
2106 // Find the sequence
2107 S32 seqIndex = findSequence(seqName);
2108 if (seqIndex < 0)
2109 {
2110 Con::errorf("setSequenceGroundSpeed: Could not find sequence named '%s'", seqName.c_str());
2111 return false;
2112 }
2113 TSShape::Sequence& seq = sequences[seqIndex];
2114
2115 // Determine how many ground-frames to generate (FPS=10, at least 1 frame)
2116 const F32 groundFrameRate = 10.0f;
2117 S32 numFrames = getMax(1, (S32)(seq.duration * groundFrameRate));
2118
2119 // Allocate space for the frames (add/delete frames as required)
2120 S32 frameAdjust = numFrames - seq.numGroundFrames;
2121 for (S32 i = 0; i < mAbs(frameAdjust); i++)
2122 {
2123 if (frameAdjust > 0)
2124 {
2125 groundTranslations.insert(seq.firstGroundFrame);
2126 groundRotations.insert(seq.firstGroundFrame);
2127 }
2128 else
2129 {
2130 groundTranslations.erase(seq.firstGroundFrame);
2131 groundRotations.erase(seq.firstGroundFrame);
2132 }
2133 }
2134
2135 // Fixup ground frame indices
2136 seq.numGroundFrames += frameAdjust;
2137 for (S32 i = seqIndex + 1; i < sequences.size(); i++)
2138 sequences[i].firstGroundFrame += frameAdjust;
2139
2140 // Generate the ground-frames
2141 Point3F adjTrans = trans;
2142 Point3F adjRot = rot;
2143 if (seq.numGroundFrames > 0)
2144 {
2145 adjTrans /= seq.numGroundFrames;
2146 adjRot /= seq.numGroundFrames;
2147 }
2148 QuatF rotSpeed(adjRot);
2149 QuatF groundRot(rotSpeed);
2150 for (S32 i = 0; i < seq.numGroundFrames; i++)
2151 {
2152 groundTranslations[seq.firstGroundFrame + i] = adjTrans * (i + 1);
2153 groundRotations[seq.firstGroundFrame + i].set(groundRot);
2154 groundRot *= rotSpeed;
2155 }
2156
2157 // set MakePath flag so ground frames will be animated
2158 seq.flags |= TSShape::MakePath;
2159
2160 return true;
2161}

Callers 2

getGroundInfoMethod · 0.80

Calls 8

getMaxFunction · 0.85
mAbsFunction · 0.85
errorfFunction · 0.50
c_strMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45
sizeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected