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

Method buildTimeMap

Engine/source/T3D/cameraSpline.cpp:143–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141static bool gBuilding = false;
142
143void CameraSpline::buildTimeMap()
144{
145 if (!mIsMapDirty)
146 return;
147
148 gBuilding = true;
149
150 mTimeMap.clear();
151 mTimeMap.reserve(size()*3); // preallocate
152
153 // Initial node and knot value..
154 TimeMap map;
155 map.mTime = 0;
156 map.mDistance = 0;
157 mTimeMap.push_back(map);
158
159 Knot ka,kj,ki;
160 value(0, &kj, true);
161 F32 length = 0.0f;
162 ka = kj;
163
164 // Loop through the knots and add nodes. Nodes are added for every knot and
165 // whenever the spline length and segment length deviate by epsilon.
166 F32 epsilon = Con::getFloatVariable("CameraSpline::epsilon", 0.90f);
167 const F32 Step = 0.05f;
168 F32 lt = 0,time = 0;
169 do
170 {
171 if ((time += Step) > F32(mSize - 1))
172 time = (F32)mSize - 1.0f;
173
174 value(time, &ki, true);
175 length += (ki.mPosition - kj.mPosition).len();
176 F32 segment = (ki.mPosition - ka.mPosition).len();
177
178 if ((segment / length) < epsilon || time == (mSize - 1) || mFloor(lt) != mFloor(time))
179 {
180 map.mTime = time;
181 map.mDistance = length;
182 mTimeMap.push_back(map);
183 ka = ki;
184 }
185 kj = ki;
186 lt = time;
187 }
188 while (time < mSize - 1);
189
190 mIsMapDirty = false;
191
192 gBuilding = false;
193}
194
195
196//-----------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 7

getFloatVariableFunction · 0.85
mFloorFunction · 0.85
sizeFunction · 0.50
clearMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected