Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/animation/drivers.c
| Show All 34 Lines | |||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_texture_types.h" | #include "DNA_texture_types.h" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_node.h" | |||||
| #include "BKE_main.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_build.h" | #include "DEG_depsgraph_build.h" | ||||
| #include "ED_keyframing.h" | #include "ED_keyframing.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| ▲ Show 20 Lines • Show All 790 Lines • ▼ Show 20 Lines | bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace) | ||||
| /* since driver variables are cached, the expression needs re-compiling too */ | /* since driver variables are cached, the expression needs re-compiling too */ | ||||
| BKE_driver_invalidate_expression(driver, false, true); | BKE_driver_invalidate_expression(driver, false, true); | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* -------------------------------------------------- */ | /* -------------------------------------------------- */ | ||||
| /* Compute an ID pointer and path to property valid for use in a driver. | |||||
| * Corrects for ID references that are not independent (e.g. material NodeTree). */ | |||||
| bool ANIM_get_target_ID_and_path_to_property( | |||||
| Main *bmain, PointerRNA *ptr, PropertyRNA *prop, int index, ID **r_id, char **r_path) | |||||
| { | |||||
| int dim = RNA_property_array_dimension(ptr, prop, NULL); | |||||
| char *path = RNA_path_from_ID_to_property_index(ptr, prop, dim, index); | |||||
| ID *id = ptr->id.data; | |||||
| if (!path) { | |||||
| return false; | |||||
| } | |||||
| if (id->flag & LIB_PRIVATE_DATA) { | |||||
| ID *owner = NULL; | |||||
| const char *prefix = NULL; | |||||
| switch (GS(id->name)) { | |||||
| case ID_NT: | |||||
| prefix = "node_tree"; | |||||
| owner = BKE_node_tree_find_owner_ID(bmain, (bNodeTree *)id); | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| if (!owner || !prefix) { | |||||
| MEM_freeN(path); | |||||
| return false; | |||||
| } | |||||
| else if (owner != id) { | |||||
| char *new_path = BLI_sprintfN("%s%s%s", prefix, path[0] == '[' ? "" : ".", path); | |||||
| MEM_freeN(path); | |||||
| path = new_path; | |||||
| id = owner; | |||||
| } | |||||
| } | |||||
| *r_id = id; | |||||
| *r_path = path; | |||||
| return true; | |||||
| } | |||||
| /* Create a driver & variable that reads the specified property, | /* Create a driver & variable that reads the specified property, | ||||
| * and store it in the buffers for Paste Driver and Paste Variables. */ | * and store it in the buffers for Paste Driver and Paste Variables. */ | ||||
| void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const char *var_name) | void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const char *var_name) | ||||
| { | { | ||||
| /* Clear copy/paste buffer first (for consistency with other copy/paste buffers). */ | /* Clear copy/paste buffer first (for consistency with other copy/paste buffers). */ | ||||
| ANIM_drivers_copybuf_free(); | ANIM_drivers_copybuf_free(); | ||||
| ANIM_driver_vars_copybuf_free(); | ANIM_driver_vars_copybuf_free(); | ||||
| ▲ Show 20 Lines • Show All 476 Lines • Show Last 20 Lines | |||||