commit 0320ac6a3fb476ffe6cea86bbe7d7a40eba6ea3f
parent ca0976b33d65ed0fe9fbc8f3d1cb512532ed18d1
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 26 Jan 2021 12:13:36 +0100
Upd how empty voxels are registered against the octree
Previously, the range of their radiative coefficients were degenerated.
Now, their value is 0.
Diffstat:
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/src/atrstm_dump_svx_octree.c b/src/atrstm_dump_svx_octree.c
@@ -143,10 +143,6 @@ register_leaf
/* Register leaf data */
kext_min = radcoefs[ATRSTM_RADCOEF_Kext][ATRSTM_SVX_OP_MIN];
kext_max = radcoefs[ATRSTM_RADCOEF_Kext][ATRSTM_SVX_OP_MAX];
- if(kext_min > kext_max) {/* Empty voxel */
- kext_min = kext_max = 0;
- }
-
CHK(RES_OK == darray_double_push_back(&ctx->data, &kext_min));
CHK(RES_OK == darray_double_push_back(&ctx->data, &kext_max));
}
diff --git a/src/atrstm_setup_octrees.c b/src/atrstm_setup_octrees.c
@@ -402,10 +402,28 @@ voxel_get(const size_t xyz[3], const uint64_t mcode, void* dst, void* context)
if(!part) { /* An error occurs */
memset(dst, 0, NFLOATS_PER_VOXEL * sizeof(float));
} else {
+ int cpnt;
vox = part_get_voxel(part, ivox); /* Fetch the voxel data */
- /* Copy voxel data */
- memcpy(dst, vox, NFLOATS_PER_VOXEL * sizeof(float));
+ /* Setup destination data */
+ FOR_EACH(cpnt, 0, ATRSTM_CPNTS_COUNT__) {
+ int radcoef;
+ FOR_EACH(radcoef, 0, ATRSTM_RADCOEFS_COUNT__) {
+ const float k_min = vox_get(vox, cpnt, radcoef, ATRSTM_SVX_OP_MIN);
+ const float k_max = vox_get(vox, cpnt, radcoef, ATRSTM_SVX_OP_MAX);
+ ASSERT(ATRSTM_SVX_OPS_COUNT__ == 2);
+
+ if(k_min < k_max) {
+ vox_set(dst, cpnt, radcoef, ATRSTM_SVX_OP_MIN, k_min);
+ vox_set(dst, cpnt, radcoef, ATRSTM_SVX_OP_MAX, k_max);
+ } else {
+ /* The voxel was not overlaped by any tetrahedron. Set its radiative
+ * coefficients to 0 */
+ vox_set(dst, cpnt, radcoef, ATRSTM_SVX_OP_MIN, 0);
+ vox_set(dst, cpnt, radcoef, ATRSTM_SVX_OP_MAX, 0);
+ }
+ }
+ }
/* Free the partition if the fetch voxel was its last one */
if(ivox == PARTITION_NVOXELS - 1) {