diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /sp/src/public/simple_physics.h | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'sp/src/public/simple_physics.h')
| -rw-r--r-- | sp/src/public/simple_physics.h | 162 |
1 files changed, 81 insertions, 81 deletions
diff --git a/sp/src/public/simple_physics.h b/sp/src/public/simple_physics.h index d122d822..fd40b18f 100644 --- a/sp/src/public/simple_physics.h +++ b/sp/src/public/simple_physics.h @@ -1,81 +1,81 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef SIMPLE_PHYSICS_H
-#define SIMPLE_PHYSICS_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-
-#include "mathlib/vector.h"
-
-
-// CSimplePhysics is a framework for simplified physics simulation.
-// It simulates at a fixed timestep and uses the Verlet integrator.
-//
-// To use it, create your nodes and implement your constraints and
-// forces in an IHelper, then call Simulate each frame.
-// CSimplePhysics will figure out how many timesteps to run and will
-// provide predicted positions of things for you.
-class CSimplePhysics
-{
-public:
-
- class CNode
- {
- public:
-
- // Call this when initializing the nodes with their starting positions.
- void Init( const Vector &vPos )
- {
- m_vPos = m_vPrevPos = m_vPredicted = vPos;
- }
-
- Vector m_vPos; // At time t
- Vector m_vPrevPos; // At time t - m_flTimeStep
- Vector m_vPredicted; // Predicted position
- };
-
- class IHelper
- {
- public:
- virtual void GetNodeForces( CNode *pNodes, int iNode, Vector *pAccel ) = 0;
- virtual void ApplyConstraints( CNode *pNodes, int nNodes ) = 0;
- };
-
-
-public:
-
- CSimplePhysics();
-
- void Init( float flTimeStep );
-
- void Simulate(
- CNode *pNodes,
- int nNodes,
- IHelper *pHelper,
- float dt,
- float flDamp );
-
-
-private:
-
- double GetCurTime() { return m_flTimeStep * m_iCurTimeStep; }
-
-
-private:
-
- double m_flPredictedTime; // (GetCurTime()-m_flTimeStep) <= m_flPredictedTime <= GetCurTime()
- int m_iCurTimeStep;
-
- float m_flTimeStep;
- float m_flTimeStepMul; // dt*dt*0.5
-};
-
-
-#endif // SIMPLE_PHYSICS_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef SIMPLE_PHYSICS_H +#define SIMPLE_PHYSICS_H +#ifdef _WIN32 +#pragma once +#endif + + +#include "mathlib/vector.h" + + +// CSimplePhysics is a framework for simplified physics simulation. +// It simulates at a fixed timestep and uses the Verlet integrator. +// +// To use it, create your nodes and implement your constraints and +// forces in an IHelper, then call Simulate each frame. +// CSimplePhysics will figure out how many timesteps to run and will +// provide predicted positions of things for you. +class CSimplePhysics +{ +public: + + class CNode + { + public: + + // Call this when initializing the nodes with their starting positions. + void Init( const Vector &vPos ) + { + m_vPos = m_vPrevPos = m_vPredicted = vPos; + } + + Vector m_vPos; // At time t + Vector m_vPrevPos; // At time t - m_flTimeStep + Vector m_vPredicted; // Predicted position + }; + + class IHelper + { + public: + virtual void GetNodeForces( CNode *pNodes, int iNode, Vector *pAccel ) = 0; + virtual void ApplyConstraints( CNode *pNodes, int nNodes ) = 0; + }; + + +public: + + CSimplePhysics(); + + void Init( float flTimeStep ); + + void Simulate( + CNode *pNodes, + int nNodes, + IHelper *pHelper, + float dt, + float flDamp ); + + +private: + + double GetCurTime() { return m_flTimeStep * m_iCurTimeStep; } + + +private: + + double m_flPredictedTime; // (GetCurTime()-m_flTimeStep) <= m_flPredictedTime <= GetCurTime() + int m_iCurTimeStep; + + float m_flTimeStep; + float m_flTimeStepMul; // dt*dt*0.5 +}; + + +#endif // SIMPLE_PHYSICS_H |