Avara3D 0.2.0
C++ API reference
PhysicsWorldProxy.h
1//
2// PhysicsWorldProxy.h
3// avara3d
4//
5// Created by Morgan Davis on 12/8/23.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_PHYSICS_PROXY_PHYSICSWORLDPROXY_H
10#define AVARA3D_PHYSICS_PROXY_PHYSICSWORLDPROXY_H
11
12#include <cstdint>
13#include <memory>
14#include <optional>
15#include <vector>
16
17#include "a3d/physics/PhysicsContact.h"
18#include "a3d/physics/PhysicsWorld.h"
19#include "a3d/scene/HitTestResult.h"
20#include "a3d/scene/Scene.h"
21
22namespace a3d {
23
24 class Line;
25 class PhysicsWorld;
26 class PhysicsBody;
27 class Profiler;
28 class Renderer;
29 class RenderContext;
30
31 class PhysicsWorldProxy {
32
33 public:
34 // [Internal Types]
35
36 enum class ContactEventType : uint8_t {
37 Begin,
38 Continue,
39 End
40 };
41
42 struct ContactEvent {
43 ContactEventType type;
44 PhysicsContact contact;
45 };
46
47 using ContactEvents = std::vector<ContactEvent>;
48
49 // [Internal Lifecycle Functions]
50
51 explicit PhysicsWorldProxy(PhysicsWorld& world);
52
53 PhysicsWorldProxy(const PhysicsWorldProxy&) = delete;
54 PhysicsWorldProxy& operator=(const PhysicsWorldProxy&) = delete;
55
56 PhysicsWorldProxy(PhysicsWorldProxy&&) = delete;
57 PhysicsWorldProxy& operator=(PhysicsWorldProxy&&) = delete;
58
59 virtual ~PhysicsWorldProxy();
60
61 // [Internal Member Functions]
62
63 virtual void add(PhysicsBody& body) = 0;
64 virtual void remove(PhysicsBody& body) = 0;
65
66 virtual math::vec3 gravity() const = 0;
67 virtual void gravity(const math::vec3& gravity) = 0;
68
69 virtual const ContactEvents& step(double deltaTime, Profiler& profiler) = 0;
70
71 virtual std::optional<PhysicsContact> contactTest(const PhysicsBody& bodyA,
72 const PhysicsBody& bodyB) const = 0;
73 virtual std::vector<PhysicsContact> contactTest(const PhysicsBody& body) const = 0;
74 virtual std::vector<HitTestResult> rayTest(const math::vec3& from,
75 const math::vec3& to,
76 HitTestSearchMode searchMode) const = 0;
77 // ! NOT IMPLEMENTED !
78 virtual std::vector<PhysicsContact> convexSweepTest(const PhysicsShape& shape,
79 const math::mat4& fromMat,
80 const math::mat4& toMat,
81 HitTestSearchMode searchMode) const = 0;
82
83 virtual PhysicsWorld::Inventory inventory() const = 0;
84
85 virtual void appendDebugLines(std::vector<Line>& out, Scene::DebugOptions debugOptions) = 0;
86 };
87
88}
89
90#endif // AVARA3D_PHYSICS_PROXY_PHYSICSWORLDPROXY_H
DebugOptions
Scene-wide debug visualization options.
Definition: Scene.h:61