2011-10-10 09:38:02 +00:00
|
|
|
/*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/anim.c
|
|
|
|
|
* \ingroup bke
|
|
|
|
|
*/
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
|
2014-01-21 12:11:34 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include "BLI_listbase.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2012-10-13 15:44:50 +00:00
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2010-01-07 22:54:05 +00:00
|
|
|
#include "DNA_armature_types.h"
|
Orange branch: Revived hidden treasure, the Groups!
Previous experiment (in 2000) didn't satisfy, it had even some primitive
NLA option in groups... so, cleaned up the old code (removed most) and
integrated it back in a more useful way.
Usage:
- CTRL+G gives menu to add group, add to existing group, or remove from
groups.
- In Object buttons, a new (should become first) Panel was added, showing
not only Object "ID button" and Parent, but also the Groups the Object
Belongs to. These buttons also allow rename, assigning or removing.
- To indicate Objects are grouped, they're drawn in a (not theme yet, so
temporal?) green wire color.
- Use ALT+SHIFT mouse-select to (de)select an entire group
But, the real power of groups is in the following features:
-> Particle Force field and Guide control
In the "Particle Motion" Panel, you can indicate a Group name, this then
limits force fields or guides to members of that Group. (Note that layers
still work on top of that... not sure about that).
-> Light Groups
In the Material "Shaders" Panel, you can indicate a Group name to limit
lighting for the Material to lamps in this group. The Lights in a Group do
need to be 'visible' for the Scene to be rendered (as usual).
-> Group Duplicator
In the Object "Anim" Panel, you can set any Object (use Empty!) to
duplicate an entire Group. It will make copies of all Objects in that Group.
Also works for animated Objects, but it will copy the current positions or
deforms. Control over 'local timing' (so we can do Massive anims!) will be
added later.
(Note; this commit won't render Group duplicators yet, a fix in bf-blender
will enable that, next commit will sync)
-> Library Appending
In the SHIFT-F1 or SHIFT+F4 browsers, you can also find the Groups listed.
By appending or linking the Group itself, and use the Group Duplicator, you
now can animate and position linked Objects. The nice thing is that the
local saved file itself will only store the Group name that was linked, so
on a next file read, the Group Objects will be re-read as stored (changed)
in the Library file.
(Note; current implementation also "gives a base" to linked Group Objects,
to show them as Objects in the current Scene. Need that now for testing
purposes, but probably will be removed later).
-> Outliner
Outliner now shows Groups as optio too, nice to organize your data a bit too!
In General, Groups have a very good potential... for example, it could
become default for MetaBall Objects too (jiri, I can help you later on how
this works). All current 'layer relationships' in Blender should be dropped
in time, I guess...
2005-12-06 10:55:30 +00:00
|
|
|
#include "DNA_key_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
2008-09-23 06:26:48 +00:00
|
|
|
#include "BKE_curve.h"
|
2010-05-27 04:54:53 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_key.h"
|
Big commit with work on Groups & Libraries:
-> Any Group Duplicate now can get local timing and local NLA override. This
enables to control the entire animation system of the Group.
Two methods for this have been implemented.
1) The quick way: just give the duplicator a "Startframe" offset.
2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator
to override NLA/action of any Grouped Object.
For "Group NLA" to work, an ActionStrip needs to know which Object in a
group it controls. On adding a strip, the code checks if an Action was
already used by an Object in the Group, and assigns it automatic to that
Object.
You can also set this in the Nkey "Properties" panel for the strip.
Change in NLA: the SHIFT+A "Add strip" command now always adds strips to
the active Object. (It used to check where mouse was). This allows to add
NLA strips to Objects that didn't have actions/nla yet.
Important note: In Blender, duplicates are fully procedural and generated
on the fly for each redraw. This means that redraw speed equals to stepping
through frames, when using animated Duplicated Groups.
-> Recoded entire duplicator system
The old method was antique and clumsy, using globals and full temporal
copies of Object. The new system is nicer in control, faster, and since it
doesn't use temporal object copies anymore, it works better with Derived
Mesh and DisplayList and rendering.
By centralizing the code for duplicating, more options can be easier added.
Features to note:
- Duplicates now draw selected/unselected based on its Duplicator setting.
- Same goes for the drawtype (wire, solid, selection outline, etc)
- Duplicated Groups can be normally selected too
Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a
listing of all groups, allowing to add Group instances immediate.
-> Library System
- SHIFT+F4 data browse now shows the entire path for linked data
- Outliner draws Library Icons to denote linked data
- Outliner operation added: "Make Local" for library data.
- Outliner now also draws Groups in regular view, allowing to unlink too.
-> Fixes
- depsgraph missed signal update for bone-parented Objects
- on reading file, the entire database was tagged to "recalc" fully,
causing unnecessary slowdown on reading.
Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_object.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
#include "BKE_particle.h"
|
2010-01-07 22:54:05 +00:00
|
|
|
#include "BKE_scene.h"
|
2011-02-13 10:52:18 +00:00
|
|
|
#include "BKE_anim.h"
|
2011-11-12 04:40:53 +00:00
|
|
|
#include "BKE_report.h"
|
2002-11-25 12:02:15 +00:00
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
// XXX bad level call...
|
2009-03-30 07:28:37 +00:00
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
/* --------------------- */
|
|
|
|
|
/* forward declarations */
|
|
|
|
|
|
|
|
|
|
/* ******************************************************************** */
|
2012-07-03 19:09:07 +00:00
|
|
|
/* Animation Visualization */
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
|
2012-07-03 19:09:07 +00:00
|
|
|
/* Initialize the default settings for animation visualization */
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
void animviz_settings_init(bAnimVizSettings *avs)
|
|
|
|
|
{
|
|
|
|
|
/* sanity check */
|
|
|
|
|
if (avs == NULL)
|
|
|
|
|
return;
|
2012-07-06 23:56:59 +00:00
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
/* ghosting settings */
|
2012-05-06 17:22:54 +00:00
|
|
|
avs->ghost_bc = avs->ghost_ac = 10;
|
2012-07-06 23:56:59 +00:00
|
|
|
|
|
|
|
|
avs->ghost_sf = 1; /* xxx - take from scene instead? */
|
|
|
|
|
avs->ghost_ef = 250; /* xxx - take from scene instead? */
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
avs->ghost_step = 1;
|
2012-07-06 23:56:59 +00:00
|
|
|
|
|
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
/* path settings */
|
2012-05-06 17:22:54 +00:00
|
|
|
avs->path_bc = avs->path_ac = 10;
|
2012-07-06 23:56:59 +00:00
|
|
|
|
|
|
|
|
avs->path_sf = 1; /* xxx - take from scene instead? */
|
|
|
|
|
avs->path_ef = 250; /* xxx - take from scene instead? */
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
avs->path_viewflag = (MOTIONPATH_VIEW_KFRAS | MOTIONPATH_VIEW_KFNOS);
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
avs->path_step = 1;
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ------------------- */
|
|
|
|
|
|
|
|
|
|
/* Free the given motion path's cache */
|
|
|
|
|
void animviz_free_motionpath_cache(bMotionPath *mpath)
|
|
|
|
|
{
|
|
|
|
|
/* sanity check */
|
|
|
|
|
if (mpath == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* free the path if necessary */
|
|
|
|
|
if (mpath->points)
|
|
|
|
|
MEM_freeN(mpath->points);
|
|
|
|
|
|
|
|
|
|
/* reset the relevant parameters */
|
2012-05-06 17:22:54 +00:00
|
|
|
mpath->points = NULL;
|
|
|
|
|
mpath->length = 0;
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free the given motion path instance and its data
|
|
|
|
|
* NOTE: this frees the motion path given!
|
|
|
|
|
*/
|
|
|
|
|
void animviz_free_motionpath(bMotionPath *mpath)
|
|
|
|
|
{
|
|
|
|
|
/* sanity check */
|
|
|
|
|
if (mpath == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* free the cache first */
|
|
|
|
|
animviz_free_motionpath_cache(mpath);
|
|
|
|
|
|
|
|
|
|
/* now the instance itself */
|
|
|
|
|
MEM_freeN(mpath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ------------------- */
|
|
|
|
|
|
2014-05-29 21:16:04 +10:00
|
|
|
/**
|
|
|
|
|
* Setup motion paths for the given data.
|
|
|
|
|
* \note Only used when explicitly calculating paths on bones which may/may not be consider already
|
2012-05-01 13:10:36 +00:00
|
|
|
*
|
2014-05-29 21:16:04 +10:00
|
|
|
* \param scene Current scene (for frame ranges, etc.)
|
|
|
|
|
* \param ob Object to add paths for (must be provided)
|
|
|
|
|
* \param pchan Posechannel to add paths for (optional; if not provided, object-paths are assumed)
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
*/
|
2011-11-12 04:40:53 +00:00
|
|
|
bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Object *ob, bPoseChannel *pchan)
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
{
|
|
|
|
|
bAnimVizSettings *avs;
|
|
|
|
|
bMotionPath *mpath, **dst;
|
|
|
|
|
|
|
|
|
|
/* sanity checks */
|
|
|
|
|
if (ELEM(NULL, scene, ob))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* get destination data */
|
|
|
|
|
if (pchan) {
|
|
|
|
|
/* paths for posechannel - assume that posechannel belongs to the object */
|
2012-05-06 17:22:54 +00:00
|
|
|
avs = &ob->pose->avs;
|
|
|
|
|
dst = &pchan->mpath;
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* paths for object */
|
2012-05-06 17:22:54 +00:00
|
|
|
avs = &ob->avs;
|
|
|
|
|
dst = &ob->mpath;
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
}
|
2011-06-20 17:50:59 +00:00
|
|
|
|
|
|
|
|
/* avoid 0 size allocs */
|
2011-07-12 03:02:53 +00:00
|
|
|
if (avs->path_sf >= avs->path_ef) {
|
2011-11-12 04:40:53 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR,
|
2012-10-21 14:02:30 +00:00
|
|
|
"Motion path frame extents invalid for %s (%d to %d)%s",
|
2012-05-06 17:22:54 +00:00
|
|
|
(pchan) ? pchan->name : ob->id.name,
|
|
|
|
|
avs->path_sf, avs->path_ef,
|
2012-10-13 15:44:50 +00:00
|
|
|
(avs->path_sf == avs->path_ef) ? TIP_(", cannot have single-frame paths") : "");
|
2011-06-20 17:50:59 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 22:54:05 +00:00
|
|
|
/* if there is already a motionpath, just return that,
|
2012-05-01 13:10:36 +00:00
|
|
|
* provided it's settings are ok (saves extra free+alloc)
|
2010-01-07 22:54:05 +00:00
|
|
|
*/
|
|
|
|
|
if (*dst != NULL) {
|
2012-05-01 13:10:36 +00:00
|
|
|
int expected_length = avs->path_ef - avs->path_sf;
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
mpath = *dst;
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
|
2012-05-01 13:10:36 +00:00
|
|
|
/* path is "valid" if length is valid, but must also be of the same length as is being requested */
|
|
|
|
|
if ((mpath->start_frame != mpath->end_frame) && (mpath->length > 0)) {
|
|
|
|
|
/* outer check ensures that we have some curve data for this path */
|
|
|
|
|
if (mpath->length == expected_length) {
|
|
|
|
|
/* return/use this as it is already valid length */
|
|
|
|
|
return mpath;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* clear the existing path (as the range has changed), and reallocate below */
|
2012-05-01 16:19:13 +00:00
|
|
|
animviz_free_motionpath_cache(mpath);
|
2012-05-01 13:10:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-01-07 22:54:05 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* create a new motionpath, and assign it */
|
2012-05-06 17:22:54 +00:00
|
|
|
mpath = MEM_callocN(sizeof(bMotionPath), "bMotionPath");
|
|
|
|
|
*dst = mpath;
|
2010-01-07 22:54:05 +00:00
|
|
|
}
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
|
|
|
|
|
/* set settings from the viz settings */
|
2012-05-06 17:22:54 +00:00
|
|
|
mpath->start_frame = avs->path_sf;
|
|
|
|
|
mpath->end_frame = avs->path_ef;
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
mpath->length = mpath->end_frame - mpath->start_frame;
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
|
|
|
|
|
if (avs->path_bakeflag & MOTIONPATH_BAKE_HEADS)
|
|
|
|
|
mpath->flag |= MOTIONPATH_FLAG_BHEAD;
|
2010-05-20 12:34:32 +00:00
|
|
|
else
|
|
|
|
|
mpath->flag &= ~MOTIONPATH_FLAG_BHEAD;
|
2017-01-20 16:49:14 +01:00
|
|
|
|
|
|
|
|
/* set default custom values */
|
|
|
|
|
mpath->color[0] = 1.0; /* Red */
|
|
|
|
|
mpath->color[1] = 0.0;
|
|
|
|
|
mpath->color[2] = 0.0;
|
|
|
|
|
|
|
|
|
|
mpath->line_thickness = 1;
|
|
|
|
|
mpath->flag |= MOTIONPATH_FLAG_LINES; /* draw lines by default */
|
|
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
/* allocate a cache */
|
2012-05-06 17:22:54 +00:00
|
|
|
mpath->points = MEM_callocN(sizeof(bMotionPathVert) * mpath->length, "bMotionPathVerts");
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
|
2010-03-11 11:15:25 +00:00
|
|
|
/* tag viz settings as currently having some path(s) which use it */
|
|
|
|
|
avs->path_bakeflag |= MOTIONPATH_BAKE_HAS_PATHS;
|
|
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
/* return it */
|
|
|
|
|
return mpath;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 22:54:05 +00:00
|
|
|
/* ------------------- */
|
|
|
|
|
|
|
|
|
|
/* Motion path needing to be baked (mpt) */
|
|
|
|
|
typedef struct MPathTarget {
|
|
|
|
|
struct MPathTarget *next, *prev;
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
bMotionPath *mpath; /* motion path in question */
|
2010-01-07 22:54:05 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
Object *ob; /* source object */
|
|
|
|
|
bPoseChannel *pchan; /* source posechannel (if applicable) */
|
2010-01-07 22:54:05 +00:00
|
|
|
} MPathTarget;
|
|
|
|
|
|
|
|
|
|
/* ........ */
|
|
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* get list of motion paths to be baked for the given object
|
2012-05-06 17:22:54 +00:00
|
|
|
* - assumes the given list is ready to be used
|
2010-01-19 11:31:49 +00:00
|
|
|
*/
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: it would be nice in future to be able to update objects dependent on these bones too? */
|
2010-01-19 11:31:49 +00:00
|
|
|
void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
|
2010-01-07 22:54:05 +00:00
|
|
|
{
|
|
|
|
|
MPathTarget *mpt;
|
|
|
|
|
|
|
|
|
|
/* object itself first */
|
|
|
|
|
if ((ob->avs.recalc & ANIMVIZ_RECALC_PATHS) && (ob->mpath)) {
|
|
|
|
|
/* new target for object */
|
2012-05-06 17:22:54 +00:00
|
|
|
mpt = MEM_callocN(sizeof(MPathTarget), "MPathTarget Ob");
|
2010-01-07 22:54:05 +00:00
|
|
|
BLI_addtail(targets, mpt);
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
mpt->mpath = ob->mpath;
|
|
|
|
|
mpt->ob = ob;
|
2010-01-07 22:54:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* bones */
|
|
|
|
|
if ((ob->pose) && (ob->pose->avs.recalc & ANIMVIZ_RECALC_PATHS)) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bArmature *arm = ob->data;
|
2010-01-07 22:54:05 +00:00
|
|
|
bPoseChannel *pchan;
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
2010-01-07 22:54:05 +00:00
|
|
|
if ((pchan->bone) && (arm->layer & pchan->bone->layer) && (pchan->mpath)) {
|
|
|
|
|
/* new target for bone */
|
2012-05-06 17:22:54 +00:00
|
|
|
mpt = MEM_callocN(sizeof(MPathTarget), "MPathTarget PoseBone");
|
2010-01-07 22:54:05 +00:00
|
|
|
BLI_addtail(targets, mpt);
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
mpt->mpath = pchan->mpath;
|
|
|
|
|
mpt->ob = ob;
|
|
|
|
|
mpt->pchan = pchan;
|
2010-01-07 22:54:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* ........ */
|
|
|
|
|
|
2012-08-24 23:22:34 +00:00
|
|
|
/* Note on evaluation optimizations:
|
2013-10-31 14:10:01 +00:00
|
|
|
* Optimization's currently used here play tricks with the depsgraph in order to try and
|
2010-05-21 12:17:34 +00:00
|
|
|
* evaluate as few objects as strictly necessary to get nicer performance under standard
|
|
|
|
|
* production conditions. For those people who really need the accurate version,
|
2010-05-21 13:01:18 +00:00
|
|
|
* disable the ifdef (i.e. 1 -> 0) and comment out the call to motionpaths_calc_optimise_depsgraph()
|
2010-05-21 12:17:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* tweak the object ordering to trick depsgraph into making MotionPath calculations run faster */
|
|
|
|
|
static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
|
|
|
|
|
{
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
BaseLegacy *base, *baseNext;
|
2010-05-21 12:17:34 +00:00
|
|
|
MPathTarget *mpt;
|
|
|
|
|
|
|
|
|
|
/* make sure our temp-tag isn't already in use */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (base = scene->base.first; base; base = base->next)
|
2010-05-21 12:17:34 +00:00
|
|
|
base->object->flag &= ~BA_TEMP_TAG;
|
|
|
|
|
|
|
|
|
|
/* for each target, dump its object to the start of the list if it wasn't moved already */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (mpt = targets->first; mpt; mpt = mpt->next) {
|
|
|
|
|
for (base = scene->base.first; base; base = baseNext) {
|
2010-05-21 12:17:34 +00:00
|
|
|
baseNext = base->next;
|
|
|
|
|
|
|
|
|
|
if ((base->object == mpt->ob) && !(mpt->ob->flag & BA_TEMP_TAG)) {
|
|
|
|
|
BLI_remlink(&scene->base, base);
|
|
|
|
|
BLI_addhead(&scene->base, base);
|
|
|
|
|
|
|
|
|
|
mpt->ob->flag |= BA_TEMP_TAG;
|
2013-01-29 01:23:29 +00:00
|
|
|
|
2012-07-06 23:56:59 +00:00
|
|
|
/* we really don't need to continue anymore once this happens, but this line might really 'break' */
|
|
|
|
|
break;
|
2010-05-21 12:17:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* "brew me a list that's sorted a bit faster now depsy" */
|
2013-02-21 19:33:04 +00:00
|
|
|
DAG_scene_relations_rebuild(G.main, scene);
|
2010-05-21 12:17:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* update scene for current frame */
|
|
|
|
|
static void motionpaths_calc_update_scene(Scene *scene)
|
|
|
|
|
{
|
2012-08-24 23:22:34 +00:00
|
|
|
#if 1 // 'production' optimizations always on
|
2013-02-23 23:04:10 +00:00
|
|
|
/* rigid body simulation needs complete update to work correctly for now */
|
|
|
|
|
/* RB_TODO investigate if we could avoid updating everything */
|
|
|
|
|
if (BKE_scene_check_rigidbody_active(scene)) {
|
2013-12-26 17:24:42 +06:00
|
|
|
BKE_scene_update_for_newframe(G.main->eval_ctx, G.main, scene, scene->lay);
|
2010-05-21 12:17:34 +00:00
|
|
|
}
|
2013-02-23 23:04:10 +00:00
|
|
|
else { /* otherwise we can optimize by restricting updates */
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
BaseLegacy *base, *last = NULL;
|
2010-05-21 12:17:34 +00:00
|
|
|
|
2013-02-23 23:04:10 +00:00
|
|
|
/* only stuff that moves or needs display still */
|
2014-02-25 15:44:39 +06:00
|
|
|
DAG_scene_update_flags(G.main, scene, scene->lay, true, false);
|
2013-02-23 23:04:10 +00:00
|
|
|
|
|
|
|
|
/* find the last object with the tag
|
|
|
|
|
* - all those afterwards are assumed to not be relevant for our calculations
|
|
|
|
|
*/
|
|
|
|
|
/* optimize further by moving out... */
|
|
|
|
|
for (base = scene->base.first; base; base = base->next) {
|
|
|
|
|
if (base->object->flag & BA_TEMP_TAG)
|
|
|
|
|
last = base;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* perform updates for tagged objects */
|
|
|
|
|
/* XXX: this will break if rigs depend on scene or other data that
|
|
|
|
|
* is animated but not attached to/updatable from objects */
|
|
|
|
|
for (base = scene->base.first; base; base = base->next) {
|
|
|
|
|
/* update this object */
|
2013-12-26 17:24:42 +06:00
|
|
|
BKE_object_handle_update(G.main->eval_ctx, scene, base->object);
|
2013-02-23 23:04:10 +00:00
|
|
|
|
|
|
|
|
/* if this is the last one we need to update, let's stop to save some time */
|
|
|
|
|
if (base == last)
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-05-21 12:17:34 +00:00
|
|
|
}
|
|
|
|
|
#else // original, 'always correct' version
|
2016-06-19 06:25:54 +10:00
|
|
|
/* do all updates
|
|
|
|
|
* - if this is too slow, resort to using a more efficient way
|
|
|
|
|
* that doesn't force complete update, but for now, this is the
|
|
|
|
|
* most accurate way!
|
|
|
|
|
*/
|
2013-12-26 17:24:42 +06:00
|
|
|
BKE_scene_update_for_newframe(G.main->eval_ctx, G.main, scene, scene->lay); /* XXX this is the best way we can get anything moving */
|
2010-05-21 12:17:34 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ........ */
|
|
|
|
|
|
2010-01-07 22:54:05 +00:00
|
|
|
/* perform baking for the targets on the current frame */
|
|
|
|
|
static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
|
|
|
|
|
{
|
|
|
|
|
MPathTarget *mpt;
|
|
|
|
|
|
|
|
|
|
/* for each target, check if it can be baked on the current frame */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (mpt = targets->first; mpt; mpt = mpt->next) {
|
|
|
|
|
bMotionPath *mpath = mpt->mpath;
|
2010-01-07 22:54:05 +00:00
|
|
|
bMotionPathVert *mpv;
|
|
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* current frame must be within the range the cache works for
|
|
|
|
|
* - is inclusive of the first frame, but not the last otherwise we get buffer overruns
|
|
|
|
|
*/
|
|
|
|
|
if ((CFRA < mpath->start_frame) || (CFRA >= mpath->end_frame))
|
2010-01-07 22:54:05 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* get the relevant cache vert to write to */
|
2012-05-06 17:22:54 +00:00
|
|
|
mpv = mpath->points + (CFRA - mpath->start_frame);
|
2010-01-07 22:54:05 +00:00
|
|
|
|
|
|
|
|
/* pose-channel or object path baking? */
|
|
|
|
|
if (mpt->pchan) {
|
|
|
|
|
/* heads or tails */
|
|
|
|
|
if (mpath->flag & MOTIONPATH_FLAG_BHEAD) {
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(mpv->co, mpt->pchan->pose_head);
|
2010-01-07 22:54:05 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(mpv->co, mpt->pchan->pose_tail);
|
2010-01-07 22:54:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* result must be in worldspace */
|
|
|
|
|
mul_m4_v3(mpt->ob->obmat, mpv->co);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* worldspace object location */
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(mpv->co, mpt->ob->obmat[3]);
|
2010-01-07 22:54:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
/* Perform baking of the given object's and/or its bones' transforms to motion paths
|
|
|
|
|
* - scene: current scene
|
|
|
|
|
* - ob: object whose flagged motionpaths should get calculated
|
2012-07-06 23:56:59 +00:00
|
|
|
* - recalc: whether we need to
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
*/
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: include reports pointer? */
|
2010-01-19 11:31:49 +00:00
|
|
|
void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
{
|
2010-01-07 22:54:05 +00:00
|
|
|
MPathTarget *mpt;
|
|
|
|
|
int sfra, efra;
|
|
|
|
|
int cfra;
|
|
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* sanity check */
|
|
|
|
|
if (ELEM(NULL, targets, targets->first))
|
2010-01-07 22:54:05 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* set frame values */
|
|
|
|
|
cfra = CFRA;
|
|
|
|
|
sfra = efra = cfra;
|
|
|
|
|
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: this method could be improved...
|
|
|
|
|
* 1) max range for standard baking
|
|
|
|
|
* 2) minimum range for recalc baking (i.e. between keyframes, but how?) */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (mpt = targets->first; mpt; mpt = mpt->next) {
|
2010-01-07 22:54:05 +00:00
|
|
|
/* try to increase area to do (only as much as needed) */
|
2012-05-06 17:22:54 +00:00
|
|
|
sfra = MIN2(sfra, mpt->mpath->start_frame);
|
|
|
|
|
efra = MAX2(efra, mpt->mpath->end_frame);
|
2010-01-07 22:54:05 +00:00
|
|
|
}
|
|
|
|
|
if (efra <= sfra) return;
|
|
|
|
|
|
2012-03-02 16:05:54 +00:00
|
|
|
/* optimize the depsgraph for faster updates */
|
2012-08-24 23:22:34 +00:00
|
|
|
/* TODO: whether this is used should depend on some setting for the level of optimizations used */
|
2010-05-21 12:17:34 +00:00
|
|
|
motionpaths_calc_optimise_depsgraph(scene, targets);
|
|
|
|
|
|
2010-01-07 22:54:05 +00:00
|
|
|
/* calculate path over requested range */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (CFRA = sfra; CFRA <= efra; CFRA++) {
|
2010-05-21 12:17:34 +00:00
|
|
|
/* update relevant data for new frame */
|
|
|
|
|
motionpaths_calc_update_scene(scene);
|
2010-01-07 22:54:05 +00:00
|
|
|
|
|
|
|
|
/* perform baking for targets */
|
2010-01-19 11:31:49 +00:00
|
|
|
motionpaths_calc_bake_targets(scene, targets);
|
2010-01-07 22:54:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* reset original environment */
|
2012-05-06 17:22:54 +00:00
|
|
|
CFRA = cfra;
|
2010-05-21 12:17:34 +00:00
|
|
|
motionpaths_calc_update_scene(scene);
|
2010-01-07 22:54:05 +00:00
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* clear recalc flags from targets */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (mpt = targets->first; mpt; mpt = mpt->next) {
|
2010-01-19 11:31:49 +00:00
|
|
|
bAnimVizSettings *avs;
|
|
|
|
|
|
|
|
|
|
/* get pointer to animviz settings for each target */
|
|
|
|
|
if (mpt->pchan)
|
2012-05-06 17:22:54 +00:00
|
|
|
avs = &mpt->ob->pose->avs;
|
2012-05-19 13:55:54 +00:00
|
|
|
else
|
2012-05-06 17:22:54 +00:00
|
|
|
avs = &mpt->ob->avs;
|
2010-01-19 11:31:49 +00:00
|
|
|
|
|
|
|
|
/* clear the flag requesting recalculation of targets */
|
|
|
|
|
avs->recalc &= ~ANIMVIZ_RECALC_PATHS;
|
|
|
|
|
}
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ******************************************************************** */
|
|
|
|
|
/* Curve Paths - for curve deforms and/or curve following */
|
|
|
|
|
|
|
|
|
|
/* free curve path data
|
|
|
|
|
* NOTE: frees the path itself!
|
2012-03-03 11:45:08 +00:00
|
|
|
* NOTE: this is increasingly inaccurate with non-uniform BevPoint subdivisions [#24633]
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
*/
|
2002-10-12 11:37:38 +00:00
|
|
|
void free_path(Path *path)
|
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (path->data) MEM_freeN(path->data);
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(path);
|
|
|
|
|
}
|
|
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
/* calculate a curve-deform path for a curve
|
2012-05-06 17:22:54 +00:00
|
|
|
* - only called from displist.c -> do_makeDispListCurveTypes
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
*/
|
2013-08-19 09:36:40 +00:00
|
|
|
void calc_curvepath(Object *ob, ListBase *nurbs)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
BevList *bl;
|
2009-09-16 17:43:09 +00:00
|
|
|
BevPoint *bevp, *bevpn, *bevpfirst, *bevplast;
|
|
|
|
|
PathPoint *pp;
|
2002-10-12 11:37:38 +00:00
|
|
|
Nurb *nu;
|
|
|
|
|
Path *path;
|
2009-09-16 17:43:09 +00:00
|
|
|
float *fp, *dist, *maxdist, xyz[3];
|
2012-05-06 17:22:54 +00:00
|
|
|
float fac, d = 0, fac1, fac2;
|
|
|
|
|
int a, tot, cycl = 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-25 15:48:11 +00:00
|
|
|
/* in a path vertices are with equal differences: path->len = number of verts */
|
|
|
|
|
/* NOW WITH BEVELCURVE!!! */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-09-03 22:53:34 +00:00
|
|
|
if (ob == NULL || ob->type != OB_CURVE) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-07-25 11:57:36 +00:00
|
|
|
|
2013-08-19 09:25:24 +00:00
|
|
|
if (ob->curve_cache->path) free_path(ob->curve_cache->path);
|
|
|
|
|
ob->curve_cache->path = NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-09-03 22:53:34 +00:00
|
|
|
/* weak! can only use first curve */
|
2013-08-19 09:25:24 +00:00
|
|
|
bl = ob->curve_cache->bev.first;
|
2012-09-03 22:53:34 +00:00
|
|
|
if (bl == NULL || !bl->nr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nu = nurbs->first;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-08-19 09:25:24 +00:00
|
|
|
ob->curve_cache->path = path = MEM_callocN(sizeof(Path), "calc_curvepath");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-25 15:48:11 +00:00
|
|
|
/* if POLY: last vertice != first vertice */
|
2012-05-06 17:22:54 +00:00
|
|
|
cycl = (bl->poly != -1);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-09-03 22:53:34 +00:00
|
|
|
tot = cycl ? bl->nr : bl->nr - 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
path->len = tot + 1;
|
2006-11-21 13:07:16 +00:00
|
|
|
/* exception: vector handle paths and polygon paths should be subdivided at least a factor resolu */
|
2012-09-03 22:53:34 +00:00
|
|
|
if (path->len < nu->resolu * SEGMENTSU(nu)) {
|
|
|
|
|
path->len = nu->resolu * SEGMENTSU(nu);
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-10-12 02:19:37 +00:00
|
|
|
dist = (float *)MEM_mallocN(sizeof(float) * (tot + 1), "calcpathdist");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* all lengths in *dist */
|
2014-06-15 14:23:23 +10:00
|
|
|
bevp = bevpfirst = bl->bevpoints;
|
2012-05-06 17:22:54 +00:00
|
|
|
fp = dist;
|
2012-09-03 22:53:34 +00:00
|
|
|
*fp = 0.0f;
|
2012-05-06 17:22:54 +00:00
|
|
|
for (a = 0; a < tot; a++) {
|
2002-10-12 11:37:38 +00:00
|
|
|
fp++;
|
2012-05-06 17:22:54 +00:00
|
|
|
if (cycl && a == tot - 1)
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec);
|
2009-09-16 17:43:09 +00:00
|
|
|
else
|
2012-05-06 17:22:54 +00:00
|
|
|
sub_v3_v3v3(xyz, (bevp + 1)->vec, bevp->vec);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
*fp = *(fp - 1) + len_v3(xyz);
|
2002-10-12 11:37:38 +00:00
|
|
|
bevp++;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
path->totdist = *fp;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the path verts in path->data */
|
|
|
|
|
/* now also with TILT value */
|
|
|
|
|
pp = path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint) * path->len, "pathdata");
|
|
|
|
|
|
|
|
|
|
bevp = bevpfirst;
|
|
|
|
|
bevpn = bevp + 1;
|
|
|
|
|
bevplast = bevpfirst + (bl->nr - 1);
|
2014-04-11 17:40:07 +06:00
|
|
|
if (UNLIKELY(bevpn > bevplast)) {
|
|
|
|
|
bevpn = cycl ? bevpfirst : bevplast;
|
|
|
|
|
}
|
2012-05-06 17:22:54 +00:00
|
|
|
fp = dist + 1;
|
|
|
|
|
maxdist = dist + tot;
|
|
|
|
|
fac = 1.0f / ((float)path->len - 1.0f);
|
|
|
|
|
fac = fac * path->totdist;
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
for (a = 0; a < path->len; a++) {
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
d = ((float)a) * fac;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-25 15:48:11 +00:00
|
|
|
/* we're looking for location (distance) 'd' in the array */
|
2014-04-11 17:40:07 +06:00
|
|
|
if (LIKELY(tot > 0)) {
|
|
|
|
|
while ((fp < maxdist) && (d >= *fp)) {
|
|
|
|
|
fp++;
|
|
|
|
|
if (bevp < bevplast) bevp++;
|
|
|
|
|
bevpn = bevp + 1;
|
|
|
|
|
if (UNLIKELY(bevpn > bevplast)) {
|
|
|
|
|
bevpn = cycl ? bevpfirst : bevplast;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2014-04-11 17:40:07 +06:00
|
|
|
|
|
|
|
|
fac1 = (*(fp) - d) / (*(fp) - *(fp - 1));
|
|
|
|
|
fac2 = 1.0f - fac1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
fac1 = 1.0f;
|
2014-05-04 12:36:44 +10:00
|
|
|
fac2 = 0.0f;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2012-09-03 22:53:34 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2);
|
2012-09-03 22:53:34 +00:00
|
|
|
pp->vec[3] = fac1 * bevp->alfa + fac2 * bevpn->alfa;
|
2012-05-06 17:22:54 +00:00
|
|
|
pp->radius = fac1 * bevp->radius + fac2 * bevpn->radius;
|
|
|
|
|
pp->weight = fac1 * bevp->weight + fac2 * bevpn->weight;
|
2009-11-10 20:43:45 +00:00
|
|
|
interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2);
|
|
|
|
|
normalize_qt(pp->quat);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
pp++;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(dist);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 22:53:34 +00:00
|
|
|
static int interval_test(const int min, const int max, int p1, const int cycl)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (cycl) {
|
2013-09-05 20:54:32 +00:00
|
|
|
p1 = mod_i(p1 - min, (max - min + 1)) + min;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-09-03 22:53:34 +00:00
|
|
|
if (p1 < min) p1 = min;
|
2012-05-06 17:22:54 +00:00
|
|
|
else if (p1 > max) p1 = max;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
return p1;
|
|
|
|
|
}
|
|
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
|
2012-01-31 20:38:03 +00:00
|
|
|
/* calculate the deformation implied by the curve path at a given parametric position,
|
|
|
|
|
* and returns whether this operation succeeded.
|
|
|
|
|
*
|
|
|
|
|
* note: ctime is normalized range <0-1>
|
|
|
|
|
*
|
|
|
|
|
* returns OK: 1/0
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
*/
|
2012-01-31 20:38:03 +00:00
|
|
|
int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float quat[4], float *radius, float *weight)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
Curve *cu;
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BevList *bl;
|
|
|
|
|
Path *path;
|
2009-09-16 17:43:09 +00:00
|
|
|
PathPoint *pp, *p0, *p1, *p2, *p3;
|
|
|
|
|
float fac;
|
2002-10-12 11:37:38 +00:00
|
|
|
float data[4];
|
2012-05-06 17:22:54 +00:00
|
|
|
int cycl = 0, s0, s1, s2, s3;
|
2013-04-15 12:04:55 +00:00
|
|
|
ListBase *nurbs;
|
2004-09-14 19:03:11 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
if (ob == NULL || ob->type != OB_CURVE) return 0;
|
|
|
|
|
cu = ob->data;
|
2013-08-19 09:25:24 +00:00
|
|
|
if (ob->curve_cache == NULL || ob->curve_cache->path == NULL || ob->curve_cache->path->data == NULL) {
|
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
|
|
|
printf("no path!\n");
|
2009-05-23 03:24:15 +00:00
|
|
|
return 0;
|
2004-09-14 19:03:11 +00:00
|
|
|
}
|
2013-08-19 09:25:24 +00:00
|
|
|
path = ob->curve_cache->path;
|
2012-05-06 17:22:54 +00:00
|
|
|
pp = path->data;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-25 15:48:11 +00:00
|
|
|
/* test for cyclic */
|
2013-08-19 09:25:24 +00:00
|
|
|
bl = ob->curve_cache->bev.first;
|
2009-05-23 03:24:15 +00:00
|
|
|
if (!bl) return 0;
|
2007-12-03 22:42:48 +00:00
|
|
|
if (!bl->nr) return 0;
|
2012-05-06 17:22:54 +00:00
|
|
|
if (bl->poly > -1) cycl = 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2014-10-23 16:29:40 +02:00
|
|
|
/* values below zero for non-cyclic curves give strange results */
|
|
|
|
|
BLI_assert(cycl || ctime >= 0.0f);
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
ctime *= (path->len - 1);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
s1 = (int)floor(ctime);
|
|
|
|
|
fac = (float)(s1 + 1) - ctime;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-25 15:48:11 +00:00
|
|
|
/* path->len is corected for cyclic */
|
2012-05-06 17:22:54 +00:00
|
|
|
s0 = interval_test(0, path->len - 1 - cycl, s1 - 1, cycl);
|
|
|
|
|
s1 = interval_test(0, path->len - 1 - cycl, s1, cycl);
|
|
|
|
|
s2 = interval_test(0, path->len - 1 - cycl, s1 + 1, cycl);
|
|
|
|
|
s3 = interval_test(0, path->len - 1 - cycl, s1 + 2, cycl);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
p0 = pp + s0;
|
|
|
|
|
p1 = pp + s1;
|
|
|
|
|
p2 = pp + s2;
|
|
|
|
|
p3 = pp + s3;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2014-01-10 01:45:53 +06:00
|
|
|
/* NOTE: commented out for follow constraint
|
|
|
|
|
*
|
|
|
|
|
* If it's ever be uncommented watch out for curve_deform_verts()
|
|
|
|
|
* which used to temporary set CU_FOLLOW flag for the curve and no
|
|
|
|
|
* longer does it (because of threading issues of such a thing.
|
|
|
|
|
*/
|
2012-04-21 12:51:47 +00:00
|
|
|
//if (cu->flag & CU_FOLLOW) {
|
2009-11-21 14:35:28 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
key_curve_tangent_weights(1.0f - fac, data, KEY_BSPLINE);
|
2009-11-21 14:35:28 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
interp_v3_v3v3v3v3(dir, p0->vec, p1->vec, p2->vec, p3->vec, data);
|
2009-11-21 14:35:28 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* make compatible with vectoquat */
|
|
|
|
|
negate_v3(dir);
|
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
|
|
|
//}
|
2013-04-15 12:04:55 +00:00
|
|
|
|
|
|
|
|
nurbs = BKE_curve_editNurbs_get(cu);
|
|
|
|
|
if (!nurbs)
|
|
|
|
|
nurbs = &cu->nurb;
|
|
|
|
|
nu = nurbs->first;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-25 15:48:11 +00:00
|
|
|
/* make sure that first and last frame are included in the vectors here */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (nu->type == CU_POLY) key_curve_position_weights(1.0f - fac, data, KEY_LINEAR);
|
|
|
|
|
else if (nu->type == CU_BEZIER) key_curve_position_weights(1.0f - fac, data, KEY_LINEAR);
|
|
|
|
|
else if (s0 == s1 || p2 == p3) key_curve_position_weights(1.0f - fac, data, KEY_CARDINAL);
|
|
|
|
|
else key_curve_position_weights(1.0f - fac, data, KEY_BSPLINE);
|
2009-09-16 17:43:09 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
vec[0] = data[0] * p0->vec[0] + data[1] * p1->vec[0] + data[2] * p2->vec[0] + data[3] * p3->vec[0]; /* X */
|
|
|
|
|
vec[1] = data[0] * p0->vec[1] + data[1] * p1->vec[1] + data[2] * p2->vec[1] + data[3] * p3->vec[1]; /* Y */
|
|
|
|
|
vec[2] = data[0] * p0->vec[2] + data[1] * p1->vec[2] + data[2] * p2->vec[2] + data[3] * p3->vec[2]; /* Z */
|
|
|
|
|
vec[3] = data[0] * p0->vec[3] + data[1] * p1->vec[3] + data[2] * p2->vec[3] + data[3] * p3->vec[3]; /* Tilt, should not be needed since we have quat still used */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
if (quat) {
|
2010-09-20 09:09:00 +00:00
|
|
|
float totfac, q1[4], q2[4];
|
2009-09-16 17:43:09 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
totfac = data[0] + data[3];
|
|
|
|
|
if (totfac > FLT_EPSILON) interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac);
|
|
|
|
|
else copy_qt_qt(q1, p1->quat);
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
totfac = data[1] + data[2];
|
|
|
|
|
if (totfac > FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac);
|
|
|
|
|
else copy_qt_qt(q2, p3->quat);
|
2009-09-16 17:43:09 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
totfac = data[0] + data[1] + data[2] + data[3];
|
|
|
|
|
if (totfac > FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1] + data[2]) / totfac);
|
|
|
|
|
else copy_qt_qt(quat, q2);
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (radius)
|
2012-05-06 17:22:54 +00:00
|
|
|
*radius = data[0] * p0->radius + data[1] * p1->radius + data[2] * p2->radius + data[3] * p3->radius;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (weight)
|
2012-05-06 17:22:54 +00:00
|
|
|
*weight = data[0] * p0->weight + data[1] * p1->weight + data[2] * p2->weight + data[3] * p3->weight;
|
2010-04-21 11:59:47 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|