Changeset View
Changeset View
Standalone View
Standalone View
source/gui/ObjectTypes/CMiniMap.cpp
Show First 20 Lines • Show All 339 Lines • ▼ Show 20 Lines | bool CMiniMap::FireWorldClickEvent(int button, int UNUSED(clicks)) | ||||||||
return ScriptEventWithReturn(EventNameWorldClick, paramData); | return ScriptEventWithReturn(EventNameWorldClick, paramData); | ||||||||
} | } | ||||||||
// This sets up and draws the rectangle on the minimap | // This sets up and draws the rectangle on the minimap | ||||||||
// which represents the view of the camera in the world. | // which represents the view of the camera in the world. | ||||||||
void CMiniMap::DrawViewRect(const CMatrix3D& transform) const | void CMiniMap::DrawViewRect(const CMatrix3D& transform) const | ||||||||
{ | { | ||||||||
// Compute the camera frustum intersected with a fixed-height plane. | // Compute the camera frustum intersected with an imaginary plane | ||||||||
// Use the water height as a fixed base height, which should be the lowest we can go | // derived from the center-point of the camera's current view. | ||||||||
float h = g_Renderer.GetWaterManager()->m_WaterHeight; | |||||||||
const float width = m_CachedActualSize.GetWidth(); | const float width = m_CachedActualSize.GetWidth(); | ||||||||
const float height = m_CachedActualSize.GetHeight(); | const float height = m_CachedActualSize.GetHeight(); | ||||||||
const float invTileMapSize = 1.0f / float(TERRAIN_TILE_SIZE * m_MapSize); | const float invTileMapSize = 1.0f / float(TERRAIN_TILE_SIZE * m_MapSize); | ||||||||
const CCamera* camera = g_Game->GetView()->GetCamera(); | const CCamera* camera = g_Game->GetView()->GetCamera(); | ||||||||
const int viewHeight = g_Renderer.GetHeight(); | |||||||||
vladislavbelov: `const`. | |||||||||
const int viewWidth = g_Renderer.GetWidth(); | |||||||||
const float planeHeight = camera->GetWorldCoordinates(viewWidth / 2, viewHeight / 2, true).Y; | |||||||||
StanUnsubmitted Not Done Inline Actions
Stan: | |||||||||
vladislavbelovUnsubmitted Not Done Inline ActionsKinda ambiguous, because we have GetWorldCoordinates(int, int, bool) and GetWorldCoordinates(float, float, float). vladislavbelov: Kinda ambiguous, because we have `GetWorldCoordinates(int, int, bool)` and `GetWorldCoordinates… | |||||||||
s0600204AuthorUnsubmitted Not Done Inline Actions@Stan: I'm no expert so perhaps it's something beyond my current knowledge, however I don't see why taking the result of an int / float calculation and passing it to something expecting an int is better than the above? @vladislavbelov, I see:
... there isn't a GetWorldCoordinates(float, float, float) version. s0600204: @Stan: I'm no expert so perhaps it's something beyond my current knowledge, however I don't see… | |||||||||
vladislavbelovUnsubmitted Not Done Inline ActionsMy bad, I wrote it incorrectly. Also I agree that it doesn't make sense to divide by float to get float to pass to int. vladislavbelov: My bad, I wrote it incorrectly. Also I agree that it doesn't make sense to divide by float to… | |||||||||
const std::array<CVector3D, 4> hitPoints = { | const std::array<CVector3D, 4> hitPoints = { | ||||||||
camera->GetWorldCoordinates(0, g_Renderer.GetHeight(), h), | camera->GetWorldCoordinates(0, viewHeight, planeHeight), | ||||||||
camera->GetWorldCoordinates(g_Renderer.GetWidth(), g_Renderer.GetHeight(), h), | camera->GetWorldCoordinates(viewWidth, viewHeight, planeHeight), | ||||||||
camera->GetWorldCoordinates(g_Renderer.GetWidth(), 0, h), | camera->GetWorldCoordinates(viewWidth, 0, planeHeight), | ||||||||
camera->GetWorldCoordinates(0, 0, h) | camera->GetWorldCoordinates(0, 0, planeHeight) | ||||||||
}; | }; | ||||||||
std::vector<CVector3D> lines; | std::vector<CVector3D> lines; | ||||||||
// We need to prevent drawing view bounds out of the map. | // We need to prevent drawing view bounds out of the map. | ||||||||
const float halfMapSize = static_cast<float>((m_MapSize - 1) * TERRAIN_TILE_SIZE) * 0.5f; | const float halfMapSize = static_cast<float>((m_MapSize - 1) * TERRAIN_TILE_SIZE) * 0.5f; | ||||||||
CropPointsByCircle(hitPoints, CVector3D(halfMapSize, 0.0f, halfMapSize), halfMapSize * m_MapScale, &lines); | CropPointsByCircle(hitPoints, CVector3D(halfMapSize, 0.0f, halfMapSize), halfMapSize * m_MapScale, &lines); | ||||||||
if (lines.empty()) | if (lines.empty()) | ||||||||
return; | return; | ||||||||
▲ Show 20 Lines • Show All 357 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
const.