@@ -360,6 +360,14 @@ void TileGenerator::renderMap()
360
360
361
361
for (int i = 0 ; i < 16 ; ++i) {
362
362
m_readedPixels[i] = 0 ;
363
+ m_readInfo[i] = 0 ;
364
+ }
365
+ for (int i = 0 ; i < 16 ; i++) {
366
+ for (int j = 0 ; j < 16 ; j++) {
367
+ 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
368
+ m_col[i][j].a = 0 ; // ..but set alpha to 0 to tell renderMapBlock() not to use this color to mix a shade
369
+ m_th[i][j] = 0 ;
370
+ }
363
371
}
364
372
365
373
int xPos = position->first ;
@@ -460,6 +468,15 @@ void TileGenerator::renderMap()
460
468
break ;
461
469
}
462
470
}
471
+ bool allReaded = true ;
472
+ for (int i = 0 ; i < 16 ; ++i) {
473
+ if (m_readedPixels[i] != 0xffff ) {
474
+ allReaded = false ;
475
+ }
476
+ }
477
+ if (!allReaded) {
478
+ renderMapBlockBottom (blockStack.begin ()->first );
479
+ }
463
480
}
464
481
if (m_shading)
465
482
renderShading (zPos);
@@ -473,19 +490,13 @@ inline void TileGenerator::renderMapBlock(const ustring &mapBlock, const BlockPo
473
490
const unsigned char *mapData = mapBlock.c_str ();
474
491
int minY = (pos.y * 16 > m_yMin) ? 0 : m_yMin - pos.y * 16 ;
475
492
int maxY = (pos.y * 16 < m_yMax) ? 15 : m_yMax - pos.y * 16 ;
476
- Color col;
477
- uint8_t th;
478
493
for (int z = 0 ; z < 16 ; ++z) {
479
494
int imageY = getImageY (zBegin + 15 - z);
480
495
for (int x = 0 ; x < 16 ; ++x) {
481
496
if (m_readedPixels[z] & (1 << x)) {
482
497
continue ;
483
498
}
484
499
int imageX = getImageX (xBegin + x);
485
- if (m_drawAlpha) {
486
- col = Color (0 ,0 ,0 ,0 );
487
- th = 0 ;
488
- }
489
500
490
501
for (int y = maxY; y >= minY; --y) {
491
502
int position = x + (y << 4 ) + (z << 8 );
@@ -501,21 +512,26 @@ inline void TileGenerator::renderMapBlock(const ustring &mapBlock, const BlockPo
501
512
if (color != m_colors.end ()) {
502
513
const Color c = color->second .to_color ();
503
514
if (m_drawAlpha) {
504
- if (col .a == 0 )
505
- col = c;
515
+ if (m_col[z][x] .a == 0 )
516
+ m_col[z][x] = c;
506
517
else
507
- col = mixColors (col, c);
508
- if (col.a == 0xFF || y == minY) {
509
- m_image->tpixels [imageY][imageX] = color2int (col);
510
- m_blockPixelAttributes.attribute (15 - z, xBegin + x).thicken = th;
518
+ m_col[z][x] = mixColors (m_col[z][x], c);
519
+ if (m_col[z][x].a == 0xFF ) {
520
+ m_image->tpixels [imageY][imageX] = color2int (m_col[z][x]);
521
+ m_readedPixels[z] |= (1 << x);
522
+ m_blockPixelAttributes.attribute (15 - z, xBegin + x).thicken = m_th[z][x];
511
523
} else {
512
- th = (th + color->second .t ) / 2.0 ;
524
+ m_th[z][x] = (m_th[z][x] + color->second .t ) / 2.0 ;
513
525
continue ;
514
526
}
515
- } else
527
+ } else {
516
528
m_image->tpixels [imageY][imageX] = color2int (c);
517
- m_readedPixels[z] |= (1 << x);
518
- m_blockPixelAttributes.attribute (15 - z, xBegin + x).height = pos.y * 16 + y;
529
+ m_readedPixels[z] |= (1 << x);
530
+ }
531
+ if (!(m_readInfo[z] & (1 << x))) {
532
+ m_blockPixelAttributes.attribute (15 - z, xBegin + x).height = pos.y * 16 + y;
533
+ m_readInfo[z] |= (1 << x);
534
+ }
519
535
} else {
520
536
m_unknownNodes.insert (name);
521
537
continue ;
@@ -526,6 +542,27 @@ inline void TileGenerator::renderMapBlock(const ustring &mapBlock, const BlockPo
526
542
}
527
543
}
528
544
545
+ inline void TileGenerator::renderMapBlockBottom (const BlockPos &pos)
546
+ {
547
+ int xBegin = (pos.x - m_xMin) * 16 ;
548
+ int zBegin = (m_zMax - pos.z ) * 16 ;
549
+ for (int z = 0 ; z < 16 ; ++z) {
550
+ int imageY = getImageY (zBegin + 15 - z);
551
+ for (int x = 0 ; x < 16 ; ++x) {
552
+ if (m_readedPixels[z] & (1 << x)) {
553
+ continue ;
554
+ }
555
+ int imageX = getImageX (xBegin + x);
556
+
557
+ if (m_drawAlpha) {
558
+ m_image->tpixels [imageY][imageX] = color2int (m_col[z][x]);
559
+ m_readedPixels[z] |= (1 << x);
560
+ m_blockPixelAttributes.attribute (15 - z, xBegin + x).thicken = m_th[z][x];
561
+ }
562
+ }
563
+ }
564
+ }
565
+
529
566
inline void TileGenerator::renderShading (int zPos)
530
567
{
531
568
int zBegin = (m_zMax - zPos) * 16 ;
0 commit comments