Files
SimpleRayTracing/header/Algorithm/BVH.h
Misaki 6800810369 Update project structure and improve performance
Added new files for BVH, AABB, and Debug functionalities.
Added new utility functions in Common.h.
Added gamma correction function in PostProcessing.h.
Changed the return type of path_trace to vec4s for alpha blending.
Changed BSDF function signatures to include sample index and bounce.
Changed the BSDF.h to replace inline functions with declarations.
Changed the Light and SkyLight evaluation functions to include throughput and sample index.
Changed the sphere creation function in GeometryUtilities.h for better quality.
Changed the scene structure to include a BVH tree for improved ray intersection.
Changed the scene initialization parameters for better performance.
Created new Debug functions for ray intersection counting.
Created new functions for triangle collection management in Triangle.c.
Improved pixel updating logic in Window.c.
Improved ray intersection performance with new BVH implementation.
Removed unused includes from Common.h.
Removed old library linking methods in CMakeLists.txt.
2025-04-21 15:56:19 +09:00

35 lines
1.1 KiB
C

#ifndef BVH_H
#define BVH_H
#include "Geometry/AABB.h"
#include "Geometry/Triangle.h"
#define SAH_BIN_COUNT 8 // Number of bins for SAH
#define SAH_TRAVERSAL_COST 1.0f // Cost of traversing a node
#define SAH_INTERSECTION_COST 10.0f // Cost of intersecting a triangle
typedef struct
{
aabb_t bounds;
uint64_t start_index;
uint64_t primitive_count;
uint64_t left_child_offset;
uint64_t right_child_offset;
} bvh_node_t;
typedef struct
{
uint64_t node_count; // Current number of nodes used
uint64_t node_capacity; // Allocated capacity for nodes
uint64_t primitive_count; // Total number of primitives (should match triangles->count)
bvh_node_t* nodes;
uint64_t* primitive_indices; // Buffer of indices mapping to the original triangle_collection_t buffer
const triangle_collection_t* triangles; // Pointer to the original triangle data (read-only access)
} bvh_tree_t;
bool bvh_tree_init(bvh_tree_t* bvh_tree, const triangle_collection_t* triangles);
bool bvh_tree_build(bvh_tree_t* bvh_tree);
void bvh_tree_free(bvh_tree_t* bvh_tree);
#endif // BVH_H