diff --git a/External/tely b/External/tely index cc7ef01..d58010b 160000 --- a/External/tely +++ b/External/tely @@ -1 +1 @@ -Subproject commit cc7ef01f28ee6a09f7811c58480e9a94a1667d42 +Subproject commit d58010b431d3ed7ee0076f3195f1d2a8ccc4a220 diff --git a/feely_pona.cpp b/feely_pona.cpp index 1498153..b9ea650 100644 --- a/feely_pona.cpp +++ b/feely_pona.cpp @@ -1424,7 +1424,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer) Dqn_Profiler_ZoneScopeWithIndex("FP_Render", FP_ProfileZone_FPRender); TELY_PlatformInput *input = &platform->input; Dqn_M2x3 model_view = FP_Game_CameraModelViewM2x3(game->camera, platform); - Dqn_V2 world_mouse_p = Dqn_M2x3_MulV2(model_view, input->mouse_p); + Dqn_V2 world_mouse_p = input->mouse_p + game->camera.world_pos; // NOTE: Draw tiles ============================================================================ Dqn_usize tile_count_x = DQN_CAST(Dqn_usize)(platform->core.window_size.w / game->tile_size); @@ -1670,7 +1670,7 @@ void TELY_DLL_FrameUpdate(void *user_data) Dqn_M2x3 model_view = FP_Game_CameraModelViewM2x3(game->camera, platform); TELY_Render_PushTransform(renderer, model_view); - Dqn_V2 world_mouse_p = Dqn_M2x3_MulV2(model_view, input->mouse_p); + Dqn_V2 world_mouse_p = input->mouse_p + game->camera.world_pos; // ============================================================================================= diff --git a/feely_pona_game.cpp b/feely_pona_game.cpp index 7e84ca5..2731ce2 100644 --- a/feely_pona_game.cpp +++ b/feely_pona_game.cpp @@ -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; }