Skip to content

Implement ParticleSystem module - #43

Merged
vitorbetmann merged 46 commits into
mainfrom
implement-particle-system
May 28, 2026
Merged

vitorbetmann merged 46 commits into
mainfrom
implement-particle-system

Conversation

@vitorbetmann

Copy link
Copy Markdown
Owner

Summary

  • Implements the full ParticleSystem public API (psCreate, psDestroy, psReset, psBurst, psStream, psUpdate, psForEach, all psGet* and psSet* functions including influence and snapshot-influence callbacks)
  • Adds tests/ParticleSystem.c with a comprehensive test suite covering happy-path, error, edge-case, and stress scenarios
  • Ships docs/ParticleSystem/README.md (Getting Started) and docs/ParticleSystem/ParticleSystemAPI.md (full API reference), plus Doxygen comments on all public declarations in include/ParticleSystem.h

Test plan

  • Build in developer mode: cmake -S . -B build -DSMILE_DEV=ON && cmake --build build
  • Run the full test suite: ctest --test-dir build --output-on-failure
  • Run ParticleSystem tests specifically: ctest --test-dir build -R TestAPIParticleSystem --output-on-failure
  • Confirm no regressions in TestAPILog, TestAPISceneManager, and TestToolGenScene

🤖 Generated with Claude Code

…ructions

  - Extend module lifecycle section in CLAUDE.md and README.md to distinguish
    global-state (Start → Use → Stop) from per-instance (Create → Use → Destroy)
  - Add Documentation Guidelines section to CONTRIBUTING.md covering file placement,
    two-tier README/API structure, Markdown style, and Doxygen rules
  - Add Running Tests section to CONTRIBUTING.md

  Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ference

  - Implement psCreate (calloc + bounds check) and psDestroy in ParticleSystem.c
  - Reorder lifecycle declarations in ParticleSystem.h to match call order; add blank
    lines between prototypes; rename maxParticles param to particles
  - Restructure test file: constexpr constants, fixtures section, one smoke test
    passing; remaining tests commented out pending implementation
  - Add docs/ParticleSystem/ParticleSystemAPI.md

  Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
  Replace psEmit with two dedicated emission functions:
  - psBurst(ps, n)      — spawns up to n particles immediately, capped at idle slots
  - psStream(ps, rate)  — sets a particles/second rate driven by psUpdate's accumulator

  Remove psSetEvent (lifetime events) — game-loop polling via psForEach/psGetActive
  covers the use case without adding complexity inside the module.

  Drop PS_SHAPE_POINT — point emission is PS_SHAPE_ELLIPSE with all spreads 0.0f,
  which is also the default at psCreate.

  Add void *context to psSetSnapshotInfluence/SnapshotInfluenceFn for consistency
  with psSetInfluence — C function pointers cannot close over state.

  Mark psForEach, psGetX/Y, psGetActive, and psGetIdle const-correct.

  Add streamRate/streamAccumulator to psInternalParticleSystem; reorder
  velocity/acceleration fields to group by axis (minX/minY, maxX/maxY).

  Implement psGetActive, psReset, psBurst, psStream, and null guard on psDestroy.

  Activate all Create, Destroy, Reset, Burst, and Stream tests; remove psSetEvent
  stubs; update remaining scaffolding to reflect the new API names.

  Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
vitorbetmann and others added 16 commits May 27, 2026 20:04
Range-validation branches in psSetSpread, psSetVelocity, psSetAcceleration,
and psSetLifetime were logging CSE_NULL_ARG despite no null pointer being
involved; corrected to CSE_INVALID_ARG.

Three MSG_INVALID_*_RANGE message strings described the valid requirement
backwards (e.g. "Min lifetime must be greater than max lifetime"); rephrased
to "min X must not exceed max X".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Correct influence callback timing (after, not before, position integration),
remove unimplemented negativity guards from psSetSpread/psSetLifetime notes,
and fix psReset description to reflect that the stream accumulator is preserved.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Move <string.h> to the angle-bracket include group
- Remove const from all by-value parameters in function definitions
- Fix float const/const float inconsistency in psInternalSamplePosition
- Remove double blank line in psSetSnapshotInfluence

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Install clang-18 explicitly on Ubuntu runners and use it as the compiler
in both the build-and-test matrix and the sanitize job.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
clang-18 (used in CI on Ubuntu) does not support C23 constexpr; replace
all occurrences with static const. Also fix lgPrivateLogV's definition
to match its forward declaration (drop const from the value parameter
and va_list argument, which also resolves the vfprintf qualifier warning).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cosf, sinf, and nanf require explicit -lm on Linux; macOS provides them
in the standard C library. PUBLIC visibility propagates the flag to all
consumers of smile (tests, GenScene) without touching each target.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vitorbetmann
vitorbetmann merged commit bb25c4b into main May 28, 2026
4 checks passed
@vitorbetmann

Copy link
Copy Markdown
Owner Author

Good job, me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant