Skip to content

Commit 0e2ba34

Browse files
Control the Lighting Engine with le_set_enabled in real time (#1193)
* Control the Lighting Engine with le_disable and le_enable in real time (FORK REDO FOR PR) * I hate it when I typo * Control the Lighting Engine in real time with le_set_active (new change) * Changed to le_set_enabled to be better in line with functions
1 parent 675c71e commit 0e2ba34

6 files changed

Lines changed: 54 additions & 0 deletions

File tree

autogen/lua_definitions/functions.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5155,6 +5155,12 @@ function le_set_max_lights_per_vertex(count)
51555155
-- ...
51565156
end
51575157

5158+
--- @param value boolean
5159+
--- This will let the user control the lighting engine in real time to disable or enable it.
5160+
function le_set_enabled(value)
5161+
-- ...
5162+
end
5163+
51585164
--- @param pos Vec3f
51595165
--- @param out Color
51605166
--- @param lightIntensityScalar number

docs/lua/functions-4.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,29 @@ Sets the max amount of lights that can affect a vertex
170170

171171
<br />
172172

173+
## [le_set_enabled](#le_set_enabled)
174+
175+
### Description
176+
This will let the user control the lighting engine in real time to disable or enable it.
177+
178+
### Lua Example
179+
`le_set_enabled(value)`
180+
181+
### Parameters
182+
| Field | Type |
183+
| ----- | ---- |
184+
| value | `boolean` |
185+
186+
### Returns
187+
- None
188+
189+
### C Prototype
190+
`void le_set_enabled(bool value);`
191+
192+
[:arrow_up_small:](#)
193+
194+
<br />
195+
173196
## [le_calculate_lighting_color](#le_calculate_lighting_color)
174197

175198
### Description

docs/lua/functions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,7 @@
983983
- [le_get_ambient_color](functions-4.md#le_get_ambient_color)
984984
- [le_set_ambient_color](functions-4.md#le_set_ambient_color)
985985
- [le_set_max_lights_per_vertex](functions-4.md#le_set_max_lights_per_vertex)
986+
- [le_set_enabled](functions-4.md#le_set_enabled)
986987
- [le_calculate_lighting_color](functions-4.md#le_calculate_lighting_color)
987988
- [le_calculate_lighting_color_with_normal](functions-4.md#le_calculate_lighting_color_with_normal)
988989
- [le_calculate_lighting_dir](functions-4.md#le_calculate_lighting_dir)

src/engine/lighting_engine.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ C_FIELD void le_set_max_lights_per_vertex(u8 count) {
9292
sMaxLightsPerVertex = count;
9393
}
9494

95+
C_FIELD void le_set_enabled(bool value) {
96+
sEnabled = value;
97+
}
98+
9599
static inline void le_tone_map_total_weighted(Color out, Color inAmbient, Vec3f inColor, f32 weight) {
96100
out[0] = clamp_u8((inAmbient[0] + inColor[0]) / weight);
97101
out[1] = clamp_u8((inAmbient[1] + inColor[1]) / weight);

src/engine/lighting_engine.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ void le_get_ambient_color(VEC_OUT Color out);
3737
void le_set_ambient_color(u8 r, u8 g, u8 b);
3838
/* |description|Sets the max amount of lights that can affect a vertex|descriptionEnd| */
3939
void le_set_max_lights_per_vertex(u8 count);
40+
/* |description|This will let the user control the lighting engine in real time to disable or enable it. |descriptionEnd|*/
41+
void le_set_enabled(bool value);
4042

4143
void le_calculate_vertex_lighting(const Vtx_t* v, Vec3f pos, VEC_OUT Color out);
4244
/* |description|Calculates the lighting with `lightIntensityScalar` at a position and outputs the color in `out`|descriptionEnd|*/

src/pc/lua/smlua_functions_autogen.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15657,6 +15657,23 @@ int smlua_func_le_set_max_lights_per_vertex(lua_State* L) {
1565715657
return 1;
1565815658
}
1565915659

15660+
int smlua_func_le_set_enabled(lua_State* L) {
15661+
if (L == NULL) { return 0; }
15662+
15663+
int top = lua_gettop(L);
15664+
if (top != 1) {
15665+
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "le_set_enabled", 1, top);
15666+
return 0;
15667+
}
15668+
15669+
bool value = smlua_to_boolean(L, 1);
15670+
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "le_set_enabled"); return 0; }
15671+
15672+
le_set_enabled(value);
15673+
15674+
return 1;
15675+
}
15676+
1566015677
int smlua_func_le_calculate_lighting_color(lua_State* L) {
1566115678
if (L == NULL) { return 0; }
1566215679

@@ -37809,6 +37826,7 @@ void smlua_bind_functions_autogen(void) {
3780937826
smlua_bind_function(L, "le_get_ambient_color", smlua_func_le_get_ambient_color);
3781037827
smlua_bind_function(L, "le_set_ambient_color", smlua_func_le_set_ambient_color);
3781137828
smlua_bind_function(L, "le_set_max_lights_per_vertex", smlua_func_le_set_max_lights_per_vertex);
37829+
smlua_bind_function(L, "le_set_enabled", smlua_func_le_set_enabled);
3781237830
smlua_bind_function(L, "le_calculate_lighting_color", smlua_func_le_calculate_lighting_color);
3781337831
smlua_bind_function(L, "le_calculate_lighting_color_with_normal", smlua_func_le_calculate_lighting_color_with_normal);
3781437832
smlua_bind_function(L, "le_calculate_lighting_dir", smlua_func_le_calculate_lighting_dir);

0 commit comments

Comments
 (0)