Set C standard to C11 and add new assets
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.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "Geometry/Triangle.h"
|
||||
|
||||
bool triangle_collection_init(triangle_collection_t* triangles, size_t size)
|
||||
bool triangle_collection_init(size_t size, triangle_collection_t* triangles)
|
||||
{
|
||||
if (size > UINT64_MAX)
|
||||
{
|
||||
@@ -45,37 +45,23 @@ void triangle_collection_free(triangle_collection_t* collection)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
void triangle_create(vertex_t v1, vertex_t v2, vertex_t v3, uint8_t material_id, triangle_collection_t* collection)
|
||||
{
|
||||
vec3s edge1 = glms_vec3_sub(v2.position, v1.position);
|
||||
vec3s edge2 = glms_vec3_sub(v3.position, v1.position);
|
||||
vec3s normal = glms_vec3_normalize(glms_vec3_cross(edge1, edge2));
|
||||
|
||||
triangle_t triangle = {
|
||||
.vertices = {v1, v2, v3},
|
||||
.face_normal = normal,
|
||||
.material_id = material_id,
|
||||
};
|
||||
|
||||
if (collection->count >= collection->size)
|
||||
{
|
||||
triangle_collection_resize(collection, collection->size * 2);
|
||||
}
|
||||
|
||||
triangle_t triangle;
|
||||
triangle.point_1 = point1;
|
||||
triangle.point_2 = point2;
|
||||
triangle.point_3 = point3;
|
||||
triangle.material_id = material_id;
|
||||
|
||||
triangle.normal_1 = normal1;
|
||||
triangle.normal_2 = normal2;
|
||||
triangle.normal_3 = normal3;
|
||||
|
||||
vec3s edge1 = glms_vec3_sub(point2, point1);
|
||||
vec3s edge2 = glms_vec3_sub(point3, point1);
|
||||
triangle.normal_face = glms_vec3_normalize(glms_vec3_cross(edge1, edge2));
|
||||
|
||||
collection->buffer[collection->count] = triangle;
|
||||
collection->count++;
|
||||
}
|
||||
|
||||
void triangle_create(vec3s point1, vec3s point2, vec3s point3, uint8_t material_id, triangle_collection_t* collection)
|
||||
{
|
||||
vec3s edge1 = glms_vec3_sub(point2, point1);
|
||||
vec3s edge2 = glms_vec3_sub(point3, point1);
|
||||
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