All pastes #923569 Raw Edit

Anonymous

public text v1 · immutable
#923569 ·published 2008-02-29 17:43 UTC
rendered paste body
Index: source/blender/python/api2_2x/Modifier.c
===================================================================
--- source/blender/python/api2_2x/Modifier.c	(revision 13915)
+++ source/blender/python/api2_2x/Modifier.c	(working copy)
@@ -1,5 +1,5 @@
 /*
- * $Id: Modifier.c 12840 2007-12-11 01:58:22Z khughes $
+ * $Id$
  *
  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
  *
@@ -43,6 +43,7 @@
 #include "BKE_library.h"
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
+#include "BDR_editobject.h"
 #include "MEM_guardedalloc.h"
 #include "butspace.h"
 #include "blendef.h"
@@ -155,6 +156,7 @@
 static int Modifier_setName( BPy_Modifier * self, PyObject *arg );
 static PyObject *Modifier_getType( BPy_Modifier * self );
 static PyObject *Modifier_reset( BPy_Modifier * self );
+static PyObject *Modifier_hook( BPy_Modifier * self );
 
 static PyObject *Modifier_getData( BPy_Modifier * self, PyObject * key );
 static int Modifier_setData( BPy_Modifier * self, PyObject * key, 
@@ -167,6 +169,8 @@
 	/* name, method, flags, doc */
 	{"reset", (PyCFunction)Modifier_reset, METH_NOARGS,
 		"resets a hook modifier location"},
+	{"empty", (PyCFunction)Modifier_hook, METH_NOARGS,
+		"ZanQdo hook!!"},
 	{NULL, NULL, 0, NULL}
 };
 
@@ -1132,6 +1136,12 @@
 	Py_RETURN_NONE;
 }
 
+static PyObject *Modifier_hook( BPy_Modifier * self )
+{
+	add_hook_zanqdo();
+	Py_RETURN_NONE;
+}
+
 /*****************************************************************************/
 /* Function:    Modifier_repr                                                */
 /* Description: This is a callback function for the BPy_Modifier type. It    */
Index: source/blender/include/BDR_editobject.h
===================================================================
--- source/blender/include/BDR_editobject.h	(revision 13915)
+++ source/blender/include/BDR_editobject.h	(working copy)
@@ -121,6 +121,7 @@
 
 
 void add_hook(void);
+void add_hook_zanqdo(void);
 void hook_select(struct HookModifierData *hmd);
 int hook_getIndexArray(int *tot, int **indexar, char *name, float *cent_r);
 
Index: source/blender/src/editobject.c
===================================================================
--- source/blender/src/editobject.c	(revision 13915)
+++ source/blender/src/editobject.c	(working copy)
@@ -632,6 +632,62 @@
 	}
 }
 
+void add_hook_zanqdo(void)
+{
+	HookModifierData *hmd= NULL;
+	ModifierData *md= NULL;
+	Object *ob= NULL;
+	float cent[3];
+	int tot, ok, *indexar;
+	char name[32];
+	Base *base, *newbase;
+
+	ok= hook_getIndexArray(&tot, &indexar, name, cent);
+	if (ok==0) {
+		error("Requires selected vertices or active Vertex Group");
+		return;
+	}
+
+	base= BASACT;
+	ob= add_object(OB_EMPTY);
+	/* set layers ok */
+	newbase= BASACT;
+	newbase->lay= base->lay;
+	ob->lay= newbase->lay;
+
+	/* transform cent to global coords for loc */
+	VecMat4MulVecfl(ob->loc, G.obedit->obmat, cent);
+
+	/* restore, add_object sets active */
+	BASACT= base;
+
+	md= G.obedit->modifiers.first;
+	while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) {
+		md= md->next;
+	}
+
+	hmd= (HookModifierData *) modifier_new(eModifierType_Hook);
+	BLI_insertlinkbefore(&G.obedit->modifiers, md, hmd);
+	sprintf(hmd->modifier.name, "Hook-%s", ob->id.name+2);
+
+	hmd->object= ob;
+	hmd->indexar= indexar;
+	VECCOPY(hmd->cent, cent);
+	hmd->totindex= tot;
+	BLI_strncpy(hmd->name, name, 32);
+
+	where_is_object(ob);
+	Mat4Invert(ob->imat, ob->obmat);
+
+	/* apparently this call goes from right to left... */
+	Mat4MulSerie(hmd->parentinv, ob->imat, G.obedit->obmat, NULL, NULL, NULL, NULL, NULL, NULL);
+
+	allqueue(REDRAWVIEW3D, 0);
+	allqueue(REDRAWBUTSOBJECT, 0);
+	DAG_scene_sort(G.scene);
+	BIF_undo_push("Add hook");
+}
+
 void add_hook(void)
 {
 	ModifierData *md = NULL;