Commit Graph
26 Commits
Author SHA1 Message Date
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
Goober5000andClaude Opus 4.6 3f85d6172a use std::move() for local variables that are copied but not reused (#7308)
* use std::move() for local variables that are copied but not reused

Addresses ~140 Coverity "Variable copied when it could be moved"
defects across 74 files.  Every std::move() targets a local variable
whose value is consumed by push_back, emplace, assignment, lambda
capture, or a function call and is never read again afterward.

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

* clang: use std::make_shared

* clang: use std::make_unique

* address feedback

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-07 14:40:38 +09: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
BMagnu 95d21a4085 Minor Particle Fixes (#6884)
* Fix scripted particle velocity

* Add error if no bitmaps were defined
2025-07-30 20:53:26 +09: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
BMagnu e1810ed522 Allow curves to be tabled inline (#6674)
* Add inline curve definitions

* Fix comma parsing

* Fix cast

* Incorporate feedback

* Fix parsing call
2025-06-02 01:41:06 +02: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
BMagnu ae501e21c9 Fix particle name assignment when using legacy-type composite effects that address child effects by name (#6600) 2025-02-21 21:37:21 +01:00
Birk Magnussen 8323d9ed2f Fix parsing 2024-12-16 13:05:38 +01:00
Birk Magnussen b22716a4d2 remove no longer required delay restriction 2024-12-16 12:55:19 +01:00
Birk Magnussen 783ebba5ac Finish parsing 2024-12-16 11:17:17 +01:00
Birk Magnussen bcaac067f5 Modern basic particle parsing 2024-12-16 00:40:23 +01:00
Birk Magnussen a2e14b0580 Add parser modules for everything 2024-12-12 19:02:20 +01:00
Birk Magnussen df4c12330e Volume Parsing 2024-12-12 18:38:53 +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
Birk Magnussen 1aa67c9342 Properly use new effect host 2024-11-02 14:48:58 +01:00
Birk Magnussen b9b7a13586 Fix source bugs 2024-09-24 17:42:19 +02:00
Birk Magnussen 0ec845b4ce Make builtin particle sources actually anonymous 2024-09-24 17:34:43 +02:00
Birk Magnussen 562c39d8b4 fix parse 2024-09-24 17:24:32 +02:00
Birk Magnussen 09d8ffe66d Do legacy parsin 2024-09-24 17:24:31 +02:00