From 479cc5450f7c6ac3954a50bd1560549efbc1d51c Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Sun, 14 Jan 2024 11:50:36 -0800 Subject: [PATCH] Modularize, but disable for now, snapping It needs to be smarter than just snapping to NxN grid on canvas. --- magic/src/n_pt_persp.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/magic/src/n_pt_persp.c b/magic/src/n_pt_persp.c index 31a72ea2b..e8819071d 100644 --- a/magic/src/n_pt_persp.c +++ b/magic/src/n_pt_persp.c @@ -11,6 +11,9 @@ provided with an alternative vanishing point). And in Novice mode, this plugin offers NO tools. + TODO - See if we can get `snap_to()` working for + axon. & oblique drawing modes. + by Bill Kendrick December 12, 2023 - January 14, 2024 @@ -341,6 +344,7 @@ void n_pt_persp_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); void n_pt_persp_draw_points(magic_api * api, int tool, SDL_Surface * canvas); void n_pt_persp_draw_one_point(magic_api * api, SDL_Surface * canvas, int x, int y, int i); +void snap_to(int which, int * x, int * y); Uint32 n_pt_persp_api_version(void) @@ -588,8 +592,7 @@ void n_pt_persp_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, fflush(stdout); #endif - x = (x / SNAP) * SNAP; - y = (y / SNAP) * SNAP; + snap_to(which, &x, &y); tool = which_to_tool[which]; @@ -761,10 +764,8 @@ void n_pt_persp_drag(magic_api * api, int which, int i, x1, y1, x2, y2; float slope; - old_x = (old_x / SNAP) * SNAP; - old_y = (old_y / SNAP) * SNAP; - x = (x / SNAP) * SNAP; - y = (y / SNAP) * SNAP; + snap_to(which, &old_x, &old_y); + snap_to(which, &x, &y); #ifdef DEBUG printf("\nn_pt_persp_drag\n"); @@ -1343,8 +1344,7 @@ void n_pt_persp_release(magic_api * api, int which, fflush(stdout); #endif - x = (x / SNAP) * SNAP; - y = (y / SNAP) * SNAP; + snap_to(which, &x, &y); which = which_to_tool[which]; @@ -1753,3 +1753,18 @@ void n_pt_persp_draw_one_point(magic_api * api, SDL_Surface * canvas, int x, int } } } + + +/* Snap to grids based on the tool */ +void snap_to(int which, int * x, int * y) { + if (which == TOOL_ISO_DRAW) { + /* FIXME */ + } else if (which == TOOL_DIM_DRAW) { + /* FIXME */ + } else if (which == TOOL_TRI_DRAW) { + /* FIXME */ + } else if (which == TOOL_OBLQ_DRAW || which == TOOL_OBLQ_DRAW_ALT) { + /* FIXME */ + } +} +