[Bf-blender-cvs] [c8dd6b6] master: Fix T38013: Incorrect RNA Path when trying to keyframe the nth vertex of Bezier curve shape key data

Joshua Leung noreply at git.blender.org
Wed Jan 1 12:32:52 CET 2014


Commit: c8dd6b67b6de00d4839d76d0cbffe3d187995cdc
Author: Joshua Leung
Date:   Thu Jan 2 00:28:02 2014 +1300
https://developer.blender.org/rBc8dd6b67b6de00d4839d76d0cbffe3d187995cdc

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.

===================================================================

M	source/blender/makesrna/intern/rna_key.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index 6d6f516..68e132f 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));




More information about the Bf-blender-cvs mailing list