Fix T83164: Spline IK `joint_bindings` parameter is broken.
Code freeing the array would not properly reset its length value to zero. Note that this corrupted data could also be saved in .blend files, so had to bump fileversion and add some doversion code too. Fix T90166: crash when creating a liboverride.
This commit is contained in:
parent
103e314be4
commit
dbdf22786d
Notes:
blender-bot
2023-02-13 23:16:02 +01:00
Referenced by issue #90166, Library override crashing Referenced by issue #83164, Spline IK `joint_bindings` parameter is broken Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
|
@ -4360,9 +4360,7 @@ static void splineik_free(bConstraint *con)
|
|||
bSplineIKConstraint *data = con->data;
|
||||
|
||||
/* binding array */
|
||||
if (data->points) {
|
||||
MEM_freeN(data->points);
|
||||
}
|
||||
MEM_SAFE_FREE(data->points);
|
||||
}
|
||||
|
||||
static void splineik_copy(bConstraint *con, bConstraint *srccon)
|
||||
|
|
|
@ -1778,6 +1778,19 @@ static void do_versions_seq_set_cache_defaults(Editing *ed)
|
|||
ed->recycle_max_cost = 10.0f;
|
||||
}
|
||||
|
||||
static void do_version_constraints_spline_ik_joint_bindings(ListBase *lb)
|
||||
{
|
||||
/* Binding array data could be freed without properly resetting its size data. */
|
||||
LISTBASE_FOREACH (bConstraint *, con, lb) {
|
||||
if (con->type == CONSTRAINT_TYPE_SPLINEIK) {
|
||||
bSplineIKConstraint *data = (bSplineIKConstraint *)con->data;
|
||||
if (data->points == NULL) {
|
||||
data->numpoints = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
||||
{
|
||||
bool use_collection_compat_28 = true;
|
||||
|
@ -5090,6 +5103,17 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
if (!MAIN_VERSION_ATLEAST(bmain, 283, 21)) {
|
||||
ListBase *lb = which_libbase(bmain, ID_VF);
|
||||
BKE_main_id_repair_duplicate_names_listbase(lb);
|
||||
|
||||
/* Fix SplineIK constraint's inconsistency between binding points array and its stored size. */
|
||||
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
|
||||
/* NOTE: Objects should never have SplineIK constraint, so no need to apply this fix on
|
||||
* their constraints. */
|
||||
if (ob->pose) {
|
||||
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
||||
do_version_constraints_spline_ik_joint_bindings(&pchan->constraints);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -405,11 +405,8 @@ static void test_constraint(
|
|||
* free the points array and request a rebind...
|
||||
*/
|
||||
if ((data->points == NULL) || (data->numpoints != data->chainlen + 1)) {
|
||||
/* free the points array */
|
||||
if (data->points) {
|
||||
MEM_freeN(data->points);
|
||||
data->points = NULL;
|
||||
}
|
||||
MEM_SAFE_FREE(data->points);
|
||||
data->numpoints = 0;
|
||||
|
||||
/* clear the bound flag, forcing a rebind next time this is evaluated */
|
||||
data->flag &= ~CONSTRAINT_SPLINEIK_BOUND;
|
||||
|
|
Loading…
Reference in New Issue