GameMaker Collision functions (and event) works wrong with precise masks on macOS

nsobject

Member
Screen Shot 2019-12-16 at 04.15.06.png
Left and right green collision masks has the same mode and type: Automatic Precise (Slow). Both has top left origin. Purple object has Automatic Rectangle mask, top left origin.
Collision event in square purple object (with common parent of green slopes) does not fired for left case but fired for right case. Why is that?
I workaround this issue by using left slope in place of right with Flip X checked. But if anyone can explain this behavior it would be great.
 

TheouAegis

Member
Maybe it's just the image, but it looks like your green object is a little bit wider than you think. Looks like each step is actually one pixel wider than you think. That one pixel is not overlapping anything on the left but it is overlapping on the right.

also is the green object actually two separate objects or is it the same object but mirrored? Mirroring can be problematic.
 
R

robproctor83

Guest
Hi @nsobject I just downloaded your demo to test and maybe I am misunderstanding your issue, but I don't experience what your saying. When I run the demo you uploaded by default there is nothing colliding. Neither of the Quads are colliding with the positions you have put them in. However, if I move them down a cell you can see they collide properly. So, I am not sure what your suggesting really. FYI I am testing in gms2

* I edited the project to make the squares orange when they collide, raher than deleting the triangle for better visual purposes.

*Edit, are you experiencing a collision with the demo you posted by default? If so, then it may be related to the version of gms you are using. If not, and it's only happening in your real project, then it's likely due to an issue with a sub pixel (meaning you have something positioned at 1.01 instead of just 1.
 

Attachments

nsobject

Member
Hi @nsobject

*Edit, are you experiencing a collision with the demo you posted by default? If so, then it may be related to the version of gms you are using.
Yes, in this demo objects collide when they should not.
I am using GMS2 IDE v2.2.4.474 Runtime v2.2.4.374 running on macOS 10.14.6. Demo run from editor (F5), output: VM. Can't test YYC because this is trial version GMS2.
I will test this on Windows 10 soon, but only under Parallels Desktop.
 
R

robproctor83

Guest
Yes, in this demo objects collide when they should not.
I am using GMS2 IDE v2.2.4.474 Runtime v2.2.4.374 running on macOS 10.14.6. Demo run from editor (F5), output: VM. Can't test YYC because this is trial version GMS2.
I will test this on Windows 10 soon, but only under Parallels Desktop.
Strange, I am running the same version except windows 10. I suppose it's a mac bug, that is a bummer.
 

nsobject

Member
I ran the same test project on windows and there is no issue, just as you say. So yes, it's only macOS bug.
But there is more. I found what place_meeting function also buggy on macOS.

This code:
Code:
// Create event
hsp = 0;
hsp_frac = 0;

// Step event
var key_right = keyboard_check(vk_right);
var key_left = keyboard_check(vk_left);

var move = key_right - key_left;

hsp = move * 0.5;

if hsp != 0 {
    hsp_frac += hsp;
    var hsp_rounded = round(hsp_frac);
    hsp_frac -= hsp_rounded;
    var dir = sign(hsp_rounded);

    repeat abs(hsp_rounded) {
        if place_meeting(x + dir, y, oParent) {
        //if collision_rectangle(bbox_left + dir, bbox_top, bbox_right + dir, bbox_bottom, oParent, true, true) {
            hsp_frac = 0;
            break;
        } else {
            x += dir;
        }
    }
}
Produce this result on macOS:
Screen Shot 2019-12-16 at 20.43.11.png
The top objects use place_meeting, the bottom - collision_rectangle. Objects visually collide, but not report collision via collision event.
This bug is also present only on macOS, on windows functions behave exactly the same, as they should.

Is anyone on macOS can confirm this bugs? Is they really exists, or may be I am doing something wrong?
 

nsobject

Member
Well, on macOS, simple collision checking functions like place_meeting, instance_place, as well as collision event, simply broken. They does not work right with precise collision masks. collision_rectangle, however, works ok, same as on windows.
 

nsobject

Member
I submitted this bug in December 2019, nothing was done by YoYo Games: https://bugs.yoyogames.com/view.php?id=31573
It even has a low priority. I don't understand such things, this bug, from my point of view, makes GMS2 completely unusable as a tool for creating games on Mac and for Mac.
I resubmitted this bug a few days ago with another example project.
 

Coded Games

Member
I mainly develop for MacOS and have never discovered this issue. Although, my game does not need precise collisions once so ever. But my first guess would be to look into the "use retina" setting. Since MacOS will usually be scaling everything the visual coordinate system might be slightly off from where the bounding boxes are. But, who knows. As a hack maybe render your character a pixel off from where they actually are.
 

rwkay

GameMaker Staff
GameMaker Dev.
I submitted this bug in December 2019, nothing was done by YoYo Games: https://bugs.yoyogames.com/view.php?id=31573
It even has a low priority. I don't understand such things, this bug, from my point of view, makes GMS2 completely unusable as a tool for creating games on Mac and for Mac.
I resubmitted this bug a few days ago with another example project.
I have taken a look at this problem and isolated the issue, it is the macOS compiler not optimising correctly - I have rearranged the code and it now works correctly... I am not sure this fix will make 2.3.3 though I need to talk to @Dan on Monday

Russell
 
Top