From badd8699ab69117fbdec9041fc799701111cd6ee Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Wed, 29 Mar 2023 21:06:33 +0200 Subject: [PATCH] Sun Position: Cleanup: simplify the Sun Properties, get rid of TAzEl The TAzEl class used to store a set of Time, Azimuth, Elevation properties, and was used for the sunrise and sunset. But these don't actually need to store azimuth and elevation, so they can be simplified and the entire class can be removed. --- sun_position/__init__.py | 2 +- sun_position/properties.py | 4 ++-- sun_position/sun_calc.py | 22 +++++++--------------- sun_position/ui_sun.py | 4 ++-- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/sun_position/__init__.py b/sun_position/__init__.py index ed0242ca..73a849cd 100644 --- a/sun_position/__init__.py +++ b/sun_position/__init__.py @@ -16,7 +16,7 @@ bl_info = { "name": "Sun Position", "author": "Michael Martin, Damien Picard", - "version": (3, 3, 2), + "version": (3, 3, 3), "blender": (3, 0, 0), "location": "World > Sun Position", "description": "Show sun position with objects and/or sky texture", diff --git a/sun_position/properties.py b/sun_position/properties.py index 673845df..11fe20e4 100644 --- a/sun_position/properties.py +++ b/sun_position/properties.py @@ -86,14 +86,14 @@ class SunPosProperties(PropertyGroup): description="Time at which the Sun rises", soft_min=0.0, soft_max=24.0, default=0.0, - get=lambda _: sun.sunrise.time) + get=lambda _: sun.sunrise) sunset_time: FloatProperty( name="Sunset Time", description="Time at which the Sun sets", soft_min=0.0, soft_max=24.0, default=0.0, - get=lambda _: sun.sunset.time) + get=lambda _: sun.sunset) sun_azimuth: FloatProperty( name="Sun Azimuth", diff --git a/sun_position/sun_calc.py b/sun_position/sun_calc.py index 47d289d5..85550b7a 100644 --- a/sun_position/sun_calc.py +++ b/sun_position/sun_calc.py @@ -16,21 +16,14 @@ class SunInfo: """ Store intermediate sun calculations """ - class TAzEl: - time = 0.0 - azimuth = 0.0 - elevation = 0.0 - class CLAMP: + class SunBind: azimuth = 0.0 elevation = 0.0 az_start_sun = 0.0 az_start_env = 0.0 - sunrise = TAzEl() - sunset = TAzEl() - - bind = CLAMP() + bind = SunBind() bind_to_sun = False latitude = 0.0 @@ -38,6 +31,9 @@ class SunInfo: elevation = 0.0 azimuth = 0.0 + sunrise = 0.0 + sunset = 0.0 + month = 0 day = 0 year = 0 @@ -459,13 +455,9 @@ def calc_sunrise_sunset(rise): tl = time_local / 60.0 tl %= 24.0 if rise: - sun.sunrise.time = tl - sun.sunrise.azimuth = azimuth - sun.sunrise.elevation = elevation + sun.sunrise = tl else: - sun.sunset.time = tl - sun.sunset.azimuth = azimuth - sun.sunset.elevation = elevation + sun.sunset = tl def julian_time_from_y2k(utc_time, year, month, day): diff --git a/sun_position/ui_sun.py b/sun_position/ui_sun.py index 29e0e3d3..e8a0f31c 100644 --- a/sun_position/ui_sun.py +++ b/sun_position/ui_sun.py @@ -287,8 +287,8 @@ class SUNPOS_PT_Time(bpy.types.Panel): col = flow.column(align=True) col.alignment = 'CENTER' if p.show_rise_set: - sr = format_hms(sun.sunrise.time) - ss = format_hms(sun.sunset.time) + sr = format_hms(sun.sunrise) + ss = format_hms(sun.sunset) split = col.split(factor=0.5, align=True) split.label(text="Sunrise:", icon='LIGHT_SUN') -- 2.11.4.GIT