| 144 | extern ENGINE_API CCustomHUD* g_hud; |
| 145 | |
| 146 | void CDebugRenderer::OnRenderStaticItems() |
| 147 | { |
| 148 | CHUDManager& HUD = *((CHUDManager*)g_hud); |
| 149 | //-- draw text |
| 150 | auto draw_text = [&HUD](const Fvector& position, const shared_str& text, const float& clamp_dist, u32& color) { |
| 151 | if (text.size() && Device.vCameraPosition.distance_to(position) < clamp_dist) |
| 152 | { |
| 153 | Fvector4 v_res; |
| 154 | Device.mFullTransform.transform(v_res, position); |
| 155 | if (v_res.z < 0 || v_res.w < 0) |
| 156 | return; |
| 157 | if (v_res.x < -1.f || v_res.x > 1.f || v_res.y < -1.f || v_res.y > 1.f) |
| 158 | return; |
| 159 | float x = (1.f + v_res.x) / 2.f * (Device.dwWidth); |
| 160 | float y = (1.f - v_res.y) / 2.f * (Device.dwHeight); |
| 161 | HUD.Font().pFontMedium->SetColor(color); |
| 162 | HUD.Font().pFontMedium->OutSet(x, y); |
| 163 | HUD.Font().pFontMedium->OutNext("%s", text.c_str()); |
| 164 | } |
| 165 | }; |
| 166 | |
| 167 | //-- draw static lines |
| 168 | for (auto& line : m_StaticLines) |
| 169 | { |
| 170 | if (!psActorFlags.test(line.mDrawMask) && line.mDrawMask != 0xFFFFFFFF) |
| 171 | continue; |
| 172 | draw_line(Fidentity, line.mStartPos, line.mEndPos, line.mColor); |
| 173 | draw_text(line.mStartPos, line.mText, line.mNameDist, line.mTextColor); |
| 174 | draw_text(line.mEndPos, line.mTextEnd, line.mNameDist, line.mTextColor); |
| 175 | } |
| 176 | |
| 177 | //-- draw static boxes |
| 178 | for (auto& box : m_StaticBoxes) |
| 179 | { |
| 180 | if (!psActorFlags.test(box.mDrawMask) && box.mDrawMask != 0xFFFFFFFF) |
| 181 | continue; |
| 182 | draw_aabb(box.mXFORM.c, VPUSH(box.mHalfSize), box.mColor); |
| 183 | draw_text(box.mXFORM.c, box.mText, box.mNameDist, box.mTextColor); |
| 184 | } |
| 185 | |
| 186 | //-- draw static spheres |
| 187 | for (auto& sphere : m_StaticSpheres) |
| 188 | { |
| 189 | if (!psActorFlags.test(sphere.mDrawMask) && sphere.mDrawMask != 0xFFFFFFFF) |
| 190 | continue; |
| 191 | draw_ellipse(sphere.mXFORM, sphere.mColor); |
| 192 | draw_text(sphere.mXFORM.c, sphere.mText, sphere.mNameDist, sphere.mTextColor); |
| 193 | } |
| 194 | } |