Browse Source

Forgot scaling when creating shapes and in PolygonShape::getPoints()

--HG--
branch : box2d-update
Bill Meltsner 14 years ago
parent
commit
5f4b4c8838

+ 5 - 3
src/modules/physics/box2d/Physics.cpp

@@ -65,7 +65,7 @@ namespace box2d
 	CircleShape * Physics::newCircleShape(float x, float y, float radius)
 	{
 		b2CircleShape *s = new b2CircleShape();
-		s->m_p = b2Vec2(x, y);
+		s->m_p = Physics::scaleDown(b2Vec2(x, y));
 		s->m_radius = radius;
 		return new CircleShape(s);
 	}
@@ -83,14 +83,14 @@ namespace box2d
 	PolygonShape * Physics::newRectangleShape(float x, float y, float w, float h, float angle)
 	{
 		b2PolygonShape* s = new b2PolygonShape();
-		s->SetAsBox(w/2.0f, h/2.0f, b2Vec2(x, y), angle);
+		s->SetAsBox(Physics::scaleDown(w/2.0f), Physics::scaleDown(h/2.0f), Physics::scaleDown(b2Vec2(x, y)), angle);
 		return new PolygonShape(s);
 	}
 	
 	EdgeShape * Physics::newEdgeShape(float x1, float y1, float x2, float y2)
 	{
 		b2EdgeShape* s = new b2EdgeShape();
-		s->Set(b2Vec2(x1, y1), b2Vec2(x2, y2));
+		s->Set(Physics::scaleDown(b2Vec2(x1, y1)), Physics::scaleDown(b2Vec2(x2, y2)));
 		return new EdgeShape(s);
 	}
 
@@ -127,6 +127,7 @@ namespace box2d
 		
 		for (int i = 0; i < count; i++) {
 			vecs[i].Set(convex_hull[i].x, convex_hull[i].y);
+			vecs[i] = Physics::scaleDown(vecs[i]);
 		}
 		
 		s->Set(vecs, count);
@@ -155,6 +156,7 @@ namespace box2d
 			float x = (float)lua_tonumber(L, -2);
 			float y = (float)lua_tonumber(L, -1);
 			vecs[i].Set(x, y);
+			vecs[i] = Physics::scaleDown(vecs[i]);
 			lua_pop(L, 2);
 		}
 		

+ 2 - 1
src/modules/physics/box2d/PolygonShape.cpp

@@ -23,6 +23,7 @@
 // Module
 #include "Body.h"
 #include "World.h"
+#include "Physics.h"
 
 namespace love
 {
@@ -48,7 +49,7 @@ namespace box2d
 		int count = p->GetVertexCount();
 		for(int i = 0;i<count; i++)
 		{
-			b2Vec2 v = p->GetVertex(i);
+			b2Vec2 v = Physics::scaleUp(p->GetVertex(i));
 			lua_pushnumber(L, v.x);
 			lua_pushnumber(L, v.y);
 		}