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:
@@ -22,7 +22,7 @@ typedef vec3s (*evaluate_bsdf_sky_f) (const void* data, const light_shading_cont
|
||||
typedef struct
|
||||
{
|
||||
evaluate_bsdf_sky_f evaluate_bsdf_sky;
|
||||
void* data;
|
||||
const void* data;
|
||||
} sky_light_t;
|
||||
|
||||
typedef enum
|
||||
@@ -66,18 +66,32 @@ typedef struct
|
||||
bool is_punctual;
|
||||
} light_entity_t;
|
||||
|
||||
inline light_collection_t light_collection_create(uint32_t max_punctual_lights, uint32_t max_directional_lights)
|
||||
inline bool light_collection_create(uint32_t max_punctual_lights, uint32_t max_directional_lights, light_collection_t* collection)
|
||||
{
|
||||
light_collection_t collection = {0};
|
||||
collection.max_punctual_lights = max_punctual_lights;
|
||||
collection.max_directional_lights = max_directional_lights;
|
||||
collection.punctual_light_count = 0;
|
||||
collection.directional_light_count = 0;
|
||||
if (max_punctual_lights == 0 || max_directional_lights == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
collection.punctual_lights = (punctual_light_t*)malloc(max_punctual_lights * sizeof(punctual_light_t));
|
||||
collection.directional_lights = (directional_light_t*)malloc(max_directional_lights * sizeof(directional_light_t));
|
||||
collection->max_punctual_lights = max_punctual_lights;
|
||||
collection->max_directional_lights = max_directional_lights;
|
||||
collection->punctual_light_count = 0;
|
||||
collection->directional_light_count = 0;
|
||||
|
||||
return collection;
|
||||
collection->punctual_lights = (punctual_light_t*)malloc(max_punctual_lights * sizeof(punctual_light_t));
|
||||
if (collection->punctual_lights == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
collection->directional_lights = (directional_light_t*)malloc(max_directional_lights * sizeof(directional_light_t));
|
||||
if (collection->directional_lights == NULL)
|
||||
{
|
||||
free(collection->punctual_lights);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline light_entity_t light_create_punctual_light(light_collection_t* collection)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "Geometry/Triangle.h"
|
||||
#include "Rendering/Scene.h"
|
||||
|
||||
vec3s evaluate_bsdf_directional(const directional_light_t light, const light_shading_context_t* context, sobol_state_t* sobol_state);
|
||||
vec3s evaluate_bsdf_directional( directional_light_t light, const light_shading_context_t* context, sobol_state_t* sobol_state);
|
||||
|
||||
inline vec3s evaluate_bsdf_sky(const scene_t* scene, const light_shading_context_t* context, sobol_state_t* sobol_state)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ typedef struct
|
||||
|
||||
vec3s evaluate_bsdf_const_sky(const void* data, const light_shading_context_t* context, sobol_state_t* sobol_state);
|
||||
|
||||
inline sky_light_t sky_create_constant_sky(constant_sky_data_t* data)
|
||||
inline sky_light_t sky_create_constant_sky(const constant_sky_data_t* data)
|
||||
{
|
||||
return (sky_light_t){
|
||||
.evaluate_bsdf_sky = evaluate_bsdf_const_sky,
|
||||
|
||||
Reference in New Issue
Block a user