Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kim <pk15950@gmail.com>2022-09-08 07:00:12 +0300
committerPeter Kim <pk15950@gmail.com>2022-09-08 07:00:12 +0300
commit00dcfdf916c69672210b006e62d966f1bc2fbeb7 (patch)
tree0cbb1b91fe26c750197126085b74224a795a103c /source/blender/blenkernel/intern/constraint.c
parenta39532670f6b668da7be5810fb1f844b82feeba3 (diff)
parentd5934974219135102f364f57c45a8b1465e2b8d9 (diff)
Merge branch 'master' into xr-devxr-dev
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r--source/blender/blenkernel/intern/constraint.c288
1 files changed, 134 insertions, 154 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 6ffb3299869..bcc3db48947 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -116,7 +116,6 @@ void BKE_constraint_unique_name(bConstraint *con, ListBase *list)
/* ----------------- Evaluation Loop Preparation --------------- */
-/* package an object/bone for use in constraint evaluation */
bConstraintOb *BKE_constraints_make_evalob(
Depsgraph *depsgraph, Scene *scene, Object *ob, void *subdata, short datatype)
{
@@ -529,9 +528,27 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[
float vec[3] = {0.0f, 0.0f, 0.0f};
float normal[3] = {0.0f, 0.0f, 0.0f};
float weightsum = 0.0f;
- if (me_eval) {
+ if (em) {
+ if (CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) {
+ BMVert *v;
+ BMIter iter;
+
+ BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
+ MDeformVert *dv = CustomData_bmesh_get(&em->bm->vdata, v->head.data, CD_MDEFORMVERT);
+ MDeformWeight *dw = BKE_defvert_find_index(dv, defgroup);
+
+ if (dw && dw->weight > 0.0f) {
+ madd_v3_v3fl(vec, v->co, dw->weight);
+ madd_v3_v3fl(normal, v->no, dw->weight);
+ weightsum += dw->weight;
+ }
+ }
+ }
+ }
+ else if (me_eval) {
const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(me_eval);
const MDeformVert *dvert = CustomData_get_layer(&me_eval->vdata, CD_MDEFORMVERT);
+ const MVert *verts = BKE_mesh_verts(me_eval);
int numVerts = me_eval->totvert;
/* check that dvert is a valid pointers (just in case) */
@@ -540,7 +557,7 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[
/* get the average of all verts with that are in the vertex-group */
for (int i = 0; i < numVerts; i++) {
const MDeformVert *dv = &dvert[i];
- const MVert *mv = &me_eval->mvert[i];
+ const MVert *mv = &verts[i];
const MDeformWeight *dw = BKE_defvert_find_index(dv, defgroup);
if (dw && dw->weight > 0.0f) {
@@ -551,23 +568,6 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[
}
}
}
- else if (em) {
- if (CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) {
- BMVert *v;
- BMIter iter;
-
- BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
- MDeformVert *dv = CustomData_bmesh_get(&em->bm->vdata, v->head.data, CD_MDEFORMVERT);
- MDeformWeight *dw = BKE_defvert_find_index(dv, defgroup);
-
- if (dw && dw->weight > 0.0f) {
- madd_v3_v3fl(vec, v->co, dw->weight);
- madd_v3_v3fl(normal, v->no, dw->weight);
- weightsum += dw->weight;
- }
- }
- }
- }
else {
/* No valid edit or evaluated mesh, just abort. */
return;
@@ -949,30 +949,9 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph),
} \
(void)0
-static void custom_space_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
+static bool is_custom_space_needed(bConstraint *con)
{
- func(con, (ID **)&con->space_object, false, userdata);
-}
-
-static int get_space_tar(bConstraint *con, ListBase *list)
-{
- if (!con || !list ||
- (con->ownspace != CONSTRAINT_SPACE_CUSTOM && con->tarspace != CONSTRAINT_SPACE_CUSTOM)) {
- return 0;
- }
- bConstraintTarget *ct;
- SINGLETARGET_GET_TARS(con, con->space_object, con->space_subtarget, ct, list);
- return 1;
-}
-
-static void flush_space_tar(bConstraint *con, ListBase *list, bool no_copy)
-{
- if (!con || !list ||
- (con->ownspace != CONSTRAINT_SPACE_CUSTOM && con->tarspace != CONSTRAINT_SPACE_CUSTOM)) {
- return;
- }
- bConstraintTarget *ct = (bConstraintTarget *)list->last;
- SINGLETARGET_FLUSH_TARS(con, con->space_object, con->space_subtarget, ct, list, no_copy);
+ return con->ownspace == CONSTRAINT_SPACE_CUSTOM || con->tarspace == CONSTRAINT_SPACE_CUSTOM;
}
/* --------- ChildOf Constraint ------------ */
@@ -1133,7 +1112,7 @@ static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
static bConstraintTypeInfo CTI_CHILDOF = {
CONSTRAINT_TYPE_CHILDOF, /* type */
sizeof(bChildOfConstraint), /* size */
- "Child Of", /* name */
+ N_("Child Of"), /* name */
"bChildOfConstraint", /* struct name */
NULL, /* free data */
childof_id_looper, /* id looper */
@@ -1161,8 +1140,6 @@ static void trackto_id_looper(bConstraint *con, ConstraintIDFunc func, void *use
/* target only */
func(con, (ID **)&data->tar, false, userdata);
-
- custom_space_id_looper(con, func, userdata);
}
static int trackto_get_tars(bConstraint *con, ListBase *list)
@@ -1174,7 +1151,7 @@ static int trackto_get_tars(bConstraint *con, ListBase *list)
/* standard target-getting macro for single-target constraints */
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
- return 1 + get_space_tar(con, list);
+ return 1;
}
return 0;
@@ -1188,7 +1165,6 @@ static void trackto_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
/* the following macro is used for all standard single-target constraints */
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
- flush_space_tar(con, list, no_copy);
}
}
@@ -1321,7 +1297,7 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
static bConstraintTypeInfo CTI_TRACKTO = {
CONSTRAINT_TYPE_TRACKTO, /* type */
sizeof(bTrackToConstraint), /* size */
- "Track To", /* name */
+ N_("Track To"), /* name */
"bTrackToConstraint", /* struct name */
NULL, /* free data */
trackto_id_looper, /* id looper */
@@ -1427,7 +1403,7 @@ static void kinematic_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
static bConstraintTypeInfo CTI_KINEMATIC = {
CONSTRAINT_TYPE_KINEMATIC, /* type */
sizeof(bKinematicConstraint), /* size */
- "IK", /* name */
+ N_("IK"), /* name */
"bKinematicConstraint", /* struct name */
NULL, /* free data */
kinematic_id_looper, /* id looper */
@@ -1584,7 +1560,7 @@ static void followpath_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *
/* un-apply scaling caused by path */
if ((data->followflag & FOLLOWPATH_RADIUS) == 0) {
- /* XXX(campbell): Assume that scale correction means that radius
+ /* XXX(@campbellbarton): Assume that scale correction means that radius
* will have some scale error in it. */
float obsize[3];
@@ -1605,7 +1581,7 @@ static void followpath_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *
static bConstraintTypeInfo CTI_FOLLOWPATH = {
CONSTRAINT_TYPE_FOLLOWPATH, /* type */
sizeof(bFollowPathConstraint), /* size */
- "Follow Path", /* name */
+ N_("Follow Path"), /* name */
"bFollowPathConstraint", /* struct name */
NULL, /* free data */
followpath_id_looper, /* id looper */
@@ -1658,14 +1634,14 @@ static void loclimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UN
static bConstraintTypeInfo CTI_LOCLIMIT = {
CONSTRAINT_TYPE_LOCLIMIT, /* type */
sizeof(bLocLimitConstraint), /* size */
- "Limit Location", /* name */
+ N_("Limit Location"), /* name */
"bLocLimitConstraint", /* struct name */
NULL, /* free data */
- custom_space_id_looper, /* id looper */
+ NULL, /* id looper */
NULL, /* copy data */
NULL, /* new data */
- get_space_tar, /* get constraint targets */
- flush_space_tar, /* flush constraint targets */
+ NULL, /* get constraint targets */
+ NULL, /* flush constraint targets */
NULL, /* get target matrix */
loclimit_evaluate, /* evaluate */
};
@@ -1739,14 +1715,14 @@ static void rotlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UN
static bConstraintTypeInfo CTI_ROTLIMIT = {
CONSTRAINT_TYPE_ROTLIMIT, /* type */
sizeof(bRotLimitConstraint), /* size */
- "Limit Rotation", /* name */
+ N_("Limit Rotation"), /* name */
"bRotLimitConstraint", /* struct name */
NULL, /* free data */
- custom_space_id_looper, /* id looper */
+ NULL, /* id looper */
NULL, /* copy data */
NULL, /* new data */
- get_space_tar, /* get constraint targets */
- flush_space_tar, /* flush constraint targets */
+ NULL, /* get constraint targets */
+ NULL, /* flush constraint targets */
NULL, /* get target matrix */
rotlimit_evaluate, /* evaluate */
};
@@ -1806,14 +1782,14 @@ static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *U
static bConstraintTypeInfo CTI_SIZELIMIT = {
CONSTRAINT_TYPE_SIZELIMIT, /* type */
sizeof(bSizeLimitConstraint), /* size */
- "Limit Scale", /* name */
+ N_("Limit Scale"), /* name */
"bSizeLimitConstraint", /* struct name */
NULL, /* free data */
- custom_space_id_looper, /* id looper */
+ NULL, /* id looper */
NULL, /* copy data */
NULL, /* new data */
- get_space_tar, /* get constraint targets */
- flush_space_tar, /* flush constraint targets */
+ NULL, /* get constraint targets */
+ NULL, /* flush constraint targets */
NULL, /* get target matrix */
sizelimit_evaluate, /* evaluate */
};
@@ -1833,8 +1809,6 @@ static void loclike_id_looper(bConstraint *con, ConstraintIDFunc func, void *use
/* target only */
func(con, (ID **)&data->tar, false, userdata);
-
- custom_space_id_looper(con, func, userdata);
}
static int loclike_get_tars(bConstraint *con, ListBase *list)
@@ -1846,7 +1820,7 @@ static int loclike_get_tars(bConstraint *con, ListBase *list)
/* standard target-getting macro for single-target constraints */
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
- return 1 + get_space_tar(con, list);
+ return 1;
}
return 0;
@@ -1860,7 +1834,6 @@ static void loclike_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
/* the following macro is used for all standard single-target constraints */
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
- flush_space_tar(con, list, no_copy);
}
}
@@ -1906,7 +1879,7 @@ static void loclike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
static bConstraintTypeInfo CTI_LOCLIKE = {
CONSTRAINT_TYPE_LOCLIKE, /* type */
sizeof(bLocateLikeConstraint), /* size */
- "Copy Location", /* name */
+ N_("Copy Location"), /* name */
"bLocateLikeConstraint", /* struct name */
NULL, /* free data */
loclike_id_looper, /* id looper */
@@ -1933,8 +1906,6 @@ static void rotlike_id_looper(bConstraint *con, ConstraintIDFunc func, void *use
/* target only */
func(con, (ID **)&data->tar, false, userdata);
-
- custom_space_id_looper(con, func, userdata);
}
static int rotlike_get_tars(bConstraint *con, ListBase *list)
@@ -1946,7 +1917,7 @@ static int rotlike_get_tars(bConstraint *con, ListBase *list)
/* standard target-getting macro for single-target constraints */
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
- return 1 + get_space_tar(con, list);
+ return 1;
}
return 0;
@@ -1960,7 +1931,6 @@ static void rotlike_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
/* the following macro is used for all standard single-target constraints */
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
- flush_space_tar(con, list, no_copy);
}
}
@@ -2086,7 +2056,7 @@ static void rotlike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
static bConstraintTypeInfo CTI_ROTLIKE = {
CONSTRAINT_TYPE_ROTLIKE, /* type */
sizeof(bRotateLikeConstraint), /* size */
- "Copy Rotation", /* name */
+ N_("Copy Rotation"), /* name */
"bRotateLikeConstraint", /* struct name */
NULL, /* free data */
rotlike_id_looper, /* id looper */
@@ -2114,8 +2084,6 @@ static void sizelike_id_looper(bConstraint *con, ConstraintIDFunc func, void *us
/* target only */
func(con, (ID **)&data->tar, false, userdata);
-
- custom_space_id_looper(con, func, userdata);
}
static int sizelike_get_tars(bConstraint *con, ListBase *list)
@@ -2127,7 +2095,7 @@ static int sizelike_get_tars(bConstraint *con, ListBase *list)
/* standard target-getting macro for single-target constraints */
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
- return 1 + get_space_tar(con, list);
+ return 1;
}
return 0;
@@ -2141,7 +2109,6 @@ static void sizelike_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
/* the following macro is used for all standard single-target constraints */
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
- flush_space_tar(con, list, no_copy);
}
}
@@ -2219,7 +2186,7 @@ static void sizelike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *ta
static bConstraintTypeInfo CTI_SIZELIKE = {
CONSTRAINT_TYPE_SIZELIKE, /* type */
sizeof(bSizeLikeConstraint), /* size */
- "Copy Scale", /* name */
+ N_("Copy Scale"), /* name */
"bSizeLikeConstraint", /* struct name */
NULL, /* free data */
sizelike_id_looper, /* id looper */
@@ -2239,8 +2206,6 @@ static void translike_id_looper(bConstraint *con, ConstraintIDFunc func, void *u
/* target only */
func(con, (ID **)&data->tar, false, userdata);
-
- custom_space_id_looper(con, func, userdata);
}
static int translike_get_tars(bConstraint *con, ListBase *list)
@@ -2252,7 +2217,7 @@ static int translike_get_tars(bConstraint *con, ListBase *list)
/* standard target-getting macro for single-target constraints */
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
- return 1 + get_space_tar(con, list);
+ return 1;
}
return 0;
@@ -2266,7 +2231,6 @@ static void translike_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
/* the following macro is used for all standard single-target constraints */
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
- flush_space_tar(con, list, no_copy);
}
}
@@ -2328,7 +2292,7 @@ static void translike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
static bConstraintTypeInfo CTI_TRANSLIKE = {
CONSTRAINT_TYPE_TRANSLIKE, /* type */
sizeof(bTransLikeConstraint), /* size */
- "Copy Transforms", /* name */
+ N_("Copy Transforms"), /* name */
"bTransLikeConstraint", /* struct name */
NULL, /* free data */
translike_id_looper, /* id looper */
@@ -2397,14 +2361,14 @@ static void samevolume_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *
static bConstraintTypeInfo CTI_SAMEVOL = {
CONSTRAINT_TYPE_SAMEVOL, /* type */
sizeof(bSameVolumeConstraint), /* size */
- "Maintain Volume", /* name */
+ N_("Maintain Volume"), /* name */
"bSameVolumeConstraint", /* struct name */
NULL, /* free data */
- custom_space_id_looper, /* id looper */
+ NULL, /* id looper */
NULL, /* copy data */
samevolume_new_data, /* new data */
- get_space_tar, /* get constraint targets */
- flush_space_tar, /* flush constraint targets */
+ NULL, /* get constraint targets */
+ NULL, /* flush constraint targets */
NULL, /* get target matrix */
samevolume_evaluate, /* evaluate */
};
@@ -2529,7 +2493,7 @@ static void pycon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targe
static bConstraintTypeInfo CTI_PYTHON = {
CONSTRAINT_TYPE_PYTHON, /* type */
sizeof(bPythonConstraint), /* size */
- "Script", /* name */
+ N_("Script"), /* name */
"bPythonConstraint", /* struct name */
pycon_free, /* free data */
pycon_id_looper, /* id looper */
@@ -2776,7 +2740,7 @@ static void armdef_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ
static bConstraintTypeInfo CTI_ARMATURE = {
CONSTRAINT_TYPE_ARMATURE, /* type */
sizeof(bArmatureConstraint), /* size */
- "Armature", /* name */
+ N_("Armature"), /* name */
"bArmatureConstraint", /* struct name */
armdef_free, /* free data */
armdef_id_looper, /* id looper */
@@ -2810,8 +2774,6 @@ static void actcon_id_looper(bConstraint *con, ConstraintIDFunc func, void *user
/* action */
func(con, (ID **)&data->act, true, userdata);
-
- custom_space_id_looper(con, func, userdata);
}
static int actcon_get_tars(bConstraint *con, ListBase *list)
@@ -2823,7 +2785,7 @@ static int actcon_get_tars(bConstraint *con, ListBase *list)
/* standard target-getting macro for single-target constraints */
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
- return 1 + get_space_tar(con, list);
+ return 1;
}
return 0;
@@ -2837,7 +2799,6 @@ static void actcon_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
/* the following macro is used for all standard single-target constraints */
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
- flush_space_tar(con, list, no_copy);
}
}
@@ -2995,7 +2956,7 @@ static void actcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ
static bConstraintTypeInfo CTI_ACTION = {
CONSTRAINT_TYPE_ACTION, /* type */
sizeof(bActionConstraint), /* size */
- "Action", /* name */
+ N_("Action"), /* name */
"bActionConstraint", /* struct name */
NULL, /* free data */
actcon_id_looper, /* id looper */
@@ -3311,7 +3272,7 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
static bConstraintTypeInfo CTI_LOCKTRACK = {
CONSTRAINT_TYPE_LOCKTRACK, /* type */
sizeof(bLockTrackConstraint), /* size */
- "Locked Track", /* name */
+ N_("Locked Track"), /* name */
"bLockTrackConstraint", /* struct name */
NULL, /* free data */
locktrack_id_looper, /* id looper */
@@ -3338,8 +3299,6 @@ static void distlimit_id_looper(bConstraint *con, ConstraintIDFunc func, void *u
/* target only */
func(con, (ID **)&data->tar, false, userdata);
-
- custom_space_id_looper(con, func, userdata);
}
static int distlimit_get_tars(bConstraint *con, ListBase *list)
@@ -3351,7 +3310,7 @@ static int distlimit_get_tars(bConstraint *con, ListBase *list)
/* standard target-getting macro for single-target constraints */
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
- return 1 + get_space_tar(con, list);
+ return 1;
}
return 0;
@@ -3365,7 +3324,6 @@ static void distlimit_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
/* the following macro is used for all standard single-target constraints */
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
- flush_space_tar(con, list, no_copy);
}
}
@@ -3457,7 +3415,7 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
static bConstraintTypeInfo CTI_DISTLIMIT = {
CONSTRAINT_TYPE_DISTLIMIT, /* type */
sizeof(bDistLimitConstraint), /* size */
- "Limit Distance", /* name */
+ N_("Limit Distance"), /* name */
"bDistLimitConstraint", /* struct name */
NULL, /* free data */
distlimit_id_looper, /* id looper */
@@ -3665,7 +3623,7 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
static bConstraintTypeInfo CTI_STRETCHTO = {
CONSTRAINT_TYPE_STRETCHTO, /* type */
sizeof(bStretchToConstraint), /* size */
- "Stretch To", /* name */
+ N_("Stretch To"), /* name */
"bStretchToConstraint", /* struct name */
NULL, /* free data */
stretchto_id_looper, /* id looper */
@@ -3694,8 +3652,6 @@ static void minmax_id_looper(bConstraint *con, ConstraintIDFunc func, void *user
/* target only */
func(con, (ID **)&data->tar, false, userdata);
-
- custom_space_id_looper(con, func, userdata);
}
static int minmax_get_tars(bConstraint *con, ListBase *list)
@@ -3707,7 +3663,7 @@ static int minmax_get_tars(bConstraint *con, ListBase *list)
/* standard target-getting macro for single-target constraints */
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
- return 1 + get_space_tar(con, list);
+ return 1;
}
return 0;
@@ -3721,7 +3677,6 @@ static void minmax_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
/* the following macro is used for all standard single-target constraints */
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
- flush_space_tar(con, list, no_copy);
}
}
@@ -3799,7 +3754,7 @@ static void minmax_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ
static bConstraintTypeInfo CTI_MINMAX = {
CONSTRAINT_TYPE_MINMAX, /* type */
sizeof(bMinMaxConstraint), /* size */
- "Floor", /* name */
+ N_("Floor"), /* name */
"bMinMaxConstraint", /* struct name */
NULL, /* free data */
minmax_id_looper, /* id looper */
@@ -3985,7 +3940,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
static bConstraintTypeInfo CTI_CLAMPTO = {
CONSTRAINT_TYPE_CLAMPTO, /* type */
sizeof(bClampToConstraint), /* size */
- "Clamp To", /* name */
+ N_("Clamp To"), /* name */
"bClampToConstraint", /* struct name */
NULL, /* free data */
clampto_id_looper, /* id looper */
@@ -4019,8 +3974,6 @@ static void transform_id_looper(bConstraint *con, ConstraintIDFunc func, void *u
/* target only */
func(con, (ID **)&data->tar, false, userdata);
-
- custom_space_id_looper(con, func, userdata);
}
static int transform_get_tars(bConstraint *con, ListBase *list)
@@ -4032,7 +3985,7 @@ static int transform_get_tars(bConstraint *con, ListBase *list)
/* standard target-getting macro for single-target constraints */
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
- return 1 + get_space_tar(con, list);
+ return 1;
}
return 0;
@@ -4046,7 +3999,6 @@ static void transform_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
/* the following macro is used for all standard single-target constraints */
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy);
- flush_space_tar(con, list, no_copy);
}
}
@@ -4197,7 +4149,7 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
static bConstraintTypeInfo CTI_TRANSFORM = {
CONSTRAINT_TYPE_TRANSFORM, /* type */
sizeof(bTransformConstraint), /* size */
- "Transformation", /* name */
+ N_("Transformation"), /* name */
"bTransformConstraint", /* struct name */
NULL, /* free data */
transform_id_looper, /* id looper */
@@ -4428,7 +4380,7 @@ static void shrinkwrap_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, Li
static bConstraintTypeInfo CTI_SHRINKWRAP = {
CONSTRAINT_TYPE_SHRINKWRAP, /* type */
sizeof(bShrinkwrapConstraint), /* size */
- "Shrinkwrap", /* name */
+ N_("Shrinkwrap"), /* name */
"bShrinkwrapConstraint", /* struct name */
NULL, /* free data */
shrinkwrap_id_looper, /* id looper */
@@ -4593,7 +4545,7 @@ static void damptrack_do_transform(float matrix[4][4], const float tarvec_in[3],
static bConstraintTypeInfo CTI_DAMPTRACK = {
CONSTRAINT_TYPE_DAMPTRACK, /* type */
sizeof(bDampTrackConstraint), /* size */
- "Damped Track", /* name */
+ N_("Damped Track"), /* name */
"bDampTrackConstraint", /* struct name */
NULL, /* free data */
damptrack_id_looper, /* id looper */
@@ -4688,7 +4640,7 @@ static void splineik_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
static bConstraintTypeInfo CTI_SPLINEIK = {
CONSTRAINT_TYPE_SPLINEIK, /* type */
sizeof(bSplineIKConstraint), /* size */
- "Spline IK", /* name */
+ N_("Spline IK"), /* name */
"bSplineIKConstraint", /* struct name */
splineik_free, /* free data */
splineik_id_looper, /* id looper */
@@ -4812,7 +4764,7 @@ static void pivotcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *ta
static bConstraintTypeInfo CTI_PIVOT = {
CONSTRAINT_TYPE_PIVOT, /* type */
sizeof(bPivotConstraint), /* size */
- "Pivot", /* name */
+ N_("Pivot"), /* name */
"bPivotConstraint", /* struct name */
NULL, /* free data */
pivotcon_id_looper, /* id looper */
@@ -5233,7 +5185,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
static bConstraintTypeInfo CTI_FOLLOWTRACK = {
CONSTRAINT_TYPE_FOLLOWTRACK, /* type */
sizeof(bFollowTrackConstraint), /* size */
- "Follow Track", /* name */
+ N_("Follow Track"), /* name */
"bFollowTrackConstraint", /* struct name */
NULL, /* free data */
followtrack_id_looper, /* id looper */
@@ -5291,7 +5243,7 @@ static void camerasolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
static bConstraintTypeInfo CTI_CAMERASOLVER = {
CONSTRAINT_TYPE_CAMERASOLVER, /* type */
sizeof(bCameraSolverConstraint), /* size */
- "Camera Solver", /* name */
+ N_("Camera Solver"), /* name */
"bCameraSolverConstraint", /* struct name */
NULL, /* free data */
camerasolver_id_looper, /* id looper */
@@ -5379,7 +5331,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
static bConstraintTypeInfo CTI_OBJECTSOLVER = {
CONSTRAINT_TYPE_OBJECTSOLVER, /* type */
sizeof(bObjectSolverConstraint), /* size */
- "Object Solver", /* name */
+ N_("Object Solver"), /* name */
"bObjectSolverConstraint", /* struct name */
NULL, /* free data */
objectsolver_id_looper, /* id looper */
@@ -5476,7 +5428,7 @@ static void transformcache_new_data(void *cdata)
static bConstraintTypeInfo CTI_TRANSFORM_CACHE = {
CONSTRAINT_TYPE_TRANSFORM_CACHE, /* type */
sizeof(bTransformCacheConstraint), /* size */
- "Transform Cache", /* name */
+ N_("Transform Cache"), /* name */
"bTransformCacheConstraint", /* struct name */
transformcache_free, /* free data */
transformcache_id_looper, /* id looper */
@@ -5582,6 +5534,19 @@ static void con_unlink_refs_cb(bConstraint *UNUSED(con),
}
}
+/** Helper function to invoke the id_looper callback, including custom space. */
+static void con_invoke_id_looper(const bConstraintTypeInfo *cti,
+ bConstraint *con,
+ ConstraintIDFunc func,
+ void *userdata)
+{
+ if (cti->id_looper) {
+ cti->id_looper(con, func, userdata);
+ }
+
+ func(con, (ID **)&con->space_object, false, userdata);
+}
+
void BKE_constraint_free_data_ex(bConstraint *con, bool do_id_user)
{
if (con->data) {
@@ -5594,8 +5559,8 @@ void BKE_constraint_free_data_ex(bConstraint *con, bool do_id_user)
}
/* unlink the referenced resources it uses */
- if (do_id_user && cti->id_looper) {
- cti->id_looper(con, con_unlink_refs_cb, NULL);
+ if (do_id_user) {
+ con_invoke_id_looper(cti, con, con_unlink_refs_cb, NULL);
}
}
@@ -5880,9 +5845,12 @@ static bConstraint *add_new_constraint(Object *ob,
return con;
}
-bool BKE_constraint_target_uses_bbone(struct bConstraint *con,
- struct bConstraintTarget *UNUSED(ct))
+bool BKE_constraint_target_uses_bbone(struct bConstraint *con, struct bConstraintTarget *ct)
{
+ if (ct->flag & CONSTRAINT_TAR_CUSTOM_SPACE) {
+ return false;
+ }
+
return (con->flag & CONSTRAINT_BBONE_SHAPE) || (con->type == CONSTRAINT_TYPE_ARMATURE);
}
@@ -5913,9 +5881,7 @@ void BKE_constraints_id_loop(ListBase *conlist, ConstraintIDFunc func, void *use
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
if (cti) {
- if (cti->id_looper) {
- cti->id_looper(con, func, userdata);
- }
+ con_invoke_id_looper(cti, con, func, userdata);
}
}
}
@@ -5967,16 +5933,14 @@ static void constraint_copy_data_ex(bConstraint *dst,
}
/* Fix usercounts for all referenced data that need it. */
- if (cti->id_looper && (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
- cti->id_looper(dst, con_fix_copied_refs_cb, NULL);
+ if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
+ con_invoke_id_looper(cti, dst, con_fix_copied_refs_cb, NULL);
}
/* for proxies we don't want to make extern */
if (do_extern) {
/* go over used ID-links for this constraint to ensure that they are valid for proxies */
- if (cti->id_looper) {
- cti->id_looper(dst, con_extern_cb, NULL);
- }
+ con_invoke_id_looper(cti, dst, con_extern_cb, NULL);
}
}
}
@@ -6208,6 +6172,15 @@ int BKE_constraint_targets_get(struct bConstraint *con, struct ListBase *r_targe
count = cti->get_constraint_targets(con, r_targets);
}
+ /* Add the custom target. */
+ if (is_custom_space_needed(con)) {
+ bConstraintTarget *ct;
+ SINGLETARGET_GET_TARS(con, con->space_object, con->space_subtarget, ct, r_targets);
+ ct->space = CONSTRAINT_SPACE_WORLD;
+ ct->flag |= CONSTRAINT_TAR_CUSTOM_SPACE;
+ count++;
+ }
+
return count;
}
@@ -6219,6 +6192,20 @@ void BKE_constraint_targets_flush(struct bConstraint *con, struct ListBase *targ
return;
}
+ /* Remove the custom target. */
+ bConstraintTarget *ct = (bConstraintTarget *)targets->last;
+
+ if (ct && (ct->flag & CONSTRAINT_TAR_CUSTOM_SPACE)) {
+ BLI_assert(is_custom_space_needed(con));
+
+ if (!no_copy) {
+ con->space_object = ct->tar;
+ BLI_strncpy(con->space_subtarget, ct->subtarget, sizeof(con->space_subtarget));
+ }
+
+ BLI_freelinkN(targets, ct);
+ }
+
/* Release the constraint-specific targets. */
if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, targets, no_copy);
@@ -6276,6 +6263,9 @@ void BKE_constraint_target_matrix_get(struct Depsgraph *depsgraph,
}
}
+ /* Initialize the custom space for use in calculating the matrices. */
+ BKE_constraint_custom_object_space_init(cob, con);
+
/* get targets - we only need the first one though (and there should only be one) */
cti->get_constraint_targets(con, &targets);
@@ -6339,33 +6329,23 @@ void BKE_constraint_targets_for_solving_get(struct Depsgraph *depsgraph,
}
}
-void BKE_constraint_custom_object_space_get(float r_mat[4][4], bConstraint *con)
+void BKE_constraint_custom_object_space_init(bConstraintOb *cob, bConstraint *con)
{
- if (!con ||
- (con->ownspace != CONSTRAINT_SPACE_CUSTOM && con->tarspace != CONSTRAINT_SPACE_CUSTOM)) {
- return;
- }
- bConstraintTarget *ct;
- ListBase target = {NULL, NULL};
- SINGLETARGET_GET_TARS(con, con->space_object, con->space_subtarget, ct, &target);
-
- /* Basically default_get_tarmat but without the unused parameters. */
- if (VALID_CONS_TARGET(ct)) {
- constraint_target_to_mat4(ct->tar,
- ct->subtarget,
+ if (con && con->space_object && is_custom_space_needed(con)) {
+ /* Basically default_get_tarmat but without the unused parameters. */
+ constraint_target_to_mat4(con->space_object,
+ con->space_subtarget,
NULL,
- ct->matrix,
+ cob->space_obj_world_matrix,
CONSTRAINT_SPACE_WORLD,
CONSTRAINT_SPACE_WORLD,
0,
0);
- copy_m4_m4(r_mat, ct->matrix);
- }
- else {
- unit_m4(r_mat);
+
+ return;
}
- SINGLETARGET_FLUSH_TARS(con, con->space_object, con->space_subtarget, ct, &target, true);
+ unit_m4(cob->space_obj_world_matrix);
}
/* ---------- Evaluation ----------- */
@@ -6410,8 +6390,8 @@ void BKE_constraints_solve(struct Depsgraph *depsgraph,
*/
enf = con->enforce;
- /* Get custom space matrix. */
- BKE_constraint_custom_object_space_get(cob->space_obj_world_matrix, con);
+ /* Initialize the custom space for use in calculating the matrices. */
+ BKE_constraint_custom_object_space_init(cob, con);
/* make copy of world-space matrix pre-constraint for use with blending later */
copy_m4_m4(oldmat, cob->matrix);