MCPcopy Create free account
hub / github.com/cuberite/cuberite / Render

Method Render

Tools/BiomeVisualiser/BiomeRenderer.cpp:35–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34
35bool cBiomeRenderer::Render(cPixmap & a_Pixmap)
36{
37 cTimer Timer("cBiomeRenderer::Render");
38
39 int Wid = a_Pixmap.GetWidth();
40 int Hei = a_Pixmap.GetHeight();
41
42 // Hint the approximate view area to the biome source so that it can adjust its caches:
43 int MinBlockX = ( - m_OriginX) * m_Zoom;
44 int MaxBlockX = (Wid - m_OriginX) * m_Zoom;
45 int MinBlockZ = ( - m_OriginY) * m_Zoom;
46 int MaxBlockZ = (Hei - m_OriginY) * m_Zoom;
47 m_Cache.HintViewArea(MinBlockX / 16 - 1, MaxBlockX / 16 + 1, MinBlockZ / 16 - 1, MaxBlockZ / 16 + 1);
48
49 // Hold one current chunk of biome data:
50 int CurChunkX = -10000;
51 int CurChunkZ = -10000;
52 cChunkDef::BiomeMap CurBiomes;
53
54 bool res = false;
55
56 for (int y = 0; y < Hei; y++)
57 {
58 int BlockZ = (y - m_OriginY) * m_Zoom;
59 int ChunkZ = (BlockZ >= 0) ? (BlockZ / 16) : ((BlockZ + 1) / 16 - 1);
60 int RelZ = BlockZ - ChunkZ * 16;
61 for (int x = 0; x < Wid; x++)
62 {
63 int BlockX = (x - m_OriginX) * m_Zoom;
64 int ChunkX = (BlockX >= 0) ? (BlockX / 16) : ((BlockX + 1) / 16 - 1);
65 int RelX = BlockX - ChunkX * 16;
66 if ((ChunkZ != CurChunkZ) || (ChunkX != CurChunkX))
67 {
68 CurChunkX = ChunkX;
69 CurChunkZ = ChunkZ;
70 switch (m_Cache.GetBiome(CurChunkX, CurChunkZ, CurBiomes))
71 {
72 case cBiomeSource::baLater:
73 {
74 res = true;
75 // fallthrough:
76 }
77 case cBiomeSource::baNever:
78 {
79 for (int i = 0; i < ARRAYCOUNT(CurBiomes); i++)
80 {
81 CurBiomes[i] = biInvalidBiome;
82 }
83 break;
84 }
85 } // switch (Biome availability)
86 }
87 EMCSBiome Biome = cChunkDef::GetBiome(CurBiomes, RelX, RelZ);
88 a_Pixmap.SetPixel(x, y, GetBiomeColor(Biome));
89 } // for x
90 } // for y
91 return res;
92}

Callers 3

RedrawMethod · 0.80
OnPaintMethod · 0.80
OnTimerMethod · 0.80

Calls 5

GetWidthMethod · 0.45
GetHeightMethod · 0.45
HintViewAreaMethod · 0.45
GetBiomeMethod · 0.45
SetPixelMethod · 0.45

Tested by

no test coverage detected