Skip to content

Commit

Permalink
Merge pull request #4 from AIGODLIKE/fix-scene-node-tree-is-none
Browse files Browse the repository at this point in the history
Fix scene node tree is none
  • Loading branch information
xmx-emm authored Jun 12, 2024
2 parents 4a5efe3 + 94e19e4 commit 64c278d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion blender_manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ schema_version = "1.0.0"
# Example of manifest file for a Blender extension
# Change the values according to your extension
id = "hdr_rotation"
version = "1.0.2"
version = "1.0.3"
name = "Hdr Rotation"
tagline = "Rotation HDR by Shift+Right Drag in 3D View"
maintainer = "AIGODLIKE Community, 小萌新"
Expand Down
14 changes: 11 additions & 3 deletions ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@ def __init__(self):

self.start_rotation_angle = None
self.start_x = None
self.nodes = get_node(node_tree=bpy.context.scene.world.node_tree)
self.is_rotation_hdr = self.shading.type in {'MATERIAL', 'RENDERED'}
self.use_scene_world = is_material or is_rendered

self.inputs_list = []
self.vector_list = []
self.rotation = None # 调用的旋转方法,用于替换执行方法优化性能

if bpy.context.scene.world is not None:
self.nodes = get_node(node_tree=bpy.context.scene.world.node_tree)
else:
self.nodes = None

def init_node(self, context):
for node in context.scene.world.node_tree.nodes:
if node.type == 'GROUP':
Expand All @@ -73,9 +77,13 @@ def invoke(self, context, event):
# mouse over model
return {'FINISHED', 'PASS_THROUGH'}
if self.use_scene_world:
if len(self.nodes) == 0:
self.report({'WARNING'}, "World Environment Not Mapping Node,Please add a Mapping node")
if self.nodes is None:
self.report({'WARNING'}, "No World, Please add a World")
return {'FINISHED', 'PASS_THROUGH'}
elif len(self.nodes) == 0:
self.report({'WARNING'}, "World Environment Not Mapping Node, Please add a Mapping node")
return {'FINISHED', 'PASS_THROUGH'}

self.init_node(context)
self.rotation = self.rotation_scene_world_shader
self.start_rotation_angle = degrees(self.get_init_node_rotation())
Expand Down

0 comments on commit 64c278d

Please sign in to comment.