Bonjour,
j'ai une soucis dans la création d'un polygone de géométrie avec FarseerPhysics. Suivant la liste de Vertices que je passe à la méthode CreatePolygonGeom, il me déclenche ou non une erreur d'OverFlow.
Exemple :
Ce code la marche et me génère bien ce qu'il faut.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 Vertices vertices = new Vertices(); vertices.Add(new Vector2(-720, 50)); vertices.Add(new Vector2(-625, 75)); vertices.Add(new Vector2(-380, 70)); vertices.Add(new Vector2(-220, 85)); vertices.Add(new Vector2(0, 30)); vertices.Add(new Vector2(360, 0)); vertices.Add(new Vector2(720, 0)); Body rampBody = BodyFactory.Instance.CreateRectangleBody(501, 501, 1); rampBody.Position = new Vector2(500, 500); rampBody.IsStatic = true; Geom rampGeom = GeomFactory.Instance.CreatePolygonGeom(rampBody, vertices, 0f); this.physicsSim.Add(rampBody); this.physicsSim.Add(rampGeom);
Ce code la me génère l'exception :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 Vertices vertices = new Vertices(); vertices.Add(new Vector2(-250, -250)); vertices.Add(new Vector2(-200, -200)); vertices.Add(new Vector2(-100, -100)); vertices.Add(new Vector2(0, 0)); vertices.Add(new Vector2(100, 100)); vertices.Add(new Vector2(200, 200)); vertices.Add(new Vector2(250, 250)); Body rampBody = BodyFactory.Instance.CreateRectangleBody(501, 501, 1); rampBody.Position = new Vector2(500, 500); rampBody.IsStatic = true; Geom rampGeom = GeomFactory.Instance.CreatePolygonGeom(rampBody, vertices, 0f); this.physicsSim.Add(rampBody); this.physicsSim.Add(rampGeom);
à la ligne 142 de FarseerGames.FarseerPhysics.Collisions.DistanceGrid .L'opération arithmétique a provoqué un dépassement de capacité.
Seul la position des vertices a changée. Il y a-t-il une erreur que je n'aurais pas vu? :o
merci
Partager