Cleanup: Remove deprecated Python and Rigid Body Joint constraints
Remove long-deprecated constraints that will likely never be implemented in this form. - Rigid Body Joint Constraint was removed in 2.80, but some references remained in the code. Versioning code was written that tried to remove them on load, but since constraint initialization code sets the type to CONSTRAINT_TYPE_NULL before versioning gets a chance, the versioning code ended up never running. This has all been removed. - Python/Script Constraint never worked since 2.50 and showed an error message in the UI panel. These constraints now load as 'null' constraint, as seems to be (looking at the code) the way that Blender currently deals with removed constraint types. These still show up in the outliner and python API, but have no UI panel. Removing such constraints completely will be left for another time, as it is beyond the scope of removing these two specific constraint types. Pull Request: https://projects.blender.org/blender/blender/pulls/136672
This commit is contained in:
committed by
Sybren A. Stüvel
parent
b0e4c31bb0
commit
ba04393fde
@@ -646,7 +646,6 @@ class SpellChecker:
|
||||
"polygroup", "polygroups",
|
||||
"poselib",
|
||||
"pushpull",
|
||||
"pyconstraint", "pyconstraints",
|
||||
"qe", # keys...
|
||||
"shaderfx", "shaderfxs",
|
||||
"shapekey", "shapekeys",
|
||||
|
||||
@@ -857,10 +857,6 @@ class ConstraintButtonsPanel:
|
||||
|
||||
self.draw_influence(layout, con)
|
||||
|
||||
def draw_python_constraint(self, _context):
|
||||
layout = self.layout
|
||||
layout.label(text="Blender 2.6 doesn't support Python constraints yet")
|
||||
|
||||
def draw_armature(self, context):
|
||||
layout = self.layout
|
||||
con = self.get_constraint(context)
|
||||
@@ -1650,18 +1646,6 @@ class BONE_PT_bTransformCacheConstraint_time(BoneConstraintPanel, ConstraintButt
|
||||
self.draw_transform_cache_time(context)
|
||||
|
||||
|
||||
# Python Constraint
|
||||
|
||||
class OBJECT_PT_bPythonConstraint(ObjectConstraintPanel, ConstraintButtonsPanel, Panel):
|
||||
def draw(self, context):
|
||||
self.draw_python_constraint(context)
|
||||
|
||||
|
||||
class BONE_PT_bPythonConstraint(BoneConstraintPanel, ConstraintButtonsPanel, Panel):
|
||||
def draw(self, context):
|
||||
self.draw_python_constraint(context)
|
||||
|
||||
|
||||
# Armature Constraint
|
||||
|
||||
class OBJECT_PT_bArmatureConstraint(ObjectConstraintPanel, ConstraintButtonsPanel, Panel):
|
||||
@@ -1740,7 +1724,6 @@ classes = (
|
||||
OBJECT_PT_bTransformCacheConstraint_procedural,
|
||||
OBJECT_PT_bTransformCacheConstraint_velocity,
|
||||
OBJECT_PT_bTransformCacheConstraint_layers,
|
||||
OBJECT_PT_bPythonConstraint,
|
||||
OBJECT_PT_bArmatureConstraint,
|
||||
OBJECT_PT_bArmatureConstraint_bones,
|
||||
# Bone panels
|
||||
@@ -1781,7 +1764,6 @@ classes = (
|
||||
BONE_PT_bTransformCacheConstraint_procedural,
|
||||
BONE_PT_bTransformCacheConstraint_velocity,
|
||||
BONE_PT_bTransformCacheConstraint_layers,
|
||||
BONE_PT_bPythonConstraint,
|
||||
BONE_PT_bArmatureConstraint,
|
||||
BONE_PT_bArmatureConstraint_bones,
|
||||
)
|
||||
|
||||
@@ -2466,139 +2466,6 @@ static bConstraintTypeInfo CTI_SAMEVOL = {
|
||||
/*evaluate_constraint*/ samevolume_evaluate,
|
||||
};
|
||||
|
||||
/* ----------- Python Constraint -------------- */
|
||||
|
||||
static void pycon_free(bConstraint *con)
|
||||
{
|
||||
bPythonConstraint *data = static_cast<bPythonConstraint *>(con->data);
|
||||
|
||||
/* id-properties */
|
||||
IDP_FreeProperty(data->prop);
|
||||
|
||||
/* multiple targets */
|
||||
BLI_freelistN(&data->targets);
|
||||
}
|
||||
|
||||
static void pycon_copy(bConstraint *con, bConstraint *srccon)
|
||||
{
|
||||
bPythonConstraint *pycon = (bPythonConstraint *)con->data;
|
||||
bPythonConstraint *opycon = (bPythonConstraint *)srccon->data;
|
||||
|
||||
pycon->prop = IDP_CopyProperty(opycon->prop);
|
||||
BLI_duplicatelist(&pycon->targets, &opycon->targets);
|
||||
}
|
||||
|
||||
static void pycon_new_data(void *cdata)
|
||||
{
|
||||
bPythonConstraint *data = (bPythonConstraint *)cdata;
|
||||
|
||||
/* Everything should be set correctly by calloc, except for the prop->type constant. */
|
||||
data->prop = MEM_callocN<IDProperty>("PyConstraintProps");
|
||||
data->prop->type = IDP_GROUP;
|
||||
}
|
||||
|
||||
static int pycon_get_tars(bConstraint *con, ListBase *list)
|
||||
{
|
||||
if (con && list) {
|
||||
bPythonConstraint *data = static_cast<bPythonConstraint *>(con->data);
|
||||
|
||||
list->first = data->targets.first;
|
||||
list->last = data->targets.last;
|
||||
|
||||
return data->tarnum;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pycon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
||||
{
|
||||
bPythonConstraint *data = static_cast<bPythonConstraint *>(con->data);
|
||||
|
||||
/* targets */
|
||||
LISTBASE_FOREACH (bConstraintTarget *, ct, &data->targets) {
|
||||
func(con, (ID **)&ct->tar, false, userdata);
|
||||
}
|
||||
|
||||
/* script */
|
||||
func(con, (ID **)&data->text, true, userdata);
|
||||
}
|
||||
|
||||
/* Whether this approach is maintained remains to be seen (aligorith) */
|
||||
static bool pycon_get_tarmat(Depsgraph * /*depsgraph*/,
|
||||
bConstraint *con,
|
||||
bConstraintOb *cob,
|
||||
bConstraintTarget *ct,
|
||||
float /*ctime*/)
|
||||
{
|
||||
#ifdef WITH_PYTHON
|
||||
bPythonConstraint *data = static_cast<bPythonConstraint *>(con->data);
|
||||
#endif
|
||||
|
||||
if (!VALID_CONS_TARGET(ct)) {
|
||||
unit_ct_matrix_nullsafe(ct);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ct->tar->type == OB_CURVES_LEGACY && ct->tar->runtime->curve_cache == nullptr) {
|
||||
unit_m4(ct->matrix);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* firstly calculate the matrix the normal way, then let the py-function override
|
||||
* this matrix if it needs to do so
|
||||
*/
|
||||
constraint_target_to_mat4(ct->tar,
|
||||
ct->subtarget,
|
||||
cob,
|
||||
ct->matrix,
|
||||
CONSTRAINT_SPACE_WORLD,
|
||||
ct->space,
|
||||
con->flag,
|
||||
con->headtail);
|
||||
|
||||
/* only execute target calculation if allowed */
|
||||
#ifdef WITH_PYTHON
|
||||
if (G.f & G_FLAG_SCRIPT_AUTOEXEC) {
|
||||
BPY_pyconstraint_target(data, ct);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
static void pycon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
||||
{
|
||||
#ifndef WITH_PYTHON
|
||||
UNUSED_VARS(con, cob, targets);
|
||||
return;
|
||||
#else
|
||||
bPythonConstraint *data = static_cast<bPythonConstraint *>(con->data);
|
||||
|
||||
/* only evaluate in python if we're allowed to do so */
|
||||
if ((G.f & G_FLAG_SCRIPT_AUTOEXEC) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Now, run the actual 'constraint' function, which should only access the matrices */
|
||||
BPY_pyconstraint_exec(data, cob, targets);
|
||||
#endif /* WITH_PYTHON */
|
||||
}
|
||||
|
||||
static bConstraintTypeInfo CTI_PYTHON = {
|
||||
/*type*/ CONSTRAINT_TYPE_PYTHON,
|
||||
/*size*/ sizeof(bPythonConstraint),
|
||||
/*name*/ N_("Script"),
|
||||
/*struct_name*/ "bPythonConstraint",
|
||||
/*free_data*/ pycon_free,
|
||||
/*id_looper*/ pycon_id_looper,
|
||||
/*copy_data*/ pycon_copy,
|
||||
/*new_data*/ pycon_new_data,
|
||||
/*get_constraint_targets*/ pycon_get_tars,
|
||||
/*flush_constraint_targets*/ nullptr,
|
||||
/*get_target_matrix*/ pycon_get_tarmat,
|
||||
/*evaluate_constraint*/ pycon_evaluate,
|
||||
};
|
||||
|
||||
/* ----------- Armature Constraint -------------- */
|
||||
|
||||
static void armdef_free(bConstraint *con)
|
||||
@@ -5597,7 +5464,7 @@ static void constraints_init_typeinfo()
|
||||
constraintsTypeInfo[8] = &CTI_ROTLIKE; /* Copy Rotation Constraint */
|
||||
constraintsTypeInfo[9] = &CTI_LOCLIKE; /* Copy Location Constraint */
|
||||
constraintsTypeInfo[10] = &CTI_SIZELIKE; /* Copy Scale Constraint */
|
||||
constraintsTypeInfo[11] = &CTI_PYTHON; /* Python/Script Constraint */
|
||||
constraintsTypeInfo[11] = nullptr; /* Python/Script Constraint: DEPRECATED. */
|
||||
constraintsTypeInfo[12] = &CTI_ACTION; /* Action Constraint */
|
||||
constraintsTypeInfo[13] = &CTI_LOCKTRACK; /* Locked-Track Constraint */
|
||||
constraintsTypeInfo[14] = &CTI_DISTLIMIT; /* Limit Distance Constraint */
|
||||
@@ -6181,10 +6048,7 @@ static bConstraint *constraint_list_find_from_target(ListBase *constraints, bCon
|
||||
LISTBASE_FOREACH (bConstraint *, con, constraints) {
|
||||
ListBase *targets = nullptr;
|
||||
|
||||
if (con->type == CONSTRAINT_TYPE_PYTHON) {
|
||||
targets = &((bPythonConstraint *)con->data)->targets;
|
||||
}
|
||||
else if (con->type == CONSTRAINT_TYPE_ARMATURE) {
|
||||
if (con->type == CONSTRAINT_TYPE_ARMATURE) {
|
||||
targets = &((bArmatureConstraint *)con->data)->targets;
|
||||
}
|
||||
|
||||
@@ -6587,20 +6451,6 @@ void BKE_constraint_blend_write(BlendWriter *writer, ListBase *conlist)
|
||||
|
||||
/* do any constraint specific stuff */
|
||||
switch (con->type) {
|
||||
case CONSTRAINT_TYPE_PYTHON: {
|
||||
bPythonConstraint *data = static_cast<bPythonConstraint *>(con->data);
|
||||
|
||||
/* write targets */
|
||||
LISTBASE_FOREACH (bConstraintTarget *, ct, &data->targets) {
|
||||
BLO_write_struct(writer, bConstraintTarget, ct);
|
||||
}
|
||||
|
||||
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
|
||||
* of library blocks that implement this. */
|
||||
IDP_BlendWrite(writer, data->prop);
|
||||
|
||||
break;
|
||||
}
|
||||
case CONSTRAINT_TYPE_ARMATURE: {
|
||||
bArmatureConstraint *data = static_cast<bArmatureConstraint *>(con->data);
|
||||
|
||||
@@ -6643,9 +6493,6 @@ void BKE_constraint_blend_read_data(BlendDataReader *reader, ID *id_owner, ListB
|
||||
|
||||
/* Patch for error introduced by changing constraints (don't know how). */
|
||||
/* NOTE(@ton): If `con->data` type changes, DNA cannot resolve the pointer!. */
|
||||
/* FIXME This is likely dead code actually, since it used to be in
|
||||
* constraint 'read_lib', so it would have crashed on null pointer access in any of
|
||||
* the code below? But does not hurt to keep it around as a safety measure. */
|
||||
if (con->data == nullptr) {
|
||||
con->type = CONSTRAINT_TYPE_NULL;
|
||||
}
|
||||
@@ -6656,15 +6503,6 @@ void BKE_constraint_blend_read_data(BlendDataReader *reader, ID *id_owner, ListB
|
||||
}
|
||||
|
||||
switch (con->type) {
|
||||
case CONSTRAINT_TYPE_PYTHON: {
|
||||
bPythonConstraint *data = static_cast<bPythonConstraint *>(con->data);
|
||||
|
||||
BLO_read_struct_list(reader, bConstraintTarget, &data->targets);
|
||||
|
||||
BLO_read_struct(reader, IDProperty, &data->prop);
|
||||
IDP_BlendDataRead(reader, &data->prop);
|
||||
break;
|
||||
}
|
||||
case CONSTRAINT_TYPE_ARMATURE: {
|
||||
bArmatureConstraint *data = static_cast<bArmatureConstraint *>(con->data);
|
||||
|
||||
|
||||
@@ -3254,19 +3254,6 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
}
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
|
||||
bConstraint *con = static_cast<bConstraint *>(ob->constraints.first);
|
||||
while (con) {
|
||||
bConstraint *con_next = static_cast<bConstraint *>(con->next);
|
||||
if (con->type == 17) { /* CONSTRAINT_TYPE_RIGIDBODYJOINT */
|
||||
BLI_remlink(&ob->constraints, con);
|
||||
BKE_constraint_free_data(con);
|
||||
MEM_freeN(con);
|
||||
}
|
||||
con = con_next;
|
||||
}
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
|
||||
@@ -407,28 +407,8 @@ static void do_version_free_effects_245(ListBase *lb)
|
||||
|
||||
static void do_version_constraints_245(ListBase *lb)
|
||||
{
|
||||
bConstraintTarget *ct;
|
||||
|
||||
LISTBASE_FOREACH (bConstraint *, con, lb) {
|
||||
if (con->type == CONSTRAINT_TYPE_PYTHON) {
|
||||
bPythonConstraint *data = (bPythonConstraint *)con->data;
|
||||
if (data->tar) {
|
||||
/* version patching needs to be done */
|
||||
ct = MEM_callocN<bConstraintTarget>("PyConTarget");
|
||||
|
||||
ct->tar = data->tar;
|
||||
STRNCPY(ct->subtarget, data->subtarget);
|
||||
ct->space = con->tarspace;
|
||||
|
||||
BLI_addtail(&data->targets, ct);
|
||||
data->tarnum++;
|
||||
|
||||
/* clear old targets to avoid problems */
|
||||
data->tar = nullptr;
|
||||
data->subtarget[0] = '\0';
|
||||
}
|
||||
}
|
||||
else if (con->type == CONSTRAINT_TYPE_LOCLIKE) {
|
||||
if (con->type == CONSTRAINT_TYPE_LOCLIKE) {
|
||||
bLocateLikeConstraint *data = (bLocateLikeConstraint *)con->data;
|
||||
|
||||
/* new headtail functionality makes Bone-Tip function obsolete */
|
||||
|
||||
@@ -154,99 +154,6 @@ bConstraint *constraint_active_get(Object *ob)
|
||||
|
||||
/** \} */
|
||||
|
||||
/* ------------------------------------------------------------------- */
|
||||
/** \name PyConstraints (Unused)
|
||||
* \{ */
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
|
||||
/* this callback sets the text-file to be used for selected menu item */
|
||||
static void validate_pyconstraint_cb(Main *bmain, void *arg1, void *arg2)
|
||||
{
|
||||
bPythonConstraint *data = static_cast<bPythonConstraint *>(arg1);
|
||||
Text *text = nullptr;
|
||||
int index = *((int *)arg2);
|
||||
int i;
|
||||
|
||||
/* exception for no script */
|
||||
if (index) {
|
||||
/* innovative use of a for...loop to search */
|
||||
for (text = static_cast<Text *>(bmain->texts.first), i = 1; text && index != i;
|
||||
i++, text = static_cast<Text *>(text->id.next))
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
}
|
||||
data->text = text;
|
||||
}
|
||||
|
||||
/* this returns a string for the list of usable pyconstraint script names */
|
||||
static char *buildmenu_pyconstraints(Main *bmain, Text *con_text, int *pyconindex)
|
||||
{
|
||||
DynStr *pupds = BLI_dynstr_new();
|
||||
Text *text;
|
||||
char *str;
|
||||
char buf[64];
|
||||
int i;
|
||||
|
||||
/* add title first */
|
||||
STRNCPY(buf, "Scripts: %t|[None]%x0|");
|
||||
BLI_dynstr_append(pupds, buf);
|
||||
|
||||
/* init active-index first */
|
||||
if (con_text == nullptr) {
|
||||
*pyconindex = 0;
|
||||
}
|
||||
|
||||
/* loop through markers, adding them */
|
||||
for (text = static_cast<Text *>(bmain->texts.first), i = 1; text;
|
||||
i++, text = static_cast<Text *>(text->id.next))
|
||||
{
|
||||
/* this is important to ensure that right script is shown as active */
|
||||
if (text == con_text) {
|
||||
*pyconindex = i;
|
||||
}
|
||||
|
||||
/* only include valid pyconstraint scripts */
|
||||
if (BPY_is_pyconstraint(text)) {
|
||||
BLI_dynstr_append(pupds, text->id.name + 2);
|
||||
|
||||
SNPRINTF(buf, "%%x%d", i);
|
||||
BLI_dynstr_append(pupds, buf);
|
||||
|
||||
if (text->id.next) {
|
||||
BLI_dynstr_append(pupds, "|");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* convert to normal MEM_malloc'd string */
|
||||
str = BLI_dynstr_get_cstring(pupds);
|
||||
BLI_dynstr_free(pupds);
|
||||
|
||||
return str;
|
||||
}
|
||||
#endif /* WITH_PYTHON */
|
||||
|
||||
#if 0 /* UNUSED, until pyconstraints are added back. */
|
||||
/* this callback gets called when the 'refresh' button of a pyconstraint gets pressed */
|
||||
static void update_pyconstraint_cb(void *arg1, void *arg2)
|
||||
{
|
||||
# ifndef WITH_PYTHON
|
||||
(void)arg1; /* unused */
|
||||
(void)arg2; /* unused */
|
||||
# else
|
||||
Object *owner = (Object *)arg1;
|
||||
bConstraint *con = (bConstraint *)arg2;
|
||||
if (owner && con) {
|
||||
BPY_pyconstraint_update(owner, con);
|
||||
}
|
||||
# endif /* WITH_PYTHON */
|
||||
}
|
||||
#endif /* UNUSED */
|
||||
|
||||
/** \} */
|
||||
|
||||
/* ------------------------------------------------------------------- */
|
||||
/** \name Add Constraint Utilities
|
||||
* \{ */
|
||||
@@ -2440,34 +2347,6 @@ static wmOperatorStatus constraint_add_exec(
|
||||
}
|
||||
}
|
||||
|
||||
/* Do type-specific tweaking to the constraint settings. */
|
||||
switch (type) {
|
||||
case CONSTRAINT_TYPE_PYTHON: /* FIXME: this code is not really valid anymore */
|
||||
{
|
||||
#ifdef WITH_PYTHON
|
||||
char *menustr;
|
||||
int scriptint = 0;
|
||||
/* popup a list of usable scripts */
|
||||
menustr = buildmenu_pyconstraints(bmain, nullptr, &scriptint);
|
||||
// scriptint = pupmenu(menustr); /* XXX */
|
||||
MEM_freeN(menustr);
|
||||
|
||||
/* only add constraint if a script was chosen */
|
||||
if (scriptint) {
|
||||
/* add constraint */
|
||||
validate_pyconstraint_cb(bmain, con->data, &scriptint);
|
||||
|
||||
/* make sure target allowance is set correctly */
|
||||
BPY_pyconstraint_update(ob, con);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* make sure all settings are valid - similar to above checks, but sometimes can be wrong */
|
||||
object_test_constraints(bmain, ob);
|
||||
|
||||
|
||||
@@ -167,7 +167,6 @@ static void text_operatortypes()
|
||||
WM_operatortype_append(TEXT_OT_save_as);
|
||||
WM_operatortype_append(TEXT_OT_make_internal);
|
||||
WM_operatortype_append(TEXT_OT_run_script);
|
||||
WM_operatortype_append(TEXT_OT_refresh_pyconstraints);
|
||||
|
||||
WM_operatortype_append(TEXT_OT_paste);
|
||||
WM_operatortype_append(TEXT_OT_copy);
|
||||
|
||||
@@ -121,7 +121,6 @@ void TEXT_OT_save(wmOperatorType *ot);
|
||||
void TEXT_OT_save_as(wmOperatorType *ot);
|
||||
void TEXT_OT_make_internal(wmOperatorType *ot);
|
||||
void TEXT_OT_run_script(wmOperatorType *ot);
|
||||
void TEXT_OT_refresh_pyconstraints(wmOperatorType *ot);
|
||||
|
||||
void TEXT_OT_paste(wmOperatorType *ot);
|
||||
void TEXT_OT_copy(wmOperatorType *ot);
|
||||
|
||||
@@ -924,71 +924,6 @@ void TEXT_OT_run_script(wmOperatorType *ot)
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Refresh Pyconstraints Operator
|
||||
* \{ */
|
||||
|
||||
static wmOperatorStatus text_refresh_pyconstraints_exec(bContext * /*C*/, wmOperator * /*op*/)
|
||||
{
|
||||
#ifdef WITH_PYTHON
|
||||
# if 0
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
Object *ob;
|
||||
bConstraint *con;
|
||||
bool update;
|
||||
|
||||
/* check all pyconstraints */
|
||||
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
|
||||
update = false;
|
||||
if (ob->type == OB_ARMATURE && ob->pose) {
|
||||
bPoseChannel *pchan;
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
for (con = pchan->constraints.first; con; con = con->next) {
|
||||
if (con->type == CONSTRAINT_TYPE_PYTHON) {
|
||||
bPythonConstraint *data = con->data;
|
||||
if (data->text == text) {
|
||||
BPY_pyconstraint_update(ob, con);
|
||||
}
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (con = ob->constraints.first; con; con = con->next) {
|
||||
if (con->type == CONSTRAINT_TYPE_PYTHON) {
|
||||
bPythonConstraint *data = con->data;
|
||||
if (data->text == text) {
|
||||
BPY_pyconstraint_update(ob, con);
|
||||
}
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (update) {
|
||||
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void TEXT_OT_refresh_pyconstraints(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Refresh PyConstraints";
|
||||
ot->idname = "TEXT_OT_refresh_pyconstraints";
|
||||
ot->description = "Refresh all pyconstraints";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = text_refresh_pyconstraints_exec;
|
||||
ot->poll = text_edit_poll;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Paste Operator
|
||||
* \{ */
|
||||
|
||||
@@ -119,33 +119,6 @@ typedef enum eConstraintObType {
|
||||
/* CONSTRAINT_OBTYPE_CV = 4, */ /* UNUSED */
|
||||
} eConstraintObType;
|
||||
|
||||
/* Python Script Constraint */
|
||||
typedef struct bPythonConstraint {
|
||||
/** Text-buffer (containing script) to execute. */
|
||||
struct Text *text;
|
||||
/** 'id-properties' used to store custom properties for constraint. */
|
||||
IDProperty *prop;
|
||||
|
||||
/** General settings/state indicators accessed by bitmapping. */
|
||||
int flag;
|
||||
/** Number of targets - usually only 1-3 are needed. */
|
||||
int tarnum;
|
||||
|
||||
/** A list of targets that this constraint has (bConstraintTarget-s). */
|
||||
ListBase targets;
|
||||
|
||||
/**
|
||||
* Target from previous implementation
|
||||
* (version-patch sets this to NULL on file-load).
|
||||
*/
|
||||
struct Object *tar;
|
||||
/**
|
||||
* Subtarget from previous implementation
|
||||
* (version-patch sets this to "" on file-load), MAX_ID_NAME-2.
|
||||
*/
|
||||
char subtarget[64];
|
||||
} bPythonConstraint;
|
||||
|
||||
/* Inverse-Kinematics (IK) constraint
|
||||
* This constraint supports a variety of mode determine by the type field
|
||||
* according to eConstraint_IK_Type.
|
||||
@@ -638,7 +611,7 @@ typedef enum eBConstraint_Types {
|
||||
CONSTRAINT_TYPE_ROTLIKE = 8,
|
||||
CONSTRAINT_TYPE_LOCLIKE = 9,
|
||||
CONSTRAINT_TYPE_SIZELIKE = 10,
|
||||
CONSTRAINT_TYPE_PYTHON = 11,
|
||||
/* CONSTRAINT_TYPE_DEPRECATED = 11, */
|
||||
CONSTRAINT_TYPE_ACTION = 12,
|
||||
CONSTRAINT_TYPE_LOCKTRACK = 13,
|
||||
CONSTRAINT_TYPE_DISTLIMIT = 14,
|
||||
|
||||
@@ -160,18 +160,6 @@ const EnumPropertyItem rna_enum_constraint_type_items[] = {
|
||||
ICON_CON_PIVOT,
|
||||
"Pivot",
|
||||
"Change pivot point for transforms (buggy)"},
|
||||
#if 0
|
||||
{CONSTRAINT_TYPE_RIGIDBODYJOINT,
|
||||
"RIGID_BODY_JOINT",
|
||||
ICON_CONSTRAINT_DATA,
|
||||
"Rigid Body Joint",
|
||||
"Use to define a Rigid Body Constraint (for Game Engine use only)"},
|
||||
{CONSTRAINT_TYPE_PYTHON,
|
||||
"SCRIPT",
|
||||
ICON_CONSTRAINT_DATA,
|
||||
"Script",
|
||||
"Custom constraint(s) written in Python (Not yet implemented)"},
|
||||
#endif
|
||||
{CONSTRAINT_TYPE_SHRINKWRAP,
|
||||
"SHRINKWRAP",
|
||||
ICON_CON_SHRINKWRAP,
|
||||
@@ -353,8 +341,6 @@ static StructRNA *rna_ConstraintType_refine(PointerRNA *ptr)
|
||||
return &RNA_CopyScaleConstraint;
|
||||
case CONSTRAINT_TYPE_SAMEVOL:
|
||||
return &RNA_MaintainVolumeConstraint;
|
||||
case CONSTRAINT_TYPE_PYTHON:
|
||||
return &RNA_PythonConstraint;
|
||||
case CONSTRAINT_TYPE_ARMATURE:
|
||||
return &RNA_ArmatureConstraint;
|
||||
case CONSTRAINT_TYPE_ACTION:
|
||||
@@ -491,10 +477,6 @@ static std::optional<std::string> rna_ConstraintTarget_path(const PointerRNA *pt
|
||||
bArmatureConstraint *acon = static_cast<bArmatureConstraint *>(con->data);
|
||||
index = BLI_findindex(&acon->targets, tgt);
|
||||
}
|
||||
else if (con->type == CONSTRAINT_TYPE_PYTHON) {
|
||||
bPythonConstraint *pcon = static_cast<bPythonConstraint *>(con->data);
|
||||
index = BLI_findindex(&pcon->targets, tgt);
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= 0) {
|
||||
@@ -1170,46 +1152,6 @@ static void rna_def_constraint_childof(BlenderRNA *brna)
|
||||
RNA_define_lib_overridable(false);
|
||||
}
|
||||
|
||||
static void rna_def_constraint_python(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
srna = RNA_def_struct(brna, "PythonConstraint", "Constraint");
|
||||
RNA_def_struct_ui_text(srna, "Python Constraint", "Use Python script for constraint evaluation");
|
||||
RNA_def_struct_sdna_from(srna, "bPythonConstraint", "data");
|
||||
|
||||
RNA_define_lib_overridable(true);
|
||||
|
||||
prop = RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
|
||||
RNA_def_property_collection_sdna(prop, nullptr, "targets", nullptr);
|
||||
RNA_def_property_struct_type(prop, "ConstraintTarget");
|
||||
RNA_def_property_ui_text(prop, "Targets", "Target Objects");
|
||||
|
||||
prop = RNA_def_property(srna, "target_count", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_int_sdna(prop, nullptr, "tarnum");
|
||||
RNA_def_property_ui_text(prop, "Number of Targets", "Usually only 1 to 3 are needed");
|
||||
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
|
||||
|
||||
prop = RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_ui_text(prop, "Script", "The text object that contains the Python script");
|
||||
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
|
||||
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_targets", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", PYCON_USETARGETS);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Use Targets", "Use the targets indicated in the constraint panel");
|
||||
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
|
||||
|
||||
prop = RNA_def_property(srna, "has_script_error", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", PYCON_SCRIPTERROR);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Script Error", "The linked Python script has thrown an error");
|
||||
|
||||
RNA_define_lib_overridable(false);
|
||||
}
|
||||
|
||||
static void rna_def_constraint_armature_deform_targets(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
StructRNA *srna;
|
||||
@@ -3793,7 +3735,6 @@ void RNA_def_constraint(BlenderRNA *brna)
|
||||
rna_def_constrainttarget_bone(brna);
|
||||
|
||||
rna_def_constraint_childof(brna);
|
||||
rna_def_constraint_python(brna);
|
||||
rna_def_constraint_armature_deform(brna);
|
||||
rna_def_constraint_stretch_to(brna);
|
||||
rna_def_constraint_follow_path(brna);
|
||||
|
||||
@@ -31,17 +31,9 @@ struct bConstraintOb; /* DNA_constraint_types.h */
|
||||
struct bConstraintTarget; /* DNA_constraint_types.h */
|
||||
struct bContext;
|
||||
struct bContextDataResult;
|
||||
struct bPythonConstraint; /* DNA_constraint_types.h */
|
||||
struct StructRNA;
|
||||
struct wmWindowManager;
|
||||
|
||||
void BPY_pyconstraint_exec(bPythonConstraint *con, bConstraintOb *cob, ListBase *targets);
|
||||
// void BPY_pyconstraint_settings(void *arg1, void *arg2);
|
||||
void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct);
|
||||
void BPY_pyconstraint_update(Object *owner, bConstraint *con);
|
||||
bool BPY_is_pyconstraint(Text *text);
|
||||
// void BPY_free_pyconstraint_links(struct Text *text);
|
||||
|
||||
/* global interpreter lock */
|
||||
|
||||
using BPy_ThreadStatePtr = void *;
|
||||
|
||||
@@ -65,7 +65,6 @@ set(SRC
|
||||
bpy_traceback.cc
|
||||
bpy_utils_previews.cc
|
||||
bpy_utils_units.cc
|
||||
stubs.cc
|
||||
|
||||
bpy.hh
|
||||
bpy_app.hh
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2007 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup pythonintern
|
||||
*/
|
||||
|
||||
#include "BPY_extern.hh"
|
||||
|
||||
/* python, will come back */
|
||||
// void BPY_script_exec() {}
|
||||
// void BPY_python_start() {}
|
||||
void BPY_pyconstraint_exec(bPythonConstraint * /*con*/,
|
||||
bConstraintOb * /*cob*/,
|
||||
ListBase * /*targets*/)
|
||||
{
|
||||
}
|
||||
void BPY_pyconstraint_target(bPythonConstraint * /*con*/, bConstraintTarget * /*ct*/) {}
|
||||
bool BPY_is_pyconstraint(Text * /*text*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void BPY_pyconstraint_update(Object * /*owner*/, bConstraint * /*con*/) {}
|
||||
Reference in New Issue
Block a user