diff --git a/blender_manifest.toml b/blender_manifest.toml index 80f9faa..113b853 100644 --- a/blender_manifest.toml +++ b/blender_manifest.toml @@ -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, 小萌新" diff --git a/ops.py b/ops.py index 1d446cb..7f9fe9d 100644 --- a/ops.py +++ b/ops.py @@ -45,7 +45,6 @@ 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 @@ -53,6 +52,11 @@ def __init__(self): 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': @@ -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())