Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2019-03-17 00:10:15 +0300
committermano-wii <germano.costa@ig.com.br>2019-03-17 00:10:44 +0300
commit8b62f203d9d0420b0d44c1c3a58efa350f8a9fcd (patch)
treec7b53f97ad6a703b9ef25ac93700134b4cbc2af3 /source/blender/editors/space_view3d
parent9e152f919f2f86cbe3530c6adc34373ebc703904 (diff)
ED View3d: Fix possible bug when subtracting unsigned ints.
Related to rB681661dbed12.
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 4660220fe27..3c38bb6d909 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -384,12 +384,19 @@ uint ED_view3d_select_id_read_nearest(
for (int b = 0; b < nr; b++) {
if (*tbuf && *tbuf >= min && *tbuf < max) {
/* we got a hit */
+ int hit_co[2], center_co[2];
/* get x,y pixel coords from the offset
* (manhatten distance in keeping with other screen-based selection) */
- *r_dist = (float)(
- abs(((int)(tbuf - buf) % height) - (height / 2)) +
- abs(((int)(tbuf - buf) / height) - (height / 2)));
+ hit_co[0] = (int)(tbuf - buf) % (int)height;
+ hit_co[1] = (int)(tbuf - buf) / (int)height;
+
+ center_co[0] = (int)(height / 2);
+ center_co[1] = (int)(width / 2);
+
+ /* for more efficiency, just sum the x, y pixel dist coords */
+ *r_dist = (float)(abs(hit_co[0] - center_co[0]) +
+ abs(hit_co[1] - center_co[1]));
/* indices start at 1 here */
index = (*tbuf - min) + 1;