diff options
author | Damien Picard <dam.pic@free.fr> | 2019-12-13 19:11:26 +0300 |
---|---|---|
committer | Damien Picard <dam.pic@free.fr> | 2019-12-13 19:11:26 +0300 |
commit | 13b7618409aac26eb512133373828ab9e92a6ac7 (patch) | |
tree | 196f6ee8714012f82c80e9cee80fab3eada77036 /sun_position | |
parent | 180b77ffa0800fcf7e20cd4403473cb63ceae3b0 (diff) |
sun_position: remove redundant use_* props
Diffstat (limited to 'sun_position')
-rw-r--r-- | sun_position/__init__.py | 4 | ||||
-rw-r--r-- | sun_position/properties.py | 32 | ||||
-rw-r--r-- | sun_position/sun_calc.py | 9 | ||||
-rw-r--r-- | sun_position/ui_sun.py | 39 |
4 files changed, 24 insertions, 60 deletions
diff --git a/sun_position/__init__.py b/sun_position/__init__.py index 5c9c35b7..cca1bc21 100644 --- a/sun_position/__init__.py +++ b/sun_position/__init__.py @@ -65,7 +65,7 @@ def register(): bpy.utils.register_class(ui_sun.SUNPOS_OT_DefaultPresets) bpy.utils.register_class(ui_sun.SUNPOS_MT_Presets) bpy.utils.register_class(ui_sun.SUNPOS_PT_Panel) - bpy.utils.register_class(ui_sun.SUNPOS_PT_Position) + bpy.utils.register_class(ui_sun.SUNPOS_PT_Location) bpy.utils.register_class(ui_sun.SUNPOS_PT_Time) bpy.utils.register_class(hdr.SUNPOS_OT_ShowHdr) @@ -75,7 +75,7 @@ def register(): def unregister(): bpy.utils.unregister_class(hdr.SUNPOS_OT_ShowHdr) bpy.utils.unregister_class(ui_sun.SUNPOS_PT_Panel) - bpy.utils.unregister_class(ui_sun.SUNPOS_PT_Position) + bpy.utils.unregister_class(ui_sun.SUNPOS_PT_Location) bpy.utils.unregister_class(ui_sun.SUNPOS_PT_Time) bpy.utils.unregister_class(ui_sun.SUNPOS_MT_Presets) bpy.utils.unregister_class(ui_sun.SUNPOS_OT_DefaultPresets) diff --git a/sun_position/properties.py b/sun_position/properties.py index f20991f1..945bdebf 100644 --- a/sun_position/properties.py +++ b/sun_position/properties.py @@ -137,25 +137,15 @@ class SunPosProperties(PropertyGroup): min=0.0, soft_max=3000.0, step=10.0, default=50.0, update=sun_update) - use_sun_object: BoolProperty( - name="Use object", - description="Enable sun positioning of light object", - default=False, - update=sun_update) - sun_object: PointerProperty( + name="Sun Object", type=bpy.types.Object, description="Sun object to set in the scene", poll=lambda self, obj: obj.type == 'LIGHT', update=sun_update) - use_object_collection: BoolProperty( - name="Use collection", - description="Allow a collection of objects to be positioned", - default=False, - update=sun_update) - object_collection: PointerProperty( + name="Collection", type=bpy.types.Collection, description="Collection of objects used to visualize sun motion", update=sun_update) @@ -170,17 +160,9 @@ class SunPosProperties(PropertyGroup): default='ANALEMMA', update=sun_update) - use_sky_texture: BoolProperty( - name="Use sky texture", - description="Enable use of Cycles' " - "sky texture. World nodes must be enabled, " - "then set color to Sky Texture", - default=False, - update=sun_update) - sky_texture: StringProperty( - default="Sky Texture", name="Sky Texture", + default="Sky Texture", description="Name of sky texture to be used", update=sun_update) @@ -233,12 +215,6 @@ class SunPosAddonPreferences(AddonPreferences): description="Show time/place presets", default=False) - show_object_collection: BoolProperty( - name="Collection", - description="Show object collection", - default=True, - update=sun_update) - show_dms: BoolProperty( name="D° M' S\"", description="Show lat/long degrees, minutes, seconds labels", @@ -278,7 +254,7 @@ class SunPosAddonPreferences(AddonPreferences): box = layout.box() col = box.column() - col.label(text="Show or use:") + col.label(text="Show options or labels:") flow = col.grid_flow(columns=0, even_columns=True, even_rows=False, align=False) flow.prop(self, "show_time_place") flow.prop(self, "show_object_collection") diff --git a/sun_position/sun_calc.py b/sun_position/sun_calc.py index 78e9ff85..8d56853d 100644 --- a/sun_position/sun_calc.py +++ b/sun_position/sun_calc.py @@ -153,7 +153,7 @@ def move_sun(context): north_offset, zone, sun_props.month, sun_props.day, sun_props.year, sun_props.sun_distance) - if sun_props.use_sky_texture and sun_props.sky_texture: + if sun_props.sky_texture: sky_node = bpy.context.scene.world.node_tree.nodes.get(sun_props.sky_texture) if sky_node is not None and sky_node.type == "TEX_SKY": locX = math.sin(sun.phi) * math.sin(-sun.theta) @@ -163,8 +163,7 @@ def move_sun(context): sky_node.sun_direction = locX, locY, locZ # Sun object - if ((sun_props.use_sun_object or sun_props.usage_mode == 'HDR') - and sun_props.sun_object + if (sun_props.sun_object is not None and sun_props.sun_object.name in context.view_layer.objects): obj = sun_props.sun_object set_sun_position(obj, sun_props.sun_distance) @@ -173,9 +172,7 @@ def move_sun(context): set_sun_rotations(obj, rotation_euler) # Sun collection - if (addon_prefs.show_object_collection - and sun_props.use_object_collection - and sun_props.object_collection): + if sun_props.object_collection is not None: sun_objects = sun_props.object_collection.objects object_count = len(sun_objects) if sun_props.object_collection_type == 'DIURNAL': diff --git a/sun_position/ui_sun.py b/sun_position/ui_sun.py index e2244201..6dcc0905 100644 --- a/sun_position/ui_sun.py +++ b/sun_position/ui_sun.py @@ -170,36 +170,27 @@ class SUNPOS_PT_Panel(bpy.types.Panel): row.operator(SUNPOS_OT_AddPreset.bl_idname, text="", icon='REMOVE').remove_active = True row.operator(SUNPOS_OT_DefaultPresets.bl_idname, text="", icon='FILE_REFRESH') - flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False) - - col = flow.column(align=True) - col.prop(sp, "use_sun_object") - if sp.use_sun_object: - col.prop(sp, "sun_object", text="") - col.separator() + col = layout.column(align=True) + col.use_property_split = True + col.use_property_decorate = False + col.prop(sp, "sun_object") + col.separator() - col = flow.column(align=True) - if p.show_object_collection: - col.prop(sp, "use_object_collection") - if sp.use_object_collection: - col.prop(sp, "object_collection", text="") - if sp.object_collection: - col.prop(sp, "object_collection_type") - if sp.object_collection_type == 'DIURNAL': - col.prop(sp, "time_spread") - col.separator() + col.prop(sp, "object_collection") + if sp.object_collection: + col.prop(sp, "object_collection_type") + if sp.object_collection_type == 'DIURNAL': + col.prop(sp, "time_spread") + col.separator() - col = flow.column(align=True) - col.prop(sp, "use_sky_texture") - if sp.use_sky_texture: - col.prop_search(sp, "sky_texture", context.scene.world.node_tree, - "nodes", text="") + col.prop_search(sp, "sky_texture", context.scene.world.node_tree, + "nodes") -class SUNPOS_PT_Position(bpy.types.Panel): +class SUNPOS_PT_Location(bpy.types.Panel): bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "world" - bl_label = "Position" + bl_label = "Location" bl_parent_id = "SUNPOS_PT_Panel" @classmethod |