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-
This commit is contained in:
2005-07-03 17:35:38 +00:00
parent 99a8747e82
commit 28a1e8277b
112 changed files with 6085 additions and 9396 deletions

View File

@@ -610,9 +610,9 @@ static PyObject *Armature_addBone( BPy_Armature * self, PyObject * args )
//rebuild_bone_parent_matrix(py_bone->bone);
precalc_bonelist_irestmats( &self->armature->bonebase );
precalc_armature_posemats( self->armature );
precalc_bone_defmat( py_bone->bone );
//precalc_bonelist_irestmats( &self->armature->bonebase );
//precalc_armature_posemats( self->armature );
//precalc_bone_defmat( py_bone->bone );
Py_INCREF( Py_None );
return Py_None;

View File

@@ -91,12 +91,14 @@ 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 );
static PyObject *Bone_setTail( BPy_Bone * self, PyObject * args );
// note; this can only be done as POSE operation
static PyObject *Bone_setLoc( BPy_Bone * self, PyObject * args );
static PyObject *Bone_setSize( BPy_Bone * self, PyObject * args );
static PyObject *Bone_setQuat( BPy_Bone * self, PyObject * args );
static PyObject *Bone_setPose( BPy_Bone * self, PyObject * args );
static PyObject *Bone_setParent( BPy_Bone * self, PyObject * args );
static PyObject *Bone_setWeight( BPy_Bone * self, PyObject * args );
static PyObject *Bone_setPose( BPy_Bone * self, PyObject * args );
static PyObject *Bone_setBoneclass( BPy_Bone * self, PyObject * args );
static PyObject *Bone_getRestMatrix( BPy_Bone * self, PyObject * args );
@@ -261,7 +263,7 @@ static int updatePyBone( BPy_Bone * self )
BLI_strncpy( self->parent, parent_str,
strlen( parent_str ) + 1 );
}
#if 0
for( x = 0; x < 3; x++ ) {
self->head->vec[x] = self->bone->head[x];
self->tail->vec[x] = self->bone->tail[x];
@@ -288,6 +290,7 @@ static int updatePyBone( BPy_Bone * self )
self->bone->posemat[x][y];
}
}
#endif
return 1;
}
}
@@ -315,27 +318,27 @@ int updateBoneData( BPy_Bone * self, Bone * parent )
for( x = 0; x < 3; x++ ) {
self->bone->head[x] = self->head->vec[x];
self->bone->tail[x] = self->tail->vec[x];
self->bone->loc[x] = self->loc->vec[x];
self->bone->dloc[x] = self->dloc->vec[x];
self->bone->size[x] = self->size->vec[x];
self->bone->dsize[x] = self->dsize->vec[x];
// self->bone->loc[x] = self->loc->vec[x];
// self->bone->dloc[x] = self->dloc->vec[x];
// self->bone->size[x] = self->size->vec[x];
// self->bone->dsize[x] = self->dsize->vec[x];
}
for( x = 0; x < 4; x++ ) {
self->bone->quat[x] = self->quat->quat[x];
self->bone->dquat[x] = self->dquat->quat[x];
// self->bone->quat[x] = self->quat->quat[x];
// self->bone->dquat[x] = self->dquat->quat[x];
}
for( x = 0; x < 4; x++ ) {
for( y = 0; y < 4; y++ ) {
self->bone->obmat[x][y] =
self->obmat->matrix[x][y];
self->bone->parmat[x][y] =
self->parmat->matrix[x][y];
self->bone->defmat[x][y] =
self->defmat->matrix[x][y];
self->bone->irestmat[x][y] =
self->irestmat->matrix[x][y];
self->bone->posemat[x][y] =
self->posemat->matrix[x][y];
// self->bone->obmat[x][y] =
// self->obmat->matrix[x][y];
// self->bone->parmat[x][y] =
// self->parmat->matrix[x][y];
// self->bone->defmat[x][y] =
// self->defmat->matrix[x][y];
// self->bone->irestmat[x][y] =
// self->irestmat->matrix[x][y];
// self->bone->posemat[x][y] =
// self->posemat->matrix[x][y];
}
}
return 1;
@@ -828,9 +831,10 @@ static PyObject *Bone_getLoc( BPy_Bone * self )
//use bone datastruct
attr = newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ),
3 );
( ( VectorObject * ) attr )->vec[0] = self->bone->loc[0];
( ( VectorObject * ) attr )->vec[1] = self->bone->loc[1];
( ( VectorObject * ) attr )->vec[2] = self->bone->loc[2];
// ( ( VectorObject * ) attr )->vec[0] = self->bone->loc[0];
// ( ( VectorObject * ) attr )->vec[1] = self->bone->loc[1];
// ( ( VectorObject * ) attr )->vec[2] = self->bone->loc[2];
}
if( attr )
return attr;
@@ -856,9 +860,9 @@ static PyObject *Bone_getSize( BPy_Bone * self )
//use bone datastruct
attr = newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ),
3 );
( ( VectorObject * ) attr )->vec[0] = self->bone->size[0];
( ( VectorObject * ) attr )->vec[1] = self->bone->size[1];
( ( VectorObject * ) attr )->vec[2] = self->bone->size[2];
// ( ( VectorObject * ) attr )->vec[0] = self->bone->size[0];
// ( ( VectorObject * ) attr )->vec[1] = self->bone->size[1];
// ( ( VectorObject * ) attr )->vec[2] = self->bone->size[2];
}
if( attr )
return attr;
@@ -885,10 +889,10 @@ static PyObject *Bone_getQuat( BPy_Bone * self )
//use bone datastruct
attr = newQuaternionObject( PyMem_Malloc
( 4 * sizeof( float ) ) );
( ( QuaternionObject * ) attr )->quat[0] = self->bone->quat[0];
( ( QuaternionObject * ) attr )->quat[1] = self->bone->quat[1];
( ( QuaternionObject * ) attr )->quat[2] = self->bone->quat[2];
( ( QuaternionObject * ) attr )->quat[3] = self->bone->quat[3];
// ( ( QuaternionObject * ) attr )->quat[0] = self->bone->quat[0];
// ( ( QuaternionObject * ) attr )->quat[1] = self->bone->quat[1];
// ( ( QuaternionObject * ) attr )->quat[2] = self->bone->quat[2];
// ( ( QuaternionObject * ) attr )->quat[3] = self->bone->quat[3];
}
return attr;
@@ -1095,9 +1099,9 @@ static PyObject *Bone_setLoc( BPy_Bone * self, PyObject * args )
self->loc->vec[2] = f3;
} else {
//use bone datastruct
self->bone->loc[0] = f1;
self->bone->loc[1] = f2;
self->bone->loc[2] = f3;
// self->bone->loc[0] = f1;
// self->bone->loc[1] = f2;
// self->bone->loc[2] = f3;
}
return EXPP_incr_ret( Py_None );
}
@@ -1124,9 +1128,9 @@ static PyObject *Bone_setSize( BPy_Bone * self, PyObject * args )
self->size->vec[2] = f3;
} else {
//use bone datastruct
self->bone->size[0] = f1;
self->bone->size[1] = f2;
self->bone->size[2] = f3;
// self->bone->size[0] = f1;
// self->bone->size[1] = f2;
// self->bone->size[2] = f3;
}
return EXPP_incr_ret( Py_None );
}
@@ -1168,10 +1172,10 @@ static PyObject *Bone_setQuat( BPy_Bone * self, PyObject * args )
self->quat->quat[3] = f4;
} else {
//use bone datastruct
self->bone->quat[0] = f1;
self->bone->quat[1] = f2;
self->bone->quat[2] = f3;
self->bone->quat[3] = f4;
// self->bone->quat[0] = f1;
// self->bone->quat[1] = f2;
// self->bone->quat[2] = f3;
// self->bone->quat[3] = f4;
}
return EXPP_incr_ret( Py_None );
}
@@ -1543,19 +1547,22 @@ static PyObject *Bone_setPose( BPy_Bone * self, PyObject * args )
object->pose = MEM_callocN( sizeof( bPose ), "Pose" );
//if bone does have a channel create one
verify_pose_channel( object->pose, self->bone->name );
// do not use anymore! (ton)
chan= verify_pose_channel( object->pose, self->bone->name );
//create temp Pose Channel
chan = MEM_callocN( sizeof( bPoseChannel ), "PoseChannel" );
// chan = MEM_callocN( sizeof( bPoseChannel ), "PoseChannel" );
//set the variables for this pose
memcpy( chan->loc, self->bone->loc, sizeof( chan->loc ) );
memcpy( chan->quat, self->bone->quat, sizeof( chan->quat ) );
memcpy( chan->size, self->bone->size, sizeof( chan->size ) );
// memcpy( chan->loc, self->bone->loc, sizeof( chan->loc ) );
// memcpy( chan->quat, self->bone->quat, sizeof( chan->quat ) );
// memcpy( chan->size, self->bone->size, sizeof( chan->size ) );
strcpy( chan->name, self->bone->name );
chan->flag |= flagValue;
//set it to the channel
setChan = set_pose_channel( object->pose, chan );
// setChan = set_pose_channel( object->pose, chan );
//frees unlinked pose/bone channels from object
collect_pose_garbage( object );
/* note; changing an Armature requires building poses again, consult me! (ton) */
// collect_pose_garbage( object );
//create an action if one not already assigned to object
if( !py_action && !object->action ) {
@@ -1600,8 +1607,8 @@ static PyObject *Bone_setPose( BPy_Bone * self, PyObject * args )
//rebuild ipos
remake_action_ipos( object->action );
//rebuild displists
rebuild_all_armature_displists( );
//signal to rebuild displists (new! added by ton)
object->recalc |= OB_RECALC_DATA;
}
return EXPP_incr_ret( Py_None );
}
@@ -1667,6 +1674,11 @@ static PyObject *Bone_hasIK( BPy_Bone * self )
}
//--------------- BPy_Bone.getRestMatrix()-------------------------
/* we now got BoneSpace, ArmatureSpace, PoseSpace, WorldSpace.
check DNA_armature.h, only read from data itself, dont use evil calls
that evaluate animation system anymore (ton) */
static PyObject *Bone_getRestMatrix( BPy_Bone * self, PyObject * args )
{
char *local = "worldspace";
@@ -1691,8 +1703,8 @@ static PyObject *Bone_getRestMatrix( BPy_Bone * self, PyObject * args )
//use python vars
if( BLI_streq( local, worldspace ) ) {
VecSubf( delta, self->tail->vec, self->head->vec );
make_boneMatrixvr( (float ( * )[4]) *( ( MatrixObject * ) matrix )->
matrix, delta, self->roll );
// make_boneMatrixvr( (float ( * )[4]) *( ( MatrixObject * ) matrix )->
// matrix, delta, self->roll );
} else if( BLI_streq( local, bonespace ) ) {
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"bone not yet linked to an armature....'" ) );
@@ -1706,12 +1718,13 @@ static PyObject *Bone_getRestMatrix( BPy_Bone * self, PyObject * args )
1 );
} else if( BLI_streq( local, bonespace ) ) {
VecSubf( delta, self->bone->tail, self->bone->head );
make_boneMatrixvr( (float ( * )[4]) *( ( MatrixObject * ) matrix )->
matrix, delta, self->bone->roll );
// make_boneMatrixvr( (float ( * )[4]) *( ( MatrixObject * ) matrix )->
// matrix, delta, self->bone->roll );
if( self->bone->parent ) {
get_bone_root_pos( self->bone, root, 1 );
get_bone_root_pos( self->bone->parent, p_root,
1 );
// get_bone_root_pos( self->bone, root, 1 );
// get_bone_root_pos( self->bone->parent, p_root,
// 1 );
VecSubf( delta, root, p_root );
VECCOPY( ( ( MatrixObject * ) matrix )->
matrix[3], delta );

View File

@@ -46,15 +46,15 @@
#include "DNA_object_force.h"
#include <DNA_property_types.h>
#include <BSE_edit.h>
#include <BKE_depsgraph.h>
#include <BKE_font.h>
#include <BKE_property.h>
#include <BKE_mball.h>
#include <BKE_font.h>
#include <BKE_softbody.h>
#include <BIF_editview.h>
#include <BSE_editipo.h>
#include <BSE_edit.h>
#include "Ipo.h"
#include "Lattice.h"
@@ -581,7 +581,6 @@ PyObject *M_Object_New( PyObject * self, PyObject * args )
type = OB_CURVE;
else if (strcmp (str_type, "Text") == 0)
type = OB_FONT;
/* else if (strcmp (str_type, "Ika") == 0) type = OB_IKA; */
else if( strcmp( str_type, "Lamp" ) == 0 )
type = OB_LAMP;
else if( strcmp( str_type, "Lattice" ) == 0 )
@@ -865,7 +864,7 @@ static PyObject *Object_clrParent( BPy_Object * self, PyObject * args )
}
if( !fast ) {
sort_baselist( G.scene );
DAG_scene_sort( G.scene );
}
Py_INCREF( Py_None );
@@ -891,7 +890,7 @@ static PyObject *Object_clearTrack( BPy_Object * self, PyObject * args )
}
if( !fast ) {
sort_baselist( G.scene );
DAG_scene_sort( G.scene );
}
Py_INCREF( Py_None );
@@ -941,10 +940,6 @@ int EXPP_add_obdata( struct Object *object )
case OB_FONT:
object->data = add_curve(OB_FONT);
break;
case OB_IKA:
object->data = add_ika();
object->dt = OB_WIRE;
break;
case OB_WAVE:
object->data = add_wave();
break;
@@ -1290,8 +1285,6 @@ static PyObject *Object_getType( BPy_Object * self )
return ( Py_BuildValue( "s", "Empty" ) );
case OB_FONT:
return ( Py_BuildValue( "s", "Text" ) );
case OB_IKA:
return ( Py_BuildValue( "s", "Ika" ) );
case OB_LAMP:
return ( Py_BuildValue( "s", "Lamp" ) );
case OB_LATTICE:
@@ -1597,7 +1590,7 @@ static PyObject *Object_makeParent( BPy_Object * self, PyObject * args )
}
if( !fast ) {
sort_baselist( G.scene );
DAG_scene_sort( G.scene );
}
// We don't need the child object anymore.
Py_DECREF (py_child);
@@ -1984,7 +1977,7 @@ static PyObject *Object_makeTrack( BPy_Object * self, PyObject * args )
ob->track = tracked->object;
if( !fast )
sort_baselist( G.scene );
DAG_scene_sort( G.scene );
return EXPP_incr_ret( Py_None );
}
@@ -2414,7 +2407,6 @@ static void Object_dealloc( BPy_Object * obj )
static PyObject *Object_getAttr( BPy_Object * obj, char *name )
{
struct Object *object;
struct Ika *ika;
object = obj->object;
if( StringEqual( name, "LocX" ) )
@@ -2475,25 +2467,7 @@ static PyObject *Object_getAttr( BPy_Object * obj, char *name )
return ( Py_BuildValue
( "fff", object->dsize[0], object->dsize[1],
object->dsize[2] ) );
/* no IKA anymore, I think we can remove this. (theeth)
if( strncmp( name, "Eff", 3 ) == 0 ) {
if( ( object->type == OB_IKA ) && ( object->data != NULL ) ) {
ika = object->data;
switch ( name[3] ) {
case 'X':
return ( PyFloat_FromDouble( ika->effg[0] ) );
case 'Y':
return ( PyFloat_FromDouble( ika->effg[1] ) );
case 'Z':
return ( PyFloat_FromDouble( ika->effg[2] ) );
default:
// Do we need to display a sensible error message here?
return ( NULL );
}
}
return ( NULL );
}
*/
/* accept both Layer (old, for compatibility) and Layers */
if( strncmp( name, "Layer", 5 ) == 0)
return ( PyInt_FromLong( object->lay ) );
@@ -2612,7 +2586,6 @@ static int Object_setAttr( BPy_Object * obj, char *name, PyObject * value )
{
PyObject *valtuple, *result=NULL;
struct Object *object;
struct Ika *ika;
object = obj->object;
@@ -2682,6 +2655,7 @@ static int Object_setAttr( BPy_Object * obj, char *name, PyObject * value )
return ( !PyArg_ParseTuple
( value, "fff", &( object->dsize[0] ),
&( object->dsize[1] ), &( object->dsize[2] ) ) );
if( StringEqual( name, "DupSta" ) )
return ( !PyArg_Parse( value, "h", &( object->dupsta ) ) );

View File

@@ -52,7 +52,6 @@
#include <DNA_armature_types.h>
#include <DNA_action_types.h>
#include <DNA_ID.h>
#include <DNA_ika_types.h>
#include <DNA_listBase.h>
#include <DNA_scene_types.h>
#include <DNA_userdef_types.h>

View File

@@ -31,19 +31,26 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include <BKE_main.h>
#include <MEM_guardedalloc.h> /* for MEM_callocN */
#include <DNA_screen_types.h> /* SPACE_VIEW3D, SPACE_SEQ */
#include <DNA_scriptlink_types.h>
#include <BKE_depsgraph.h>
#include <BKE_global.h>
#include <BKE_scene.h>
#include <BKE_library.h>
#include <BKE_main.h>
#include <BKE_scene.h>
#include <BLI_blenlib.h>
#include <BSE_drawview.h> /* for play_anim */
#include <BSE_headerbuttons.h> /* for copy_scene */
#include <BIF_drawscene.h> /* for set_scene */
#include <BIF_space.h> /* for copy_view3d_lock() */
#include <BIF_screen.h> /* curarea */
#include <DNA_screen_types.h> /* SPACE_VIEW3D, SPACE_SEQ */
#include <DNA_scriptlink_types.h>
#include <MEM_guardedalloc.h> /* for MEM_callocN */
#include <mydevice.h> /* for #define REDRAW */
#include "Object.h"
@@ -141,7 +148,7 @@ static PyMethodDef BPy_Scene_methods[] = {
{"update", ( PyCFunction ) Scene_update, METH_VARARGS,
"(full = 0) - Update scene self.\n"
"full = 0: sort the base list of objects."
"full = 1: full update -- also regroups, does ipos, ikas, keys"},
"full = 1: full update -- also regroups, does ipos, keys"},
{"link", ( PyCFunction ) Scene_link, METH_VARARGS,
"(obj) - Link Object obj to this scene"},
{"unlink", ( PyCFunction ) Scene_unlink, METH_VARARGS,
@@ -702,12 +709,12 @@ static PyObject *Scene_update( BPy_Scene * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected nothing or int (0 or 1) argument" );
/* Under certain circunstances, sort_baselist *here* can crash Blender.
/* Under certain circunstances, DAG_scene_sort *here* can crash Blender.
* A "RuntimeError: max recursion limit" happens when a scriptlink
* on frame change has scene.update(1).
* Investigate better how to avoid this. */
if( !full )
sort_baselist( scene );
DAG_scene_sort( scene );
else if( full == 1 )
set_scene_bg( scene );
@@ -716,7 +723,7 @@ static PyObject *Scene_update( BPy_Scene * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_ValueError,
"in method scene.update(full), full should be:\n"
"0: to only sort scene elements (old behavior); or\n"
"1: for a full update (regroups, does ipos, ikas, keys, etc.)" );
"1: for a full update (regroups, does ipos, keys, etc.)" );
Py_INCREF( Py_None );
return Py_None;

View File

@@ -137,9 +137,6 @@ class Object:
@ivar dSizeY: The delta Y size of the object.
@ivar dSizeZ: The delta Z size of the object.
@ivar dsize: The delta (X,Y,Z) size of the object.
@ivar EffX: The X effector coordinate of the object. Only applies to IKA.
@ivar EffY: The Y effector coordinate of the object. Only applies to IKA.
@ivar EffZ: The Z effector coordinate of the object. Only applies to IKA.
@type Layers: integer (bitmask)
@ivar Layers: The object layers (also check the newer attribute
L{layers<Object.Object.layers>}). This value is a bitmask with at

View File

@@ -158,7 +158,7 @@ class Scene:
@type full: int
@param full: A bool to control the level of updating:
- 0: sort the base list of objects.
- 1: sort and also regroup, do ipos, ikas, keys, script links, etc.
- 1: sort and also regroup, do ipos, keys, script links, etc.
@warn: When in doubt, try with I{full = 0} first, since it is faster.
The "full" update is a recent addition to this method.
"""