Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_templates.c
| Show First 20 Lines • Show All 2,057 Lines • ▼ Show 20 Lines | uiListPanelIDFromDataFunc panel_id_func = use_bone_constraints ? bone_constraint_panel_id : | ||||
| object_constraint_panel_id; | object_constraint_panel_id; | ||||
| const bool panels_match = UI_panel_list_matches_data(region, constraints, panel_id_func); | const bool panels_match = UI_panel_list_matches_data(region, constraints, panel_id_func); | ||||
| if (!panels_match) { | if (!panels_match) { | ||||
| UI_panels_free_instanced(C, region); | UI_panels_free_instanced(C, region); | ||||
| bConstraint *con = (constraints == NULL) ? NULL : constraints->first; | bConstraint *con = (constraints == NULL) ? NULL : constraints->first; | ||||
| for (int i = 0; con; i++, con = con->next) { | for (int i = 0; con; i++, con = con->next) { | ||||
| if (con->type == CONSTRAINT_TYPE_KINEMATIC) { | |||||
| bKinematicConstraint *data = con->data; | |||||
| if (data->flag & CONSTRAINT_IK_TEMP) { | |||||
| continue; | |||||
| } | |||||
| } | |||||
| char panel_idname[MAX_NAME]; | char panel_idname[MAX_NAME]; | ||||
| panel_id_func(con, panel_idname); | panel_id_func(con, panel_idname); | ||||
| /* Create custom data RNA pointer. */ | /* Create custom data RNA pointer. */ | ||||
| PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | ||||
| RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr); | RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr); | ||||
| Panel *new_panel = UI_panel_add_instanced(region, ®ion->panels, panel_idname, con_ptr); | Panel *new_panel = UI_panel_add_instanced(region, ®ion->panels, panel_idname, con_ptr); | ||||
| if (new_panel) { | if (new_panel) { | ||||
| /* Set the list panel functionality function pointers since we don't do it with python. */ | /* Set the list panel functionality function pointers since we don't do it with python. */ | ||||
| new_panel->type->set_list_data_expand_flag = set_constraint_expand_flag; | new_panel->type->set_list_data_expand_flag = set_constraint_expand_flag; | ||||
| new_panel->type->get_list_data_expand_flag = get_constraint_expand_flag; | new_panel->type->get_list_data_expand_flag = get_constraint_expand_flag; | ||||
| new_panel->type->reorder = constraint_reorder; | new_panel->type->reorder = constraint_reorder; | ||||
| UI_panel_set_expand_from_list_data(C, new_panel); | UI_panel_set_expand_from_list_data(C, new_panel); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* Assuming there's only one group of instanced panels, update the custom data pointers. */ | /* Assuming there's only one group of instanced panels, update the custom data pointers. */ | ||||
| Panel *panel = region->panels.first; | Panel *panel = region->panels.first; | ||||
| LISTBASE_FOREACH (bConstraint *, con, constraints) { | LISTBASE_FOREACH (bConstraint *, con, constraints) { | ||||
| /* Move to the next instanced panel corresponding to the next constraint. */ | /* Move to the next instanced panel corresponding to the next constraint. */ | ||||
HooglyBoogly: It worked fine for me when I tested this patch, but theoretically this check should be… | |||||
| while ((panel->type == NULL) || !(panel->type->flag & PNL_INSTANCED)) { | while ((panel->type == NULL) || !(panel->type->flag & PNL_INSTANCED)) { | ||||
| panel = panel->next; | panel = panel->next; | ||||
| BLI_assert(panel != NULL); /* There shouldn't be fewer panels than constraint panels. */ | BLI_assert(panel != NULL); /* There shouldn't be fewer panels than constraint panels. */ | ||||
| } | } | ||||
| PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "constraint panel customdata"); | PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "constraint panel customdata"); | ||||
| RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr); | RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr); | ||||
| UI_panel_custom_data_set(panel, con_ptr); | UI_panel_custom_data_set(panel, con_ptr); | ||||
| ▲ Show 20 Lines • Show All 5,329 Lines • Show Last 20 Lines | |||||
It worked fine for me when I tested this patch, but theoretically this check should be duplicated down here too). I'm guessing it works because they're added at the end.
Otherwise it might break in the case where the constraint list doesn't change over successive redraws.
Sorry for the messiness of this code. It's in my personal medium terms to clean up / generalize the code for the different stacks.
This check would become a generalized "don't show data in UI" check.
So let's keep this consistent with the other templates and add the check down here for now too.