[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15358] branches/soc-2008-jaguarandi/ source/blender/blenkernel: Forgot the modifier files on the last commit :S

André Pinto andresusanopinto at gmail.com
Thu Jun 26 02:04:56 CEST 2008


Revision: 15358
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15358
Author:   jaguarandi
Date:     2008-06-26 02:03:59 +0200 (Thu, 26 Jun 2008)

Log Message:
-----------
Forgot the modifier files on the last commit :S

Added Paths:
-----------
    branches/soc-2008-jaguarandi/source/blender/blenkernel/BKE_simple_deform.h
    branches/soc-2008-jaguarandi/source/blender/blenkernel/intern/simple_deform.c

Added: branches/soc-2008-jaguarandi/source/blender/blenkernel/BKE_simple_deform.h
===================================================================
--- branches/soc-2008-jaguarandi/source/blender/blenkernel/BKE_simple_deform.h	                        (rev 0)
+++ branches/soc-2008-jaguarandi/source/blender/blenkernel/BKE_simple_deform.h	2008-06-26 00:03:59 UTC (rev 15358)
@@ -0,0 +1,40 @@
+/**
+ * BKE_shrinkwrap.h
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef BKE_SIMPLE_DEFORM_H
+#define BKE_SIMPLE_DEFORM_H
+
+struct Object;
+struct DerivedMesh;
+struct SimpleDeformModifierData;
+
+/* struct DerivedMesh *simpledeformModifier_do(struct SimpleDeformModifierData *smd, struct Object *ob, struct DerivedMesh *dm, int useRenderParams, int isFinalCalc); */
+void SimpleDeformModifier_do(SimpleDeformModifierData *smd, float (*vertexCos)[3], int numVerts);
+
+#endif
+

Added: branches/soc-2008-jaguarandi/source/blender/blenkernel/intern/simple_deform.c
===================================================================
--- branches/soc-2008-jaguarandi/source/blender/blenkernel/intern/simple_deform.c	                        (rev 0)
+++ branches/soc-2008-jaguarandi/source/blender/blenkernel/intern/simple_deform.c	2008-06-26 00:03:59 UTC (rev 15358)
@@ -0,0 +1,118 @@
+/**
+ * deform_simple.c
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): André Pinto
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#include "DNA_object_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BKE_simple_deform.h"
+#include "BKE_DerivedMesh.h"
+#include "BLI_arithb.h"
+
+#include <string.h>
+#include <math.h>
+
+
+static void simpleDeform_tapper(const float factor, float *co)
+{
+	float x = co[0], y = co[1], z = co[2];
+
+	co[0] = x*(1.0f + z*factor);
+	co[1] = y;
+	co[2] = z;
+}
+
+
+static void simpleDeform_twist(const float factor, float *co)
+{
+	float x = co[0], y = co[1], z = co[2];
+
+	float theta = z*factor;
+	float sint = sin(theta);
+	float cost = cos(theta);
+
+	co[0] = x*cost - y*sint;
+	co[1] = x*sint + y*cost;
+	co[2] = z;
+}
+
+static void simpleDeform_bend(const float factor, float *co)
+{
+	float x = co[0], y = co[1], z = co[2];
+
+	float x0 = 0.0f;
+	float theta = (x - x0)*factor;
+	float sint = sin(theta);
+	float cost = cos(theta);
+
+	co[0] = -sint*(y-1.0f/factor) + x0;
+	co[1] =  cost*(y-1.0f/factor) + 1.0f/factor;
+	co[2] =  z;
+}
+
+static void simpleDeform_shear(const float factor, float *co)
+{
+	float x = co[0], y = co[1], z = co[2];
+
+	co[0] = x + factor;
+	co[1] = y;
+	co[2] = z;
+}
+
+/* simple deform modifier */
+void SimpleDeformModifier_do(SimpleDeformModifierData *smd, float (*vertexCos)[3], int numVerts)
+{
+	float (*ob2mod)[4] = NULL, (*mod2ob)[4] = NULL;
+	if(smd->origin)
+	{
+		Mat4Invert(smd->origin->imat, smd->origin->obmat);	//inverse is outdated
+
+		ob2mod = smd->origin->imat;
+		mod2ob = smd->origin->obmat;
+	}
+
+
+	for(; numVerts; numVerts--, vertexCos++)
+	{
+		if(ob2mod)
+			Mat4MulVecfl(ob2mod, *vertexCos);
+
+		switch(smd->mode)
+		{
+			case 0: simpleDeform_tapper	(smd->factor[0], *vertexCos); break;
+			case 1: simpleDeform_twist	(smd->factor[0], *vertexCos); break;
+			case 2: simpleDeform_bend	(smd->factor[0], *vertexCos); break;
+			case 3: simpleDeform_shear	(smd->factor[0], *vertexCos); break;
+		}
+
+		if(mod2ob)
+			Mat4MulVecfl(mod2ob, *vertexCos);
+	}
+}
+
+





More information about the Bf-blender-cvs mailing list