2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-03 21:18:10 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
2008-12-03 21:18:10 +00:00
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation (2008).
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:20:01 +00:00
|
|
|
/** \file blender/makesrna/intern/rna_key.c
|
|
|
|
|
* \ingroup RNA
|
|
|
|
|
*/
|
|
|
|
|
|
2008-12-03 21:18:10 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2008-12-04 00:07:47 +00:00
|
|
|
#include "DNA_ID.h"
|
2012-04-05 05:05:18 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2008-12-04 00:07:47 +00:00
|
|
|
#include "DNA_curve_types.h"
|
2008-12-03 21:18:10 +00:00
|
|
|
#include "DNA_key_types.h"
|
2008-12-04 00:07:47 +00:00
|
|
|
#include "DNA_lattice_types.h"
|
|
|
|
|
#include "DNA_mesh_types.h"
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2013-03-25 08:29:06 +00:00
|
|
|
#include "BLF_translation.h"
|
|
|
|
|
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
2013-09-11 21:27:14 +00:00
|
|
|
#include "RNA_enum_types.h"
|
2013-03-07 02:44:55 +00:00
|
|
|
|
|
|
|
|
#include "rna_internal.h"
|
|
|
|
|
|
2008-12-03 21:18:10 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
2008-12-04 00:07:47 +00:00
|
|
|
|
Bugfix #19663: Renaming named data doesn't fix F-Curves
RNA Paths used in F-Curve, Drivers, etc. now get renamed when some data that they use gets renamed. This only works when things like Bones, Constraints, Shape Keys, and Modifiers get renamed, but other cases can get added easily.
The code here only performs simple string replacements, so there is the potential for problems when several sets of data with the same names are present. For example, if there are multiple armatures with bones that have the same names, renaming a bone on one armature (with a bone on another armature having the same name) will break all the drivers on the other one, even though they aren't really connected. However, I don't expect the aforementioned scenario to really be a problem in most production scenarios.
2009-10-20 03:44:35 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
2009-07-03 15:23:33 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
2009-10-20 04:07:57 +00:00
|
|
|
#include "BKE_animsys.h"
|
2009-07-03 15:23:33 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
|
|
|
|
#include "BKE_key.h"
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
2009-10-22 23:23:09 +00:00
|
|
|
static Key *rna_ShapeKey_find_key(ID *id)
|
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (GS(id->name)) {
|
2012-05-12 11:01:29 +00:00
|
|
|
case ID_CU: return ((Curve *)id)->key;
|
|
|
|
|
case ID_KE: return (Key *)id;
|
|
|
|
|
case ID_LT: return ((Lattice *)id)->key;
|
|
|
|
|
case ID_ME: return ((Mesh *)id)->key;
|
2012-09-19 10:12:07 +00:00
|
|
|
case ID_OB: return BKE_key_from_object((Object *)id);
|
2009-10-22 23:23:09 +00:00
|
|
|
default: return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-22 14:07:55 +00:00
|
|
|
static void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value)
|
Bugfix #19663: Renaming named data doesn't fix F-Curves
RNA Paths used in F-Curve, Drivers, etc. now get renamed when some data that they use gets renamed. This only works when things like Bones, Constraints, Shape Keys, and Modifiers get renamed, but other cases can get added easily.
The code here only performs simple string replacements, so there is the potential for problems when several sets of data with the same names are present. For example, if there are multiple armatures with bones that have the same names, renaming a bone on one armature (with a bone on another armature having the same name) will break all the drivers on the other one, even though they aren't really connected. However, I don't expect the aforementioned scenario to really be a problem in most production scenarios.
2009-10-20 03:44:35 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
KeyBlock *kb = ptr->data;
|
2010-04-04 14:33:41 +00:00
|
|
|
char oldname[sizeof(kb->name)];
|
Bugfix #19663: Renaming named data doesn't fix F-Curves
RNA Paths used in F-Curve, Drivers, etc. now get renamed when some data that they use gets renamed. This only works when things like Bones, Constraints, Shape Keys, and Modifiers get renamed, but other cases can get added easily.
The code here only performs simple string replacements, so there is the potential for problems when several sets of data with the same names are present. For example, if there are multiple armatures with bones that have the same names, renaming a bone on one armature (with a bone on another armature having the same name) will break all the drivers on the other one, even though they aren't really connected. However, I don't expect the aforementioned scenario to really be a problem in most production scenarios.
2009-10-20 03:44:35 +00:00
|
|
|
|
|
|
|
|
/* make a copy of the old name first */
|
2010-04-04 14:33:41 +00:00
|
|
|
BLI_strncpy(oldname, kb->name, sizeof(kb->name));
|
Bugfix #19663: Renaming named data doesn't fix F-Curves
RNA Paths used in F-Curve, Drivers, etc. now get renamed when some data that they use gets renamed. This only works when things like Bones, Constraints, Shape Keys, and Modifiers get renamed, but other cases can get added easily.
The code here only performs simple string replacements, so there is the potential for problems when several sets of data with the same names are present. For example, if there are multiple armatures with bones that have the same names, renaming a bone on one armature (with a bone on another armature having the same name) will break all the drivers on the other one, even though they aren't really connected. However, I don't expect the aforementioned scenario to really be a problem in most production scenarios.
2009-10-20 03:44:35 +00:00
|
|
|
|
|
|
|
|
/* copy the new name into the name slot */
|
2011-09-15 12:26:48 +00:00
|
|
|
BLI_strncpy_utf8(kb->name, value, sizeof(kb->name));
|
Bugfix #19663: Renaming named data doesn't fix F-Curves
RNA Paths used in F-Curve, Drivers, etc. now get renamed when some data that they use gets renamed. This only works when things like Bones, Constraints, Shape Keys, and Modifiers get renamed, but other cases can get added easily.
The code here only performs simple string replacements, so there is the potential for problems when several sets of data with the same names are present. For example, if there are multiple armatures with bones that have the same names, renaming a bone on one armature (with a bone on another armature having the same name) will break all the drivers on the other one, even though they aren't really connected. However, I don't expect the aforementioned scenario to really be a problem in most production scenarios.
2009-10-20 03:44:35 +00:00
|
|
|
|
|
|
|
|
/* make sure the name is truly unique */
|
|
|
|
|
if (ptr->id.data) {
|
2012-03-05 23:30:41 +00:00
|
|
|
Key *key = rna_ShapeKey_find_key(ptr->id.data);
|
2013-03-25 08:29:06 +00:00
|
|
|
BLI_uniquename(&key->block, kb, CTX_DATA_(BLF_I18NCONTEXT_ID_SHAPEKEY, "Key"), '.',
|
|
|
|
|
offsetof(KeyBlock, name), sizeof(kb->name));
|
Bugfix #19663: Renaming named data doesn't fix F-Curves
RNA Paths used in F-Curve, Drivers, etc. now get renamed when some data that they use gets renamed. This only works when things like Bones, Constraints, Shape Keys, and Modifiers get renamed, but other cases can get added easily.
The code here only performs simple string replacements, so there is the potential for problems when several sets of data with the same names are present. For example, if there are multiple armatures with bones that have the same names, renaming a bone on one armature (with a bone on another armature having the same name) will break all the drivers on the other one, even though they aren't really connected. However, I don't expect the aforementioned scenario to really be a problem in most production scenarios.
2009-10-20 03:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* fix all the animation data which may link to this */
|
2012-03-30 13:04:29 +00:00
|
|
|
BKE_all_animdata_fix_paths_rename(NULL, "key_blocks", oldname, kb->name);
|
Bugfix #19663: Renaming named data doesn't fix F-Curves
RNA Paths used in F-Curve, Drivers, etc. now get renamed when some data that they use gets renamed. This only works when things like Bones, Constraints, Shape Keys, and Modifiers get renamed, but other cases can get added easily.
The code here only performs simple string replacements, so there is the potential for problems when several sets of data with the same names are present. For example, if there are multiple armatures with bones that have the same names, renaming a bone on one armature (with a bone on another armature having the same name) will break all the drivers on the other one, even though they aren't really connected. However, I don't expect the aforementioned scenario to really be a problem in most production scenarios.
2009-10-20 03:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
Fix T39897: shape keys created while the Relative checkbox is unchecked start out with frame=0
So! First, frame for absolute shape keys: never allow a new key to have the same pos as an
existing one (this does not make sense). This way, the two workflows are possible (create
all keys and then animate ctime, or animate ctime and then create keys where you need them).
Also, fixed UIList for shapekeys, the "absolute" test was wrong, and better to show frame
value, even though not editable, than nothing in case of absolute keys.
And finally, add getter to RNA 'frame' readonly value, so that we output real frame values,
and not dummy internal ones (which are /100) in our API.
2014-05-18 22:05:21 +02:00
|
|
|
static float rna_ShapeKey_frame_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
KeyBlock *kb = (KeyBlock *)ptr->data;
|
|
|
|
|
return kb->pos * 100.0f; /* Because pos is ctime/100... */
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-01 06:03:08 +00:00
|
|
|
static void rna_ShapeKey_value_set(PointerRNA *ptr, float value)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
KeyBlock *data = (KeyBlock *)ptr->data;
|
2009-08-01 06:03:08 +00:00
|
|
|
CLAMP(value, data->slidermin, data->slidermax);
|
2012-03-05 23:30:41 +00:00
|
|
|
data->curval = value;
|
2009-08-01 06:03:08 +00:00
|
|
|
}
|
|
|
|
|
|
2013-09-20 06:35:28 +00:00
|
|
|
static void rna_ShapeKey_value_range(PointerRNA *ptr, float *min, float *max,
|
|
|
|
|
float *UNUSED(softmin), float *UNUSED(softmax))
|
2009-08-01 06:03:08 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
KeyBlock *data = (KeyBlock *)ptr->data;
|
2009-08-01 06:03:08 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
*min = data->slidermin;
|
|
|
|
|
*max = data->slidermax;
|
2009-08-01 06:03:08 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-03 11:58:19 +00:00
|
|
|
/* epsilon for how close one end of shapekey range can get to the other */
|
2011-03-28 02:34:55 +00:00
|
|
|
#define SHAPEKEY_SLIDER_TOL 0.001f
|
2011-01-03 11:58:19 +00:00
|
|
|
|
2013-09-20 06:35:28 +00:00
|
|
|
static void rna_ShapeKey_slider_min_range(PointerRNA *ptr, float *min, float *max,
|
|
|
|
|
float *UNUSED(softmin), float *UNUSED(softmax))
|
2011-01-03 11:58:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
KeyBlock *data = (KeyBlock *)ptr->data;
|
2011-01-03 11:58:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
*min = -10.0f;
|
|
|
|
|
*max = data->slidermax - SHAPEKEY_SLIDER_TOL;
|
2011-01-03 11:58:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_ShapeKey_slider_min_set(PointerRNA *ptr, float value)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
KeyBlock *data = (KeyBlock *)ptr->data;
|
2012-03-30 16:09:05 +00:00
|
|
|
float min, max, softmin, softmax;
|
2011-01-03 11:58:19 +00:00
|
|
|
|
2012-03-30 16:09:05 +00:00
|
|
|
rna_ShapeKey_slider_min_range(ptr, &min, &max, &softmin, &softmax);
|
2011-01-03 11:58:19 +00:00
|
|
|
CLAMP(value, min, max);
|
|
|
|
|
data->slidermin = value;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-20 06:35:28 +00:00
|
|
|
static void rna_ShapeKey_slider_max_range(PointerRNA *ptr, float *min, float *max,
|
|
|
|
|
float *UNUSED(softmin), float *UNUSED(softmax))
|
2011-01-03 11:58:19 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
KeyBlock *data = (KeyBlock *)ptr->data;
|
2011-01-03 11:58:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
*min = data->slidermin + SHAPEKEY_SLIDER_TOL;
|
|
|
|
|
*max = 10.0f;
|
2011-01-03 11:58:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_ShapeKey_slider_max_set(PointerRNA *ptr, float value)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
KeyBlock *data = (KeyBlock *)ptr->data;
|
2012-03-30 16:09:05 +00:00
|
|
|
float min, max, softmin, softmax;
|
2011-01-03 11:58:19 +00:00
|
|
|
|
2012-03-30 16:09:05 +00:00
|
|
|
rna_ShapeKey_slider_max_range(ptr, &min, &max, &softmin, &softmax);
|
2011-01-03 11:58:19 +00:00
|
|
|
CLAMP(value, min, max);
|
|
|
|
|
data->slidermax = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef SHAPEKEY_SLIDER_TOL
|
|
|
|
|
|
2010-03-30 11:49:07 +00:00
|
|
|
PointerRNA rna_object_shapekey_index_get(ID *id, int value)
|
2008-12-04 00:07:47 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Key *key = rna_ShapeKey_find_key(id);
|
|
|
|
|
KeyBlock *kb = NULL;
|
2010-03-30 11:49:07 +00:00
|
|
|
PointerRNA ptr;
|
2008-12-04 00:07:47 +00:00
|
|
|
|
2011-01-26 10:46:43 +00:00
|
|
|
if (key && value < key->totkey)
|
|
|
|
|
kb = BLI_findlink(&key->block, value);
|
2010-03-30 11:49:07 +00:00
|
|
|
|
|
|
|
|
RNA_pointer_create(id, &RNA_ShapeKey, kb, &ptr);
|
2008-12-04 00:07:47 +00:00
|
|
|
|
2010-03-30 11:49:07 +00:00
|
|
|
return ptr;
|
2008-12-04 00:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 11:49:07 +00:00
|
|
|
int rna_object_shapekey_index_set(ID *id, PointerRNA value, int current)
|
2009-07-03 15:23:33 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Key *key = rna_ShapeKey_find_key(id);
|
2009-07-03 15:23:33 +00:00
|
|
|
|
2011-01-26 10:46:43 +00:00
|
|
|
if (key) {
|
|
|
|
|
int a = BLI_findindex(&key->block, value.data);
|
2014-02-01 01:45:09 +11:00
|
|
|
if (a != -1) return a;
|
2011-01-26 10:46:43 +00:00
|
|
|
}
|
2010-03-30 11:49:07 +00:00
|
|
|
|
|
|
|
|
return current;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PointerRNA rna_ShapeKey_relative_key_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
KeyBlock *kb = (KeyBlock *)ptr->data;
|
2010-03-30 11:49:07 +00:00
|
|
|
|
|
|
|
|
return rna_object_shapekey_index_get(ptr->id.data, kb->relative);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_ShapeKey_relative_key_set(PointerRNA *ptr, PointerRNA value)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
KeyBlock *kb = (KeyBlock *)ptr->data;
|
2010-03-30 11:49:07 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
kb->relative = rna_object_shapekey_index_set(ptr->id.data, value, kb->relative);
|
2009-07-03 15:23:33 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static void rna_ShapeKeyPoint_co_get(PointerRNA *ptr, float *values)
|
2008-12-04 01:58:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
float *vec = (float *)ptr->data;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
values[0] = vec[0];
|
|
|
|
|
values[1] = vec[1];
|
|
|
|
|
values[2] = vec[2];
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static void rna_ShapeKeyPoint_co_set(PointerRNA *ptr, const float *values)
|
2008-12-04 01:58:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
float *vec = (float *)ptr->data;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
vec[0] = values[0];
|
|
|
|
|
vec[1] = values[1];
|
|
|
|
|
vec[2] = values[2];
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float rna_ShapeKeyCurvePoint_tilt_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
float *vec = (float *)ptr->data;
|
2008-12-04 01:58:14 +00:00
|
|
|
return vec[3];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_ShapeKeyCurvePoint_tilt_set(PointerRNA *ptr, float value)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
float *vec = (float *)ptr->data;
|
2012-03-05 23:30:41 +00:00
|
|
|
vec[3] = value;
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static void rna_ShapeKeyBezierPoint_co_get(PointerRNA *ptr, float *values)
|
2008-12-04 01:58:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
float *vec = (float *)ptr->data;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
values[0] = vec[0 + 3];
|
|
|
|
|
values[1] = vec[1 + 3];
|
|
|
|
|
values[2] = vec[2 + 3];
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static void rna_ShapeKeyBezierPoint_co_set(PointerRNA *ptr, const float *values)
|
2008-12-04 01:58:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
float *vec = (float *)ptr->data;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
vec[0 + 3] = values[0];
|
|
|
|
|
vec[1 + 3] = values[1];
|
|
|
|
|
vec[2 + 3] = values[2];
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static void rna_ShapeKeyBezierPoint_handle_1_co_get(PointerRNA *ptr, float *values)
|
2008-12-04 01:58:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
float *vec = (float *)ptr->data;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
values[0] = vec[0];
|
|
|
|
|
values[1] = vec[1];
|
|
|
|
|
values[2] = vec[2];
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static void rna_ShapeKeyBezierPoint_handle_1_co_set(PointerRNA *ptr, const float *values)
|
2008-12-04 01:58:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
float *vec = (float *)ptr->data;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
vec[0] = values[0];
|
|
|
|
|
vec[1] = values[1];
|
|
|
|
|
vec[2] = values[2];
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static void rna_ShapeKeyBezierPoint_handle_2_co_get(PointerRNA *ptr, float *values)
|
2008-12-04 01:58:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
float *vec = (float *)ptr->data;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
values[0] = vec[6 + 0];
|
|
|
|
|
values[1] = vec[6 + 1];
|
|
|
|
|
values[2] = vec[6 + 2];
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static void rna_ShapeKeyBezierPoint_handle_2_co_set(PointerRNA *ptr, const float *values)
|
2008-12-04 01:58:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
float *vec = (float *)ptr->data;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
vec[6 + 0] = values[0];
|
|
|
|
|
vec[6 + 1] = values[1];
|
|
|
|
|
vec[6 + 2] = values[2];
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
2012-04-22 11:54:53 +00:00
|
|
|
#if 0
|
|
|
|
|
static float rna_ShapeKeyBezierPoint_tilt_get(PointerRNA *ptr)
|
2008-12-04 01:58:14 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
float *vec = (float *)ptr->data;
|
2008-12-04 01:58:14 +00:00
|
|
|
return vec[10];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_ShapeKeyBezierPoint_tilt_set(PointerRNA *ptr, float value)
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
float *vec = (float *)ptr->data;
|
|
|
|
|
vec[10] = value;
|
2012-04-22 11:54:53 +00:00
|
|
|
}
|
|
|
|
|
#endif
|
2008-12-04 01:58:14 +00:00
|
|
|
|
|
|
|
|
static void rna_ShapeKey_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Key *key = rna_ShapeKey_find_key(ptr->id.data);
|
2012-05-12 11:01:29 +00:00
|
|
|
KeyBlock *kb = (KeyBlock *)ptr->data;
|
2008-12-04 01:58:14 +00:00
|
|
|
Curve *cu;
|
|
|
|
|
Nurb *nu;
|
2012-03-05 23:30:41 +00:00
|
|
|
int tot = kb->totelem, size = key->elemsize;
|
2011-01-26 10:46:43 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (GS(key->from->name) == ID_CU) {
|
2012-05-12 11:01:29 +00:00
|
|
|
cu = (Curve *)key->from;
|
2012-03-05 23:30:41 +00:00
|
|
|
nu = cu->nurb.first;
|
2011-01-26 10:46:43 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (nu->bezt) {
|
2008-12-04 01:58:14 +00:00
|
|
|
tot /= 3;
|
|
|
|
|
size *= 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-26 10:46:43 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_iterator_array_begin(iter, (void *)kb->data, size, tot, 0, NULL);
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int rna_ShapeKey_data_length(PointerRNA *ptr)
|
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Key *key = rna_ShapeKey_find_key(ptr->id.data);
|
2012-05-12 11:01:29 +00:00
|
|
|
KeyBlock *kb = (KeyBlock *)ptr->data;
|
2008-12-04 01:58:14 +00:00
|
|
|
Curve *cu;
|
|
|
|
|
Nurb *nu;
|
2012-03-05 23:30:41 +00:00
|
|
|
int tot = kb->totelem;
|
2011-01-26 10:46:43 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (GS(key->from->name) == ID_CU) {
|
2012-05-12 11:01:29 +00:00
|
|
|
cu = (Curve *)key->from;
|
2012-03-05 23:30:41 +00:00
|
|
|
nu = cu->nurb.first;
|
2011-01-26 10:46:43 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (nu->bezt)
|
2008-12-04 01:58:14 +00:00
|
|
|
tot /= 3;
|
|
|
|
|
}
|
2011-01-26 10:46:43 +00:00
|
|
|
|
2008-12-04 01:58:14 +00:00
|
|
|
return tot;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter)
|
2008-12-04 01:58:14 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Key *key = rna_ShapeKey_find_key(iter->parent.id.data);
|
2009-02-02 19:57:57 +00:00
|
|
|
StructRNA *type;
|
2008-12-04 01:58:14 +00:00
|
|
|
Curve *cu;
|
|
|
|
|
Nurb *nu;
|
2011-01-26 10:46:43 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (GS(key->from->name) == ID_CU) {
|
2012-05-12 11:01:29 +00:00
|
|
|
cu = (Curve *)key->from;
|
2012-03-05 23:30:41 +00:00
|
|
|
nu = cu->nurb.first;
|
2011-01-26 10:46:43 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (nu->bezt)
|
|
|
|
|
type = &RNA_ShapeKeyBezierPoint;
|
2008-12-04 01:58:14 +00:00
|
|
|
else
|
2012-03-05 23:30:41 +00:00
|
|
|
type = &RNA_ShapeKeyCurvePoint;
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
else
|
2012-03-05 23:30:41 +00:00
|
|
|
type = &RNA_ShapeKeyPoint;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
|
return rna_pointer_inherit_refine(&iter->parent, type, rna_iterator_array_get(iter));
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
2009-09-25 01:30:32 +00:00
|
|
|
static char *rna_ShapeKey_path(PointerRNA *ptr)
|
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
KeyBlock *kb = (KeyBlock *)ptr->data;
|
|
|
|
|
ID *id = ptr->id.data;
|
2013-04-23 20:10:22 +00:00
|
|
|
char name_esc[sizeof(kb->name) * 2];
|
|
|
|
|
|
|
|
|
|
BLI_strescape(name_esc, kb->name, sizeof(name_esc));
|
|
|
|
|
|
2010-01-08 02:02:52 +00:00
|
|
|
if ((id) && (GS(id->name) != ID_KE))
|
2013-04-23 20:10:22 +00:00
|
|
|
return BLI_sprintfN("shape_keys.key_blocks[\"%s\"]", name_esc);
|
2010-01-08 02:02:52 +00:00
|
|
|
else
|
2013-04-23 20:10:22 +00:00
|
|
|
return BLI_sprintfN("key_blocks[\"%s\"]", name_esc);
|
2009-09-25 01:30:32 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-26 21:30:08 +00:00
|
|
|
static void rna_Key_update_data(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
|
2009-07-03 15:23:33 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
Key *key = ptr->id.data;
|
2009-07-03 15:23:33 +00:00
|
|
|
Object *ob;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ob = bmain->object.first; ob; ob = ob->id.next) {
|
2012-09-19 10:12:07 +00:00
|
|
|
if (BKE_key_from_object(ob) == key) {
|
2010-12-05 18:59:23 +00:00
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
|
2009-07-03 15:23:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-26 21:58:32 +00:00
|
|
|
static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, float *point)
|
|
|
|
|
{
|
|
|
|
|
KeyBlock *kb;
|
|
|
|
|
|
|
|
|
|
/* sanity checks */
|
|
|
|
|
if (ELEM(NULL, key, point))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
/* we'll need to manually search through the keyblocks and check
|
2011-01-26 21:58:32 +00:00
|
|
|
* if the point is somewhere in the middle of each block's data
|
|
|
|
|
*/
|
|
|
|
|
for (kb = key->block.first; kb; kb = kb->next) {
|
|
|
|
|
if (kb->data) {
|
|
|
|
|
float *start = (float *)kb->data;
|
|
|
|
|
float *end;
|
|
|
|
|
|
|
|
|
|
/* easy cases first */
|
|
|
|
|
if ((start == NULL) || (start > point)) {
|
|
|
|
|
/* there's no chance point is in array */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else if (start == point) {
|
|
|
|
|
/* exact match - point is first in array */
|
|
|
|
|
return kb;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
/* determine where end of array is
|
2013-10-16 04:08:20 +00:00
|
|
|
* - elemsize is in bytes, so use (char *) cast to get array in terms of bytes
|
2011-01-26 21:58:32 +00:00
|
|
|
*/
|
|
|
|
|
end = (float *)((char *)start + (key->elemsize * kb->totelem));
|
|
|
|
|
|
|
|
|
|
/* if point's address is less than the end, then it is somewhere between start and end, so in array */
|
|
|
|
|
if (end > point) {
|
|
|
|
|
/* we've found the owner of the point data */
|
|
|
|
|
return kb;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int rna_ShapeKeyPoint_get_index(Key *key, KeyBlock *kb, float *point)
|
|
|
|
|
{
|
2013-10-16 04:08:20 +00:00
|
|
|
/* if we frame the data array and point pointers as (char *), then the difference between
|
2011-01-26 21:58:32 +00:00
|
|
|
* them will be in bytes. Thus, dividing through by key->elemsize (number of bytes per point)
|
|
|
|
|
* gives us the offset of point from start of array.
|
|
|
|
|
*/
|
|
|
|
|
char *start = (char *)kb->data;
|
|
|
|
|
char *pt = (char *)point;
|
|
|
|
|
|
|
|
|
|
return (int)(pt - start) / key->elemsize;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-02 00:28:02 +13:00
|
|
|
static int rna_ShapeKeyBezierPoint_get_index(KeyBlock *kb, float *point)
|
|
|
|
|
{
|
|
|
|
|
float *start = (float *)kb->data;
|
|
|
|
|
|
|
|
|
|
/* Unlike with rna_ShapeKeyPoint_get_index(), we cannot use key->elemsize here
|
|
|
|
|
* since the default value for curves (16) is actually designed for BPoints
|
|
|
|
|
* (i.e. NURBS Surfaces). The magic number "12" here was found by empirical
|
|
|
|
|
* testing on a 64-bit system, and is similar to what's used for meshes and
|
|
|
|
|
* lattices. For more details, see T38013
|
|
|
|
|
*/
|
|
|
|
|
return (int)(point - start) / 12;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-26 21:58:32 +00:00
|
|
|
static char *rna_ShapeKeyPoint_path(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
ID *id = (ID *)ptr->id.data;
|
|
|
|
|
Key *key = rna_ShapeKey_find_key(ptr->id.data);
|
|
|
|
|
KeyBlock *kb;
|
|
|
|
|
float *point = (float *)ptr->data;
|
|
|
|
|
|
|
|
|
|
/* if we can get a key block, we can construct a path */
|
2012-03-18 09:27:36 +00:00
|
|
|
kb = rna_ShapeKeyData_find_keyblock(key, point);
|
2011-01-26 21:58:32 +00:00
|
|
|
|
|
|
|
|
if (kb) {
|
2013-04-23 20:10:22 +00:00
|
|
|
char name_esc_kb[sizeof(kb->name) * 2];
|
2014-01-02 00:28:02 +13:00
|
|
|
int index;
|
|
|
|
|
|
|
|
|
|
if (ptr->type == &RNA_ShapeKeyBezierPoint)
|
|
|
|
|
index = rna_ShapeKeyBezierPoint_get_index(kb, point);
|
|
|
|
|
else
|
|
|
|
|
index = rna_ShapeKeyPoint_get_index(key, kb, point);
|
2013-04-23 20:10:22 +00:00
|
|
|
|
|
|
|
|
BLI_strescape(name_esc_kb, kb->name, sizeof(name_esc_kb));
|
2011-01-26 21:58:32 +00:00
|
|
|
|
|
|
|
|
if (GS(id->name) == ID_KE)
|
2013-04-23 20:10:22 +00:00
|
|
|
return BLI_sprintfN("key_blocks[\"%s\"].data[%d]", name_esc_kb, index);
|
2011-01-26 21:58:32 +00:00
|
|
|
else
|
2013-04-23 20:10:22 +00:00
|
|
|
return BLI_sprintfN("shape_keys.key_blocks[\"%s\"].data[%d]", name_esc_kb, index);
|
2011-01-26 21:58:32 +00:00
|
|
|
}
|
|
|
|
|
else
|
2012-05-12 11:01:29 +00:00
|
|
|
return NULL; /* XXX: there's really no way to resolve this... */
|
2011-01-26 21:58:32 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-03 21:18:10 +00:00
|
|
|
#else
|
|
|
|
|
|
2012-05-22 13:43:36 +00:00
|
|
|
EnumPropertyItem keyblock_type_items[] = {
|
|
|
|
|
{KEY_LINEAR, "KEY_LINEAR", 0, "Linear", ""},
|
|
|
|
|
{KEY_CARDINAL, "KEY_CARDINAL", 0, "Cardinal", ""},
|
2013-06-25 10:49:20 +00:00
|
|
|
{KEY_CATMULL_ROM, "KEY_CATMULL_ROM", 0, "Catmull-Rom", ""},
|
2012-05-22 13:43:36 +00:00
|
|
|
{KEY_BSPLINE, "KEY_BSPLINE", 0, "BSpline", ""},
|
|
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
|
|
|
|
|
2008-12-04 01:58:14 +00:00
|
|
|
static void rna_def_keydata(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "ShapeKeyPoint", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Shape Key Point", "Point in a shape key");
|
2011-01-26 21:58:32 +00:00
|
|
|
RNA_def_struct_path_func(srna, "rna_ShapeKeyPoint_path");
|
2008-12-04 01:58:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
|
2008-12-04 01:58:14 +00:00
|
|
|
RNA_def_property_array(prop, 3);
|
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", NULL);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Location", "");
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-04 01:58:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "ShapeKeyCurvePoint", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Shape Key Curve Point", "Point in a shape key for curves");
|
2012-05-12 11:01:29 +00:00
|
|
|
/* there's nothing type specific here, so this is fine for now */
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_struct_path_func(srna, "rna_ShapeKeyPoint_path");
|
2008-12-04 01:58:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
|
2008-12-04 01:58:14 +00:00
|
|
|
RNA_def_property_array(prop, 3);
|
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", NULL);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Location", "");
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-04 01:58:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
|
2008-12-04 01:58:14 +00:00
|
|
|
RNA_def_property_float_funcs(prop, "rna_ShapeKeyCurvePoint_tilt_get", "rna_ShapeKeyCurvePoint_tilt_set", NULL);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Tilt", "");
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-04 01:58:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "ShapeKeyBezierPoint", NULL);
|
2011-04-11 01:18:25 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Shape Key Bezier Point", "Point in a shape key for Bezier curves");
|
2012-05-12 11:01:29 +00:00
|
|
|
/* there's nothing type specific here, so this is fine for now */
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_struct_path_func(srna, "rna_ShapeKeyPoint_path");
|
2008-12-04 01:58:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
|
2008-12-04 01:58:14 +00:00
|
|
|
RNA_def_property_array(prop, 3);
|
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_co_get", "rna_ShapeKeyBezierPoint_co_set", NULL);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Location", "");
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-04 01:58:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_TRANSLATION);
|
2008-12-04 01:58:14 +00:00
|
|
|
RNA_def_property_array(prop, 3);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_handle_1_co_get",
|
|
|
|
|
"rna_ShapeKeyBezierPoint_handle_1_co_set", NULL);
|
2008-12-04 01:58:14 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Handle 1 Location", "");
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-04 01:58:14 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_TRANSLATION);
|
2008-12-04 01:58:14 +00:00
|
|
|
RNA_def_property_array(prop, 3);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_handle_2_co_get",
|
|
|
|
|
"rna_ShapeKeyBezierPoint_handle_2_co_set", NULL);
|
2008-12-04 01:58:14 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Handle 2 Location", "");
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-04 01:58:14 +00:00
|
|
|
|
2012-03-09 18:28:30 +00:00
|
|
|
/* appears to be unused currently */
|
|
|
|
|
#if 0
|
2012-03-18 09:27:36 +00:00
|
|
|
prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
|
2008-12-04 01:58:14 +00:00
|
|
|
RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_tilt_get", "rna_ShapeKeyBezierPoint_tilt_set", NULL);
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Tilt", "");
|
2012-03-09 18:28:30 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
|
|
|
|
#endif
|
2008-12-04 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_def_keyblock(BlenderRNA *brna)
|
2008-12-03 21:18:10 +00:00
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "ShapeKey", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Shape Key", "Shape key in a shape keys datablock");
|
2008-12-04 00:07:47 +00:00
|
|
|
RNA_def_struct_sdna(srna, "KeyBlock");
|
2009-09-25 01:30:32 +00:00
|
|
|
RNA_def_struct_path_func(srna, "rna_ShapeKey_path");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_SHAPEKEY_DATA);
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
2011-05-15 17:59:48 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Name", "Name of Shape Key");
|
Bugfix #19663: Renaming named data doesn't fix F-Curves
RNA Paths used in F-Curve, Drivers, etc. now get renamed when some data that they use gets renamed. This only works when things like Bones, Constraints, Shape Keys, and Modifiers get renamed, but other cases can get added easily.
The code here only performs simple string replacements, so there is the potential for problems when several sets of data with the same names are present. For example, if there are multiple armatures with bones that have the same names, renaming a bone on one armature (with a bone on another armature having the same name) will break all the drivers on the other one, even though they aren't really connected. However, I don't expect the aforementioned scenario to really be a problem in most production scenarios.
2009-10-20 03:44:35 +00:00
|
|
|
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ShapeKey_name_set");
|
2014-05-18 20:30:48 +02:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-04 00:07:47 +00:00
|
|
|
RNA_def_struct_name_property(srna, prop);
|
|
|
|
|
|
2008-12-04 01:58:14 +00:00
|
|
|
/* keys need to be sorted to edit this */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-12-03 21:18:10 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "pos");
|
Fix T39897: shape keys created while the Relative checkbox is unchecked start out with frame=0
So! First, frame for absolute shape keys: never allow a new key to have the same pos as an
existing one (this does not make sense). This way, the two workflows are possible (create
all keys and then animate ctime, or animate ctime and then create keys where you need them).
Also, fixed UIList for shapekeys, the "absolute" test was wrong, and better to show frame
value, even though not editable, than nothing in case of absolute keys.
And finally, add getter to RNA 'frame' readonly value, so that we output real frame values,
and not dummy internal ones (which are /100) in our API.
2014-05-18 22:05:21 +02:00
|
|
|
RNA_def_property_float_funcs(prop, "rna_ShapeKey_frame_get", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Frame", "Frame for absolute keys");
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2009-01-24 11:35:14 +00:00
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
/* for now, this is editable directly, as users can set this even if they're not animating them
|
|
|
|
|
* (to test results) */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_FACTOR);
|
2008-12-03 21:18:10 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "curval");
|
2009-08-01 06:03:08 +00:00
|
|
|
RNA_def_property_float_funcs(prop, NULL, "rna_ShapeKey_value_set", "rna_ShapeKey_value_range");
|
2009-10-21 20:58:10 +00:00
|
|
|
RNA_def_property_ui_range(prop, -10.0f, 10.0f, 10, 3);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Value", "Value of shape key at the current frame");
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
|
2008-12-03 22:35:38 +00:00
|
|
|
RNA_def_property_enum_sdna(prop, NULL, "type");
|
2012-05-22 13:43:36 +00:00
|
|
|
RNA_def_property_enum_items(prop, keyblock_type_items);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Interpolation", "Interpolation type for absolute shape keys");
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
|
2008-12-03 21:18:10 +00:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "vgroup");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Vertex Group", "Vertex weight group, to blend with basis shape");
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "relative_key", PROP_POINTER, PROP_NONE);
|
2008-12-04 00:07:47 +00:00
|
|
|
RNA_def_property_struct_type(prop, "ShapeKey");
|
2013-05-02 04:16:41 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get",
|
|
|
|
|
"rna_ShapeKey_relative_key_set", NULL, NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Relative Key", "Shape used as a relative key");
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
|
2008-12-04 00:07:47 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYBLOCK_MUTE);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Mute", "Mute this shape key");
|
2012-01-30 09:49:30 +00:00
|
|
|
RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "slider_min", PROP_FLOAT, PROP_NONE);
|
2008-12-03 21:18:10 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "slidermin");
|
2008-12-04 00:07:47 +00:00
|
|
|
RNA_def_property_range(prop, -10.0f, 10.0f);
|
2011-01-03 11:58:19 +00:00
|
|
|
RNA_def_property_float_funcs(prop, NULL, "rna_ShapeKey_slider_min_set", "rna_ShapeKey_slider_min_range");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Slider Min", "Minimum for slider");
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "slider_max", PROP_FLOAT, PROP_NONE);
|
2008-12-03 21:18:10 +00:00
|
|
|
RNA_def_property_float_sdna(prop, NULL, "slidermax");
|
2008-12-04 00:07:47 +00:00
|
|
|
RNA_def_property_range(prop, -10.0f, 10.0f);
|
2009-08-01 06:03:08 +00:00
|
|
|
RNA_def_property_float_default(prop, 1.0f);
|
2011-01-03 11:58:19 +00:00
|
|
|
RNA_def_property_float_funcs(prop, NULL, "rna_ShapeKey_slider_max_set", "rna_ShapeKey_slider_max_range");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Slider Max", "Maximum for slider");
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
|
2008-12-04 01:58:14 +00:00
|
|
|
RNA_def_property_collection_sdna(prop, NULL, "data", "totelem");
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_struct_type(prop, "UnknownType");
|
2008-12-04 01:58:14 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Data", "");
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, "rna_ShapeKey_data_begin", NULL, NULL, "rna_ShapeKey_data_get",
|
|
|
|
|
"rna_ShapeKey_data_length", NULL, NULL, NULL);
|
2008-12-03 21:18:10 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-04 01:58:14 +00:00
|
|
|
static void rna_def_key(BlenderRNA *brna)
|
2008-12-03 21:18:10 +00:00
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "Key", "ID");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Key", "Shape keys datablock containing different shapes of geometric datablocks");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_SHAPEKEY_DATA);
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "reference_key", PROP_POINTER, PROP_NONE);
|
2009-09-16 18:04:01 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2008-12-04 00:07:47 +00:00
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, "refkey");
|
2008-12-03 21:18:10 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Reference Key", "");
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "key_blocks", PROP_COLLECTION, PROP_NONE);
|
2008-12-03 21:18:10 +00:00
|
|
|
RNA_def_property_collection_sdna(prop, NULL, "block", NULL);
|
2008-12-04 00:07:47 +00:00
|
|
|
RNA_def_property_struct_type(prop, "ShapeKey");
|
2011-03-25 02:12:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Key Blocks", "Shape keys");
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2009-02-02 11:51:10 +00:00
|
|
|
rna_def_animdata_common(srna);
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "user", PROP_POINTER, PROP_NONE);
|
2009-09-16 18:04:01 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
2008-12-18 23:34:19 +00:00
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, "from");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "User", "Datablock using these shape keys");
|
2008-12-03 21:18:10 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_relative", PROP_BOOLEAN, PROP_NONE);
|
2008-12-04 00:07:47 +00:00
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "type", KEY_RELATIVE);
|
2012-04-05 05:05:18 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Relative",
|
|
|
|
|
"Make shape keys relative, "
|
|
|
|
|
"otherwise play through shapes as a sequence using the evaluation time");
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE);
|
|
|
|
|
RNA_def_property_float_sdna(prop, NULL, "ctime");
|
|
|
|
|
RNA_def_property_range(prop, MINFRAME, MAXFRAME);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Evaluation Time", "Evaluation time for absolute shape keys");
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
2008-12-03 21:18:10 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-04 01:58:14 +00:00
|
|
|
void RNA_def_key(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
rna_def_key(brna);
|
|
|
|
|
rna_def_keyblock(brna);
|
|
|
|
|
rna_def_keydata(brna);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-03 21:18:10 +00:00
|
|
|
#endif
|