Make object visibility and instancing creation to be calculated via depsgraph #57

Merged
Bogdan Nagirniak merged 16 commits from BLEN-442 into hydra-render 2023-07-08 10:09:53 +02:00
6 changed files with 7 additions and 18 deletions
Showing only changes of commit 8a40fc54ea - Show all commits

View File

@ -3,7 +3,6 @@
#include <bitset> #include <bitset>
#include "BKE_object.h"
#include "BLI_set.hh" #include "BLI_set.hh"
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "DNA_scene_types.h" #include "DNA_scene_types.h"

View File

@ -6,7 +6,6 @@
#include "BKE_customdata.h" #include "BKE_customdata.h"
#include "BKE_material.h" #include "BKE_material.h"
#include "BKE_object.h"
#include "blender_scene_delegate.h" #include "blender_scene_delegate.h"

View File

@ -4,7 +4,6 @@
#include <pxr/base/gf/vec2f.h> #include <pxr/base/gf/vec2f.h>
#include <pxr/imaging/hd/light.h> #include <pxr/imaging/hd/light.h>
#include "BKE_object.h"
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "blender_scene_delegate.h" #include "blender_scene_delegate.h"
@ -202,15 +201,6 @@ void InstancerData::write_instances()
l_inst.transforms.clear(); l_inst.transforms.clear();
} }
auto is_instance_visible = [&](Object *parent_ob) {
eEvaluationMode deg_mode = DEG_get_mode(scene_delegate_->depsgraph);
bool ret = BKE_object_visibility(parent_ob, deg_mode) & OB_VISIBLE_INSTANCES;
if (deg_mode == DAG_EVAL_VIEWPORT) {
ret &= BKE_object_is_visible_in_viewport(scene_delegate_->view3d, parent_ob);
}
return ret;
};
DEGObjectIterSettings s = {0}; DEGObjectIterSettings s = {0};
s.depsgraph = scene_delegate_->depsgraph; s.depsgraph = scene_delegate_->depsgraph;
s.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | s.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
@ -230,7 +220,7 @@ void InstancerData::write_instances()
if (dupli == nullptr) { if (dupli == nullptr) {
continue; continue;
} }
if (!is_instance_visible(d.dupli_parent)) { if (!ObjectData::is_visible(scene_delegate_, d.dupli_parent, OB_VISIBLE_INSTANCES)) {
continue; continue;
} }
Object *ob = dupli->ob; Object *ob = dupli->ob;

View File

@ -8,7 +8,6 @@
#include "BKE_material.h" #include "BKE_material.h"
#include "BKE_mesh.hh" #include "BKE_mesh.hh"
#include "BKE_mesh_runtime.h" #include "BKE_mesh_runtime.h"
#include "BKE_object.h"
#include "blender_scene_delegate.h" #include "blender_scene_delegate.h"
#include "mesh.h" #include "mesh.h"

View File

@ -1,7 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0 /* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */ * Copyright 2011-2022 Blender Foundation */
#include "BKE_object.h"
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "blender_scene_delegate.h" #include "blender_scene_delegate.h"
@ -64,10 +63,10 @@ bool ObjectData::is_supported(Object *object)
return false; return false;
} }
bool ObjectData::is_visible(BlenderSceneDelegate *scene_delegate, Object *object) bool ObjectData::is_visible(BlenderSceneDelegate *scene_delegate, Object *object, int mode)
{ {
eEvaluationMode deg_mode = DEG_get_mode(scene_delegate->depsgraph); eEvaluationMode deg_mode = DEG_get_mode(scene_delegate->depsgraph);
bool ret = BKE_object_visibility(object, deg_mode) & OB_VISIBLE_SELF; bool ret = BKE_object_visibility(object, deg_mode) & mode;
if (deg_mode == DAG_EVAL_VIEWPORT) { if (deg_mode == DAG_EVAL_VIEWPORT) {
ret &= BKE_object_is_visible_in_viewport(scene_delegate->view3d, object); ret &= BKE_object_is_visible_in_viewport(scene_delegate->view3d, object);
} }

View File

@ -7,6 +7,7 @@
#include <pxr/base/gf/matrix4d.h> #include <pxr/base/gf/matrix4d.h>
#include "BKE_layer.h" #include "BKE_layer.h"
#include "BKE_object.h"
#include "BLI_map.hh" #include "BLI_map.hh"
#include "DNA_object_types.h" #include "DNA_object_types.h"
@ -23,7 +24,9 @@ class ObjectData : public IdData {
Object *object, Object *object,
pxr::SdfPath const &prim_id); pxr::SdfPath const &prim_id);
static bool is_supported(Object *object); static bool is_supported(Object *object);
static bool is_visible(BlenderSceneDelegate *scene_delegate, Object *object); static bool is_visible(BlenderSceneDelegate *scene_delegate,
Object *object,
int mode = OB_VISIBLE_SELF);
virtual bool update_visibility(); virtual bool update_visibility();