Concave regions may cease detecting actors inside.

Hectate

  • *
  • Posts: 4643
This may already be known, but concave polygonical regions can "break" actor detection for any actors inside.
In my game, I have regions that push the player around if they enter them (typically for one-way passage, for example). I created 10 duplicates of the scene behavior that performs the "pushing" because I estimated it would be sufficient (for the level designs) to have that many regions per scene. I used all 10 behaviors on a level this morning, and to do this I needed to use polygonical regions for a few to make them fit multiple locations that would be "pushing".
Oddly, a couple of them (all concave shapes) ceased pushing the player at odd intervals while the player was inside the region. Examination of the offending regions resulted in the following information becoming apparent...

1. Attempting to enter the regions (successfully or otherwise - since some directions would push the player back) triggered the behavior's code properly, and printed to the console that the player was "inside" the region for that frame.

2. Debug Draw shows the polygon being broken up with vertex-to-vertex cross-lines (expected). Moving over one of these lines (one per region on mine, although more may exist for more complex shapes) causes the region to cease operation, even if the actor is technically inside the region still. The player is no longer pushed, and I stopped getting the prints in the console.

3. If the player, since they're not being pushed anymore, reverses direction manually and attempts to cross the mid-region line (from #2 above), it will revert to recognizing the actor (push, print, etc) while in contact with the line.

4. I temporarily removed the push effect to test (so I could fully re-cross the line) and confirmed that it will only register region interaction with the cross-line itself at this point. You cannot "re-enter" the originally functioning portion of the region once you have made any contact with the cross-line. It is not required for you to traverse in a particular direction, you can merely touch it and return to the originally functioning portion of the region with the same erroneous (no contact) results.

5. If you never touch the cross-line the region will function properly the entire time. 

6. Leaving the region altogether will reset everything and allow the region to operate as normal again until the cross-line is touched again.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Greg

  • *
  • Posts: 1260
Crap -- I was hoping this one wouldn't resurface.  I remember running into an issue like this when I was first adding polygonal support for regions.  The problem seemed to go away and I was never able to reproduce it -- it's possible I just didn't have the correct scenario down.

Thanks for the steps, I'll try to figure it out when I get time.  The non ideal workaround for now, would be to break things up into multiple convex polygons. 

Greg

  • *
  • Posts: 1260
Found another issue, probably not related -- but if you have a region such as the first one in the attached picture.  It will detect the Actor as being in the region, even if you just move under the upper left point of the region (even if you're clearly not in the region).

I found that this issue doesn't happen when all animations are turned off -- so my guess is that something is going on when the player switches animations (and as such collision shapes).


Greg

  • *
  • Posts: 1260
Sorry to hijack this thread with the other issue, but I'll hopefully fix both of them.  The issue from my last note seems to be related to a hack we had to put in regarding this rather long and ugly issue -
http://team.stencyl.net/showthread.php?tid=9564&page=2

In particular, this call (called when switching an animation):
var contact:b2ContactEdge = body.GetContactList();

I have to assume that this check is looking for collisions using a bounding box around the fixture and not looking at the actual shape itself?  I added some print statements to verify that it detects the collision with the region right when the animation change happens, but before the Actor is really in the region (like the screenshot above).

Hectate

  • *
  • Posts: 4643
Thanks for the steps, I'll try to figure it out when I get time.  The non ideal workaround for now, would be to break things up into multiple convex polygons.
Glad to help.
I've already broken up the two that were having the issue. I'd actually just now encountered some very odd (unrelated possibly) bugs where on some of the region edges the player motion/keys gets stuck in an "on" position (and one of them is a regular box region!) that I'll have to examine too. I'll let you know what I encounter if it's not user error (my fault!), but it'll probably not be today. I think it's related to the deleting and replacing several regions where names were recycled automatically (Region 10, etc). I did examine all the behaviors for setup errors.

If you're curious, the player can touch select locations (a corner on one, a specific edge on the other) on the problem regions and lose control (partial or full) of the actor.

On the box region edge-contact one, the player moves slightly back and forth like he's holding the right-arrow key while the region is pushing left. Actually pressing left and right do nothing, but up/down are not restricted. So it gets stuck on the edge of the region when trying to leave it. I did break free somehow once...

On the corner one (convex poly region that pushes rightward), touching the top-rightmost corner causes the actor to involuntarily move one or both of down and right with no response from other keypresses.

As I said, very odd and probably unrelated.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Jon

  • *
  • Posts: 17524
Sorry to hijack this thread with the other issue, but I'll hopefully fix both of them.  The issue from my last note seems to be related to a hack we had to put in regarding this rather long and ugly issue -
http://team.stencyl.net/showthread.php?tid=9564&page=2

In particular, this call (called when switching an animation):
var contact:b2ContactEdge = body.GetContactList();

I have to assume that this check is looking for collisions using a bounding box around the fixture and not looking at the actual shape itself?  I added some print statements to verify that it detects the collision with the region right when the animation change happens, but before the Actor is really in the region (like the screenshot above).

That sounds about right to me.

Darkhog

  • Posts: 1243
Also are collisions with concave shapes fixed? I mean in particular the ones Rhys got in Circyt (you were able to drive into trees even considering fact it had collision boundary over hem)

There are no impossible things. There is only lack of skills.
Don't click this if your computer has less than 641 kilobytes of RAM.
Stencyl stencyling stencylish stencylers :D

Jon

  • *
  • Posts: 17524
If you turn on continuous collision detection for the car actor, that issue becomes fixed.

Darkhog

  • Posts: 1243

There are no impossible things. There is only lack of skills.
Don't click this if your computer has less than 641 kilobytes of RAM.
Stencyl stencyling stencylish stencylers :D

Greg

  • *
  • Posts: 1260
Does anyone know how to find out more about what this really does? 

Code: [Select]
var contact:b2ContactEdge = body.GetContactList();
Looks like it's using some internal Box2d conventions that I'm not familiar with.  Just trying to confirm for sure that it is using the bounding box rather than the actual shape.

And if that is the case, we'll have to find another method for handling this on animation changes.

Matt_S

  • Posts: 46
I believe you're right about that using the bounding box, but I'm not entirely sure either.

Jon

  • *
  • Posts: 17524
If you see the term "AABB" used in the source, it stands for Axis-Aligned Bounding Box, in other words, what we're talking about.

Greg

  • *
  • Posts: 1260
Ok I think I have a solution for the animation change issue and will commit that now. Still looking into the other issue. 

I think the other issue has to do with the fact that the concave regions are made up of multiple fixtures, but the logic only checks one. 

edit: actually, the issue is that when the code detects an end contact (after leaving the first fixture) it removes the actor from the region -- not knowing that it's still in for another contact.

edit 2: that part should be fixed now as well (at least according to my testing)

« Last Edit: March 19, 2011, 10:13:41 pm by Greg »

Greg

  • *
  • Posts: 1260
Hectate, if you're willing to help test out the fix for the issue in your original post -- feel free to drop this file into your plaf\flash directory.  Let me know if you run into any problems (if you're able to test).


Hectate

  • *
  • Posts: 4643
Hectate, if you're willing to help test out the fix for the issue in your original post -- feel free to drop this file into your plaf\flash directory.  Let me know if you run into any problems (if you're able to test).
I've already altered the scene to fit the workaround, but if I have an opportunity I'll copy the scene and revert some changes. It won't be today, so if anyone else can test that'd be ideal - I know Jon was intending for B368 to be out soon (today?).
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.