1
0
mirror of https://github.com/The-Powder-Toy/The-Powder-Toy.git synced 2025-02-16 13:44:51 +01:00

6088 Commits

Author SHA1 Message Date
Tamás Bálint Misius
bf5f9fdcb0
Expose threaded rendering as a setting 2024-08-21 23:48:13 +02:00
Tamás Bálint Misius
a9b84e5f26
Hide away some more Renderer functions 2024-08-21 23:48:13 +02:00
Tamás Bálint Misius
820f44a716
Do rendering on another thread when possible
"Possible" here means "when there are no particles with Lua graphics functions that haven't reported that they don't want to be called again and there are no beforesimdraw/aftersimdraw event handlers". I put my trust in Simulation::elementCount here; I sure hope it's always correct. If there is any of these, the renderer thread is paused and rendering happens on the main thread. To be clear, these are the situations in which Lua code is called with LuaScriptInterface::eventTraits having the eventTraitSimGraphics bit set.

If the detection of this situation is somehow flawed, there will still be no crashes because when running on the renderer thread, Renderer is told to not call Lua functions, and GameController::BeforeSimDraw/AfterSimDraw is not called by GameView::RendererThread. The worst that can happen is that some particles are not rendered properly.

Renderer settings (color and display modes, deco state, finding-element state, etc.) are managed by GameModel in the form of a RendererSettings and are passed to Renderer before each frame. The RenderableSimulation that Renderer works off of is also configured before each frame, either to point to a copy dedicated to the renderer thread, or directly to GameModel's Simulation, if the renderer thread is paused. Similarly, the result of the rendering is managed by GameView in the form of a RendererFrame, to enable e.g. sampling with deco tools without having to pause the renderer thread.

Each time GameView::OnDraw is called, it checks whether rendering is allowed to happen on a different thread (see above for conditions).

If it is, but the renderer thread is absent, GameView starts it and dispatches it (provides with settings and simulation data) right away. At this point, the renderer thread is definitely rendering a frame. GameView waits for this to finish and exchanges data with the renderer once it's done: it takes the result of the rendering and also dispatches the renderer thread again. This introduces a one-frame delay in rendering, which we can live with.

If rendering is not allowed to happen on a different thread, GameView waits for the renderer thread to finish what it's currently doing and pauses it, then proceeds to render the frame by itself.

Affecting this condition (whether rendering is allowed to happen on a different) by installing or removing event handlers, or clearing graphics cache (which, note, requires acquiring a unique lock on it), while the renderer thread is working, is not an issue because the renderer thread doesn't bother with event handlers, and because it acquires a shared lock on the graphics cache for rendering.

The GameModel's Renderer is thus still primarily managed by GameView, potentially in two different threads, in a strictly non-overlapping manner. The exception to this is when RenderView butts in and starts doing renders of its own; in such cases, the renderer thread must be paused explicitly, as RenderView does by calling GameView::PauseRendererThread.
2024-08-21 23:48:13 +02:00
Tamás Bálint Misius
77edec62d1
Make Renderer presets static 2024-08-21 19:30:15 +02:00
Tamás Bálint Misius
f52e047037
Move sampling further away from Renderer 2024-08-21 19:30:15 +02:00
Tamás Bálint Misius
7f60a44d1c
Move brushes further away from Renderer 2024-08-21 17:18:00 +02:00
Tamás Bálint Misius
d5c2d87b2e
Move zoom further away from Renderer 2024-08-21 17:17:42 +02:00
Tamás Bálint Misius
4ed83912af
Get rid of render and display mode arrays
These were arrays because that made them easy to compose, but that's a UI task, it makes no sense to propagate them internally. That said, RenderView is still confusing because it still has checkboxes that control multiple bits of render mode and display mode at once; I'm not dealing with that for now.

The game now prefers the item-type preferences Renderer.RenderMode and Renderer.DisplayMode over the array-type preferences Renderer.RenderModes and Renderer.DisplayModes. It'll preserve the old ones for compatibility if found and derive the new ones from them. The corresponding Lua functions are now deprecated and will just return single-item arrays from now; the similarly named replacements operate with integers.
2024-08-21 17:16:06 +02:00
Tamás Bálint Misius
6e01699a7f
Separate Simulation-specific Renderer code
Also decouple Simulation lifetime from Renderer lifetime. This also let me get rid of the hack that was RendererFont.cpp.
2024-08-21 17:15:58 +02:00
Tamás Bálint Misius
c1a072f2e5
Separate Simulation members required for rendering
More precisely, move them to RenderableSimulation, which Simulation now inherits from. This type is copyable and so is easy to send off to be rendered, potentially on a different thread.
2024-08-21 17:15:49 +02:00
Tamás Bálint Misius
d24a70d6d1
Make pmap size sanity check more precise
Simulations as big as 2048 by 2048 had been possible, but this change enables sizes such as 1900 by 2100, which would have failed the originally very power-of-2-oriented check. Very useful, no doubt.

Also make the tags button span the entire window, fixing the annoying gap or overlap with other buttons when changing the sim size.
2024-08-21 17:15:30 +02:00
Tamás Bálint Misius
57f6ea5953
Fix a few warnings 2024-08-18 13:23:07 +02:00
Tamás Bálint Misius
1854bc25f0
Replace &range[0] with range.data() where appropriate
I had been under the impression that .data() on containers returns a const pointer and so hadn't been using it too much. I was wrong; I think that may be limited to std::basic_string. EDIT: I've checked, even std::basic_string has a non-const .data() since C++17, nice.
2024-08-18 13:23:06 +02:00
Tamás Bálint Misius
ba0a9fa2a5
Snapshot 368 snapshot-368 2024-08-13 20:43:39 +02:00
Tamás Bálint Misius
8e03c97b60
Fix broken gravity walls
They stopped working because 7e9d9686dda4 accidentally had BeforeSim reset the gravity mask also, not just the gravity mass from the previous frame.
2024-08-13 20:39:16 +02:00
Tamás Bálint Misius
2d03fb4b56
Fix resource depfile generation
I got the escaping wrong so on windows, where the path to the script has characters that need to be escaped, the script wouldn't be found, leaving all dependents stale, triggering rebuilds of all resources.
2024-08-07 10:56:56 +02:00
Tamás Bálint Misius
281dbfa283
Make to-array.py list itself as a dependency of its outputs
This causes these dependencies to be rebuilt if the script chanages, which is heaps better than having to remember to clean the build directory every time.
2024-08-07 10:20:43 +02:00
Tamás Bálint Misius
295aad1800
Mark dlls as link-time dependencies of powder.exe
So they get copied into the build site even if you invoke only the powder build target, rather than all build targets by not specifying one. Case in point:

	meson compile

vs

	meson compile powder

wherein the latter will build powder.exe but will not copy the dlls into the build site, which are required by powder.exe.
2024-08-06 07:26:12 +02:00
Tamás Bálint Misius
c97cc1ec51
Slightly smarter Defer 2024-07-25 10:45:27 +02:00
Tamás Bálint Misius
daea125837
Disable the requestHandles.size() assert in Libcurl.cpp
It's getting triggered because the lifetime of some objects that own RequestHandles are not exactly deterministic, to put it lightly. I'm not dealing with those.
2024-07-21 14:00:44 +02:00
dxgldotorg
6179a7383a
Add HiDPI to manifest file, fixes 2024-07-06 21:12:52 +02:00
Tamás Bálint Misius
c7bb950cfc
Snapshot 367 snapshot-367 2024-07-03 21:25:58 +02:00
Tamás Bálint Misius
7e9d9686dd
Change gravity timing and add support for saving it
Timing is now such that the input to the gravity process (the point masses and the mask derived from gravity walls) is passed in BeforeSim and the output of the gravity process (the 2D force field) is taken also in BeforeSim, at the same time. This means that input generated by particles in frame n is passed to the gravity process at the beginning of frame n+1, the corresponding output is available by the beginning of frame n+2, and so it is visible to particles in frame n+2. Thus, gravity is now properly and predictably one frame late, though, sadly, it's displayed two frames late.

This is in contrast with the case of not being late at all, which would be the case if input generated in frame n produced visible output by frame n+1, and also in contrast with what we've had until now, which was that gravity was *at least* one frame late, but it could be more out of sync than that if the gravity process for some reason took more time to produce output.

Further, both input and output now make it into snapshots and saves, which fixes one half of what causes the phenomenon wherein beams of PHOT under the effect of gravity wiggle for a few frames before stabilizing after a save is loaded. The other half is that velocities are saved at very a low precision, so overall, the effect of this change on this phenomenon is negligible.

It is not crucial that a client understands this new piece of info, as clients have been fine not getting gravity data from saves for years. Thus, its presence does not restrict the save to client versions newer than the one that adds this feature.

An interesting question this brings up is whether settings, crucially, the enabled state of Newtonian gravity, should be considered simulation state and be also included in saves.

Gravity data is now also included in the output of sim.hash, so Newtonian gravity no longer has to be disabled in order to ensure local determinism.

The diff is large because I gave up on being non-invasive and renamed important structures that lots of elements use. gravp, which was functionally just hypot(gravx, gravy), was removed, because it was only ever used to display a single value in the HUD. I've also taken a few detours and made changes that really should have been in separate commits, see below, but oh well.

This commit also includes a complete rework of the gravity wall area of effect discovery algorithm. The old implementation was extremely broken even beyond the usual C99-isms.

Also fix Simulation.NewtonianGravity being read as an integer from powder.pref, even though it's a boolean and is in fact saved as a boolean. It's pure luck that it's worked fine until now.

Also introduce PlaneBase for use with PlaneAdapter. PlaneBase is a very budget version of std::span from C++20, so budget in fact that it doesn't even store span size; this is fine because PlaneAdapter knows the span size anyway. std::basic_string_view worked for char types but this new code deals with floats.

Also include blockAir data in saves unconditionally. It used to be included only if ensureDeterminism was enabled, like rngState and frameCount, but those last two are conditionally included only because some assumptions are broken if they are included, such as that of expecting a saved simulation to take different paths of evolution after each reload. blockAir has no such effect.

Also remove sim.resetGravityField aka tpt.reset_gravity_field because it was agreed that it's really weird that the output of the gravity process can be changed at all from Lua, not to mention that it can only be reset to zero. No scripts to my knowledge ever used these functions.
2024-07-03 20:51:05 +02:00
Tamás Bálint Misius
0345dcf508
Spam hdiutil until it works 2024-07-03 20:51:05 +02:00
yangbowen
24628db58b Add support for clang-cl. Also refactors compiler detection logic. 2024-07-03 20:49:46 +02:00
thfrwn
605c98c9f8 add OpenBSD to platforms using exit(3) 2024-07-03 19:47:02 +02:00
Tamás Bálint Misius
c174833734
Complain about http:// URL bases when enforce_https=true 2024-06-20 12:13:39 +02:00
Tamás Bálint Misius
f3c92038e1
Use NT and ST for checks against *Transition
This is already a fairly obscure part of the codebase, and that NT and ST are only used in element files but not where *Transition properties are processed really doesn't help. This change makes usage of these constants easier to search for. Sadly, this doesn't help the case of IPL, IPH, ITL, ITH, whose handling is still implicit. I dared not rework the code to check for them explicitly because eww, floats.
2024-06-20 11:56:21 +02:00
Tamás Bálint Misius
b4a12aae32
Simplify Startup.json parsing slightly
The lambdas were originally there to allow for different ways to determine whether the version offered by the website is indeed an update. The lambdas became identical in a9cbd784f756 however, which is when this change should have been made.
2024-06-19 12:18:54 +02:00
Tamás Bálint Misius
a24e1dbee8
Remove http scheme variables
The separation from the server variables doesn't really serve any purpose other than making it require very conscious effort to accidentally start connecting over plain http, but we already have enforce_https for this purpose. Beyond that, it just makes prototyping with a local server really annoying.
2024-06-19 12:18:52 +02:00
Onestay42
72fd55fafe
Add CtypeDraw for VOID / PVOD () 2024-06-13 00:17:12 -04:00
jacob1
175d8e1b28
Fix "Large Screen" dialog not properly updating scale in powder.pref, causing scale to reset back to 1 on the next launch 2024-06-01 00:37:11 -04:00
Saveliy Skresanov
27e6fad80e Set solid resist ctype/tmp from unbreakable/breakable clone. 2024-05-25 12:07:21 +07:00
Tamás Bálint Misius
118786e39b
Fix gfx.drawPixel being unable to draw in event.AFTERSIMDRAW
It somehow never got the upgrade where a drawing primitive looks at the current event context and chooses a graphics backend based on it. All the others primitive got it in c5b72b213baa.
2024-05-24 10:48:53 +02:00
jacob1
080f059da9
Fix page count increasing when refreshing comments, disable "Submit" button until comments are refreshed 2024-05-16 00:02:01 -04:00
jacob1
bb51daa05f
Fix some issues with comment submission
- Fix error when submitting comments being ignored, meaning you'd only know if your comment got rejected if your comment wasn't there after the comments refreshed
- Fix issue in Request::ParseResponse where "Could not read response" is always included on all website errors
- Add ability to refresh comments by clicking the Submit button with an empty textbox
2024-05-14 23:56:58 -04:00
Tamás Bálint Misius
d32873b717
Print address of main on bluescreens
So we have at least some handle on the layout of the module/object's base address. Makes interpreting bare return addresses easier.
2024-05-06 17:23:18 +02:00
jacob1
696e31295e
Snapshot 366 snapshot-366 2024-05-01 11:31:58 -04:00
Tamás Bálint Misius
1705240c3c
Hopefully fix random hdiutil failures on ghactions 2024-04-30 19:23:42 +02:00
Saveliy Skresanov
feb3f9de8d Cap air temp for real. 2024-04-30 23:28:04 +07:00
Saveliy Skresanov
a92f742c66 Improve heat convection in ambient heat. 2024-04-30 23:16:19 +07:00
Tamás Bálint Misius
9a785dc389
Fix assumption that python is called python
The assumption was introduced by 7e674a887d69, where find_program('python') was used instead of Meson's built-in python discovery services. This turned out to be a bad idea because of course there are systems in 2024 where python is not python 3.
2024-04-29 17:50:45 +02:00
jacob1
81d684b04c
Update intro text cracker64 -> Pilihp64
[10:44 AM] jacob1: You're still credited that way in-game, should it be changed?
[10:44 AM] Pilihp64: I guess so, I think my github is actually Pilihp64 as well
2024-04-26 21:24:26 -04:00
jacob1
2c1b9241a4
Move hidden elements into solid/liquid/gas menus where appropriate 2024-04-26 21:18:55 -04:00
Tamás Bálint Misius
7e674a887d
Replace resource tools with python scripts
May fix pipeline failures on ghactions where makeico or toarray just exit with a non-zero status for no reason.

Also makes it easier (possible, rather) to build TPT using a cross-compiling msvc toolchain on windows; you can't have two different msvc toolchains in PATH on windows because of course you can't.

toarray had been python before, maybe I converted it to cpp to avoid pulling in python as a dependency, I'm not sure. With android vanilla development (hopefully) gaining traction soon, we'll be relying anyway on helper scripts I've written in python, so python will be a dependency sooner or later. Meson implicitly makes python a dependency, but there could be Meson implementations out there that don't rely on python, who knows.
2024-04-26 11:55:50 +02:00
Tamás Bálint Misius
4179155963
Remove invisible CRACKER and CRACKER2 menu sections
Also add elem.NUM_MENUSECTIONS, which specifies the range of valid ui.menuEnabled inputs and MenuSection element property values.
2024-04-26 11:38:18 +02:00
Saveliy Skresanov
6ce8e10adb Add a limit on the number of SPARK, LFLARE and FLARE effects drawn in one frame. 2024-04-22 22:49:00 +07:00
jacob1
47384c5572
ICE contains arbitrary elements in ctype as well and should track this in saves 2024-04-21 00:11:55 -04:00
jacob1
de345a85a1
Fix "missing custom elements" warnings when loading saves with RSST/RSSS; mark SNOW as carrying ctype as well 2024-04-19 23:31:20 -04:00
Tamás Bálint Misius
6de252eb34
Check starcatcher credentials early
It's infuriating when the entire workflow fails at the publish stage because Discord pretends to have markdown.
2024-04-14 20:36:05 +02:00