commit 3face32bdf729929c34ac339cd62393cdba13ce8
parent ae0824fb5ebe7db0870ae64dfad85444ba85dbaf
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 13 Feb 2017 13:33:56 +0100
Fix GCC warnings & coding style
Diffstat:
3 files changed, 43 insertions(+), 47 deletions(-)
diff --git a/src/ssol_scene.c b/src/ssol_scene.c
@@ -44,8 +44,8 @@ scene_release(ref_T* ref)
ASSERT(dev && dev->allocator);
SSOL(scene_clear(scene));
if(scene->scn_rt) S3D(scene_ref_put(scene->scn_rt));
- if (scene->scn_samp) S3D(scene_ref_put(scene->scn_samp));
- if (scene->scn_prim) S3D(scene_ref_put(scene->scn_prim));
+ if(scene->scn_samp) S3D(scene_ref_put(scene->scn_samp));
+ if(scene->scn_prim) S3D(scene_ref_put(scene->scn_prim));
if(scene->sun) SSOL(sun_ref_put(scene->sun));
if(scene->atmosphere) SSOL(atmosphere_ref_put(scene->atmosphere));
htable_instance_release(&scene->instances_rt);
@@ -83,7 +83,7 @@ ssol_scene_create
res = s3d_scene_create(dev->s3d, &scene->scn_rt);
if(res != RES_OK) goto error;
res = s3d_scene_create(dev->s3d, &scene->scn_samp);
- if (res != RES_OK) goto error;
+ if(res != RES_OK) goto error;
res = s3d_scene_create(dev->s3d, &scene->scn_prim);
if(res != RES_OK) goto error;
@@ -320,7 +320,7 @@ scene_create_s3d_views
/* Attach the instantiated s3d raytraced shape to the s3d primary scene */
res = s3d_scene_attach_shape(scn->scn_prim, inst->shape_rt);
- if (res != RES_OK) goto error;
+ if(res != RES_OK) goto error;
/* Register the instantiated s3d sampling shape */
S3D(shape_get_id(inst->shape_samp, &id));
diff --git a/src/ssol_solver.c b/src/ssol_solver.c
@@ -59,7 +59,18 @@ struct point {
enum ssol_side_flag side;
};
-#define POINT_NULL__ { NULL, NULL, S3D_PRIMITIVE_NULL__, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0}, 0, 0, 0, 0, SSOL_FRONT }
+#define POINT_NULL__ { \
+ NULL, /* Instance */ \
+ NULL, /* Shaded shape */ \
+ S3D_PRIMITIVE_NULL__, /* Primitive */ \
+ {0, 0, 0}, /* Normal */ \
+ {0, 0, 0}, /* Position */ \
+ {0, 0, 0}, /* Direction */ \
+ {0, 0}, /* UV */ \
+ 0, /* Wavelength */ \
+ 0, 0, 0, /* MC weights */ \
+ SSOL_FRONT /* Side */ \
+}
static const struct point POINT_NULL = POINT_NULL__;
/*******************************************************************************
@@ -552,40 +563,24 @@ ssol_solve
/* Sum both sides, even if no receiver is defined to avoid tests */
struct mc_per_receiver_data* thread_data
= htable_receiver_find(mc_rcvs + i, &key);
- estimator_data->front.irradiance.weight
- += thread_data->front.irradiance.weight;
- estimator_data->front.irradiance.sqr_weight
- += thread_data->front.irradiance.sqr_weight;
- estimator_data->back.irradiance.weight
- += thread_data->back.irradiance.weight;
- estimator_data->back.irradiance.sqr_weight
- += thread_data->back.irradiance.sqr_weight;
-
- estimator_data->front.absorptivity_loss.weight
- += thread_data->front.absorptivity_loss.weight;
- estimator_data->front.absorptivity_loss.sqr_weight
- += thread_data->front.absorptivity_loss.sqr_weight;
- estimator_data->back.absorptivity_loss.weight
- += thread_data->back.absorptivity_loss.weight;
- estimator_data->back.absorptivity_loss.sqr_weight
- += thread_data->back.absorptivity_loss.sqr_weight;
-
- estimator_data->front.reflectivity_loss.weight
- += thread_data->front.reflectivity_loss.weight;
- estimator_data->front.reflectivity_loss.sqr_weight
- += thread_data->front.reflectivity_loss.sqr_weight;
- estimator_data->back.reflectivity_loss.weight
- += thread_data->back.reflectivity_loss.weight;
- estimator_data->back.reflectivity_loss.sqr_weight
- += thread_data->back.reflectivity_loss.sqr_weight;
+ #define ACCUM_WEIGHT(Name) { \
+ estimator_data->front.Name.weight += thread_data->front.Name.weight; \
+ estimator_data->back.Name.weight += thread_data->front.Name.weight; \
+ estimator_data->front.Name.sqr_weight += thread_data->front.Name.sqr_weight;\
+ estimator_data->back.Name.sqr_weight += thread_data->front.Name.sqr_weight;\
+ } (void)0
+ ACCUM_WEIGHT(irradiance);
+ ACCUM_WEIGHT(absorptivity_loss);
+ ACCUM_WEIGHT(reflectivity_loss);
+ #undef ACCUM_WEIGHT
}
}
estimator->realisation_count += realisations_count;
exit:
if(view_rt) S3D(scene_view_ref_put(view_rt));
- if (view_samp) S3D(scene_view_ref_put(view_samp));
- if (view_prim) S3D(scene_view_ref_put(view_prim));
+ if(view_samp) S3D(scene_view_ref_put(view_samp));
+ if(view_prim) S3D(scene_view_ref_put(view_prim));
if(ran_sun_dir) ranst_sun_dir_ref_put(ran_sun_dir);
if(ran_sun_wl) ranst_sun_wl_ref_put(ran_sun_wl);
if(rng_proxy) SSP(rng_proxy_ref_put(rng_proxy));
diff --git a/src/test_ssol_materials.h b/src/test_ssol_materials.h
@@ -16,11 +16,13 @@
#ifndef TEST_SSOL_MATERIALS_H
#define TEST_SSOL_MATERIALS_H
+#include <rsys/rsys.h>
+
#define REFLECTIVITY 0.87
struct ssol_device;
-static void
+static INLINE void
get_shader_normal
(struct ssol_device* dev,
struct ssol_param_buffer* buf,
@@ -37,7 +39,7 @@ get_shader_normal
FOR_EACH(i, 0, 3) val[i] = Ns[i];
}
-static void
+static INLINE void
get_shader_reflectivity
(struct ssol_device* dev,
struct ssol_param_buffer* buf,
@@ -54,24 +56,24 @@ get_shader_reflectivity
*val = 1;
}
-static void
+static INLINE void
get_shader_reflectivity_2
-(struct ssol_device* dev,
- struct ssol_param_buffer* buf,
- const double wavelength,
- const double P[3],
- const double Ng[3],
- const double Ns[3],
- const double uv[2],
- const double w[3],
- double* val)
+ (struct ssol_device* dev,
+ struct ssol_param_buffer* buf,
+ const double wavelength,
+ const double P[3],
+ const double Ng[3],
+ const double Ns[3],
+ const double uv[2],
+ const double w[3],
+ double* val)
{
(void) dev, (void) buf, (void) wavelength;
(void) P, (void) Ng, (void) Ns, (void) uv, (void) w;
*val = REFLECTIVITY;
}
-static void
+static INLINE void
get_shader_roughness
(struct ssol_device* dev,
struct ssol_param_buffer* buf,
@@ -88,5 +90,4 @@ get_shader_roughness
*val = 0;
}
-
#endif /* TEST_SSOL_MATERIALS_H */