proxyId problem

Topics: User Forum
Jul 11, 2011 at 10:51 AM

Hi,

I keep getting assert errors from this method in DynamicTree.cs

/// <summary>
/// Get the fat AABB for a proxy.
/// </summary>
/// <param name="proxyId">The proxy id.</param>
/// <param name="fatAABB">The fat AABB.</param>
public void GetFatAABB(int proxyId, out AABB fatAABB)
{
    Debug.Assert(0 <= proxyId && proxyId < _nodeCapacity);
    fatAABB = _nodes[proxyId].AABB;
}

My proxyId is always -1 when this assert gets me. I know it's related to collisiongroups, as I can sometimes dodge this by changing them around. But running away from the problem isn't the solution, so could someone tell me what's going on? Any common mistakes with collisiongroups? Any tips to avoid them?

Thanks!

Jul 11, 2011 at 2:03 PM
Edited Jul 11, 2011 at 2:23 PM

This is the same problem I'm having just now, only I'm creating bodies and fixtures, then disabling them to use later. But for some reason they're still colliding with other objects and causing this same problem of the -1 proxyId. I posted this a few days ago and I think it's beyond the point of getting a reply. If I find out what's going on with it I'll let you know.

If it's just a case of the collision groups is it possible just to set the group as I create the fixtures and maybe I wont get this -1 problem?

 

Edit:

I've just had a play about with my code and setting the collisiongroups to none when disabled and resetting them when I enable them again seems to have resolved my issue. Thanks for pointing me in the right direction with the collision groups. ;)

Aug 13, 2011 at 12:24 AM

Me too, same problem.  I'm not sure if it's a problem with collisionGroups though...

In my case: I've figured out that this problem happens when I have a geometry in the world, and I create more bodies on top of it (or near it) which are immediately disabled (before a world step occurs).

Here's a tested example:  I create an array of dynamic Circle geometries at position (0, 0) in my world.  As soon as I create them, I set them all Enabled=false.  But I already have a static geometry at (or near) position (0, 0).  When the world step occurs, the AABB of the static geometry is still compared to the AABBs of the Circles, even though they're disabled-- and that's when everything goes wrong....

I haven't tested this out extensively, but in my case it had nothing to do with collisionGroups (I believe they were all at the default value when I did my test).  I was able to fix the problem by setting the positions of the Circle geometries to a value that I knew wouldn't be occupied when they were created.  Something like: Vector2(Float.MaxValue, Float.MaxValue).  Then I set their value to something practical when re-enabling them.  Depending on your needs, this might or might not be a suitable work-around..