Commit Graph
7 Commits
Author SHA1 Message Date
waozi 2423b97a0c scene/property/signal/transform: drop the Kry/Kryon prefix from the public API
KryScene->Scene, KryNode->Node, KryonProperty*->Property*,
KrySignal*->Signal*, KryTransform2D->Transform2D, and the
KRY_NODE_/KRY_SCENE_/KRYON_PROPERTY_/KRY_SIGNAL_ enum and macro
families to NODE_/SCENE_/PROPERTY_/SIGNAL_. Header guards keep their
original names (internal). The lowercase kry_ module namespaces
(kry_json, kry_term, ...) and the raymath-shadowing helpers
(KryVector2*, KryClamp, KryLerp) stay prefixed: their unprefixed names
collide with the raylib API surface kryon tracks.
2026-08-16 20:35:15 -03:00
waozi afca3f5a4e scene: recycle removed node slots through a freelist
KryNodeCreate only ever grew the arena, so churn (respawning enemies,
particles) exhausted KRY_SCENE_MAX_NODES. Removed slots now chain onto a
freelist (via next_sibling, unused once detached) and create pops from
it before growing count.
2026-08-16 20:30:12 -03:00
waozi 6f40008742 scene: application-defined node kinds with property callbacks
Kinds beyond the builtin enum can now be allocated at runtime
(KryNodeRegisterCustomKind) so games can put their own entity types
into the scene tree and the editor property model without forking
KryNodeKind. Ops/destroyers/spec tables register against the returned
id like any builtin. Custom-kind property access dispatches to
registered getter/setter callbacks; indices 0..2 stay the shared
transform fields handled generically. Kind tables are growable (cap 64)
and bounds checks use the dynamic count.
2026-08-16 20:26:47 -03:00
waozi e2df69c01b Remove the last kc remnants
- docs/KC_PARSER_PLAN.md: the pre-split kc parser plan — the parser it
  describes is deleted; the shipped architecture (kir frontend, k2c/k2b
  backends) lives in the sources.
- stale build/*/bin/kc binaries from before the rename.
- Comments/variable names still saying 'kc' in scene_tree.h,
  kry_animation.h, kryon-preview, k2b, krait's GNUmakefile/native_krb.c.
  CHANGELOG history entries keep the name each release actually shipped
  with.
2026-08-14 17:05:04 -05:00
waozi e8eb0dd789 Phase 4: Box2D v3 physics integration
Vendor Box2D v3.1.1 (erincatto/box2d) as a submodule; wired into
mk/vendor.mk (CMake static archive, samples/tests/benchmarks off) and
CPPFLAGS_BASE (-Ivendor/box2d/include). libkryon.a now depends on it.

Runtime:
- include/scene_tree.h: KryScene carries an opaque b2WorldId + physics_enabled;
  KryScenePhysicsCreate/Destroy build/tear down the world; KryScenePhysicsTick
  steps it via a function pointer installed by physics_world.c (keeps
  scene_tree.c free of a box2d.h dependency)
- src/scene/physics_world.c: owns the only #include <box2d/box2d.h>; world
  creation/step, body+shape creation helpers, transform sync
- src/scene/node_body2d.c: static/kinematic/dynamic body; creates b2Body on
  ready, syncs transform on physics_process, debug-draws an outline
- src/scene/node_collision_shape2d.c: box/circle shape attached to the nearest
  Body2D ancestor on ready
- src/scene/node_area2d.c: trigger volume (sensor) node
- include/node2d_props.h: Body2DProps/CollisionShape2DProps/Area2DProps +
  allocators
- src/scene/scene_physics_internal.h: private bridge for Box2D-typed helpers

Example: examples/22_physics.kry (a dynamic box falling onto a static ground).
2026-08-12 09:06:23 -05:00
waozi 6c0f79c53e Add kc scene-tree language support, example, and tests
kc compiler (.kry -> C):
- Recognize new top-level 'scene Name { ... }' form; emits a builder
  void Name_kry_scene(KryScene *scene) via a new is_scene flag on KryFunction
  and an _kry_scene suffix branch in kc_function_base_name
- New app{} directive 'scene Name' that makes kc emit a retained-tree main():
  KrySceneRegisterBuiltins / KrySceneInit / run builder / tick+physics+draw
  loop / KrySceneDestroy. Takes priority over the single-screen UI main()
- app_hook_c_name now also resolves scene builders (not just exact_name hooks)
- Single-screen picker skips scene builders so they don't hijack UI apps

Scene tree API:
- KryNodeSetPosition/SetRotation/SetScale/SetProps accessors so builders can
  mutate nodes (C disallows assigning through an rvalue returned struct)

Example + tests:
- examples/20_scene.kry: camera + Sprite2D scene, the first retained-tree game
- tests/scene_tree_test.c: tree ops, transform composition, lifecycle, removal,
  active-camera selection; wired into 'make test' as SCENE_TREE_TEST
- examples/Makefile: add 20_scene to the examples list

Verified end-to-end: .kry -> kc -> clean C -> object file with no warnings
2026-08-11 03:33:41 -05:00
waozi 2bb8640279 Add retained scene tree foundation and rename UI Sprite to Picture
- include/kry_math.h: Vector2 math and KryTransform2D (compose/point/camera)
- include/scene_tree.h + src/scene/scene_tree.c: KryScene/KryNode retained
  node tree with array arena, parent/child links, world-transform update,
  lifecycle vtable (ready/process/physics_process/draw), KrySceneTick/
  PhysicsTick/Draw driver
- include/node2d_props.h: Camera2DProps, Sprite2DProps
- Rename UI Sprite widget to Picture (raylib owns Image as a struct):
  ui_sprite.h -> ui_picture.h, SpriteProps -> PictureProps,
  UISpriteFit -> UIPictureFit, UI_SPRITE_FIT_* -> UI_PICTURE_FIT_*,
  Sprite() -> Picture(); extract shared texture cache to
  src/ui/ui_picture_cache.c (KryLoadPictureTexture, KryPictureFitRect)
  shared by the Picture widget and the upcoming Sprite2D scene node
- Migrate example, docs, node registry to the Picture name
2026-08-11 03:11:34 -05:00