Kohi Game Engine
geometry_3d.h
Go to the documentation of this file.
1 #include "identifiers/khandle.h"
2 #include "math_types.h"
3 
9 typedef struct ray {
12 } ray;
13 
14 typedef enum raycast_hit_type {
18 
19 typedef struct raycast_hit {
27 
28 typedef struct raycast_result {
29  // Darray - only created if a hit exists; otherwise null.
32 
33 KAPI ray ray_create(vec3 position, vec3 direction);
34 KAPI ray ray_from_screen(vec2 screen_pos, rect_2d viewport_rect, vec3 origin, mat4 view, mat4 projection);
35 
36 KAPI b8 raycast_aabb(extents_3d bb_extents, const ray* r, vec3* out_point);
37 KAPI b8 raycast_oriented_extents(extents_3d bb_extents, mat4 model, const ray* r, f32* out_dist);
38 
39 KAPI b8 raycast_plane_3d(const ray* r, const plane_3d* p, vec3* out_point, f32* out_distance);
40 
41 KAPI b8 raycast_disc_3d(const ray* r, vec3 center, vec3 normal, f32 outer_radius, f32 inner_radius, vec3* out_point, f32* out_distance);
#define KAPI
Import/export qualifier.
Definition: defines.h:205
_Bool b8
8-bit boolean type
Definition: defines.h:58
float f32
32-bit floating point number
Definition: defines.h:47
KAPI ray ray_create(vec3 position, vec3 direction)
struct ray ray
Represents a line which starts at an origin and proceed infinitely in the given direction....
struct raycast_hit raycast_hit
KAPI b8 raycast_plane_3d(const ray *r, const plane_3d *p, vec3 *out_point, f32 *out_distance)
KAPI b8 raycast_disc_3d(const ray *r, vec3 center, vec3 normal, f32 outer_radius, f32 inner_radius, vec3 *out_point, f32 *out_distance)
raycast_hit_type
Definition: geometry_3d.h:14
@ RAYCAST_HIT_TYPE_SURFACE
Definition: geometry_3d.h:16
@ RAYCAST_HIT_TYPE_OBB
Definition: geometry_3d.h:15
struct raycast_result raycast_result
KAPI b8 raycast_oriented_extents(extents_3d bb_extents, mat4 model, const ray *r, f32 *out_dist)
KAPI ray ray_from_screen(vec2 screen_pos, rect_2d viewport_rect, vec3 origin, mat4 view, mat4 projection)
KAPI b8 raycast_aabb(extents_3d bb_extents, const ray *r, vec3 *out_point)
A global handle system for Kohi. Handles are used to obtain various resources using a unique handle i...
Contains various math types required for the engine.
Represents the extents of a 3d object.
Definition: math_types.h:213
A handle is a unique identifier used a system in the engine to avoid using raw pointers where possibl...
Definition: khandle.h:25
Definition: math_types.h:256
Represents a line which starts at an origin and proceed infinitely in the given direction....
Definition: geometry_3d.h:9
vec3 origin
Definition: geometry_3d.h:10
vec3 direction
Definition: geometry_3d.h:11
Definition: geometry_3d.h:19
vec3 position
Definition: geometry_3d.h:24
f32 distance
Definition: geometry_3d.h:25
khandle xform_handle
Definition: geometry_3d.h:21
khandle xform_parent_handle
Definition: geometry_3d.h:23
khandle node_handle
Definition: geometry_3d.h:22
raycast_hit_type type
Definition: geometry_3d.h:20
Definition: geometry_3d.h:28
raycast_hit * hits
Definition: geometry_3d.h:30
a 4x4 matrix, typically used to represent object transformations.
Definition: math_types.h:195
A 2-element vector.
Definition: math_types.h:19
A 3-element vector.
Definition: math_types.h:49
A 4-element vector.
Definition: math_types.h:89