279 {
282 s32 i;
283
284
285 normalizedLengths[0] = 0.0f;
286 for (i = 1; i < num; i++) {
287 f32 dx = pathPositions[i].
x - pathPositions[i-1].
x;
288 f32 dy = pathPositions[i].
y - pathPositions[i-1].
y;
289 f32 dz = pathPositions[i].
z - pathPositions[i-1].
z;
291 normalizedLengths[i] = normalizedLengths[i-1] + length;
292 }
293 for (i = 1; i < num; i++) {
294 normalizedLengths[i] /= normalizedLengths[num-1];
295 }
296
297
298 outVectors[0].
x = 0.0f;
299 outVectors[0].
y = 0.0f;
300 outVectors[0].
z = 0.0f;
301 outVectors[num-1].
x = 0.0f;
302 outVectors[num-1].
y = 0.0f;
303 outVectors[num-1].
z = 0.0f;
304
305 for (i = 0; i < num - 1; i++) {
306 lenBuf[i] = normalizedLengths[i+1] - normalizedLengths[i];
307 vecBuf[i+1].
x = (pathPositions[i+1].
x - pathPositions[i].
x) / lenBuf[i];
308 vecBuf[i+1].
y = (pathPositions[i+1].
y - pathPositions[i].
y) / lenBuf[i];
309 vecBuf[i+1].
z = (pathPositions[i+1].
z - pathPositions[i].
z) / lenBuf[i];
310 }
311
312
313 outVectors[1].
x = vecBuf[2].
x - vecBuf[1].
x;
314 outVectors[1].
y = vecBuf[2].
y - vecBuf[1].
y;
315 outVectors[1].
z = vecBuf[2].
z - vecBuf[1].
z;
316 vecBuf[1].
x = 2.0f * (normalizedLengths[2] - normalizedLengths[0]);
317 vecBuf[1].
y = 2.0f * (normalizedLengths[2] - normalizedLengths[0]);
318 vecBuf[1].
z = 2.0f * (normalizedLengths[2] - normalizedLengths[0]);
319
320
321 for (i = 1; i < num - 2; i++) {
322 f32 sx = lenBuf[i] / vecBuf[i].
x;
323 f32 sy = lenBuf[i] / vecBuf[i].
y;
324 f32 sz = lenBuf[i] / vecBuf[i].
z;
325 outVectors[i+1].
x = (vecBuf[i+2].
x - vecBuf[i+1].
x) - outVectors[i].x * sx;
326 outVectors[i+1].
y = (vecBuf[i+2].
y - vecBuf[i+1].
y) - outVectors[i].y * sy;
327 outVectors[i+1].
z = (vecBuf[i+2].
z - vecBuf[i+1].
z) - outVectors[i].z * sz;
328 vecBuf[i+1].
x = 2.0f * (normalizedLengths[i+2] - normalizedLengths[i]) - lenBuf[i] * sx;
329 vecBuf[i+1].
y = 2.0f * (normalizedLengths[i+2] - normalizedLengths[i]) - lenBuf[i] * sy;
330 vecBuf[i+1].
z = 2.0f * (normalizedLengths[i+2] - normalizedLengths[i]) - lenBuf[i] * sz;
331 }
332
333
334 outVectors[num-2].
x -= (lenBuf[num-2] * outVectors[num-1].
x);
335 outVectors[num-2].
y -= (lenBuf[num-2] * outVectors[num-1].
y);
336 outVectors[num-2].
z -= (lenBuf[num-2] * outVectors[num-1].
z);
337
338 for (i = num - 2; i > 0; i--) {
339 outVectors[i].
x = (outVectors[i].
x - (lenBuf[i] * outVectors[i+1].
x)) / vecBuf[i].
x;
340 outVectors[i].
y = (outVectors[i].
y - (lenBuf[i] * outVectors[i+1].
y)) / vecBuf[i].
y;
341 outVectors[i].
z = (outVectors[i].
z - (lenBuf[i] * outVectors[i+1].
z)) / vecBuf[i].
z;
342 }
343
346}
void * heap_malloc(s32 size)