[PR #1208] [MERGED] Perlin noise without libm floor or int-to-float conversions, same values #3422

Closed
opened 2026-11-03 04:09:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1208
Author: @pirut
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @ludovic111

Base: main ← Head: claude/upstream-perlin-floor


📝 Commits (2)

  • 5bad717 Perlin noise without libm floor or int-to-float conversions, same values
  • a49cf55 geometry: floor_i32 saturates below i32::MIN, as (int) Math.floor

📊 Changes

3 files changed (+74 additions, -12 deletions)

View changed files

📝 crates/horizon-core/src/geometry/mod.rs (+47 -1)
📝 crates/horizon-core/src/noise/mod.rs (+20 -4)
📝 crates/horizon-core/src/noise/perlin.rs (+7 -7)

📄 Description

Requested by JR

What and why

Perlin noise without libm floor or int-to-float conversions, same values

floor_i32 is now Java's Mth.floor (truncate, step down for negative
fractions): f64::floor is a libm call on baseline x86-64, made for every
Perlin sample. Perlin's gradient table is stored as floats (every
component is -1, 0 or 1, exact either way), so the corner dot products
skip three conversions each. About 10% fewer instructions generating
terrain; values unchanged.

Vanilla reference

Mth.floor (truncate, then step down for negative fractions) and ImprovedNoise's gradient dot products: values unchanged. Harnesses: test_noise_parity.py, test_terrain_parity.py.

Self-check

pr_ready (tools/pr_ready.py --base upstream/main on Mac, against upstream/main at e730dc142, 39 s)

Check Result
Scope ✅ 3 files, +60 −12
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (4 s)
clippy ✅ (18 s)
tests: horizon-core ✅ 104 passed (15 s)
doc tests ✅ 0 passed (1 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/1208 **Author:** [@pirut](https://github.com/pirut) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `claude/upstream-perlin-floor` --- ### 📝 Commits (2) - [`5bad717`](https://github.com/horizon-rust/horizon/commit/5bad717213c5119dd1d0bbfbf134ec44f6c9a6f2) Perlin noise without libm floor or int-to-float conversions, same values - [`a49cf55`](https://github.com/horizon-rust/horizon/commit/a49cf5502d187daae072a039468a156226d90533) geometry: floor_i32 saturates below i32::MIN, as (int) Math.floor ### 📊 Changes **3 files changed** (+74 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-core/src/geometry/mod.rs` (+47 -1) 📝 `crates/horizon-core/src/noise/mod.rs` (+20 -4) 📝 `crates/horizon-core/src/noise/perlin.rs` (+7 -7) </details> ### 📄 Description <!-- claude-projects-attribution: {"github_login":"pirut"} --> _Requested by **JR**_ ## What and why Perlin noise without libm floor or int-to-float conversions, same values floor_i32 is now Java's Mth.floor (truncate, step down for negative fractions): f64::floor is a libm call on baseline x86-64, made for every Perlin sample. Perlin's gradient table is stored as floats (every component is -1, 0 or 1, exact either way), so the corner dot products skip three conversions each. About 10% fewer instructions generating terrain; values unchanged. ## Vanilla reference `Mth.floor` (truncate, then step down for negative fractions) and `ImprovedNoise`'s gradient dot products: values unchanged. Harnesses: `test_noise_parity.py`, `test_terrain_parity.py`. ## Self-check **pr_ready** (`tools/pr_ready.py --base upstream/main` on Mac, against upstream/main at e730dc142, 39 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +60 −12 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (4 s) | | clippy | ✅ (18 s) | | tests: horizon-core | ✅ 104 passed (15 s) | | doc tests | ✅ 0 passed (1 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:09:25 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3422
No description provided.