twndel: fix y axis point move

This commit is contained in:
veclavtalica 2025-03-08 04:10:14 +03:00
parent 5f7b8bac6d
commit 78b6a26de9

View File

@ -200,8 +200,7 @@ static bool find_closest_point(uint8_t* object_result, uint16_t *point_result) {
float ray_dist = vec3_length(b);
if (ray_dist > ((float)SELECTION_SPHERE_RADIUS / POINTS_PER_METER))
continue;
Vec3 i = vec3_add(p, b);
float dist = vec3_length(i);
float dist = vec3_length(vec3_add(p, b));
if (dist < closest_distance) {
closest_distance = dist;
closest_obj = obj;
@ -225,6 +224,7 @@ static bool find_closest_point(uint8_t* object_result, uint16_t *point_result) {
static void process_operation_move_point(Operation *op) {
/* finish dragging around */
/* TODO: dont keep empty ops on stack? */
if (input_action_just_released("select")) {
state.op_active = false;
return;
@ -246,13 +246,15 @@ static void process_operation_move_point(Operation *op) {
/* TODO: show thresholds */
log_vec3(b, "cross");
/* change along axes, delta is accumulated when threshold is met*/
int16_t xch = (int16_t)(floorf(vec3_dot(b, (Vec3){0,0,1}) * (float)POINTS_PER_METER)) * !state.axis_mask[0];
xch -= xch % state.grid_snap_granularity;
state.points[op->data.move_point.point].x += xch;
op->data.move_point.delta_x += xch;
int16_t ych = (int16_t)(floorf(vec3_dot(b, (Vec3){0,-1,0}) * (float)POINTS_PER_METER)) * !state.axis_mask[1];
int16_t ych = (int16_t)(floorf(vec3_dot(vec3_cross(b, pos_and_ray.direction), (Vec3){0,-1,0}) * (float)POINTS_PER_METER)) * !state.axis_mask[1];
ych -= ych % state.grid_snap_granularity;
state.points[op->data.move_point.point].y += ych;
op->data.move_point.delta_y += ych;