-
Notifications
You must be signed in to change notification settings - Fork 450
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
Add getRotatedRectBounds helpers #2298
Conversation
Tbh, my first thought is that |
originally this was in flxCollision. Austin mentioned that people may not look there. i can put them in |
converting back to a draft for some drastic changes, namely
|
@Gama11 any more thoughts on this? |
Not sure how I feel about a method called In general, I'd be happier with this if they were actually needed for something within flixel, i.e. that optimization you mentioned. |
I think I already have the optimization in another branch, I can add it here with some performance info. got anything shorter than |
I've added the optimization to Here is a simple video of the performance difference: https://imgur.com/ISFuHcj The old method checked a bounds much bigger than what was needed. the benefits of this change are bigger as the dimensions of the image increase, especially a long skinny image like the spikes on flappybalt. with the previous method it's bounds were like half the screen even though it's only 9 px wide I've also renamed |
Did some further testing, I didn't realize that pixelPerfectCheck ignores the sprite's scale, when I apply random scaling on the PPC demo's sprites I actually get worse performance because it's checking a larger bounds than it did previously. it would be neat to honor scale in pixel perfect overlap (it already works with flipX/Y), but for now it may be better to just ignore scale in the bounds check. I may add an arg to input appreciated |
Apparently it's pretty easy to get I renamed |
That's weird. I forgot to update the tests but all tests passed. |
Found some other uses and optimizations for this. I also wanted to look into pixelPerfectPosition, pixelPerfectRender and camera zoom to see if those should be considered for these tools The scope of this change seems to be much bigger than initially thought, if you think it's getting out of hand, let me know |
in summary this adds:
Made changes to:
|
* Enable workflow_dispatch * Fixing little error for android build (#2407) * Explain FlxG singletons in input util docs (#2411) * Mention color in docs for FlxBitmapFont.fromMonospace (#2412) This makes it a little more clear that if you're loading a FlxBitmapFont from a monospace font file that you wish to change the color of, ensure the pixels are white. This allows the textColor property to work as expected. If the pixels happen to be black, the textColor changes won't be visible. * redraw sprite before `updateHitbox()`. fixes #2413 (#2417) * Remove references to FlxObject direction flag constants (#2424) * fix: image showcase link (#2438) * Fixed spelling in comment in FlxBasePreloader (#2447) * Update documentation on scale modes. (#2455) * Update license link (#2464) * remove redundant modifier (#2467) * Fix CI * Add FlxAnimationController.getNamesList() to get the current list of animation names (#2473) * Add the list thing * Oops, beta description * Kinda a fix? * Experimental stuff with setting new names lol * Adds a more safe option in case you don't complete the entire thing * remove the variable and add the functions * change some minor stuff * remove the last _list things * Update FlxAnimationController.hx * Idk if it works but maybe the checks are failing cos of that? * Add a nicer code and description stuff * add tests, and small corrections * Add the rename test on FlxAnimationControllertest Co-authored-by: George FunBook <[email protected]> * fix typo in unit tests * Add getRotatedRectBounds helpers (#2298) * `FlxRect.getRotatedBounds` * `FlxObject.getRotatedBounds` * `FlxSprite.getRotatedBounds` - override * `FlxSprite.getScreenBounds` - similar to `FlxSprite.getScreenPosition` * `FlxSpriteUtil.cameraWrap` - similar to `FlxSpriteUtil.screenWrap` but uses FlxDirectionFlags instead of 4 booleans * `FlxSpriteUtil.cameraBounds` - similar to `FlxSpriteUtil.cameraWrap` * `FlxCamera.getViewRect` - helper for `FlxSpriteUtil.cameraWrap` and `cameraBound` * `FlxCamera.containsRect`- helper for `FlxSpriteUtil.cameraWrap` and `cameraBound` * `FlxCollision.pixelPerfectCheck` - uses getScreenBounds to reduce the number of pixel checks, honors FlxSprite's scale * `FlxSprite.isOnScreen` - uses getScreenBounds for more accuracy * `FlxCamera.containsPoint` - calls putWeak * ignore failing test for now * sceenCenter Readibility (#2441) * add screenCenter test * improve readability of screenCenter * add check with no parameters * inline screenCenter * update FlxState comment on constructor * Prevent hashlink segfaults on linux (#2487) * change integers used for ANY and NONE FlxKey <REVERTED> * add FlxKey tests for ANY/NONE * remove switch causing seg faults Co-authored-by: jf <[email protected]> Co-authored-by: George FunBook <[email protected]> * call members' kill/revive when called on sprite groups (#2423) * call members' kill/revive when called on sprite groups * make sure kill/revive is NOT called when not needed * fix spriteGroup.reset() * minimize setters * add resetTest * remove haxe4 compile conditions (#2489) * Release 4.11.0 (#2490) * add release notes * seg fault bugfix * FlxSpriteGroup kill/revive * change haxelib * wording * change date Co-authored-by: Jens Fischer <[email protected]> Co-authored-by: Gliar <[email protected]> Co-authored-by: Brett Chalupa <[email protected]> Co-authored-by: Julian Holfeld <[email protected]> Co-authored-by: RafPlayz69YT <[email protected]> Co-authored-by: Eric Myllyoja <[email protected]> Co-authored-by: MrClogsworthYT <[email protected]> Co-authored-by: MrCheemsAndFriends <[email protected]> Co-authored-by: jobf <[email protected]> Co-authored-by: jf <[email protected]>
Add helpers to FlxRect that calculate the globally-aligned bounding box of a rotated rectangle, and similarly the GABB of a FlxObject and FlxSprite. Useful for determining the actual world space of a rotated rect for things like calculating redraw regions or broad phase collision (like getting a rect quadtree bounds).
I made this when I was looking into issues with
pixelPerfectCheck
, I thought this might optimize it, preventing it from iterating pixel data when the sprites are far away from each other. that's still in progress, and might not even be fruitful.I wanted to see if this utility was up to standards, or even worthwhile on its own, before I invested my time into that application of it.
Here's a demo: https://www.newgrounds.com/projects/games/1603054/preview