feat: post-effects array parameters & add gfx.posteffects.set_array & make shadows opacity depending on clouds opacity
This commit is contained in:
@@ -57,6 +57,22 @@ static int l_set_params(lua::State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_set_array(lua::State* L) {
|
||||
size_t index = static_cast<size_t>(lua::tointeger(L, 1));
|
||||
auto key = lua::require_string(L, 2);
|
||||
auto data = lua::require_lstring(L, 3);
|
||||
auto effect = post_processing->getEffect(index);
|
||||
if (effect == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
std::vector<ubyte> buffer(
|
||||
reinterpret_cast<const ubyte*>(data.begin()),
|
||||
reinterpret_cast<const ubyte*>(data.end())
|
||||
);
|
||||
effect->setArray(key, std::move(buffer));
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg posteffectslib[] = {
|
||||
{"index", lua::wrap<l_index>},
|
||||
{"set_effect", lua::wrap<l_set_effect>},
|
||||
@@ -64,5 +80,6 @@ const luaL_Reg posteffectslib[] = {
|
||||
{"set_intensity", lua::wrap<l_set_intensity>},
|
||||
{"is_active", lua::wrap<l_is_active>},
|
||||
{"set_params", lua::wrap<l_set_params>},
|
||||
{"set_array", lua::wrap<l_set_array>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <random>
|
||||
|
||||
#include "libs/api_lua.hpp"
|
||||
#include "debug/Logger.hpp"
|
||||
@@ -149,6 +150,15 @@ int l_debug_print(lua::State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::normal_distribution<double> randomFloats(0.0f, 1.0f);
|
||||
std::default_random_engine generator;
|
||||
}
|
||||
|
||||
static int l_math_normal_random(lua::State* L) {
|
||||
return lua::pushnumber(L, randomFloats(generator));
|
||||
}
|
||||
|
||||
void initialize_libs_extends(lua::State* L) {
|
||||
if (lua::getglobal(L, "debug")) {
|
||||
lua::pushcfunction(L, lua::wrap<l_debug_error>);
|
||||
@@ -163,6 +173,12 @@ void initialize_libs_extends(lua::State* L) {
|
||||
lua::pushcfunction(L, lua::wrap<l_debug_print>);
|
||||
lua::setfield(L, "print");
|
||||
|
||||
lua::pop(L);
|
||||
}
|
||||
if (lua::getglobal(L, "math")) {
|
||||
lua::pushcfunction(L, lua::wrap<l_math_normal_random>);
|
||||
lua::setfield(L, "normal_random");
|
||||
|
||||
lua::pop(L);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user