diff --git a/CHANGELOG.md b/CHANGELOG.md index c4c617a..6002be8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v0.0.13](https://github.com/chark/blender-skunk/compare/v0.0.12...v0.0.13) - 2024-XX-XX + +### Added + +- Option to choose on which axis to distribute objects on. + +### Changed + +- Default child name suffix from `Child` to `LOD0`. +- Increased min and max sizes when distributing objects. + +### Fixed + +- Collections not being maintained when creating LODs or empty parents. + ## [v0.0.12](https://github.com/chark/blender-skunk/compare/v0.0.11...v0.0.12) - 2024-12-03 ### Added diff --git a/README.md b/README.md index be0a4f2..6b7eebb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Blender Skunk -Blender add-on, which provides a set of tools for bulk 3D model processing. This add-on is designed to be used with how Unity so that LODs are imported automatically (see [Import Mesh with LOD settings](https://docs.unity3d.com/6000.0/Documentation/Manual/importing-lod-meshes.html)). +Blender add-on, which provides a set of tools for bulk 3D model processing. This add-on is designed to be used with Unity, so that LODs are imported automatically (see [Import Mesh with LOD settings](https://docs.unity3d.com/6000.0/Documentation/Manual/importing-lod-meshes.html)).
diff --git a/__init__.py b/__init__.py index fb45928..f6bd27b 100644 --- a/__init__.py +++ b/__init__.py @@ -9,7 +9,7 @@ 'tracker_url': 'https://github.com/chark/blender-skunk', 'doc_url': 'https://github.com/chark/blender-skunk', 'support': 'COMMUNITY', - 'version': (0, 0, 12), + 'version': (0, 0, 13), 'blender': (4, 3, 0), 'category': 'Object', } @@ -23,10 +23,21 @@ class OpDistributeObjects(bpy.types.Operator): distance: bpy.props.IntProperty( name='Distance', - description='Distance between objects on X axis', + description='Distance between objects on selected Axis', default=10, - min=0, - max=100 + min=-1000, + max=1000 + ) + + axis: bpy.props.EnumProperty( + name='Axis', + description='Axis to distribute objects along', + items=[ + ('X', 'X Axis', 'Distribute along the X axis'), + ('Y', 'Y Axis', 'Distribute along the Y axis'), + ('Z', 'Z Axis', 'Distribute along the Z axis'), + ], + default='X' ) def invoke(self, context, event): @@ -50,17 +61,22 @@ def execute(self, context): return {'FINISHED'} - @staticmethod - def distribute_objects(objects, distance=10): - offset_x = 0 + def distribute_objects(self, objects, distance=10): + offset = 0 for object in objects: if object.parent: continue - (object_x, object_y, object_z) = object.location.copy() - object.location = (offset_x, object_y, object_z) - offset_x = offset_x + distance + loc = object.location.copy() + if self.axis == 'X': + object.location = (offset, loc.y, loc.z) + elif self.axis == 'Y': + object.location = (loc.x, offset, loc.z) + elif self.axis == 'Z': + object.location = (loc.x, loc.y, offset) + + offset += distance class OpCreateEmptyParents(bpy.types.Operator): @@ -72,7 +88,7 @@ class OpCreateEmptyParents(bpy.types.Operator): child_name_suffix: bpy.props.StringProperty( name='Child Name Suffix', description='Suffix appended to child names', - default='Child' + default='LOD0' ) def invoke(self, context, event): @@ -108,6 +124,14 @@ def create_empty_parent(object): bpy.ops.object.add(type='EMPTY') parent_object = bpy.context.object + # Clear parent object collections + for collection in parent_object.users_collection: + collection.objects.unlink(parent_object) + + # Move parent to the same collections as child + for collection in object.users_collection: + collection.objects.link(parent_object) + # Move parent object_location = object.location.copy() parent_object.location = object_location @@ -522,7 +546,8 @@ def create_lod(object, lod_index, decimate_ratio): object_copy.data = object.data.copy() object_copy.location = object.location - bpy.context.collection.objects.link(object_copy) + for collection in object.users_collection: + collection.objects.link(object_copy) # Naming if object.name.endswith('_LOD0'):