MCPcopy Create free account
hub / github.com/ddnet/ddnet / DrawAABB

Method DrawAABB

src/game/editor/editor.cpp:1227–1249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1225}
1226
1227void CEditor::DrawAABB(const SAxisAlignedBoundingBox &AABB, ivec2 Offset) const
1228{
1229 // Drawing an AABB is simply converting the points from fixed to float
1230 // Then making lines out of quads and drawing them
1231 vec2 TL = {fx2f(AABB.m_aPoints[SAxisAlignedBoundingBox::POINT_TL].x + Offset.x), fx2f(AABB.m_aPoints[SAxisAlignedBoundingBox::POINT_TL].y + Offset.y)};
1232 vec2 TR = {fx2f(AABB.m_aPoints[SAxisAlignedBoundingBox::POINT_TR].x + Offset.x), fx2f(AABB.m_aPoints[SAxisAlignedBoundingBox::POINT_TR].y + Offset.y)};
1233 vec2 BL = {fx2f(AABB.m_aPoints[SAxisAlignedBoundingBox::POINT_BL].x + Offset.x), fx2f(AABB.m_aPoints[SAxisAlignedBoundingBox::POINT_BL].y + Offset.y)};
1234 vec2 BR = {fx2f(AABB.m_aPoints[SAxisAlignedBoundingBox::POINT_BR].x + Offset.x), fx2f(AABB.m_aPoints[SAxisAlignedBoundingBox::POINT_BR].y + Offset.y)};
1235 vec2 Center = {fx2f(AABB.m_aPoints[SAxisAlignedBoundingBox::POINT_CENTER].x + Offset.x), fx2f(AABB.m_aPoints[SAxisAlignedBoundingBox::POINT_CENTER].y + Offset.y)};
1236
1237 // We don't use IGraphics::CLineItem to draw because we don't want to stop QuadsBegin(), quads work just fine.
1238 IGraphics::CQuadItem Lines[4] = {
1239 {TL.x, TL.y, TR.x - TL.x, 1.0f * m_MouseWorldScale},
1240 {TL.x, TL.y, 1.0f * m_MouseWorldScale, BL.y - TL.y},
1241 {TR.x, TR.y, 1.0f * m_MouseWorldScale, BR.y - TR.y},
1242 {BL.x, BL.y, BR.x - BL.x, 1.0f * m_MouseWorldScale},
1243 };
1244 Graphics()->SetColor(1, 0, 1, 1);
1245 Graphics()->QuadsDrawTL(Lines, 4);
1246
1247 IGraphics::CQuadItem CenterQuad(Center.x, Center.y, 5.0f * m_MouseWorldScale, 5.0f * m_MouseWorldScale);
1248 Graphics()->QuadsDraw(&CenterQuad, 1);
1249}
1250
1251void CEditor::QuadSelectionAABB(const std::shared_ptr<CLayerQuads> &pLayer, SAxisAlignedBoundingBox &OutAABB)
1252{

Callers

nothing calls this directly

Calls 5

fx2fFunction · 0.85
GraphicsFunction · 0.85
QuadsDrawTLMethod · 0.80
QuadsDrawMethod · 0.80
SetColorMethod · 0.45

Tested by

no test coverage detected