| 53 | } |
| 54 | |
| 55 | void SBinocVisibleObj::Update() |
| 56 | { |
| 57 | m_flags.set(flVisObjNotValid, TRUE); |
| 58 | if (m_visible_time > Device.dwTimeGlobal) |
| 59 | return; |
| 60 | |
| 61 | Fbox b = m_object->Visual()->getVisData().box; |
| 62 | |
| 63 | Fmatrix xform; |
| 64 | xform.mul(Device.mFullTransform, m_object->XFORM()); |
| 65 | Fvector2 mn = {flt_max, flt_max}, mx = {flt_min, flt_min}; |
| 66 | |
| 67 | for (u32 k = 0; k < 8; ++k) |
| 68 | { |
| 69 | Fvector p; |
| 70 | b.getpoint(k, p); |
| 71 | xform.transform(p); |
| 72 | mn.x = _min(mn.x, p.x); |
| 73 | mn.y = _min(mn.y, p.y); |
| 74 | mx.x = _max(mx.x, p.x); |
| 75 | mx.y = _max(mx.y, p.y); |
| 76 | } |
| 77 | static Frect screen_rect = {-1.0f, -1.0f, 1.0f, 1.0f}; |
| 78 | |
| 79 | Frect new_rect; |
| 80 | new_rect.lt = mn; |
| 81 | new_rect.rb = mx; |
| 82 | |
| 83 | if (FALSE == screen_rect.intersected(new_rect)) |
| 84 | return; |
| 85 | if (new_rect.in(screen_rect.lt) && new_rect.in(screen_rect.rb)) |
| 86 | return; |
| 87 | |
| 88 | std::swap(mn.y, mx.y); |
| 89 | mn.x = (1.f + mn.x) / 2.f * UI_BASE_WIDTH; |
| 90 | mx.x = (1.f + mx.x) / 2.f * UI_BASE_WIDTH; |
| 91 | mn.y = (1.f - mn.y) / 2.f * UI_BASE_HEIGHT; |
| 92 | mx.y = (1.f - mx.y) / 2.f * UI_BASE_HEIGHT; |
| 93 | |
| 94 | if (m_flags.is(flTargetLocked)) |
| 95 | { |
| 96 | cur_rect.lt.set(mn); |
| 97 | cur_rect.rb.set(mx); |
| 98 | } |
| 99 | else |
| 100 | { |
| 101 | cur_rect.lt.x += (mn.x - cur_rect.lt.x) * m_upd_speed * Device.fTimeDelta; |
| 102 | cur_rect.lt.y += (mn.y - cur_rect.lt.y) * m_upd_speed * Device.fTimeDelta; |
| 103 | cur_rect.rb.x += (mx.x - cur_rect.rb.x) * m_upd_speed * Device.fTimeDelta; |
| 104 | cur_rect.rb.y += (mx.y - cur_rect.rb.y) * m_upd_speed * Device.fTimeDelta; |
| 105 | if (mn.similar(cur_rect.lt, 2.f) && mx.similar(cur_rect.rb, 2.f)) |
| 106 | { |
| 107 | // target locked |
| 108 | m_flags.set(flTargetLocked, TRUE); |
| 109 | u32 clr = subst_alpha(m_lt.GetColor(), 255); |
| 110 | |
| 111 | if (auto* pActor = Actor()) |
| 112 | { |
nothing calls this directly
no test coverage detected