diff options
author | Joshua Leung <aligorith@gmail.com> | 2014-01-01 15:28:02 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2014-01-01 15:28:39 +0400 |
commit | c8dd6b67b6de00d4839d76d0cbffe3d187995cdc (patch) | |
tree | af25e4d3606dd77cf90eb9a174fabfea07243eb6 | |
parent | de147a907f05739d49449e3184e6918dadcfdad9 (diff) |
Fix T38013: Incorrect RNA Path when trying to keyframe the nth vertex of Bezier curve shape key data
key->elemsize is set to 16 for ID_CU (i.e. Curves and NURBS surfaces). However,
this value is only correct for NURBS (which use BPoints). When trying to keyframe
the nth vertex of a particular shape key's data (where the shape keys are being
used on Bezier curves), the RNA Paths for that are generated with the wrong
data index. From empirical testing, it appears that this should be 12 instead.
-rw-r--r-- | source/blender/makesrna/intern/rna_key.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 6d6f516ecac..68e132f3207 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -432,6 +432,19 @@ static int rna_ShapeKeyPoint_get_index(Key *key, KeyBlock *kb, float *point) return (int)(pt - start) / key->elemsize; } +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; +} + static char *rna_ShapeKeyPoint_path(PointerRNA *ptr) { ID *id = (ID *)ptr->id.data; @@ -444,7 +457,12 @@ static char *rna_ShapeKeyPoint_path(PointerRNA *ptr) if (kb) { char name_esc_kb[sizeof(kb->name) * 2]; - int index = rna_ShapeKeyPoint_get_index(key, kb, point); + int index; + + if (ptr->type == &RNA_ShapeKeyBezierPoint) + index = rna_ShapeKeyBezierPoint_get_index(kb, point); + else + index = rna_ShapeKeyPoint_get_index(key, kb, point); BLI_strescape(name_esc_kb, kb->name, sizeof(name_esc_kb)); |