[Bf-blender-cvs] [48dc0c6fd6c] gsoc-2021-porting-modifiers-to-nodes-solidify: solidify_extrude_generaly working.
Fabian Schempp
noreply at git.blender.org
Tue Jun 22 10:49:49 CEST 2021
Commit: 48dc0c6fd6c00302422076acb9d1546435f313f3
Author: Fabian Schempp
Date: Mon May 24 08:46:30 2021 +0200
Branches: gsoc-2021-porting-modifiers-to-nodes-solidify
https://developer.blender.org/rB48dc0c6fd6c00302422076acb9d1546435f313f3
solidify_extrude_generaly working.
===================================================================
M source/blender/nodes/CMakeLists.txt
M source/blender/nodes/geometry/node_geometry_util.hh
M source/blender/nodes/geometry/nodes/node_geo_solidify.cc
A source/blender/nodes/geometry/nodes/node_geo_solidify.h
A source/blender/nodes/geometry/nodes/node_geo_solidify_extrude.c
===================================================================
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index ee395f0e235..ce486d0e8ab 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -197,6 +197,7 @@ set(SRC
geometry/nodes/node_geo_select_by_material.cc
geometry/nodes/node_geo_separate_components.cc
geometry/nodes/node_geo_solidify.cc
+ geometry/nodes/node_geo_solidify_extrude.c
geometry/nodes/node_geo_subdivide.cc
geometry/nodes/node_geo_subdivision_surface.cc
geometry/nodes/node_geo_switch.cc
diff --git a/source/blender/nodes/geometry/node_geometry_util.hh b/source/blender/nodes/geometry/node_geometry_util.hh
index 79a98c5ebf0..531348e46a0 100644
--- a/source/blender/nodes/geometry/node_geometry_util.hh
+++ b/source/blender/nodes/geometry/node_geometry_util.hh
@@ -16,6 +16,7 @@
#pragma once
+#include <BKE_modifier.h>
#include <string.h>
#include "BLI_float3.hh"
@@ -40,6 +41,8 @@ bool geo_node_poll_default(struct bNodeType *ntype,
struct bNodeTree *ntree,
const char **r_disabled_hint);
+Mesh *solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh);
+
namespace blender::nodes {
void update_attribute_input_socket_availabilities(bNode &node,
const StringRef name,
diff --git a/source/blender/nodes/geometry/nodes/node_geo_solidify.cc b/source/blender/nodes/geometry/nodes/node_geo_solidify.cc
index f89761acd16..ba60bb90663 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_solidify.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_solidify.cc
@@ -18,6 +18,11 @@
#include "UI_resources.h"
#include "node_geometry_util.hh"
+#include "node_geo_solidify.h"
+
+/*extern "C" { // another way
+ Mesh *solidify_extrude_modifyMesh( Mesh *mesh);
+};*/
static bNodeSocketTemplate geo_node_solidify_in[] = {
{SOCK_GEOMETRY, N_("Geometry")},
@@ -35,102 +40,8 @@ static bNodeSocketTemplate geo_node_solidify_out[] = {
{-1, ""},
};
-static void geo_node_solidify_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
- uiLayoutSetPropSep(layout, true);
- uiLayoutSetPropDecorate(layout, false);
- uiItemR(layout, ptr, "domain", 0, "", ICON_NONE);
- uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE);
-}
-
-static void geo_node_solidify_init(bNodeTree *UNUSED(tree), bNode *node)
-{
- node->custom1 = CD_PROP_FLOAT;
- node->custom2 = ATTR_DOMAIN_AUTO;
-}
-
-static void geo_node_solidify_update(bNodeTree *UNUSED(ntree), bNode *node)
-{
- bNodeSocket *socket_value_vector = (bNodeSocket *)BLI_findlink(&node->inputs, 2);
- bNodeSocket *socket_value_float = socket_value_vector->next;
- bNodeSocket *socket_value_color4f = socket_value_float->next;
- bNodeSocket *socket_value_boolean = socket_value_color4f->next;
- bNodeSocket *socket_value_int32 = socket_value_boolean->next;
-
- const CustomDataType data_type = static_cast<CustomDataType>(node->custom1);
-
- nodeSetSocketAvailability(socket_value_vector, data_type == CD_PROP_FLOAT3);
- nodeSetSocketAvailability(socket_value_float, data_type == CD_PROP_FLOAT);
- nodeSetSocketAvailability(socket_value_color4f, data_type == CD_PROP_COLOR);
- nodeSetSocketAvailability(socket_value_boolean, data_type == CD_PROP_BOOL);
- nodeSetSocketAvailability(socket_value_int32, data_type == CD_PROP_INT32);
-}
-
namespace blender::nodes {
-static AttributeDomain get_result_domain(const GeometryComponent &component, const StringRef name)
-{
- /* Use the domain of the result attribute if it already exists. */
- std::optional<AttributeMetaData> result_info = component.attribute_get_meta_data(name);
- if (result_info) {
- return result_info->domain;
- }
- return ATTR_DOMAIN_POINT;
-}
-
-static void fill_attribute(GeometryComponent &component, const GeoNodeExecParams ¶ms)
-{
- const std::string attribute_name = params.get_input<std::string>("Attribute");
- if (attribute_name.empty()) {
- return;
- }
-
- const bNode &node = params.node();
- const CustomDataType data_type = static_cast<CustomDataType>(node.custom1);
- const AttributeDomain domain = static_cast<AttributeDomain>(node.custom2);
- const AttributeDomain result_domain = (domain == ATTR_DOMAIN_AUTO) ?
- get_result_domain(component, attribute_name) :
- domain;
-
- OutputAttribute attribute = component.attribute_try_get_for_output_only(
- attribute_name, result_domain, data_type);
- if (!attribute) {
- return;
- }
-
- switch (data_type) {
- case CD_PROP_FLOAT: {
- const float value = params.get_input<float>("Value_001");
- attribute->fill(&value);
- break;
- }
- case CD_PROP_FLOAT3: {
- const float3 value = params.get_input<float3>("Value");
- attribute->fill(&value);
- break;
- }
- case CD_PROP_COLOR: {
- const Color4f value = params.get_input<Color4f>("Value_002");
- attribute->fill(&value);
- break;
- }
- case CD_PROP_BOOL: {
- const bool value = params.get_input<bool>("Value_003");
- attribute->fill(&value);
- break;
- }
- case CD_PROP_INT32: {
- const int value = params.get_input<int>("Value_004");
- attribute->fill(&value);
- break;
- }
- default:
- break;
- }
-
- attribute.save();
-}
-
static void geo_node_solidify_exec(GeoNodeExecParams params)
{
GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
@@ -138,14 +49,16 @@ static void geo_node_solidify_exec(GeoNodeExecParams params)
geometry_set = geometry_set_realize_instances(geometry_set);
if (geometry_set.has<MeshComponent>()) {
- fill_attribute(geometry_set.get_component_for_write<MeshComponent>(), params);
- }
- if (geometry_set.has<PointCloudComponent>()) {
- fill_attribute(geometry_set.get_component_for_write<PointCloudComponent>(), params);
- }
- if (geometry_set.has<CurveComponent>()) {
- fill_attribute(geometry_set.get_component_for_write<CurveComponent>(), params);
+ MeshComponent &meshComponent = geometry_set.get_component_for_write<MeshComponent>();
+ Mesh *return_mesh = solidify_extrude_modifyMesh(meshComponent.get_for_write());
+ geometry_set.replace_mesh(return_mesh);
}
+// if (geometry_set.has<PointCloudComponent>()) {
+// fill_attribute(geometry_set.get_component_for_write<PointCloudComponent>(), params);
+// }
+// if (geometry_set.has<CurveComponent>()) {
+// fill_attribute(geometry_set.get_component_for_write<CurveComponent>(), params);
+// }
params.set_output("Geometry", geometry_set);
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_solidify.h b/source/blender/nodes/geometry/nodes/node_geo_solidify.h
new file mode 100644
index 00000000000..e1904717ee8
--- /dev/null
+++ b/source/blender/nodes/geometry/nodes/node_geo_solidify.h
@@ -0,0 +1,13 @@
+//
+// Created by fabian on 24.05.21.
+//
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+Mesh *solidify_extrude_modifyMesh(Mesh *mesh);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/nodes/geometry/nodes/node_geo_solidify_extrude.c b/source/blender/nodes/geometry/nodes/node_geo_solidify_extrude.c
new file mode 100644
index 00000000000..992360a7b1d
--- /dev/null
+++ b/source/blender/nodes/geometry/nodes/node_geo_solidify_extrude.c
@@ -0,0 +1,1240 @@
+/*
+ * 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 2
+ * 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup modifiers
+ */
+
+#include "BLI_utildefines.h"
+#include <BKE_modifier.h>
+#include <DNA_modifier_types.h>
+
+#include "BLI_bitmap.h"
+#include "BLI_math.h"
+#include "BLI_utildefines_stack.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_deform.h"
+#include "BKE_mesh.h"
+#include "BKE_particle.h"
+#include "node_geo_solidify.h"
+
+//#include "node_geometry_util.hh"
+
+#ifdef __GNUC__
+# pragma GCC diagnostic error "-Wsign-conversion"
+#endif
+
+/* -------------------------------------------------------------------- */
+/** \name Local Utilities
+ * \{ */
+
+/* specific function for solidify - define locally */
+BLI_INLINE void madd_v3v3short_fl(float r[3], const short a[3], const float f)
+{
+ r[0] += (float)a[0] * f;
+ r[1] += (float)a[1] * f;
+ r[2] += (float)a[2] * f;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name High Quality Normal Calculation Function
+ * \{ */
+
+/* skip shell thickness for non-manifold edges, see T35710. */
+#define USE_NONMANIFOLD_WORKAROUND
+
+/* *** derived mesh high quality normal calculation function *** */
+/* could be exposed for other functions to use */
+
+typedef struct EdgeFaceRef {
+ int p1; /* init as -1 */
+ int p2;
+} EdgeFaceRef;
+
+BLI_INLINE bool edgeref_is_init(const EdgeFaceRef *edge_ref)
+{
+ return !((edge_ref->p1 == 0) && (edge_ref->p2 == 0));
+}
+
+/**
+ * \param mesh: Mesh to calculate normals for.
+ * \param poly_nors: Precalculated face normals.
+ * \param r_vert_nors: Return vert normals.
+ */
+static void mesh_calc_hq_normal(Mesh *mesh, float (*poly_nors)[3], float (*r_vert_nors)[3])
+{
+ int i, numVerts, numEdges, numPolys;
+ MPoly *mpoly, *mp;
+ MLoop *mloop, *ml;
+ MEdge *medge, *ed;
+ MVert *mvert, *mv;
+
+ numVerts = mesh->totvert;
+ numEdges = mesh->totedge;
+ numPolys = mesh->totpoly;
+ mpoly = mesh->mpoly;
+ medge = mesh->medge;
+ mvert = mesh->mvert;
+ mloop = me
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list