From kde-commits Sun Oct 31 23:23:41 2010 From: Stefan Majewsky Date: Sun, 31 Oct 2010 23:23:41 +0000 To: kde-commits Subject: KDE/kdegames/kolf Message-Id: <20101031232341.AD1F9AC8B0 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=128856759913014 SVN commit 1191718 by majewsky: Introduce (temporarily!) a preprocessor macro that switches ball movement between the available physics engines. Box2D is not yet the default because its stepping causes some severe regressions (i.e. ghost walls from which the ball bounces off). M +10 -0 ball.cpp M +6 -0 ball.h --- trunk/KDE/kdegames/kolf/ball.cpp #1191717:1191718 @@ -105,10 +105,20 @@ game->ballMoved(); } +#if BALL_BOX2D_STEPPING +void Ball::setVelocity(const Vector& velocity) +{ + CanvasItem::setPhysicalVelocity(velocity); + kDebug() << velocity; +} +#endif + void Ball::doAdvance() { +#if BALL_BOX2D_STEPPING == 0 if (!velocity().isNull()) moveBy(velocity().x(), velocity().y()); +#endif } void Ball::collisionDetect() --- trunk/KDE/kdegames/kolf/ball.h #1191717:1191718 @@ -20,6 +20,7 @@ #ifndef KOLF_BALL_H #define KOLF_BALL_H +#define BALL_BOX2D_STEPPING 1 #include "canvasitem.h" class Wall; @@ -51,6 +52,11 @@ void friction(); void collisionDetect(); +#if BALL_BOX2D_STEPPING + virtual void setVelocity(const Vector& velocity); + Vector velocity() const { return CanvasItem::physicalVelocity(); } +#endif + int addStroke() const { return m_addStroke; } bool placeOnGround(Vector &v) { v = m_pogOldVelocity; return m_placeOnGround; } void setAddStroke(int newStrokes) { m_addStroke = newStrokes; }