Fix visibility of instancer object #43

Merged
Bogdan Nagirniak merged 16 commits from BLEN-405_1 into hydra-render 2023-05-24 13:44:35 +02:00
3 changed files with 17 additions and 25 deletions
Showing only changes of commit a18ac61a0b - Show all commits

View File

@ -39,24 +39,13 @@ bool InstancerData::is_supported(Object *object)
bool InstancerData::is_visible(BlenderSceneDelegate *scene_delegate, Object *object)
{
bool ret = true;
if (DEG_get_mode(scene_delegate->depsgraph) == DAG_EVAL_VIEWPORT) {
eEvaluationMode deg_mode = DEG_get_mode(scene_delegate->depsgraph);
if (deg_mode == DAG_EVAL_VIEWPORT) {
ret = BKE_object_is_visible_in_viewport(scene_delegate->view3d, object);
}
else {
}
return ret;
}
bool InstancerData::is_visible(BlenderSceneDelegate *scene_delegate,
Object *object,
Object *child_object)
{
bool ret = true;
eEvaluationMode deg_mode = DEG_get_mode(scene_delegate->depsgraph);
ret = BKE_object_visibility(object, deg_mode) & (OB_VISIBLE_SELF | OB_VISIBLE_INSTANCES);
if (ret && child_object && child_object->transflag & OB_DUPLI) {
int flag = deg_mode == DAG_EVAL_VIEWPORT ? OB_DUPLI_FLAG_VIEWPORT : OB_DUPLI_FLAG_RENDER;
ret = child_object->duplicator_visibility_flag & flag;
int vis = BKE_object_visibility(object, deg_mode);
ret = vis & (OB_VISIBLE_SELF | OB_VISIBLE_INSTANCES);
}
return ret;
}

View File

@ -26,9 +26,6 @@ class InstancerData : public ObjectData {
InstancerData(BlenderSceneDelegate *scene_delegate, Object *object, pxr::SdfPath const &prim_id);
static bool is_supported(Object *object);
static bool is_visible(BlenderSceneDelegate *scene_delegate, Object *object);
static bool is_visible(BlenderSceneDelegate *scene_delegate,
Object *object,
Object *child_object);
void init() override;
void insert() override;

View File

@ -63,20 +63,26 @@ bool ObjectData::is_supported(Object *object)
bool ObjectData::is_visible(BlenderSceneDelegate *scene_delegate, Object *object)
{
bool ret = true;
if (DEG_get_mode(scene_delegate->depsgraph) == DAG_EVAL_VIEWPORT) {
eEvaluationMode deg_mode = DEG_get_mode(scene_delegate->depsgraph);
if (deg_mode == DAG_EVAL_VIEWPORT) {
ret = BKE_object_is_visible_in_viewport(scene_delegate->view3d, object);
if (ret && object->transflag & OB_DUPLI) {
ret = object->duplicator_visibility_flag & OB_DUPLI_FLAG_VIEWPORT;
}
}
else {
if (object->parent) {
ret = false;
int vis = BKE_object_visibility(object, deg_mode);
ret = vis & OB_VISIBLE_SELF;
if (ret && object->transflag & OB_DUPLI) {
ret = object->duplicator_visibility_flag & OB_DUPLI_FLAG_RENDER;
}
else {
if (object->transflag & OB_DUPLI) {
ret = object->duplicator_visibility_flag & OB_DUPLI_FLAG_RENDER;
if (ret) {
/* If some of parent object is instacer, then object is invisible in Final render */
for (Object *ob = object->parent; ob != nullptr; ob = ob->parent) {
if (ob->transflag & OB_DUPLI) {
ret = false;
break;
}
}
}
}