goto() bitmap debugger
parent
d38ddcbc41
commit
e24d77bde8
|
@ -3986,7 +3986,7 @@ void CEngine::UpdateGroundSpotTextures()
|
|||
set = true;
|
||||
}
|
||||
|
||||
if (clear || set || m_debugResources)
|
||||
if (clear || set || m_debugResources || m_displayGotoImage != nullptr)
|
||||
{
|
||||
CImage shadowImg(Math::IntPoint(256, 256));
|
||||
shadowImg.Fill(Gfx::IntColor(255, 255, 255, 255));
|
||||
|
@ -4169,6 +4169,20 @@ void CEngine::UpdateGroundSpotTextures()
|
|||
}
|
||||
}
|
||||
|
||||
if (m_displayGotoImage != nullptr)
|
||||
{
|
||||
Math::IntPoint size = m_displayGotoImage->GetSize();
|
||||
for (float x = min.x; x < max.x; x += 1.0f)
|
||||
{
|
||||
for (float y = min.y; y < max.y; y += 1.0f)
|
||||
{
|
||||
int px = x / 4.0f / 254.0f * size.x;
|
||||
int py = y / 4.0f / 254.0f * size.y;
|
||||
shadowImg.SetPixelInt(Math::IntPoint(x-min.x, y-min.y), m_displayGotoImage->GetPixelInt(Math::IntPoint(px, py)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream str;
|
||||
str << "textures/shadow" << std::setfill('0') << std::setw(2) << s << ".png";
|
||||
std::string texName = str.str();
|
||||
|
@ -5147,6 +5161,10 @@ bool CEngine::GetDebugResources()
|
|||
void CEngine::SetDebugGoto(bool debugGoto)
|
||||
{
|
||||
m_debugGoto = debugGoto;
|
||||
if (!m_debugGoto)
|
||||
{
|
||||
m_displayGotoImage.reset();
|
||||
}
|
||||
}
|
||||
|
||||
bool CEngine::GetDebugGoto()
|
||||
|
@ -5159,4 +5177,11 @@ void CEngine::AddDebugGotoLine(std::vector<Gfx::VertexCol> line)
|
|||
m_displayGoto.push_back(line);
|
||||
}
|
||||
|
||||
void CEngine::SetDebugGotoBitmap(std::unique_ptr<CImage> debugImage)
|
||||
{
|
||||
m_displayGotoImage = std::move(debugImage);
|
||||
m_firstGroundSpot = true; // Force ground spot texture reload
|
||||
UpdateGroundSpotTextures();
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
|
|
|
@ -1194,6 +1194,7 @@ public:
|
|||
void SetDebugGoto(bool debugGoto);
|
||||
bool GetDebugGoto();
|
||||
void AddDebugGotoLine(std::vector<Gfx::VertexCol> line);
|
||||
void SetDebugGotoBitmap(std::unique_ptr<CImage> debugImage);
|
||||
|
||||
protected:
|
||||
//! Resets some states and flushes textures after device was changed (e.g. resoulution changed)
|
||||
|
@ -1494,6 +1495,7 @@ protected:
|
|||
|
||||
std::vector<Math::Sphere> m_displayCrashSpheres;
|
||||
std::vector<std::vector<VertexCol>> m_displayGoto;
|
||||
std::unique_ptr<CImage> m_displayGotoImage;
|
||||
|
||||
//! Pause the animation updates
|
||||
bool m_pause = false;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "common/event.h"
|
||||
#include "common/global.h"
|
||||
#include "common/image.h"
|
||||
#include "common/make_unique.h"
|
||||
|
||||
#include "graphics/engine/terrain.h"
|
||||
|
@ -65,6 +66,9 @@ CTaskGoto::CTaskGoto(COldObject* object) : CForegroundTask(object)
|
|||
CTaskGoto::~CTaskGoto()
|
||||
{
|
||||
BitmapClose();
|
||||
|
||||
if (m_engine->GetDebugGoto() && m_object->GetSelect())
|
||||
m_engine->SetDebugGotoBitmap(std::move(nullptr));
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,6 +109,31 @@ bool CTaskGoto::EventProcess(const Event &event)
|
|||
debugLine.push_back(Gfx::VertexCol(m_object->GetPosition(), color));
|
||||
debugLine.push_back(Gfx::VertexCol(AdjustPoint(m_bmTotal > 0 && m_bmIndex <= m_bmTotal && m_phase != TGP_BEAMSEARCH ? m_bmPoints[m_bmIndex] : m_goal), color));
|
||||
m_engine->AddDebugGotoLine(debugLine);
|
||||
|
||||
if (m_object->GetSelect() && m_bmChanged)
|
||||
{
|
||||
if (m_bmArray != nullptr)
|
||||
{
|
||||
std::unique_ptr<CImage> debugImage = MakeUnique<CImage>(Math::IntPoint(m_bmSize, m_bmSize));
|
||||
debugImage->Fill(Gfx::IntColor(255, 255, 255, 255));
|
||||
for (int x = 0; x < m_bmSize; x++)
|
||||
{
|
||||
for (int y = 0; y < m_bmSize; y++)
|
||||
{
|
||||
bool a = BitmapTestDot(0, x, y);
|
||||
bool b = BitmapTestDot(1, x, y);
|
||||
if (a || b)
|
||||
{
|
||||
Gfx::Color c = Gfx::Color(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
if (b) c = Gfx::Color(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
debugImage->SetPixel(Math::IntPoint(x, y), c);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_engine->SetDebugGotoBitmap(std::move(debugImage));
|
||||
}
|
||||
m_bmChanged = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_engine->GetPause() ) return true;
|
||||
|
@ -2001,6 +2030,7 @@ bool CTaskGoto::BitmapOpen()
|
|||
|
||||
m_bmSize = static_cast<int>(3200.0f/BM_DIM_STEP);
|
||||
m_bmArray = MakeUniqueArray<unsigned char>(m_bmSize*m_bmSize/8*2);
|
||||
m_bmChanged = true;
|
||||
|
||||
m_bmOffset = m_bmSize/2;
|
||||
m_bmLine = m_bmSize/8;
|
||||
|
@ -2018,6 +2048,7 @@ bool CTaskGoto::BitmapOpen()
|
|||
bool CTaskGoto::BitmapClose()
|
||||
{
|
||||
m_bmArray.reset();
|
||||
m_bmChanged = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2074,6 +2105,7 @@ void CTaskGoto::BitmapSetDot(int rank, int x, int y)
|
|||
y < 0 || y >= m_bmSize ) return;
|
||||
|
||||
m_bmArray[rank*m_bmLine*m_bmSize + m_bmLine*y + x/8] |= (1<<x%8);
|
||||
m_bmChanged = true;
|
||||
}
|
||||
|
||||
// Removes a point in the bitmap.
|
||||
|
@ -2085,6 +2117,7 @@ void CTaskGoto::BitmapClearDot(int rank, int x, int y)
|
|||
y < 0 || y >= m_bmSize ) return;
|
||||
|
||||
m_bmArray[rank*m_bmLine*m_bmSize + m_bmLine*y + x/8] &= ~(1<<x%8);
|
||||
m_bmChanged = true;
|
||||
}
|
||||
|
||||
// Tests a point in the bitmap.
|
||||
|
|
|
@ -137,6 +137,7 @@ protected:
|
|||
float m_wormLastTime = 0.0f;
|
||||
float m_lastDistance = 0.0f;
|
||||
|
||||
bool m_bmChanged = true;
|
||||
int m_bmSize = 0; // width or height of the table
|
||||
int m_bmOffset = 0; // m_bmSize/2
|
||||
int m_bmLine = 0; // increment line m_bmSize/8
|
||||
|
|
Loading…
Reference in New Issue