2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-02-17 19:59:41 +01:00
|
|
|
#pragma once
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup DNA
|
2013-03-01 15:47:06 +01:00
|
|
|
*
|
|
|
|
* This file defines structures for Shape-Keys (not animation keyframes),
|
|
|
|
* attached to Mesh, Curve and Lattice Data. Even though Key's are ID blocks they
|
|
|
|
* aren't intended to be shared between multiple data blocks as with other ID types.
|
2011-02-17 21:48:12 +01:00
|
|
|
*/
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_ID.h"
|
2011-12-04 07:05:48 +01:00
|
|
|
#include "DNA_defs.h"
|
2002-10-12 13:37:38 +02:00
|
|
|
#include "DNA_listBase.h"
|
|
|
|
|
2009-01-17 06:36:58 +01:00
|
|
|
struct AnimData;
|
2002-10-12 13:37:38 +02:00
|
|
|
struct Ipo;
|
|
|
|
|
|
|
|
typedef struct KeyBlock {
|
|
|
|
struct KeyBlock *next, *prev;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/**
|
|
|
|
* point in time (Key->type == KEY_NORMAL) only,
|
|
|
|
* for historic reasons this is relative to (Key->ctime / 100),
|
|
|
|
* so this value increments by 0.1f per frame.
|
|
|
|
*/
|
|
|
|
float pos;
|
2021-06-24 07:56:58 +02:00
|
|
|
/** influence (typically [0 - 1] but can be more), `(Key->type == KEY_RELATIVE)` only. */
|
2019-01-07 12:19:13 +01:00
|
|
|
float curval;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-24 07:56:58 +02:00
|
|
|
/** Interpolation type `(Key->type == KEY_NORMAL)` only. */
|
2019-01-07 12:19:13 +01:00
|
|
|
short type;
|
2019-02-27 05:07:50 +01:00
|
|
|
char _pad1[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/** relative == 0 means first key is reference, otherwise the index of Key->blocks */
|
|
|
|
short relative;
|
2012-04-14 05:58:08 +02:00
|
|
|
short flag;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/** total number if items in the keyblock (compare with mesh/curve verts to check we match) */
|
|
|
|
int totelem;
|
|
|
|
/** for meshes only, match the unique number with the customdata layer */
|
|
|
|
int uid;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-24 07:56:58 +02:00
|
|
|
/** array of shape key values, size is `(Key->elemsize * KeyBlock->totelem)` */
|
2019-01-07 12:19:13 +01:00
|
|
|
void *data;
|
|
|
|
/** MAX_NAME (unique name, user assigned) */
|
|
|
|
char name[64];
|
|
|
|
/** MAX_VGROUP_NAME (optional vertex group), array gets allocated into 'weights' when set */
|
|
|
|
char vgroup[64];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/** ranges, for RNA and UI only to clamp 'curval' */
|
2003-07-21 01:04:09 +02:00
|
|
|
float slidermin;
|
|
|
|
float slidermax;
|
2012-04-14 05:58:08 +02:00
|
|
|
|
2002-10-12 13:37:38 +02:00
|
|
|
} KeyBlock;
|
|
|
|
|
|
|
|
typedef struct Key {
|
|
|
|
ID id;
|
2019-01-07 12:19:13 +01:00
|
|
|
/** Animation data (must be immediately after id for utilities to use it). */
|
|
|
|
struct AnimData *adt;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/**
|
2021-06-24 07:56:58 +02:00
|
|
|
* commonly called 'Basis', `(Key->type == KEY_RELATIVE)` only.
|
2012-04-14 05:58:08 +02:00
|
|
|
* Looks like this is _always_ 'key->block.first',
|
2019-01-07 12:19:13 +01:00
|
|
|
* perhaps later on it could be defined as some other KeyBlock - campbell
|
|
|
|
*/
|
2002-10-12 13:37:38 +02:00
|
|
|
KeyBlock *refkey;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/**
|
|
|
|
* This is not a regular string, although it is \0 terminated
|
2012-04-14 04:48:56 +02:00
|
|
|
* this is an array of (element_array_size, element_type) pairs
|
2019-01-07 12:19:13 +01:00
|
|
|
* (each one char) used for calculating shape key-blocks. */
|
2012-04-14 04:48:56 +02:00
|
|
|
char elemstr[32];
|
2019-01-07 12:19:13 +01:00
|
|
|
/** Size of each element in #KeyBlock.data, use for allocation and stride. */
|
|
|
|
int elemsize;
|
2019-02-27 05:07:50 +01:00
|
|
|
char _pad[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/** list of KeyBlock's */
|
|
|
|
ListBase block;
|
|
|
|
/** old animation system, deprecated for 2.5 */
|
|
|
|
struct Ipo *ipo DNA_DEPRECATED;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2002-10-12 13:37:38 +02:00
|
|
|
ID *from;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/** (totkey == BLI_listbase_count(&key->block)) */
|
|
|
|
int totkey;
|
2012-04-14 05:58:08 +02:00
|
|
|
short flag;
|
2019-01-07 12:19:13 +01:00
|
|
|
/** absolute or relative shape key */
|
|
|
|
char type;
|
2019-02-27 05:07:50 +01:00
|
|
|
char _pad2;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/** Only used when (Key->type == KEY_NORMAL), this value is used as a time slider,
|
2012-04-14 05:58:08 +02:00
|
|
|
* rather than using the scene's time, this value can be animated to give greater control */
|
2012-04-05 07:05:18 +02:00
|
|
|
float ctime;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/**
|
|
|
|
* Can never be 0, this is used for detecting old data.
|
2020-06-25 15:13:02 +02:00
|
|
|
* current free UID for key-blocks.
|
2019-01-07 12:19:13 +01:00
|
|
|
*/
|
|
|
|
int uidgen;
|
2002-10-12 13:37:38 +02:00
|
|
|
} Key;
|
|
|
|
|
|
|
|
/* **************** KEY ********************* */
|
|
|
|
|
2012-04-14 05:58:08 +02:00
|
|
|
/* Key->type: KeyBlocks are interpreted as... */
|
2012-04-11 17:24:13 +02:00
|
|
|
enum {
|
2012-09-18 16:40:02 +02:00
|
|
|
/* Sequential positions over time (using KeyBlock->pos and Key->ctime) */
|
2012-04-11 17:24:13 +02:00
|
|
|
KEY_NORMAL = 0,
|
2012-04-14 05:58:08 +02:00
|
|
|
|
|
|
|
/* States to blend between (default) */
|
2019-01-15 13:57:49 +01:00
|
|
|
KEY_RELATIVE = 1,
|
2012-04-11 17:24:13 +02:00
|
|
|
};
|
2005-09-26 17:34:21 +02:00
|
|
|
|
2012-04-14 05:58:08 +02:00
|
|
|
/* Key->flag */
|
2012-04-11 17:24:13 +02:00
|
|
|
enum {
|
2019-01-15 13:57:49 +01:00
|
|
|
KEY_DS_EXPAND = 1,
|
2012-04-11 17:24:13 +02:00
|
|
|
};
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2012-04-14 05:58:08 +02:00
|
|
|
/* KeyBlock->type */
|
2012-04-11 17:24:13 +02:00
|
|
|
enum {
|
|
|
|
KEY_LINEAR = 0,
|
|
|
|
KEY_CARDINAL = 1,
|
2013-06-25 12:49:20 +02:00
|
|
|
KEY_BSPLINE = 2,
|
|
|
|
KEY_CATMULL_ROM = 3,
|
2012-04-11 17:24:13 +02:00
|
|
|
};
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2012-04-14 05:58:08 +02:00
|
|
|
/* KeyBlock->flag */
|
2012-04-11 17:24:13 +02:00
|
|
|
enum {
|
|
|
|
KEYBLOCK_MUTE = (1 << 0),
|
|
|
|
KEYBLOCK_SEL = (1 << 1),
|
2019-01-15 13:57:49 +01:00
|
|
|
KEYBLOCK_LOCKED = (1 << 2),
|
2023-07-14 19:57:28 +02:00
|
|
|
KEYBLOCK_LOCKED_SHAPE = (1 << 3),
|
2012-04-11 17:24:13 +02:00
|
|
|
};
|
|
|
|
|
Put the Radius property of Curve points under shape key control.
Since shape keys are stored as raw floating point data, this
unfortunately requires changes to all code that works with it.
An additional complication is that bezier and nurbs control
points have different entry size, and can be mixed in the same
object (and hence shape key buffer).
Shape key entries are changed from:
bezier: float v1[3], v2[3], v3[3], tilt, pad, pad;
nurbs: float vec[3], tilt;
To:
bezier: float v1[3], v2[3], v3[3], tilt, radius, pad;
nurbs: float vec[3], tilt, radius, pad;
The official shape key element size is changed to 3 floats,
with 4 elements for bezier nodes, and 2 for nurbs. This also
means that the element count is not equal to the vertex count
anymore.
While searching for all curve Shape Key code, I also found that
BKE_curve_transform_ex and BKE_curve_translate were broken. This
can be seen by trying to change the Origin of a Curve with keys.
Reviewers: campbellbarton, sergey
Differential Revision: https://developer.blender.org/D3676
2018-09-05 15:17:59 +02:00
|
|
|
#define KEYELEM_FLOAT_LEN_COORD 3
|
|
|
|
|
|
|
|
/* Curve key data layout constants */
|
|
|
|
#define KEYELEM_ELEM_SIZE_CURVE 3
|
|
|
|
|
|
|
|
#define KEYELEM_ELEM_LEN_BPOINT 2
|
|
|
|
#define KEYELEM_FLOAT_LEN_BPOINT (KEYELEM_ELEM_LEN_BPOINT * KEYELEM_ELEM_SIZE_CURVE)
|
|
|
|
|
|
|
|
#define KEYELEM_ELEM_LEN_BEZTRIPLE 4
|
|
|
|
#define KEYELEM_FLOAT_LEN_BEZTRIPLE (KEYELEM_ELEM_LEN_BEZTRIPLE * KEYELEM_ELEM_SIZE_CURVE)
|