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

Breakable Bodies & slow render

Topics: Developer Forum
Jun 13, 2012 at 8:53 PM

Hi everybody (not breakable) !

I have implement Farseer Physics for some tests. On one of them I saw de huge decrease of performance when i try to calculate texture on fixtures of breakable bodies. 
With the code of mattbettcher on his second TexturePolygon example the textures has been implement by it's too slow!

If someone has a better idea to how implement calculation of textures for this kind of bodies, it would be great for the all commuity :)

I remember the code : 

            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, matrix);
            foreach (var body in BodyList)
                foreach (var fixture in body.FixtureList)
                    if (fixture.ShapeType == WPhysics.Collision.Shapes.ShapeType.Polygon)
                        if (fixture.UserData != null)
                            TexturedFixture polygon = fixture.UserData as TexturedFixture;

                            effect.Texture = polygon.Texture;

                            VertexPositionColorTexture[] points;
                            int vertexCount;
                            int[] indices;
                            int triangleCount;

                            polygon.Polygon.GetTriangleList(fixture.Body.Position, fixture.Body.Rotation, out points, out vertexCount, out indices, out triangleCount);

                            graphicdevice.SamplerStates[0] = SamplerState.PointWrap;
                            graphicdevice.RasterizerState = new RasterizerState() { FillMode = FillMode.Solid, CullMode = CullMode.CullCounterClockwiseFace, };

                            graphicdevice.DrawUserIndexedPrimitives<VertexPositionColorTexture>(PrimitiveType.TriangleList, points, 0, vertexCount, indices, 0, triangleCount);