Skip to content

Commit

Permalink
[Fixed][Render 3D] Rotation/offset for highlighted bottom components
Browse files Browse the repository at this point in the history
Fixes #659
  • Loading branch information
set-soft committed Sep 12, 2024
1 parent f4f8a85 commit 6472dc0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update XML: `check_pcb_parity` not usable for KiCad 8, must use the `drc`
preflight (#633)
- PCB Print: %ln and %ll substitution when using `repeat_for_layer` option
- Render_3D: bottom side components that doesn't rotate from its center got
displaced highlight (#659)
- QR Lib output and various preflights: might remove DRC exclusions. This is
a KiCad bug that we must workaround (#653)
- 3D outputs: temporal .kicad_dru file not removed (#655)
Expand Down
2 changes: 2 additions & 0 deletions docs/source/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ Fixed:
``drc`` preflight (#633)
- PCB Print: %ln and %ll substitution when using ``repeat_for_layer``
option
- Render_3D: bottom side components that doesn’t rotate from its center
got displaced highlight (#659)
- QR Lib output and various preflights: might remove DRC exclusions.
This is a KiCad bug that we must workaround (#653)
- 3D outputs: temporal .kicad_dru file not removed (#655)
Expand Down
6 changes: 5 additions & 1 deletion kibot/out_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ def highlight_3D_models(self, board, highlight):
models = m.Models()
m_pos = m.GetPosition()
rot = m.GetOrientationDegrees()
if m.IsFlipped():
rot = 180-rot
# Measure the courtyard
bbox = self.get_crtyd_bbox(board, m)
if bbox.x1 is not None:
Expand All @@ -773,7 +775,7 @@ def highlight_3D_models(self, board, highlight):
if extra_debug:
logger.debug(f'Highlight for {ref}')
logger.debug(f' - Position {ToMM(m_pos.x)}, {ToMM(m_pos.y)}')
logger.debug(f' - Orientation {rot}')
logger.debug(f' - Orientation {rot} (Flipped: {m.IsFlipped()})')
logger.debug(f' - Center {ToMM(m_cen.x)} {ToMM(m_cen.y)}')
logger.debug(f' - w,h {ToMM(w)}, {ToMM(h)}')
# Compute the offset
Expand All @@ -782,6 +784,8 @@ def highlight_3D_models(self, board, highlight):
rrot = math.radians(rot)
# KiCad coordinates are inverted in the Y axis
off_y = -off_y
if m.IsFlipped():
off_x = -off_x
# Apply the component rotation
off_xp = off_x*math.cos(rrot)+off_y*math.sin(rrot)
off_yp = -off_x*math.sin(rrot)+off_y*math.cos(rrot)
Expand Down

0 comments on commit 6472dc0

Please sign in to comment.