forked from blender/blender
Fix visibility of instancer object #43
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
|
||||||
|
#include "BKE_object.h"
|
||||||
#include "DEG_depsgraph_query.h"
|
#include "DEG_depsgraph_query.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
|
|
||||||
@ -305,22 +306,26 @@ void BlenderSceneDelegate::update_objects(Object *object)
|
|||||||
if (!ObjectData::is_supported(object)) {
|
if (!ObjectData::is_supported(object)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pxr::SdfPath id = object_prim_id(object);
|
pxr::SdfPath id = object_prim_id(object);
|
||||||
ObjectData *obj_data = object_data(id);
|
ObjectData *obj_data = object_data(id);
|
||||||
if (obj_data) {
|
if (obj_data) {
|
||||||
obj_data->update_parent();
|
obj_data->update_parent();
|
||||||
obj_data->update();
|
obj_data->update();
|
||||||
|
obj_data->update_visibility();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (view3d && !BKE_object_is_visible_in_viewport(view3d, object)) {
|
|
||||||
|
if (!ObjectData::is_visible(this, object)) {
|
||||||
|
/* Do not export new object if it is invisible */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
objects_[id] = ObjectData::create(this, object, id);
|
objects_[id] = ObjectData::create(this, object, id);
|
||||||
obj_data = object_data(id);
|
obj_data = object_data(id);
|
||||||
obj_data->update_parent();
|
obj_data->update_parent();
|
||||||
obj_data->init();
|
obj_data->init();
|
||||||
obj_data->insert();
|
obj_data->insert();
|
||||||
obj_data->update_visibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlenderSceneDelegate::update_instancers(Object *object)
|
void BlenderSceneDelegate::update_instancers(Object *object)
|
||||||
@ -333,26 +338,30 @@ void BlenderSceneDelegate::update_instancers(Object *object)
|
|||||||
pxr::SdfPath id = instancer_prim_id(object);
|
pxr::SdfPath id = instancer_prim_id(object);
|
||||||
InstancerData *i_data = instancer_data(id);
|
InstancerData *i_data = instancer_data(id);
|
||||||
if (i_data) {
|
if (i_data) {
|
||||||
if (object->transflag & OB_DUPLI) {
|
if ((object->transflag & OB_DUPLI) == 0) {
|
||||||
i_data->update();
|
/* Object isn't instancer anymore and should be removed */
|
||||||
}
|
|
||||||
else {
|
|
||||||
i_data->remove();
|
i_data->remove();
|
||||||
instancers_.erase(id);
|
instancers_.erase(id);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i_data->update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((object->transflag & OB_DUPLI) == 0) {
|
if ((object->transflag & OB_DUPLI) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (view3d && !BKE_object_is_visible_in_viewport(view3d, object)) {
|
|
||||||
|
if (!InstancerData::is_visible(this, object)) {
|
||||||
|
/* Do not export new instancer if it is invisible */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
instancers_[id] = std::make_unique<InstancerData>(this, object, id);
|
instancers_[id] = std::make_unique<InstancerData>(this, object, id);
|
||||||
i_data = instancer_data(id);
|
i_data = instancer_data(id);
|
||||||
i_data->init();
|
i_data->init();
|
||||||
i_data->insert();
|
i_data->insert();
|
||||||
i_data->update_visibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlenderSceneDelegate::update_world()
|
void BlenderSceneDelegate::update_world()
|
||||||
@ -385,6 +394,8 @@ void BlenderSceneDelegate::check_updates()
|
|||||||
DEGIDIterData data = {0};
|
DEGIDIterData data = {0};
|
||||||
data.graph = depsgraph;
|
data.graph = depsgraph;
|
||||||
data.only_updated = true;
|
data.only_updated = true;
|
||||||
|
eEvaluationMode deg_mode = DEG_get_mode(depsgraph);
|
||||||
|
|
||||||
ITER_BEGIN (DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id)
|
ITER_BEGIN (DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id)
|
||||||
{
|
{
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE,
|
CLOG_INFO(LOG_RENDER_HYDRA_SCENE,
|
||||||
@ -396,6 +407,11 @@ void BlenderSceneDelegate::check_updates()
|
|||||||
switch (GS(id->name)) {
|
switch (GS(id->name)) {
|
||||||
case ID_OB: {
|
case ID_OB: {
|
||||||
Object *object = (Object *)id;
|
Object *object = (Object *)id;
|
||||||
|
CLOG_INFO(LOG_RENDER_HYDRA_SCENE,
|
||||||
|
2,
|
||||||
|
"Visibility: %s [%s]",
|
||||||
|
object->id.name,
|
||||||
|
std::bitset<3>(BKE_object_visibility(object, deg_mode)).to_string().c_str());
|
||||||
update_objects(object);
|
update_objects(object);
|
||||||
update_instancers(object);
|
update_instancers(object);
|
||||||
} break;
|
} break;
|
||||||
@ -414,6 +430,10 @@ void BlenderSceneDelegate::check_updates()
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case ID_SCE: {
|
case ID_SCE: {
|
||||||
|
if (id->recalc & ID_RECALC_COPY_ON_WRITE && !(id->recalc & ID_RECALC_SELECT)) {
|
||||||
|
do_update_collection = true;
|
||||||
|
do_update_visibility = true;
|
||||||
|
}
|
||||||
if (id->recalc & ID_RECALC_BASE_FLAGS) {
|
if (id->recalc & ID_RECALC_BASE_FLAGS) {
|
||||||
do_update_visibility = true;
|
do_update_visibility = true;
|
||||||
}
|
}
|
||||||
@ -448,12 +468,13 @@ void BlenderSceneDelegate::add_new_objects()
|
|||||||
{
|
{
|
||||||
DEGObjectIterSettings settings = {0};
|
DEGObjectIterSettings settings = {0};
|
||||||
settings.depsgraph = depsgraph;
|
settings.depsgraph = depsgraph;
|
||||||
settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_VISIBLE |
|
settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
|
||||||
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
|
|
||||||
DEGObjectIterData data = {0};
|
DEGObjectIterData data = {0};
|
||||||
data.settings = &settings;
|
data.settings = &settings;
|
||||||
data.graph = settings.depsgraph;
|
data.graph = settings.depsgraph;
|
||||||
data.flag = settings.flags;
|
data.flag = settings.flags;
|
||||||
|
eEvaluationMode deg_mode = DEG_get_mode(depsgraph);
|
||||||
|
|
||||||
ITER_BEGIN (DEG_iterator_objects_begin,
|
ITER_BEGIN (DEG_iterator_objects_begin,
|
||||||
DEG_iterator_objects_next,
|
DEG_iterator_objects_next,
|
||||||
DEG_iterator_objects_end,
|
DEG_iterator_objects_end,
|
||||||
@ -461,7 +482,11 @@ void BlenderSceneDelegate::add_new_objects()
|
|||||||
Object *,
|
Object *,
|
||||||
object)
|
object)
|
||||||
{
|
{
|
||||||
|
CLOG_INFO(LOG_RENDER_HYDRA_SCENE,
|
||||||
|
2,
|
||||||
|
"Visibility: %s [%s]",
|
||||||
|
object->id.name,
|
||||||
|
std::bitset<3>(BKE_object_visibility(object, deg_mode)).to_string().c_str());
|
||||||
update_objects(object);
|
update_objects(object);
|
||||||
update_instancers(object);
|
update_instancers(object);
|
||||||
}
|
}
|
||||||
@ -480,6 +505,7 @@ void BlenderSceneDelegate::remove_unused_objects()
|
|||||||
data.settings = &settings;
|
data.settings = &settings;
|
||||||
data.graph = settings.depsgraph;
|
data.graph = settings.depsgraph;
|
||||||
data.flag = settings.flags;
|
data.flag = settings.flags;
|
||||||
|
|
||||||
ITER_BEGIN (DEG_iterator_objects_begin,
|
ITER_BEGIN (DEG_iterator_objects_begin,
|
||||||
DEG_iterator_objects_next,
|
DEG_iterator_objects_next,
|
||||||
DEG_iterator_objects_end,
|
DEG_iterator_objects_end,
|
||||||
@ -539,6 +565,7 @@ void BlenderSceneDelegate::remove_unused_objects()
|
|||||||
|
|
||||||
void BlenderSceneDelegate::update_visibility()
|
void BlenderSceneDelegate::update_visibility()
|
||||||
{
|
{
|
||||||
|
/* Updating visibility of existing objects/instancers */
|
||||||
for (auto &it : objects_) {
|
for (auto &it : objects_) {
|
||||||
it.second->update_visibility();
|
it.second->update_visibility();
|
||||||
}
|
}
|
||||||
@ -546,15 +573,16 @@ void BlenderSceneDelegate::update_visibility()
|
|||||||
it.second->update_visibility();
|
it.second->update_visibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add objects which were invisible before and not added yet */
|
/* Add objects/instancers which were invisible before and not added yet */
|
||||||
DEGObjectIterSettings settings = {0};
|
DEGObjectIterSettings settings = {0};
|
||||||
settings.depsgraph = depsgraph;
|
settings.depsgraph = depsgraph;
|
||||||
settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_VISIBLE |
|
settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
|
||||||
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
|
|
||||||
DEGObjectIterData data = {0};
|
DEGObjectIterData data = {0};
|
||||||
data.settings = &settings;
|
data.settings = &settings;
|
||||||
data.graph = settings.depsgraph;
|
data.graph = settings.depsgraph;
|
||||||
data.flag = settings.flags;
|
data.flag = settings.flags;
|
||||||
|
eEvaluationMode deg_mode = DEG_get_mode(depsgraph);
|
||||||
|
|
||||||
ITER_BEGIN (DEG_iterator_objects_begin,
|
ITER_BEGIN (DEG_iterator_objects_begin,
|
||||||
DEG_iterator_objects_next,
|
DEG_iterator_objects_next,
|
||||||
DEG_iterator_objects_end,
|
DEG_iterator_objects_end,
|
||||||
@ -562,7 +590,11 @@ void BlenderSceneDelegate::update_visibility()
|
|||||||
Object *,
|
Object *,
|
||||||
object)
|
object)
|
||||||
{
|
{
|
||||||
|
CLOG_INFO(LOG_RENDER_HYDRA_SCENE,
|
||||||
|
2,
|
||||||
|
"Visibility: %s [%s]",
|
||||||
|
object->id.name,
|
||||||
|
std::bitset<3>(BKE_object_visibility(object, deg_mode)).to_string().c_str());
|
||||||
if (!object_data(object_prim_id(object))) {
|
if (!object_data(object_prim_id(object))) {
|
||||||
update_objects(object);
|
update_objects(object);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
#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 "blender_scene_delegate.h"
|
#include "blender_scene_delegate.h"
|
||||||
#include "instancer.h"
|
#include "instancer.h"
|
||||||
|
|
||||||
@ -33,6 +36,29 @@ bool InstancerData::is_supported(Object *object)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InstancerData::is_visible(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||||
|
{
|
||||||
|
eEvaluationMode deg_mode = DEG_get_mode(scene_delegate->depsgraph);
|
||||||
|
int vis = BKE_object_visibility(object, deg_mode);
|
||||||
|
bool ret = vis & OB_VISIBLE_INSTANCES;
|
||||||
|
if (deg_mode == DAG_EVAL_VIEWPORT) {
|
||||||
|
ret &= BKE_object_is_visible_in_viewport(scene_delegate->view3d, object);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (ret) {
|
||||||
|
/* If some of parent object is instancer, then currenct object as instancer
|
||||||
|
* is invisible in Final render */
|
||||||
|
for (Object *ob = object->parent; ob != nullptr; ob = ob->parent) {
|
||||||
|
if (ob->transflag & OB_DUPLI) {
|
||||||
|
ret = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void InstancerData::init()
|
void InstancerData::init()
|
||||||
{
|
{
|
||||||
ID_LOG(2, "");
|
ID_LOG(2, "");
|
||||||
@ -62,7 +88,6 @@ void InstancerData::remove()
|
|||||||
void InstancerData::update()
|
void InstancerData::update()
|
||||||
{
|
{
|
||||||
ID_LOG(2, "");
|
ID_LOG(2, "");
|
||||||
|
|
||||||
Object *object = (Object *)id;
|
Object *object = (Object *)id;
|
||||||
if (id->recalc & ID_RECALC_GEOMETRY ||
|
if (id->recalc & ID_RECALC_GEOMETRY ||
|
||||||
(object->data && ((ID *)object->data)->recalc & ID_RECALC_GEOMETRY) ||
|
(object->data && ((ID *)object->data)->recalc & ID_RECALC_GEOMETRY) ||
|
||||||
@ -86,7 +111,10 @@ pxr::VtValue InstancerData::get_data(pxr::TfToken const &key) const
|
|||||||
|
|
||||||
bool InstancerData::update_visibility()
|
bool InstancerData::update_visibility()
|
||||||
{
|
{
|
||||||
bool ret = ObjectData::update_visibility();
|
bool prev_visible = visible;
|
||||||
|
visible = is_visible(scene_delegate_, (Object *)id);
|
||||||
|
bool ret = visible != prev_visible;
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
auto &change_tracker = scene_delegate_->GetRenderIndex().GetChangeTracker();
|
auto &change_tracker = scene_delegate_->GetRenderIndex().GetChangeTracker();
|
||||||
change_tracker.MarkInstancerDirty(prim_id, pxr::HdChangeTracker::DirtyVisibility);
|
change_tracker.MarkInstancerDirty(prim_id, pxr::HdChangeTracker::DirtyVisibility);
|
||||||
@ -164,6 +192,14 @@ void InstancerData::check_update(Object *object)
|
|||||||
pxr::SdfPath path = object_prim_id(object);
|
pxr::SdfPath path = object_prim_id(object);
|
||||||
MeshInstance *m_inst = mesh_instance(path);
|
MeshInstance *m_inst = mesh_instance(path);
|
||||||
if (m_inst) {
|
if (m_inst) {
|
||||||
|
if (!is_instance_visible(object)) {
|
||||||
|
m_inst->data->remove();
|
||||||
|
mesh_instances_.erase(path);
|
||||||
|
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkInstancerDirty(
|
||||||
|
prim_id, pxr::HdChangeTracker::AllDirty);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_inst->data->update();
|
m_inst->data->update();
|
||||||
|
|
||||||
if (m_inst->data->id->recalc & ID_RECALC_TRANSFORM) {
|
if (m_inst->data->id->recalc & ID_RECALC_TRANSFORM) {
|
||||||
@ -176,6 +212,13 @@ void InstancerData::check_update(Object *object)
|
|||||||
|
|
||||||
LightInstance *l_inst = light_instance(path);
|
LightInstance *l_inst = light_instance(path);
|
||||||
if (l_inst) {
|
if (l_inst) {
|
||||||
|
if (!is_instance_visible(object)) {
|
||||||
|
l_inst->transforms.clear();
|
||||||
|
update_light_instance(*l_inst);
|
||||||
|
light_instances_.erase(path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Object *obj = (Object *)l_inst->data->id;
|
Object *obj = (Object *)l_inst->data->id;
|
||||||
if (obj->id.recalc & (ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY) ||
|
if (obj->id.recalc & (ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY) ||
|
||||||
((ID *)obj->data)->recalc & ID_RECALC_GEOMETRY)
|
((ID *)obj->data)->recalc & ID_RECALC_GEOMETRY)
|
||||||
@ -184,6 +227,28 @@ void InstancerData::check_update(Object *object)
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Checking if object wasn't added to instances before */
|
||||||
|
if (is_supported(object) && is_instance_visible(object)) {
|
||||||
|
bool do_write_instances = false;
|
||||||
|
ListBase *lb = object_duplilist(
|
||||||
|
scene_delegate_->depsgraph, scene_delegate_->scene, (Object *)id);
|
||||||
|
LISTBASE_FOREACH (DupliObject *, dupli, lb) {
|
||||||
|
if (dupli->ob == object) {
|
||||||
|
do_write_instances = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free_object_duplilist(lb);
|
||||||
|
|
||||||
|
if (do_write_instances) {
|
||||||
|
write_instances();
|
||||||
|
if (!mesh_instances_.empty()) {
|
||||||
|
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkInstancerDirty(
|
||||||
|
prim_id, pxr::HdChangeTracker::AllDirty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstancerData::check_remove(std::set<std::string> &available_objects)
|
void InstancerData::check_remove(std::set<std::string> &available_objects)
|
||||||
@ -237,6 +302,22 @@ void InstancerData::update_double_sided(MaterialData *mat_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InstancerData::is_instance_visible(Object *object)
|
||||||
|
{
|
||||||
|
eEvaluationMode deg_mode = DEG_get_mode(scene_delegate_->depsgraph);
|
||||||
|
int vis = BKE_object_visibility(object, deg_mode);
|
||||||
|
bool ret = vis & OB_VISIBLE_SELF;
|
||||||
|
if (deg_mode == DAG_EVAL_VIEWPORT) {
|
||||||
|
if (!ret && ((object->transflag & OB_DUPLI) == 0 ||
|
||||||
|
(object->transflag & OB_DUPLI &&
|
||||||
|
object->duplicator_visibility_flag & OB_DUPLI_FLAG_VIEWPORT)))
|
||||||
|
{
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
pxr::SdfPath InstancerData::object_prim_id(Object *object) const
|
pxr::SdfPath InstancerData::object_prim_id(Object *object) const
|
||||||
{
|
{
|
||||||
/* Making id of object in form like <prefix>_<pointer in 16 hex digits format> */
|
/* Making id of object in form like <prefix>_<pointer in 16 hex digits format> */
|
||||||
@ -273,7 +354,7 @@ void InstancerData::write_instances()
|
|||||||
scene_delegate_->depsgraph, scene_delegate_->scene, (Object *)id);
|
scene_delegate_->depsgraph, scene_delegate_->scene, (Object *)id);
|
||||||
LISTBASE_FOREACH (DupliObject *, dupli, lb) {
|
LISTBASE_FOREACH (DupliObject *, dupli, lb) {
|
||||||
Object *ob = dupli->ob;
|
Object *ob = dupli->ob;
|
||||||
if (!is_supported(ob)) {
|
if (!is_supported(ob) || !is_instance_visible(ob)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ class InstancerData : public ObjectData {
|
|||||||
public:
|
public:
|
||||||
InstancerData(BlenderSceneDelegate *scene_delegate, Object *object, pxr::SdfPath const &prim_id);
|
InstancerData(BlenderSceneDelegate *scene_delegate, Object *object, 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);
|
||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
void insert() override;
|
void insert() override;
|
||||||
@ -46,6 +47,7 @@ class InstancerData : public ObjectData {
|
|||||||
void update_double_sided(MaterialData *mat_data);
|
void update_double_sided(MaterialData *mat_data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool is_instance_visible(Object *object);
|
||||||
pxr::SdfPath object_prim_id(Object *object) const;
|
pxr::SdfPath object_prim_id(Object *object) const;
|
||||||
pxr::SdfPath light_prim_id(LightInstance const &inst, int index) const;
|
pxr::SdfPath light_prim_id(LightInstance const &inst, int index) const;
|
||||||
int light_prim_id_index(pxr::SdfPath const &id) const;
|
int light_prim_id_index(pxr::SdfPath const &id) const;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
* Copyright 2011-2022 Blender Foundation */
|
* Copyright 2011-2022 Blender Foundation */
|
||||||
|
|
||||||
#include "BKE_object.h"
|
#include "BKE_object.h"
|
||||||
|
#include "DEG_depsgraph_query.h"
|
||||||
|
|
||||||
#include "blender_scene_delegate.h"
|
#include "blender_scene_delegate.h"
|
||||||
#include "light.h"
|
#include "light.h"
|
||||||
@ -59,21 +60,36 @@ bool ObjectData::is_supported(Object *object)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjectData::update_visibility()
|
bool ObjectData::is_visible(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||||
{
|
{
|
||||||
if (!scene_delegate_->view3d) {
|
eEvaluationMode deg_mode = DEG_get_mode(scene_delegate->depsgraph);
|
||||||
return false;
|
int vis = BKE_object_visibility(object, deg_mode);
|
||||||
|
bool ret = vis & OB_VISIBLE_SELF;
|
||||||
|
if (deg_mode == DAG_EVAL_VIEWPORT) {
|
||||||
|
ret &= BKE_object_is_visible_in_viewport(scene_delegate->view3d, object);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
bool prev_visible = visible;
|
if (ret) {
|
||||||
visible = BKE_object_is_visible_in_viewport(scene_delegate_->view3d, (Object *)id);
|
/* If some of parent object is instancer, then currenct object
|
||||||
bool ret = visible != prev_visible;
|
* is invisible in Final render */
|
||||||
if (ret) {
|
for (Object *ob = object->parent; ob != nullptr; ob = ob->parent) {
|
||||||
ID_LOG(2, "");
|
if (ob->transflag & OB_DUPLI) {
|
||||||
|
ret = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ObjectData::update_visibility()
|
||||||
|
{
|
||||||
|
bool prev_visible = visible;
|
||||||
|
visible = is_visible(scene_delegate_, (Object *)id);
|
||||||
|
return visible != prev_visible;
|
||||||
|
}
|
||||||
|
|
||||||
void ObjectData::update_parent()
|
void ObjectData::update_parent()
|
||||||
{
|
{
|
||||||
Object *object = (Object *)id;
|
Object *object = (Object *)id;
|
||||||
@ -87,7 +103,6 @@ void ObjectData::update_parent()
|
|||||||
scene_delegate_->instancer_prim_id(ob));
|
scene_delegate_->instancer_prim_id(ob));
|
||||||
if (i_data) {
|
if (i_data) {
|
||||||
i_data->update_as_parent();
|
i_data->update_as_parent();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ 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);
|
||||||
|
|
||||||
virtual bool update_visibility();
|
virtual bool update_visibility();
|
||||||
void update_parent();
|
void update_parent();
|
||||||
|
Loading…
Reference in New Issue
Block a user