Nodes: Remove "Use Nodes" in Shader Editor for World
Part of https://projects.blender.org/blender/blender/pulls/141278 Blend files compatibility: If a World exists and "Use Nodes" is disabled, we add new nodes to the existing node tree (or create one if it doesn't) that emulates the behavior of a world without a node tree. This ensures backward and forward compatibility. Python API compatibility: - `world.use_nodes` was removed from Python API => **Breaking change** - `world.color` is still being used by Workbench, so it stays there, although it has no effect anymore when using Cycles or EEVEE. Python API changes: Creating a World using `bpy.data.worlds.new()` now creates a World with an empty (embedded) node tree. This was necessary to enable Python scripts to add nodes without having to create a node tree (which is currently not possible, because World node trees are embedded). Pull Request: https://projects.blender.org/blender/blender/pulls/142342
This commit is contained in:
@@ -12,20 +12,17 @@ from bpy.app.translations import pgettext_tip as tip_
|
||||
|
||||
|
||||
class CYCLES_OT_use_shading_nodes(Operator):
|
||||
"""Enable nodes on a material, world or light"""
|
||||
"""Enable nodes on a material or light"""
|
||||
bl_idname = "cycles.use_shading_nodes"
|
||||
bl_label = "Use Nodes"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return (getattr(context, "material", False) or getattr(context, "world", False) or
|
||||
getattr(context, "light", False))
|
||||
return (getattr(context, "material", False) or getattr(context, "light", False))
|
||||
|
||||
def execute(self, context):
|
||||
if context.material:
|
||||
context.material.use_nodes = True
|
||||
elif context.world:
|
||||
context.world.use_nodes = True
|
||||
elif context.light:
|
||||
context.light.use_nodes = True
|
||||
|
||||
|
||||
@@ -1456,7 +1456,7 @@ class CYCLES_OBJECT_PT_visibility_culling(CyclesButtonsPanel, Panel):
|
||||
def panel_node_draw(layout, id_data, output_type, input_name):
|
||||
from bpy_extras.node_utils import find_node_input
|
||||
|
||||
if not id_data.use_nodes:
|
||||
if not isinstance(id_data, bpy.types.World) and not id_data.use_nodes:
|
||||
layout.operator("cycles.use_shading_nodes", icon='NODETREE')
|
||||
return False
|
||||
|
||||
|
||||
@@ -1639,9 +1639,7 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
|
||||
unique_ptr<ShaderGraph> graph = make_unique<ShaderGraph>();
|
||||
|
||||
/* create nodes */
|
||||
if (new_viewport_parameters.use_scene_world && b_world && b_world.use_nodes() &&
|
||||
b_world.node_tree())
|
||||
{
|
||||
if (new_viewport_parameters.use_scene_world && b_world && b_world.node_tree()) {
|
||||
BL::ShaderNodeTree b_ntree(b_world.node_tree());
|
||||
|
||||
add_nodes(scene, b_engine, b_data, b_scene, graph.get(), b_ntree);
|
||||
|
||||
Reference in New Issue
Block a user