Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ jobs:
- uses: Swatinem/rust-cache@v2

- name: Generate SVG
run: cargo run -p hex-grid --example svg --release -- 3 2.0 > hex-grid.svg
run: cargo run -p apicult-desigual --example svg --release -- 3 2.0 > apicult-desigual.svg

- name: Create release and attach SVG
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ inputs.tag || github.ref_name }}"
gh release create "$TAG" --generate-notes || true
gh release upload "$TAG" hex-grid.svg --clobber
gh release upload "$TAG" apicult-desigual.svg --clobber
2 changes: 1 addition & 1 deletion .github/workflows/svg-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: SVG Preview
on:
push:
paths:
- "crates/hex-grid/**"
- "crates/apicult-desigual/**"
- "web/svg-preview.html"
- "web/hex-terrain.html"
- "web/hex-terrain.js"
Expand Down
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["crates/mesh-gradient", "crates/hex-grid", "crates/flora"]
members = ["crates/mesh-gradient", "crates/apicult-desigual", "crates/flora"]

[package]
name = "hex-terrain"
Expand Down Expand Up @@ -54,7 +54,7 @@ bevy-inspector-egui = { version = "0.36", optional = true }
bevy_egui = "0.39"
hexx = { version = "0.24.0", features = ["bevy"] }
mesh-gradient = { path = "crates/mesh-gradient" }
hex-grid = { path = "crates/hex-grid" }
apicult-desigual = { path = "crates/apicult-desigual" }
flora = { path = "crates/flora" }

[lints.rust]
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ svg-prep:
@mkdir -p $(SVG_OUT)

svg-plain: svg-prep
cargo run -q -p hex-grid --example geo_export --release -- $(SVG_RADIUS) $(SVG_PAD) > $(SVG_OUT)/hex-grid.svg
cargo run -q -p apicult-desigual --example geo_export --release -- $(SVG_RADIUS) $(SVG_PAD) > $(SVG_OUT)/apicult-desigual.svg

svg-rich: svg-prep
cargo run -q -p hex-grid --example geo_export --release -- $(SVG_RADIUS) $(SVG_PAD) --format svg-rich > $(SVG_OUT)/hex-grid-rich.svg
cargo run -q -p apicult-desigual --example geo_export --release -- $(SVG_RADIUS) $(SVG_PAD) --format svg-rich > $(SVG_OUT)/apicult-desigual-rich.svg

svg-json: svg-prep
cargo run -q -p hex-grid --example geo_export --release -- $(SVG_RADIUS) $(SVG_PAD) --format json-v1 > $(SVG_OUT)/hex-grid.json
cargo run -q -p apicult-desigual --example geo_export --release -- $(SVG_RADIUS) $(SVG_PAD) --format json-v1 > $(SVG_OUT)/apicult-desigual.json

svg-json-v2: svg-prep
cargo run -q -p hex-grid --example geo_export --release -- $(SVG_RADIUS) $(SVG_PAD) --format json-v2 > $(SVG_OUT)/hex-terrain.json
cargo run -q -p apicult-desigual --example geo_export --release -- $(SVG_RADIUS) $(SVG_PAD) --format json-v2 > $(SVG_OUT)/hex-terrain.json

svg-html: svg-prep
sed "s|__SHA__|$(SHORT_SHA)|g" web/svg-preview.html > $(SVG_OUT)/index.html
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ graph LR
end
```

![hex-grid preview](https://dynnamitt.github.io/hex-terrain/svg/hex-grid.svg)
![apicult-desigual preview](https://dynnamitt.github.io/hex-terrain/svg/apicult-desigual.svg)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "hex-grid"
name = "apicult-desigual"
version = "0.1.0"
edition = "2024"

Expand Down
12 changes: 6 additions & 6 deletions crates/hex-grid/README.md → crates/apicult-desigual/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# hex-grid
# apicult-desigual

## 🌐 [**Live WebGL demo →**](https://dynnamitt.github.io/hex-terrain/svg/)

Expand All @@ -20,7 +20,7 @@ Zero game-engine dependencies -- uses `glam` for vectors, `hexx` for hex coordin
## Usage

```rust
use hex_grid::{HGridLayout, HGridSettings};
use apicult_desigual::{HGridLayout, HGridSettings};

let settings = HGridSettings { radius: 10, ..HGridSettings::default() };
let layout = HGridLayout::from_settings(&settings);
Expand All @@ -38,10 +38,10 @@ let tris = layout.all_tris();
The `geo_export` example streams the grid to stdout in any of the supported formats. It's the same binary that drives the [live WebGL demo](https://dynnamitt.github.io/hex-terrain/svg/):

```sh
cargo run -p hex-grid --example geo_export # plain SVG (gray, no labels)
cargo run -p hex-grid --example geo_export -- 5 2.0 --format svg-rich # green fill, outlined strokes, height labels
cargo run -p hex-grid --example geo_export -- 5 2.0 --format json-v1 # gen1: {hexes, edges, quads, tris}
cargo run -p hex-grid --example geo_export -- 5 2.0 --format json-v2 # gen2: {version: 2, tris} — welded-mesh consumers
cargo run -p apicult-desigual --example geo_export # plain SVG (gray, no labels)
cargo run -p apicult-desigual --example geo_export -- 5 2.0 --format svg-rich # green fill, outlined strokes, height labels
cargo run -p apicult-desigual --example geo_export -- 5 2.0 --format json-v1 # gen1: {hexes, edges, quads, tris}
cargo run -p apicult-desigual --example geo_export -- 5 2.0 --format json-v2 # gen2: {version: 2, tris} — welded-mesh consumers
```

`--rich` and `--json` remain as backward-compat aliases for `--format svg-rich` and `--format json-v1`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
//! Export hex-grid geometry as SVG or JSON via the [`SerializeGeo`] trait.
//! Export apicult-desigual geometry as SVG or JSON via the [`SerializeGeo`] trait.
//!
//! ```sh
//! cargo run -p hex-grid --example geo_export # plain SVG
//! cargo run -p hex-grid --example geo_export -- 5 2.0 # plain SVG, custom radius/pad
//! cargo run -p hex-grid --example geo_export -- 5 2.0 --format svg-rich # rich SVG
//! cargo run -p hex-grid --example geo_export -- 5 2.0 --format json-v1 # gen1 JSON
//! cargo run -p hex-grid --example geo_export -- 5 2.0 --format json-v2 # gen2 JSON (tris only)
//! cargo run -p apicult-desigual --example geo_export # plain SVG
//! cargo run -p apicult-desigual --example geo_export -- 5 2.0 # plain SVG, custom radius/pad
//! cargo run -p apicult-desigual --example geo_export -- 5 2.0 --format svg-rich # rich SVG
//! cargo run -p apicult-desigual --example geo_export -- 5 2.0 --format json-v1 # gen1 JSON
//! cargo run -p apicult-desigual --example geo_export -- 5 2.0 --format json-v2 # gen2 JSON (tris only)
//! ```
//!
//! Backward-compat aliases: `--rich` → `--format svg-rich`, `--json` → `--format json-v1`.

use std::io::{self, Write};

use hex_grid::{HGridLayout, HGridSettings, JsonV1, JsonV2, SerializeGeo, SvgPlain, SvgRich};
use apicult_desigual::{
HGridLayout, HGridSettings, JsonV1, JsonV2, SerializeGeo, SvgPlain, SvgRich,
};

fn main() {
let mut positional: Vec<String> = Vec::new();
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Pure computation helpers for hex-grid geometry.
//! Pure computation helpers for apicult-desigual geometry.
//!
//! All functions operate on plain numeric / `glam` inputs with no ECS dependencies.

Expand All @@ -12,7 +12,7 @@ use hexx::{EdgeDirection, GridVertex, Hex, VertexDirection};
///
/// # Examples
/// ```
/// # use hex_grid::math::map_noise_to_range;
/// # use apicult_desigual::math::map_noise_to_range;
/// assert_eq!(map_noise_to_range(-1.0, 0.0, 10.0), 0.0);
/// assert_eq!(map_noise_to_range( 1.0, 0.0, 10.0), 10.0);
/// assert_eq!(map_noise_to_range( 0.0, 2.0, 6.0), 4.0);
Expand Down Expand Up @@ -41,7 +41,7 @@ pub fn gap_vertex_data(world_verts: &[Vec3], flat: bool) -> (Vec<[f32; 3]>, [f32
}

/// Count total (quads, tris) for a grid using the same ownership rules
/// as hex-grid generation: quads on even edges \[0,2,4\] where neighbor exists,
/// as apicult-desigual generation: quads on even edges \[0,2,4\] where neighbor exists,
/// tris on vertices \[0,1\] with canonical ownership and all 3 coords in grid.
pub fn gap_filler(grid: &[Hex]) -> (usize, usize) {
let quads = grid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use hexx::{Hex, shapes};

use crate::HGridLayout;

/// Streamed serialization of a hex-grid layout to bytes.
/// Streamed serialization of an apicult-desigual layout to bytes.
pub trait SerializeGeo {
fn write(&self, layout: &HGridLayout, out: &mut dyn io::Write) -> io::Result<()>;
}
Expand Down
4 changes: 2 additions & 2 deletions src/h_terrain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use bevy::prelude::*;
use crate::{DebugFlag, GameState};
use fov_overlay::FovMaterial;

pub use apicult_desigual::edge_cuboid_transform;
pub use entities::InSight;
pub use hex_grid::edge_cuboid_transform;

/// Pipeline ordering for h_terrain update systems.
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -120,7 +120,7 @@ pub struct HGridSettings {
pub flat_gap_normals: bool,
}

impl From<&HGridSettings> for hex_grid::HGridSettings {
impl From<&HGridSettings> for apicult_desigual::HGridSettings {
fn from(s: &HGridSettings) -> Self {
Self {
radius: s.radius,
Expand Down
2 changes: 1 addition & 1 deletion src/h_terrain/flora_spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use bevy::platform::collections::HashMap;
use bevy::prelude::*;
use hexx::Hex;

use apicult_desigual::HGridLayout;
use flora::cluster::shimeji_cluster;
use flora::{FloraCfg, FloraMaterials};
use hex_grid::HGridLayout;

use super::mineral::{Mineral, hash_hex};

Expand Down
2 changes: 1 addition & 1 deletion src/h_terrain/gaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::entities::{
};
use super::h_grid_layout::HGridLayout;
use super::mineral::Mineral;
use hex_grid::{edge_cuboid_transform, gap_vertex_data, quad_corner_indices};
use apicult_desigual::{edge_cuboid_transform, gap_vertex_data, quad_corner_indices};

pub(super) const EDGE_THICKNESS: f32 = 0.03;
pub(super) const DBG_NORMAL_LEN: f32 = 0.3;
Expand Down
6 changes: 3 additions & 3 deletions src/h_terrain/h_grid_layout.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! Re-exports [`hex_grid::HGridLayout`] and bridges from h_terrain's [`HGridSettings`].
//! Re-exports [`apicult_desigual::HGridLayout`] and bridges from h_terrain's [`HGridSettings`].

use super::HGridSettings;

pub use hex_grid::HGridLayout;
pub use apicult_desigual::HGridLayout;

impl HGridSettings {
/// Build an [`HGridLayout`] from these settings.
pub fn build_layout(&self) -> HGridLayout {
HGridLayout::from_settings(&hex_grid::HGridSettings::from(self))
HGridLayout::from_settings(&apicult_desigual::HGridSettings::from(self))
}
}
2 changes: 1 addition & 1 deletion src/h_terrain/startup_systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::gaps;
use super::materials::TerrainMaterials;
use super::mineral::Mineral;
use crate::DebugFlag;
use hex_grid::{edge_cuboid_transform, gap_filler};
use apicult_desigual::{edge_cuboid_transform, gap_filler};

/// Spawns the [`HGrid`] entity with [`HCell`] children, [`Corner`] grandchildren,
/// and Quad/Tri gap geometry with distributed emitter markers.
Expand Down
2 changes: 1 addition & 1 deletion src/h_terrain/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use super::fov_overlay::FovMaterial;
use super::materials::TerrainMaterials;
use super::{HTerrainConfig, HTerrainPhase, materials, startup_systems, systems};
use crate::{DebugFlag, GameState, GroundLevel, PlayerMoved, PlayerPos};
use hex_grid::gap_filler;
use apicult_desigual::gap_filler;

fn test_config() -> HTerrainConfig {
HTerrainConfig {
Expand Down
2 changes: 1 addition & 1 deletion web/hex-terrain.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ not a performance term.
seams, you'd get hairline cracks where a hex face meets a gap quad —
not from rendering artifacts but from floating-point drift if positions
were re-emitted from different code paths. The Rust crate's
`HGridLayout::vertex(hex, i)` (`crates/hex-grid/src/layout.rs:143-150`)
`HGridLayout::vertex(hex, i)` (`crates/apicult-desigual/src/layout.rs:143-150`)
returning identical `Vec3` for shared corners is what makes the weld
watertight.
2. **Free smooth shading at seams** — when `computeVertexNormals()` runs
Expand Down
16 changes: 8 additions & 8 deletions web/svg-preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>hex-grid preview</title>
<title>apicult-desigual preview</title>
<style>
body { margin: 0; background: #050810; display: flex; flex-direction: column; align-items: center; min-height: 100vh; font-family: monospace; color: #aaa; }
h1 { margin: 1.5rem 0 0.5rem; font-size: 1.2rem; font-weight: normal; }
Expand All @@ -29,20 +29,20 @@
</script>
</head>
<body>
<h1>hex-grid terrain preview</h1>
<h1>apicult-desigual terrain preview</h1>
<p class="meta">generated from <a href="https://github.com/dynnamitt/hex-terrain">dynnamitt/hex-terrain</a> &mdash; <span id="sha">__SHA__</span> &middot; <a href="hex-terrain.html">welded terrain</a></p>
<div class="terrain-wrap">
<canvas id="terrain"></canvas>
<p class="hint">drag to orbit &middot; scroll to zoom &middot; right-drag to pan</p>
</div>
<div class="grid">
<figure>
<object data="hex-grid.svg" type="image/svg+xml">SVG not available</object>
<figcaption>plain &mdash; <a href="hex-grid.svg">hex-grid.svg</a></figcaption>
<object data="apicult-desigual.svg" type="image/svg+xml">SVG not available</object>
<figcaption>plain &mdash; <a href="apicult-desigual.svg">apicult-desigual.svg</a></figcaption>
</figure>
<figure>
<object data="hex-grid-rich.svg" type="image/svg+xml">SVG not available</object>
<figcaption>rich &mdash; <a href="hex-grid-rich.svg">hex-grid-rich.svg</a></figcaption>
<object data="apicult-desigual-rich.svg" type="image/svg+xml">SVG not available</object>
<figcaption>rich &mdash; <a href="apicult-desigual-rich.svg">apicult-desigual-rich.svg</a></figcaption>
</figure>
</div>

Expand All @@ -58,8 +58,8 @@ <h1>hex-grid terrain preview</h1>
};

try {
const res = await fetch('hex-grid.json');
if (!res.ok) throw new Error(`hex-grid.json ${res.status}`);
const res = await fetch('apicult-desigual.json');
if (!res.ok) throw new Error(`apicult-desigual.json ${res.status}`);
const { hexes, edges } = await res.json();

const scene = new THREE.Scene();
Expand Down
Loading