Skip to content

Commit

Permalink
Bump version, tweak distribute function, fix LOD & empty child creati…
Browse files Browse the repository at this point in the history
…on ignoring collections
  • Loading branch information
Edvinas01 committed Dec 10, 2024
1 parent 39941b2 commit e5ed8d8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 13 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)).

<p align="center">
<img src="screenshot.png" />
Expand Down
49 changes: 37 additions & 12 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'):
Expand Down

0 comments on commit e5ed8d8

Please sign in to comment.