Make gravity mask accessible from Lua

This commit is contained in:
Tamás Bálint Misius
2025-02-04 08:23:25 +01:00
parent da111d5244
commit 51f5259de3
2 changed files with 10 additions and 1 deletions

View File

@@ -206,6 +206,14 @@ static int gravityMass(lua_State *L)
}); });
} }
static int gravityMask(lua_State *L)
{
auto *lsi = GetLSI();
return LuaBlockMap(L, [lsi](Vec2<int> p) -> uint32_t & {
return lsi->sim->gravIn.mask[p];
});
}
static int gravityField(lua_State *L) static int gravityField(lua_State *L)
{ {
auto *lsi = GetLSI(); auto *lsi = GetLSI();
@@ -1931,6 +1939,7 @@ void LuaSimulation::Open(lua_State *L)
LFUNC(ensureDeterminism), LFUNC(ensureDeterminism),
LFUNC(paused), LFUNC(paused),
LFUNC(gravityMass), LFUNC(gravityMass),
LFUNC(gravityMask),
LFUNC(gravityField), LFUNC(gravityField),
LFUNC(resetSpark), LFUNC(resetSpark),
LFUNC(resetVelocity), LFUNC(resetVelocity),

View File

@@ -3595,7 +3595,7 @@ void Simulation::BeforeSim()
air->update_airh(); air->update_airh();
DispatchNewtonianGravity(); DispatchNewtonianGravity();
// gravIn is now potentially garbage, which is ok, we were going to clear it for the frame anyway // gravIn::mass is now potentially garbage, which is ok, we were going to clear it for the frame anyway
for (auto p : gravIn.mass.Size().OriginRect()) for (auto p : gravIn.mass.Size().OriginRect())
{ {
gravIn.mass[p] = 0.f; gravIn.mass[p] = 0.f;