From f86f3dd41a94d39273313b9695197d0fbc459473 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Sun, 9 Mar 2025 08:12:29 +0300 Subject: [PATCH] /apps/tools/twndel: use roundf for snapping --- apps/tools/twndel/tool.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/tools/twndel/tool.c b/apps/tools/twndel/tool.c index 22f24e0..7e172f4 100644 --- a/apps/tools/twndel/tool.c +++ b/apps/tools/twndel/tool.c @@ -354,7 +354,7 @@ static void process_operation_move_point(Operation *op) { Vec3 s; if (!state.axis_mask[0]) { if (vector_plane_intersection(cam.position, cam.direction, p, plane_normal_x, &s)) { - int16_t xch = (int16_t)(floorf(vec3_dot(vec3_sub(s, p), (Vec3){1,0,0}) * (float)POINTS_PER_METER)); + int16_t xch = (int16_t)(roundf(vec3_dot(vec3_sub(s, p), (Vec3){1,0,0}) * (float)POINTS_PER_METER)); xch -= xch % state.grid_snap_granularity; state.points[op->data.move_point.point].x += xch; op->data.move_point.delta_x += xch; @@ -364,7 +364,7 @@ static void process_operation_move_point(Operation *op) { if (!state.axis_mask[1]) { if (vector_plane_intersection(cam.position, cam.direction, p, (Vec3){0,0,1}, &s)) { - int16_t ych = (int16_t)(floorf(vec3_dot(vec3_sub(s, p), (Vec3){0,1,0}) * (float)POINTS_PER_METER)); + int16_t ych = (int16_t)(roundf(vec3_dot(vec3_sub(s, p), (Vec3){0,1,0}) * (float)POINTS_PER_METER)); ych -= ych % state.grid_snap_granularity; state.points[op->data.move_point.point].y += ych; op->data.move_point.delta_y += ych; @@ -374,7 +374,7 @@ static void process_operation_move_point(Operation *op) { if (!state.axis_mask[2]) { if (vector_plane_intersection(cam.position, cam.direction, p, plane_normal_z, &s)) { - int16_t zch = (int16_t)(floorf(vec3_dot(vec3_sub(s, p), (Vec3){0,0,1}) * (float)POINTS_PER_METER)); + int16_t zch = (int16_t)(roundf(vec3_dot(vec3_sub(s, p), (Vec3){0,0,1}) * (float)POINTS_PER_METER)); zch -= zch % state.grid_snap_granularity; state.points[op->data.move_point.point].z += zch; op->data.move_point.delta_z += zch;