Depsgraph: Fix crash with copy-on-write enabled

Was caused by ec0756af6c7, once again, we can't pass view layer,
need to pass index.

The sad part is that currently we don't have quick way to look up
view layer by index. Can do similar thing as we do for bones and
bases.
This commit is contained in:
Sergey Sharybin 2018-04-19 12:03:02 +02:00
parent caa7101df5
commit b352d2705d
5 changed files with 16 additions and 8 deletions

@ -248,7 +248,7 @@ void BKE_object_data_select_update(
void BKE_object_eval_flush_base_flags(
struct Depsgraph *depsgraph,
struct ViewLayer *view_layer,
struct Scene *scene, const int view_layer_index,
struct Object *object, int base_index,
const bool is_from_set);

@ -445,9 +445,14 @@ void BKE_object_data_select_update(Depsgraph *UNUSED(depsgraph),
}
void BKE_object_eval_flush_base_flags(Depsgraph *UNUSED(depsgraph),
ViewLayer *view_layer,
Object *object, int base_index, bool is_from_set)
Scene *scene, const int view_layer_index,
Object *object, int base_index,
const bool is_from_set)
{
/* TODO(sergey): Avoid list lookup. */
BLI_assert(view_layer_index >= 0);
ViewLayer *view_layer = BLI_findlink(&scene->view_layers, view_layer_index);
BLI_assert(view_layer != NULL);
BLI_assert(view_layer->object_bases_array != NULL);
BLI_assert(base_index >= 0);
BLI_assert(base_index < MEM_allocN_len(view_layer->object_bases_array) / sizeof(Base *));

@ -526,14 +526,16 @@ void DepsgraphNodeBuilder::build_object_flags(
if (base_index == -1) {
return;
}
/* TODO(sergey): Is this really best component to be used? */
Scene *scene_cow = get_cow_datablock(scene_);
Object *object_cow = get_cow_datablock(object);
const bool is_from_set = (linked_state == DEG_ID_LINKED_VIA_SET);
/* TODO(sergey): Is this really best component to be used? */
add_operation_node(&object->id,
DEG_NODE_TYPE_LAYER_COLLECTIONS,
function_bind(BKE_object_eval_flush_base_flags,
_1,
view_layer_,
scene_cow,
view_layer_index_,
object_cow, base_index,
is_from_set),
DEG_OPCODE_OBJECT_BASE_FLAGS);

@ -234,6 +234,7 @@ protected:
/* State which demotes currently built entities. */
Scene *scene_;
ViewLayer *view_layer_;
int view_layer_index_;
GHash *cow_id_hash_;
BuilderMap built_map_;

@ -70,6 +70,8 @@ void DepsgraphNodeBuilder::build_view_layer(
ViewLayer *view_layer,
eDepsNode_LinkedState_Type linked_state)
{
view_layer_index_ = BLI_findindex(&scene->view_layers, view_layer);
BLI_assert(view_layer_index_ != -1);
/* Scene ID block. */
add_id_node(&scene->id);
/* Time source. */
@ -134,14 +136,12 @@ void DepsgraphNodeBuilder::build_view_layer(
build_movieclip(clip);
}
/* Collections. */
int view_layer_index = BLI_findindex(&scene->view_layers, view_layer);
BLI_assert(view_layer_index != -1);
add_operation_node(&scene->id,
DEG_NODE_TYPE_LAYER_COLLECTIONS,
function_bind(BKE_layer_eval_view_layer_indexed,
_1,
&scene_cow->id,
view_layer_index),
view_layer_index_),
DEG_OPCODE_VIEW_LAYER_EVAL);
/* Parameters evaluation for scene relations mainly. */
add_operation_node(&scene->id,