commit ce61446885e68ba72cbc50ffa58d8014082ff0c9
parent 860b5418492f3bab4cb091cd356ba02ce123c64d
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 4 Mar 2021 18:55:25 +0100
Small upd of the setup_tetrahedra_normals function
Diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/suvm_volume.c b/src/suvm_volume.c
@@ -452,18 +452,22 @@ setup_tetrahedra_normals
SWAP(uint32_t, ids[1], ids[2]);
}
- /* Precompute the normals */
+ /* Precompute and store the facet the normals */
if(precompute_normals) {
float* n0 = darray_float_data_get(&vol->normals) + (itetra*4 + 0)*3;
float* n1 = darray_float_data_get(&vol->normals) + (itetra*4 + 1)*3;
float* n2 = darray_float_data_get(&vol->normals) + (itetra*4 + 2)*3;
float* n3 = darray_float_data_get(&vol->normals) + (itetra*4 + 3)*3;
if(!flip) {
- f3_set(n0, normal0);
+ /* Copy the already computed normal of the facet 0 */
+ n0[0] = normal0[0];
+ n0[1] = normal0[1];
+ n0[2] = normal0[2];
} else {
- /* Do not simply negate the normal of the facet 0 if the tetrahedron
- * vertices wer flipped but recompute it from scratch. This ensure that
- * precomputed normals are strictly the same of non-precomputed ones */
+ /* We could store the negated normal of the facet 0 but we recompute it
+ * from scratch to ensure strict equivalence if it is not stored; since
+ * tetrahedron vertices were flipped the negated normal and the
+ * recomputed one are not strictly equals */
volume_primitive_compute_facet_normal(vol, itetra, 0, n0);
}
volume_primitive_compute_facet_normal(vol, itetra, 1, n1);