X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?p=physics.git;a=blobdiff_plain;f=src%2FEntities%2FPhysicsEntity.cpp;fp=src%2FEntities%2FPhysicsEntity.cpp;h=b43874b0aec57d908849d222afff2273634b80b8;hp=d8615dae34c2d95096fb1fc769fed0acdaf283d1;hb=fd1a93a71bc0222dd77f56c145d550cb6f7829bc;hpb=a1a3765dc4eaa4f8dad5d8710c3e6f420d3d2e09 diff --git a/src/Entities/PhysicsEntity.cpp b/src/Entities/PhysicsEntity.cpp index d8615da..b43874b 100644 --- a/src/Entities/PhysicsEntity.cpp +++ b/src/Entities/PhysicsEntity.cpp @@ -27,7 +27,7 @@ using namespace bear; /// ***** Constructors/Destructors ***** PhysicsEntity::PhysicsEntity(const Vector2& pos) - : Entity(pos), force(0,0), mass(1), CoR(0.8) + : Entity(pos), m_force(0,0), m_mass(1), m_CoR(0.8) { } @@ -43,31 +43,31 @@ void PhysicsEntity::update(float time_step) position = positionAt(time_step); velocity = velocityAt(time_step); - force *= 0; + m_force *= 0; } Vector2 PhysicsEntity::positionAt(float time_step) const { Vector2 newPosition = position; Vector2 newVelocity = velocity; - Vector2 newForce = force; + Vector2 newForce = m_force; newPosition += effect::positionDelta(this, time_step); newVelocity += effect::velocityDelta(this, time_step); newForce += effect::forceDelta(this, time_step); - return newForce/mass / 2 * time_step * time_step + newVelocity * time_step + newPosition; + return newForce/m_mass / 2 * time_step * time_step + newVelocity * time_step + newPosition; } Vector2 PhysicsEntity::velocityAt(float time_step) const { - Vector2 newForce = force; + Vector2 newForce = m_force; Vector2 newVelocity = velocity; newForce += effect::forceDelta(this, time_step); newVelocity += effect::velocityDelta(this, time_step); - return newForce/mass / 2 * time_step + newVelocity; + return newForce/m_mass / 2 * time_step + newVelocity; } void PhysicsEntity::applyForce(const Vector2& force) @@ -76,7 +76,7 @@ void PhysicsEntity::applyForce(const Vector2& force) } void PhysicsEntity::applyForce(const Vector2& force, const Vector2& /*at*/) { - this->force += force; + this->m_force += force; } void PhysicsEntity::applyImpulse(const Vector2& impulse)