[Bf-extensions-cvs] [b52e7760] master: sun_position: fix errors when selecting wrong types of node
Damien Picard
noreply at git.blender.org
Wed Dec 4 12:08:29 CET 2019
Commit: b52e7760ff6ccbcca73d2bbccc77f70ca2eaf98f
Author: Damien Picard
Date: Wed Dec 4 12:02:33 2019 +0100
Branches: master
https://developer.blender.org/rBACb52e7760ff6ccbcca73d2bbccc77f70ca2eaf98f
sun_position: fix errors when selecting wrong types of node
===================================================================
M sun_position/hdr.py
M sun_position/sun_calc.py
===================================================================
diff --git a/sun_position/hdr.py b/sun_position/hdr.py
index ceff0411..257daf58 100644
--- a/sun_position/hdr.py
+++ b/sun_position/hdr.py
@@ -57,8 +57,8 @@ void main()
def draw_callback_px(self, context):
- nt = bpy.context.scene.world.node_tree.nodes
- env_tex_node = nt.get(bpy.context.scene.sun_pos_properties.hdr_texture)
+ nt = context.scene.world.node_tree.nodes
+ env_tex_node = nt.get(context.scene.sun_pos_properties.hdr_texture)
image = env_tex_node.image
if self.area != context.area:
@@ -121,6 +121,11 @@ class SUNPOS_OT_ShowHdr(bpy.types.Operator):
exposure = 1.0
+ @classmethod
+ def poll(self, context):
+ sun_props = context.scene.sun_pos_properties
+ return sun_props.hdr_texture and sun_props.sun_object is not None
+
def update(self, context, event):
sun_props = context.scene.sun_pos_properties
mouse_position_abs = Vector((event.mouse_x, event.mouse_y))
@@ -276,6 +281,12 @@ class SUNPOS_OT_ShowHdr(bpy.types.Operator):
self.report({'ERROR'}, 'Could not find 3D View')
return {'CANCELLED'}
+ nt = context.scene.world.node_tree.nodes
+ env_tex_node = nt.get(context.scene.sun_pos_properties.hdr_texture)
+ if env_tex_node.type != "TEX_ENVIRONMENT":
+ self.report({'ERROR'}, 'Please select an Environment Texture node')
+ return {'CANCELLED'}
+
self.area = context.area
self.mouse_position = event.mouse_region_x, event.mouse_region_y
diff --git a/sun_position/sun_calc.py b/sun_position/sun_calc.py
index e23abb66..0813fd12 100644
--- a/sun_position/sun_calc.py
+++ b/sun_position/sun_calc.py
@@ -155,7 +155,7 @@ def move_sun(context):
if sun_props.use_sky_texture and sun_props.sky_texture:
sky_node = bpy.context.scene.world.node_tree.nodes.get(sun_props.sky_texture)
- if sky_node is not None:
+ if sky_node is not None and sky_node.type == "TEX_SKY":
locX = math.sin(sun.phi) * math.sin(-sun.theta)
locY = math.sin(sun.theta) * math.cos(sun.phi)
locZ = math.cos(sun.theta)
More information about the Bf-extensions-cvs
mailing list