Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_util.h
| Show First 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | static inline int get_int(PointerRNA& ptr, const char *name) | ||||
| return RNA_int_get(&ptr, name); | return RNA_int_get(&ptr, name); | ||||
| } | } | ||||
| static inline void set_int(PointerRNA& ptr, const char *name, int value) | static inline void set_int(PointerRNA& ptr, const char *name, int value) | ||||
| { | { | ||||
| RNA_int_set(&ptr, name, value); | RNA_int_set(&ptr, name, value); | ||||
| } | } | ||||
| static inline int get_enum(PointerRNA& ptr, const char *name) | /* Get a RNA enum value with sanity check: if the RNA value is above num_values | ||||
| { | * the function will return a fallback default value. | ||||
| return RNA_enum_get(&ptr, name); | * | ||||
| * NOTE: This function assumes that RNA enum values are a continuous sequence | |||||
| * from 0 to num_values-1. Be careful to use it with enums where some values are | |||||
| * deprecated! | |||||
| */ | |||||
| static inline int get_enum(PointerRNA& ptr, | |||||
| const char *name, | |||||
| int num_values = -1, | |||||
| int default_value = -1) | |||||
| { | |||||
| int value = RNA_enum_get(&ptr, name); | |||||
| if(num_values != -1 && value >= num_values) { | |||||
| assert(default_value != -1); | |||||
| value = default_value; | |||||
| } | |||||
| return value; | |||||
| } | } | ||||
| static inline string get_enum_identifier(PointerRNA& ptr, const char *name) | static inline string get_enum_identifier(PointerRNA& ptr, const char *name) | ||||
| { | { | ||||
| PropertyRNA *prop = RNA_struct_find_property(&ptr, name); | PropertyRNA *prop = RNA_struct_find_property(&ptr, name); | ||||
| const char *identifier = ""; | const char *identifier = ""; | ||||
| int value = RNA_property_enum_get(&ptr, prop); | int value = RNA_property_enum_get(&ptr, prop); | ||||
| ▲ Show 20 Lines • Show All 336 Lines • Show Last 20 Lines | |||||