void DefaultPathDrawer::DrawInMiniMap() { const CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); const CPathEstimator* pe = pm->medResPE; const MoveDef* md = GetSelectedMoveDef(); if (md == NULL) return; if (gd->GetDrawMode() < CBaseGroundDrawer::drawPathTrav) return; if (gd->GetDrawMode() > CBaseGroundDrawer::drawPathCost) return; glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0.0f, 1.0f, 0.0f, 1.0f, 0.0f, -1.0f); glTranslatef((float)minimap->GetPosX() * globalRendering->pixelX, (float)minimap->GetPosY() * globalRendering->pixelY, 0.0f); glScalef((float)minimap->GetSizeX() * globalRendering->pixelX, (float)minimap->GetSizeY() * globalRendering->pixelY, 1.0f); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef3(UpVector); glScalef(1.0f / gs->mapx, -1.0f / gs->mapy, 1.0f); glDisable(GL_TEXTURE_2D); glColor4f(1.0f, 1.0f, 0.0f, 0.7f); for (const CPathEstimator::SingleBlock& sb: pe->updatedBlocks) { if (sb.moveDef == md) { const int blockIdxX = sb.blockPos.x * pe->GetBlockSize(); const int blockIdxY = sb.blockPos.y * pe->GetBlockSize(); glRectf(blockIdxX, blockIdxY, blockIdxX + pe->GetBlockSize(), blockIdxY + pe->GetBlockSize()); } } glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glEnable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); }
void QTPFSPathDrawer::DrawAll() const { const MoveDef* md = GetSelectedMoveDef(); if (md == NULL) return; if (enabled && (gs->cheatEnabled || gu->spectating)) { glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); DrawNodeTree(md); DrawPaths(md); glPopAttrib(); } }
void QTPFSPathDrawer::DrawAll() const { const MoveDef* md = GetSelectedMoveDef(); if (md == NULL) return; // QTPFS::PathManager is not thread-safe if (!GML::SimEnabled() && globalRendering->drawdebug && (gs->cheatEnabled || gu->spectating)) { glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); DrawNodeTree(md); DrawPaths(md); glPopAttrib(); } }
void QTPFSPathDrawer::UpdateExtraTexture(int extraTex, int starty, int endy, int offset, unsigned char* texMem) const { switch (extraTex) { case CLegacyInfoTextureHandler::drawPathTrav: { const MoveDef* md = GetSelectedMoveDef(); if (md != NULL) { const QTPFS::NodeLayer& nl = pm->nodeLayers[md->pathType]; const float smr = 1.0f / nl.GetMaxRelSpeedMod(); const bool los = (gs->cheatEnabled || gu->spectating); for (int ty = starty; ty < endy; ++ty) { for (int tx = 0; tx < mapDims.hmapx; ++tx) { const int sqx = (tx << 1); const int sqz = (ty << 1); const int texIdx = ((ty * (mapDims.pwr2mapx >> 1)) + tx) * 4 - offset; const bool losSqr = losHandler->InLos(SquareToFloat3(sqx, sqz), gu->myAllyTeam); #if 1 // use node-modifiers as baseline so visualisation is in sync with alt+B const QTPFS::QTNode* node = static_cast<const QTPFS::QTNode*>(nl.GetNode(sqx, sqz)); const float sm = CMoveMath::GetPosSpeedMod(*md, sqx, sqz); const SColor& smc = GetSpeedModColor((los || losSqr)? node->speedModAvg * smr: sm); #else float scale = 1.0f; if (los || losSqr) { if (CMoveMath::IsBlocked(*md, sqx, sqz ) & CMoveMath::BLOCK_STRUCTURE) { scale -= 0.25f; } if (CMoveMath::IsBlocked(*md, sqx + 1, sqz ) & CMoveMath::BLOCK_STRUCTURE) { scale -= 0.25f; } if (CMoveMath::IsBlocked(*md, sqx, sqz + 1) & CMoveMath::BLOCK_STRUCTURE) { scale -= 0.25f; } if (CMoveMath::IsBlocked(*md, sqx + 1, sqz + 1) & CMoveMath::BLOCK_STRUCTURE) { scale -= 0.25f; } } const float sm = CMoveMath::GetPosSpeedMod(md, sqx, sqz); const SColor& smc = GetSpeedModColor(sm * scale); #endif texMem[texIdx + CLegacyInfoTextureHandler::COLOR_R] = smc.r; texMem[texIdx + CLegacyInfoTextureHandler::COLOR_G] = smc.g; texMem[texIdx + CLegacyInfoTextureHandler::COLOR_B] = smc.b; texMem[texIdx + CLegacyInfoTextureHandler::COLOR_A] = smc.a; } } } else { // we have nothing to show -> draw a dark red overlay for (int ty = starty; ty < endy; ++ty) { for (int tx = 0; tx < mapDims.hmapx; ++tx) { const int texIdx = ((ty * (mapDims.pwr2mapx >> 1)) + tx) * 4 - offset; texMem[texIdx + CLegacyInfoTextureHandler::COLOR_R] = 100; texMem[texIdx + CLegacyInfoTextureHandler::COLOR_G] = 0; texMem[texIdx + CLegacyInfoTextureHandler::COLOR_B] = 0; texMem[texIdx + CLegacyInfoTextureHandler::COLOR_A] = 255; } } } } break; case CLegacyInfoTextureHandler::drawPathCost: { } break; }
void DefaultPathDrawer::UpdateExtraTexture(int extraTex, int starty, int endy, int offset, unsigned char* texMem) const { switch (extraTex) { case CBaseGroundDrawer::drawPathTraversability: { bool useCurrentBuildOrder = true; if (guihandler->inCommand <= 0) { useCurrentBuildOrder = false; } if (guihandler->inCommand >= guihandler->commands.size()) { useCurrentBuildOrder = false; } if (useCurrentBuildOrder && guihandler->commands[guihandler->inCommand].type != CMDTYPE_ICON_BUILDING) { useCurrentBuildOrder = false; } if (useCurrentBuildOrder) { for (int ty = starty; ty < endy; ++ty) { for (int tx = 0; tx < gs->hmapx; ++tx) { const float3 pos(tx * (SQUARE_SIZE << 1) + SQUARE_SIZE, 0.0f, ty * (SQUARE_SIZE << 1) + SQUARE_SIZE); const int idx = ((ty * (gs->pwr2mapx >> 1)) + tx) * 4 - offset; BuildSquareStatus status = FREE; if (!loshandler->InLos(pos, gu->myAllyTeam)) { status = NOLOS; } else { const UnitDef* ud = unitDefHandler->GetUnitDefByID(-guihandler->commands[guihandler->inCommand].id); const BuildInfo bi(ud, pos, guihandler->buildFacing); CFeature* f = NULL; GML_RECMUTEX_LOCK(quad); // UpdateExtraTexture - testunitbuildsquare accesses features in the quadfield if (uh->TestUnitBuildSquare(bi, f, gu->myAllyTeam, false)) { if (f != NULL) { status = OBJECTBLOCKED; } } else { status = TERRAINBLOCKED; } } const SColor& col = GetBuildColor(status); texMem[idx + CBaseGroundDrawer::COLOR_R] = col.r; texMem[idx + CBaseGroundDrawer::COLOR_G] = col.g; texMem[idx + CBaseGroundDrawer::COLOR_B] = col.b; texMem[idx + CBaseGroundDrawer::COLOR_A] = col.a; } } } else { const MoveDef* md = GetSelectedMoveDef(); if (md != NULL) { const bool los = (gs->cheatEnabled || gu->spectating); for (int ty = starty; ty < endy; ++ty) { for (int tx = 0; tx < gs->hmapx; ++tx) { const int sqx = (tx << 1); const int sqy = (ty << 1); const int texIdx = ((ty * (gs->pwr2mapx >> 1)) + tx) * 4 - offset; const bool losSqr = loshandler->InLos(sqx, sqy, gu->myAllyTeam); float scale = 1.0f; if (los || losSqr) { if (CMoveMath::IsBlocked(*md, sqx, sqy , NULL) & CMoveMath::BLOCK_STRUCTURE) { scale -= 0.25f; } if (CMoveMath::IsBlocked(*md, sqx + 1, sqy , NULL) & CMoveMath::BLOCK_STRUCTURE) { scale -= 0.25f; } if (CMoveMath::IsBlocked(*md, sqx, sqy + 1, NULL) & CMoveMath::BLOCK_STRUCTURE) { scale -= 0.25f; } if (CMoveMath::IsBlocked(*md, sqx + 1, sqy + 1, NULL) & CMoveMath::BLOCK_STRUCTURE) { scale -= 0.25f; } } // NOTE: raw speedmods are not necessarily clamped to [0, 1] const float sm = CMoveMath::GetPosSpeedMod(*md, sqx, sqy); const SColor& smc = GetSpeedModColor(sm * scale); texMem[texIdx + CBaseGroundDrawer::COLOR_R] = smc.r; texMem[texIdx + CBaseGroundDrawer::COLOR_G] = smc.g; texMem[texIdx + CBaseGroundDrawer::COLOR_B] = smc.b; texMem[texIdx + CBaseGroundDrawer::COLOR_A] = smc.a; } } } else { // we have nothing to show -> draw a dark red overlay for (int ty = starty; ty < endy; ++ty) { for (int tx = 0; tx < gs->hmapx; ++tx) { const int texIdx = ((ty * (gs->pwr2mapx >> 1)) + tx) * 4 - offset; texMem[texIdx + CBaseGroundDrawer::COLOR_R] = 100; texMem[texIdx + CBaseGroundDrawer::COLOR_G] = 0; texMem[texIdx + CBaseGroundDrawer::COLOR_B] = 0; texMem[texIdx + CBaseGroundDrawer::COLOR_A] = 255; } } } } } break;