Changed function signatures to remove const qualifiers
Changed several function signatures across multiple files to remove the `const` qualifier from parameters of type `vec3s` for improved flexibility. Changed `material_collection_create` to `material_collection_init` for better initialization handling. Changed `scene_create` to `scene_init` to return a boolean indicating success or failure. Changed `render_target_create` to `render_target_init` for consistent initialization practices. Changed `window_create` to remove `const` from its parameters for consistency. Changed `evaluate_bsdf_directional` and `evaluate_bsdf_const_sky` to remove `const` from their parameters. Changed `sample_bsdf_simple_lit` and `sample_bsdf_pdf_simple_lit` to remove `const` from the `normal` parameter. Changed `scene_render` to take a pointer to `render_target_t` instead of returning it directly. Updated `main.c` to reflect new initialization functions for better memory management.
This commit is contained in:
@@ -8,8 +8,7 @@ mesh_entity_t mesh_load(const char* filename, uint8_t material_id, triangle_coll
|
||||
{
|
||||
mesh_entity_t entity = {0};
|
||||
|
||||
const C_STRUCT aiScene* scene = NULL;
|
||||
scene = aiImportFile(filename,aiProcessPreset_TargetRealtime_MaxQuality);
|
||||
const C_STRUCT aiScene* scene = aiImportFile(filename,aiProcessPreset_TargetRealtime_MaxQuality);
|
||||
if (scene == NULL)
|
||||
{
|
||||
// fprintf(stderr, "Error loading mesh: %s\n", aiGetErrorString());
|
||||
@@ -18,7 +17,7 @@ mesh_entity_t mesh_load(const char* filename, uint8_t material_id, triangle_coll
|
||||
|
||||
for (uint32_t i = 0; i < scene->mNumMeshes; i++)
|
||||
{
|
||||
const struct aiMesh* mesh = scene->mMeshes[i];
|
||||
struct aiMesh* mesh = scene->mMeshes[i];
|
||||
|
||||
//TODO: Handle all mesh types, not just triangles
|
||||
if (mesh->mPrimitiveTypes != aiPrimitiveType_TRIANGLE)
|
||||
@@ -29,7 +28,7 @@ mesh_entity_t mesh_load(const char* filename, uint8_t material_id, triangle_coll
|
||||
|
||||
for (uint32_t j = 0; j < mesh->mNumFaces; j++)
|
||||
{
|
||||
const struct aiFace* face = &mesh->mFaces[j];
|
||||
struct aiFace* face = &mesh->mFaces[j];
|
||||
if (face->mNumIndices != 3)
|
||||
{
|
||||
// fprintf(stderr, "Face %llu in mesh %llu does not have 3 indices\n", j, i);
|
||||
|
||||
@@ -1,41 +1,5 @@
|
||||
#include "Geometry/Triangle.h"
|
||||
|
||||
triangle_collection_t triangle_collection_create(size_t size)
|
||||
{
|
||||
if (size > UINT64_MAX)
|
||||
{
|
||||
size = UINT64_MAX;
|
||||
}
|
||||
|
||||
triangle_collection_t collection = {0};
|
||||
collection.buffer = (triangle_t*)malloc(size * sizeof(triangle_t));
|
||||
collection.size = (uint64_t)size;
|
||||
return collection;
|
||||
}
|
||||
|
||||
void triangle_collection_resize(triangle_collection_t* collection, size_t size)
|
||||
{
|
||||
if (size > UINT64_MAX)
|
||||
{
|
||||
size = UINT64_MAX;
|
||||
}
|
||||
|
||||
triangle_t* temp = 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)
|
||||
|
||||
Reference in New Issue
Block a user