diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-11 02:05:47 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-11 02:05:47 +0400 |
commit | 3e1e76a2c1f711b4888cb6e82892f6c765b21fef (patch) | |
tree | 648b9023659155728c7efd6706c5d34cece44746 /source/blender | |
parent | 8e13bb3f602eac73296e98fe149d8bd18165a244 (diff) |
Fix #35289: UV layout export to image was extremely slow for large meshes. This
was due to slow implementation of slice operation for things like mesh uv data.
Made that faster now for cases where the internal storage is an array.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 23 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 18 |
3 files changed, 29 insertions, 13 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 816a5b0bdc3..45613f2083f 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -857,6 +857,7 @@ PointerRNA RNA_property_pointer_get_default(PointerRNA *ptr, PropertyRNA *prop); void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, CollectionPropertyIterator *iter); void RNA_property_collection_next(CollectionPropertyIterator *iter); +void RNA_property_collection_skip(CollectionPropertyIterator *iter, int num); void RNA_property_collection_end(CollectionPropertyIterator *iter); int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop); int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *t_ptr); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index a7e81416b80..ac2c994a4f8 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2820,6 +2820,29 @@ void RNA_property_collection_next(CollectionPropertyIterator *iter) cprop->next(iter); } +void RNA_property_collection_skip(CollectionPropertyIterator *iter, int num) +{ + CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)rna_ensure_property(iter->prop); + int i; + + if (num > 1 && (iter->idprop || (cprop->property.flag & PROP_RAW_ARRAY))) { + /* fast skip for array */ + ArrayIterator *internal = iter->internal; + + if (!internal->skip) { + internal->ptr += internal->itemsize*(num-1); + iter->valid = (internal->ptr < internal->endptr); + if(iter->valid) + RNA_property_collection_next(iter); + return; + } + } + + /* slow iteration otherwise */ + for (i = 0; i < num && iter->valid; i++) + RNA_property_collection_next(iter); +} + void RNA_property_collection_end(CollectionPropertyIterator *iter) { CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)rna_ensure_property(iter->prop); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index f1c0530fedf..a0b2cd639bb 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -2270,7 +2270,7 @@ static PyObject *pyrna_prop_collection_subscript_str_lib_pair(BPy_PropertyRNA *s static PyObject *pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self, Py_ssize_t start, Py_ssize_t stop) { CollectionPropertyIterator rna_macro_iter; - int count = 0; + int count; PyObject *list; PyObject *item; @@ -2279,20 +2279,12 @@ static PyObject *pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self, Py list = PyList_New(0); - /* first loop up-until the start */ - for (RNA_property_collection_begin(&self->ptr, self->prop, &rna_macro_iter); - rna_macro_iter.valid; - RNA_property_collection_next(&rna_macro_iter)) - { - /* PointerRNA itemptr = rna_macro_iter.ptr; */ - if (count == start) { - break; - } - count++; - } + /* skip to start */ + RNA_property_collection_begin(&self->ptr, self->prop, &rna_macro_iter); + RNA_property_collection_skip(&rna_macro_iter, start); /* add items until stop */ - for (; rna_macro_iter.valid; + for (count = start; rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) { item = pyrna_struct_CreatePyObject(&rna_macro_iter.ptr); |