| 456 | |
| 457 | |
| 458 | void GetSpruceTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks) |
| 459 | { |
| 460 | // Spruces have a top section with layer sizes of (0, 1, 0) or only (1, 0), |
| 461 | // then 1 - 3 sections of ascending sizes (1, 2) [most often], (1, 3) or (1, 2, 3) |
| 462 | // and an optional bottom section of size 1, followed by 1 - 3 clear trunk blocks |
| 463 | |
| 464 | // We'll use bits from this number as partial random numbers; but the noise function has mod8 irregularities |
| 465 | // (each of the mod8 remainders has a very different chance of occurrence) - that's why we divide by 8 |
| 466 | int MyRandom = a_Noise.IntNoise3DInt(a_BlockX + 32 * a_Seq, a_BlockY + 32 * a_Seq, a_BlockZ) / 8; |
| 467 | |
| 468 | static const int sHeights[] = {1, 2, 2, 3}; |
| 469 | int Height = sHeights[MyRandom & 3]; |
| 470 | MyRandom >>= 2; |
| 471 | |
| 472 | // Prealloc, so that we don't realloc too often later: |
| 473 | a_LogBlocks.reserve(Height); |
| 474 | a_OtherBlocks.reserve(180); |
| 475 | |
| 476 | // Clear trunk blocks: |
| 477 | for (int i = 0; i < Height; i++) |
| 478 | { |
| 479 | a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER)); |
| 480 | } |
| 481 | Height += a_BlockY; |
| 482 | |
| 483 | // Optional size-1 bottom leaves layer: |
| 484 | if ((MyRandom & 1) == 0) |
| 485 | { |
| 486 | PushCoordBlocks(a_BlockX, Height, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER); |
| 487 | a_OtherBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER)); |
| 488 | Height++; |
| 489 | } |
| 490 | MyRandom >>= 1; |
| 491 | |
| 492 | // 1 to 3 sections of leaves layers: |
| 493 | static const int sNumSections[] = {1, 2, 2, 3}; |
| 494 | int NumSections = sNumSections[MyRandom & 3]; |
| 495 | MyRandom >>= 2; |
| 496 | for (int i = 0; i < NumSections; i++) |
| 497 | { |
| 498 | switch (MyRandom & 3) // SectionType; (1, 2) twice as often as the other two |
| 499 | { |
| 500 | case 0: |
| 501 | case 1: |
| 502 | { |
| 503 | PushCoordBlocks(a_BlockX, Height, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER); |
| 504 | PushCoordBlocks(a_BlockX, Height + 1, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER); |
| 505 | a_LogBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER)); |
| 506 | a_LogBlocks.push_back(sSetBlock(a_BlockX, Height + 1, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER)); |
| 507 | Height += 2; |
| 508 | break; |
| 509 | } |
| 510 | case 2: |
| 511 | { |
| 512 | PushCoordBlocks(a_BlockX, Height, a_BlockZ, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER); |
| 513 | PushCoordBlocks(a_BlockX, Height + 1, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_CONIFER); |
| 514 | a_LogBlocks.push_back(sSetBlock(a_BlockX, Height, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER)); |
| 515 | a_LogBlocks.push_back(sSetBlock(a_BlockX, Height + 1, a_BlockZ, E_BLOCK_LOG, E_META_LOG_CONIFER)); |
no test coverage detected