Rename some variables to make their purpose clearer

This commit is contained in:
sfan5 2015-03-18 22:49:19 +01:00
parent 70b75507fe
commit a361e4d1eb
3 changed files with 36 additions and 36 deletions

@ -15,9 +15,9 @@
#include "config.h" #include "config.h"
struct PixelAttribute { struct PixelAttribute {
PixelAttribute(): height(std::numeric_limits<int>::min()), thicken(0) {}; PixelAttribute(): height(std::numeric_limits<int>::min()), thickness(0) {};
int height; int height;
uint8_t thicken; uint8_t thickness;
inline bool valid_height() { inline bool valid_height() {
return height != std::numeric_limits<int>::min(); return height != std::numeric_limits<int>::min();
} }

@ -281,7 +281,7 @@ void TileGenerator::parseColorsStream(std::istream &in)
if(strlen(name) == 0) if(strlen(name) == 0)
break; break;
ColorEntry color = ColorEntry(r, g, b, a, t); ColorEntry color = ColorEntry(r, g, b, a, t);
m_colors[name] = color; m_colorMap[name] = color;
} }
} }
@ -365,14 +365,14 @@ void TileGenerator::renderMap()
} }
for (int i = 0; i < 16; ++i) { for (int i = 0; i < 16; ++i) {
m_readedPixels[i] = 0; m_readPixels[i] = 0;
m_readInfo[i] = 0; m_readInfo[i] = 0;
} }
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) { for (int j = 0; j < 16; j++) {
m_col[i][j] = m_bgColor; // This will be drawn by renderMapBlockBottom() for y-rows with only 'air', 'ignore' or unknown nodes if --drawalpha is used m_color[i][j] = m_bgColor; // This will be drawn by renderMapBlockBottom() for y-rows with only 'air', 'ignore' or unknown nodes if --drawalpha is used
m_col[i][j].a = 0; // ..but set alpha to 0 to tell renderMapBlock() not to use this color to mix a shade m_color[i][j].a = 0; // ..but set alpha to 0 to tell renderMapBlock() not to use this color to mix a shade
m_th[i][j] = 0; m_thickness[i][j] = 0;
} }
} }
@ -464,23 +464,23 @@ void TileGenerator::renderMap()
renderMapBlock(mapData, pos, version); renderMapBlock(mapData, pos, version);
bool allReaded = true; bool allRead = true;
for (int i = 0; i < 16; ++i) { for (int i = 0; i < 16; ++i) {
if (m_readedPixels[i] != 0xffff) { if (m_readPixels[i] != 0xffff) {
allReaded = false; allRead = false;
} }
} }
if (allReaded) { if (allRead) {
break; break;
} }
} }
bool allReaded = true; bool allRead = true;
for (int i = 0; i < 16; ++i) { for (int i = 0; i < 16; ++i) {
if (m_readedPixels[i] != 0xffff) { if (m_readPixels[i] != 0xffff) {
allReaded = false; allRead = false;
} }
} }
if (!allReaded) { if (!allRead) {
renderMapBlockBottom(blockStack.begin()->first); renderMapBlockBottom(blockStack.begin()->first);
} }
} }
@ -499,7 +499,7 @@ inline void TileGenerator::renderMapBlock(const ustring &mapBlock, const BlockPo
for (int z = 0; z < 16; ++z) { for (int z = 0; z < 16; ++z) {
int imageY = getImageY(zBegin + 15 - z); int imageY = getImageY(zBegin + 15 - z);
for (int x = 0; x < 16; ++x) { for (int x = 0; x < 16; ++x) {
if (m_readedPixels[z] & (1 << x)) { if (m_readPixels[z] & (1 << x)) {
continue; continue;
} }
int imageX = getImageX(xBegin + x); int imageX = getImageX(xBegin + x);
@ -514,25 +514,25 @@ inline void TileGenerator::renderMapBlock(const ustring &mapBlock, const BlockPo
if (blockName == m_nameMap.end()) if (blockName == m_nameMap.end())
continue; continue;
const string &name = blockName->second; const string &name = blockName->second;
ColorMap::const_iterator color = m_colors.find(name); ColorMap::const_iterator color = m_colorMap.find(name);
if (color != m_colors.end()) { if (color != m_colorMap.end()) {
const Color c = color->second.to_color(); const Color c = color->second.to_color();
if (m_drawAlpha) { if (m_drawAlpha) {
if (m_col[z][x].a == 0) if (m_color[z][x].a == 0)
m_col[z][x] = c; m_color[z][x] = c;
else else
m_col[z][x] = mixColors(m_col[z][x], c); m_color[z][x] = mixColors(m_color[z][x], c);
if(m_col[z][x].a == 0xFF) { if(m_color[z][x].a == 0xFF) {
m_image->tpixels[imageY][imageX] = color2int(m_col[z][x]); m_image->tpixels[imageY][imageX] = color2int(m_color[z][x]);
m_readedPixels[z] |= (1 << x); m_readPixels[z] |= (1 << x);
m_blockPixelAttributes.attribute(15 - z, xBegin + x).thicken = m_th[z][x]; m_blockPixelAttributes.attribute(15 - z, xBegin + x).thickness = m_thickness[z][x];
} else { } else {
m_th[z][x] = (m_th[z][x] + color->second.t) / 2.0; m_thickness[z][x] = (m_thickness[z][x] + color->second.t) / 2.0;
continue; continue;
} }
} else { } else {
m_image->tpixels[imageY][imageX] = color2int(c); m_image->tpixels[imageY][imageX] = color2int(c);
m_readedPixels[z] |= (1 << x); m_readPixels[z] |= (1 << x);
} }
if(!(m_readInfo[z] & (1 << x))) { if(!(m_readInfo[z] & (1 << x))) {
m_blockPixelAttributes.attribute(15 - z, xBegin + x).height = pos.y * 16 + y; m_blockPixelAttributes.attribute(15 - z, xBegin + x).height = pos.y * 16 + y;
@ -555,15 +555,15 @@ inline void TileGenerator::renderMapBlockBottom(const BlockPos &pos)
for (int z = 0; z < 16; ++z) { for (int z = 0; z < 16; ++z) {
int imageY = getImageY(zBegin + 15 - z); int imageY = getImageY(zBegin + 15 - z);
for (int x = 0; x < 16; ++x) { for (int x = 0; x < 16; ++x) {
if (m_readedPixels[z] & (1 << x)) { if (m_readPixels[z] & (1 << x)) {
continue; continue;
} }
int imageX = getImageX(xBegin + x); int imageX = getImageX(xBegin + x);
if (m_drawAlpha) { if (m_drawAlpha) {
m_image->tpixels[imageY][imageX] = color2int(m_col[z][x]); m_image->tpixels[imageY][imageX] = color2int(m_color[z][x]);
m_readedPixels[z] |= (1 << x); m_readPixels[z] |= (1 << x);
m_blockPixelAttributes.attribute(15 - z, xBegin + x).thicken = m_th[z][x]; m_blockPixelAttributes.attribute(15 - z, xBegin + x).thickness = m_thickness[z][x];
} }
} }
} }
@ -591,7 +591,7 @@ inline void TileGenerator::renderShading(int zPos)
} }
// more thickness -> less visible shadows: t=0 -> 100% visible, t=255 -> 0% visible // more thickness -> less visible shadows: t=0 -> 100% visible, t=255 -> 0% visible
if (m_drawAlpha) if (m_drawAlpha)
d = d * ((0xFF - m_blockPixelAttributes.attribute(z, x).thicken) / 255.0); d = d * ((0xFF - m_blockPixelAttributes.attribute(z, x).thickness) / 255.0);
int sourceColor = m_image->tpixels[imageY][getImageX(x)] & 0xffffff; int sourceColor = m_image->tpixels[imageY][getImageX(x)] & 0xffffff;
uint8_t r = (sourceColor & 0xff0000) >> 16; uint8_t r = (sourceColor & 0xff0000) >> 16;
uint8_t g = (sourceColor & 0x00ff00) >> 8; uint8_t g = (sourceColor & 0x00ff00) >> 8;

@ -120,12 +120,12 @@ private:
int m_mapHeight; int m_mapHeight;
std::list<std::pair<int, int> > m_positions; std::list<std::pair<int, int> > m_positions;
NameMap m_nameMap; NameMap m_nameMap;
ColorMap m_colors; ColorMap m_colorMap;
uint16_t m_readedPixels[16]; uint16_t m_readPixels[16];
uint16_t m_readInfo[16]; uint16_t m_readInfo[16];
NameSet m_unknownNodes; NameSet m_unknownNodes;
Color m_col[16][16]; Color m_color[16][16];
uint8_t m_th[16][16]; uint8_t m_thickness[16][16];
int m_blockAirId; int m_blockAirId;
int m_blockIgnoreId; int m_blockIgnoreId;