[Bf-blender-cvs] [c31f095edf3] soc-2021-adaptive-cloth: adaptive_remesh: create a new modifier

ishbosamiya noreply at git.blender.org
Wed Jun 9 06:43:03 CEST 2021


Commit: c31f095edf3502f69400453f2f10e29752c57592
Author: ishbosamiya
Date:   Wed Jun 9 10:11:24 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBc31f095edf3502f69400453f2f10e29752c57592

adaptive_remesh: create a new modifier

===================================================================

M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/CMakeLists.txt
M	source/blender/modifiers/MOD_modifiertypes.h
A	source/blender/modifiers/intern/MOD_adaptive_remesh.cc
M	source/blender/modifiers/intern/MOD_util.c

===================================================================

diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index c61e940190f..a4d7a98dd4a 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -98,6 +98,7 @@ typedef enum ModifierType {
   eModifierType_MeshToVolume = 58,
   eModifierType_VolumeDisplace = 59,
   eModifierType_VolumeToMesh = 60,
+  eModifierType_AdaptiveRemesh = 61,
   NUM_MODIFIER_TYPES,
 } ModifierType;
 
@@ -2343,6 +2344,10 @@ typedef enum VolumeToMeshFlag {
   VOLUME_TO_MESH_USE_SMOOTH_SHADE = 1 << 0,
 } VolumeToMeshFlag;
 
+typedef struct AdaptiveRemeshModifierData {
+  ModifierData modifier;
+} AdaptiveRemeshModifierData;
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 379e3e77b6e..4b8618e1dcd 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -53,6 +53,7 @@ extern StructRNA RNA_ActionFCurves;
 extern StructRNA RNA_ActionGroup;
 extern StructRNA RNA_ActionGroups;
 extern StructRNA RNA_ActionPoseMarkers;
+extern StructRNA RNA_AdaptiveRemeshModifier;
 extern StructRNA RNA_Addon;
 extern StructRNA RNA_AddonPreferences;
 extern StructRNA RNA_AdjustmentSequence;
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 674e5845ccb..ebe92fb8bbb 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -308,6 +308,11 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = {
      "Spawn particles from the shape"},
     {eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""},
     {eModifierType_Surface, "SURFACE", ICON_MODIFIER, "Surface", ""},
+    {eModifierType_AdaptiveRemesh,
+     "ADAPTIVEREMESH",
+     ICON_MOD_CLOTH,
+     "Adaptive Remesh",
+     ""}, /* TODO(ish): Use correct icon. */
     {0, NULL, 0, NULL, NULL},
 };
 
@@ -7222,6 +7227,21 @@ static void rna_def_modifier_volume_to_mesh(BlenderRNA *brna)
   RNA_define_lib_overridable(false);
 }
 
+static void rna_def_modifier_adaptive_remesh(BlenderRNA *brna)
+{
+  StructRNA *srna;
+  PropertyRNA *prop;
+
+  srna = RNA_def_struct(brna, "AdaptiveRemeshModifier", "Modifier");
+  RNA_def_struct_ui_text(srna, "Adaptive Remesh Modifier", "");
+  RNA_def_struct_sdna(srna, "AdaptiveRemeshModifierData");
+  RNA_def_struct_ui_icon(srna, ICON_MOD_CLOTH); /* TODO(ish): Use correct icon. */
+
+  RNA_define_lib_overridable(true);
+
+  RNA_define_lib_overridable(false);
+}
+
 void RNA_def_modifier(BlenderRNA *brna)
 {
   StructRNA *srna;
@@ -7363,6 +7383,7 @@ void RNA_def_modifier(BlenderRNA *brna)
   rna_def_modifier_mesh_to_volume(brna);
   rna_def_modifier_volume_displace(brna);
   rna_def_modifier_volume_to_mesh(brna);
+  rna_def_modifier_adaptive_remesh(brna);
 }
 
 #endif
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 0138dd0c3ad..2b7c895f77b 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -47,6 +47,7 @@ set(INC_SYS
 )
 
 set(SRC
+  intern/MOD_adaptive_remesh.cc
   intern/MOD_armature.c
   intern/MOD_array.c
   intern/MOD_bevel.c
diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h
index f36cb7ded9c..944bd87b764 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -89,6 +89,7 @@ extern ModifierTypeInfo modifierType_Nodes;
 extern ModifierTypeInfo modifierType_MeshToVolume;
 extern ModifierTypeInfo modifierType_VolumeDisplace;
 extern ModifierTypeInfo modifierType_VolumeToMesh;
+extern ModifierTypeInfo modifierType_AdaptiveRemesh;
 
 /* MOD_util.c */
 void modifier_type_init(ModifierTypeInfo *types[]);
diff --git a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
new file mode 100644
index 00000000000..4904905eef8
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2005 by the Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup modifiers
+ */
+
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+#include "BKE_modifier.h"
+
+#include "DNA_screen_types.h"
+
+#include "RNA_access.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "MOD_ui_common.h"
+
+static Mesh *modifyMesh(ModifierData *UNUSED(md),
+                        const ModifierEvalContext *UNUSED(ctx),
+                        Mesh *mesh)
+{
+  return mesh;
+}
+
+static bool dependsOnTime(ModifierData *UNUSED(md))
+{
+  return true;
+}
+
+static void panel_draw(const bContext *UNUSED(C), Panel *panel)
+{
+  uiLayout *layout = panel->layout;
+
+  PointerRNA ob_ptr;
+  PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
+
+  uiLayoutSetPropSep(layout, true);
+
+  modifier_panel_end(layout, ptr);
+}
+
+static void panelRegister(ARegionType *region_type)
+{
+  modifier_panel_register(region_type, eModifierType_AdaptiveRemesh, panel_draw);
+}
+
+ModifierTypeInfo modifierType_AdaptiveRemesh = {
+    /* name */ "AdaptiveRemesh",
+    /* structName */ "AdaptiveRemeshModifierData",
+    /* structSize */ sizeof(AdaptiveRemeshModifierData),
+    /* srna */ &RNA_AdaptiveRemeshModifier,
+    /* type */ eModifierTypeType_Nonconstructive,
+    /* flags */ eModifierTypeFlag_AcceptsMesh,
+    /* icon */ ICON_MOD_CLOTH, /* TODO(ish): Use correct icon. */
+
+    /* copyData */ nullptr,
+
+    /* deformVerts */ nullptr,
+    /* deformMatrices */ nullptr,
+    /* deformVertsEM */ nullptr,
+    /* deformMatricesEM */ nullptr,
+    /* modifyMesh */ modifyMesh,
+    /* modifyHair */ nullptr,
+    /* modifyGeometrySet */ nullptr,
+
+    /* initData */ nullptr,
+    /* requiredDataMask */ nullptr,
+    /* freeData */ nullptr,
+    /* isDisabled */ nullptr,
+    /* updateDepsgraph */ NULL,
+    /* dependsOnTime */ dependsOnTime,
+    /* dependsOnNormals */ nullptr,
+    /* foreachIDLink */ nullptr,
+    /* foreachTexLink */ nullptr,
+    /* freeRuntimeData */ nullptr,
+    /* panelRegister */ panelRegister,
+    /* blendWrite */ nullptr,
+    /* blendRead */ nullptr,
+};
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 55409cba114..26ba440e611 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -346,5 +346,6 @@ void modifier_type_init(ModifierTypeInfo *types[])
   INIT_TYPE(VolumeDisplace);
   INIT_TYPE(VolumeToMesh);
   INIT_TYPE(Nodes);
+  INIT_TYPE(AdaptiveRemesh);
 #undef INIT_TYPE
 }



More information about the Bf-blender-cvs mailing list