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.
This commit is contained in:
@@ -1,5 +1,50 @@
|
||||
#include "Geometry/Triangle.h"
|
||||
|
||||
bool triangle_collection_init(size_t size, triangle_collection_t* triangles)
|
||||
{
|
||||
if (size > UINT64_MAX)
|
||||
{
|
||||
size = UINT64_MAX;
|
||||
}
|
||||
|
||||
triangle_collection_t temp = {0};
|
||||
temp.buffer = (triangle_t*)malloc(size * sizeof(triangle_t));
|
||||
if (temp.buffer == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
temp.size = (uint64_t)size;
|
||||
temp.count = 0;
|
||||
|
||||
*triangles = temp;
|
||||
return true;
|
||||
}
|
||||
|
||||
void triangle_collection_resize(triangle_collection_t* collection, size_t size)
|
||||
{
|
||||
if (size > UINT64_MAX)
|
||||
{
|
||||
size = UINT64_MAX;
|
||||
}
|
||||
|
||||
triangle_t* temp = (triangle_t*)realloc(collection->buffer, size * sizeof(triangle_t));
|
||||
if (temp != NULL)
|
||||
{
|
||||
collection->buffer = temp;
|
||||
collection->size = (uint64_t)size;
|
||||
}
|
||||
}
|
||||
|
||||
void triangle_collection_free(triangle_collection_t* collection)
|
||||
{
|
||||
if (collection->buffer != NULL)
|
||||
{
|
||||
free(collection->buffer);
|
||||
collection->buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void triangle_create_with_normals(vec3s point1, vec3s point2, vec3s point3,
|
||||
vec3s normal1, vec3s normal2, vec3s normal3,
|
||||
uint8_t material_id, triangle_collection_t* collection)
|
||||
@@ -34,4 +79,3 @@ void triangle_create(vec3s point1, vec3s point2, vec3s point3, uint8_t material_
|
||||
vec3s normal = glms_vec3_normalize(glms_vec3_cross(edge1, edge2));
|
||||
triangle_create_with_normals(point1, point2, point3, normal, normal, normal, material_id, collection);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user