Skip to content

Commit 12c4070

Browse files
committed
Merge remote-tracking branch 'origin/vorticity' into playtest-june2025
2 parents 4aa0abe + 1335425 commit 12c4070

20 files changed

+206
-14
lines changed

src/client/GameSave.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <algorithm>
1818

1919
constexpr auto currentVersion = UPSTREAM_VERSION.displayVersion;
20-
constexpr auto nextVersion = Version(99, 3);
20+
constexpr auto nextVersion = Version(100, 0);
2121
static_assert(!ALLOW_FAKE_NEWER_VERSION || nextVersion >= currentVersion);
2222

2323
constexpr auto effectiveVersion = ALLOW_FAKE_NEWER_VERSION ? nextVersion : currentVersion;
@@ -630,6 +630,7 @@ void GameSave::readOPS(const std::vector<char> &data)
630630
CheckBsonFieldFloat(iter, "customGravityY", &customGravityY);
631631
CheckBsonFieldInt(iter, "airMode", &airMode);
632632
CheckBsonFieldFloat(iter, "ambientAirTemp", &ambientAirTemp);
633+
CheckBsonFieldFloat(iter, "vorticityCoeff", &vorticityCoeff);
633634
CheckBsonFieldInt(iter, "edgeMode", &edgeMode);
634635
CheckBsonFieldInt(iter, "pmapbits", &pmapbits);
635636
CheckBsonFieldBool(iter, "ensureDeterminism", &ensureDeterminism);
@@ -2583,6 +2584,11 @@ std::pair<bool, std::vector<char>> GameSave::serialiseOPS() const
25832584
bson_append_double(&b, "ambientAirTemp", double(ambientAirTemp));
25842585
RESTRICTVERSION(96, 0);
25852586
}
2587+
if (vorticityCoeff > 0.0001f && vorticityCoeff < 1.0f)
2588+
{
2589+
bson_append_double(&b, "vorticityCoeff", double(vorticityCoeff));
2590+
RESTRICTVERSION(100, 0);
2591+
}
25862592
bson_append_int(&b, "edgeMode", edgeMode);
25872593

25882594
if (stkm.hasData())

src/client/GameSave.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class GameSave
107107
float customGravityY = 0.0f;
108108
int airMode = 0;
109109
float ambientAirTemp = R_TEMP + 273.15f;
110+
float vorticityCoeff = 0.0f;
110111
int edgeMode = 0;
111112
bool wantAuthors = true;
112113

src/graphics/Graphics.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool inve
435435
BlendChar({ x + 1, y + 1 }, 0xE055, 0x37FF37_rgb .WithAlpha(alpha));
436436
}
437437
break;
438+
case IconVort:
439+
if(invert)
440+
BlendChar({ x + 1, y + 1 }, 0xE054, 0xA64D79_rgb .WithAlpha(alpha));
441+
else
442+
BlendChar({ x + 1, y + 1 }, 0xE054, 0xC27BA0_rgb .WithAlpha(alpha));
443+
break;
438444
default:
439445
if(invert)
440446
BlendChar({ x, y }, 't', 0x000000_rgb .WithAlpha(alpha));

src/graphics/Icons.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ enum Icon
3838
IconPersistant,
3939
IconHeat,
4040
IconLife,
41-
IconGradient
41+
IconGradient,
42+
IconVort
4243
};

src/graphics/Renderer.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,14 @@ void Renderer::draw_air()
988988
c = RGB(r, g, b);
989989
}
990990
}
991+
else if (displayMode & DISPLAY_AIRW)
992+
{
993+
auto w = 4*Air::vorticity(*sim, y, x);
994+
if (w > 0.0f)
995+
c = RGB(clamp_flt(w, 0.0f, 8.0f), 0, 0); //positive vorticity is red
996+
else
997+
c = RGB(0, 0, clamp_flt(-w, 0.0f, 8.0f)); //negative vorticity is blue
998+
}
991999
if (findingElement)
9921000
{
9931001
c.Red /= 10;

src/gui/game/GameModel.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ GameModel::GameModel(GameView *newView):
6161
colour(255, 0, 0, 255),
6262
edgeMode(EDGE_VOID),
6363
ambientAirTemp(R_TEMP + 273.15f),
64+
vorticityCoeff(0.0f),
6465
decoSpace(DECOSPACE_SRGB),
6566
view(newView)
6667
{
@@ -121,6 +122,17 @@ GameModel::GameModel(GameView *newView):
121122
}
122123
}
123124
sim->air->ambientAirTemp = ambientAirTemp;
125+
126+
vorticityCoeff = 0.1f; // The default for old saves is 0, but use 0.1 for old configs
127+
{
128+
auto vort = prefs.Get("Simulation.VorticityCoeff", vorticityCoeff);
129+
if (0.0f <= vort && vort <= 1.0f)
130+
{
131+
vorticityCoeff = vort;
132+
}
133+
}
134+
sim->air->vorticityCoeff = vorticityCoeff;
135+
124136
decoSpace = prefs.Get("Simulation.DecoSpace", NUM_DECOSPACES, DECOSPACE_SRGB);
125137
sim->SetDecoSpace(decoSpace);
126138
if (prefs.Get("Simulation.NewtonianGravity", false))
@@ -308,6 +320,17 @@ float GameModel::GetAmbientAirTemperature()
308320
return this->ambientAirTemp;
309321
}
310322

323+
void GameModel::SetVorticityCoeff(float vorticityCoeff)
324+
{
325+
this->vorticityCoeff = vorticityCoeff;
326+
sim->air->vorticityCoeff = vorticityCoeff;
327+
}
328+
329+
float GameModel::GetVorticityCoeff()
330+
{
331+
return this->vorticityCoeff;
332+
}
333+
311334
void GameModel::SetDecoSpace(int decoSpace)
312335
{
313336
sim->SetDecoSpace(decoSpace);
@@ -736,6 +759,7 @@ void GameModel::SaveToSimParameters(const GameSave &saveData)
736759
sim->customGravityY = saveData.customGravityY;
737760
sim->air->airMode = saveData.airMode;
738761
sim->air->ambientAirTemp = saveData.ambientAirTemp;
762+
sim->air->vorticityCoeff = saveData.vorticityCoeff;
739763
sim->edgeMode = saveData.edgeMode;
740764
sim->legacy_enable = saveData.legacyEnable;
741765
sim->water_equal_test = saveData.waterEEnabled;
@@ -1112,6 +1136,7 @@ void GameModel::ClearSimulation()
11121136
sim->water_equal_test = false;
11131137
sim->SetEdgeMode(edgeMode);
11141138
sim->air->ambientAirTemp = ambientAirTemp;
1139+
sim->air->vorticityCoeff = vorticityCoeff;
11151140

11161141
sim->clear_sim();
11171142
ren->ClearAccumulation();

src/gui/game/GameModel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class GameModel
104104

105105
int edgeMode;
106106
float ambientAirTemp;
107+
float vorticityCoeff;
107108
int decoSpace;
108109

109110
String infoTip;
@@ -162,6 +163,8 @@ class GameModel
162163
}
163164
void SetAmbientAirTemperature(float ambientAirTemp);
164165
float GetAmbientAirTemperature();
166+
void SetVorticityCoeff(float vorticityCoeff);
167+
float GetVorticityCoeff();
165168
void SetDecoSpace(int decoSpace);
166169
int GetDecoSpace();
167170

src/gui/options/OptionsController.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ void OptionsController::SetAmbientAirTemperature(float ambientAirTemp)
6262
model->SetAmbientAirTemperature(ambientAirTemp);
6363
}
6464

65+
void OptionsController::SetVorticityCoeff(float vorticityCoeff)
66+
{
67+
model->SetVorticityCoeff(vorticityCoeff);
68+
}
69+
6570
void OptionsController::SetEdgeMode(int edgeMode)
6671
{
6772
model->SetEdgeMode(edgeMode);

src/gui/options/OptionsController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class OptionsController
2222
void SetCustomGravityY(float y);
2323
void SetAirMode(int airMode);
2424
void SetAmbientAirTemperature(float ambientAirTemp);
25+
void SetVorticityCoeff(float vorticityCoeff);
2526
void SetEdgeMode(int edgeMode);
2627
void SetTemperatureScale(int temperatureScale);
2728
void SetThreadedRendering(bool newThreadedRendering);

src/gui/options/OptionsModel.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ void OptionsModel::SetAmbientAirTemperature(float ambientAirTemp)
119119
notifySettingsChanged();
120120
}
121121

122+
float OptionsModel::GetVorticityCoeff()
123+
{
124+
return gModel->GetSimulation()->air->vorticityCoeff;
125+
}
126+
void OptionsModel::SetVorticityCoeff(float vorticityCoeff)
127+
{
128+
GlobalPrefs::Ref().Set("Simulation.VorticityCoeff", vorticityCoeff);
129+
gModel->SetVorticityCoeff(vorticityCoeff);
130+
notifySettingsChanged();
131+
}
132+
122133
int OptionsModel::GetGravityMode()
123134
{
124135
return sim->gravityMode;

0 commit comments

Comments
 (0)