2011-10-10 09:38:02 +00:00
|
|
|
/*
|
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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
2011-02-27 20:40:57 +00:00
|
|
|
*/
|
|
|
|
|
|
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
|
|
|
|
2020-04-03 11:35:04 +02:00
|
|
|
#include <float.h>
|
2014-01-21 12:11:34 +01:00
|
|
|
|
2020-04-03 11:35:04 +02:00
|
|
|
#include "DNA_curve_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"
|
2020-04-03 11:35:04 +02:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_math_vector.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2020-04-03 11:35:04 +02:00
|
|
|
#include "BKE_anim_path.h"
|
2008-09-23 06:26:48 +00:00
|
|
|
#include "BKE_curve.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_key.h"
|
2018-06-01 16:38:21 +02:00
|
|
|
|
2019-02-01 12:44:19 +11:00
|
|
|
#include "CLG_log.h"
|
|
|
|
|
|
|
|
|
|
static CLG_LogRef LOG = {"bke.anim"};
|
|
|
|
|
|
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 */
|
|
|
|
|
|
2020-06-13 15:16:18 +10:00
|
|
|
/**
|
|
|
|
|
* Free curve path data
|
|
|
|
|
*
|
|
|
|
|
* \note Frees the path itself!
|
|
|
|
|
* \note This is increasingly inaccurate with non-uniform #BevPoint subdivisions T24633.
|
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)
|
|
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (path->data) {
|
2019-04-17 06:17:24 +02:00
|
|
|
MEM_freeN(path->data);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
MEM_freeN(path);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-13 15:16:18 +10:00
|
|
|
/**
|
|
|
|
|
* Calculate a curve-deform path for a curve
|
|
|
|
|
* - 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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BevList *bl;
|
|
|
|
|
BevPoint *bevp, *bevpn, *bevpfirst, *bevplast;
|
|
|
|
|
PathPoint *pp;
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
Path *path;
|
|
|
|
|
float *fp, *dist, *maxdist, xyz[3];
|
|
|
|
|
float fac, d = 0, fac1, fac2;
|
|
|
|
|
int a, tot, cycl = 0;
|
|
|
|
|
|
|
|
|
|
/* in a path vertices are with equal differences: path->len = number of verts */
|
|
|
|
|
/* NOW WITH BEVELCURVE!!! */
|
|
|
|
|
|
|
|
|
|
if (ob == NULL || ob->type != OB_CURVE) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ob->runtime.curve_cache->path) {
|
2019-04-17 06:17:24 +02:00
|
|
|
free_path(ob->runtime.curve_cache->path);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
ob->runtime.curve_cache->path = NULL;
|
|
|
|
|
|
|
|
|
|
/* weak! can only use first curve */
|
|
|
|
|
bl = ob->runtime.curve_cache->bev.first;
|
|
|
|
|
if (bl == NULL || !bl->nr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nu = nurbs->first;
|
|
|
|
|
|
|
|
|
|
ob->runtime.curve_cache->path = path = MEM_callocN(sizeof(Path), "calc_curvepath");
|
|
|
|
|
|
|
|
|
|
/* if POLY: last vertice != first vertice */
|
|
|
|
|
cycl = (bl->poly != -1);
|
|
|
|
|
|
|
|
|
|
tot = cycl ? bl->nr : bl->nr - 1;
|
|
|
|
|
|
|
|
|
|
path->len = tot + 1;
|
2019-04-27 12:07:07 +10:00
|
|
|
/* Exception: vector handle paths and polygon paths should be subdivided
|
|
|
|
|
* at least a factor resolution. */
|
2019-04-17 06:17:24 +02:00
|
|
|
if (path->len < nu->resolu * SEGMENTSU(nu)) {
|
|
|
|
|
path->len = nu->resolu * SEGMENTSU(nu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dist = (float *)MEM_mallocN(sizeof(float) * (tot + 1), "calcpathdist");
|
|
|
|
|
|
|
|
|
|
/* all lengths in *dist */
|
|
|
|
|
bevp = bevpfirst = bl->bevpoints;
|
|
|
|
|
fp = dist;
|
|
|
|
|
*fp = 0.0f;
|
|
|
|
|
for (a = 0; a < tot; a++) {
|
|
|
|
|
fp++;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (cycl && a == tot - 1) {
|
2019-04-17 06:17:24 +02:00
|
|
|
sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
sub_v3_v3v3(xyz, (bevp + 1)->vec, bevp->vec);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
*fp = *(fp - 1) + len_v3(xyz);
|
|
|
|
|
bevp++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path->totdist = *fp;
|
|
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
if (UNLIKELY(bevpn > bevplast)) {
|
|
|
|
|
bevpn = cycl ? bevpfirst : bevplast;
|
|
|
|
|
}
|
|
|
|
|
fp = dist + 1;
|
|
|
|
|
maxdist = dist + tot;
|
|
|
|
|
fac = 1.0f / ((float)path->len - 1.0f);
|
|
|
|
|
fac = fac * path->totdist;
|
|
|
|
|
|
|
|
|
|
for (a = 0; a < path->len; a++) {
|
|
|
|
|
|
|
|
|
|
d = ((float)a) * fac;
|
|
|
|
|
|
|
|
|
|
/* we're looking for location (distance) 'd' in the array */
|
|
|
|
|
if (LIKELY(tot > 0)) {
|
|
|
|
|
while ((fp < maxdist) && (d >= *fp)) {
|
|
|
|
|
fp++;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (bevp < bevplast) {
|
2019-04-17 06:17:24 +02:00
|
|
|
bevp++;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
bevpn = bevp + 1;
|
|
|
|
|
if (UNLIKELY(bevpn > bevplast)) {
|
|
|
|
|
bevpn = cycl ? bevpfirst : bevplast;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fac1 = (*(fp)-d) / (*(fp) - *(fp - 1));
|
|
|
|
|
fac2 = 1.0f - fac1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
fac1 = 1.0f;
|
|
|
|
|
fac2 = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2);
|
|
|
|
|
pp->vec[3] = fac1 * bevp->tilt + fac2 * bevpn->tilt;
|
|
|
|
|
pp->radius = fac1 * bevp->radius + fac2 * bevpn->radius;
|
|
|
|
|
pp->weight = fac1 * bevp->weight + fac2 * bevpn->weight;
|
|
|
|
|
interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2);
|
|
|
|
|
normalize_qt(pp->quat);
|
|
|
|
|
|
|
|
|
|
pp++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(dist);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (cycl) {
|
|
|
|
|
p1 = mod_i(p1 - min, (max - min + 1)) + min;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (p1 < min) {
|
2019-04-17 06:17:24 +02:00
|
|
|
p1 = min;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else if (p1 > max) {
|
2019-04-17 06:17:24 +02:00
|
|
|
p1 = max;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
return p1;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-13 15:16:18 +10:00
|
|
|
/**
|
|
|
|
|
* Calculate the deformation implied by the curve path at a given parametric position,
|
2012-01-31 20:38:03 +00:00
|
|
|
* and returns whether this operation succeeded.
|
|
|
|
|
*
|
2020-06-13 15:16:18 +10:00
|
|
|
* \param ctime: Time is normalized range <0-1>.
|
2012-01-31 20:38:03 +00:00
|
|
|
*
|
2020-06-13 15:16:18 +10:00
|
|
|
* \return success.
|
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
|
|
|
*/
|
2020-06-13 16:08:34 +10:00
|
|
|
bool where_on_path(const Object *ob,
|
2020-06-13 15:16:18 +10:00
|
|
|
float ctime,
|
2020-06-13 15:25:43 +10:00
|
|
|
float r_vec[4],
|
|
|
|
|
float r_dir[3],
|
|
|
|
|
float r_quat[4],
|
|
|
|
|
float *r_radius,
|
|
|
|
|
float *r_weight)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Curve *cu;
|
2020-06-13 16:08:34 +10:00
|
|
|
const Nurb *nu;
|
|
|
|
|
const BevList *bl;
|
|
|
|
|
const Path *path;
|
|
|
|
|
const PathPoint *pp, *p0, *p1, *p2, *p3;
|
2019-04-17 06:17:24 +02:00
|
|
|
float fac;
|
|
|
|
|
float data[4];
|
|
|
|
|
int cycl = 0, s0, s1, s2, s3;
|
2020-06-13 16:08:34 +10:00
|
|
|
const ListBase *nurbs;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ob == NULL || ob->type != OB_CURVE) {
|
2020-06-13 15:16:18 +10:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
cu = ob->data;
|
|
|
|
|
if (ob->runtime.curve_cache == NULL || ob->runtime.curve_cache->path == NULL ||
|
|
|
|
|
ob->runtime.curve_cache->path->data == NULL) {
|
|
|
|
|
CLOG_WARN(&LOG, "no path!");
|
2020-06-13 15:16:18 +10:00
|
|
|
return false;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
path = ob->runtime.curve_cache->path;
|
|
|
|
|
pp = path->data;
|
|
|
|
|
|
|
|
|
|
/* test for cyclic */
|
|
|
|
|
bl = ob->runtime.curve_cache->bev.first;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!bl) {
|
2020-06-13 15:16:18 +10:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (!bl->nr) {
|
2020-06-13 15:16:18 +10:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
if (bl->poly > -1) {
|
2019-04-17 06:17:24 +02:00
|
|
|
cycl = 1;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* values below zero for non-cyclic curves give strange results */
|
|
|
|
|
BLI_assert(cycl || ctime >= 0.0f);
|
|
|
|
|
|
|
|
|
|
ctime *= (path->len - 1);
|
|
|
|
|
|
|
|
|
|
s1 = (int)floor(ctime);
|
|
|
|
|
fac = (float)(s1 + 1) - ctime;
|
|
|
|
|
|
|
|
|
|
/* path->len is corrected for cyclic */
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
p0 = pp + s0;
|
|
|
|
|
p1 = pp + s1;
|
|
|
|
|
p2 = pp + s2;
|
|
|
|
|
p3 = pp + s3;
|
|
|
|
|
|
|
|
|
|
/* NOTE: commented out for follow constraint
|
|
|
|
|
*
|
2020-06-12 12:51:57 +10:00
|
|
|
* If it's ever be uncommented watch out for BKE_curve_deform_coords()
|
2019-04-17 06:17:24 +02:00
|
|
|
* which used to temporary set CU_FOLLOW flag for the curve and no
|
|
|
|
|
* longer does it (because of threading issues of such a thing.
|
|
|
|
|
*/
|
2019-05-01 11:09:22 +10:00
|
|
|
// if (cu->flag & CU_FOLLOW) {
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
key_curve_tangent_weights(1.0f - fac, data, KEY_BSPLINE);
|
|
|
|
|
|
2020-06-13 15:25:43 +10:00
|
|
|
interp_v3_v3v3v3v3(r_dir, p0->vec, p1->vec, p2->vec, p3->vec, data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-13 15:25:43 +10:00
|
|
|
/* Make compatible with #vec_to_quat. */
|
|
|
|
|
negate_v3(r_dir);
|
2019-04-17 06:17:24 +02:00
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
nurbs = BKE_curve_editNurbs_get(cu);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!nurbs) {
|
2019-04-17 06:17:24 +02:00
|
|
|
nurbs = &cu->nurb;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
nu = nurbs->first;
|
|
|
|
|
|
|
|
|
|
/* make sure that first and last frame are included in the vectors here */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (nu->type == CU_POLY) {
|
2019-04-17 06:17:24 +02:00
|
|
|
key_curve_position_weights(1.0f - fac, data, KEY_LINEAR);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else if (nu->type == CU_BEZIER) {
|
2019-04-17 06:17:24 +02:00
|
|
|
key_curve_position_weights(1.0f - fac, data, KEY_LINEAR);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else if (s0 == s1 || p2 == p3) {
|
2019-04-17 06:17:24 +02:00
|
|
|
key_curve_position_weights(1.0f - fac, data, KEY_CARDINAL);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
key_curve_position_weights(1.0f - fac, data, KEY_BSPLINE);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-13 15:25:43 +10:00
|
|
|
r_vec[0] = /* X */
|
|
|
|
|
data[0] * p0->vec[0] + data[1] * p1->vec[0] + data[2] * p2->vec[0] + data[3] * p3->vec[0];
|
|
|
|
|
r_vec[1] = /* Y */
|
|
|
|
|
data[0] * p0->vec[1] + data[1] * p1->vec[1] + data[2] * p2->vec[1] + data[3] * p3->vec[1];
|
|
|
|
|
r_vec[2] = /* Z */
|
|
|
|
|
data[0] * p0->vec[2] + data[1] * p1->vec[2] + data[2] * p2->vec[2] + data[3] * p3->vec[2];
|
|
|
|
|
r_vec[3] = /* Tilt, should not be needed since we have quat still used */
|
|
|
|
|
data[0] * p0->vec[3] + data[1] * p1->vec[3] + data[2] * p2->vec[3] + data[3] * p3->vec[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-13 15:25:43 +10:00
|
|
|
if (r_quat) {
|
2019-04-17 06:17:24 +02:00
|
|
|
float totfac, q1[4], q2[4];
|
|
|
|
|
|
|
|
|
|
totfac = data[0] + data[3];
|
2019-04-22 09:39:35 +10:00
|
|
|
if (totfac > FLT_EPSILON) {
|
2019-04-17 06:17:24 +02:00
|
|
|
interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
copy_qt_qt(q1, p1->quat);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
totfac = data[1] + data[2];
|
2019-04-22 09:39:35 +10:00
|
|
|
if (totfac > FLT_EPSILON) {
|
2019-04-17 06:17:24 +02:00
|
|
|
interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
copy_qt_qt(q2, p3->quat);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
totfac = data[0] + data[1] + data[2] + data[3];
|
2019-04-22 09:39:35 +10:00
|
|
|
if (totfac > FLT_EPSILON) {
|
2020-06-13 15:25:43 +10:00
|
|
|
interp_qt_qtqt(r_quat, q1, q2, (data[1] + data[2]) / totfac);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2020-06-13 15:25:43 +10:00
|
|
|
copy_qt_qt(r_quat, q2);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-13 15:25:43 +10:00
|
|
|
if (r_radius) {
|
|
|
|
|
*r_radius = data[0] * p0->radius + data[1] * p1->radius + data[2] * p2->radius +
|
|
|
|
|
data[3] * p3->radius;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-13 15:25:43 +10:00
|
|
|
if (r_weight) {
|
|
|
|
|
*r_weight = data[0] * p0->weight + data[1] * p1->weight + data[2] * p2->weight +
|
|
|
|
|
data[3] * p3->weight;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-13 15:16:18 +10:00
|
|
|
return true;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|