Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_object.c
| Show First 20 Lines • Show All 1,320 Lines • ▼ Show 20 Lines | if (ob->protectflag & OB_LOCK_ROT4D) { | ||||
| } | } | ||||
| } | } | ||||
| return PROP_EDITABLE; | return PROP_EDITABLE; | ||||
| } | } | ||||
| static int rna_MaterialSlot_index(PointerRNA *ptr) | static int rna_MaterialSlot_index(PointerRNA *ptr) | ||||
| { | { | ||||
| /* There is an offset of one, so that `ptr->data` is not null. */ | /* There is an offset, so that `ptr->data` is not null and unique across IDs. */ | ||||
| return POINTER_AS_INT(ptr->data) - 1; | return (uintptr_t)ptr->data - (uintptr_t)ptr->owner_id; | ||||
JacquesLucke: This is still using `POINTER_AS_INT` on a pointer. This works by accident.
{F10327308} | |||||
| } | } | ||||
| static int rna_MaterialSlot_material_editable(PointerRNA *ptr, const char **UNUSED(r_info)) | static int rna_MaterialSlot_material_editable(PointerRNA *ptr, const char **UNUSED(r_info)) | ||||
| { | { | ||||
| Object *ob = (Object *)ptr->owner_id; | Object *ob = (Object *)ptr->owner_id; | ||||
| const int index = rna_MaterialSlot_index(ptr); | const int index = rna_MaterialSlot_index(ptr); | ||||
| bool is_editable; | bool is_editable; | ||||
| ▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | static void rna_Object_material_slots_next(CollectionPropertyIterator *iter) | ||||
| const int length = rna_Object_material_slots_length(&iter->ptr); | const int length = rna_Object_material_slots_length(&iter->ptr); | ||||
| iter->internal.count.item++; | iter->internal.count.item++; | ||||
| iter->valid = iter->internal.count.item < length; | iter->valid = iter->internal.count.item < length; | ||||
| } | } | ||||
| static PointerRNA rna_Object_material_slots_get(CollectionPropertyIterator *iter) | static PointerRNA rna_Object_material_slots_get(CollectionPropertyIterator *iter) | ||||
| { | { | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| RNA_pointer_create((ID *)iter->internal.count.ptr, | ID *id = (ID *)iter->internal.count.ptr; | ||||
| RNA_pointer_create(id, | |||||
| &RNA_MaterialSlot, | &RNA_MaterialSlot, | ||||
| /* Add one, so that `ptr->data` is not null. */ | /* Add offset, so that `ptr->data` is not null and unique across IDs. */ | ||||
| POINTER_FROM_INT(iter->internal.count.item + 1), | (void *)(iter->internal.count.item + (uintptr_t)id), | ||||
| &ptr); | &ptr); | ||||
| return ptr; | return ptr; | ||||
| } | } | ||||
| static void rna_Object_material_slots_end(CollectionPropertyIterator *UNUSED(iter)) | static void rna_Object_material_slots_end(CollectionPropertyIterator *UNUSED(iter)) | ||||
| { | { | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 2,327 Lines • Show Last 20 Lines | |||||
This is still using POINTER_AS_INT on a pointer. This works by accident.