This project has moved and is read-only. For the latest updates, please go here.

Update fixture position (AABB)

Sep 16, 2011 at 3:42 AM

I need to allow game designers to move objects around. This all works fine for regular bodies but I have edge shape fixtures for which I don't seem to be able to update the AABBs. I also tried just disposing the fixtures and re-creating the edge, but the fixtures do not get removed at all.  It's should be faster to just update the Vertexes which works, but the broadphase collision gets out of sync.  I tried updating the AABB vectors in the proxy list but this doesn't work;

Any suggestions?

                    List<Fixture> fList =  gameObj.sprite.body.FixtureList;

                    EdgeShape edge;
                    Transform transform; 
                    for (int i = 0; i < fList.Count;i++ )
                        Fixture f = fList[i];
                        if (f.ShapeType == ShapeType.Edge)
                            edge = (EdgeShape)f.Shape;
                            edge.Vertex1 -= new Vector2(xM / MeterInPixels, yM / MeterInPixels);
                            edge.Vertex2 -= new Vector2(xM / MeterInPixels, yM / MeterInPixels);

                        for (int y=0;y< f.ProxyCount;y++)
                            FixtureProxy proxy = f.Proxies[y];

                            Vertices v = proxy.AABB.Vertices;
                            for (int x = 0; x < v.Count; x++)
                                v[x] -= new Vector2(xM / MeterInPixels, yM / MeterInPixels); // This line doesn't seem to work as expected