Skip to content

Commit

Permalink
fix: fix circular array empty rotation in single-object mode and tidy…
Browse files Browse the repository at this point in the history
… up operator
  • Loading branch information
tristan-hm committed Mar 15, 2024
1 parent 1076273 commit e39bfc1
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions replicate/circular_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ND_OT_circular_array(BaseOperator):
bl_idname = "nd.circular_array"
bl_label = "Circular Array"
bl_description = """Array an object around another in a circular fashion
ALT — Use faux origin translation (for origin-reliant geometry)
ALT — Use faux origin (for origin-reliant procedural geometry)
CTRL — Remove existing modifiers"""


Expand Down Expand Up @@ -208,19 +208,17 @@ def prepare_new_operator(self, context):

self.rotator_obj = bpy.data.objects.new("empty", None)
self.rotator_obj.name = "ND — Circular Array Rotator"
bpy.context.scene.collection.objects.link(self.rotator_obj)
self.rotator_obj.empty_display_size = 1
self.rotator_obj.empty_display_type = 'PLAIN_AXES'

bpy.context.scene.collection.objects.link(self.rotator_obj)

if self.single_obj_mode or self.faux_origin:
self.rotator_obj.location = (0, 0, 0)
else:
self.rotator_obj.location = self.target_obj.location.copy()

self.rotator_obj.rotation_euler = self.reference_obj.rotation_euler.copy()
self.rotator_obj_rotation_snapshot = self.reference_obj.rotation_euler.copy()
bpy.data.objects[self.reference_obj.name]["NDCA_rotator_obj_rotation_snapshot"] = self.rotator_obj_rotation_snapshot

self.rotator_obj.rotation_euler = (0, 0, 0)
self.rotator_obj.scale = (1, 1, 1)

self.rotator_obj.parent = self.reference_obj
Expand Down Expand Up @@ -256,7 +254,6 @@ def summon_old_operator(self, context, mods):
self.displace_axis = self.displace_axis_prev = ['X', 'Y', 'Z'].index(self.displace.direction)
self.count = self.count_prev = self.array.count
self.offset = self.offset_prev = self.displace.strength
self.rotator_obj_rotation_snapshot = bpy.data.objects[self.reference_obj.name]["NDCA_rotator_obj_rotation_snapshot"]


def add_array_modifier(self):
Expand Down Expand Up @@ -299,7 +296,7 @@ def operate(self, context):
rotation = radians(self.angle / altered_count)
rotation_axis = ['X', 'Y', 'Z'][self.axis]

self.rotator_obj.rotation_euler = self.rotator_obj_rotation_snapshot
self.rotator_obj.rotation_euler = (0, 0, 0)
self.rotator_obj.rotation_euler.rotate_axis(rotation_axis, rotation)

self.array.count = self.count
Expand Down Expand Up @@ -339,6 +336,7 @@ def revert(self, context):
self.axis = self.axis_prev
self.count = self.count_prev
self.offset = self.offset_prev
self.displace_axis = self.displace_axis_prev

self.operate(context)

Expand Down

0 comments on commit e39bfc1

Please sign in to comment.