-
Notifications
You must be signed in to change notification settings - Fork 134
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
New Circle and Polygon masks + minor changes/fixes to other masks #133
base: master
Are you sure you want to change the base?
New Circle and Polygon masks + minor changes/fixes to other masks #133
Conversation
…d to add some things to other mask too
…orld and a bunch of other things to make debugging easier (will purge once finished)
…robably needs some more love), changed console update() position in Engine (now shouldn't lag behind), updated project() func, need to work out Image->Polygon sync
… (esp. w/Pixelmask), improved Masklist (and its drawing in console), syncing between Image->Polygon seems to be a hard task - we'll see...
I want @Draknek to get eyes on this. |
I also want to get eyes on this! But am currently exhausted and have lots going on. Can someone send me a reminder to look at this if I've not commented again by Thurs 17th April? |
(Pickup Boomerang for gmail. You can toss away mail and have it "return" when you need to) |
I'll remind you, bro. On Sun, Mar 30, 2014 at 4:37 PM, Erik Yuzwa [email protected]
|
@zachwlewis @Draknek have you found the time to take a proper look at this yet? |
I have not! New self-imposed deadline: 1st May. Thanks for the reminder :) |
:D |
So I've not tested the actual code, just skimmed over it looking for potential problems. Hopefully it's been well tested! Ideally @zachwlewis would also skim over the code and set up some tests to check weird edge-cases. This doesn't appear to fix a lot of the weirdness that makes it kinda awkward to make new masks (code/properties split weirdly between I'm happy for this to be merged in after the following issues are resolved:
Minor things that aren't as important:
|
*/ | ||
public static function createRegular(sides:int = 3, radius:Number = 100, angle:Number = 0):Polygon | ||
{ | ||
if (sides < 3) throw "The polygon needs at least 3 sides."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably create PolygonError
and throw those instead. That seems more elegant (and easier to catch polygon errors).
Added a couple notes to |
Oh, also: this code only supports convex polygons, but that's not documented anywhere. It should either throw an error if you provide a concave polygon, or generate the convex hull of the points passed in. |
Should it generate a convex hull, or should it divide the polygon into multiple convex polygons? On Fri, May 2, 2014 at 4:16 AM, Alan Hazelden [email protected]
|
I agree with most of your points:
Above all you're right we need more tests/people testing the whole thing. |
Other masks have I'm happy either way though. Supporting multiple polygons means either refactoring a lot of code or having a Buuut I'm not the one who's doing the work, so do as you like :) |
About modifying polygon origin: I was wrong, it doesn't move, but the rotation pivot is updated, so if you change the angle afterwards the polygon rotates around the new pivot. |
Conflicts: net/flashpunk/masks/Hitbox.as net/flashpunk/masks/Masklist.as
About |
… angle to createFromFlatVector
…nes, pivot getters/setters, specified to work with convex polygons Image.createPolygon() now takes an array of points
So... I think I've addressed almost all of the issues. Only things left are:
|
Don't worry about a special error type. I can add those when I'm bored. For concave polys, as a user, I want to make a shape and have it collide. I don't care what's going on. I'll be very confused if I give it a valid polygon and it doesn't work the way I expect. I'd say a simple triangulation would work just fine for concave polys. On Sat, May 3, 2014 at 11:04 AM, Giuseppe Di Mauro
|
The main problem with using just a triangulator is that it is not efficient, it would probably decompose the original concave polygon into a high number of triangles (f.e. see https://raw.github.com/azrafe7/as3GeomAlgo/master/screenshot.png). Another thing to note: since the result of the triangulation is a list of triangles that would eventually be turned into a |
I'd throw an error when creating a concave polygon. Then later we can add some functions to create the |
I agree with @Rolpege, that's a reasonable compromise for the time being. |
Testing polygons for simplicity (non self-intersection) and convexity (which are the costraints under which the mask should properly work). Please test this further and report back if you encounter some bugs. If none we could drop this in the code: https://github.com/azrafe7/FPPolygonProps |
Assuming this code is similar to the one that was pushed to HaxePunk, an additional issue has arisen. The new masks could have problems with hitboxes set using I think this should be changed, and all Masks should be using the mask properties and not the Entity's own properties (because entities can have multiple masks using Masklist, and other issues). Maybe this should be a separate issue... |
Trying to sum up:
Circle
andPolygon
masks from HaxePunkWorld/Entities
(so now should not be a frame behind)project()
function to some masks to make working withPolygon
easierImage.createRect/createCircle()
(fill, thick, etc.)Image.createPolygon()
to create anImage
from aPolygon
maskprivate collide___()
functions tooverride protected collide___()
(this was a weird surprise o.O: don't know why they were simply declared as private and not overriding from the super class)debugDraw()
forHitboxes
inMasklist
Masklist.update()
to handleHitboxes/Polygons
correctlyThere shouldn't be any breaking changes, but surely needs some more testing.
Link to related topic on the forums: http://developers.useflashpunk.net/t/polygon-and-circle-masks-for-flashpunk-round-2