-
-
Notifications
You must be signed in to change notification settings - Fork 643
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
Evaluate replacement for me.Entity.bounds #580
Comments
actually the preliminary reason was that and for now |
I see. There's something else kind of concerning, on that note. Let's say there's a hypothetical entity whose renderable and shape bounding boxes are really very different. The renderable bounding box tests whether it's in the viewport, and the shape bounding box tests for collisions (simplified.) We also have a case where objects outside of the viewport are not considered for collision checks: melonJS/src/physics/collision.js Line 463 in a65c959
You can imagine the issue: it's possible for an entity's renderable to be outside of the viewport while its shape is inside (and intersecting with other stuff). This is why the above commit fixes collision detection; because it uses the shape bounding box to set the Should we then instead set the |
the union sounds like a good idea actually, i kind of like it :P |
Cool. After that. What do we do about the |
fair enough, the entity rect can be used as the union of the body bounds and the renderable size :) should be transparent anyway, as far as we keep the getBounds() function |
Given how we've changed the way bounds works a bit, is this still relevant? |
Oh yes. Something still needs to be done. :) The spec may have to evolve with recent changes, but for sure we need something better than shoving more rectangles onto entities to get everything working... |
For future reference: Entity:
Sprite:
|
I was looking at remove as so as far as it goes for this ticket, what I would "only" do so far is to change the following line
|
also, are these two functions not somehow redundant :
and especially when you look at the parent function for |
Yes, very similar. It could probably be unified. Not sure if it will be a huge gain. ;P The To make positioning independent of a rectangle's corner, the code will probably have to evolve in the same direction @Giwayume started to explore for #99. That means, the position vector itself does not provide information about a rectangle's left or top boundaries, but instead you have to use the With that, changing the shape (and |
design changes, so breaking changes and 4.0.0 |
Should help changing/improving the bounds implementation later on : - remove all references to private bounds objects - remove the private `resizeBounds` function (use `getBounds().resize()`) - add some futher bounds testing for container and sprites objects add missing renderable test unit from index.html
so with the two last commits, it's now possible to add a physic body to any renderable object, Sprite, container, or whatever object inheriting from me.Renderable. which means that me.Entity could slowly go to die....as for simple case me.Sprite is enough, and for more advanced use cases (with multiple renderable), ones could use a me.Container. |
here is an example : |
that makes the whole thing much more modular/flexible, as it does not rely anymore on a specific object type for physic/collision. |
see #1008 |
This seems kind of tricky. There has been a lot of discussion about this in the past, mostly in #560. But it seems like maintaining the bounds rectangle separately from the entity rectangle is problematic. See this commit as an example of how it goes wrong: 104b6f4 The entity geometry was silently working for most objects, but fails for TMX Polygon and Poly Line objects. 😕
@obiot What are the reasons for creating a
bounds
object inside theEntity
, instead of using the entity geometry itself as the bounding box?I know the entity geometry was once used as the renderable geometry. Then that changed when renderable was broken into its own object. And then the collision box object was removed, but it appears the bounds object has just taken its place.
The text was updated successfully, but these errors were encountered: