forked from blender/blender
Fix visibility of instancer object #43
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -63,21 +63,27 @@ 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;
|
||||
}
|
||||
else {
|
||||
if (object->transflag & OB_DUPLI) {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user