[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47809] branches/soc-2012-sushi: I added a new modifier for laplacian smooth, with base on http://wiki. blender.org/index.php/Dev:Source/Modifiers/Adding

Alexander Pinzon apinzonf at gmail.com
Wed Jun 13 00:15:08 CEST 2012


Revision: 47809
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47809
Author:   apinzonf
Date:     2012-06-12 22:14:55 +0000 (Tue, 12 Jun 2012)
Log Message:
-----------
I added a new modifier for laplacian smooth, with base on http://wiki.blender.org/index.php/Dev:Source/Modifiers/Adding
At this moment the laplacian smooth is then same that smooth modifier.

Modified Paths:
--------------
    branches/soc-2012-sushi/release/scripts/startup/bl_ui/properties_data_modifier.py
    branches/soc-2012-sushi/source/blender/makesdna/DNA_modifier_types.h
    branches/soc-2012-sushi/source/blender/makesrna/RNA_access.h
    branches/soc-2012-sushi/source/blender/makesrna/intern/rna_modifier.c
    branches/soc-2012-sushi/source/blender/modifiers/CMakeLists.txt
    branches/soc-2012-sushi/source/blender/modifiers/MOD_modifiertypes.h
    branches/soc-2012-sushi/source/blender/modifiers/intern/MOD_util.c

Added Paths:
-----------
    branches/soc-2012-sushi/source/blender/modifiers/intern/MOD_laplaciansmooth.c

Modified: branches/soc-2012-sushi/release/scripts/startup/bl_ui/properties_data_modifier.py
===================================================================
--- branches/soc-2012-sushi/release/scripts/startup/bl_ui/properties_data_modifier.py	2012-06-12 22:05:33 UTC (rev 47808)
+++ branches/soc-2012-sushi/release/scripts/startup/bl_ui/properties_data_modifier.py	2012-06-12 22:14:55 UTC (rev 47809)
@@ -307,7 +307,21 @@
             row = layout.row()
             row.operator("object.hook_select", text="Select")
             row.operator("object.hook_assign", text="Assign")
+    def LAPLACIANSMOOTH(self, layout, ob, md):
+        split = layout.split(percentage=0.25)
 
+        col = split.column()
+        col.label(text="Axis:")
+        col.prop(md, "use_x")
+        col.prop(md, "use_y")
+        col.prop(md, "use_z")
+
+        col = split.column()
+        col.prop(md, "factor")
+        col.prop(md, "iterations")
+        col.label(text="Vertex Group:")
+        col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+
     def LATTICE(self, layout, ob, md):
         split = layout.split()
 

Modified: branches/soc-2012-sushi/source/blender/makesdna/DNA_modifier_types.h
===================================================================
--- branches/soc-2012-sushi/source/blender/makesdna/DNA_modifier_types.h	2012-06-12 22:05:33 UTC (rev 47808)
+++ branches/soc-2012-sushi/source/blender/makesdna/DNA_modifier_types.h	2012-06-12 22:14:55 UTC (rev 47809)
@@ -77,6 +77,7 @@
 	eModifierType_Ocean,
 	eModifierType_DynamicPaint,
 	eModifierType_Remesh,
+	eModifierType_LaplacianSmooth,
 	NUM_MODIFIER_TYPES
 } ModifierType;
 
@@ -1065,4 +1066,17 @@
 	char pad;
 } RemeshModifierData;
 
+/* Smooth modifier flags */
+#define MOD_LAPLACIANSMOOTH_X (1<<1)
+#define MOD_LAPLACIANSMOOTH_Y (1<<2)
+#define MOD_LAPLACIANSMOOTH_Z (1<<3)
+
+typedef struct LaplacianSmoothModifierData {
+	ModifierData modifier;
+	float fac;
+	char defgrp_name[64];	/* MAX_VGROUP_NAME */
+	short flag, repeat;
+
+} LaplacianSmoothModifierData;
+
 #endif

Modified: branches/soc-2012-sushi/source/blender/makesrna/RNA_access.h
===================================================================
--- branches/soc-2012-sushi/source/blender/makesrna/RNA_access.h	2012-06-12 22:05:33 UTC (rev 47808)
+++ branches/soc-2012-sushi/source/blender/makesrna/RNA_access.h	2012-06-12 22:14:55 UTC (rev 47809)
@@ -469,6 +469,7 @@
 extern StructRNA RNA_SmokeFlowSettings;
 extern StructRNA RNA_SmokeModifier;
 extern StructRNA RNA_SmoothModifier;
+extern StructRNA RNA_LaplacianSmoothModifier;
 extern StructRNA RNA_SoftBodyModifier;
 extern StructRNA RNA_SoftBodySettings;
 extern StructRNA RNA_SolidifyModifier;

Modified: branches/soc-2012-sushi/source/blender/makesrna/intern/rna_modifier.c
===================================================================
--- branches/soc-2012-sushi/source/blender/makesrna/intern/rna_modifier.c	2012-06-12 22:05:33 UTC (rev 47808)
+++ branches/soc-2012-sushi/source/blender/makesrna/intern/rna_modifier.c	2012-06-12 22:14:55 UTC (rev 47809)
@@ -83,6 +83,7 @@
 	{eModifierType_Curve, "CURVE", ICON_MOD_CURVE, "Curve", ""},
 	{eModifierType_Displace, "DISPLACE", ICON_MOD_DISPLACE, "Displace", ""},
 	{eModifierType_Hook, "HOOK", ICON_HOOK, "Hook", ""},
+	{eModifierType_LaplacianSmooth, "LAPLACIANSMOOTH", ICON_MOD_SMOOTH, "Laplacian Smooth", ""},
 	{eModifierType_Lattice, "LATTICE", ICON_MOD_LATTICE, "Lattice", ""},
 	{eModifierType_MeshDeform, "MESH_DEFORM", ICON_MOD_MESHDEFORM, "Mesh Deform", ""},
 	{eModifierType_Shrinkwrap, "SHRINKWRAP", ICON_MOD_SHRINKWRAP, "Shrinkwrap", ""},
@@ -207,6 +208,8 @@
 			return &RNA_DynamicPaintModifier;
 		case eModifierType_Remesh:
 			return &RNA_RemeshModifier;
+		case eModifierType_LaplacianSmooth:
+			return &RNA_LaplacianSmoothModifier;
 		default:
 			return &RNA_Modifier;
 	}
@@ -381,6 +384,12 @@
 	rna_object_vgroup_name_set(ptr, value, lmd->defgrp_name, sizeof(lmd->defgrp_name));
 }
 
+static void rna_LaplacianSmoothModifier_vgroup_set(PointerRNA *ptr, const char *value)
+{
+	LaplacianSmoothModifierData *lmd = (LaplacianSmoothModifierData *)ptr->data;
+	rna_object_vgroup_name_set(ptr, value, lmd->defgrp_name, sizeof(lmd->defgrp_name));
+}
+
 static void rna_WaveModifier_vgroup_set(PointerRNA *ptr, const char *value)
 {
 	WaveModifierData *lmd = (WaveModifierData *)ptr->data;
@@ -1727,6 +1736,52 @@
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
+static void rna_def_modifier_laplaciansmooth(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	srna = RNA_def_struct(brna, "LaplacianSmoothModifier", "Modifier");
+	RNA_def_struct_ui_text(srna, "Laplacian Smooth Modifier", "Smoothing effect modifier");
+	RNA_def_struct_sdna(srna, "LaplacianSmoothModifierData");
+	RNA_def_struct_ui_icon(srna, ICON_MOD_SMOOTH);
+
+	prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_X);
+	RNA_def_property_ui_text(prop, "X", "Smooth object along X axis");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_Y);
+	RNA_def_property_ui_text(prop, "Y", "Smooth object along Y axis");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_Z);
+	RNA_def_property_ui_text(prop, "Z", "Smooth object along Z axis");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "fac");
+	RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
+	RNA_def_property_ui_range(prop, -10, 10, 1, 3);
+	RNA_def_property_ui_text(prop, "Factor", "Strength of modifier effect");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
+	RNA_def_property_int_sdna(prop, NULL, "repeat");
+	RNA_def_property_ui_range(prop, 0, 30, 1, 0);
+	RNA_def_property_ui_text(prop, "Repeat", "");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+	
+	prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
+	RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
+	RNA_def_property_ui_text(prop, "Vertex Group",
+	                         "Name of Vertex Group which determines influence of modifier per point");
+	RNA_def_property_string_funcs(prop, NULL, NULL, "rna_LaplacianSmoothModifier_vgroup_set");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+}
+
 static void rna_def_modifier_cast(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -3301,6 +3356,7 @@
 	rna_def_modifier_dynamic_paint(brna);
 	rna_def_modifier_ocean(brna);
 	rna_def_modifier_remesh(brna);
+	rna_def_modifier_laplaciansmooth(brna);
 }
 
 #endif

Modified: branches/soc-2012-sushi/source/blender/modifiers/CMakeLists.txt
===================================================================
--- branches/soc-2012-sushi/source/blender/modifiers/CMakeLists.txt	2012-06-12 22:05:33 UTC (rev 47808)
+++ branches/soc-2012-sushi/source/blender/modifiers/CMakeLists.txt	2012-06-12 22:14:55 UTC (rev 47809)
@@ -64,6 +64,7 @@
 	intern/MOD_fluidsim_util.c
 	intern/MOD_hook.c
 	intern/MOD_lattice.c
+	intern/MOD_laplaciansmooth.c
 	intern/MOD_mask.c
 	intern/MOD_meshdeform.c
 	intern/MOD_mirror.c

Modified: branches/soc-2012-sushi/source/blender/modifiers/MOD_modifiertypes.h
===================================================================
--- branches/soc-2012-sushi/source/blender/modifiers/MOD_modifiertypes.h	2012-06-12 22:05:33 UTC (rev 47808)
+++ branches/soc-2012-sushi/source/blender/modifiers/MOD_modifiertypes.h	2012-06-12 22:14:55 UTC (rev 47809)
@@ -74,6 +74,7 @@
 extern ModifierTypeInfo modifierType_WeightVGProximity;
 extern ModifierTypeInfo modifierType_DynamicPaint;
 extern ModifierTypeInfo modifierType_Remesh;
+extern ModifierTypeInfo modifierType_LaplacianSmooth;
 
 /* MOD_util.c */
 void modifier_type_init(ModifierTypeInfo *types[]);

Added: branches/soc-2012-sushi/source/blender/modifiers/intern/MOD_laplaciansmooth.c
===================================================================
--- branches/soc-2012-sushi/source/blender/modifiers/intern/MOD_laplaciansmooth.c	                        (rev 0)
+++ branches/soc-2012-sushi/source/blender/modifiers/intern/MOD_laplaciansmooth.c	2012-06-12 22:14:55 UTC (rev 47809)
@@ -0,0 +1,266 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * Contributor(s): Daniel Dunbar
+ *                 Ton Roosendaal,
+ *                 Ben Batt,
+ *                 Brecht Van Lommel,
+ *                 Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/** \file blender/modifiers/intern/MOD_smooth.c
+ *  \ingroup modifiers
+ */
+
+
+#include "DNA_meshdata_types.h"
+
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_cdderivedmesh.h"
+#include "BKE_particle.h"
+#include "BKE_deform.h"
+
+#include "MOD_modifiertypes.h"
+#include "MOD_util.h"
+
+
+static void initData(ModifierData *md)
+{
+	LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *) md;
+
+	smd->fac = 0.5f;
+	smd->repeat = 1;
+	smd->flag = MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z;
+	smd->defgrp_name[0] = '\0';
+}
+
+static void copyData(ModifierData *md, ModifierData *target)
+{
+	LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *) md;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list