0x004BAEDA
| 24 | |
| 25 | // 0x004BAEDA |
| 26 | void paintTree(PaintSession& session, const World::TreeElement& elTree) |
| 27 | { |
| 28 | session.setItemType(InteractionItem::tree); |
| 29 | |
| 30 | const auto* treeObj = ObjectManager::get<TreeObject>(elTree.treeObjectId()); |
| 31 | const uint8_t viewableRotation = (session.getRotation() + elTree.rotation()) & 0x3; |
| 32 | const uint32_t treeFrameNum = (viewableRotation % treeObj->numRotations) + elTree.growth() * treeObj->numRotations; |
| 33 | |
| 34 | uint8_t season = elTree.season(); |
| 35 | bool hasImage2 = false; |
| 36 | uint32_t imageIndex2 = 0; |
| 37 | uint8_t noiseMask = 0; |
| 38 | if (elTree.unk7l() != 7) |
| 39 | { |
| 40 | hasImage2 = true; |
| 41 | |
| 42 | season = _50076A[season]; |
| 43 | noiseMask = elTree.unk7l() + 1; |
| 44 | auto image2Season = elTree.season(); |
| 45 | |
| 46 | if (_500770[image2Season]) |
| 47 | { |
| 48 | image2Season = season; |
| 49 | season = elTree.season(); |
| 50 | noiseMask = 8 - noiseMask; |
| 51 | } |
| 52 | |
| 53 | auto imageId = elTree.hasSnow() ? treeObj->snowSprites[image2Season] : treeObj->sprites[image2Season]; |
| 54 | imageIndex2 = treeFrameNum + imageId; |
| 55 | } |
| 56 | |
| 57 | const auto seasonBaseImageIndex = elTree.hasSnow() ? treeObj->snowSprites[season] : treeObj->sprites[season]; |
| 58 | |
| 59 | std::optional<ImageId> shadowImageId = std::nullopt; |
| 60 | if (treeObj->hasFlags(TreeObjectFlags::hasShadow)) |
| 61 | { |
| 62 | shadowImageId = ImageId{ treeObj->shadowImageOffset + treeFrameNum + seasonBaseImageIndex }.withTranslucency(ExtColour::unk32); |
| 63 | } |
| 64 | |
| 65 | const uint8_t quadrant = (elTree.quadrant() + session.getRotation()) % 4; |
| 66 | const auto imageOffset = World::Pos3(kTreeQuadrantOffset[quadrant].x, kTreeQuadrantOffset[quadrant].y, elTree.baseHeight()); |
| 67 | |
| 68 | const int16_t boundBoxSizeZ = std::min(elTree.clearZ() - elTree.baseZ(), 32) * World::kSmallZStep - 3; |
| 69 | |
| 70 | const uint32_t imageIndex1 = treeFrameNum + seasonBaseImageIndex; |
| 71 | ImageId imageId1{}; |
| 72 | ImageId imageId2{}; |
| 73 | |
| 74 | if (elTree.isGhost()) |
| 75 | { |
| 76 | session.setItemType(InteractionItem::noInteraction); |
| 77 | imageId2 = Gfx::applyGhostToImage(imageIndex2); |
| 78 | imageId1 = Gfx::applyGhostToImage(imageIndex1); |
| 79 | } |
| 80 | else if (treeObj->colours != 0) |
| 81 | { |
| 82 | // No vanilla object has this property set |
| 83 | const auto colour = static_cast<Colour>(elTree.colour()); |
no test coverage detected