Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-01-05 01:30:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-05 01:30:09 +0300
commite90b6eefb191693b0ffe1d5a0b1bc399fc5b0aef (patch)
tree7e8823cb3a14c16b183b66b860569acf86727dcf /source/blender/makesrna/intern/rna_access.c
parent7f03297fc8f3625bbad8ecc18d44b916536ca71f (diff)
patch from Benoit Bolsee (ben2610) for 4 bugs in report [#20527] Several bugs in RNA
from the report... # bug 1. UV properties are not raw editable but are reported # as RAW_TYPE_INT by RNA causing wrong conversion # internally (bpy_rna.c line 2205) # bug 2. raw update of UV coordinates crash blender (rna_access.c line 252) mtfaces.foreach_set("uv", rawuvs) # workaround: #for i in range(int(len(faces)/4)): # mtfaces[i].uv = uvs[i] # bug 3. raw update of non-array property fails (rna_access.c line 2270) mfaces.foreach_set("material_index", mats) # workaround: # for i in range(int(len(mfaces))): # mfaces[i].material_index = mats[i] # bug 4. It is not possible to add a vertex color layer using mesh API. me.add_vertex_color() # no workaround...
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c77
1 files changed, 71 insertions, 6 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index d8b31f4093e..61fdbb27507 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -249,7 +249,7 @@ static int rna_ensure_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
{
if(prop->magic == RNA_MAGIC) {
int arraylen[RNA_MAX_ARRAY_DIMENSION];
- return (prop->getlength)? prop->getlength(ptr, arraylen): prop->totarraylength;
+ return (prop->getlength && ptr->data)? prop->getlength(ptr, arraylen): prop->totarraylength;
}
else {
IDProperty *idprop= (IDProperty*)prop;
@@ -2266,8 +2266,9 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro
/* try to access as raw array */
if(RNA_property_collection_raw_array(ptr, prop, itemprop, &out)) {
- if(in.len != itemlen*out.len) {
- BKE_reportf(reports, RPT_ERROR, "Array length mismatch (expected %d, got %d).", out.len*itemlen, in.len);
+ int arraylen = (itemlen == 0) ? 1 : itemlen;
+ if(in.len != arraylen*out.len) {
+ BKE_reportf(reports, RPT_ERROR, "Array length mismatch (expected %d, got %d).", out.len*arraylen, in.len);
return 0;
}
@@ -2277,8 +2278,7 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro
void *outp= out.array;
int a, size;
- itemlen= (itemlen == 0)? 1: itemlen;
- size= RNA_raw_type_sizeof(out.type) * itemlen;
+ size= RNA_raw_type_sizeof(out.type) * arraylen;
for(a=0; a<out.len; a++) {
if(set) memcpy(outp, inp, size);
@@ -2300,6 +2300,12 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro
void *tmparray= NULL;
int tmplen= 0;
int err= 0, j, a= 0;
+ int needconv = 1;
+
+ if (((itemtype == PROP_BOOLEAN || itemtype == PROP_INT) && in.type == PROP_RAW_INT) ||
+ (itemtype == PROP_FLOAT && in.type == PROP_RAW_FLOAT))
+ /* avoid creating temporary buffer if the data type match */
+ needconv = 0;
/* no item property pointer, can still be id property, or
* property of a type derived from the collection pointer type */
@@ -2387,7 +2393,7 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro
}
a++;
}
- else {
+ else if (needconv == 1) {
/* allocate temporary array if needed */
if(tmparray && tmplen != itemlen) {
MEM_freeN(tmparray);
@@ -2448,6 +2454,50 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro
}
}
}
+ else {
+ if(set) {
+ switch(itemtype) {
+ case PROP_BOOLEAN: {
+ RNA_property_boolean_set_array(&itemptr, iprop, &((int*)in.array)[a]);
+ a += itemlen;
+ break;
+ }
+ case PROP_INT: {
+ RNA_property_int_set_array(&itemptr, iprop, &((int*)in.array)[a]);
+ a += itemlen;
+ break;
+ }
+ case PROP_FLOAT: {
+ RNA_property_float_set_array(&itemptr, iprop, &((float*)in.array)[a]);
+ a += itemlen;
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ else {
+ switch(itemtype) {
+ case PROP_BOOLEAN: {
+ RNA_property_boolean_get_array(&itemptr, iprop, &((int*)in.array)[a]);
+ a += itemlen;
+ break;
+ }
+ case PROP_INT: {
+ RNA_property_int_get_array(&itemptr, iprop, &((int*)in.array)[a]);
+ a += itemlen;
+ break;
+ }
+ case PROP_FLOAT: {
+ RNA_property_float_get_array(&itemptr, iprop, &((float*)in.array)[a]);
+ a += itemlen;
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
}
}
}
@@ -2462,6 +2512,21 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro
RawPropertyType RNA_property_raw_type(PropertyRNA *prop)
{
+ if (prop->rawtype == PROP_RAW_UNSET) {
+ /* this property has no raw access, yet we try to provide a raw type to help building the array */
+ switch (prop->type) {
+ case PROP_BOOLEAN:
+ return PROP_RAW_INT;
+ case PROP_INT:
+ return PROP_RAW_INT;
+ case PROP_FLOAT:
+ return PROP_RAW_FLOAT;
+ case PROP_ENUM:
+ return PROP_RAW_INT;
+ default:
+ break;
+ }
+ }
return prop->rawtype;
}