Changed CMakeLists.txt to set the C standard to C11. Added multiple binary image files for new visual assets. Added several new image files to enhance rendering capabilities. Changed stb_image.h to improve support for various image formats. Changed ray tracing engine to enhance ray creation and intersection. Changed triangle structure to use a vertex array for better attribute handling. Changed scene initialization to accommodate new texture management.
39 lines
1.1 KiB
C
39 lines
1.1 KiB
C
#ifndef RAY_INTERSECTION_H
|
|
#define RAY_INTERSECTION_H
|
|
|
|
#include "Common.h"
|
|
#include "Geometry/Triangle.h"
|
|
#include "Rendering/Scene.h"
|
|
|
|
#define SIGN_BIT(sign, axis) (((sign) >> (axis)) & 1)
|
|
|
|
typedef struct
|
|
{
|
|
vec3s origin;
|
|
vec3s direction;
|
|
vec3s inverse_direction;
|
|
uint8_t sign;
|
|
} ray_t;
|
|
|
|
typedef struct
|
|
{
|
|
vec3s point;
|
|
vec3s normal;
|
|
vec2s uv;
|
|
uint64_t triangle_id;
|
|
float distance;
|
|
bool hit;
|
|
} hit_result_t;
|
|
|
|
ray_t ray_create(vec3s origin, vec3s direction);
|
|
vec3s offset_ray_origin(vec3s point, vec3s normal, vec3s wo);
|
|
|
|
hit_result_t ray_intersect_triangle(const ray_t* ray, const triangle_t* triangle);
|
|
bool ray_intersect_aabb(const ray_t* ray, aabb_t aabb, float* enter_out, float* exit_out);
|
|
void ray_intersect_bvh(const ray_t* ray, const bvh_node_t* bvh_nodes,
|
|
const uint64_t* primitive_indices, const triangle_collection_t* all_triangles, uint64_t node_index,
|
|
float* closest_out, hit_result_t* best_hit_out);
|
|
hit_result_t ray_intersect_scene(const ray_t* ray, const scene_t* scene);
|
|
|
|
#endif // RAY_INTERSECTION_H
|