From 1ec5c85005c7f0b87d0781a3401d242b1d9436d1 Mon Sep 17 00:00:00 2001 From: ketmar Date: Sun, 19 Jan 2014 20:39:41 +0200 Subject: [PATCH] fixed bug in drawing --- src/jelly/Body.cpp | 16 ++++++++++++++++ src/jelly/Body.h | 5 ++++- src/main.cpp | 3 +-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/jelly/Body.cpp b/src/jelly/Body.cpp index b20540a..db04429 100644 --- a/src/jelly/Body.cpp +++ b/src/jelly/Body.cpp @@ -454,4 +454,20 @@ void Body::addGlobalForce (const Vector2 &pt, const Vector2 &force) { } +Vector2List Body::getVerticiesInWorld () const { + Vector2List res; + for (unsigned int f = mPointMasses.size(); f > 0; --f) res.push_back(Vector2::Zero); + getVerticiesInWorld(res); + return res; +} + + +void Body::getVerticiesInWorld (Vector2List &outList) const { + Vector2List::iterator out = outList.begin(); + for (PointMassList::const_iterator it = mPointMasses.begin(); it != mPointMasses.end(); ++it, ++out) { + *out = it->Position; + } +} + + } diff --git a/src/jelly/Body.h b/src/jelly/Body.h index af91b28..e36e7df 100644 --- a/src/jelly/Body.h +++ b/src/jelly/Body.h @@ -128,9 +128,12 @@ public: bool getIgnoreMe () const { return mIgnoreMe; } void setIgnoreMe (bool setting) { mIgnoreMe = setting; } - //const Vector2List &getGlobalShape (void) const { return mGlobalShape; } + const Vector2List &getGlobalShape (void) const { return mGlobalShape; } const ClosedShape &getBaseShape (void) const { return mBaseShape; } + Vector2List getVerticiesInWorld () const; + void getVerticiesInWorld (Vector2List &outList) const; + public: //Bitmask mBitMaskX; Bitmask mBitMaskY; diff --git a/src/main.cpp b/src/main.cpp index 75ae7cb..36a218a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -231,8 +231,7 @@ static void rebuild (void) { memset(sdl_vscr, 0, SCR_WIDTH*SCR_HEIGHT*sizeof(sdl_vscr[0])); for (int f = 0; f < mWorld->bodyCount(); ++f) { Body *b = mWorld->getBody(f); - const ClosedShape &shp = b->getBaseShape(); - Vector2List vrt = shp.transformVertices(b->getDerivedPosition(), b->getDerivedAngle(), b->getScale()); + Vector2List vrt = b->getVerticiesInWorld(); unsigned int pn = vrt.size()-1; for (unsigned int vn = 0; vn < vrt.size(); pn = vn++) { //fprintf(stderr, "vn=%u; x=%d; y=%d\n", vn, x2s(vrt[vn].X), y2s(vrt[vn].Y)); -- 2.11.4.GIT