Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-10-21 16:42:19 +0300
committerJacques Lucke <jacques@blender.org>2020-10-21 16:42:19 +0300
commitf7af5f993303086f5382c7689ca4c272cbcc81e9 (patch)
treedb2849731c42f27b43dc4df60cf2deb0d4abd963 /source/blender/nodes/geometry/nodes/node_geo_triangulate.cc
parenta7dba81aab22338738365a9a549dd4418f32c2e3 (diff)
initial evaluation code
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_triangulate.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_triangulate.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc b/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc
index e3ece88a576..b9e53947449 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc
@@ -14,7 +14,15 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#include "node_geometry_util.h"
+#include "node_geometry_util.hh"
+
+extern "C" {
+Mesh *triangulate_mesh(Mesh *mesh,
+ const int quad_method,
+ const int ngon_method,
+ const int min_vertices,
+ const int flag);
+}
static bNodeSocketTemplate geo_node_triangulate_in[] = {
{SOCK_GEOMETRY, N_("Geometry")},
@@ -26,11 +34,24 @@ static bNodeSocketTemplate geo_node_triangulate_out[] = {
{-1, ""},
};
+namespace blender::nodes {
+static void geo_triangulate_exec(bNode *UNUSED(node), GeoNodeInput input, GeoNodeOutput output)
+{
+ Geometry *geometry = input.get<GeometryP>("Geometry").p;
+ Mesh *old_mesh = geometry->extract_mesh();
+ delete geometry;
+ Mesh *new_mesh = triangulate_mesh(old_mesh, 3, 0, 4, 0);
+ Geometry *new_geometry = Geometry::from_mesh(new_mesh);
+ output.set("Geometry", GeometryP{new_geometry});
+}
+} // namespace blender::nodes
+
void register_node_type_geo_triangulate()
{
static bNodeType ntype;
geo_node_type_base(&ntype, GEO_NODE_TRIANGULATE, "Triangulate", 0, 0);
node_type_socket_templates(&ntype, geo_node_triangulate_in, geo_node_triangulate_out);
+ ntype.geometry_node_execute = blender::nodes::geo_triangulate_exec;
nodeRegisterType(&ntype);
}