-
Notifications
You must be signed in to change notification settings - Fork 98
/
Physics_ShadowController.h
86 lines (68 loc) · 2.57 KB
/
Physics_ShadowController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef PHYSICS_SHADOWCONTROLLER_H
#define PHYSICS_SHADOWCONTROLLER_H
#if defined(_MSC_VER) || (defined(__GNUC__) && __GNUC__ > 3)
#pragma once
#endif
#include "IController.h"
#include "Physics_Object.h"
struct shadowcontrol_params_t {
shadowcontrol_params_t() {lastPosition.setZero();}
btVector3 targetPosition;
btQuaternion targetRotation;
btScalar maxSpeed;
btScalar maxDampSpeed;
btScalar maxAngular;
btScalar maxDampAngular;
btVector3 lastPosition;
float dampFactor;
float teleportDistance;
};
class CShadowController : public IController, public IPhysicsShadowController, public IObjectEventListener
{
public:
CShadowController(CPhysicsObject *pObject, bool allowTranslation, bool allowRotation);
~CShadowController();
void Update(const Vector &position, const QAngle &angles, float timeOffset);
void MaxSpeed(float maxSpeed, float maxAngularSpeed);
void StepUp(float height);
void SetTeleportDistance(float teleportDistance);
bool AllowsTranslation();
bool AllowsRotation();
void SetPhysicallyControlled(bool isPhysicallyControlled);
bool IsPhysicallyControlled();
void GetLastImpulse(Vector *pOut);
void UseShadowMaterial(bool bUseShadowMaterial);
void ObjectMaterialChanged(int materialIndex);
float GetTargetPosition(Vector *pPositionOut, QAngle *pAnglesOut);
float GetTeleportDistance();
void GetMaxSpeed(float *pMaxSpeedOut, float *pMaxAngularSpeedOut);
// UNEXPOSED FUNCTIONS
void Tick(float deltaTime);
void SetAllowsTranslation(bool enable);
void SetAllowsRotation(bool enable);
void ObjectDestroyed(CPhysicsObject *pObject);
int GetTicksSinceUpdate();
private:
void AttachObject();
void DetachObject();
// NOTE: If you add more than 7 flags, change the m_flags variable type to a short.
enum EShadowFlags {
FLAG_ALLOWPHYSICSMOVEMENT = 1<<0,
FLAG_ALLOWPHYSICSROTATION = 1<<1,
FLAG_PHYSICALLYCONTROLLED = 1<<2,
FLAG_USESHADOWMATERIAL = 1<<3,
};
CPhysicsObject * m_pObject;
float m_secondsToArrival;
btVector3 m_currentSpeed;
float m_savedMass;
float m_timeOffset;
int m_savedMaterialIndex;
int m_ticksSinceUpdate;
bool m_enable;
char m_flags;
shadowcontrol_params_t m_shadow;
};
float ComputeShadowControllerHL(CPhysicsObject *pObject, const hlshadowcontrol_params_t ¶ms, float secondsToArrival, float dt);
CShadowController *CreateShadowController(IPhysicsObject *pObject, bool allowPhysicsMovement, bool allowPhysicsRotation);
#endif // PHYSICS_SHADOWCONTROLLER_H