2003-05-29 04:00:35 +00:00
|
|
|
/*
|
2004-09-18 18:47:03 +00:00
|
|
|
* $Id$
|
2003-05-29 04:00:35 +00:00
|
|
|
*
|
|
|
|
|
* ***** BEGIN GPL/BL DUAL 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. The Blender
|
|
|
|
|
* Foundation also sells licenses for use in proprietary software under
|
|
|
|
|
* the Blender License. See http://www.blender.org/BL/ for information
|
|
|
|
|
* about this.
|
|
|
|
|
*
|
|
|
|
|
* 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) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* This is a new part of Blender.
|
|
|
|
|
*
|
2004-04-14 23:42:58 +00:00
|
|
|
* Contributor(s): Jordi Rovira i Bonet, Joseph Gilbert
|
2003-05-29 04:00:35 +00:00
|
|
|
*
|
|
|
|
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "Armature.h"
|
|
|
|
|
#include "Bone.h"
|
2004-04-19 06:57:41 +00:00
|
|
|
#include "NLA.h"
|
2004-03-31 07:40:08 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <BKE_main.h>
|
|
|
|
|
#include <BKE_global.h>
|
|
|
|
|
#include <BKE_object.h>
|
|
|
|
|
#include <BKE_armature.h>
|
|
|
|
|
#include <BKE_library.h>
|
|
|
|
|
#include <BLI_blenlib.h>
|
2004-05-11 08:26:44 +00:00
|
|
|
#include <MEM_guardedalloc.h>
|
2004-04-04 08:34:43 +00:00
|
|
|
#include <BLI_arithb.h>
|
2004-03-31 07:40:08 +00:00
|
|
|
#include "constant.h"
|
|
|
|
|
#include "gen_utils.h"
|
2004-04-04 08:34:43 +00:00
|
|
|
#include "Types.h"
|
2004-03-31 07:40:08 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
//---------------- Python API function prototypes for the Armature module---
|
|
|
|
|
static PyObject *M_Armature_New( PyObject * self, PyObject * args );
|
|
|
|
|
static PyObject *M_Armature_Get( PyObject * self, PyObject * args );
|
|
|
|
|
|
|
|
|
|
//------------- Python API Doc Strings for the Armature module-----------
|
2004-04-19 06:57:41 +00:00
|
|
|
static char M_Armature_doc[] = "The Blender Armature module\n\n\
|
2004-05-11 08:26:44 +00:00
|
|
|
This module provides control over **Armature Data** objects in Blender.\n";
|
2004-09-25 20:30:40 +00:00
|
|
|
static char M_Armature_New_doc[] =
|
|
|
|
|
"(name) - return a new Armature datablock of \n\
|
2004-05-11 08:26:44 +00:00
|
|
|
optional name 'name'.";
|
2004-04-19 06:57:41 +00:00
|
|
|
static char M_Armature_Get_doc[] =
|
2004-09-25 20:30:40 +00:00
|
|
|
"(name) - return the armature with the name 'name', \
|
2004-05-11 08:26:44 +00:00
|
|
|
returns None if not found.\n If 'name' is not specified, it returns a list of all armatures in the\ncurrent scene.";
|
2004-04-19 06:57:41 +00:00
|
|
|
static char M_Armature_get_doc[] = "(name) - DEPRECATED. Use 'Get' instead. \
|
2004-05-11 08:26:44 +00:00
|
|
|
return the armature with the name 'name', returns None if not found.\n If 'name' is not specified, \
|
|
|
|
|
it returns a list of all armatures in the\ncurrent scene.";
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//------Python method structure definition for Blender.Armature module-----
|
2004-03-31 07:40:08 +00:00
|
|
|
struct PyMethodDef M_Armature_methods[] = {
|
2004-09-25 20:30:40 +00:00
|
|
|
{"New", ( PyCFunction ) M_Armature_New, METH_VARARGS,
|
|
|
|
|
M_Armature_New_doc},
|
|
|
|
|
{"Get", M_Armature_Get, METH_VARARGS, M_Armature_Get_doc},
|
|
|
|
|
{"get", M_Armature_Get, METH_VARARGS, M_Armature_get_doc},
|
|
|
|
|
{NULL, NULL, 0, NULL}
|
2004-03-31 07:40:08 +00:00
|
|
|
};
|
2004-09-25 20:30:40 +00:00
|
|
|
//--------Python BPy_Armature methods declarations----------------------------
|
|
|
|
|
static PyObject *Armature_getName( BPy_Armature * self );
|
|
|
|
|
static PyObject *Armature_getBones( BPy_Armature * self );
|
|
|
|
|
static PyObject *Armature_addBone( BPy_Armature * self, PyObject * args );
|
|
|
|
|
static PyObject *Armature_setName( BPy_Armature * self, PyObject * args );
|
|
|
|
|
static PyObject *Armature_drawAxes( BPy_Armature * self, PyObject * args );
|
|
|
|
|
static PyObject *Armature_drawNames( BPy_Armature * self, PyObject * args );
|
|
|
|
|
//----------------Python BPy_Armature methods table---------------------------
|
2004-03-31 07:40:08 +00:00
|
|
|
static PyMethodDef BPy_Armature_methods[] = {
|
2004-09-25 20:30:40 +00:00
|
|
|
{"getName", ( PyCFunction ) Armature_getName, METH_NOARGS,
|
|
|
|
|
"() - return Armature name"},
|
|
|
|
|
{"getBones", ( PyCFunction ) Armature_getBones, METH_NOARGS,
|
|
|
|
|
"() - return Armature root bones"},
|
|
|
|
|
{"setName", ( PyCFunction ) Armature_setName, METH_VARARGS,
|
|
|
|
|
"(str) - rename Armature"},
|
|
|
|
|
{"addBone", ( PyCFunction ) Armature_addBone, METH_VARARGS,
|
|
|
|
|
"(bone)-add bone"},
|
|
|
|
|
{"drawAxes", ( PyCFunction ) Armature_drawAxes, METH_VARARGS,
|
|
|
|
|
"will draw the axis of each bone in armature"},
|
|
|
|
|
{"drawNames", ( PyCFunction ) Armature_drawNames, METH_VARARGS,
|
|
|
|
|
"will draw the names of each bone in armature"},
|
|
|
|
|
{NULL, NULL, 0, NULL}
|
2004-03-31 07:40:08 +00:00
|
|
|
};
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//----------------Python TypeArmature callback function prototypes-----------
|
|
|
|
|
static void Armature_dealloc( BPy_Armature * armature );
|
|
|
|
|
static PyObject *Armature_getAttr( BPy_Armature * armature, char *name );
|
|
|
|
|
static int Armature_setAttr( BPy_Armature * armature, char *name,
|
|
|
|
|
PyObject * v );
|
|
|
|
|
static int Armature_compare( BPy_Armature * a1, BPy_Armature * a2 );
|
|
|
|
|
static PyObject *Armature_repr( BPy_Armature * armature );
|
|
|
|
|
static int doesBoneName_exist( char *name, bArmature * arm );
|
|
|
|
|
|
|
|
|
|
//---------------- Python TypeArmature structure definition:-----------
|
2004-03-31 07:40:08 +00:00
|
|
|
PyTypeObject Armature_Type = {
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject_HEAD_INIT( NULL )
|
|
|
|
|
0, /* ob_size */
|
|
|
|
|
"Blender Armature", /* tp_name */
|
|
|
|
|
sizeof( BPy_Armature ), /* tp_basicsize */
|
|
|
|
|
0, /* tp_itemsize */
|
|
|
|
|
/* methods */
|
|
|
|
|
( destructor ) Armature_dealloc, /* tp_dealloc */
|
|
|
|
|
0, /* tp_print */
|
|
|
|
|
( getattrfunc ) Armature_getAttr, /* tp_getattr */
|
|
|
|
|
( setattrfunc ) Armature_setAttr, /* tp_setattr */
|
|
|
|
|
( cmpfunc ) Armature_compare, /* tp_compare */
|
|
|
|
|
( reprfunc ) Armature_repr, /* tp_repr */
|
|
|
|
|
0, /* tp_as_number */
|
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
|
0, /* tp_as_hash */
|
|
|
|
|
0, 0, 0, 0, 0, 0,
|
|
|
|
|
0, /* tp_doc */
|
|
|
|
|
0, 0, 0, 0, 0, 0,
|
|
|
|
|
BPy_Armature_methods, /* tp_methods */
|
|
|
|
|
0, /* tp_members */
|
2004-03-31 07:40:08 +00:00
|
|
|
};
|
2004-09-25 20:30:40 +00:00
|
|
|
//-------------------Blender Armature Module Init-----------------
|
|
|
|
|
PyObject *Armature_Init( void )
|
2003-05-29 04:00:35 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject *submodule;
|
|
|
|
|
PyObject *dict;
|
2003-05-29 04:00:35 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Armature_Type.ob_type = &PyType_Type;
|
2003-06-02 20:15:50 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
submodule = Py_InitModule3( "Blender.Armature",
|
|
|
|
|
M_Armature_methods, M_Armature_doc );
|
2003-05-29 04:00:35 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
/* Add the Bone submodule to this module */
|
|
|
|
|
dict = PyModule_GetDict( submodule );
|
|
|
|
|
PyDict_SetItemString( dict, "Bone", Bone_Init( ) );
|
|
|
|
|
PyDict_SetItemString( dict, "NLA", NLA_Init( ) );
|
2003-05-29 04:00:35 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( submodule );
|
2003-05-29 04:00:35 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//----------------------Blender Armature Module internal callbacks----
|
|
|
|
|
|
|
|
|
|
//------------------append_childrenToList-----------------------------------
|
|
|
|
|
static void append_childrenToList( Bone * parent, PyObject * listbones )
|
2004-04-05 04:17:01 +00:00
|
|
|
{
|
|
|
|
|
Bone *child = NULL;
|
|
|
|
|
|
|
|
|
|
//append children
|
2004-09-25 20:30:40 +00:00
|
|
|
for( child = parent->childbase.first; child; child = child->next ) {
|
|
|
|
|
PyList_Append( listbones, Bone_CreatePyObject( child ) );
|
|
|
|
|
if( child->childbase.first ) { //has children?
|
|
|
|
|
append_childrenToList( child, listbones );
|
2004-04-05 04:17:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-05-29 04:00:35 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//------------------unique_BoneName----------------------------
|
|
|
|
|
static void unique_BoneName( char *name, bArmature * arm )
|
2004-04-04 08:34:43 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
char tempname[64];
|
|
|
|
|
int number;
|
|
|
|
|
char *dot;
|
|
|
|
|
|
|
|
|
|
if( doesBoneName_exist( name, arm ) ) {
|
|
|
|
|
/* Strip off the suffix */
|
|
|
|
|
dot = strchr( name, '.' );
|
|
|
|
|
if( dot )
|
|
|
|
|
*dot = 0;
|
|
|
|
|
|
|
|
|
|
for( number = 1; number <= 999; number++ ) {
|
|
|
|
|
sprintf( tempname, "%s.%03d", name, number );
|
|
|
|
|
if( !doesBoneName_exist( tempname, arm ) ) {
|
|
|
|
|
strcpy( name, tempname );
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-04-04 08:34:43 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//------------------doesBoneName_exist----------------------------
|
|
|
|
|
static int doesBoneName_exist( char *name, bArmature * arm )
|
2004-04-04 08:34:43 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
Bone *parent = NULL;
|
|
|
|
|
Bone *child = NULL;
|
|
|
|
|
|
|
|
|
|
for( parent = arm->bonebase.first; parent; parent = parent->next ) {
|
|
|
|
|
if( !strcmp( name, parent->name ) )
|
|
|
|
|
return 1;
|
|
|
|
|
for( child = parent->childbase.first; child;
|
|
|
|
|
child = child->next ) {
|
|
|
|
|
if( !strcmp( name, child->name ) )
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2004-04-04 08:34:43 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
return 0;
|
2004-04-04 08:34:43 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//------------------testChildInChildbase--------------------------
|
|
|
|
|
static int testChildInChildbase( Bone * bone, Bone * test )
|
2004-04-19 06:57:41 +00:00
|
|
|
{
|
|
|
|
|
Bone *child;
|
2004-09-25 20:30:40 +00:00
|
|
|
for( child = bone->childbase.first; child; child = child->next ) {
|
|
|
|
|
if( child == test ) {
|
2004-04-19 06:57:41 +00:00
|
|
|
return 1;
|
2004-09-25 20:30:40 +00:00
|
|
|
} else {
|
|
|
|
|
if( child->childbase.first != NULL ) {
|
|
|
|
|
if( testChildInChildbase( child, test ) ) {
|
2004-04-19 06:57:41 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//------------------testBoneInArmature-----------------------------
|
|
|
|
|
static int testBoneInArmature( bArmature * arm, Bone * test )
|
2004-04-14 23:42:58 +00:00
|
|
|
{
|
|
|
|
|
Bone *root;
|
2004-09-25 20:30:40 +00:00
|
|
|
for( root = arm->bonebase.first; root; root = root->next ) {
|
|
|
|
|
if( root == test ) {
|
2004-04-14 23:42:58 +00:00
|
|
|
return 1;
|
2004-09-25 20:30:40 +00:00
|
|
|
} else {
|
|
|
|
|
if( root->childbase.first != NULL ) {
|
|
|
|
|
if( testChildInChildbase( root, test ) ) {
|
2004-04-19 06:57:41 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-04-14 23:42:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------testChildNameInChildbase--------------------------
|
|
|
|
|
static Bone *testChildNameInChildbase( Bone * bone, char *name )
|
2004-04-04 08:34:43 +00:00
|
|
|
{
|
2004-05-11 08:26:44 +00:00
|
|
|
Bone *child;
|
|
|
|
|
Bone *test;
|
2004-09-25 20:30:40 +00:00
|
|
|
for( child = bone->childbase.first; child; child = child->next ) {
|
|
|
|
|
if( BLI_streq( child->name, name ) ) {
|
2004-05-11 08:26:44 +00:00
|
|
|
return child;
|
2004-09-25 20:30:40 +00:00
|
|
|
} else {
|
|
|
|
|
if( child->childbase.first != NULL ) {
|
|
|
|
|
test = testChildNameInChildbase( child, name );
|
|
|
|
|
if( test )
|
|
|
|
|
return test;
|
2004-05-11 08:26:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
2004-04-14 23:42:58 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//----------------testBoneNameInArmature----------------------------
|
|
|
|
|
static Bone *testBoneNameInArmature( bArmature * arm, char *name )
|
2004-04-14 23:42:58 +00:00
|
|
|
{
|
2004-05-11 08:26:44 +00:00
|
|
|
Bone *bone;
|
|
|
|
|
Bone *test;
|
2004-09-25 20:30:40 +00:00
|
|
|
for( bone = arm->bonebase.first; bone; bone = bone->next ) {
|
|
|
|
|
if( BLI_streq( bone->name, name ) ) {
|
|
|
|
|
return bone; //found it
|
|
|
|
|
} else {
|
|
|
|
|
if( bone->childbase.first != NULL ) {
|
|
|
|
|
test = testChildNameInChildbase( bone, name );
|
|
|
|
|
if( test )
|
|
|
|
|
return test;
|
2004-05-11 08:26:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
2004-04-14 23:42:58 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-------------------BPy_Armature internal methods------------------
|
|
|
|
|
|
|
|
|
|
//------------------dealloc-----------------------------------------
|
|
|
|
|
static void Armature_dealloc( BPy_Armature * self )
|
2003-05-29 04:00:35 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject_DEL( self );
|
2003-05-29 04:00:35 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------getattr--------------------------------------------
|
|
|
|
|
static PyObject *Armature_getAttr( BPy_Armature * self, char *name )
|
2003-05-29 04:00:35 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject *attr = Py_None;
|
|
|
|
|
|
|
|
|
|
if( strcmp( name, "name" ) == 0 )
|
|
|
|
|
attr = Armature_getName( self );
|
|
|
|
|
if( strcmp( name, "bones" ) == 0 )
|
|
|
|
|
attr = Armature_getBones( self );
|
|
|
|
|
else if( strcmp( name, "__members__" ) == 0 ) {
|
|
|
|
|
/* 2 entries */
|
|
|
|
|
attr = Py_BuildValue( "[s,s]", "name", "bones" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !attr )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
|
|
|
|
|
"couldn't create PyObject" ) );
|
|
|
|
|
|
|
|
|
|
if( attr != Py_None )
|
|
|
|
|
return attr; /* member attribute found, return it */
|
|
|
|
|
|
|
|
|
|
/* not an attribute, search the methods table */
|
|
|
|
|
return Py_FindMethod( BPy_Armature_methods, ( PyObject * ) self,
|
|
|
|
|
name );
|
2003-05-29 04:00:35 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------setattr--------------------------------------------
|
2004-03-31 07:40:08 +00:00
|
|
|
static int
|
2004-09-25 20:30:40 +00:00
|
|
|
Armature_setAttr( BPy_Armature * self, char *name, PyObject * value )
|
2003-05-29 04:00:35 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject *valtuple;
|
|
|
|
|
PyObject *error = NULL;
|
2003-05-29 04:00:35 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
valtuple = Py_BuildValue( "(O)", value ); /*the set* functions expect a tuple */
|
2003-05-29 04:00:35 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !valtuple )
|
|
|
|
|
return EXPP_ReturnIntError( PyExc_MemoryError,
|
|
|
|
|
"ArmatureSetAttr: couldn't create tuple" );
|
2003-05-29 04:00:35 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( strcmp( name, "name" ) == 0 )
|
|
|
|
|
error = Armature_setName( self, valtuple );
|
|
|
|
|
else { /* Error */
|
|
|
|
|
Py_DECREF( valtuple );
|
2004-03-31 07:40:08 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
/* ... member with the given name was found */
|
|
|
|
|
return ( EXPP_ReturnIntError
|
|
|
|
|
( PyExc_KeyError, "attribute not found" ) );
|
|
|
|
|
}
|
2004-03-31 07:40:08 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_DECREF( valtuple );
|
2004-03-31 07:40:08 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( error != Py_None )
|
|
|
|
|
return -1;
|
2004-03-31 07:40:08 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_DECREF( Py_None ); /* was incref'ed by the called Armature_set* function */
|
|
|
|
|
return 0; /* normal exit */
|
2003-05-29 04:00:35 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------repr-----------------------------------------------
|
|
|
|
|
static PyObject *Armature_repr( BPy_Armature * self )
|
2003-05-29 04:00:35 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
return PyString_FromFormat( "[Armature \"%s\"]",
|
|
|
|
|
self->armature->id.name + 2 );
|
2003-05-29 04:00:35 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------compare--------------------------------------------
|
|
|
|
|
static int Armature_compare( BPy_Armature * a, BPy_Armature * b )
|
2003-05-29 04:00:35 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
bArmature *pa = a->armature, *pb = b->armature;
|
|
|
|
|
return ( pa == pb ) ? 0 : -1;
|
2003-05-29 04:00:35 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------Armature_CreatePyObject----------------------------
|
|
|
|
|
PyObject *Armature_CreatePyObject( struct bArmature * obj )
|
2003-05-29 04:00:35 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
BPy_Armature *blen_armature;
|
2003-05-29 04:00:35 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
blen_armature =
|
|
|
|
|
( BPy_Armature * ) PyObject_NEW( BPy_Armature,
|
|
|
|
|
&Armature_Type );
|
2003-05-29 04:00:35 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( blen_armature == NULL ) {
|
|
|
|
|
return ( NULL );
|
|
|
|
|
}
|
|
|
|
|
blen_armature->armature = obj;
|
2004-04-04 08:34:43 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( ( PyObject * ) blen_armature );
|
2003-05-29 04:00:35 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------Armature_CheckPyObject ----------------------------
|
|
|
|
|
int Armature_CheckPyObject( PyObject * py_obj )
|
2003-05-29 04:00:35 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( py_obj->ob_type == &Armature_Type );
|
2003-05-29 04:00:35 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------Armature_FromPyObject -----------------------------
|
|
|
|
|
struct bArmature *Armature_FromPyObject( PyObject * py_obj )
|
2003-05-29 04:00:35 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
BPy_Armature *blen_obj;
|
2003-05-29 04:00:35 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
blen_obj = ( BPy_Armature * ) py_obj;
|
|
|
|
|
return ( blen_obj->armature );
|
2003-05-29 04:00:35 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//-----------------Blender Module function prototypes-----------------
|
|
|
|
|
|
|
|
|
|
//----------------Blender.Armature.New()------------------------------
|
|
|
|
|
static PyObject *M_Armature_New( PyObject * self, PyObject * args )
|
2004-05-11 08:26:44 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
char *name_str = "ArmatureData";
|
|
|
|
|
BPy_Armature *py_armature; /* for Armature Data object wrapper in Python */
|
|
|
|
|
bArmature *bl_armature; /* for actual Armature Data we create in Blender */
|
|
|
|
|
char buf[21];
|
|
|
|
|
|
|
|
|
|
if( !PyArg_ParseTuple( args, "|s", &name_str ) )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"expected string or empty argument" ) );
|
|
|
|
|
|
|
|
|
|
bl_armature = add_armature( ); /* first create in Blender */
|
|
|
|
|
|
|
|
|
|
if( bl_armature ) {
|
|
|
|
|
/* return user count to zero because add_armature() inc'd it */
|
|
|
|
|
bl_armature->id.us = 0;
|
|
|
|
|
/* now create the wrapper obj in Python */
|
|
|
|
|
py_armature =
|
|
|
|
|
( BPy_Armature * ) PyObject_NEW( BPy_Armature,
|
|
|
|
|
&Armature_Type );
|
|
|
|
|
} else {
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"couldn't create Armature Data in Blender" ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( py_armature == NULL )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
|
|
|
|
|
"couldn't create ArmaturePyObject" ) );
|
|
|
|
|
|
|
|
|
|
/* link Python armature wrapper with Blender Armature: */
|
|
|
|
|
py_armature->armature = bl_armature;
|
|
|
|
|
|
|
|
|
|
if( strcmp( name_str, "ArmatureData" ) == 0 )
|
|
|
|
|
return ( PyObject * ) py_armature;
|
|
|
|
|
else { /* user gave us a name for the armature, use it */
|
|
|
|
|
PyOS_snprintf( buf, sizeof( buf ), "%s", name_str );
|
|
|
|
|
rename_id( &bl_armature->id, buf );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ( PyObject * ) py_armature;
|
2004-05-11 08:26:44 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//----------------Blender.Armature.Get()------------------------------
|
|
|
|
|
static PyObject *M_Armature_Get( PyObject * self, PyObject * args )
|
2004-05-11 08:26:44 +00:00
|
|
|
{
|
|
|
|
|
char *name = NULL;
|
|
|
|
|
bArmature *armature_iter;
|
|
|
|
|
BPy_Armature *wanted_armature;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "|s", &name ) )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected string argument (or nothing)" ) );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
|
|
|
|
armature_iter = G.main->armature.first;
|
|
|
|
|
|
|
|
|
|
/* Use the name to search for the armature requested. */
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( name ) { /* (name) - Search armature by name */
|
2004-05-11 08:26:44 +00:00
|
|
|
wanted_armature = NULL;
|
2004-09-25 20:30:40 +00:00
|
|
|
while( ( armature_iter ) && ( wanted_armature == NULL ) ) {
|
|
|
|
|
if( strcmp( name, armature_iter->id.name + 2 ) == 0 ) {
|
2004-05-11 08:26:44 +00:00
|
|
|
wanted_armature =
|
2004-09-25 20:30:40 +00:00
|
|
|
( BPy_Armature * )
|
|
|
|
|
PyObject_NEW( BPy_Armature,
|
|
|
|
|
&Armature_Type );
|
|
|
|
|
if( wanted_armature )
|
|
|
|
|
wanted_armature->armature =
|
|
|
|
|
armature_iter;
|
2004-05-11 08:26:44 +00:00
|
|
|
}
|
|
|
|
|
armature_iter = armature_iter->id.next;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( wanted_armature == NULL ) { /* Requested Armature doesn't exist */
|
2004-05-11 08:26:44 +00:00
|
|
|
char error_msg[64];
|
2004-09-25 20:30:40 +00:00
|
|
|
PyOS_snprintf( error_msg, sizeof( error_msg ),
|
|
|
|
|
"Armature \"%s\" not found", name );
|
|
|
|
|
return ( EXPP_ReturnPyObjError
|
|
|
|
|
( PyExc_NameError, error_msg ) );
|
2004-05-11 08:26:44 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( PyObject * ) wanted_armature;
|
|
|
|
|
} else {
|
2004-05-11 08:26:44 +00:00
|
|
|
/* Return a list of with armatures in the scene */
|
|
|
|
|
int index = 0;
|
|
|
|
|
PyObject *armlist, *pyobj;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
armlist = PyList_New( BLI_countlist( &( G.main->armature ) ) );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( armlist == NULL )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
|
|
|
|
|
"couldn't create PyList" ) );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
while( armature_iter ) {
|
|
|
|
|
pyobj = Armature_CreatePyObject( armature_iter );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !pyobj )
|
|
|
|
|
return ( EXPP_ReturnPyObjError
|
|
|
|
|
( PyExc_MemoryError,
|
|
|
|
|
"couldn't create PyString" ) );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
PyList_SET_ITEM( armlist, index, pyobj );
|
2004-05-11 08:26:44 +00:00
|
|
|
armature_iter = armature_iter->id.next;
|
|
|
|
|
index++;
|
|
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( armlist );
|
2004-05-11 08:26:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//--------------------------Python BPy_Armature methods---------------
|
|
|
|
|
|
|
|
|
|
//---------------------BPy_Armature.getName()-------------------------
|
|
|
|
|
static PyObject *Armature_getName( BPy_Armature * self )
|
2004-05-11 08:26:44 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject *attr = PyString_FromString( self->armature->id.name + 2 );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( attr )
|
|
|
|
|
return attr;
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
|
|
|
|
"couldn't get Armature.name attribute" ) );
|
2004-05-11 08:26:44 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//---------------------BPy_Armature.getBones()------------------------
|
|
|
|
|
static PyObject *Armature_getBones( BPy_Armature * self )
|
2004-05-11 08:26:44 +00:00
|
|
|
{
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
PyObject *listbones = NULL;
|
|
|
|
|
Bone *parent = NULL;
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
listbones = PyList_New( 0 );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
//append root bones
|
|
|
|
|
for( parent = self->armature->bonebase.first; parent;
|
|
|
|
|
parent = parent->next ) {
|
|
|
|
|
PyList_Append( listbones, Bone_CreatePyObject( parent ) );
|
|
|
|
|
if( parent->childbase.first ) { //has children?
|
|
|
|
|
append_childrenToList( parent, listbones );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return listbones;
|
2004-05-11 08:26:44 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//---------------------BPy_Armature.addBone()-------------------------
|
|
|
|
|
static PyObject *Armature_addBone( BPy_Armature * self, PyObject * args )
|
2004-05-11 08:26:44 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
BPy_Bone *py_bone = NULL;
|
2004-05-11 08:26:44 +00:00
|
|
|
float M_boneObjectspace[4][4];
|
|
|
|
|
float iM_parentRest[4][4];
|
|
|
|
|
Bone *blen_bone;
|
|
|
|
|
char *parent_str = "";
|
|
|
|
|
Bone *parent;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "O!", &Bone_Type, &py_bone ) )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"expected bone object argument (or nothing)" ) );
|
|
|
|
|
|
|
|
|
|
if( py_bone->bone != NULL )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"this bone has already been linked to an armature" );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
//check to see if we can parent this bone if it will be attempted
|
|
|
|
|
//otherwise exit
|
|
|
|
|
if( !BLI_streq( py_bone->parent, parent_str ) ) { //parenting being attempted
|
2004-05-11 08:26:44 +00:00
|
|
|
//get parent if exists in this armature
|
2004-09-25 20:30:40 +00:00
|
|
|
parent = testBoneNameInArmature( self->armature,
|
|
|
|
|
py_bone->parent );
|
|
|
|
|
if( !parent ) { //could find the parent's name
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
|
|
|
|
|
"cannot find parent's name in armature - check to see if name of parent is correct" ) );
|
2004-05-11 08:26:44 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
} else { //no parent for this bone
|
2004-05-11 08:26:44 +00:00
|
|
|
parent = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//create a bone struct
|
2004-09-25 20:30:40 +00:00
|
|
|
blen_bone = ( Bone * ) MEM_callocN( sizeof( Bone ), "DefaultBone" );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
|
|
|
|
//set the bone struct pointer
|
|
|
|
|
py_bone->bone = blen_bone;
|
|
|
|
|
//update the bonestruct data from py data
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !updateBoneData( py_bone, parent ) )
|
|
|
|
|
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"bone struct empty" );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
|
|
|
|
//make sure the name is unique for this armature
|
2004-09-25 20:30:40 +00:00
|
|
|
unique_BoneName( py_bone->bone->name, self->armature );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
//if bone has a parent....
|
|
|
|
|
if( py_bone->bone->parent ) {
|
2004-05-11 08:26:44 +00:00
|
|
|
|
|
|
|
|
//then check to see if parent has been added to the armature - bone loop test
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !testBoneInArmature
|
|
|
|
|
( self->armature, py_bone->bone->parent ) )
|
|
|
|
|
return ( EXPP_ReturnPyObjError
|
|
|
|
|
( PyExc_TypeError,
|
|
|
|
|
"cannot parent to a bone not yet added to armature!" ) );
|
|
|
|
|
|
2004-05-11 08:26:44 +00:00
|
|
|
//add to parent's childbase
|
2004-09-25 20:30:40 +00:00
|
|
|
BLI_addtail( &py_bone->bone->parent->childbase,
|
|
|
|
|
py_bone->bone );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
|
|
|
|
//get the worldspace coords for the parent
|
2004-09-25 20:30:40 +00:00
|
|
|
get_objectspace_bone_matrix( py_bone->bone->parent,
|
|
|
|
|
M_boneObjectspace, 0, 0 );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
|
|
|
|
// Invert the parent rest matrix
|
2004-09-25 20:30:40 +00:00
|
|
|
Mat4Invert( iM_parentRest, M_boneObjectspace );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
|
|
|
|
//transformation of local bone
|
2004-09-25 20:30:40 +00:00
|
|
|
Mat4MulVecfl( iM_parentRest, py_bone->bone->tail );
|
|
|
|
|
Mat4MulVecfl( iM_parentRest, py_bone->bone->head );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
} else //no parent....
|
|
|
|
|
BLI_addtail( &self->armature->bonebase, py_bone->bone );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-05-25 02:48:02 +00:00
|
|
|
//rebuild_bone_parent_matrix(py_bone->bone);
|
2004-05-11 08:26:44 +00:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
//precalc_bonelist_irestmats( &self->armature->bonebase );
|
|
|
|
|
//precalc_armature_posemats( self->armature );
|
|
|
|
|
//precalc_bone_defmat( py_bone->bone );
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
Py_INCREF( Py_None );
|
2004-05-11 08:26:44 +00:00
|
|
|
return Py_None;
|
|
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//---------------------BPy_Armature.setName()-------------------------
|
|
|
|
|
static PyObject *Armature_setName( BPy_Armature * self, PyObject * args )
|
2004-05-11 08:26:44 +00:00
|
|
|
{
|
2004-09-25 20:30:40 +00:00
|
|
|
char *name;
|
|
|
|
|
char buf[21];
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "s", &name ) )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"expected string argument" ) );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
rename_id( &self->armature->id, buf );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None );
|
|
|
|
|
return Py_None;
|
2004-05-11 08:26:44 +00:00
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//---------------------BPy_Armature.drawAxes()------------------------
|
|
|
|
|
static PyObject *Armature_drawAxes( BPy_Armature * self, PyObject * args )
|
2004-05-11 08:26:44 +00:00
|
|
|
{
|
|
|
|
|
int toggle;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "i", &toggle ) )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"expected 1 or 0 as integer" ) );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( toggle )
|
2004-05-11 08:26:44 +00:00
|
|
|
self->armature->flag |= ARM_DRAWAXES;
|
|
|
|
|
else
|
|
|
|
|
self->armature->flag &= ~ARM_DRAWAXES;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None );
|
2004-05-11 08:26:44 +00:00
|
|
|
return Py_None;
|
|
|
|
|
}
|
2004-09-25 20:30:40 +00:00
|
|
|
|
|
|
|
|
//---------------------BPy_Armature.drawNames()-------------------------
|
|
|
|
|
static PyObject *Armature_drawNames( BPy_Armature * self, PyObject * args )
|
2004-05-11 08:26:44 +00:00
|
|
|
{
|
|
|
|
|
int toggle;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( !PyArg_ParseTuple( args, "i", &toggle ) )
|
|
|
|
|
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
|
|
|
|
|
"expected 1 or 0 as integer" ) );
|
2004-05-11 08:26:44 +00:00
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
if( toggle )
|
2004-05-11 08:26:44 +00:00
|
|
|
self->armature->flag |= ARM_DRAWNAMES;
|
|
|
|
|
else
|
|
|
|
|
self->armature->flag &= ~ARM_DRAWNAMES;
|
|
|
|
|
|
2004-09-25 20:30:40 +00:00
|
|
|
Py_INCREF( Py_None );
|
2004-05-11 08:26:44 +00:00
|
|
|
return Py_None;
|
|
|
|
|
}
|