Skip to content

Commit

Permalink
Fix liniting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
GottfriedHofmann committed Jul 30, 2024
1 parent deda117 commit 6a69cfe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
30 changes: 13 additions & 17 deletions addons/io_hubs_addon/components/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,20 +676,20 @@ class BakeLightmaps(Operator):
bl_description = "Bake lightmaps of selected objects using the Cycles render engine and pack them into the .blend."
bl_options = {'REGISTER', 'UNDO'}

default_intensity: FloatProperty(name="Lightmaps Intensity",
default=3.14,
default_intensity: FloatProperty(name="Lightmaps Intensity",
default=3.14,
description="Multiplier for hubs on how to interpert the brightness of the image. Set this to 1.0 if you have set up the lightmaps manually and use a non-HDR format like png or jpg.")
resolution: IntProperty(name="Lightmaps Resolution",
default=2048,
resolution: IntProperty(name="Lightmaps Resolution",
default=2048,
description="The pixel resoltion of the resulting lightmap.")
samples: IntProperty(name="Max Samples",
default=1024,
samples: IntProperty(name="Max Samples",
default=1024,
description="The number of samples to use for baking. Higher values reduce noise but take longer.")

def execute(self, context):
# Check selected objects
selected_objects = bpy.context.selected_objects

# filter mesh objects and others
mesh_objs, other_objs = [], []
for ob in selected_objects:
Expand All @@ -706,10 +706,6 @@ def execute(self, context):
if len(obj_uv_layers) == 0:
obj_uv_layers.new(name='UV0')
obj_uv_layers.new(name='UV1')
# The first layer is usually used for regular texturing so don't touch it.
# elif obj_uv_layers[0].name != 'UV0':
# # Rename the first UV layer to "UV0"
# obj_uv_layers[0].name = 'UV0'

# In case there is only one UV layer create a second one named "UV1" for the lightmap.
if len(obj_uv_layers) == 1:
Expand Down Expand Up @@ -751,7 +747,7 @@ def execute(self, context):
lightmap_texture_nodes = []
for mat in materials:
mat_nodes = mat.node_tree.nodes
lightmap_nodes = [node for node in mat_nodes if node.bl_idname=='moz_lightmap.node']
lightmap_nodes = [node for node in mat_nodes if node.bl_idname == 'moz_lightmap.node']
if len(lightmap_nodes) > 1:
print("Too many lightmap nodes in node tree of material", mat.name)
elif len(lightmap_nodes) < 1:
Expand Down Expand Up @@ -792,7 +788,7 @@ def execute(self, context):
node.image.save()
node.image.pack()
# Update the filepath so it unpacks nicely for the user.
#TODO: Mechanism taken from reflection_probe.py line 300-306, de-duplicate
# TODO: Mechanism taken from reflection_probe.py line 300-306, de-duplicate
new_filepath = f"//{node.image.name}.hdr"
node.image.packed_files[0].filepath = new_filepath
node.image.filepath_raw = new_filepath
Expand All @@ -803,10 +799,9 @@ def execute(self, context):
os.remove(file_path)

return {'FINISHED'}

def invoke(self, context, event):
if bpy.data.is_saved == False:
#
if bpy.data.is_saved is False:
def draw(self, context):
self.layout.label(
text="You ned to save the .blend file before running this operator.")
Expand All @@ -815,7 +810,7 @@ def draw(self, context):
return {'CANCELLED'}
# needed to get the dialoge with the intensity
return context.window_manager.invoke_props_dialog(self)

def setup_moz_lightmap_nodes(self, node_tree):
''' Returns the lightmap texture node of the newly created setup '''
mat_nodes = node_tree.nodes
Expand All @@ -842,6 +837,7 @@ def setup_moz_lightmap_nodes(self, node_tree):

return lightmap_texture_node


def register():
bpy.utils.register_class(AddHubsComponent)
bpy.utils.register_class(RemoveHubsComponent)
Expand Down
1 change: 1 addition & 0 deletions addons/io_hubs_addon/components/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class HubsObjectPanel(bpy.types.Panel):
def draw(self, context):
draw_components_list(self, context)


class HubsObjectLightmapPanel(bpy.types.Panel):
bl_label = "Hubs Lightmap Baker"
bl_idname = "OBJECT_PT_hubs_lightmap_baker"
Expand Down

0 comments on commit 6a69cfe

Please sign in to comment.