commit bdc86e5d6be19374c61e4fe96dc73c70954797ff
parent 8f805ccc1319dcd36e653f92d27b0f81a66092d8
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Wed, 18 Dec 2019 17:29:52 +0100
Add missing files
Diffstat:
2 files changed, 135 insertions(+), 0 deletions(-)
diff --git a/src/sg3_s3d_helper.h b/src/sg3_s3d_helper.h
@@ -0,0 +1,61 @@
+/* Copyright (C) 2016-2019 |Meso|Star> (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 SG3_SENC_WRAPPER_H__
+#define SG3_SENC_WRAPPER_H__
+
+#include "sg3.h"
+#include <star/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
+sg3_s3d_geometry_get_indices__
+ (const unsigned itri,
+ unsigned indices[3],
+ void* ctx)
+{
+ const struct sg3_geometry* geometry = ctx;
+ res_T r;
+ ASSERT(indices && geometry);
+ r = sg3_geometry_get_unique_triangle_vertices(geometry, 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
+sg3_s3d_geometry_get_position__
+ (const unsigned ivert,
+ float coord[3],
+ void* ctx)
+{
+ const struct sg3_geometry* geometry = ctx;
+ double tmp[3];
+ res_T r;
+ ASSERT(coord && geometry);
+ r = sg3_geometry_get_unique_vertex(geometry, ivert, tmp);
+ ASSERT(r == RES_OK); (void)r;
+ f3_set_d3(coord, tmp);
+}
+
+END_DECLS
+
+#endif /* SG3_SENC_WRAPPER_H__ */
diff --git a/src/sg3_senc_helper.h b/src/sg3_senc_helper.h
@@ -0,0 +1,74 @@
+/* Copyright (C) 2016-2019 |Meso|Star> (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 SG3_SENC_WRAPPER_H__
+#define SG3_SENC_WRAPPER_H__
+
+#include "sg3.h"
+#include <star/senc.h>
+
+#include <rsys/rsys.h>
+
+ /* Get vertex indices for the itri_th triangle.
+ * Suitable for use as indices callback in senc_scene_add_geometry calls. */
+static FINLINE void
+sg3_senc_geometry_get_indices__
+ (const unsigned itri,
+ unsigned indices[3],
+ void* ctx)
+{
+ const struct sg3_geometry* geometry = ctx;
+ res_T r;
+ ASSERT(indices && geometry);
+ r = sg3_geometry_get_unique_triangle_vertices(geometry, itri, indices);
+ ASSERT(r == RES_OK); (void)r;
+}
+
+/* Get vertex indices for the itri_th triangle.
+ * Suitable for use as media callback in senc_scene_add_geometry calls. */
+static FINLINE void
+sg3_senc_geometry_get_media__
+ (const unsigned itri,
+ unsigned media[2],
+ void* ctx)
+{
+ const struct sg3_geometry* geometry = ctx;
+ unsigned tmp[SG3_PROP_TYPES_COUNT__];
+ res_T r;
+ ASSERT(media && geometry);
+ r = sg3_geometry_get_unique_triangle_properties(geometry, itri, tmp);
+ ASSERT(r == RES_OK); (void)r;
+ media[SENC_FRONT] = tmp[SG3_FRONT];
+ media[SENC_BACK] = tmp[SG3_BACK];
+}
+
+/* Get vertex indices for the itri_th triangle.
+ * Suitable for use as position callback in senc_scene_add_geometry calls. */
+static FINLINE void
+sg3_senc_geometry_get_position__
+ (const unsigned ivert,
+ double coord[3],
+ void* ctx)
+{
+ const struct sg3_geometry* geometry = ctx;
+ res_T r;
+ ASSERT(coord && geometry);
+ r = sg3_geometry_get_unique_vertex(geometry, ivert, coord);
+ ASSERT(r == RES_OK); (void)r;
+}
+
+END_DECLS
+
+#endif /* SG3_SENC_WRAPPER_H__ */