diff --git a/src/game_api/game_api.cpp b/src/game_api/game_api.cpp index 7b333c631..b4521058a 100644 --- a/src/game_api/game_api.cpp +++ b/src/game_api/game_api.cpp @@ -1,6 +1,8 @@ #include "game_api.hpp" +#include "render_api.hpp" #include "search.hpp" +#include "state.hpp" GameAPI* GameAPI::get() { @@ -11,7 +13,8 @@ GameAPI* GameAPI::get() float GameAPI::get_current_zoom() { - return renderer->current_zoom + renderer->current_zoom_offset; + auto state = State::get().ptr(); + return renderer->current_zoom + get_layer_transition_zoom_offset(state->camera_layer); } float GameAPI::get_target_zoom() diff --git a/src/game_api/render_api.cpp b/src/game_api/render_api.cpp index a85f35c5a..011694831 100644 --- a/src/game_api/render_api.cpp +++ b/src/game_api/render_api.cpp @@ -64,6 +64,7 @@ void render_loading(size_t param_1) } std::optional g_forced_lut_textures[2]{}; +float g_layer_zoom_offset[2]; using RenderLayer = void(const std::vector&, uint8_t, const Camera&, const char**, const char**); RenderLayer* g_render_layer_trampoline{nullptr}; @@ -72,6 +73,9 @@ void render_layer(const std::vector& lightsources, uint8_t layer, if (trigger_vanilla_render_layer_callbacks(ON::RENDER_PRE_LAYER, layer)) return; + auto game_api = GameAPI::get(); + g_layer_zoom_offset[layer] = game_api->renderer->current_zoom_offset; + // The lhs and rhs LUTs are blended in the shader, but we don't know where that value is CPU side so we can only override // with a single LUT for now if (g_forced_lut_textures[layer]) @@ -106,6 +110,11 @@ void render_game(StateMemory* state) trigger_vanilla_render_callbacks(ON::RENDER_POST_GAME); } +float get_layer_transition_zoom_offset(uint8_t l) +{ + return g_layer_zoom_offset[l]; +} + void RenderAPI::set_lut(TEXTURE texture_id, uint8_t layer) { g_forced_lut_textures[layer] = texture_id; diff --git a/src/game_api/render_api.hpp b/src/game_api/render_api.hpp index 352f167fe..d0c90d1f7 100644 --- a/src/game_api/render_api.hpp +++ b/src/game_api/render_api.hpp @@ -365,6 +365,7 @@ void init_render_api_hooks(); bool& get_journal_enabled(); void on_open_journal_chapter(JournalUI* journal_ui, uint8_t chapter, bool instant, bool play_sound); void render_draw_depth(Layer* layer, uint8_t draw_depth, float bbox_left, float bbox_bottom, float bbox_right, float bbox_top); +float get_layer_transition_zoom_offset(uint8_t layer); struct HudInventory {