TileMapAtlas - Atlas generation / updates
| 122 | |
| 123 | // TileMapAtlas - Atlas generation / updates |
| 124 | void TileMapAtlas::setTile(const Color3B& tile, const Vec2& position) |
| 125 | { |
| 126 | AXASSERT(_TGAInfo != nullptr, "tgaInfo must not be nil"); |
| 127 | AXASSERT(position.x < _TGAInfo->width, "Invalid position.x"); |
| 128 | AXASSERT(position.y < _TGAInfo->height, "Invalid position.x"); |
| 129 | AXASSERT(tile.r != 0, "R component must be non 0"); |
| 130 | |
| 131 | Color3B* ptr = (Color3B*)_TGAInfo->imageData; |
| 132 | Color3B value = ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)]; |
| 133 | if (value.r == 0) |
| 134 | { |
| 135 | AXLOGD("Value.r must be non 0."); |
| 136 | } |
| 137 | else |
| 138 | { |
| 139 | ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)] = tile; |
| 140 | |
| 141 | // FIXME:: this method consumes a lot of memory |
| 142 | // FIXME:: a tree of something like that shall be implemented |
| 143 | std::string key = StringUtils::toString(position.x) + "," + StringUtils::toString(position.y); |
| 144 | int num = _posToAtlasIndex[key].asInt(); |
| 145 | |
| 146 | this->updateAtlasValueAt(position, tile, num); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | Color3B TileMapAtlas::getTileAt(const Vec2& position) const |
| 151 | { |
nothing calls this directly
no test coverage detected