Avara3D 0.2.0
C++ API reference
PhysicsBodyProxy.h
1//
2// PhysicsBodyProxy.h
3// avara3d
4//
5// Created by Morgan Davis on 11/13/23.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_PHYSICS_PROXY_PHYSICSBODYPROXY_H
10#define AVARA3D_PHYSICS_PROXY_PHYSICSBODYPROXY_H
11
12#include "a3d/physics/PhysicsBody.h"
13
14namespace a3d {
15
16 class PhysicsBody;
17 class PhysicsShapeProxy;
18
19 class PhysicsBodyProxy {
20
21 public:
22 // [Internal Lifecycle Functions]
23
24 explicit PhysicsBodyProxy(PhysicsBody& body, PhysicsBody::Type type);
25
26 PhysicsBodyProxy(const PhysicsBodyProxy&) = delete;
27 PhysicsBodyProxy& operator=(const PhysicsBodyProxy&) = delete;
28
29 PhysicsBodyProxy(PhysicsBodyProxy&&) = delete;
30 PhysicsBodyProxy& operator=(PhysicsBodyProxy&&) = delete;
31
32 virtual ~PhysicsBodyProxy();
33
34 // [Internal Member Functions]
35
36 virtual PhysicsBody::Type type() const = 0;
37 virtual void type(PhysicsBody::Type type) = 0;
38
39 virtual PhysicsShapeProxy* shapeProxy() const = 0;
40 virtual void shapeProxy(PhysicsShapeProxy* proxy) = 0;
41
42 virtual float mass() const = 0;
43 virtual void mass(float mass) = 0;
44
45 virtual math::vec3 momentOfInertia() const = 0;
46 virtual void momentOfInertia(const math::vec3& moment) = 0;
47
48 virtual math::vec3 centerOfMass() const = 0;
49 virtual void centerOfMass(const math::vec3& offset) = 0;
50
51 virtual float friction() const = 0;
52 virtual void friction(float friction) = 0;
53
54 virtual float rollingFriction() const = 0;
55 virtual void rollingFriction(float friction) = 0;
56
57 virtual float spinningFriction() const = 0;
58 virtual void spinningFriction(float friction) = 0;
59
60 virtual float restitution() const = 0;
61 virtual void restitution(float restitution) = 0;
62
63 virtual math::vec3 linearVelocity() const = 0;
64 virtual void linearVelocity(const math::vec3& velocity) = 0;
65
66 virtual math::vec3 angularVelocity() const = 0;
67 virtual void angularVelocity(const math::vec3& velocity) = 0;
68
69 virtual math::vec3 linearFactor() const = 0;
70 virtual void linearFactor(const math::vec3& factor) = 0;
71
72 virtual math::vec3 angularFactor() const = 0;
73 virtual void angularFactor(const math::vec3& factor) = 0;
74
75 virtual float linearDamping() const = 0;
76 virtual void linearDamping(float damping) = 0;
77
78 virtual float angularDamping() const = 0;
79 virtual void angularDamping(float damping) = 0;
80
81 virtual float linearSleepingThreshold() const = 0;
82 virtual void linearSleepingThreshold(float threshold) = 0;
83
84 virtual float angularSleepingThreshold() const = 0;
85 virtual void angularSleepingThreshold(float threshold) = 0;
86
87 virtual void applyForce(const math::vec3& force, const math::vec3& worldPosition) = 0;
88 virtual void applyCentralForce(const math::vec3& force) = 0;
89
90 virtual void applyImpulse(const math::vec3& impulse, const math::vec3& worldPosition) = 0;
91 virtual void applyCentralImpulse(const math::vec3& impulse) = 0;
92
93 virtual void applyTorque(const math::vec3& torque) = 0;
94 virtual void applyTorqueImpulse(const math::vec3& torque) = 0;
95
96 virtual math::vec3 totalForce() const = 0;
97 virtual math::vec3 totalTorque() const = 0;
98
99 virtual void ccdEnabled(bool enabled) = 0;
100 virtual bool ccdEnabled() const = 0;
101
102 virtual void ccdMotionThreshold(float distance) = 0;
103 virtual float ccdMotionThreshold() const = 0;
104
105 virtual void ccdSweptSphereRadius(float radius) = 0;
106 virtual float ccdSweptSphereRadius() const = 0;
107
108 virtual bool affectedByGravity() const = 0;
109 virtual void affectedByGravity(bool affectedByGravity) = 0;
110
111 virtual bool allowsResting() const = 0;
112 virtual void allowsResting(bool allowsResting) = 0;
113
114 virtual bool resting() const = 0;
115 virtual void resting(bool resting) = 0;
116
117 virtual void clearForces() = 0;
118
119 virtual void worldTransform(const math::mat4& worldTransform) = 0;
120
121 virtual bool autocalculatesCenterOfMass() const;
122 virtual void autocalculatesCenterOfMass(bool autocalculate);
123
124 virtual PhysicsBody::CenterOfMassCalculation centerOfMassCalculation() const;
125 virtual void centerOfMassCalculation(PhysicsBody::CenterOfMassCalculation calculation);
126
127 virtual bool autocalculatesMomentOfInertia() const;
128 virtual void autocalculatesMomentOfInertia(bool autocalculate);
129
130 void attachedToBody(PhysicsBody& body);
131 void detachedFromBody(PhysicsBody& body);
132
133 protected:
134 // [Protected Member Variables]
135
136 PhysicsBody* _body;
137 PhysicsShapeProxy* _shapeProxy;
138 math::vec3 _centerOfMass;
139 bool _autocalculatesCenterOfMass;
140 PhysicsBody::CenterOfMassCalculation _centerOfMassCalculation;
141 bool _autocalculatesMomentOfInertia;
142 };
143
144}
145
146#endif // AVARA3D_PHYSICS_PROXY_PHYSICSBODYPROXY_H
Type
Determines how a rigid body participates in simulation.
Definition: PhysicsBody.h:45
CenterOfMassCalculation
Selects the method used to automatically determine a dynamic body's center of mass.
Definition: PhysicsBody.h:52