Added option for wall_from_to_points not round the length and angle.

This function was hard coded to round length angle, now it has an option.
I assume it was originally built like this because it was supposed to
work only with Grease Pencil.
This commit is contained in:
Bruno Perdigão
2024-08-25 19:07:50 -03:00
parent be9719f5ca
commit 51018177cd
+9 -7
View File
@@ -700,7 +700,7 @@ class DumbWallGenerator:
for stroke in layer.active_frame.strokes:
if len(stroke.points) == 1:
continue
data = self.create_wall_from_2_points((stroke.points[0].co, stroke.points[-1].co))
data = self.create_wall_from_2_points((stroke.points[0].co, stroke.points[-1].co), round=True)
if data:
strokes.append(data)
objs.append(data["obj"])
@@ -725,19 +725,21 @@ class DumbWallGenerator:
bpy.context.scene.grease_pencil.layers.remove(layer)
return objs
def create_wall_from_2_points(self, coords):
def create_wall_from_2_points(self, coords, round=False):
direction = coords[1] - coords[0]
length = direction.length
if length < 0.1:
return
data = {"coords": coords}
# Round to nearest 50mm (yes, metric for now)
self.length = 0.05 * round(length / 0.05)
self.length = length
self.rotation = math.atan2(direction[1], direction[0])
# Round to nearest 5 degrees
nearest_degree = (math.pi / 180) * 5
self.rotation = nearest_degree * round(self.rotation / nearest_degree)
if round:
# Round to nearest 50mm (yes, metric for now)
self.length = 0.05 * round(length / 0.05)
# Round to nearest 5 degrees
nearest_degree = (math.pi / 180) * 5
self.rotation = nearest_degree * round(self.rotation / nearest_degree)
self.location = coords[0]
data["obj"] = self.create_wall()
return data