planetsim/src/render/Picking.hpp
Jonas Reith acc0e5eec9 Initial commit: fanworgen planet sim
C++/raylib semi-realistic fantasy/sci-fi planet generator on a fixed icosphere
grid (Eulerian: properties flow over fixed cells). World-creation stages:
tectonics, continental drift & erosion, hydrology (rivers/lakes), climate
(temperature + orographic precipitation), and biome classification. Engine in
src/sim (raylib-free, headless-testable), viewer in src/render. See CLAUDE.md
and docs/ (design-notes.md, fauna-flora-plan.md = next step).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 15:08:25 +02:00

20 lines
869 B
C++

#pragma once
#include "raylib.h"
#include "Vec3.hpp"
#include "Planet.hpp"
// Mouse-picking helpers: ray from the 3D viewport, sphere intersection, nearest
// cell to a direction, and angular distance between two unit directions.
// Custom camera ray for the 3D viewport (GetScreenToWorldRay assumes the full
// screen; the globe occupies only the top-left quadrant).
Vec3 rayDirFromMouse(Vector3 pos, Vector3 target, float fovyDeg,
float mx, float my, float vw, float vh);
bool raySphere(Vec3 o, Vec3 d, double R, Vec3& hitUnit);
int nearestCell(const Planet& p, const Vec3& dir);
double angBetween(const Vec3& a, const Vec3& b);
// Rotate v by `deg` degrees CCW about the world +Z axis (matches rlRotatef(deg,0,0,1)).
// Used for the axial-tilt transform: +tilt maps model->world, -tilt world->model.
Vec3 rotateZ(const Vec3& v, double deg);