30 Commits
Author SHA1 Message Date
BMagnu 856e676e79 Add render path to dispatch Particles as Decals (#7507)
* Add path to dispatch particles as decals

* Testing and bugfixing

* Address feedback

* Fix Typo

* Fix obj attachment
2026-07-17 13:38:45 +09:00
BMagnu fcaa9dd998 Allow trail particles to be parented to their spawner (#7528)
* Adapt particle at runtime

* Refactor EffectHosts

* fix issues

* cleanup

* Remove live transitive particles

* paticle hosts now do local correctly

* Fix effecthostparticle local mode

* again

* Set particle host orientation

* I don't like mixed local and global vectors

* agaiiin

* Fix validity check

* parent foo

* Fix bugs, hopefully finally

* refactor

* Flip new table option for intuitiveness

* Fix support for GCC9 due to issues with LWG3052

* Address feedback
2026-07-15 15:10:15 +09:00
Goober5000andClaude Opus 4.8 bed228d264 avoid undefined behavior from UNREACHABLE on reachable code paths (#7555)
* avoid undefined behavior from UNREACHABLE on reachable code paths

UNREACHABLE expands to __assume(false) / __builtin_unreachable() in
release builds, which is undefined behavior if the code is ever actually
reached. Many UNREACHABLE sites only guard against unexpected-but-
possible runtime states (values from tables, mission/save files, network
packets, scripting, or user input), so reaching them should degrade
gracefully rather than invoke UB.

Replace UNREACHABLE with Assertion(false, ...) at all such sites. It
still pops an error in debug builds, but in release it is a harmless
no-op that simply falls through to the following code. Sites that are
genuinely unreachable by local invariants (e.g. a switch over a bounded
random number) are left as UNREACHABLE.

A few converted sites had no safe fall-through -- an uninitialized read,
null dereference, or null call would have followed -- so they also get a
minimal recovery: initialize the value, guard the dereference, return
early, or skip the offending item.

Where the converted site was a simple guard of the form
    if (x) { Assertion(false, ...); return; }
hoist the check onto the invariant instead:
    Assertion(!x, ...);
    if (x) { return; }
This states the expectation directly and shows the offending value in
the debug popup, while keeping the same graceful runtime degradation.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* addendum

After consultation with Lafiel, use UNREACHABLE in situations that are effectively impossible even if not provably impossible.  UNREACHABLE = "this shouldn't ever happen"; Assertion = "if this ever happens, it's a coding error".  Also fix a few other sites and change a couple to Warnings.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
2026-07-09 11:20:25 +09:00
BMagnu 7da707de7f Add particles on death of particles (#7504) 2026-07-05 04:14:41 +02:00
BMagnu c8ea9c6035 Model surface particles (#7447)
* Pick model surface particle by sampling random vertex

* Parse and keep buffers

* Add local position scaling

* Fix warning

* Fix warning 2

* Fix warning 3

* Fix warning 4

* Add scale parameter

* Incorporate feedback
2026-05-18 13:23:41 +09:00
BMagnu e827011113 Particle source duration curve + life remaining input (#7231)
* Add curve to control the duration of a particle source

* Also add fractional Life Left curve input for sources

* Actually register new particle curve output
2026-02-17 12:09:13 +01:00
BMagnu 2e4d97ce4e Properly initialize max_life when no lifetime is available (#7131) 2025-12-02 12:15:36 +09:00
BMagnu 973bd5570e Small particle copy-paste fixes (#7044)
* Use correct curve

* Properly init animation data
2025-09-18 12:49:46 +00:00
BMagnu 15445408f9 Particles can now emit light (#7040)
* Add backend for paticles to emit light

* Parse new light options

* Modular Curves account for light

* Actually apply curves

* remove comment

* Add cone mode
2025-09-18 13:39:12 +02:00
BMagnu 1e7431a044 Give Particles Access to Their Spawner Effect (#7034)
* Make particles aware of the effect that spawned them

* Allow modular curves to call global functions from submember inputs

* Add more in and outputs for particle lifetime curves

* Allow post-curve velocity as a curve input

* fix warning and incorrect assig

* Disable CheckTriviallyCopyableMove

* Clang Tidy
2025-09-15 04:42:06 +02:00
Kestrellius 0bf632ceae Add apparent size input for particle source curve (#6947)
* functional method

* add input
2025-08-18 22:36:17 -04:00
Kestrellius 5cd3b3a308 Extend particle interpolation to lifetime (#6910)
* the naive method

* the correct method
2025-08-08 07:29:59 -04:00
BMagnu fcb257db59 Fix calculation of apparent size (#6872) 2025-07-26 03:04:44 +02:00
BMagnu 82dfdbc962 Cleanup of Level 0 Particles (#6808)
* Make scripting use the full-blown particle system

* Add reverse option

* Add animation reversal as an option to modern particles

* Start implementation of beam particles

* Add multi-emission particle source API for legacy particles

* Attach beam muzzle particles to the correct host

* Reorder code in order to facilitate apparent visual size as modular curve input for particles

* fix lua api

* Typo

* Fix scripting and beam muzzle particles

* Remove muzzleflash code, prepare to replace with particles

* Begin mflash effect conversion

* Pass final parameters to mflashes and fix curve

* Remove deprecated particle function

* Add debris flame particles

* remove weapon_explosion table

* Convert shield explosion particles

* Fix modular curve full inputs and convert particle curve inputs accordingly

* Allow particle volume offset and rotation with curve-based rot around fvec

* Add Ring and Point Volumes

* Convert PSPEW to new system

* Make particle curve timing aware of interp

* Update todos

* get rid of performance waste

* Add last parameter for converted pspews

* Fix pspew bugs

* Fix direction for default pspew

* Fix order for voluem rotation

* particle vel interp

* particle vel interp 2

* Make beam muzzle stay parented to the firing ship, as it's likely the more commonly intended variamnt

* fix scripting particle lifetime

* Allow beam muzzle particle override

* Skip invalid pspews

* remove pspew dcf code

* Fix sparkler stretch

* Correct sparkler bia

* General sparkler weirdness

* Tune distribution of sparklers

* Convert Asteroid particles

* Fix conversion warning

* Fix conversion warning again

* Fix conversion warning again again

* Really clang?
2025-07-09 16:47:14 +09:00
Kestrellius ad5b2372fa A couple of particle-related fixes (#6754) 2025-06-07 10:49:49 -04:00
BMagnu b3c3627f54 Allow using seeded noise for particle velocity and spawn position offset (#6675)
* Add noise backend for particles

# Conflicts:
#	code/particle/ParticleEffect.cpp

* noise frontend

* Proper scaling for noise

* make normalize safe
2025-05-26 20:43:56 +09:00
Goober5000 596f6e75da check in more places in the particle code 2025-04-12 15:38:57 -04:00
Goober5000 4797ce55a2 use vm_vector_2_matrix_norm on normalized vectors
Most places in the code that use `vm_vector_2_matrix` do so on already-normalized vectors.  Changing these to `vm_vector_2_matrix_norm` avoids redundant normalization.
2025-03-02 23:07:09 -05:00
Birk Magnussen 1f2a8dce2a remove optional 2025-02-01 13:17:26 +01:00
Birk Magnussen ec0e55d077 De-movify random ranges 2024-12-16 14:22:29 +01:00
Birk Magnussen ec027bde87 Fix compile issues 2024-12-16 13:26:47 +01:00
BMagnu 621d88e9b7 Make length a modular curve output 2024-12-13 16:44:49 +01:00
Birk Magnussen 40312e7419 Add modular curve sets to volumes 2024-12-12 16:44:34 +01:00
BMagnu 2aac63e0a9 Allow particle volumes to have access to the source for modular curves 2024-12-11 16:01:07 +01:00
BMagnu c2051578d6 Basic modular curves for particles 2024-12-11 13:55:36 +01:00
BMagnu 12ad35e10a restore shield_impact_explosion_radius 2024-12-09 13:28:16 +01:00
Birk Magnussen 32835b06fd Small cleanups 2024-11-03 21:00:39 +01:00
Birk Magnussen 1f7909112c Remove particle properties 2024-11-03 20:22:34 +01:00
Birk Magnussen 3d171eb858 Remove EffectTiming 2024-11-03 15:00:32 +01:00
Birk Magnussen e2dbb46b9c Fold OmniEffect into ParticleEffect 2024-11-03 14:45:16 +01:00