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 InstancerData::is_visible(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
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);
|
ret = BKE_object_is_visible_in_viewport(scene_delegate->view3d, object);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
}
|
int vis = BKE_object_visibility(object, deg_mode);
|
||||||
return ret;
|
ret = vis & (OB_VISIBLE_SELF | OB_VISIBLE_INSTANCES);
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,6 @@ class InstancerData : public ObjectData {
|
|||||||
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);
|
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 init() override;
|
||||||
void insert() override;
|
void insert() override;
|
||||||
|
@ -63,20 +63,26 @@ bool ObjectData::is_supported(Object *object)
|
|||||||
bool ObjectData::is_visible(BlenderSceneDelegate *scene_delegate, Object *object)
|
bool ObjectData::is_visible(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
eEvaluationMode deg_mode = DEG_get_mode(scene_delegate->depsgraph);
|
||||||
if (DEG_get_mode(scene_delegate->depsgraph) == 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);
|
||||||
if (ret && object->transflag & OB_DUPLI) {
|
if (ret && object->transflag & OB_DUPLI) {
|
||||||
ret = object->duplicator_visibility_flag & OB_DUPLI_FLAG_VIEWPORT;
|
ret = object->duplicator_visibility_flag & OB_DUPLI_FLAG_VIEWPORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (object->parent) {
|
int vis = BKE_object_visibility(object, deg_mode);
|
||||||
ret = false;
|
ret = vis & OB_VISIBLE_SELF;
|
||||||
|
if (ret && object->transflag & OB_DUPLI) {
|
||||||
|
ret = object->duplicator_visibility_flag & OB_DUPLI_FLAG_RENDER;
|
||||||
}
|
}
|
||||||
else {
|
if (ret) {
|
||||||
if (object->transflag & OB_DUPLI) {
|
/* If some of parent object is instacer, then object is invisible in Final render */
|
||||||
ret = object->duplicator_visibility_flag & OB_DUPLI_FLAG_RENDER;
|
for (Object *ob = object->parent; ob != nullptr; ob = ob->parent) {
|
||||||
|
if (ob->transflag & OB_DUPLI) {
|
||||||
|
ret = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user