Fix visibility of instancer object #40

Closed
Georgiy Markelov wants to merge 21 commits from BLEN-405 into hydra-render

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Collaborator

Purpose

Fix various visibility settings for objects.

Technical steps

  • Fixed object deletion
  • Fixed update on scene update
  • Reworked algorithm of visibility identification
### Purpose Fix various visibility settings for objects. ### Technical steps * Fixed object deletion * Fixed update on scene update * Reworked algorithm of visibility identification
Georgiy Markelov added 5 commits 2023-05-11 15:15:53 +02:00
Brian Savery (AMD) was assigned by Georgiy Markelov 2023-05-11 15:16:11 +02:00
Georgiy Markelov self-assigned this 2023-05-11 15:16:12 +02:00
Bogdan Nagirniak was assigned by Georgiy Markelov 2023-05-11 15:16:12 +02:00
Vasyl Pidhirskyi was assigned by Georgiy Markelov 2023-05-11 15:16:12 +02:00
Georgiy Markelov requested review from Brian Savery (AMD) 2023-05-11 15:16:18 +02:00
Georgiy Markelov requested review from Vasyl Pidhirskyi 2023-05-11 15:16:18 +02:00
Georgiy Markelov added 1 commit 2023-05-12 18:06:21 +02:00
Bogdan Nagirniak requested changes 2023-05-13 09:09:19 +02:00
@ -406,12 +400,10 @@ void BlenderSceneDelegate::check_updates()
} break;
case ID_SCE: {
do_update_collection = true;

It is weird that we have to update collection all the time even when selection was changed

It is weird that we have to update collection all the time even when selection was changed
DagerD marked this conversation as resolved
@ -487,2 +481,3 @@
/* Remove unused instancers */
for (auto it = instancers_.begin(); it != instancers_.end(); ++it) {
for (auto it = instancers_.cbegin(), next_it = it; it != instancers_.cend(); it = next_it) {
++next_it;

move algorithm back, as this potentially could produce undefined behavior

move algorithm back, as this potentially could produce undefined behavior
DagerD marked this conversation as resolved
@ -62,1 +62,3 @@
bool ObjectData::update_visibility()
bool ObjectData::is_visible(BlenderSceneDelegate *scene_delegate,
Object *object,
ObjectData *objectData)

objectData is not need here, use object->parent

`objectData` is not need here, use `object->parent`
DagerD marked this conversation as resolved
@ -66,0 +66,4 @@
bool ret = true;
if (scene_delegate->engine_type == BlenderSceneDelegate::EngineType::VIEWPORT) {
ret = BKE_object_is_visible_in_viewport(scene_delegate->view3d, object);

simplify algorithm, example:

ret = BKE_object_is_visible_in_viewport(scene_delegate->view3d, object) && 
         object->duplicator_visibility_flag & OB_DUPLI_FLAG_VIEWPORT;
simplify algorithm, example: ``` ret = BKE_object_is_visible_in_viewport(scene_delegate->view3d, object) && object->duplicator_visibility_flag & OB_DUPLI_FLAG_VIEWPORT; ```
DagerD marked this conversation as resolved
Georgiy Markelov added 7 commits 2023-05-18 18:36:33 +02:00
Georgiy Markelov added 1 commit 2023-05-18 18:38:36 +02:00
Georgiy Markelov added 2 commits 2023-05-18 18:46:30 +02:00
Georgiy Markelov added 1 commit 2023-05-19 09:42:52 +02:00
Bogdan Nagirniak requested changes 2023-05-19 10:24:16 +02:00
@ -332,2 +325,2 @@
instancers_.erase(id);
}
i_data->update();
i_data->update_visibility();

Checking for object->transflag & OB_DUPLI should be there and we have to remove instancer

Checking for `object->transflag & OB_DUPLI` should be there and we have to remove instancer
@ -488,2 +477,2 @@
for (auto it = instancers_.begin(); it != instancers_.end(); ++it) {
if (available_objects.find(it->first.GetName()) != available_objects.end()) {
auto it_inst = instancers_.begin();
while (it_inst != instancers_.end()) {

I think this code has to be reverted back. New implementation is suspicious

I think this code has to be reverted back. New implementation is suspicious
@ -86,0 +91,4 @@
bool ret = true;
if (object->transflag & OB_DUPLI) {
int flag = scene_delegate->engine_type == BlenderSceneDelegate::EngineType::VIEWPORT ?

Use DEG_get_mode(scene_delegate_->depsgraph) instead EngineType

Use `DEG_get_mode(scene_delegate_->depsgraph)` instead `EngineType`
@ -86,0 +116,4 @@
bool InstancerData::update_instances_visibility()
{
bool prev_visible = instances_visible;

remove extra line

remove extra line
@ -86,0 +117,4 @@
{
bool prev_visible = instances_visible;
instances_visible = (BKE_object_visibility((Object *)id,

braces ?

braces ?
@ -66,2 +71,4 @@
}
}
if (scene_delegate->engine_type == BlenderSceneDelegate::EngineType::FINAL) {

else ?

`else` ?
Georgiy Markelov added 2 commits 2023-05-19 11:35:16 +02:00
Georgiy Markelov added 1 commit 2023-05-19 14:31:14 +02:00
Georgiy Markelov added 1 commit 2023-05-19 14:32:07 +02:00

Implementation moved to #43

Implementation moved to https://projects.blender.org/BogdanNagirniak/blender/pulls/43
Bogdan Nagirniak closed this pull request 2023-05-22 10:46:20 +02:00

Pull request closed

Sign in to join this conversation.
No Label
No Milestone
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: BogdanNagirniak/blender#40
No description provided.