refactor: eliminate globals, add pen tool + edit mode, frustum culling

Remove all file-scope mutable state so the codebase compiles cleanly
as a single translation unit. State moved into structs owned by
userdata_t:

- group_index_ctx_t replaces g_group_by_id/g_group_by_id_cap
- shape_pool_ctx_t replaces g_shape_pool_dirty/g_shape_data_dirty
  and g_shape_groups/g_shape_groups_count
- panel_log_ctx_t wired through all subsystems explicitly
- pipeline_ctx_t owns render pipeline handles
- overlay_upload_state_t (per-buffer flags) replaces single bool

New features piggybacking on the refactor:

- Pen tool: click-to-place anchors, Catmull-Rom preview, finalize
  into Bezier shapes with control points
- Edit mode: anchor/handle hit testing, dragging, pre-drag undo
  snapshots, dedicated GPU buffers for edit overlays
- Frustum culling: spatial-grid-based viewport cull in draw_shapes
  with linear-scan fallback for oversized viewports
- Log dedup: FNV-1a 64-bit hash to skip duplicate messages
- Buffer shrink: halve draw buffers after 60 frames of low usage
- Shape geometry hashing for instanced-draw vertex-buffer grouping
- Group member_indices arrays with O(n) rebuild
- Log ring expanded 64→256 entries, added log_filter

Debug build: added --profiling-funcs and -sASSERTIONS flags.
This commit is contained in:
2026-05-03 00:38:45 +02:00
parent c4d657043c
commit 7e3da1c424
19 changed files with 2610 additions and 2945 deletions

14
src/globals.h Normal file
View File

@@ -0,0 +1,14 @@
// Context struct declarations are now defined alongside the code they
// belong to rather than in a single header:
//
// panel_log_ctx_t — api.h
// shape_pool_ctx_t — shape.h (after shape_t / group_t)
// group_index_ctx_t — shape.h
// pipeline_ctx_t — render.h
// shape_group_buf_t — shape.h
//
// This header exists only to avoid breaking includes elsewhere and can
// be removed once all consumers are updated.
#ifndef GLOBALS_H
#define GLOBALS_H
#endif