载入中...
搜索中...
未找到
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.originX = cfg.originX;
28 g.originY = cfg.originY;
29 g.staggerAxis = cfg.staggerAxis == StaggerAxis::Y ? grid::StaggerAxis::Y
31 g.staggerIndex = cfg.staggerIndex == StaggerIndex::Odd ? grid::StaggerIndex::Odd
33 g.hexSideLength = cfg.hexSideLength;
34 return g;
35}
36
37} // namespace
38
39void tileToWorld(const TileLayer::Config &cfg, int tx, int ty, float &wx, float &wy) {
40 grid::cellToWorld(toGridConfig(cfg), tx, ty, wx, wy);
41}
42
43float tileToDepthY(const TileLayer::Config &cfg, int tx, int ty) {
44 return grid::cellToDepthY(toGridConfig(cfg), tx, ty);
45}
46
47void worldToTile(const TileLayer::Config &cfg, float wx, float wy, int &tx, int &ty) {
48 grid::worldToCell(toGridConfig(cfg), wx, wy, tx, ty, cfg.mapW, cfg.mapH);
49}
50
51} // namespace eve::map
void cellToWorld(const GridConfig &cfg, int cx, int cy, float &px, float &py)
void worldToCell(const GridConfig &cfg, float px, float py, int &cx, int &cy, int mapW, int mapH)
float cellToDepthY(const GridConfig &cfg, int cx, int cy)
放置世界:格子占用(多通道)+ 地形语义 + 已放置建筑实例。 行为由 PlacementSystem 提供;本类暴露便于脚本绑定的薄封装方法。 坐标换算统一走 eve::grid(支持 rectang...
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.
void worldToTile(const TileLayer::Config &cfg, float wx, float wy, int &tx, int &ty)
Converts world pixels back to the containing tile index.
float tileToDepthY(const TileLayer::Config &cfg, int tx, int ty)
Painter's-algorithm depth for the tile under the layer's projection.