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 /mp/src/public/rope_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 'mp/src/public/rope_physics.h')
| -rw-r--r-- | mp/src/public/rope_physics.h | 234 |
1 files changed, 117 insertions, 117 deletions
diff --git a/mp/src/public/rope_physics.h b/mp/src/public/rope_physics.h index fce3eb8f..68f6a5d3 100644 --- a/mp/src/public/rope_physics.h +++ b/mp/src/public/rope_physics.h @@ -1,117 +1,117 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef ROPE_PHYSICS_H
-#define ROPE_PHYSICS_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-
-#include "simple_physics.h"
-#include "networkvar.h"
-
-
-class CRopeSpring
-{
-public:
- Vector *m_pNode1;
- Vector *m_pNode2;
-};
-
-
-class CBaseRopePhysics : public CSimplePhysics::IHelper
-{
-public:
- DECLARE_CLASS_NOBASE( CBaseRopePhysics );
-
- CBaseRopePhysics(
- CSimplePhysics::CNode *pNodes,
- int nNodes,
- CRopeSpring *pSprings,
- float *flSpringDistsSqr );
-
- // nNodes should be less than or equal to what you passed into the constructor.
- void SetNumNodes( int nNodes );
-
- // Restart timers and such.
- void Restart();
-
- void ResetSpringLength(float flSpringDist );
- float GetSpringLength() const;
- void ResetNodeSpringLength( int iStartNode, float flSpringDist );
-
- // Set simulation parameters.
- // If you pass in a delegate, you can be called to apply constraints.
- void SetupSimulation( float flSpringDist, CSimplePhysics::IHelper *pDelegate=0 );
-
- // Set the physics delegate.
- void SetDelegate( CSimplePhysics::IHelper *pDelegate );
-
- void Simulate( float dt );
-
- int NumNodes() { return m_nNodes; }
- CSimplePhysics::CNode* GetNode( int iNode ) { return &m_pNodes[iNode]; }
- CSimplePhysics::CNode* GetFirstNode() { return &m_pNodes[0]; }
- CSimplePhysics::CNode* GetLastNode() { return &m_pNodes[ m_nNodes-1 ]; }
-
-
-
-public:
-
- virtual void GetNodeForces( CSimplePhysics::CNode *pNodes, int iNode, Vector *pAccel );
- virtual void ApplyConstraints( CSimplePhysics::CNode *pNodes, int nNodes );
-
-
-private:
-
- int NumSprings() {return m_nNodes - 1;}
-
-
-protected:
-
- CSimplePhysics::IHelper *m_pDelegate;
-
- CSimplePhysics::CNode *m_pNodes;
- int m_nNodes;
-
- CRopeSpring *m_pSprings;
-
- float m_flSpringDist;
- float m_flSpringDistSqr;
-
- // Spring lengths per node
- float *m_flNodeSpringDistsSqr;
-
- CSimplePhysics m_Physics;
-};
-
-
-
-
-
-template< int NUM_NODES >
-class CRopePhysics : public CBaseRopePhysics
-{
-public:
-
- CRopePhysics();
-
- CSimplePhysics::CNode m_Nodes[NUM_NODES];
- CRopeSpring m_Springs[NUM_NODES - 1];
- float m_SpringDistsSqr[NUM_NODES - 1];
-};
-
-
-template< int NUM_NODES >
-CRopePhysics<NUM_NODES>::CRopePhysics() :
- CBaseRopePhysics( m_Nodes, NUM_NODES, m_Springs, m_SpringDistsSqr )
-{
-}
-
-
-#endif // ROPE_PHYSICS_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef ROPE_PHYSICS_H +#define ROPE_PHYSICS_H +#ifdef _WIN32 +#pragma once +#endif + + +#include "simple_physics.h" +#include "networkvar.h" + + +class CRopeSpring +{ +public: + Vector *m_pNode1; + Vector *m_pNode2; +}; + + +class CBaseRopePhysics : public CSimplePhysics::IHelper +{ +public: + DECLARE_CLASS_NOBASE( CBaseRopePhysics ); + + CBaseRopePhysics( + CSimplePhysics::CNode *pNodes, + int nNodes, + CRopeSpring *pSprings, + float *flSpringDistsSqr ); + + // nNodes should be less than or equal to what you passed into the constructor. + void SetNumNodes( int nNodes ); + + // Restart timers and such. + void Restart(); + + void ResetSpringLength(float flSpringDist ); + float GetSpringLength() const; + void ResetNodeSpringLength( int iStartNode, float flSpringDist ); + + // Set simulation parameters. + // If you pass in a delegate, you can be called to apply constraints. + void SetupSimulation( float flSpringDist, CSimplePhysics::IHelper *pDelegate=0 ); + + // Set the physics delegate. + void SetDelegate( CSimplePhysics::IHelper *pDelegate ); + + void Simulate( float dt ); + + int NumNodes() { return m_nNodes; } + CSimplePhysics::CNode* GetNode( int iNode ) { return &m_pNodes[iNode]; } + CSimplePhysics::CNode* GetFirstNode() { return &m_pNodes[0]; } + CSimplePhysics::CNode* GetLastNode() { return &m_pNodes[ m_nNodes-1 ]; } + + + +public: + + virtual void GetNodeForces( CSimplePhysics::CNode *pNodes, int iNode, Vector *pAccel ); + virtual void ApplyConstraints( CSimplePhysics::CNode *pNodes, int nNodes ); + + +private: + + int NumSprings() {return m_nNodes - 1;} + + +protected: + + CSimplePhysics::IHelper *m_pDelegate; + + CSimplePhysics::CNode *m_pNodes; + int m_nNodes; + + CRopeSpring *m_pSprings; + + float m_flSpringDist; + float m_flSpringDistSqr; + + // Spring lengths per node + float *m_flNodeSpringDistsSqr; + + CSimplePhysics m_Physics; +}; + + + + + +template< int NUM_NODES > +class CRopePhysics : public CBaseRopePhysics +{ +public: + + CRopePhysics(); + + CSimplePhysics::CNode m_Nodes[NUM_NODES]; + CRopeSpring m_Springs[NUM_NODES - 1]; + float m_SpringDistsSqr[NUM_NODES - 1]; +}; + + +template< int NUM_NODES > +CRopePhysics<NUM_NODES>::CRopePhysics() : + CBaseRopePhysics( m_Nodes, NUM_NODES, m_Springs, m_SpringDistsSqr ) +{ +} + + +#endif // ROPE_PHYSICS_H |