The foundation of the civilization arc: name the world so everything civic
(territory, borders, place-of-origin) can reference it. This is pure derived
geometry + a deterministic namer, so it lives in the raylib-free engine and is
fully testable headless. No agents/clock yet -- those come in later steps.
- NameGen.{hpp,cpp} (new): deterministic procedural name generator (xorshift
syllable banks; bankForRegion gives each continent a "language" so its rivers/
mountains share a sound). Reused by the whole civ arc later.
- PlanetGeography.{hpp,cpp} (new): Planet::generateGeography() extracts named
features by connectivity over the fixed grid -- continents/islands (connected
land), oceans/seas (connected water), lakes (inland filled basins), mountain
ranges + peaks (connected high terrain), rivers (largest discharge mouths
traced upstream via flowTo). Separate RNG (sGeoRng) keeps tectonic determinism
intact; per-cell index arrays (sCellLand/Water/Range/River) give O(1) lookup.
- Save v17: geography block (feature records with names + per-cell region arrays)
appended in writeState/readState; readState gains hasGeography; pre-v17 saves
load with none (regenerated on M). geo* config knobs + validation.
- Render: key M toggles place-name labels on globe (manual projection) + 2D map
(minor features only when zoomed); a 5th "Atlas" live-info tab lists features
by kind (click a row -> focusCell); cell-info shows a "region" line. Generated
lazily on a settled world (M) or on entering Live World (W).
- test_geography.cpp (new, in CMake foreach): extraction, per-cell membership,
river-traces-to-sink, names unique/deterministic, RNG isolation, v17 round-trip.
All 8 headless suites pass; GUI build clean. Docs updated (CLAUDE/design-notes/
BUILD), incl. the multi-step civilization roadmap.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
88 lines
2.6 KiB
CMake
88 lines
2.6 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(PlanetSim CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
raylib
|
|
GIT_REPOSITORY https://github.com/raysan5/raylib.git
|
|
GIT_TAG 5.5
|
|
)
|
|
# Build raylib as a static lib, no examples.
|
|
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
|
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
|
|
FetchContent_MakeAvailable(raylib)
|
|
|
|
set(SIM_SOURCES
|
|
src/sim/IcoSphere.cpp
|
|
src/sim/Planet.cpp
|
|
src/sim/PlanetTectonics.cpp
|
|
src/sim/PlanetDrift.cpp
|
|
src/sim/PlanetErosion.cpp
|
|
src/sim/PlanetHydrology.cpp
|
|
src/sim/PlanetBiomes.cpp
|
|
src/sim/PlanetClimate.cpp
|
|
src/sim/PlanetLive.cpp
|
|
src/sim/PlanetOcean.cpp
|
|
src/sim/PlanetWeather.cpp
|
|
src/sim/PlanetVolcano.cpp
|
|
src/sim/PlanetBiota.cpp
|
|
src/sim/PlanetFloraGen.cpp
|
|
src/sim/PlanetFaunaGen.cpp
|
|
src/sim/PlanetFungiGen.cpp
|
|
src/sim/NameGen.cpp
|
|
src/sim/PlanetGeography.cpp
|
|
src/sim/PlanetIO.cpp
|
|
)
|
|
|
|
set(RENDER_SOURCES
|
|
src/render/Colors.cpp
|
|
src/render/Map2D.cpp
|
|
src/render/Overlays.cpp
|
|
src/render/Picking.cpp
|
|
src/render/Panels.cpp
|
|
src/render/Viewer.cpp
|
|
src/render/ViewerInput.cpp
|
|
src/render/ViewerRender.cpp
|
|
)
|
|
|
|
add_library(planetsim_sim STATIC ${SIM_SOURCES})
|
|
target_include_directories(planetsim_sim PUBLIC src/sim)
|
|
|
|
add_executable(planetsim
|
|
src/main.cpp
|
|
${RENDER_SOURCES}
|
|
)
|
|
# Flat includes ("Planet.hpp", "Viewer.hpp", ...) resolve across both folders.
|
|
target_include_directories(planetsim PRIVATE src/sim src/render)
|
|
target_link_libraries(planetsim PRIVATE planetsim_sim raylib)
|
|
|
|
# OpenMP parallelizes the per-cell passes in Planet::step(). Optional: without
|
|
# it the #pragma omp lines are ignored and the sim runs (correctly) serial.
|
|
find_package(OpenMP)
|
|
if(OpenMP_CXX_FOUND)
|
|
target_link_libraries(planetsim_sim PUBLIC OpenMP::OpenMP_CXX)
|
|
endif()
|
|
|
|
# Linux system libs raylib needs at link time.
|
|
if(UNIX AND NOT APPLE)
|
|
target_link_libraries(planetsim PRIVATE m pthread dl)
|
|
endif()
|
|
|
|
enable_testing()
|
|
foreach(test_name logic biota ocean live weather volcano geography)
|
|
add_executable(test_${test_name} test_${test_name}.cpp)
|
|
target_link_libraries(test_${test_name} PRIVATE planetsim_sim)
|
|
add_test(NAME ${test_name} COMMAND test_${test_name})
|
|
endforeach()
|
|
|
|
add_executable(test_events test_events.cpp ${RENDER_SOURCES})
|
|
target_include_directories(test_events PRIVATE src/sim src/render)
|
|
target_link_libraries(test_events PRIVATE planetsim_sim raylib)
|
|
if(UNIX AND NOT APPLE)
|
|
target_link_libraries(test_events PRIVATE m pthread dl)
|
|
endif()
|
|
add_test(NAME events COMMAND test_events)
|