fp: Get camera fix

This commit is contained in:
2023-10-01 14:38:31 +11:00
parent e5282f7706
commit f258886d68
3 changed files with 13 additions and 5 deletions
+10 -2
View File
@@ -23,15 +23,23 @@ static bool operator!=(FP_GameEntityHandle const &lhs, FP_GameEntityHandle const
return result;
}
// TODO(doyle): Use this
struct FP_GameCameraM2x3
{
Dqn_M2x3 model_view;
Dqn_M2x3 view_model;
};
static Dqn_M2x3 FP_Game_CameraModelViewM2x3(FP_GameCamera camera, TELY_Platform *platform)
{
Dqn_M2x3 result = Dqn_M2x3_Identity();
if (platform) {
Dqn_V2 rotate_origin = camera.world_pos - (Dqn_V2_InitV2I(platform->core.window_size) * .5f);
Dqn_V2 center_offset = Dqn_V2_InitV2I(platform->core.window_size) * .5f;
Dqn_V2 rotate_origin = -camera.world_pos - center_offset;
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Translate(rotate_origin));
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Rotate(camera.rotate_rads));
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Scale(camera.scale));
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Translate(-rotate_origin + camera.world_pos));
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Translate(center_offset));
}
return result;
}