commit b249dc676de87f160c6e50a19241a27a1f4fad52
parent 9ddcd523b432fcfad45bfa49600a23edd65b7719
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Fri, 20 Dec 2019 17:58:05 +0100
Upgrade helper functions to use results from star-3d
Diffstat:
3 files changed, 93 insertions(+), 81 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -60,7 +60,7 @@ set(SENC_FILES_SRC
set(SENC_FILES_INC_API
senc.h
- senc_s3d_wrapper.h)
+ senc_s3d_helper.h)
set(SENC_FILES_INC
senc_device_c.h
diff --git a/src/senc_s3d_helper.h b/src/senc_s3d_helper.h
@@ -0,0 +1,92 @@
+/* Copyright (C) |Meso|Star> 2016-2018 (contact@meso-star.com)
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SENC_S3D_WRAPPER_H
+#define SENC_S3D_WRAPPER_H
+
+#include "senc.h"
+
+#include <rsys/rsys.h>
+#include <rsys/float3.h>
+
+/* Get vertex indices for the itri_th triangle.
+ * Suitable for use as get_indice callback in s3d_mesh_setup_indexed_vertices
+ * calls. */
+static FINLINE void
+senc_s3d_scene_get_indices__
+ (const unsigned itri,
+ unsigned indices[3],
+ void* ctx)
+{
+ const struct senc_scene* scene = ctx;
+ res_T r;
+ ASSERT(indices && scene);
+ r = senc_scene_get_triangle(scene, itri, indices);
+ ASSERT(r == RES_OK); (void)r;
+}
+
+/* Get coordinates for the ivert_th vertex.
+ * Suitable for use as s3d_vertex_data getter for S3D_POSITION s3d_attrib_usage
+ * in s3d_mesh_setup_indexed_vertices calls. */
+static FINLINE void
+senc_s3d_scene_get_position__
+ (const unsigned ivert,
+ float coord[3],
+ void* ctx)
+{
+ const struct senc_scene* scene = ctx;
+ double tmp[3];
+ res_T r;
+ ASSERT(coord && scene);
+ r = senc_scene_get_vertex(scene, ivert, tmp);
+ ASSERT(r == RES_OK); (void)r;
+ f3_set_d3(coord, tmp);
+}
+
+/* Get vertex indices for the itri_th triangle of the enclosure.
+ * Suitable for use as get_indice callback in s3d_mesh_setup_indexed_vertices
+ * calls. */
+static FINLINE void
+senc_s3d_enclosure_get_indices__
+ (const unsigned itri,
+ unsigned indices[3],
+ void* ctx)
+{
+ const struct senc_enclosure* enclosure = ctx;
+ res_T r;
+ ASSERT(indices && ctx);
+ r = senc_enclosure_get_triangle(enclosure, itri, indices);
+ ASSERT(r == RES_OK); (void)r;
+}
+
+/* Get coordinates for the ivert_th vertex of the enclosure.
+ * Suitable for use as s3d_vertex_data getter for S3D_POSITION s3d_attrib_usage
+ * in s3d_mesh_setup_indexed_vertices calls. */
+static FINLINE void
+senc_s3d_enclosure_get_position__
+ (const unsigned ivert,
+ float coord[3],
+ void* ctx)
+{
+ const struct senc_enclosure* enclosure = ctx;
+ double tmp[3];
+ res_T r;
+ ASSERT(coord && ctx);
+ r = senc_enclosure_get_vertex(enclosure, ivert, tmp);
+ ASSERT(r == RES_OK); (void)r;
+ f3_set_d3(coord, tmp);
+}
+
+#endif /* SENC_S3D_WRAPPER_H */
diff --git a/src/senc_s3d_wrapper.h b/src/senc_s3d_wrapper.h
@@ -1,80 +0,0 @@
-/* Copyright (C) |Meso|Star> 2016-2018 (contact@meso-star.com)
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef SENC_S3D_WRAPPER_H
-#define SENC_S3D_WRAPPER_H
-
-#include "senc.h"
-
-#include <rsys/rsys.h>
-#include <rsys/float3.h>
-
-static FINLINE void
-senc_scene_get_global_indices__
- (const unsigned itri,
- unsigned indices[3],
- void* ctx)
-{
- const struct senc_scene* scene = ctx;
- res_T r;
- ASSERT(indices && scene);
- r = senc_scene_get_triangle(scene, itri, indices);
- ASSERT(r == RES_OK); (void)r;
-}
-
-static FINLINE void
-senc_scene_get_global_vertices__
- (const unsigned ivert,
- float coord[3],
- void* ctx)
-{
- const struct senc_scene* scene = ctx;
- double tmp[3];
- res_T r;
- ASSERT(coord && scene);
- r = senc_scene_get_vertex(scene, ivert, tmp);
- ASSERT(r == RES_OK); (void)r;
- f3_set_d3(coord, tmp);
-}
-
-static FINLINE void
-senc_enclosure_get_triangle__
- (const unsigned itri,
- unsigned indices[3],
- void* ctx)
-{
- const struct senc_enclosure* enclosure = ctx;
- res_T r;
- ASSERT(indices && ctx);
- r = senc_enclosure_get_triangle(enclosure, itri, indices);
- ASSERT(r == RES_OK); (void)r;
-}
-
-static FINLINE void
-senc_enclosure_get_vertex__
- (const unsigned ivert,
- float coord[3],
- void* ctx)
-{
- const struct senc_enclosure* enclosure = ctx;
- double tmp[3];
- res_T r;
- ASSERT(coord && ctx);
- r = senc_enclosure_get_vertex(enclosure, ivert, tmp);
- ASSERT(r == RES_OK); (void)r;
- f3_set_d3(coord, tmp);
-}
-
-#endif /* SENC_S3D_WRAPPER_H */