Skip to content

Commit

Permalink
FIX debugdraw didn't draw properly circles
Browse files Browse the repository at this point in the history
FIX reset constants and bitmasks to original values (before port to GRRLIB)
FIX button '-' to enable/disable debugdraw
  • Loading branch information
PowerKiKi committed Oct 28, 2010
1 parent 4ec3341 commit 9833688
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions application/source/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace Polukili
const string Constants::basePath("/APPS/Polukili/DATA/");
const string Constants::logFilename(Constants::basePath + "polukili.log");
const int Constants::pixelsPerUnits = 48;
const float Constants::defaultGravity = 1.81f;
const float Constants::defaultGravity = 9.81f;
const float Constants::defaultDensity = 5.0f;
const float Constants::defaultFriction = 0.5f;
const float Constants::defaultFriction = 0.5f;
const float Constants::defaultRestitution = 0.2f;
const float Constants::defaultImpulseSpeed = 10.0f;
const float Constants::timeStep = 1.0f / 60.0f;
Expand Down
8 changes: 3 additions & 5 deletions application/source/DebugDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ namespace Polukili
v[i].y = Constants::pixelsPerUnits * vertices[i].y;
v[i].z = 0;
colors[i] = RGBA((int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255), 255);
Console::log(LOG_INFO, "point[%d] %f, %f, %f, %f", i, v[i].x, v[i].y, vertices[i].x, vertices[i].y);
}

GRRLIB_NGone(v, colors, vertexCount);
Expand All @@ -45,7 +44,6 @@ namespace Polukili
v[i].y = Constants::pixelsPerUnits * vertices[i].y;
v[i].z = 0;
colors[i] = RGBA((int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255), 255);
Console::log(LOG_INFO, "point[%d] %f, %f", i, v[i].x, v[i].y);
}

GRRLIB_NGoneFilled(v, colors, vertexCount);
Expand All @@ -54,19 +52,19 @@ namespace Polukili
void DebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color)
{
u32 c = RGBA((int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255), 255);
GRRLIB_Circle(center.y, center.y, radius, c, 0);
GRRLIB_Circle(Constants::pixelsPerUnits * center.x, Constants::pixelsPerUnits * center.y, Constants::pixelsPerUnits * radius, c, 0);
}

void DebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color)
{
u32 c = RGBA((int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255), 255);
GRRLIB_Circle(center.y, center.y, radius, c, 1);
GRRLIB_Circle(Constants::pixelsPerUnits * center.x, Constants::pixelsPerUnits * center.y, Constants::pixelsPerUnits * radius, c, 1);
}

void DebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color)
{
u32 c = RGBA((int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255), 255);
GRRLIB_Line(p1.x, p1.y, p2.x, p2.y, c);
GRRLIB_Line(Constants::pixelsPerUnits * p1.x, Constants::pixelsPerUnits * p1.y, Constants::pixelsPerUnits * p2.x, Constants::pixelsPerUnits * p2.y, c);
}

void DebugDraw::DrawTransform(const b2Transform& xf)
Expand Down
1 change: 1 addition & 0 deletions application/source/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace Polukili
{
/*************************************************/
Game::Game()
: font(0), debugDrawEnabled(false)
{
GRRLIB_Init();
this->font = GRRLIB_LoadTTF(FreeMonoBold_ttf, FreeMonoBold_ttf_size);
Expand Down
4 changes: 2 additions & 2 deletions application/source/Level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace Polukili

b2FixtureDef circleDef;
circleDef.shape = &circleShape;
// circleDef.filter.categoryBits = ground;
circleDef.filter.categoryBits = ground;

this->body->CreateFixture(&circleDef);

Expand Down Expand Up @@ -148,7 +148,7 @@ namespace Polukili

b2FixtureDef polygonDef;
polygonDef.shape = &polygonShape;
// polygonDef.filter.categoryBits = ground;
polygonDef.filter.categoryBits = ground;
this->body->CreateFixture(&polygonDef);

Console::log(LOG_INFO, "Level::loadFromXML() - polygon read");
Expand Down
4 changes: 2 additions & 2 deletions application/source/Players/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ namespace Polukili
playerDef.density = Constants::defaultDensity;
playerDef.friction = Constants::defaultFriction;
playerDef.restitution = Constants::defaultRestitution;
// playerDef.filter.categoryBits = players;
// playerDef.filter.maskBits = ground + enemies;
playerDef.filter.categoryBits = players;
playerDef.filter.maskBits = ground + enemies;


this->body->CreateFixture(&playerDef);
Expand Down

0 comments on commit 9833688

Please sign in to comment.