[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34499] trunk/blender/source/blender/ makesrna/intern/rna_key.c: ShapeKeys RNA Wrapping: Code cleanup
Joshua Leung
aligorith at gmail.com
Wed Jan 26 11:46:44 CET 2011
Revision: 34499
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34499
Author: aligorith
Date: 2011-01-26 10:46:43 +0000 (Wed, 26 Jan 2011)
Log Message:
-----------
ShapeKeys RNA Wrapping: Code cleanup
Replaced some manual/inlined operations with their equivalents from
the listbase library funcs.
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/rna_key.c
Modified: trunk/blender/source/blender/makesrna/intern/rna_key.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_key.c 2011-01-26 10:25:15 UTC (rev 34498)
+++ trunk/blender/source/blender/makesrna/intern/rna_key.c 2011-01-26 10:46:43 UTC (rev 34499)
@@ -57,6 +57,7 @@
case ID_KE: return (Key*)id;
case ID_LT: return ((Lattice*)id)->key;
case ID_ME: return ((Mesh*)id)->key;
+ case ID_OB: return ob_get_key((Object*)id);
default: return NULL;
}
}
@@ -143,12 +144,9 @@
Key *key= rna_ShapeKey_find_key(id);
KeyBlock *kb= NULL;
PointerRNA ptr;
- int a;
- if(key && value < key->totkey)
- for(a=0, kb=key->block.first; kb; kb=kb->next, a++)
- if(a == value)
- break;
+ if (key && value < key->totkey)
+ kb = BLI_findlink(&key->block, value);
RNA_pointer_create(id, &RNA_ShapeKey, kb, &ptr);
@@ -158,13 +156,11 @@
int rna_object_shapekey_index_set(ID *id, PointerRNA value, int current)
{
Key *key= rna_ShapeKey_find_key(id);
- KeyBlock *kb;
- int a;
- if(key)
- for(a=0, kb=key->block.first; kb; kb=kb->next, a++)
- if(kb == value.data)
- return a;
+ if (key) {
+ int a = BLI_findindex(&key->block, value.data);
+ if (a >= 0) return a;
+ }
return current;
}
@@ -286,17 +282,17 @@
Curve *cu;
Nurb *nu;
int tot= kb->totelem, size= key->elemsize;
-
+
if(GS(key->from->name) == ID_CU) {
cu= (Curve*)key->from;
nu= cu->nurb.first;
-
+
if(nu->bezt) {
tot /= 3;
size *= 3;
}
}
-
+
rna_iterator_array_begin(iter, (void*)kb->data, size, tot, 0, NULL);
}
@@ -307,15 +303,15 @@
Curve *cu;
Nurb *nu;
int tot= kb->totelem;
-
+
if(GS(key->from->name) == ID_CU) {
cu= (Curve*)key->from;
nu= cu->nurb.first;
-
+
if(nu->bezt)
tot /= 3;
}
-
+
return tot;
}
@@ -325,11 +321,11 @@
StructRNA *type;
Curve *cu;
Nurb *nu;
-
+
if(GS(key->from->name) == ID_CU) {
cu= (Curve*)key->from;
nu= cu->nurb.first;
-
+
if(nu->bezt)
type= &RNA_ShapeKeyBezierPoint;
else
More information about the Bf-blender-cvs
mailing list