Skip to content
This repository was archived by the owner on Sep 7, 2021. It is now read-only.

Commit a03a39b

Browse files
committed
Merge branch 'bugfix-intersect_image' of https://github.com/runrevian/livecode into bugfix-intersect_image
2 parents 2788772 + 77b74b0 commit a03a39b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

engine/src/object.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3923,7 +3923,8 @@ static void compute_objectshape_mask(MCObject *p_object, MCObjectShape& p_shape,
39233923
// What we setup depends on whether the mask is depth 1 or 8 and the threshold.
39243924
// If the threshold is not 1, we use soft bits if they are available.
39253925
r_mask . fill = compute_objectshapescanline_soft;
3926-
r_mask . bits = p_shape . mask . bits -> data + t_obj_rect . y * p_shape . mask . bits -> stride + t_obj_rect . x;
3926+
// IM-2013-05-10: fix wrong bit pointer offset due to adding stride (in bytes) to data (4-byte word pointer)
3927+
r_mask . bits = (uint8_t*)p_shape . mask . bits -> data + t_obj_rect . y * p_shape . mask . bits -> stride + t_obj_rect . x * sizeof(uint32_t);
39273928
r_mask . stride = p_shape . mask . bits -> stride;
39283929
r_mask . offset = 0;
39293930

@@ -4043,7 +4044,8 @@ bool MCObject::intersects(MCObject *p_other, uint32_t p_threshold)
40434044

40444045
// Now check for overlap!
40454046
t_intersects = false;
4046-
for(int32_t y = 0; y < t_rect . height; y++)
4047+
// IM-2013-05-10: optimize - exit from outer loop if intersect found
4048+
for(int32_t y = 0; !t_intersects && y < t_rect . height; y++)
40474049
{
40484050
// Fill the scanline for this.
40494051
if (t_this_mask . fill != nil)
@@ -4060,12 +4062,8 @@ bool MCObject::intersects(MCObject *p_other, uint32_t p_threshold)
40604062
}
40614063

40624064
// Check to see if they intersect.
4063-
for(int32_t x = 0; x < t_scanline_width; x++)
4064-
if ((t_this_scanline[x] & t_other_scanline[x]) != 0)
4065-
{
4066-
t_intersects = true;
4067-
break;
4068-
}
4065+
for(int32_t x = 0; !t_intersects && x < t_scanline_width; x++)
4066+
t_intersects = (t_this_scanline[x] & t_other_scanline[x]) != 0;
40694067
}
40704068

40714069
// Scanlines aren't needed anymore.

0 commit comments

Comments
 (0)