From c09fc5e528e62f1b6399748d7ac9f0b6fb4cdb35 Mon Sep 17 00:00:00 2001 From: Ryan Inch Date: Tue, 15 Oct 2024 05:12:07 -0400 Subject: [PATCH 1/2] Fix setting up the camera for reflection probe baking in Blender 4.2 Blender has re-arranged it's Cycles API so that the panorama settings that were previously stored on the `cycles` property of the camera data are now stored directly on the camera data. The root of the panorama settings is now abstracted into a variable so that the panorama settings can be accessed from Blender 4.2 while maintaining backward compatibility with previous versions. --- .../components/definitions/reflection_probe.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/io_hubs_addon/components/definitions/reflection_probe.py b/addons/io_hubs_addon/components/definitions/reflection_probe.py index e3723c25..88324d1f 100644 --- a/addons/io_hubs_addon/components/definitions/reflection_probe.py +++ b/addons/io_hubs_addon/components/definitions/reflection_probe.py @@ -338,14 +338,15 @@ def restore_render_props(self): def setup_probe_render(self, context): probe = self.probes[self.probe_index] + cycles_settings = self.camera_data.cycles if bpy.app.version < (4, 2, 0) else self.camera_data self.camera_data.type = "PANO" - self.camera_data.cycles.panorama_type = "EQUIRECTANGULAR" + cycles_settings.panorama_type = "EQUIRECTANGULAR" - self.camera_data.cycles.longitude_min = -math.pi - self.camera_data.cycles.longitude_max = math.pi - self.camera_data.cycles.latitude_min = -math.pi / 2 - self.camera_data.cycles.latitude_max = math.pi / 2 + cycles_settings.longitude_min = -math.pi + cycles_settings.longitude_max = math.pi + cycles_settings.latitude_min = -math.pi / 2 + cycles_settings.latitude_max = math.pi / 2 self.camera_data.clip_start = probe.data.clip_start self.camera_data.clip_end = probe.data.clip_end From f54d164ded4a85f4b7fab177818b951c11b2abd7 Mon Sep 17 00:00:00 2001 From: Ryan Inch Date: Tue, 15 Oct 2024 05:16:29 -0400 Subject: [PATCH 2/2] Fix reflection probe image assignment in Blender 4.2 Blender 4.2 no longer allows images (or possibly anything) to be assigned to uninitialized Group IDProperties via key access, e.g. `probe_component['envMapTexture'] = img` isn't allowed anymore. Images are now assigned directly to the property without going through the key, e.g. `probe_component.envMapTexture = img`. Note: `setattr` also works because it also directly assigns without going through the key. --- .../components/definitions/reflection_probe.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/io_hubs_addon/components/definitions/reflection_probe.py b/addons/io_hubs_addon/components/definitions/reflection_probe.py index 88324d1f..d7c4f491 100644 --- a/addons/io_hubs_addon/components/definitions/reflection_probe.py +++ b/addons/io_hubs_addon/components/definitions/reflection_probe.py @@ -294,7 +294,7 @@ def modal(self, context, event): else: update_image_editors(old_img, img) - probe_component['envMapTexture'] = img + probe_component.envMapTexture = img # Pack image and update filepaths so that it displays/unpacks nicely for the user. # Note: updating the filepaths prints an error to the terminal, but otherwise seems to work fine. @@ -449,11 +449,11 @@ def execute(self, context): for probe in probes: if f.name.startswith(f"{probe.name} - EnvMap"): probe_component = probe.hubs_component_reflection_probe - old_img = probe_component['envMapTexture'] + old_img = probe_component.envMapTexture img = bpy.data.images.load( filepath=os.path.join(dirname, f.name)) - probe_component['envMapTexture'] = img + probe_component.envMapTexture = img if old_img: if self.overwrite_images: