Constraints: Use RNA update instead of block update
Allows to have more control over which tags are done for which properties. This is a part of T62960 which fixes the issue in the 2.7 series.
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
#include "DNA_cachefile_types.h"
|
#include "DNA_cachefile_types.h"
|
||||||
|
#include "DNA_constraint_types.h"
|
||||||
#include "DNA_node_types.h"
|
#include "DNA_node_types.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
@@ -47,8 +48,10 @@
|
|||||||
#include "BLF_api.h"
|
#include "BLF_api.h"
|
||||||
#include "BLT_translation.h"
|
#include "BLT_translation.h"
|
||||||
|
|
||||||
|
#include "BKE_action.h"
|
||||||
#include "BKE_colorband.h"
|
#include "BKE_colorband.h"
|
||||||
#include "BKE_colortools.h"
|
#include "BKE_colortools.h"
|
||||||
|
#include "BKE_constraint.h"
|
||||||
#include "BKE_context.h"
|
#include "BKE_context.h"
|
||||||
#include "BKE_depsgraph.h"
|
#include "BKE_depsgraph.h"
|
||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
@@ -1164,47 +1167,6 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
|||||||
|
|
||||||
/************************ Constraint Template *************************/
|
/************************ Constraint Template *************************/
|
||||||
|
|
||||||
#include "DNA_constraint_types.h"
|
|
||||||
|
|
||||||
#include "BKE_action.h"
|
|
||||||
#include "BKE_constraint.h"
|
|
||||||
|
|
||||||
#define B_CONSTRAINT_TEST 5
|
|
||||||
// #define B_CONSTRAINT_CHANGETARGET 6
|
|
||||||
|
|
||||||
static void do_constraint_panels(bContext *C, void *ob_pt, int event)
|
|
||||||
{
|
|
||||||
Object *ob = (Object *)ob_pt;
|
|
||||||
|
|
||||||
switch (event) {
|
|
||||||
case B_CONSTRAINT_TEST:
|
|
||||||
break; /* no handling */
|
|
||||||
#if 0 /* UNUSED */
|
|
||||||
case B_CONSTRAINT_CHANGETARGET:
|
|
||||||
{
|
|
||||||
Main *bmain = CTX_data_main(C);
|
|
||||||
if (ob->pose)
|
|
||||||
BKE_pose_tag_recalc(bmain, ob->pose); /* checks & sorts pose channels */
|
|
||||||
DAG_relations_tag_update(bmain);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* note: RNA updates now call this, commenting else it gets called twice.
|
|
||||||
* if there are problems because of this, then rna needs changed update functions.
|
|
||||||
*
|
|
||||||
* object_test_constraints(ob);
|
|
||||||
* if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); */
|
|
||||||
|
|
||||||
if (ob->type == OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
|
|
||||||
else DAG_id_tag_update(&ob->id, OB_RECALC_OB);
|
|
||||||
|
|
||||||
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v)
|
static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v)
|
||||||
{
|
{
|
||||||
ED_object_constraint_set_active(ob_v, con_v);
|
ED_object_constraint_set_active(ob_v, con_v);
|
||||||
@@ -1239,7 +1201,6 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
|
|||||||
|
|
||||||
/* unless button has own callback, it adds this callback to button */
|
/* unless button has own callback, it adds this callback to button */
|
||||||
block = uiLayoutGetBlock(layout);
|
block = uiLayoutGetBlock(layout);
|
||||||
UI_block_func_handle_set(block, do_constraint_panels, ob);
|
|
||||||
UI_block_func_set(block, constraint_active_func, ob, con);
|
UI_block_func_set(block, constraint_active_func, ob, con);
|
||||||
|
|
||||||
RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr);
|
RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr);
|
||||||
@@ -1259,7 +1220,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
|
|||||||
UI_block_emboss_set(block, UI_EMBOSS);
|
UI_block_emboss_set(block, UI_EMBOSS);
|
||||||
|
|
||||||
/* name */
|
/* name */
|
||||||
uiDefBut(block, UI_BTYPE_LABEL, B_CONSTRAINT_TEST, typestr,
|
uiDefBut(block, UI_BTYPE_LABEL, 0, typestr,
|
||||||
xco + 0.5f * UI_UNIT_X, yco, 5 * UI_UNIT_X, 0.9f * UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "");
|
xco + 0.5f * UI_UNIT_X, yco, 5 * UI_UNIT_X, 0.9f * UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "");
|
||||||
|
|
||||||
if (con->flag & CONSTRAINT_DISABLE)
|
if (con->flag & CONSTRAINT_DISABLE)
|
||||||
@@ -1278,9 +1239,9 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
|
|||||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||||
|
|
||||||
/* draw a ghost icon (for proxy) and also a lock beside it, to show that constraint is "proxy locked" */
|
/* draw a ghost icon (for proxy) and also a lock beside it, to show that constraint is "proxy locked" */
|
||||||
uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_GHOST, xco + 12.2f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
|
uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_GHOST, xco + 12.2f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
|
||||||
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
|
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
|
||||||
uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco + 13.1f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
|
uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LOCKED, xco + 13.1f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
|
||||||
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
|
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
|
||||||
|
|
||||||
UI_block_emboss_set(block, UI_EMBOSS);
|
UI_block_emboss_set(block, UI_EMBOSS);
|
||||||
|
@@ -2520,17 +2520,20 @@ void RNA_def_constraint(BlenderRNA *brna)
|
|||||||
RNA_def_property_enum_items(prop, owner_space_pchan_items);
|
RNA_def_property_enum_items(prop, owner_space_pchan_items);
|
||||||
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_owner_space_itemf");
|
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_owner_space_itemf");
|
||||||
RNA_def_property_ui_text(prop, "Owner Space", "Space that owner is evaluated in");
|
RNA_def_property_ui_text(prop, "Owner Space", "Space that owner is evaluated in");
|
||||||
|
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "target_space", PROP_ENUM, PROP_NONE);
|
prop = RNA_def_property(srna, "target_space", PROP_ENUM, PROP_NONE);
|
||||||
RNA_def_property_enum_sdna(prop, NULL, "tarspace");
|
RNA_def_property_enum_sdna(prop, NULL, "tarspace");
|
||||||
RNA_def_property_enum_items(prop, target_space_pchan_items);
|
RNA_def_property_enum_items(prop, target_space_pchan_items);
|
||||||
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_target_space_itemf");
|
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_target_space_itemf");
|
||||||
RNA_def_property_ui_text(prop, "Target Space", "Space that target is evaluated in");
|
RNA_def_property_ui_text(prop, "Target Space", "Space that target is evaluated in");
|
||||||
|
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
|
||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_OFF);
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_OFF);
|
||||||
RNA_def_property_ui_text(prop, "Disable", "Enable/Disable Constraint");
|
RNA_def_property_ui_text(prop, "Disable", "Enable/Disable Constraint");
|
||||||
|
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_EXPAND);
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_EXPAND);
|
||||||
|
Reference in New Issue
Block a user