mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Fixed door / window preview and made preview of other objects not rotate with wall
This commit is contained in:
committed by
Ryan Schultz
parent
fcf6956a3c
commit
05412878d8
@@ -531,6 +531,7 @@ def get_generic_product_preview_data(context, relating_type):
|
||||
snap_obj = bpy.data.objects.get(snap_prop.snap_object)
|
||||
snap_element = tool.Ifc.get_entity(snap_obj)
|
||||
rot_mat = Quaternion()
|
||||
invert_x = False
|
||||
if relating_type.is_a() in ["IfcDoorType", "IfcWindowType"] and snap_element and snap_element.is_a("IfcWall"):
|
||||
layers = tool.Model.get_material_layer_parameters(snap_element)
|
||||
axes = tool.Model.get_wall_axis(snap_obj, layers=layers)
|
||||
@@ -544,6 +545,7 @@ def get_generic_product_preview_data(context, relating_type):
|
||||
else:
|
||||
# mouse is snapped to the side axis, the preview is inverted, rotate it now and correct x position later
|
||||
rot_mat = snap_obj.matrix_world.to_quaternion() @ Quaternion(Vector((0, 0, 1)), radians(180))
|
||||
invert_x = True
|
||||
|
||||
mouse_point.z = snap_obj.matrix_world.translation.z
|
||||
|
||||
@@ -551,7 +553,13 @@ def get_generic_product_preview_data(context, relating_type):
|
||||
if obj_type.data:
|
||||
data = ItemDecorator.get_obj_data(obj_type)
|
||||
data["verts"] = [tuple(obj_type.matrix_world.inverted() @ Vector(v)) for v in data["verts"]]
|
||||
data["verts"] = [tuple(rot_mat @ (Vector((v[0], v[1], (v[2] + rl)))) + mouse_point) for v in data["verts"]]
|
||||
offset_x = 0
|
||||
if invert_x:
|
||||
# correct the x position so that the inverted object occupies the same x extents
|
||||
min_x = min([p[0] for p in data["verts"]])
|
||||
max_x = max([p[0] for p in data["verts"]])
|
||||
offset_x = max_x + min_x
|
||||
data["verts"] = [tuple(rot_mat @ (Vector((v[0], v[1], (v[2] + rl)))) + mouse_point - Vector((offset_x, 0, 0))) for v in data["verts"]]
|
||||
|
||||
return data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user