12#ifndef NNGN_COLLISION_H
13#define NNGN_COLLISION_H
40 std::array<uint64_t, 4>
54 static constexpr std::array
names = {
56 "aabb_copy",
"aabb_exec_barrier",
"aabb_exec",
57 "bb_copy",
"bb_exec_barrier",
"bb_exec",
58 "sphere_pos",
"sphere_vel",
"sphere_mass",
"sphere_radius",
59 "sphere_grid_count",
"sphere_exec_grid_barrier",
60 "sphere_exec_grid",
"sphere_exec_barrier",
"sphere_exec",
62 "gravity_pos",
"gravity_mass",
"gravity_max_distance2",
63 "aabb_bb_exec_barrier",
"aabb_bb_exec",
64 "aabb_sphere_exec_barrier",
"aabb_sphere_exec",
65 "bb_sphere_exec_barrier",
"bb_sphere_exec",
66 "sphere_plane_exec_barrier",
"sphere_plane_exec",
67 "sphere_gravity_exec_barrier",
"sphere_gravity_exec"};
75 std::vector<AABBCollider>
aabb = {};
76 std::vector<BBCollider>
bb = {};
77 std::vector<SphereCollider>
sphere = {};
78 std::vector<PlaneCollider>
plane = {};
79 std::vector<GravityCollider>
gravity = {};
86 virtual
bool init(
void) {
return true; }
110 auto &
aabb(
void)
const {
return this->input.
aabb; }
111 auto &
bb(
void)
const {
return this->input.
bb; }
118 bool check(
void)
const {
return this->m_flags.
is_set(Flag::CHECK); }
set_max_colliders
Definition collision.lua:14
local n
Definition dump_lights.lua:5
local c
Definition gamma.lua:11
load
Definition entity.lua:7
#define NNGN_VIRTUAL(x)
Definition utils.h:27
#define NNGN_MOVE_ONLY(x)
Definition utils.h:39
Definition colliders.h:34
Definition colliders.h:44
Definition colliders.h:15
Definition collision.h:81
std::vector< Collision > collisions
Definition collision.h:83
CollisionStats stats
Definition collision.h:82
Definition collision.h:73
virtual bool set_max_collisions(std::size_t)
Definition collision.h:88
virtual bool check(const Timing &, Input *, Output *)
Definition collision.h:89
virtual bool set_max_colliders(std::size_t)
Definition collision.h:87
virtual bool init(void)
Definition collision.h:86
Definition collision.h:72
Flag
Definition collision.h:93
@ CHECK
Definition collision.h:94
@ MAX_COLLIDERS_UPDATED
Definition collision.h:95
@ RESOLVE
Definition collision.h:94
@ MAX_COLLISIONS_UPDATED
Definition collision.h:95
auto & aabb(void) const
Definition collision.h:110
bool resolve(void) const
Definition collision.h:119
auto & collisions(void) const
Definition collision.h:117
Backend::Input input
Definition collision.h:99
bool check_collisions(const Timing &t)
Definition collision.cpp:76
bool set_max_collisions(std::size_t n)
Definition collision.cpp:37
void set_check(bool b)
Definition collision.h:121
void set_resolve(bool b)
Definition collision.h:122
auto & sphere(void) const
Definition collision.h:112
auto & bb(void) const
Definition collision.h:111
std::size_t max_colliders(void) const
Definition collision.h:115
static std::unique_ptr< Backend > native_backend()
Definition native.cpp:440
auto & plane(void) const
Definition collision.h:113
Flags< Flag > m_flags
Definition collision.h:97
void clear(void)
Definition collision.cpp:68
bool lua_on_collision(nngn::lua::state_view lua)
Definition collision.cpp:113
static constexpr std::size_t STATS_IDX
Definition collision.h:104
bool has_backend(void) const
Definition collision.h:120
std::size_t max_collisions(void) const
Definition collision.h:139
Colliders(void)
Definition collision.cpp:18
Backend::Output output
Definition collision.h:100
std::size_t m_max_colliders
Definition collision.h:98
~Colliders(void)
Definition collision.cpp:22
static std::unique_ptr< Backend > compute_backend(Compute *c)
Definition compute.cpp:677
void remove(Collider *p)
Definition collision.cpp:50
std::unique_ptr< Backend > backend
Definition collision.h:101
void resolve_collisions(void) const
Definition collision.cpp:96
auto & gravity(void) const
Definition collision.h:114
AABBCollider * add(const AABBCollider &c)
Definition collision.cpp:145
bool set_backend(std::unique_ptr< Backend > p)
Definition collision.cpp:43
bool check(void) const
Definition collision.h:118
Definition collision.h:39
std::array< uint64_t, 4 > sphere_gravity_exec_barrier
Definition collision.h:53
std::array< uint64_t, 4 > sphere_plane_exec_barrier
Definition collision.h:52
std::array< uint64_t, 4 > sphere_exec
Definition collision.h:46
std::array< uint64_t, 4 > aabb_sphere_exec_barrier
Definition collision.h:50
std::array< uint64_t, 4 > sphere_vel
Definition collision.h:44
std::array< uint64_t, 4 > bb_exec
Definition collision.h:43
std::array< uint64_t, 4 > gravity_mass
Definition collision.h:48
std::array< uint64_t, 4 > sphere_exec_grid
Definition collision.h:46
std::array< uint64_t, 4 > bb_copy
Definition collision.h:43
std::array< uint64_t, 4 > sphere_plane_exec
Definition collision.h:52
std::array< uint64_t, 4 > bb_sphere_exec
Definition collision.h:51
std::array< uint64_t, 4 > aabb_bb_exec_barrier
Definition collision.h:49
std::array< uint64_t, 4 > plane
Definition collision.h:47
std::array< uint64_t, 4 > counters
Definition collision.h:41
static constexpr std::array names
Definition collision.h:54
const uint64_t * to_u64(void) const
Definition collision.h:68
std::array< uint64_t, 4 > bb_sphere_exec_barrier
Definition collision.h:51
std::array< uint64_t, 4 > sphere_radius
Definition collision.h:44
std::array< uint64_t, 4 > sphere_grid_count
Definition collision.h:45
std::array< uint64_t, 4 > bb_exec_barrier
Definition collision.h:43
std::array< uint64_t, 4 > sphere_exec_grid_barrier
Definition collision.h:45
std::array< uint64_t, 4 > gravity_max_distance2
Definition collision.h:48
std::array< uint64_t, 4 > aabb_exec_barrier
Definition collision.h:42
std::array< uint64_t, 4 > sphere_pos
Definition collision.h:44
std::array< uint64_t, 4 > gravity_pos
Definition collision.h:48
std::array< uint64_t, 4 > aabb_copy
Definition collision.h:42
std::array< uint64_t, 4 > aabb_bb_exec
Definition collision.h:49
std::array< uint64_t, 4 > sphere_gravity_exec
Definition collision.h:53
std::array< uint64_t, 4 > aabb_sphere_exec
Definition collision.h:50
std::array< uint64_t, 4 > sphere_exec_barrier
Definition collision.h:46
std::array< uint64_t, 4 > sphere_mass
Definition collision.h:44
uint64_t * to_u64(void)
Definition collision.h:69
std::array< uint64_t, 4 > aabb_exec
Definition collision.h:42
Definition collision.h:32
Entity * entity0
Definition collision.h:33
Entity * entity1
Definition collision.h:33
float mass0
Definition collision.h:34
vec3 force
Definition collision.h:36
float mass1
Definition collision.h:34
Flags< Collider::Flag > flags1
Definition collision.h:35
Flags< Collider::Flag > flags0
Definition collision.h:35
Base class for computation back ends, which may be hardware-accelerated.
Definition compute.h:108
Wrapper for a small unsigned integral representing flags.
Definition flags.h:18
constexpr bool is_set(AT a) const
Definition flags.h:45
constexpr Flags & set(AT a)
Definition flags.h:47
Definition colliders.h:69
Definition colliders.h:61
Definition colliders.h:53
Non-owning reference to a table on the stack.
Definition table.h:166
Operations on table values.