summaryrefslogtreecommitdiff
path: root/physics.hpp
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2025-02-07 00:34:44 +1100
committerquou <quou@disroot.org>2025-02-07 00:34:44 +1100
commit73d7f8325aeb00cbaec89a1c15602b9bd85ff04e (patch)
treefbef9f89fad53a86882aab0b17a2ff2d7290ad41 /physics.hpp
parent5d09e4f0880b182a2f4c89508744c27823ed554e (diff)
collision yes/no
Diffstat (limited to 'physics.hpp')
-rw-r--r--physics.hpp65
1 files changed, 63 insertions, 2 deletions
diff --git a/physics.hpp b/physics.hpp
index 6e6b259..a800b16 100644
--- a/physics.hpp
+++ b/physics.hpp
@@ -17,6 +17,23 @@ struct Manifold {
v3f normal;
};
+struct Int_Collider;
+struct Physics_Debughook {
+ virtual void shrinkwrap(
+ const Int_Collider* col,
+ int axis,
+ const v2f* points,
+ int count
+ );
+ virtual void projection(
+ const Int_Collider* col,
+ const v3f& n,
+ int axis,
+ const v2f* points,
+ int count
+ );
+};
+
struct Rigidbody;
struct Int_Collider {
Rigidbody* rb;
@@ -26,7 +43,46 @@ struct Int_Collider {
v3f* verts;
v3f* faces;
- bool collide(const Int_Collider& other) const;
+ bool collide(
+ Physics_Debughook* hook,
+ Arena* a,
+ const Int_Collider& other
+ ) const;
+
+ struct Projection {
+ const Int_Collider* col;
+ v3f r, u;
+
+ struct Iter {
+ const Projection* p;
+ int vert;
+
+ bool equals(const Iter& other) const {
+ return vert == other.vert;
+ }
+ bool operator==(const Iter& other) const {
+ return equals(other);
+ }
+ bool operator!=(const Iter& other) const {
+ return !equals(other);
+ }
+ Iter operator++() {
+ vert++;
+ return *this;
+ }
+ v2f operator*();
+ };
+
+ Iter begin() {
+ return { this, 0 };
+ }
+
+ Iter end() {
+ return { this, col->vert_count };
+ }
+ };
+
+ Projection project(const v3f& axis) const;
};
struct Collider : Asset {
@@ -72,7 +128,12 @@ struct Rigidbody {
Collider* make_box(Arena* a, const v3f& size);
-void physics_update(World& w, Arena* a, float ts);
+void physics_update(
+ World& w,
+ Arena* a,
+ float ts,
+ Physics_Debughook* hook
+);
void physics_debug(World& w, Line_Renderer& lr);
#endif