Skip to content

Commit

Permalink
Change SNAP_ROUND behavior
Browse files Browse the repository at this point in the history
Possibly breaks some tools!

The previous behavior was always rounding to inside the nearest voxel,
but usually when we snap to the volume we want to stay on top of it (and
then use a -0.5 offset to get inside if needed).

The new behavior only rounds along the tangent and binormal, but not the
normal.  This will make the selection tool a bit easier to implement I
think.
  • Loading branch information
guillaumechereau committed Jun 28, 2024
1 parent b48ec58 commit 961fbfb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/goxel.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,18 @@ int goxel_unproject(const float viewport[4],
best = dist;
}
end:
// Post effects.
// Note: should probably move outside of this function.
if (ret && offset)
vec3_iaddk(out, normal, offset);
if (ret && (snap_mask & SNAP_ROUNDED)) {
out[0] = round(out[0] - 0.5) + 0.5;
out[1] = round(out[1] - 0.5) + 0.5;
out[2] = round(out[2] - 0.5) + 0.5;
for (i = 0; i < 3; i++) {
if (normal[i] == 0) {
out[i] = round(out[i] - 0.5) + 0.5;
}
}
}

return ret;
}

Expand Down

0 comments on commit 961fbfb

Please sign in to comment.