Page MenuHome

Asset Browser: Allow World assets to be drag/dropped onto viewport
ClosedPublic

Authored by Jesse Yurkovich (deadpin) on Sep 20 2021, 6:07 AM.

Details

Summary

This follows the guidance in T90747 for setting up the drag/drop area
and updating the scene.

Tested by dragging/dropping several different Environment assets onto
the viewport while Cycles rendered mode was active.

Diff Detail

Repository
rB Blender
Branch
fixT90747-asset_world (branched from master)
Build Status
Buildable 17177
Build 17177: arc lint + arc unit

Event Timeline

Jesse Yurkovich (deadpin) requested review of this revision.Sep 20 2021, 6:07 AM
Jesse Yurkovich (deadpin) created this revision.
Jesse Yurkovich (deadpin) added inline comments.
source/blender/editors/space_view3d/view3d_edit.c
4886

I'm unsure if this naked assignment is correct.

Thanks for the patch!

Implementation looks straight forward.
I added @Julian Eisel (Severin) as reviewer as he is more familiar with UI related considerations.

I have been noted that you should not use Fix... in the title when adding new functionality, only when solving bugs. (I also did this in the past). You should use the area where the change is in. For here I would use Asset Browser: ...

source/blender/editors/space_view3d/view3d_edit.c
4886

Seems ok, RNA doesn't have additional logic for world.

4903

Would be more specific on the name and consistent with the other drop operations.
VIEW3DOT_drop_named_world.

Same for name + description.

Note that you're not changing the world of the 3d view, but of the scene.

Jesse Yurkovich (deadpin) retitled this revision from Fix T90747: Allow World assets to be drag/dropped onto viewport to Asset Browser: Allow World assets to be drag/dropped onto viewport.Sep 20 2021, 11:38 AM
  • Feedback from review
Jesse Yurkovich (deadpin) marked 2 inline comments as done.Sep 20 2021, 11:39 AM
Julian Eisel (Severin) requested changes to this revision.Sep 20 2021, 12:10 PM

Mostly good, just some smaller changes needed.

source/blender/editors/space_view3d/view3d_edit.c
4892

Think this is the only notifier that's needed, I wouldn't send the other ones. But make this take the scene, not the world.

4915

Use OPTYPE_UNDO | OPTYPE_INTERNAL here.

This revision now requires changes to proceed.Sep 20 2021, 12:10 PM
  • Support undo and reduce notifications

Ah, indeed, undo support. Undo seems to work well and I was able to remove 1 of the notifications. I needed to keep 2 of them though:

source/blender/editors/space_view3d/view3d_edit.c
4892

The NC_SPACE | ND_SPACE_VIEW3D notification is still needed if you drop a World while in Eevee rendered or material preview mode. Without it you have to move the viewport in order to see the change.

Jesse Yurkovich (deadpin) marked an inline comment as not done.Sep 21 2021, 5:56 AM
source/blender/editors/space_view3d/view3d_edit.c
4892

In that case it's better to make sure the 3D View updates correctly for NC_SCENE | ND_WORLD. This if block probably needs correction: https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/space_view3d/space_view3d.c$1559-1561

The design idea behind notifiers is that a notifier is sent indicating what changed, and editors can respond with a redraw if they care about this change. By sending a specific space notifier it's basically the wrong way around: the data change explicitly says which editor should redraw. So space notifiers should only be sent if the actual space data changed.
It's not so important in practice and we're sloppy at times. Still good to follow these core design ideas.

  • Remove another notification

Alright, this version now uses just 1 notification and has things respond appropriately.

The only drawback is that this is now the 3rd instance of the use_scene_world logic I could find in the codebase.

A separate cleanup patch could possible look like the following (had difficulty knowing where to place the common methods): P2429

Great!
P2429 looks like a good thing to do, could you create a separate patch for this, tagging the EEVEE & Viewport module?

This revision is now accepted and ready to land.Sep 27 2021, 4:02 PM