载入中...
搜索中...
未找到
TileProjection.cpp
浏览该文件的文档.
2
3#include "grid/GridConfig.h"
5
6namespace eve::map {
7namespace {
8
9grid::GridConfig toGridConfig(const TileLayer::Config &cfg) {
10 grid::GridConfig g;
11 switch (cfg.orientation) {
14 break;
17 break;
20 break;
23 break;
24 }
25 g.cellW = cfg.tileW;
26 g.cellH = cfg.tileH;
27 g.cellGapX = cfg.cellGapX;
28 g.cellGapY = cfg.cellGapY;
29 g.originX = cfg.originX;
30 g.originY = cfg.originY;
31 g.staggerAxis = cfg.staggerAxis == StaggerAxis::Y ? grid::StaggerAxis::Y
33 g.staggerIndex = cfg.staggerIndex == StaggerIndex::Odd ? grid::StaggerIndex::Odd
35 g.hexSideLength = cfg.hexSideLength;
36 return g;
37}
38
39} // namespace
40
41void tileToWorld(const TileLayer::Config &cfg, int tx, int ty, float &wx, float &wy) {
42 grid::cellToWorld(toGridConfig(cfg), tx, ty, wx, wy);
43}
44
45float tileToDepthY(const TileLayer::Config &cfg, int tx, int ty) {
46 return grid::cellToDepthY(toGridConfig(cfg), tx, ty);
47}
48
49void worldToTile(const TileLayer::Config &cfg, float wx, float wy, int &tx, int &ty) {
50 grid::worldToCell(toGridConfig(cfg), wx, wy, tx, ty, cfg.mapW, cfg.mapH);
51}
52
53} // namespace eve::map
tensor::Graph g
Definition GpuGraph.cpp:7
Module-neutral grid topology and sizing (no building/map dependency).
Pure cell/world projection helpers for GridConfig.
float wx
float wy
void worldToCell(const GridConfig &cfg, float px, float py, int &cx, int &cy, int mapW, int mapH)
Maps planar coordinates to the nearest cell. Staggered/hex layouts use a bounded nearest-neighbor sea...
float cellToDepthY(const GridConfig &cfg, int cx, int cy)
2D sort key (cell foot Y), matching map::tileToDepthY semantics. Unused on the XZ plane.
void cellToWorld(const GridConfig &cfg, int cx, int cy, float &px, float &py)
Maps a cell to planar coordinates (px, py). On XY plane these are world (x, y); on XZ plane they are ...
放置世界:格子占用(多通道)+ 地形语义 + 已放置建筑实例。 行为由 PlacementSystem 提供;本类暴露便于脚本绑定的薄封装方法。 坐标换算统一走 eve::grid(支持 rectang...
void worldToTile(const TileLayer::Config &cfg, float wx, float wy, int &tx, int &ty)
Converts world pixels back to the containing tile index.
void tileToWorld(const TileLayer::Config &cfg, int tx, int ty, float &wx, float &wy)
Converts a tile index to world pixels using the layer's projection.
float tileToDepthY(const TileLayer::Config &cfg, int tx, int ty)
Painter's-algorithm depth for the tile under the layer's projection.
Config public API.
Definition TileLayer.h:41