From 96567cd7800bc508259666ec4312728488cdb8bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9goire=20Payen=20de=20La=20Garanderie?=
 <gregoire.payendelagaranderie@telecom-bretagne.eu>
Date: Wed, 26 Jan 2011 13:38:30 +0100
Subject: [PATCH] =?UTF-8?q?D=C3=A9placement=20du=20centre=20du=20robot=20e?=
 =?UTF-8?q?t=20correction=20d=E2=80=99un=20bug=20de=20collision?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 stm32/src/simul/robot.cpp | 45 +++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/stm32/src/simul/robot.cpp b/stm32/src/simul/robot.cpp
index 9b0b1247..58c9b87e 100644
--- a/stm32/src/simul/robot.cpp
+++ b/stm32/src/simul/robot.cpp
@@ -80,25 +80,34 @@ Robot::Robot(b2World & world) : olds(10000)
 	fixture.density = 10.0f;
 	fixture.friction = 1.0f;
 
-	box.SetAsBox(1.15,1.795, b2Vec2(-1.49,0),0);
+	box.SetAsBox(1.15,1.795, b2Vec2(-1.49+1.04,0),0);
 	body->CreateFixture(&fixture);
 
+#ifdef BOX2D_2_0_1
+	b2Vec2 & v = box.m_vertices;
 	box.m_vertexCount = 4;
+#else
+	b2Vec2 v[4];
+#endif
 	int inc = 0;
-	box.m_vertices[inc++].Set(-.97,1.07);
-	box.m_vertices[inc++].Set(.60,1.07);
-	box.m_vertices[inc++].Set(0,1.795);
-	box.m_vertices[inc++].Set(-0.97,1.795);
+	v[inc++].Set(-.97+1.04,1.07);
+	v[inc++].Set(.60+1.04,1.07);
+	v[inc++].Set(0+1.04,1.795);
+	v[inc++].Set(-0.97+1.04,1.795);
+#ifndef BOX2D_2_0_1
+	box.Set(v, 4);
+#endif
 	body->CreateFixture(&fixture);
 
 	inc = 0;
-	box.m_vertices[inc++].Set(-0.97,-1.795);
-	box.m_vertices[inc++].Set(0,-1.795);
-	box.m_vertices[inc++].Set(.60,-1.07);
-	box.m_vertices[inc++].Set(-.97,-1.07);
+	v[inc++].Set(-0.97+1.04,-1.795);
+	v[inc++].Set(0+1.04,-1.795);
+	v[inc++].Set(.60+1.04,-1.07);
+	v[inc++].Set(-.97+1.04,-1.07);
+#ifndef BOX2D_2_0_1
+	box.Set(v, 4);
+#endif
 	body->CreateFixture(&fixture);
-	//setTriangle(box, 0, 0, 
-
 
 #ifdef BOX2D_2_0_1
 	body->SetMassFromShapes();
@@ -168,15 +177,15 @@ void Robot::paint(QPainter &p, int dt)
 
 	QPoint po[10];
 	int inc = 0;
-	po[inc++] = QPoint(0,-179.5);
-	po[inc++] = QPoint(-262,-179.5);
-	po[inc++] = QPoint(-262,179.5);
-	po[inc++] = QPoint(0,179.5);
-	po[inc++] = QPoint(60,114.5);
-	po[inc++] = QPoint(60,-114.5);
+	po[inc++] = QPoint(0+104,-179.5);
+	po[inc++] = QPoint(-262+104,-179.5);
+	po[inc++] = QPoint(-262+104,179.5);
+	po[inc++] = QPoint(0+104,179.5);
+	po[inc++] = QPoint(60+104,114.5);
+	po[inc++] = QPoint(60+104,-114.5);
 	p.drawConvexPolygon(po, 6);
 
-	p.drawChord(-103/2, -107, 2*103, 215, 16*90, 16*180);
+	p.drawChord(-103/2 + 104, -107, 2*103, 215, 16*90, 16*180);
 	//p.drawRect(-268, -179.5, 268, 359);
 	//drawTriangle(p, 0, 0,  65, 0,  60, 0);
 	p.setOpacity(1);
-- 
GitLab