Problem creating shapes

I create a shape based on the data of a 3D model. Basically I read the coords of the vertices of every triangle in the model (it's a plane and there are no overlapping triangles) and i use them to add shapes to a body that I'll use later as a wall.

While doing this, i encounter in this problem:
Quote:
TypeError: Error #1009: Impossibile accedere a una proprietà o a un metodo di un riferimento oggetto null.
at Box2D.Collision::b2PairManager/AddPair()[..\libs\Box2D\Collision\b2PairManager.as:251]
at Box2D.Collision::b2PairManager/AddBufferedPair()[..\libs\Box2D\Collision\b2PairManager.as:94]
at Box2D.Collision::b2BroadPhase/CreateProxy()[..\libs\Box2D\Collision\b2BroadPhase.as:274]
at Box2D.Collision.Shapes::b2Shape/CreateProxy()[..\libs\Box2D\Collision\Shapes\b2Shape.as:229]
at Box2D.Dynamics::b2Body/CreateShape()[..\libs\Box2D\Dynamics\b2Body.as:53]


I can't really understand what the problem is, but i've noticed that the value on m_freePair (in the AddPair method of the b2PairManager class) becomes 65535 and than it can't find the appropriate object in the m_pairs array.

The problem is that i'm adding too many shapes? or is something more subtle?

edit: forgot to mention that the Box2D version is the one modified by Boris to work with his b2BuoyancyController
I'm guessing there's a limit to 4096 proxies ... but I can't say that I've undestood what a proxy is :p
i've found that reducing the AABB world solve the problem ... for some reason that is quite obscure to me

now i'm setting it small as possible (10 instead of 1000) to prevent further problems

I someone would investigate the problem in a more logical way i can give more details on my setup
Proxy == Shape as listed in the broadphase. Proxy pair == pair of overlapping or near overlapping shapes.
You can up this limit in b2Settings, but using 4000 it's more than likely that you have some improvements you should be making, or a bug.

Don't reduce the world aabb. You are likely just truncating all the shapes outside of it, which brings you under the limits, but is hardly useful.
thanks Boris, it's good to know the "how" of things 😀
These pairs are counted also between shapes in different bodies? or just between the shapes inside the same body?

Are you aware of some problem raised by changing the b2_maxPolygonVertices value?

basically i need to create a wall (that follow a road) and i read the shape's data from a 3d model (made of triangles). Since i can't build a polygon made of 150-200 vertices i thought of creating a lot of shapes (~115) each with 3 vertices.

obviously i don't have just a wall, but 2 walls and the road (wich is a sensor).

If i can use very complex polygons i will reduce the number of near-overlapping shapes inside bodies.
Yes, shapes inside bodies are also counted, though now you point it out, for no reason.
There's no problem with upping the max vertices, but no point, either. You can only make concave polygons - see the manual.
If you are just following the outline of a shape with triangles, then you should not be hitting 4000 overlapping pairs unless it's a very complicated shape. Have you considered using shaktools thin line segments instead (search the forums for it).
don't know if the models are too complex, they have around 400 triangles in total. That means i create 400 shapes on 2 bodies. There are no overlapping shapes but most of them are adjacent

looks like the only possible solution is the thin line segments. i've found a demo and looks good

i'm gonna try it now, then i've to figure out how to take only the vertices of the model wich makes the outline

anyway, thanks Boris for the help 🙂
sigh, got some problem integrating the StaticEdgeChain classes and functionality in the box2d version made by Boris :\
You shouldn't have too much difficulty. But I'm not going to do it for you, I've unfortunately got other things on my plate.
just to keep you guys updated.
i think to have made it. thin line segments now works and i'm gonna implement them in my game.
probably i didn't integrate the 2 version of box2d in the best way, but i'm running short of time so i can't do any extra check right now

I'll post some demo with sources once the game is finished.

Thanks Boris for the help 🙂

Original thread: https://box2d.org/forum/viewtopic.php?t=1743