Page Menu
Home
Search
Configure Global Search
Log In
Files
F2450
setIK_Patch_A.diff
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Kenney Phillis Jr. (dandel1984)
Nov 13 2013, 1:04 PM
Size
10 KB
Subscribers
None
setIK_Patch_A.diff
View Options
Index: source/blender/python/api2_2x/Bone.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Bone.c,v
retrieving revision 1.27
diff -u -r1.27 Bone.c
--- source/blender/python/api2_2x/Bone.c 22 May 2005 17:40:00 -0000 1.27
+++ source/blender/python/api2_2x/Bone.c 16 Jun 2005 15:26:19 -0000
@@ -1,4 +1,4 @@
-/*
+/*
* $Id: Bone.c,v 1.27 2005/05/22 17:40:00 stiv Exp $
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
@@ -46,6 +46,7 @@
#include <BSE_editaction.h>
#include <BKE_constraint.h>
#include <MEM_guardedalloc.h>
+#include <mydevice.h>
#include "constant.h"
#include "gen_utils.h"
#include "NLA.h"
@@ -87,6 +88,7 @@
static PyObject *Bone_clearChildren( BPy_Bone * self );
static PyObject *Bone_hide( BPy_Bone * self );
static PyObject *Bone_unhide( BPy_Bone * self );
+static PyObject *Bone_setIK( BPy_Bone * self, PyObject * args ); // Quick hack to set the bone ik via declaration.
static PyObject *Bone_setName( BPy_Bone * self, PyObject * args );
static PyObject *Bone_setRoll( BPy_Bone * self, PyObject * args );
static PyObject *Bone_setHead( BPy_Bone * self, PyObject * args );
@@ -140,6 +142,8 @@
"() - remove the children associated with this bone"},
{"setName", ( PyCFunction ) Bone_setName, METH_VARARGS,
"(str) - rename Bone"},
+ {"setIK", ( PyCFunction ) Bone_setIK, METH_VARARGS,
+ "() - set the Bone IKToParent flag."},
{"setRoll", ( PyCFunction ) Bone_setRoll, METH_VARARGS,
"(float) - set Bone roll"},
{"setHead", ( PyCFunction ) Bone_setHead, METH_VARARGS,
@@ -174,7 +178,7 @@
//--------------- Python TypeBone structure definition-------------
PyTypeObject Bone_Type = {
- PyObject_HEAD_INIT( NULL )
+ PyObject_HEAD_INIT( NULL )
0, /* ob_size */
"Blender Bone", /* tp_name */
sizeof( BPy_Bone ), /* tp_basicsize */
@@ -1666,6 +1670,35 @@
"couldn't get Bone.Boneclass attribute" ) );
}
+
+//--------------- BPy_Bone.setIK()-------------------------------
+static PyObject *Bone_setIK( BPy_Bone * self, PyObject * args )
+{
+ // here is all the code to make the ik setting system... i hope.
+ int toggle;
+ char *parent_str = "";
+
+ if( !self->bone ) { //test to see if linked to armature
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "link bone to armature before attempting to set IK." ); }
+ else {
+ if( !PyArg_ParseTuple( args, "i", &toggle ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected 1 or 0 as integer" ) );
+ if( BLI_streq( self->parent, parent_str ) ) {
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "set bone to have a parent before attempting to set IK." );
+ }
+ // the positioning of the head for the bone bein changed is off... somewhere around here it need to be fixed.
+ if( toggle ){
+ VECCOPY (self->bone->head,self->bone->parent->tail); // this line is required to set hte head location of a bone.
+ self->bone->flag |= BONE_IK_TOPARENT;}
+ else
+ self->bone->flag &= ~BONE_IK_TOPARENT;
+ }
+ return EXPP_incr_ret( Py_None ); // call update.
+ }
+
//--------------- BPy_Bone.getRestMatrix()-------------------------
static PyObject *Bone_getRestMatrix( BPy_Bone * self, PyObject * args )
{
@@ -1721,3 +1754,4 @@
return matrix;
}
+
Index: source/blender/src/drawnla.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/drawnla.c,v
retrieving revision 1.18
diff -u -r1.18 drawnla.c
--- source/blender/src/drawnla.c 31 Mar 2005 18:49:52 -0000 1.18
+++ source/blender/src/drawnla.c 15 Jun 2005 23:49:25 -0000
@@ -147,7 +147,7 @@
}
/* Draw the action timeline */
- if (ACTIVE_ARMATURE(base)){
+ if (ACTIVE_ARMATURE(base) || ACTIVE_EMPTY(base)){
glRasterPos2f(x, y-8);
BIF_draw_icon(ICON_DOWNARROW_HLT);
y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
@@ -167,7 +167,7 @@
y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
/* Draw the nla strips */
- if (base->object->type==OB_ARMATURE){
+ if (base->object->type == OB_ARMATURE || base->object->type == OB_EMPTY){
for (strip = base->object->nlastrips.first; strip; strip=strip->next){
BIF_ThemeColorShade(TH_HEADER, -50);
glRectf(x+32, y-NLACHANNELHEIGHT/2, (float)NLAWIDTH, y+NLACHANNELHEIGHT/2);
@@ -277,7 +277,7 @@
/* Draw the action strip */
- if (ACTIVE_ARMATURE(base)){
+ if (ACTIVE_ARMATURE(base) || ACTIVE_EMPTY(base)){
/* Draw the field */
glEnable (GL_BLEND);
@@ -305,7 +305,7 @@
}
/* Draw the nla strips */
- if (ob->type==OB_ARMATURE){
+ if (base->object->type == OB_ARMATURE || base->object->type == OB_EMPTY){
for (strip=ob->nlastrips.first; strip; strip=strip->next){
int stripstart, stripend;
int blendstart, blendend;
@@ -415,7 +415,7 @@
bActionStrip *strip;
for (base=G.scene->base.first; base; base=base->next){
- if (nla_filter(base, 0) && base->object->type==OB_ARMATURE){
+ if (nla_filter(base, 0) && (base->object->type==OB_ARMATURE || base->object->type==OB_EMPTY)){
for (strip=base->object->nlastrips.first; strip; strip=strip->next){
if (strip->flag & ACTSTRIP_SELECT)
return strip;
@@ -607,7 +607,7 @@
/* Constraint channels */
y+=BLI_countlist(&base->object->constraintChannels);
- if (base->object->type==OB_ARMATURE){
+ if (base->object->type == OB_ARMATURE || base->object->type == OB_EMPTY){
/* Action */
if(base->object->action){
// bActionChannel *achan;
@@ -638,7 +638,7 @@
return 1;
/* Only armatures */
- if (ob->type==OB_ARMATURE)
+ if (base->object->type == OB_ARMATURE || base->object->type == OB_EMPTY)
return 1;
else return 0;
Index: source/blender/src/editarmature.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editarmature.c,v
retrieving revision 1.50
diff -u -r1.50 editarmature.c
--- source/blender/src/editarmature.c 10 May 2005 04:21:11 -0000 1.50
+++ source/blender/src/editarmature.c 16 Jun 2005 15:16:58 -0000
@@ -1747,7 +1747,7 @@
void attach_bone_to_parent_cb(void *bonev, void *arg2_unused)
{
EditBone *curBone= bonev;
- attach_bone_to_parent(curBone);
+ attach_bone_to_parent(curBone); // this is the line that does the bones pannel on the armature settings.
}
void attach_bone_to_parent(EditBone *bone)
@@ -1756,22 +1756,24 @@
if (bone->flag & BONE_IK_TOPARENT) {
- /* See if there are any other bones that refer to the same
- * parent and disconnect them
+ /* See if there are any other bones that refer to the same
+ * parent and disconnect them
*/
- for (curbone = G.edbo.first; curbone; curbone=curbone->next){
+ // this next if statement is useless, when what you want
+ // is to allow for the multiple attachment to a single parent.
+ /*for (curbone = G.edbo.first; curbone; curbone=curbone->next){
if (curbone!=bone){
- if (curbone->parent &&
- (curbone->parent == bone->parent) &&
+ if (curbone->parent &&
+ (curbone->parent == bone->parent) &&
(curbone->flag & BONE_IK_TOPARENT))
curbone->flag &= ~BONE_IK_TOPARENT;
}
}
-
+ */
/* Attach this bone to its parent */
VECCOPY(bone->head, bone->parent->tail);
+ }
}
-}
void deselectall_armature(void)
/* Actually, it toggles selection, deselecting
@@ -1948,61 +1950,57 @@
void extrude_armature(void)
{
EditBone *newbone, *curbone, *first=NULL, *partest;
-
+ short nr;
+
TEST_EDITARMATURE;
-
-
+
+
if(okee("Extrude bone segments")==0) return;
-
+
/* Duplicate the necessary bones */
for (curbone = G.edbo.first; ((curbone) && (curbone!=first)); curbone=curbone->next){
if (curbone->flag & (BONE_TIPSEL|BONE_SELECTED)){
- newbone = MEM_callocN(sizeof(EditBone), "extrudebone");
-
-
- VECCOPY (newbone->head, curbone->tail);
- VECCOPY (newbone->tail, newbone->head);
- newbone->parent = curbone;
- newbone->flag = BONE_TIPSEL;
- newbone->flag |= BONE_QUATROT;
- newbone->weight= curbone->weight;
- newbone->dist= curbone->dist;
- newbone->boneclass= curbone->boneclass;
-
- Mat4One(newbone->obmat);
-
- /* See if there are any ik children of the parent */
- for (partest = G.edbo.first; partest; partest=partest->next){
- if ((partest->parent == curbone) && (partest->flag & BONE_IK_TOPARENT))
- break;
+ nr = pupmenu("Extrude %t||Link to Parent %x1||Unliked to Parent %x2");
+ if (nr == 1 || nr == 2)
+ {
+ newbone = MEM_callocN(sizeof(EditBone), "extrudebone");
+
+ VECCOPY (newbone->head, curbone->tail);
+ VECCOPY (newbone->tail, newbone->head);
+ newbone->parent = curbone;
+ newbone->flag = BONE_TIPSEL;
+ newbone->flag |= BONE_QUATROT;
+ newbone->weight= curbone->weight;
+ newbone->dist= curbone->dist;
+ newbone->boneclass= curbone->boneclass;
+
+ Mat4One(newbone->obmat);
+
+
+ if (nr == 1)
+ newbone->flag |= BONE_IK_TOPARENT;
+
+ strcpy (newbone->name, curbone->name);
+ unique_editbone_name(newbone->name);
+
+ /* Add the new bone to the list */
+ BLI_addtail(&G.edbo, newbone);
+ if (!first)
+ first = newbone;
+ /* Deselect the old bone */
+ curbone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
+ /* Transform the endpoints */
+ countall();
+ BIF_TransformSetUndo("Extrude");
+ initTransform(TFM_TRANSLATION, CTX_NO_PET);
+ Transform();
+ allqueue(REDRAWBUTSEDIT, 0);
+ allqueue(REDRAWBUTSOBJECT, 0);
+ allqueue(REDRAWOOPS, 0);
}
-
- if (!partest)
- newbone->flag |= BONE_IK_TOPARENT;
-
- strcpy (newbone->name, curbone->name);
- unique_editbone_name(newbone->name);
-
- /* Add the new bone to the list */
- BLI_addtail(&G.edbo, newbone);
- if (!first)
- first = newbone;
}
-
- /* Deselect the old bone */
- curbone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
-
}
-
- /* Transform the endpoints */
- countall();
- BIF_TransformSetUndo("Extrude");
- initTransform(TFM_TRANSLATION, CTX_NO_PET);
- Transform();
- allqueue(REDRAWBUTSEDIT, 0);
- allqueue(REDRAWBUTSOBJECT, 0);
- allqueue(REDRAWOOPS, 0);
-}
+ }
void addvert_armature(void)
{
@@ -2521,7 +2519,7 @@
* bDeformGroup pointer -- the
* bDeformGroup pointer is set to point
* to the deform group with the bone's
- * name, and the pointer the handle
+ * name, and the pointer the handle
* points to is incremented to point to the
* next member of an array of pointers
* to bDeformGroups. This way we can loop using
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9d/51/857acb7f7fb85d71fce068a3700f
Event Timeline
Log In to Comment