MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / xCutscene_SetCamera

Function xCutscene_SetCamera

src/SB/Core/x/xCutscene.cpp:295–356  ·  view source on GitHub ↗

TODO: general pointer/index mismatching in here instructions and control flow should be close match though

Source from the content-addressed store, hash-verified

293// TODO: general pointer/index mismatching in here
294// instructions and control flow should be close match though
295void xCutscene_SetCamera(xCutscene* csn, xCamera* cam)
296{
297 xCutsceneData* data = (xCutsceneData*)&csn->Play[1];
298 for (U32 i = 0; i < csn->Play->NumData; i++)
299 {
300 if (data[i].DataType == XCUTSCENEDATA_TYPE_CAMERA)
301 {
302 U32 dataIndex = data[i + 1].DataType;
303 S32 frame = std::floorf(30.0f * csn->CamTime);
304 zFlyKey* keys = (zFlyKey*)((char*)&data[i] + 0x14);
305
306 F32 lerp;
307 if (keys[i + 1].frame < frame)
308 {
309 lerp = 0.0f;
310 }
311 else if (keys[i].frame >= frame)
312 {
313 lerp = 1.0f;
314 keys += keys[i].frame - 2;
315 }
316 else
317 {
318 lerp = 30.0f * csn->CamTime - std::floorf(30.0f * csn->CamTime);
319 keys += keys[i].frame - frame;
320 }
321
322 F32 invlerp = 1.0f - lerp;
323
324 xMat4x3 camMat;
325 xMat3x3 tmpMat;
326 xQuat quats[2];
327 for (U32 j = 0; j < 2; j++)
328 {
329 tmpMat.right.x = -keys[j].matrix[0];
330 tmpMat.right.y = -keys[j].matrix[1];
331 tmpMat.right.z = -keys[j].matrix[2];
332 tmpMat.up.x = keys[j].matrix[3];
333 tmpMat.up.y = keys[j].matrix[4];
334 tmpMat.up.z = keys[j].matrix[5];
335 tmpMat.at.x = -keys[j].matrix[6];
336 tmpMat.at.y = -keys[j].matrix[7];
337 tmpMat.at.z = -keys[j].matrix[8];
338 xQuatFromMat(&quats[j], &tmpMat);
339 }
340
341 xQuat qresult;
342 xQuatSlerp(&qresult, &quats[0], &quats[1], lerp);
343 xQuatToMat(&qresult, &camMat);
344 xVec3Lerp(&camMat.pos, (xVec3*)&keys[0].matrix[9], (xVec3*)&keys[1].matrix[9], lerp);
345
346 U32 count;
347
348 F32 camFOV = 114.59155f *
349 std::atan((12.7f * (keys[0].aperture[0] * lerp + keys[1].aperture[0] * invlerp)) /
350 (keys[0].focal * lerp + keys[1].focal * invlerp));
351 cam->mat = camMat;
352 gCameraLastFov = 0.0f;

Callers

nothing calls this directly

Calls 7

floorfFunction · 0.85
xVec3LerpFunction · 0.85
atanFunction · 0.85
xCameraSetFOVFunction · 0.85
xQuatFromMatFunction · 0.70
xQuatSlerpFunction · 0.70
xQuatToMatFunction · 0.70

Tested by

no test coverage detected