New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprite Editor Missing Properties #230

Closed
RobertBColton opened this Issue Nov 17, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@RobertBColton
Collaborator

RobertBColton commented Nov 17, 2015

The current sprite editor is lacking the "Separate Masks" checkbox as well as a field for "Alpha Threshold" which are saved properties in GMK and GMX. LGM is already loading the properties they are simply not present in the current sprite editor. I have since added them to the sprite editor.

New Sprite Editor

The other issue is regarding the automatic bounding box calculation. It was previously not correctly zero'ing the pixel transparency of the BufferedImage when comparing it with the threshold. The threshold was also not being accounted for in the algorithm, we had it hardcoded to 0. In addition, the comparison was inverted and should have been checking if the alpha is greater than the threshold, not less than.

if (img.getRGB(i,y2) >> 24 < tolerance) break y2loop;

// the correct comparison is this
if (((img.getRGB(i,y2) >> 24) & 0xff) > tolerance) break y2loop;
// as opposed to the original version
if (img.getRGB(i,y2) >> 24 < tolerance) break y2loop;

These changes make the calculation more compatible with GM8.1 and GMS. The following test case verifies the results, with one exception where GameMaker and LGM will continue to have different results after these changes.

Transparency Test Case

(Left, Top, Right, Bottom)

  • Threshold: 0 (0, 0, 31, 31)
  • Threshold: 84 (0, 0, 31, 31)
  • Threshold: 85 (0, 19, 31, 31)
  • Threshold: 158 (0, 19, 31, 31)
  • Threshold: 159 (15, 19, 31, 31)
  • Threshold: 190 (15, 19, 31, 31)

Then when we set the threshold to 191 LGM will report (0, 0, 0, 0) where GameMaker reports (31, 31, 0, 0) because of a slight anomaly in the algorithm. It does not seem logical that right would be smaller than left, so I believe this is why LGM does it this way and is more correct. If I were doing this as my own game engine I would set the comparison as larger than or equal to the alpha threshold. It does not make logical sense that when the threshold is 255 it would for every sprite always select an inappropriate bounding box (what GM does) or no bounding box at all (what LGM does). However, using this comparison would not be off by one with GM and thus can not be done.

After these changes, all of the bounding boxes for every sprite in the game Croky, posted on the forum, are now calculated the same as GM. This should address many other collision detection issues ENIGMA side in previously tested games.
http://enigma-dev.org/forums/index.php?topic=2612

@RobertBColton RobertBColton changed the title from Sprite Automatic Bounding Box Alpha Threshold to Sprite Editor Missing Properties Nov 24, 2015

@RobertBColton RobertBColton closed this in #245 Feb 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment