mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 13:52:23 +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
72ab701f30
commit
09d5de5ca2
@@ -531,6 +531,7 @@ def get_generic_product_preview_data(context, relating_type):
|
|||||||
snap_obj = bpy.data.objects.get(snap_prop.snap_object)
|
snap_obj = bpy.data.objects.get(snap_prop.snap_object)
|
||||||
snap_element = tool.Ifc.get_entity(snap_obj)
|
snap_element = tool.Ifc.get_entity(snap_obj)
|
||||||
rot_mat = Quaternion()
|
rot_mat = Quaternion()
|
||||||
|
invert_x = False
|
||||||
if relating_type.is_a() in ["IfcDoorType", "IfcWindowType"] and snap_element and snap_element.is_a("IfcWall"):
|
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)
|
layers = tool.Model.get_material_layer_parameters(snap_element)
|
||||||
axes = tool.Model.get_wall_axis(snap_obj, layers=layers)
|
axes = tool.Model.get_wall_axis(snap_obj, layers=layers)
|
||||||
@@ -544,6 +545,7 @@ def get_generic_product_preview_data(context, relating_type):
|
|||||||
else:
|
else:
|
||||||
# mouse is snapped to the side axis, the preview is inverted, rotate it now and correct x position later
|
# 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))
|
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
|
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:
|
if obj_type.data:
|
||||||
data = ItemDecorator.get_obj_data(obj_type)
|
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(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
|
return data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user