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

Method buildTimeMap

Engine/source/T3D/cameraSpline.cpp:139–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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