Skip to content

Commit

Permalink
Fix LOD naming issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Edvinas01 committed Aug 5, 2024
1 parent b09ffec commit 6130e1f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Fixed

- Parenting function not applying child name.
- Parenting function is not applying a child's name.
- Data blocks not being removed when deleting LODs.

## [v0.0.4](https://github.com/chark/blender-skunk/compare/v0.0.3...v0.0.4) - 2024-08-01

Expand Down
20 changes: 20 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class OpCreateUVs(bpy.types.Operator):
min=0.0,
max=1.0
)

# Old approach using lightmap pack - results in iffy UVs which cause leaks
# pack_quality: bpy.props.IntProperty(
# name='Light-map UV Quality',
Expand Down Expand Up @@ -315,6 +316,7 @@ def execute(self, context):

if self.is_delete_old_lods:
self.delete_lods(self.get_valid_objects(objects))
self.delete_unused_data_blocks()

self.create_lods(self.get_valid_objects(objects), self.lod_count, self.decimate_ratio)

Expand Down Expand Up @@ -349,6 +351,24 @@ def delete_lods(objects):
else:
bpy.data.objects.remove(object, do_unlink=True)

@staticmethod
def delete_unused_data_blocks():
for block in bpy.data.meshes:
if block.users == 0:
bpy.data.meshes.remove(block)

for block in bpy.data.materials:
if block.users == 0:
bpy.data.materials.remove(block)

for block in bpy.data.textures:
if block.users == 0:
bpy.data.textures.remove(block)

for block in bpy.data.images:
if block.users == 0:
bpy.data.images.remove(block)

@staticmethod
def create_lods(objects, lod_count, decimate_ratio):
for object in objects:
Expand Down

0 comments on commit 6130e1f

Please sign in to comment.