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.
This commit is contained in:
Brecht Van Lommel 2013-05-10 22:05:47 +00:00
parent 8e13bb3f60
commit 3e1e76a2c1
3 changed files with 29 additions and 13 deletions

@ -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);

@ -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);

@ -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);