Crimson Engine 1.0.0
A high-performance C++20 game engine prototype showcasing a custom ECS, Vulkan renderer, and ImGui editor.
Loading...
Searching...
No Matches
Engine::TilesetAsset Struct Reference

A disk asset (.tileset JSON) that owns an ordered list of TileAssets. At runtime, a CPU-side atlas is built by packing every tile texture into a single RGBA image, which is uploaded to Vulkan once. This gives the TilemapSystem a single draw call per tilemap. More...

#include <TilesetAsset.hpp>

Classes

struct  AtlasCache

Public Member Functions

void buildAtlas (VulkanRenderer &renderer)
 Rebuilds the CPU-side atlas from tiles[].texturePath entries, uploads it as a Vulkan texture, and fills tiles[].atlasUV. If a tile's texture cannot be loaded, a solid magenta 1×1 tile is used.
void destroyAtlas (VulkanRenderer &renderer)
 Frees the GPU-side atlas resources if they exist.

Static Public Member Functions

static TilesetAsset loadFromFile (const std::string &path)
 Loads a TilesetAsset from a .tileset JSON file. Individual tile paths listed in the file are loaded as TileAssets.
static void saveToFile (const TilesetAsset &ts)
 Saves the TilesetAsset to its filePath on disk (.tileset JSON). Does NOT write individual .tile files; use saveTileFile() for that.
static TileAsset loadTileFile (const std::string &path)
 Loads a single TileAsset from a .tile JSON file.
static void saveTileFile (const TileAsset &tile, const std::string &path)
 Saves a single TileAsset to a .tile JSON file.

Public Attributes

std::string name
 Display name of the tileset.
std::string filePath
 Absolute (or project-relative) path to the .tileset file.
int tileWidth = 16
 Width of each tile cell in the packed atlas (pixels).
int tileHeight = 16
 Height of each tile cell in the packed atlas (pixels).
std::vector< TileAsset > tiles
 Ordered list of tile slots. tiles[i].id == i. Index is the value stored in TilemapComponent::tiles[].
AtlasCache atlas

Detailed Description

A disk asset (.tileset JSON) that owns an ordered list of TileAssets. At runtime, a CPU-side atlas is built by packing every tile texture into a single RGBA image, which is uploaded to Vulkan once. This gives the TilemapSystem a single draw call per tilemap.

Member Function Documentation

◆ buildAtlas()

void Engine::TilesetAsset::buildAtlas ( VulkanRenderer & renderer)

Rebuilds the CPU-side atlas from tiles[].texturePath entries, uploads it as a Vulkan texture, and fills tiles[].atlasUV. If a tile's texture cannot be loaded, a solid magenta 1×1 tile is used.

Parameters
rendererActive VulkanRenderer (used for GPU upload).

◆ destroyAtlas()

void Engine::TilesetAsset::destroyAtlas ( VulkanRenderer & renderer)

Frees the GPU-side atlas resources if they exist.

Parameters
rendererActive VulkanRenderer.

◆ loadFromFile()

TilesetAsset Engine::TilesetAsset::loadFromFile ( const std::string & path)
static

Loads a TilesetAsset from a .tileset JSON file. Individual tile paths listed in the file are loaded as TileAssets.

Parameters
pathPath to the .tileset file.
Returns
Loaded TilesetAsset (name and filePath set; tiles populated). Returns a default-constructed asset on error.

◆ loadTileFile()

TileAsset Engine::TilesetAsset::loadTileFile ( const std::string & path)
static

Loads a single TileAsset from a .tile JSON file.

Parameters
pathPath to the .tile file.
Returns
Loaded TileAsset.

◆ saveTileFile()

void Engine::TilesetAsset::saveTileFile ( const TileAsset & tile,
const std::string & path )
static

Saves a single TileAsset to a .tile JSON file.

Parameters
tileThe tile to persist.
pathDestination .tile file path.

◆ saveToFile()

void Engine::TilesetAsset::saveToFile ( const TilesetAsset & ts)
static

Saves the TilesetAsset to its filePath on disk (.tileset JSON). Does NOT write individual .tile files; use saveTileFile() for that.

Parameters
tsThe tileset to persist.

Member Data Documentation

◆ atlas

AtlasCache Engine::TilesetAsset::atlas

◆ filePath

std::string Engine::TilesetAsset::filePath

Absolute (or project-relative) path to the .tileset file.

◆ name

std::string Engine::TilesetAsset::name

Display name of the tileset.

◆ tileHeight

int Engine::TilesetAsset::tileHeight = 16

Height of each tile cell in the packed atlas (pixels).

◆ tiles

std::vector<TileAsset> Engine::TilesetAsset::tiles

Ordered list of tile slots. tiles[i].id == i. Index is the value stored in TilemapComponent::tiles[].

◆ tileWidth

int Engine::TilesetAsset::tileWidth = 16

Width of each tile cell in the packed atlas (pixels).


The documentation for this struct was generated from the following files: