forked from Vogtinator/crafti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
colorrenderer.cpp
47 lines (39 loc) · 2.42 KB
/
colorrenderer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "colorrenderer.h"
#include "settingstask.h"
#include "terrain.h"
void ColorBlockRenderer::geometryNormalBlock(const BLOCK_WDATA block, const int local_x, const int local_y, const int local_z, const BLOCK_SIDE side, Chunk &c)
{
if(settings_task.getValue(SettingsTask::FAST_MODE) && quad_block_textures[getBLOCK(block)][side].has_quad)
{
//Which shade of the color to use
int color = (local_x ^ local_y ^ local_z ^ c.x ^ c.y ^ c.z) % (sizeof(TerrainQuadEntry::colors)/sizeof(TerrainQuadEntry::colors[0]));
switch(side)
{
case BLOCK_BACK:
case BLOCK_FRONT:
if(shouldRenderFaceAndItsTheSameAs(local_x + 1, local_y, local_z, side, c, block)
&& shouldRenderFaceAndItsTheSameAs(local_x + 1, local_y + 1, local_z, side, c, block)
&& shouldRenderFaceAndItsTheSameAs(local_x, local_y + 1, local_z, side, c, block))
return BlockRenderer::renderNormalBlockSideQuadForceColor(local_x, local_y, local_z, side, quad_block_textures[getBLOCK(block)][side].colors[color], c);
break;
case BLOCK_LEFT:
case BLOCK_RIGHT:
if(shouldRenderFaceAndItsTheSameAs(local_x, local_y, local_z + 1, side, c, block)
&& shouldRenderFaceAndItsTheSameAs(local_x, local_y + 1, local_z + 1, side, c, block)
&& shouldRenderFaceAndItsTheSameAs(local_x, local_y + 1, local_z, side, c, block))
return BlockRenderer::renderNormalBlockSideQuadForceColor(local_x, local_y, local_z, side, quad_block_textures[getBLOCK(block)][side].colors[color], c);
break;
case BLOCK_BOTTOM:
case BLOCK_TOP:
if(shouldRenderFaceAndItsTheSameAs(local_x + 1, local_y, local_z, side, c, block)
&& shouldRenderFaceAndItsTheSameAs(local_x + 1, local_y, local_z + 1, side, c, block)
&& shouldRenderFaceAndItsTheSameAs(local_x, local_y, local_z + 1, side, c, block))
return BlockRenderer::renderNormalBlockSideQuadForceColor(local_x, local_y, local_z, side, quad_block_textures[getBLOCK(block)][side].colors[color], c);
break;
default:
break;
}
return BlockRenderer::renderNormalBlockSideForceColor(local_x, local_y, local_z, side, quad_block_textures[getBLOCK(block)][side].colors[color], c);
}
NormalBlockRenderer::geometryNormalBlock(block, local_x, local_y, local_z, side, c);
}