From 1dd76db64abc2519091463c8b0f0004db4b67964 Mon Sep 17 00:00:00 2001 From: ketmar Date: Sat, 18 Jan 2014 20:33:10 +0200 Subject: [PATCH] cosmetix --- src/jelly/PointMass.cpp | 60 ++++++++++++++++++++++--------------------------- src/jelly/PointMass.h | 58 ++++++++++++++++++++++++----------------------- 2 files changed, 57 insertions(+), 61 deletions(-) rewrite src/jelly/PointMass.cpp (92%) rewrite src/jelly/PointMass.h (86%) diff --git a/src/jelly/PointMass.cpp b/src/jelly/PointMass.cpp dissimilarity index 92% index 9bbc4df..86602d5 100644 --- a/src/jelly/PointMass.cpp +++ b/src/jelly/PointMass.cpp @@ -1,33 +1,27 @@ -#include "PointMass.h" - -namespace JellyPhysics -{ - - PointMass::PointMass( float mass, const Vector2& pos ) - { - Mass = mass; - Position = pos; - Velocity = Force = Vector2::Zero; - lastElapsed = 0; - lastElapMass = 1; - } - - void PointMass::integrateForce( float elapsed ) - { - if (Mass != 0.0f) - { - if (lastElapsed != elapsed) - { - lastElapsed = elapsed; - lastElapMass = elapsed / Mass; - } - - Velocity += (Force * lastElapMass); - - Position += (Velocity * elapsed); - } - - Force = Vector2::Zero; - } - -} +#include "PointMass.h" + + +namespace JellyPhysics { + +PointMass::PointMass (float mass, const Vector2 &pos) { + Mass = mass; + Position = pos; + Velocity = Force = Vector2::Zero; + lastElapsed = 0; + lastElapMass = 1; +} + + +void PointMass::integrateForce (float elapsed) { + if (Mass != 0.0f) { + if (lastElapsed != elapsed) { + lastElapsed = elapsed; + lastElapMass = elapsed/Mass; + } + Velocity += Force*lastElapMass; + Position += Velocity*elapsed; + } + Force = Vector2::Zero; +} + +} diff --git a/src/jelly/PointMass.h b/src/jelly/PointMass.h dissimilarity index 86% index 925ac84..a7a1a27 100644 --- a/src/jelly/PointMass.h +++ b/src/jelly/PointMass.h @@ -1,28 +1,30 @@ -#ifndef _POINT_MASS_H -#define _POINT_MASS_H - -#include "Vector2.h" - -namespace JellyPhysics -{ - - class PointMass - { - public: - float Mass; - Vector2 Position; - Vector2 Velocity; - Vector2 Force; - - PointMass() : Mass(0), Position(Vector2::Zero), Velocity(Vector2::Zero), Force(Vector2::Zero), lastElapsed(0), lastElapMass(1) { } - PointMass( float mass, const Vector2& pos); - - void integrateForce( float elapsed ); - - private: - float lastElapsed; - float lastElapMass; - }; -} - -#endif // _POINT_MASS_H +#ifndef _POINT_MASS_H +#define _POINT_MASS_H + +#include "Vector2.h" + + +namespace JellyPhysics { + +class PointMass { +public: + PointMass () : Mass(0), Position(Vector2::Zero), Velocity(Vector2::Zero), Force(Vector2::Zero), lastElapsed(0), lastElapMass(1) {} + PointMass (float mass, const Vector2 &pos); + + void integrateForce (float elapsed); + +public: + float Mass; + Vector2 Position; + Vector2 Velocity; + Vector2 Force; + +private: + float lastElapsed; + float lastElapMass; +}; + +} + + +#endif -- 2.11.4.GIT