Depsgraph: Move boundbox sync to the post-geometry evaluation

Boundbox does not depend on transform and only need geometry
component.

This change solves possible race condition accessing geometry
data and allocating/assigning pointers.

Based on disacussion in IRC with @mano-wii and @brecht.
This commit is contained in:
Sergey Sharybin 2018-11-21 15:02:36 +01:00
parent b6693f1f54
commit 5e4ed2793b
3 changed files with 22 additions and 12 deletions

View File

@ -247,6 +247,8 @@ void BKE_object_eval_uber_data(
struct Scene *scene,
struct Object *ob);
void BKE_object_eval_boundbox(struct Depsgraph *depsgraph, struct Object *object);
void BKE_object_eval_ptcache_reset(
struct Depsgraph *depsgraph,
struct Scene *scene,

View File

@ -47,6 +47,7 @@
#include "BKE_curve.h"
#include "BKE_displist.h"
#include "BKE_fcurve.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BIK_api.h"
@ -748,12 +749,13 @@ void BKE_pose_splineik_evaluate(struct Depsgraph *depsgraph,
}
/* Common part for both original and proxy armatrues. */
static void pose_eval_done_common(Object *object)
static void pose_eval_done_common(struct Depsgraph *depsgraph, Object *object)
{
bPose *pose = object->pose;
UNUSED_VARS_NDEBUG(pose);
BLI_assert(pose != NULL);
armature_cached_bbone_deformation_update(object);
BKE_object_eval_boundbox(depsgraph, object);
}
static void pose_eval_cleanup_common(Object *object)
{
@ -770,7 +772,7 @@ void BKE_pose_eval_done(struct Depsgraph *depsgraph, Object *object)
UNUSED_VARS_NDEBUG(pose);
DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
BLI_assert(object->type == OB_ARMATURE);
pose_eval_done_common(object);
pose_eval_done_common(depsgraph, object);
}
void BKE_pose_eval_cleanup(struct Depsgraph *depsgraph,
@ -801,7 +803,7 @@ void BKE_pose_eval_proxy_done(struct Depsgraph *depsgraph, Object *object)
{
BLI_assert(ID_IS_LINKED(object) && object->proxy_from != NULL);
DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
pose_eval_done_common(object);
pose_eval_done_common(depsgraph, object);
}
void BKE_pose_eval_proxy_cleanup(struct Depsgraph *depsgraph, Object *object)

View File

@ -149,14 +149,6 @@ void BKE_object_eval_transform_final(Depsgraph *depsgraph, Object *ob)
copy_m4_m4(ob_orig->constinv, ob->constinv);
ob_orig->transflag = ob->transflag;
ob_orig->flag = ob->flag;
BoundBox *bb = BKE_object_boundbox_get(ob);
if (bb != NULL) {
if (ob_orig->bb == NULL) {
ob_orig->bb = MEM_mallocN(sizeof(*ob_orig->bb), __func__);
}
*ob_orig->bb = *bb;
}
}
}
@ -276,8 +268,22 @@ void BKE_object_handle_data_update(
psys = psys->next;
}
}
BKE_object_eval_boundbox(depsgraph, ob);
}
/* quick cache removed */
void BKE_object_eval_boundbox(Depsgraph *depsgraph, Object *object)
{
if (!DEG_is_active(depsgraph)) {
return;
}
Object *ob_orig = DEG_get_original_object(object);
BoundBox *bb = BKE_object_boundbox_get(object);
if (bb != NULL) {
if (ob_orig->bb == NULL) {
ob_orig->bb = MEM_mallocN(sizeof(*ob_orig->bb), __func__);
}
*ob_orig->bb = *bb;
}
}
bool BKE_object_eval_proxy_copy(Depsgraph *depsgraph,