commit 2a16edfa7aa9ca88a76cf1e8ec52f12ccc43b35b
parent e3a68b1ef3c4629f805d5ee3062169f44e34ea06
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 27 Jul 2015 17:11:48 +0200
The s3d_shape_compute_<area|volume> funcs return 0 if the shape is disabled
Diffstat:
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/s3d.h b/src/s3d.h
@@ -337,13 +337,14 @@ s3d_shape_primitives_count
(struct s3d_shape* shape,
size_t* primitives_count);
+/* Return 0 if the shape is disabled */
S3D_API res_T
s3d_shape_compute_area
(struct s3d_shape* shape,
float* area);
/* This function assumes that the shape defines a closed volume and that the
- * normals point into the volume */
+ * normals point into the volume. Return 0 if the shape is disabled */
S3D_API res_T
s3d_shape_compute_volume
(struct s3d_shape* shape,
diff --git a/src/s3d_instance.c b/src/s3d_instance.c
@@ -132,6 +132,10 @@ instance_compute_area(struct instance* inst)
struct list_node* node;
float area = 0.f;
ASSERT(inst);
+
+ if(!inst->geom.is_enabled)
+ return 0.f;
+
/* TODO take into account the scale factor of the instance */
LIST_FOR_EACH(node, &inst->scene->shapes) {
struct s3d_shape* shape = CONTAINER_OF
@@ -155,6 +159,10 @@ instance_compute_volume(struct instance* inst)
struct list_node* node;
float volume = 0.f;
ASSERT(inst);
+
+ if(!inst->geom.is_enabled)
+ return 0.f;
+
/* TODO take into account the scale factor of the instance */
LIST_FOR_EACH(node, &inst->scene->shapes) {
struct s3d_shape* shape = CONTAINER_OF
diff --git a/src/s3d_mesh.c b/src/s3d_mesh.c
@@ -342,7 +342,7 @@ mesh_compute_area(struct mesh* mesh)
ASSERT(mesh);
ntris = mesh_get_ntris(mesh);
- if(!ntris)
+ if(!ntris || !mesh->geom.is_enabled)
return 0.f;
ids = mesh_get_ids(mesh);
@@ -372,7 +372,7 @@ mesh_compute_volume(struct mesh* mesh, const char flip_surface)
ASSERT(mesh);
ntris = mesh_get_ntris(mesh);
- if(!ntris)
+ if(!ntris || !mesh->geom.is_enabled)
return 0.f;
ids = mesh_get_ids(mesh);