Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added water options to 'TopMenubar/Settings' menu. #3142

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

ohlidalp
Copy link
Member

@ohlidalp ohlidalp commented Mar 24, 2024

I tried to investigate #3137 but got nothing. So I at least analyzed the water code and added UI for tweaking HydraX water.

Both basic water with waves and HydraX water boil down to the same thing: a dynamic grid-mesh updated in code. The only major difference is how the waves are calculated: Basic uses configurable "wave trains", HydraX uses Perlin noise with adjustable params (via .hdx config file). Since both systems are in our codebase, it would make sense to unify them. To better understand how the system operates, I added the UI.

obrazek

@ohlidalp
Copy link
Member Author

ohlidalp commented Mar 25, 2024

I got curious if I could change water type in-game by simply destroying the water subsystem and initing it again. Well, it works.
obrazek
Also waves are now toggleable there, that was already possible before just the UI was missing.
Note the HydraX options only show up when HydraX is active.

@ohlidalp ohlidalp changed the title Added HydraX wave params to 'TopMenubar/Settings' menu. Added water options to 'TopMenubar/Settings' menu. Mar 25, 2024
@ohlidalp ohlidalp force-pushed the 3137_Miner34Dev_hydraxwaves branch from 7409958 to e0f8b62 Compare June 30, 2024 17:57
@ohlidalp
Copy link
Member Author

I've bumped this PR with one small fix. I couldn't fix the glitch but I got closer, see #3137 (comment)

@CuriousMike56
Copy link
Collaborator

CuriousMike56 commented Aug 6, 2024

RoR_2024-08-06_01-59-35.mp4

Switching between reflection water types often results in white, and Hydrax always crashes:

RoR_2024-08-06_01-58-00

The options remain shown when on a terrain that doesn't feature water (but doesn't do anything besides crash without error if Hydrax is selected)

Real time waves adjustment is fun, also now would be a good opportunity to add a water level slider.

@ohlidalp
Copy link
Member Author

Looks like something isn't cleaned up properly and then duplicates and breaks. Might also be Cg or Ogre bug.

The module type isn't configurable, it's hardcoddd in hydrax setup - file 'HydraxWater.cpp', function `InitHydrax()`.

The corresponding dummy line was removed from file 'HydraxDefault.hdx' and the check for it's presence was removed from file 'hydrax/Module.cpp'
Most occurences are long commented out, but this one slipped because nobody called that function until I started working on diag. UI.
This version is based on HydraX hardcoded defaults, but needs to be adjusted based on RoR's defaults.
Also cleaned up code and fixed a bug in Terrain.cpp - game would crash if other Water mode than HydraX was selected.
Codechanges:
* DustPool.cpp - // Make sure water wasn't disabled in Top menubar - if yes, just drop the particle.
* Water.cpp - just code cleanup actually - to clarify the water plane is the same with or without waves - so they can safely be toggled ad-hoc.
* GUIUtils - DrawGCombo() now returns bool - true if value changed.
* GUI_TopMenubar.cpp - change cvar `gfx_water_mode` and run `Terrain::reInitWater()`
* Terrain - added function `reInitWater()`
Uninitialized variables `m_cam_forced`* :/

I cleaned up the variable init, using in-class initializers for all.
@ohlidalp
Copy link
Member Author

@CuriousMike56 I tried only under Dx9 and didn't see the white surfaces... but I got a lot of other glitches/crashes. I fixed switching between all modes except Hydrax which still crashes when toggled the 2nd time.

Summary of changes:
* introduced ✉️ `MSG_SIM_REINIT_WATER_REQUESTED` - Request restarting water subsystem based on cvar 'gfx_water_mode'; sent by TopMenubar UI, also accepted from scripts via `game.pushMessage()`.
* HydraX resources are now loaded each time.
* Removed all direct interaction with HydraX - both classic water (Water.cpp, `class Water`) and HydraX water (HydraxWater.cpp, `class HydraxWater`) are now controlled exclusively via interface `IWater` - see comments in file 'IWater.h'
* Added 'active_water_mode' field to `IWater` - because the cvar 'gfx_water_mode' can now change anytime.
@CuriousMike56
Copy link
Collaborator

Looks like the white surfaces are gone now.

Hydrax options seem to do nothing:

RoR_2024-08-18_21-55-36.mp4

Switching to Hydrax results in visual glitches:

RoR_2024-08-18_22-03-45.mp4

And finally, basic water visuals freeze if waves are disabled:

RoR_2024-08-18_21-59-46.mp4

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.

None yet

2 participants