[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegames/kolf
From:       Stefan Majewsky <majewsky () gmx ! net>
Date:       2010-11-12 21:07:23
Message-ID: 20101112210723.BAD30AC8A6 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1196235 by majewsky:

Fix ball-ball collisions by recognizing momentum changes applied to balls in Box2D collisions.

 M  +9 -0      ball.cpp  
 M  +1 -0      ball.h  


--- trunk/KDE/kdegames/kolf/ball.cpp #1196234:1196235
@@ -97,6 +97,15 @@
 		game->ballMoved();
 }
 
+void Ball::endSimulation()
+{
+	CanvasItem::endSimulation();
+	if (state == Stopped)
+		if (!qFuzzyIsNull(Vector(velocity()).magnitude()))
+			//ball was resting, but received some momentum from collision with other ball
+			setState(Rolling);
+}
+
 void Ball::collisionDetect()
 {
 	if (!isVisible() || state == Holed || !m_doDetect)
--- trunk/KDE/kdegames/kolf/ball.h #1196234:1196235
@@ -72,6 +72,7 @@
 
 protected:
 	virtual Kolf::Overlay* createOverlay();
+	virtual void endSimulation();
 
 private:
 	BallState state;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic