prevent pan when min/max zoom reached
This commit is contained in:
parent
2cf7208920
commit
1b9208dd3b
@ -297,7 +297,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Initialize world <-> draw <-> ui transforms
|
//- Initialize world <-> draw <-> ui transforms
|
||||||
|
|
||||||
f32 zoom_rate = 1.75;
|
f32 zoom_rate = 1.50;
|
||||||
f32 min_zoom = 0.03;
|
f32 min_zoom = 0.03;
|
||||||
f32 max_zoom = 50.0;
|
f32 max_zoom = 50.0;
|
||||||
f32 world_size = 256;
|
f32 world_size = 256;
|
||||||
@ -319,8 +319,9 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
{
|
{
|
||||||
frame->edit_camera_zoom = 1;
|
frame->edit_camera_zoom = 1;
|
||||||
}
|
}
|
||||||
|
frame->edit_camera_zoom = ClampF32(frame->edit_camera_zoom, min_zoom, max_zoom);
|
||||||
/* Offset edit camera based on cursor if panning / zooming */
|
/* Offset edit camera based on cursor if panning / zooming */
|
||||||
if (last_frame->edit_mode && (last_frame->zooms != 0 || (frame->is_panning && last_frame->is_panning)))
|
if (last_frame->edit_mode && ((last_frame->zooms != 0 && (frame->edit_camera_zoom != last_frame->edit_camera_zoom)) || (frame->is_panning && last_frame->is_panning)))
|
||||||
{
|
{
|
||||||
Xform last_frame_edit_to_ui_xf = Zi;
|
Xform last_frame_edit_to_ui_xf = Zi;
|
||||||
Xform edit_to_ui_xf = Zi;
|
Xform edit_to_ui_xf = Zi;
|
||||||
@ -339,7 +340,6 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
Vec2 diff = SubVec2(last_target_cursor, target_cursor);
|
Vec2 diff = SubVec2(last_target_cursor, target_cursor);
|
||||||
frame->edit_camera_pos = AddVec2(frame->edit_camera_pos, diff);
|
frame->edit_camera_pos = AddVec2(frame->edit_camera_pos, diff);
|
||||||
}
|
}
|
||||||
frame->edit_camera_zoom = ClampF32(frame->edit_camera_zoom, min_zoom, max_zoom);
|
|
||||||
frame->edit_camera_pos.x = ClampF32(frame->edit_camera_pos.x, -world_size / 2, world_size / 2);
|
frame->edit_camera_pos.x = ClampF32(frame->edit_camera_pos.x, -world_size / 2, world_size / 2);
|
||||||
frame->edit_camera_pos.y = ClampF32(frame->edit_camera_pos.y, -world_size / 2, world_size / 2);
|
frame->edit_camera_pos.y = ClampF32(frame->edit_camera_pos.y, -world_size / 2, world_size / 2);
|
||||||
target_camera_pos = frame->edit_camera_pos;
|
target_camera_pos = frame->edit_camera_pos;
|
||||||
@ -368,7 +368,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
}
|
}
|
||||||
else if (frame->edit_mode)
|
else if (frame->edit_mode)
|
||||||
{
|
{
|
||||||
lerp_ratio = 40.0 * frame->dt;
|
lerp_ratio = 30.0 * frame->dt;
|
||||||
}
|
}
|
||||||
frame->camera_pos = LerpVec2(last_frame->camera_pos, target_camera_pos, lerp_ratio);
|
frame->camera_pos = LerpVec2(last_frame->camera_pos, target_camera_pos, lerp_ratio);
|
||||||
frame->camera_zoom = LerpF32(last_frame->camera_zoom, target_camera_zoom, lerp_ratio);
|
frame->camera_zoom = LerpF32(last_frame->camera_zoom, target_camera_zoom, lerp_ratio);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user