5 Struct ISO_MAP
gullradriel edited this page 2026-10-09 00:55:18 +02:00

ISO_MAP

Module: GRAPHICS: isometric engine, maps, tiles, ...

Height-aware isometric map with terrain and height layers, per-cell height values, configurable projection, and terrain transition support.

#include "n_iso_engine.h"

Public Attributes

Name
int width
map width in tiles (X axis)
int * terrain
terrain type per cell [height * width], indices 0..num_terrains-1
int smooth_slope_max
max height diff rendered as slope (default 1)
int smooth_height
0 = CUT mode (cliff walls), 1 = SMOOTH mode (per-corner slopes)
int show_grid
1 = draw grid overlay
ISO_TILE_SEGMENTS * segments
Per-cell height segments.
ISO_PROJECTION proj
current projection parameters
int * overlay
overlay tile index per cell [height * width], 0 = none.
int num_terrains
number of terrain types used
int * neighbor_terrains_west
[height], terrain of west neighbor's east edge
int * neighbor_terrains_south
[width], terrain of south neighbor's north edge
int * neighbor_terrains_north
[width], terrain of north neighbor's south edge
int * neighbor_terrains_east
[height], terrain of east neighbor's west edge
int * neighbor_heights_west
Heights from west neighbor chunk's east edge [height], NULL = boundary.
int * neighbor_heights_south
Heights from south neighbor chunk's north edge [width], NULL = boundary.
int * neighbor_heights_north
Heights from north neighbor chunk's south edge [width], NULL = boundary.
int * neighbor_heights_east
Heights from east neighbor chunk's west edge [height], NULL = boundary.
int max_height
maximum allowed height value
int hover_my
hovered tile Y (-1 = none)
int hover_mx
hovered tile X (-1 = none)
int * heightmap
height value per cell [height * width], 0..max_height
float height_tint_intensity
0.0 = no tint, 0.3 = subtle, 1.0 = full range.
int height
map height in tiles (Y axis)
float * dynamic_light_map
Per-tile dynamic light accumulation buffer.
int draw_order_dirty
int cached_draw_order_count
int cached_draw_order_cap
ISO_DRAW_ENTRY * cached_draw_order
Cached draw_order.
float ambient_r
Global ambient color (day/night + dark place tinting).
float ambient_g
float ambient_b
int * ability
walkability per cell [height * width] (WALK/SWIM/BLCK)

Public Attributes Documentation

variable width

int width;

map width in tiles (X axis)

variable terrain

int * terrain;

terrain type per cell [height * width], indices 0..num_terrains-1

variable smooth_slope_max

int smooth_slope_max;

max height diff rendered as slope (default 1)

variable smooth_height

int smooth_height;

0 = CUT mode (cliff walls), 1 = SMOOTH mode (per-corner slopes)

variable show_grid

int show_grid;

1 = draw grid overlay

variable segments

ISO_TILE_SEGMENTS * segments;

Per-cell height segments.

NULL = use heightmap as single segment. When non-NULL, heightmap[] is derived (top of highest segment).

variable proj

ISO_PROJECTION proj;

current projection parameters

variable overlay

int * overlay;

overlay tile index per cell [height * width], 0 = none.

NULL = no overlays

variable num_terrains

int num_terrains;

number of terrain types used

variable neighbor_terrains_west

int * neighbor_terrains_west;

[height], terrain of west neighbor's east edge

variable neighbor_terrains_south

int * neighbor_terrains_south;

[width], terrain of south neighbor's north edge

variable neighbor_terrains_north

int * neighbor_terrains_north;

[width], terrain of north neighbor's south edge

variable neighbor_terrains_east

int * neighbor_terrains_east;

[height], terrain of east neighbor's west edge

variable neighbor_heights_west

int * neighbor_heights_west;

Heights from west neighbor chunk's east edge [height], NULL = boundary.

variable neighbor_heights_south

int * neighbor_heights_south;

Heights from south neighbor chunk's north edge [width], NULL = boundary.

variable neighbor_heights_north

int * neighbor_heights_north;

Heights from north neighbor chunk's south edge [width], NULL = boundary.

variable neighbor_heights_east

int * neighbor_heights_east;

Heights from east neighbor chunk's west edge [height], NULL = boundary.

variable max_height

int max_height;

maximum allowed height value

variable hover_my

int hover_my;

hovered tile Y (-1 = none)

variable hover_mx

int hover_mx;

hovered tile X (-1 = none)

variable heightmap

int * heightmap;

height value per cell [height * width], 0..max_height

variable height_tint_intensity

float height_tint_intensity;

0.0 = no tint, 0.3 = subtle, 1.0 = full range.

Higher segments are brighter, lower are darker. Applied as a multiply tint on tile top faces and walls.

variable height

int height;

map height in tiles (Y axis)

variable dynamic_light_map

float * dynamic_light_map;

Per-tile dynamic light accumulation buffer.

Caller fills this before iso_map_draw() with additive light contributions. Array of [width * height * 3] floats (r, g, b per tile). NULL = no dynamic lighting. Caller-owned.

variable draw_order_dirty

int draw_order_dirty;

variable cached_draw_order_count

int cached_draw_order_count;

variable cached_draw_order_cap

int cached_draw_order_cap;

variable cached_draw_order

ISO_DRAW_ENTRY * cached_draw_order;

Cached draw_order.

The qsort+build in [iso_map_build_draw_order](Module-ISOMETRIC_ENGINE#user-content-function-iso_map_build_draw_order) is expensive (1024+ entries x 25 chunks per frame = ~3 ms in profiled bench). Cache the result on the map and only rebuild when segments or heights change. Setters that mutate either field ([iso_map_set_segments](Module-ISOMETRIC_ENGINE#user-content-function-iso_map_set_segments) is the only public one) set [draw_order_dirty](Struct-ISO_MAP#user-content-variable-draw_order_dirty) = 1. [iso_map_draw](Module-ISOMETRIC_ENGINE#user-content-function-iso_map_draw) rebuilds into [cached_draw_order](Struct-ISO_MAP#user-content-variable-cached_draw_order) when dirty, then reuses across frames. Lifetime tied to the map; freed in [iso_map_free](Module-ISOMETRIC_ENGINE#user-content-function-iso_map_free).

variable ambient_r

float ambient_r;

Global ambient color (day/night + dark place tinting).

Applied as additional multiply on top of height tinting. Default: (1.0, 1.0, 1.0) = no change. Set by client lighting system each frame.

variable ambient_g

float ambient_g;

variable ambient_b

float ambient_b;

variable ability

int * ability;

walkability per cell [height * width] (WALK/SWIM/BLCK)