Avara3D 0.2.0
C++ API reference
PhysicsContact.h
1//
2// PhysicsContact.h
3// avara3d
4//
5// Created by Morgan Davis on 1/25/18.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_PHYSICS_PHYSICSCONTACT_H
10#define AVARA3D_PHYSICS_PHYSICSCONTACT_H
11
12#include <memory>
13
14#include "a3d/Math.h"
15
16namespace a3d {
17
18 class Node;
19
30
31 public:
32 // [Public Member Functions]
33
35 std::weak_ptr<Node> nodeA() const;
36
38 std::weak_ptr<Node> nodeB() const;
39
41 const math::vec3& contactPoint() const;
42
44 const math::vec3& contactNormal() const;
45
47 float collisionImpulse() const;
48
50 float penetrationDistance() const;
51
53 float sweepTestFraction() const;
54
55 // [Internal Lifecycle Functions]
56
57 PhysicsContact(std::weak_ptr<Node> nodeA,
58 std::weak_ptr<Node> nodeB,
61 float collisionImpulse,
63 float sweepTestFraction);
64
65 private:
66 // [Private Member Variables]
67
68 std::weak_ptr<Node> _nodeA;
69 std::weak_ptr<Node> _nodeB;
70 math::vec3 _contactPoint;
71 math::vec3 _contactNormal;
72 float _collisionImpulse;
73 float _penetrationDistance;
74 float _sweepTestFraction;
75 };
76
77}
78
79#endif // AVARA3D_PHYSICS_PHYSICSCONTACT_H
Describes a contact between two physics bodies.
float sweepTestFraction() const
Returns the sweep-test fraction associated with this contact; ordinary contact results use zero.
const math::vec3 & contactNormal() const
Returns the world-space contact normal pointing from nodeB() toward nodeA().
std::weak_ptr< Node > nodeA() const
Returns the first contact node as a weak reference.
const math::vec3 & contactPoint() const
Returns the world-space midpoint between the two body contact points.
float penetrationDistance() const
Returns the penetration depth, where zero indicates no penetration and positive values indicate overl...
float collisionImpulse() const
Returns the collision impulse associated with the represented contact point.
std::weak_ptr< Node > nodeB() const
Returns the second contact node as a weak reference.