commit 94954c3332a7bd306020f4b37bcddd26efec3b74
parent 8f52045ff2b961a20e03db6e3b4bef1832bc98f0
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Thu, 1 Sep 2016 17:49:39 +0200
Merge branch 'master' of gitlab.com:meso-star/solstice-solver
Diffstat:
6 files changed, 67 insertions(+), 32 deletions(-)
diff --git a/src/ssol.h b/src/ssol.h
@@ -57,9 +57,15 @@ struct ssol_shape;
struct ssol_spectrum;
struct ssol_sun;
+enum ssol_clipping_op {
+ SSOL_AND,
+ SSOL_SUB,
+ SSOL_CLIPPING_OPS_COUNT__
+};
+
enum ssol_pixel_format {
SSOL_PIXEL_DOUBLE3,
- SSOL_PIXEL_FORMAT_COUNT__
+ SSOL_PIXEL_FORMATS_COUNT__
};
enum ssol_parametrization_type {
@@ -74,14 +80,6 @@ enum ssol_quadric_type {
SSOL_QUADRIC_TYPE_COUNT__
};
-enum ssol_carving_type {
- SSOL_CARVING_CIRCLE,
- SSOL_CARVING_POLYGON,
-
- SSOL_CARVING_FIRST_TYPE = SSOL_CARVING_CIRCLE,
- SSOL_CARVING_LAST_TYPE = SSOL_CARVING_POLYGON
-};
-
/* Attribute of a shape */
enum ssol_attrib_usage {
SSOL_POSITION, /* Shape space 3D position */
@@ -101,6 +99,11 @@ struct ssol_vertex_data {
void* ctx); /* Pointer toward user data */
};
+/* Invalid vertex data */
+#define SSOL_VERTEX_DATA_NULL__ { SSOL_ATTRIBS_COUNT__, NULL }
+static const struct ssol_vertex_data SSOL_VERTEX_DATA_NULL =
+ SSOL_VERTEX_DATA_NULL__;
+
struct ssol_image_layout {
size_t row_pitch; /* #bytes between 2 consecutive row */
size_t offset; /* Byte offset where the image begins */
@@ -109,23 +112,34 @@ struct ssol_image_layout {
enum ssol_pixel_format pixel_format; /* Format of a pixel */
};
-/* Invalid vertex data */
-#define SSOL_VERTEX_DATA_NULL__ { SSOL_ATTRIBS_COUNT__, NULL }
-static const struct ssol_vertex_data SSOL_VERTEX_DATA_NULL =
- SSOL_VERTEX_DATA_NULL__;
+/* Invalid image layout */
+#define SSOL_IMAGE_LAYOUT_NULL__ { 0, 0, 0, 0, 0, SSOL_PIXEL_FORMATS_COUNT__ }
+static const struct ssol_image_layout SSOL_IMAGE_LAYOUT_NULL =
+ SSOL_IMAGE_LAYOUT_NULL__;
/* The following quadric definitions are in local coordinate system. */
struct ssol_quadric_plane {
- char unused; /* Define z = 0 */
+ char dummy; /* Define z = 0 */
};
+#define SSOL_QUADRIC_PLANE_DEFAULT__ { 0 }
+static const struct ssol_quadric_plane SSOL_QUADRIC_PLANE_DEFAULT =
+ SSOL_QUADRIC_PLANE_DEFAULT__;
+/* Define x^2 + y^2 - 4 focal z = 0 */
struct ssol_quadric_parabol {
- double focal; /* Define x^2 + y^2 - 4 focal z = 0 */
+ double focal;
};
+#define SSOL_QUADRIC_PARABOL_DEFAULT__ { 0.0 }
+static const struct ssol_quadric_parabol SSOL_QUADRIC_PARABOL_DEFAULT =
+ SSOL_QUADRIC_PARABOL_DEFAULT__;
struct ssol_quadric_parabolic_cylinder {
double focal; /* Define y^2 - 4 focal z = 0 */
};
+#define SSOL_QUADRIC_PARABOLIC_CYLINDER_DEFAULT__ { 0.0 }
+static const struct ssol_quadric_parabolic_cylinder
+SSOL_QUADRIC_PARABOLIC_CYLINDER_DEFAULT =
+ SSOL_QUADRIC_PARABOLIC_CYLINDER_DEFAULT__;
struct ssol_quadric {
enum ssol_quadric_type type;
@@ -136,18 +150,30 @@ struct ssol_quadric {
} data;
};
+#define SSOL_QUADRIC_DEFAULT__ \
+ {SSOL_QUADRIC_PLANE, {SSOL_QUADRIC_PLANE_DEFAULT__}}
+static const struct ssol_quadric SSOL_QUADRIC_DEFAULT = SSOL_QUADRIC_DEFAULT__;
+
+/* Define the contour of a 2D polygon as well as the clipping operation to
+ * apply against it */
struct ssol_carving {
void (*get) /* Retrieve the 2D coordinates of the vertex `ivert' */
(const size_t ivert, double position[2], void* ctx);
size_t nb_vertices; /* #vertices */
+ enum ssol_clipping_op operation; /* Clipping operation */
void* context; /* User defined data */
};
+#define SSOL_CARVING_NULL__ { NULL, 0, SSOL_CLIPPING_OPS_COUNT__, NULL }
+static const struct ssol_carving SSOL_CARVING_NULL = SSOL_CARVING_NULL__;
struct ssol_punched_surface {
struct ssol_quadric* quadric;
struct ssol_carving* carvings;
size_t nb_carvings;
};
+#define SSOL_PUNCHED_SURFACE_NULL__ { NULL, NULL, 0 }
+static const struct ssol_punched_surface SSOL_PUNCHED_SURFACE_NULL =
+ SSOL_PUNCHED_SURFACE_NULL__;
typedef void
(*ssol_shader_getter_T)
@@ -166,6 +192,9 @@ struct ssol_mirror_shader {
ssol_shader_getter_T reflectivity;
ssol_shader_getter_T roughness;
};
+#define SSOL_MIRROR_SHADER_NULL__ { NULL, NULL, NULL }
+static const struct ssol_mirror_shader SSOL_MIRROR_SHADER_NULL =
+ SSOL_MIRROR_SHADER_NULL__;
/*
* All the ssol structures are ref counted. Once created with the appropriated
diff --git a/src/ssol_image.c b/src/ssol_image.c
@@ -102,7 +102,7 @@ ssol_image_setup
|| width <= 0
|| height <= 0
|| format < 0
- || format >= SSOL_PIXEL_FORMAT_COUNT__)
+ || (unsigned)format >= SSOL_PIXEL_FORMATS_COUNT__)
return RES_BAD_ARG;
image->width = width;
diff --git a/src/ssol_solver.c b/src/ssol_solver.c
@@ -44,22 +44,24 @@ enum realization_mode {
MODE_COUNT__
};
+/*******************************************************************************
+* Helper functions
+******************************************************************************/
static INLINE int
-is_instance_punched
- (const struct ssol_object_instance* instance)
+is_instance_punched(const struct ssol_object_instance* instance)
{
ASSERT(instance);
return instance->object->shape->type == SHAPE_PUNCHED;
}
-static const struct ssol_quadric*
-get_quadric (const struct ssol_object_instance* instance)
+static INLINE const struct ssol_quadric*
+get_quadric(const struct ssol_object_instance* instance)
{
ASSERT(instance && is_instance_punched(instance));
return instance->object->shape->quadric;
}
-static struct s3d_scene*
+static INLINE struct s3d_scene*
get_3dscene(const struct ssol_object_instance* instance)
{
ASSERT(instance);
@@ -255,7 +257,7 @@ next_segment(struct realisation* rz)
}
/* TODO: move to Star3D */
-INLINE void s3d_invalidate_hit(struct s3d_hit* hit) {
+static INLINE void s3d_invalidate_hit(struct s3d_hit* hit) {
ASSERT(hit);
hit->distance = FLT_MAX;
}
@@ -503,7 +505,7 @@ set_output_pos_and_dir(struct realisation* rz) {
const struct ssol_sun* sun = scene_get_sun(rz->data.scene);
ASSERT(-1 <= rz->start.cos_sun && rz->start.cos_sun <= 0);
f3_set_d3(sundir_f, rz->start.sundir);
- seg->weight = ssol_sun_get_dni(sun)
+ seg->weight = sun_get_dni(sun)
* brdf_composite_sample(rz->data.brdfs, rz->data.rng, sundir_f, tmp, seg->dir)
* -rz->start.cos_sun;
}
@@ -549,6 +551,9 @@ propagate(struct realisation* rz)
surface_fragment_setup(&rz->data.fragment, seg->hit_pos, seg->dir, seg->hit.normal, &seg->hit.prim, seg->hit.uv);
}
+/*******************************************************************************
+ * Exported function
+ ******************************************************************************/
res_T
ssol_solve
(struct ssol_scene* scene,
diff --git a/src/ssol_sun_c.h b/src/ssol_sun_c.h
@@ -48,8 +48,9 @@ struct ssol_sun {
ref_T ref;
};
-extern INLINE double
-ssol_sun_get_dni(const struct ssol_sun* sun) {
+static INLINE double
+sun_get_dni(const struct ssol_sun* sun)
+{
ASSERT(sun);
return sun->dni;
}
diff --git a/src/test_ssol_geometries.h b/src/test_ssol_geometries.h
@@ -21,7 +21,7 @@ struct desc {
const unsigned* indices;
};
- /*******************************************************************************
+/*******************************************************************************
* Plane
******************************************************************************/
@@ -41,9 +41,8 @@ const unsigned square_walls_ntris = sizeof(square_walls_ids) / sizeof(unsigned[3
static struct desc square_walls_desc = { square_walls, square_walls_ids };
/*******************************************************************************
-* Box
-******************************************************************************/
-
+ * Box
+ ******************************************************************************/
static const float box_walls [] = {
552.f, 0.f, 0.f,
0.f, 0.f, 0.f,
@@ -68,8 +67,8 @@ const unsigned box_walls_ntris = sizeof(box_walls_ids) / sizeof(unsigned[3]);
static struct desc box_walls_desc = { box_walls, box_walls_ids };
/*******************************************************************************
-* Callbacks
-******************************************************************************/
+ * Callbacks
+ ******************************************************************************/
static INLINE void
get_ids(const unsigned itri, unsigned ids[3], void* data)
{
diff --git a/src/test_ssol_solver.c b/src/test_ssol_solver.c
@@ -77,7 +77,8 @@ main(int argc, char** argv)
logger_set_stream(&logger, LOG_ERROR, log_stream, NULL);
logger_set_stream(&logger, LOG_WARNING, log_stream, NULL);
- CHECK(ssol_device_create(&logger, &allocator, SSOL_NTHREADS_DEFAULT, 0, &dev), RES_OK);
+ CHECK(ssol_device_create
+ (&logger, &allocator, SSOL_NTHREADS_DEFAULT, 0, &dev), RES_OK);
CHECK(ssp_rng_create(&allocator, &ssp_rng_threefry, &rng), RES_OK);
CHECK(ssol_spectrum_create(dev, &spectrum), RES_OK);