2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* ***** 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.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_action_types.h"
|
|
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
Another huge commit!!!
First, check on the new files, which are listed below.
The new butspace.h is a local include, only to be used for the buttons
drawn in the buttonswindow.
- editbuts, animbuts, gamebuts, displaybuts, paintbuts, work now
- i quite completely reorganized it, it's now nicely telling you what
context it is in
- sorting error in panel align fixed (tabs were flipping)
- align works correctly automatic when you click around in Blender
- editsca.c renamed to buttons_logic.h
- button names are truncated from the right for allmost all buttons
(except text buttons and number buttons)
- while dragging panels, you cannot move them outside window anymore
And of course fixed loads of little bugs I encountered while testing
it all. This is a version I really need good test & feedback for.
Next step: restoring material/lamp/texture/world
2003-10-10 17:29:01 +00:00
|
|
|
#include "DNA_screen_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_constraint_types.h"
|
|
|
|
|
#include "DNA_curve_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
#include "BKE_action.h"
|
|
|
|
|
#include "BKE_armature.h"
|
|
|
|
|
#include "BKE_object.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_constraint.h"
|
|
|
|
|
#include "BKE_ipo.h"
|
|
|
|
|
|
2005-07-27 10:37:20 +00:00
|
|
|
#include "BIF_editaction.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BIF_editarmature.h"
|
|
|
|
|
#include "BIF_editconstraint.h"
|
|
|
|
|
#include "BIF_interface.h"
|
|
|
|
|
#include "BIF_screen.h"
|
|
|
|
|
#include "BIF_toolbox.h"
|
|
|
|
|
|
|
|
|
|
#include "blendef.h"
|
|
|
|
|
#include "nla.h"
|
|
|
|
|
|
2002-11-25 12:02:15 +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
|
|
|
/* called by buttons to find a bone to display/edit values for */
|
|
|
|
|
static bPoseChannel *get_active_posechannel (void)
|
2002-10-12 11:37:38 +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
|
|
|
Object *ob= OBACT;
|
|
|
|
|
bPoseChannel *pchan;
|
|
|
|
|
bArmature *arm;
|
2002-10-12 11:37:38 +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
|
|
|
arm = get_armature(OBACT);
|
|
|
|
|
if (!arm)
|
|
|
|
|
return NULL;
|
2002-10-12 11:37:38 +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
|
|
|
/* find for active */
|
|
|
|
|
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
|
|
|
|
if(pchan->bone && (pchan->bone->flag & BONE_ACTIVE))
|
|
|
|
|
return pchan;
|
2002-10-12 11:37:38 +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
|
|
|
return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ListBase *get_constraint_client_channels (int forcevalid)
|
|
|
|
|
{
|
|
|
|
|
Object *ob;
|
|
|
|
|
char ipstr[64];
|
|
|
|
|
|
|
|
|
|
ob=OBACT;
|
|
|
|
|
|
|
|
|
|
if (!ob)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* See if we are a bone constraint */
|
2005-07-23 18:52:31 +00:00
|
|
|
if (ob->flag & OB_POSEMODE) {
|
|
|
|
|
bActionChannel *achan;
|
|
|
|
|
bPoseChannel *pchan;
|
|
|
|
|
|
|
|
|
|
pchan = get_active_posechannel();
|
|
|
|
|
if (pchan) {
|
|
|
|
|
|
|
|
|
|
/* Make sure we have an action */
|
|
|
|
|
if (!ob->action){
|
|
|
|
|
if (!forcevalid)
|
|
|
|
|
return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-07-23 18:52:31 +00:00
|
|
|
ob->action=add_empty_action();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make sure we have an actionchannel */
|
|
|
|
|
achan = get_named_actionchannel(ob->action, pchan->name);
|
|
|
|
|
if (!achan){
|
|
|
|
|
if (!forcevalid)
|
|
|
|
|
return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-07-23 18:52:31 +00:00
|
|
|
achan = MEM_callocN (sizeof(bActionChannel), "actionChannel");
|
|
|
|
|
|
|
|
|
|
strcpy (achan->name, pchan->name);
|
|
|
|
|
sprintf (ipstr, "%s.%s", ob->action->id.name+2, achan->name);
|
|
|
|
|
ipstr[23]=0;
|
|
|
|
|
achan->ipo= add_ipo(ipstr, ID_AC);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-07-23 18:52:31 +00:00
|
|
|
BLI_addtail (&ob->action->chanbase, achan);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-07-23 18:52:31 +00:00
|
|
|
|
|
|
|
|
return &achan->constraintChannels;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-08-22 21:58:55 +00:00
|
|
|
else return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-07-23 18:52:31 +00:00
|
|
|
/* else we return object constraints */
|
2002-10-12 11:37:38 +00:00
|
|
|
return &ob->constraintChannels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListBase *get_constraint_client(char *name, short *clientType, void **clientdata)
|
|
|
|
|
{
|
|
|
|
|
Object *ob;
|
|
|
|
|
ListBase *list;
|
|
|
|
|
|
|
|
|
|
ob=OBACT;
|
|
|
|
|
if (clientType)
|
|
|
|
|
*clientType = -1;
|
|
|
|
|
|
|
|
|
|
if (!ob)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
list = &ob->constraints;
|
|
|
|
|
|
|
|
|
|
/* Prep the object's constraint channels */
|
|
|
|
|
if (clientType)
|
|
|
|
|
*clientType = TARGET_OBJECT;
|
|
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
|
strcpy (name, ob->id.name+2);
|
|
|
|
|
|
2005-07-23 18:52:31 +00:00
|
|
|
if (ob->flag & OB_POSEMODE) {
|
|
|
|
|
bPoseChannel *pchan;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-07-23 18:52:31 +00:00
|
|
|
pchan = get_active_posechannel();
|
|
|
|
|
if (pchan) {
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-07-23 18:52:31 +00:00
|
|
|
/* Is the bone the client? */
|
|
|
|
|
if (clientType)
|
|
|
|
|
*clientType = TARGET_BONE;
|
|
|
|
|
if (clientdata)
|
|
|
|
|
*clientdata = pchan->bone;
|
|
|
|
|
if (name)
|
|
|
|
|
sprintf (name, "%s>>%s", name, pchan->name);
|
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
|
|
|
|
2005-07-23 18:52:31 +00:00
|
|
|
list = &pchan->constraints;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-22 23:17:48 +00:00
|
|
|
bConstraint * add_new_constraint(char type)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
bConstraint *con;
|
|
|
|
|
|
|
|
|
|
con = MEM_callocN(sizeof(bConstraint), "constraint");
|
|
|
|
|
|
|
|
|
|
/* Set up a generic constraint datablock */
|
2003-10-21 13:22:07 +00:00
|
|
|
con->type = type;
|
2002-10-12 11:37:38 +00:00
|
|
|
con->flag |= CONSTRAINT_EXPAND;
|
|
|
|
|
con->enforce=1.0F;
|
|
|
|
|
/* Load the data for it */
|
|
|
|
|
con->data = new_constraint_data(con->type);
|
|
|
|
|
strcpy (con->name, "Const");
|
|
|
|
|
return con;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-21 13:22:07 +00:00
|
|
|
void add_constraint_to_object(bConstraint *con, Object *ob)
|
|
|
|
|
{
|
|
|
|
|
ListBase *list;
|
|
|
|
|
list = &ob->constraints;
|
|
|
|
|
if (list)
|
|
|
|
|
{
|
|
|
|
|
unique_constraint_name(con, list);
|
|
|
|
|
BLI_addtail(list, con);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void add_constraint_to_client(bConstraint *con)
|
|
|
|
|
{
|
|
|
|
|
ListBase *list;
|
|
|
|
|
short type;
|
|
|
|
|
list = get_constraint_client(NULL, &type, NULL);
|
|
|
|
|
if (list)
|
|
|
|
|
{
|
|
|
|
|
unique_constraint_name(con, list);
|
|
|
|
|
BLI_addtail(list, con);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
bConstraintChannel *add_new_constraint_channel(const char* name)
|
|
|
|
|
{
|
|
|
|
|
bConstraintChannel *chan = NULL;
|
|
|
|
|
|
|
|
|
|
chan = MEM_callocN(sizeof(bConstraintChannel), "constraintChannel");
|
|
|
|
|
strcpy(chan->name, name);
|
|
|
|
|
|
|
|
|
|
return chan;
|
2002-10-30 00:27:48 +00:00
|
|
|
}
|
|
|
|
|
|
2003-10-21 13:22:07 +00:00
|
|
|
void add_influence_key_to_constraint (bConstraint *con){
|
|
|
|
|
printf("doesn't do anything yet\n");
|
2003-11-16 21:29:12 +00:00
|
|
|
}
|
2004-01-02 23:29:34 +00:00
|
|
|
|
2004-01-03 03:53:18 +00:00
|
|
|
char *get_con_subtarget_name(bConstraint *constraint, Object *target)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* If the target for this constraint is target, return a pointer
|
|
|
|
|
* to the name for this constraints subtarget ... NULL otherwise
|
|
|
|
|
*/
|
|
|
|
|
switch (constraint->type) {
|
|
|
|
|
|
|
|
|
|
case CONSTRAINT_TYPE_ACTION:
|
|
|
|
|
{
|
|
|
|
|
bActionConstraint *data = constraint->data;
|
|
|
|
|
if (data->tar==target) return data->subtarget;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CONSTRAINT_TYPE_LOCLIKE:
|
|
|
|
|
{
|
|
|
|
|
bLocateLikeConstraint *data = constraint->data;
|
|
|
|
|
if (data->tar==target) return data->subtarget;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CONSTRAINT_TYPE_ROTLIKE:
|
|
|
|
|
{
|
|
|
|
|
bRotateLikeConstraint *data = constraint->data;
|
|
|
|
|
if (data->tar==target) return data->subtarget;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CONSTRAINT_TYPE_KINEMATIC:
|
|
|
|
|
{
|
|
|
|
|
bKinematicConstraint *data = constraint->data;
|
|
|
|
|
if (data->tar==target) return data->subtarget;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CONSTRAINT_TYPE_TRACKTO:
|
|
|
|
|
{
|
|
|
|
|
bTrackToConstraint *data = constraint->data;
|
|
|
|
|
if (data->tar==target) return data->subtarget;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CONSTRAINT_TYPE_LOCKTRACK:
|
|
|
|
|
{
|
|
|
|
|
bLockTrackConstraint *data = constraint->data;
|
|
|
|
|
if (data->tar==target) return data->subtarget;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2004-09-05 20:21:16 +00:00
|
|
|
case CONSTRAINT_TYPE_STRETCHTO:
|
|
|
|
|
{
|
|
|
|
|
bStretchToConstraint *data = constraint->data;
|
|
|
|
|
if (data->tar==target) return data->subtarget;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2004-01-03 03:53:18 +00:00
|
|
|
case CONSTRAINT_TYPE_FOLLOWPATH:
|
|
|
|
|
/* wonder if this is relevent, since this constraint
|
|
|
|
|
* cannot have a subtarget - theeth
|
|
|
|
|
*/
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* bFollowPathConstraint *data = constraint->data;
|
|
|
|
|
*/
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
2004-09-03 14:31:06 +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
|
|
|
/* checks validity of object pointers, and NULLs,
|
|
|
|
|
if Bone doesnt exist it sets the CONSTRAINT_DISABLE flag */
|
|
|
|
|
static void test_constraints (Object *owner, const char* substring)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bConstraint *curcon;
|
|
|
|
|
ListBase *conlist= NULL;
|
|
|
|
|
int type;
|
|
|
|
|
|
|
|
|
|
if (owner==NULL) return;
|
|
|
|
|
|
|
|
|
|
/* Check parents */
|
|
|
|
|
/* Get the constraint list for this object */
|
|
|
|
|
|
|
|
|
|
if (strlen (substring)){
|
|
|
|
|
switch (owner->type){
|
|
|
|
|
case OB_ARMATURE:
|
|
|
|
|
type = TARGET_BONE;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
type = TARGET_OBJECT;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
type = TARGET_OBJECT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (type){
|
|
|
|
|
case TARGET_OBJECT:
|
|
|
|
|
conlist = &owner->constraints;
|
|
|
|
|
break;
|
|
|
|
|
case TARGET_BONE:
|
|
|
|
|
{
|
|
|
|
|
Bone *bone;
|
|
|
|
|
bPoseChannel *chan;
|
|
|
|
|
|
|
|
|
|
bone = get_named_bone(((bArmature*)owner->data), substring);
|
|
|
|
|
chan = get_pose_channel (owner->pose, substring);
|
|
|
|
|
if (bone && chan){
|
|
|
|
|
conlist = &chan->constraints;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Cycle constraints */
|
|
|
|
|
if (conlist){
|
|
|
|
|
for (curcon = conlist->first; curcon; curcon=curcon->next){
|
|
|
|
|
curcon->flag &= ~CONSTRAINT_DISABLE;
|
|
|
|
|
|
|
|
|
|
switch (curcon->type){
|
|
|
|
|
case CONSTRAINT_TYPE_ACTION:
|
|
|
|
|
{
|
|
|
|
|
bActionConstraint *data = curcon->data;
|
|
|
|
|
|
|
|
|
|
if (!exist_object(data->tar)){
|
|
|
|
|
data->tar = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (data->tar == owner) &&
|
|
|
|
|
(!get_named_bone(get_armature(owner),
|
|
|
|
|
data->subtarget))) {
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CONSTRAINT_TYPE_LOCLIKE:
|
|
|
|
|
{
|
|
|
|
|
bLocateLikeConstraint *data = curcon->data;
|
|
|
|
|
|
|
|
|
|
if (!exist_object(data->tar)){
|
|
|
|
|
data->tar = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (data->tar == owner) &&
|
|
|
|
|
(!get_named_bone(get_armature(owner),
|
|
|
|
|
data->subtarget))) {
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CONSTRAINT_TYPE_ROTLIKE:
|
|
|
|
|
{
|
|
|
|
|
bRotateLikeConstraint *data = curcon->data;
|
|
|
|
|
|
|
|
|
|
if (!exist_object(data->tar)){
|
|
|
|
|
data->tar = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (data->tar == owner) &&
|
|
|
|
|
(!get_named_bone(get_armature(owner),
|
|
|
|
|
data->subtarget))) {
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CONSTRAINT_TYPE_KINEMATIC:
|
|
|
|
|
{
|
|
|
|
|
bKinematicConstraint *data = curcon->data;
|
|
|
|
|
if (!exist_object(data->tar)){
|
|
|
|
|
data->tar = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (data->tar == owner) &&
|
|
|
|
|
(!get_named_bone(get_armature(owner),
|
|
|
|
|
data->subtarget))) {
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CONSTRAINT_TYPE_TRACKTO:
|
|
|
|
|
{
|
|
|
|
|
bTrackToConstraint *data = curcon->data;
|
|
|
|
|
if (!exist_object(data->tar)) {
|
|
|
|
|
data->tar = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (data->tar == owner) &&
|
|
|
|
|
(!get_named_bone(get_armature(owner),
|
|
|
|
|
data->subtarget))) {
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (data->reserved2==data->reserved1){
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (data->reserved2+3==data->reserved1){
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CONSTRAINT_TYPE_LOCKTRACK:
|
|
|
|
|
{
|
|
|
|
|
bLockTrackConstraint *data = curcon->data;
|
|
|
|
|
|
|
|
|
|
if (!exist_object(data->tar)){
|
|
|
|
|
data->tar = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (data->tar == owner) &&
|
|
|
|
|
(!get_named_bone(get_armature(owner),
|
|
|
|
|
data->subtarget))) {
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data->lockflag==data->trackflag){
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (data->lockflag+3==data->trackflag){
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CONSTRAINT_TYPE_STRETCHTO:
|
|
|
|
|
{
|
|
|
|
|
bStretchToConstraint *data = curcon->data;
|
|
|
|
|
|
|
|
|
|
if (!exist_object(data->tar)){
|
|
|
|
|
data->tar = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (data->tar == owner) &&
|
|
|
|
|
(!get_named_bone(get_armature(owner),
|
|
|
|
|
data->subtarget))) {
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CONSTRAINT_TYPE_FOLLOWPATH:
|
|
|
|
|
{
|
|
|
|
|
bFollowPathConstraint *data = curcon->data;
|
|
|
|
|
|
|
|
|
|
if (!exist_object(data->tar)){
|
|
|
|
|
data->tar = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (data->tar->type != OB_CURVE){
|
|
|
|
|
data->tar = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (data->upflag==data->trackflag){
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (data->upflag+3==data->trackflag){
|
|
|
|
|
curcon->flag |= CONSTRAINT_DISABLE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void test_bonelist_constraints (Object *owner, ListBase *list)
|
|
|
|
|
{
|
|
|
|
|
Bone *bone;
|
|
|
|
|
|
|
|
|
|
for (bone = list->first; bone; bone=bone->next) {
|
|
|
|
|
|
|
|
|
|
test_constraints(owner, bone->name);
|
|
|
|
|
test_bonelist_constraints (owner, &bone->childbase);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void object_test_constraints (Object *owner)
|
|
|
|
|
{
|
|
|
|
|
test_constraints(owner, "");
|
|
|
|
|
|
|
|
|
|
if(owner->type==OB_ARMATURE) {
|
|
|
|
|
bArmature *arm;
|
|
|
|
|
arm = get_armature(owner);
|
|
|
|
|
if (arm)
|
|
|
|
|
test_bonelist_constraints (owner, &arm->bonebase);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|