216 Commits
Author SHA1 Message Date
Goober5000 e71e9494d8 "change atan2_safe to atan2" followup (#7531)
Follow-up to #6255.  Partially restore use of `atan2_safe` from 87ea04fa53: keep special case while delegating most cases to atan2.

Fixes #7530.
2026-06-18 10:34:16 +09:00
Daniel Cazares a8f4be1d34 fix(math): correct vector assignments in vm_vector_2_matrix_gen_vectors (#7162) 2025-12-26 19:14:24 +09:00
Asteroth e803d8a0e9 move some stuff 2025-12-21 23:36:25 -05:00
Asteroth 761b97529a comments and assertions 2025-12-21 22:12:28 -05:00
Asteroth 1cd45aa1b4 uvec dominant frame of ref for submodels 2025-12-20 20:53:54 -05:00
Asteroth 1a1d3f040c fix interpolate matrices (#6996) 2025-08-25 17:17:52 +00:00
BMagnu 9b82daeefc Proper Ambient Light (#6849)
* Remove ambient handling from amin / decal pass

* Add ambient light to deferred pass

* Make decals work and fix double insignia rendering

* Fix decal vertex shader

* render insignias as decals

* Cleanup of old insignia stuff

* Move insignia post-processing to model load

* perform envmap lighting in deferred shader

* Remove Envmapping from main shader

* Fix MSVC warning

* exclude def_files from clang tidy
2025-07-22 00:17:22 +02:00
Taylor Richards 9e9fc22b13 fix type conversion issue in vecmat (#6749) 2025-06-05 08:02:02 -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 86f75c5d17 fix normalized vector handling (#6650)
Although normalized vectors in FSO are supposed to stay normalized, occasionally small floating point errors can pop up.  In most cases these do not cause a problem, but in certain cases these errors can rapidly accumulate and corrupt an otherwise well-behaved matrix.  This can most easily be seen with daisy-chained dock sequences or docked ships with angled dockpoints.

This PR audits the usage of `vm_vector_2_matrix_norm` to re-normalize vectors in cases where floating point errors could accumulate.  There are also a few new Assertions for extra vigilance.

Follow-up to #6596.  Fixes #6634.
2025-03-28 23:54:51 +01: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
Asteroth 20bd8b4bf4 switch to nprintf 2024-08-15 17:29:16 -04:00
Asteroth 6a5cd9fcc5 remove some prints 2024-07-24 13:41:13 -04:00
Goober5000 87ea04fa53 change atan2_safe to atan2
According to DahBlount:
> Most atan2 implementations for a long time had problems when the inputs were close to machine epsilon or when x was less than or equal to 0

And according to z64555:
> Modern versions of C++ should have an atan2() that works correctly when the inputs are at 0 or near epsilon of the floating point specification, meaning Volition's workaround shouldn't be needed anymore.

So this removes `atan2_safe` and changes all instances to `atan2`.  Consequently, the angle range in FRED now shows as [-180, 180] as expected.

Fixes #3730.
2024-07-15 20:55:57 -04:00
John Fernandez a390b5a01a Generalize linear interpolation (#5003)
* Remove old interpolate angles quick

* Remove old interpolate functions

These are no longer used.

* Add linear interpolate vm function

More clearing functions

* Add physics snapshot struct to silo interpolation

Two of these two functions require an object pointer, so they cannot be in physics_state.cpp

With doxygen documentation

* Try to placate Linux

* Address Feedback

* And update declaration, of course

* Attempt to appease linter
2024-06-18 20:10:01 +02:00
Asteroth 8bd8e785b1 adjustments to rand vecs for random orientation 2024-05-17 21:09:36 -04:00
Goober5000 379077242a it's uniformly random, per Asteroth 2024-05-17 00:45:10 -04:00
Birk Magnussen 3721f8165d Basic Stereoscopy 2023-11-09 22:42:43 +01:00
Goober5000 17d36156cb add const where appropriate to the modelrender API
See title.  There were some cascade effects, but the changes are mostly contained to the model code.  The calls to `gr_render_model` and `g3_render_primitives` use `const_cast` because constifying that API would require a whole other PR.
2023-06-18 14:05:46 -04:00
Asteroth 60f3aa59d6 Make lasers less kinky (#5446)
* properly handle trapezoidal bitmaps

* clean up

* fixup single segment trails too

* fix
2023-06-07 19:59:07 -04:00
BMagnu 5e9dd9aef5 Calculate alpha for things rendered after the nebula 2023-03-02 12:35:35 +01:00
Asteroth 219bcca23a Implement gravity (#4803)
Adds gravity! Applies on a per-mission basis, and weapons, ships, debris, and asteroids now have a configurable "gravity const" which multiplies the effect of gravity on them, by default everything except debris is 0 (meaning no effect even when the mission has gravity). AI and the lead indicator will also lead for ballistic trajectories as well, given a gravity-affected weapon. No FRED support or gravity direction control yet, to come in later PRs.
2022-11-21 20:13:35 -05:00
Goober5000 9cb2892ca9 Merge pull request #4629 from Goober5000/script_interpolate_matrices
rotational interpolation
2022-09-07 16:48:26 -04:00
Asteroth de503bb2d5 small fix for banking (#4624) 2022-09-07 18:35:30 +09:00
Goober5000 39b57cbf41 rotational interpolation
Add script support for rotational interpolation of matrixes (orientations) and vectors.
2022-09-06 21:48:03 -04:00
John Fernandez a93eeebff0 Fixes for Matrix interp 2022-09-05 19:05:12 -04:00
John FernandezandAsteroth 2b0f35b58b Add an explicit Interpolate Matrices function
Written by Asteroth, derived from our ai code.  I added a couple safety checks and changed the type to void to match our library.

Co-Authored-By: Asteroth <[email protected]>
2022-08-31 13:33:25 -04:00
wookieejedi 4074cf4c9c Fix False Null MOI warnings
In #4443, `fl_near_zero` was set to use default epsilon values in the `IS_VEC_NULL` check. In this comparison, epsilon is the wrong threshold because it used to have a much smaller threshold. The fix restores the previous definitions of `IS_VEC_NULL` and `IS_VEC_NULL_SQ_SAFE` by exposing the epsilon value as an optional parameter (similar to how `IS_NEAR_ZERO` used to work. This PR also restores `IS_VEC_NULL_SQ_SAFE` where it was replaced by `IS_VEC_NULL.`
2022-08-13 09:59:10 -04:00
Goober5000 dfeb15f8e5 more cleanup in preparation for model translation (#4443)
* more cleanup in preparation for model translation

1) Clean up stepped rotation, fixing some logic, adding safeguards for invalid values, and allowing rotations to go in the opposite direction
2) Add more specific SEXP error checking for AWACS and rotating subsystems
3) Assorted refactoring and polishing

* address feedback, plus a bit of extra cleanup
2022-08-11 08:17:17 -04:00
Asteroth a246ef21aa make sure to cap bank_vel (#4487) 2022-07-12 20:15:42 -04:00
Asteroth 049fa72df3 change bank to target vel from target position (#4417) 2022-06-18 06:06:36 +09:00
Asteroth c1fdb640b1 add wiki link 2022-05-02 01:36:13 -04:00
Goober5000 f394708f09 this should work 2022-04-24 18:48:12 -04:00
Asteroth df39ac45d7 fill fix/unfix angles 2022-04-24 15:15:35 -04:00
Asteroth 527b46443b background bitmap fix, part 2
Uses simpler and more correct math for bg bitmap angles, and when old values are parsed, they are translated into correct values
2022-04-19 02:09:44 -04:00
Goober5000 6ab17aba2a move inline functions to the header file so Linux will compile 2022-01-30 22:58:24 -05:00
Birk Magnussen 4ce2d3e029 Fix various issues in vm_closest_angle_to_matrix 2022-01-28 16:30:59 +09:00
BMagnu 42c1957adc Properly handle negative case (#3910) 2022-01-10 04:01:21 +09:00
BMagnu 61b87e682c Handle forgotten 0 case for new vecmat function (#3891)
* handle forgotten 0 case

* Reduce tolerances again
2022-01-06 02:01:28 +09:00
BMagnu 1c19199df3 Animation Rework Phase 3, Turret fix (#3877)
* Change animation turret canonicalization to now correctly calculate the closest natual turret positon

* Add angle error to vm function for convenience

* Div by Zero safety for non IEEE compliant systems

* Incorporate style changes
2022-01-03 18:54:11 +00:00
Joshua Glatt ab5aa71628 Fix random selection of points for SphereShape particles (#3841) 2021-12-24 10:06:47 -08:00
Baezon 2d84fdf5c6 Merge remote-tracking branch 'upstream/master' into poof-overhaul 2021-07-16 22:29:56 -04:00
PhantomHoover 0fe59e10ad Inline matrix multiplication ops for performance improvements (#3535) 2021-06-25 22:19:42 -04:00
PhantomHoover a687fe0aef Reimplement matrix3 multiplication based on a common overloaded operator (#3470) 2021-06-24 17:26:51 +00:00
Baezon 90558a5858 Merge branch 'master' into poof-overhaul 2021-06-16 03:26:58 -04:00
Asteroth 1445e778f0 Add volume effects (#3446) 2021-06-01 22:20:42 -04:00
Asteroth d971f34ee2 make all asinf and acosf safe (#3384) 2021-05-05 00:53:24 -04:00
Baezon 7980891b48 overhaul poof handling 2021-04-22 00:05:22 -04:00
Baezon 7a7999ca56 Merge remote-tracking branch 'upstream/master' into poof-overhaul 2021-03-19 20:43:17 -04:00