mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-07-13 12:36:47 +02:00
Compare commits
10 Commits
4ab1d99529
...
negative_b
Author | SHA1 | Date | |
---|---|---|---|
1722f61250 | |||
0abb860185 | |||
22dc949cc5 | |||
196ea7b93b | |||
f655da82d5 | |||
d672f8a52c | |||
6df865de3e | |||
e9c62f9201 | |||
7bce78167b | |||
a45da5c2b0 |
2
.github/workflows/cmake.yml
vendored
2
.github/workflows/cmake.yml
vendored
@ -9,7 +9,7 @@ on:
|
|||||||
env:
|
env:
|
||||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
BUILD_TYPE: Debug
|
BUILD_TYPE: Debug
|
||||||
EM_VERSION: 2.0.24
|
EM_VERSION: 3.1.32
|
||||||
EM_CACHE_FOLDER: 'emsdk-cache'
|
EM_CACHE_FOLDER: 'emsdk-cache'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
28
external/imgui/CMakeLists.txt
vendored
28
external/imgui/CMakeLists.txt
vendored
@ -2,43 +2,31 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
|||||||
|
|
||||||
project(imgui C CXX)
|
project(imgui C CXX)
|
||||||
|
|
||||||
set(CPP_FILES
|
add_library(imgui
|
||||||
|
"imgui/imgui.h"
|
||||||
"imgui/imgui.cpp"
|
"imgui/imgui.cpp"
|
||||||
"imgui/imgui_draw.cpp"
|
"imgui/imgui_draw.cpp"
|
||||||
"imgui/imgui_widgets.cpp"
|
"imgui/imgui_widgets.cpp"
|
||||||
"imgui/imgui_tables.cpp"
|
"imgui/imgui_tables.cpp"
|
||||||
"imgui/imgui_demo.cpp"
|
"imgui/imgui_demo.cpp"
|
||||||
|
|
||||||
"imgui/misc/cpp/imgui_stdlib.cpp"
|
|
||||||
|
|
||||||
"imgui_plot_var.cpp"
|
|
||||||
|
|
||||||
#"imgui_impl_sdl_gl3.cpp" # very old
|
|
||||||
#"imgui_impl_sdl.cpp" # old
|
|
||||||
#"imgui_impl_opengl3.cpp" # old
|
|
||||||
"imgui/backends/imgui_impl_sdl.cpp"
|
|
||||||
"imgui/backends/imgui_impl_opengl3.cpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
set(HPP_FILES
|
|
||||||
"imgui/imgui.h"
|
|
||||||
"imgui/imstb_rectpack.h"
|
"imgui/imstb_rectpack.h"
|
||||||
"imgui/imstb_textedit.h"
|
"imgui/imstb_textedit.h"
|
||||||
"imgui/imstb_truetype.h"
|
"imgui/imstb_truetype.h"
|
||||||
|
|
||||||
"imgui/misc/cpp/imgui_stdlib.h"
|
"imgui/misc/cpp/imgui_stdlib.h"
|
||||||
|
"imgui/misc/cpp/imgui_stdlib.cpp"
|
||||||
|
|
||||||
"imgui_plot_var.hpp"
|
"imgui_plot_var.hpp"
|
||||||
|
"imgui_plot_var.cpp"
|
||||||
|
|
||||||
#"imgui_impl_sdl_gl3.h" # very old
|
# TODO: seperate backends into libs
|
||||||
#"imgui_impl_sdl.h" # old
|
"imgui/backends/imgui_impl_sdl2.h"
|
||||||
#"imgui_impl_opengl3.h" # old
|
"imgui/backends/imgui_impl_sdl2.cpp"
|
||||||
"imgui/backends/imgui_impl_sdl.h"
|
|
||||||
"imgui/backends/imgui_impl_opengl3.h"
|
"imgui/backends/imgui_impl_opengl3.h"
|
||||||
|
"imgui/backends/imgui_impl_opengl3.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(imgui ${CPP_FILES} ${HPP_FILES})
|
|
||||||
|
|
||||||
target_compile_features(imgui PUBLIC cxx_std_11)
|
target_compile_features(imgui PUBLIC cxx_std_11)
|
||||||
|
|
||||||
if(MM_OPENGL_3_GLES)
|
if(MM_OPENGL_3_GLES)
|
||||||
|
2
external/imgui/imgui
vendored
2
external/imgui/imgui
vendored
Submodule external/imgui/imgui updated: 9aae45eb4a...458a109031
5
external/stb/CMakeLists.txt
vendored
5
external/stb/CMakeLists.txt
vendored
@ -11,9 +11,8 @@ target_link_libraries(stb_image stb)
|
|||||||
add_library(stb_image_write "stb/stb_image_write.h" "stb_image_write.cpp")
|
add_library(stb_image_write "stb/stb_image_write.h" "stb_image_write.cpp")
|
||||||
target_link_libraries(stb_image_write stb)
|
target_link_libraries(stb_image_write stb)
|
||||||
|
|
||||||
# lel TODO: add back in when patent expires
|
add_library(stb_perlin "stb/stb_perlin.h" "stb_perlin.cpp")
|
||||||
#add_library(stb_perlin "stb/stb_perlin.h" "stb_perlin.cpp")
|
target_link_libraries(stb_perlin stb)
|
||||||
#target_link_libraries(stb_perlin stb)
|
|
||||||
|
|
||||||
add_library(stb_rect_pack "stb/stb_rect_pack.h" "stb_rect_pack.cpp")
|
add_library(stb_rect_pack "stb/stb_rect_pack.h" "stb_rect_pack.cpp")
|
||||||
target_link_libraries(stb_rect_pack stb)
|
target_link_libraries(stb_rect_pack stb)
|
||||||
|
2
external/stb/stb
vendored
2
external/stb/stb
vendored
Submodule external/stb/stb updated: af1a5bc352...5736b15f7e
2
external/tracy/CMakeLists.txt
vendored
2
external/tracy/CMakeLists.txt
vendored
@ -10,6 +10,8 @@ if(NOT EMSCRIPTEN)
|
|||||||
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/TracyClient.cpp"
|
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/TracyClient.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option(TRACY_ENABLE "Enable tracy profiling" OFF)
|
||||||
|
|
||||||
if(TRACY_ENABLE)
|
if(TRACY_ENABLE)
|
||||||
target_compile_definitions(tracy_client PUBLIC TRACY_ENABLE)
|
target_compile_definitions(tracy_client PUBLIC TRACY_ENABLE)
|
||||||
#target_compile_definitions(tracy_client PUBLIC TRACY_NO_SYSTEM_TRACING)
|
#target_compile_definitions(tracy_client PUBLIC TRACY_NO_SYSTEM_TRACING)
|
||||||
|
2
external/tracy/tracy
vendored
2
external/tracy/tracy
vendored
Submodule external/tracy/tracy updated: 5a1f5371b7...897aec5b06
@ -50,11 +50,11 @@ namespace MM::Services {
|
|||||||
public: // send/recv
|
public: // send/recv
|
||||||
|
|
||||||
// sends a packet of max getMaxPacketSize() bytes
|
// sends a packet of max getMaxPacketSize() bytes
|
||||||
virtual bool sendPacket(peer_id peer, channel_id channel, uint8_t* data, size_t data_size) = 0;
|
virtual bool sendPacket(peer_id peer, channel_id channel, const uint8_t* data, size_t data_size) = 0;
|
||||||
|
|
||||||
// sends a packet, automatically split if too big
|
// sends a packet, automatically split if too big
|
||||||
// !! only on lossless channels
|
// !! only on lossless channels
|
||||||
virtual bool sendPacketLarge(peer_id peer, channel_id channel, uint8_t* data, size_t data_size) = 0;
|
virtual bool sendPacketLarge(peer_id peer, channel_id channel, const uint8_t* data, size_t data_size) = 0;
|
||||||
|
|
||||||
// TODO: broadcast?
|
// TODO: broadcast?
|
||||||
// has any?
|
// has any?
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "./imgui_s.hpp"
|
#include "./imgui_s.hpp"
|
||||||
|
|
||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
#include <imgui/backends/imgui_impl_sdl.h>
|
#include <imgui/backends/imgui_impl_sdl2.h>
|
||||||
|
|
||||||
#ifdef MM_OPENGL_3
|
#ifdef MM_OPENGL_3
|
||||||
#include <imgui/backends/imgui_impl_opengl3.h>
|
#include <imgui/backends/imgui_impl_opengl3.h>
|
||||||
|
@ -97,6 +97,7 @@ Texture::handle_t Texture::createEmptyMultiSampled(int32_t internalFormat, int32
|
|||||||
(void)height;
|
(void)height;
|
||||||
(void)samples;
|
(void)samples;
|
||||||
assert(false && "GLES has no multisampling support");
|
assert(false && "GLES has no multisampling support");
|
||||||
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,14 +29,20 @@ void setup_bloom(
|
|||||||
const auto bloom_internal_format = GL_RGB565; // prolly fine. NOPE its not. it causes green pixely halos
|
const auto bloom_internal_format = GL_RGB565; // prolly fine. NOPE its not. it causes green pixely halos
|
||||||
const auto bloom_format_type = GL_UNSIGNED_BYTE;
|
const auto bloom_format_type = GL_UNSIGNED_BYTE;
|
||||||
#else
|
#else
|
||||||
//const auto bloom_internal_format = GL_RGBA16F;
|
const auto bloom_format_type = GL_RGBA;
|
||||||
const auto bloom_internal_format = GL_R11F_G11F_B10F;
|
const auto bloom_internal_format = GL_RGBA16F;
|
||||||
const auto bloom_format_type = GL_FLOAT;
|
//const auto bloom_internal_format = GL_R11F_G11F_B10F;
|
||||||
|
const auto bloom_data_type = GL_FLOAT;
|
||||||
|
|
||||||
|
//const auto bloom_format_type = GL_RGBA_INTEGER;
|
||||||
|
//const auto bloom_internal_format = GL_RGBA16I;
|
||||||
|
//const auto bloom_data_type = GL_SHORT;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
//const auto bloom_internal_format = GL_RGB16F;
|
const auto bloom_format_type = GL_RGB;
|
||||||
const auto bloom_internal_format = GL_R11F_G11F_B10F;
|
const auto bloom_internal_format = GL_RGB16F; // opengl silently upgrades to RGBA
|
||||||
const auto bloom_format_type = GL_FLOAT;
|
//const auto bloom_internal_format = GL_R11F_G11F_B10F; // no sign
|
||||||
|
const auto bloom_data_type = GL_FLOAT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{ // bloom in (bloom extraction)
|
{ // bloom in (bloom extraction)
|
||||||
@ -44,7 +50,7 @@ void setup_bloom(
|
|||||||
"bloom_in",
|
"bloom_in",
|
||||||
bloom_internal_format,
|
bloom_internal_format,
|
||||||
w * bloom_in_scale, h * bloom_in_scale,
|
w * bloom_in_scale, h * bloom_in_scale,
|
||||||
GL_RGB, bloom_format_type
|
bloom_format_type, bloom_data_type
|
||||||
);
|
);
|
||||||
{ // filter
|
{ // filter
|
||||||
rm_t.get("bloom_in"_hs)->bind(0);
|
rm_t.get("bloom_in"_hs)->bind(0);
|
||||||
@ -72,7 +78,7 @@ void setup_bloom(
|
|||||||
tex_out_id,
|
tex_out_id,
|
||||||
bloom_internal_format,
|
bloom_internal_format,
|
||||||
w * bloom_in_scale * glm::pow(bloom_phase_scale, i), h * bloom_in_scale * glm::pow(bloom_phase_scale, i),
|
w * bloom_in_scale * glm::pow(bloom_phase_scale, i), h * bloom_in_scale * glm::pow(bloom_phase_scale, i),
|
||||||
GL_RGB, bloom_format_type
|
bloom_format_type, bloom_data_type
|
||||||
);
|
);
|
||||||
{ // filter
|
{ // filter
|
||||||
rm_t.get(tex_out_id)->bind(0);
|
rm_t.get(tex_out_id)->bind(0);
|
||||||
@ -89,7 +95,7 @@ void setup_bloom(
|
|||||||
tex_tmp_id,
|
tex_tmp_id,
|
||||||
bloom_internal_format,
|
bloom_internal_format,
|
||||||
w * bloom_in_scale * glm::pow(bloom_phase_scale, i), h * bloom_in_scale * glm::pow(bloom_phase_scale, i),
|
w * bloom_in_scale * glm::pow(bloom_phase_scale, i), h * bloom_in_scale * glm::pow(bloom_phase_scale, i),
|
||||||
GL_RGB, bloom_format_type
|
bloom_format_type, bloom_data_type
|
||||||
);
|
);
|
||||||
{ // filter
|
{ // filter
|
||||||
rm_t.get(tex_tmp_id)->bind(0);
|
rm_t.get(tex_tmp_id)->bind(0);
|
||||||
|
@ -106,7 +106,15 @@ void main() {
|
|||||||
vec3 color = texture(color_tex, _uv).rgb;
|
vec3 color = texture(color_tex, _uv).rgb;
|
||||||
|
|
||||||
// TODO: expose threshold
|
// TODO: expose threshold
|
||||||
_out_color = max(vec3(0.0), color - vec3(1.0));
|
//_out_color = max(vec3(0.0), color - vec3(1.0));
|
||||||
|
|
||||||
|
//_out_color = mix(
|
||||||
|
//color, // < 0.0
|
||||||
|
//max(vec3(0.0), color - vec3(1.0)), // > 0.0
|
||||||
|
//step(vec3(0.0), color)
|
||||||
|
//);
|
||||||
|
|
||||||
|
_out_color = max(min(color, vec3(0.0)), color - vec3(1.0));
|
||||||
})")
|
})")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ void main() {
|
|||||||
vec3 color = texture(color_tex, _uv).rgb;
|
vec3 color = texture(color_tex, _uv).rgb;
|
||||||
vec3 bloom = texture(bloom_tex, _uv).rgb;
|
vec3 bloom = texture(bloom_tex, _uv).rgb;
|
||||||
|
|
||||||
vec3 comp = color + bloom * vec3(bloom_factor);
|
vec3 comp = max(vec3(0.0), color + bloom * vec3(bloom_factor));
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
const vec3 tint = vec3(1.5, 0.8, 1.1);
|
const vec3 tint = vec3(1.5, 0.8, 1.1);
|
||||||
|
@ -129,8 +129,9 @@ static void setup_fbos(MM::Engine& engine) {
|
|||||||
assert(rs.targets["game_view"]);
|
assert(rs.targets["game_view"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MM::Engine engine;
|
||||||
|
|
||||||
TEST(hdr_bloom_pipeline, it) {
|
TEST(hdr_bloom_pipeline, it) {
|
||||||
MM::Engine engine;
|
|
||||||
|
|
||||||
auto& sdl_ss = engine.addService<MM::Services::SDLService>();
|
auto& sdl_ss = engine.addService<MM::Services::SDLService>();
|
||||||
ASSERT_TRUE(engine.enableService<MM::Services::SDLService>());
|
ASSERT_TRUE(engine.enableService<MM::Services::SDLService>());
|
||||||
@ -228,7 +229,7 @@ TEST(hdr_bloom_pipeline, it) {
|
|||||||
col.color = {3.f, 3.f, 3.f, 1.f};
|
col.color = {3.f, 3.f, 3.f, 1.f};
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
auto e = scene.create();
|
auto e = scene.create();
|
||||||
auto& p = scene.emplace<MM::Components::Position2D>(e);
|
auto& p = scene.emplace<MM::Components::Position2D>(e);
|
||||||
p.pos.x = i * 9.f - 40;
|
p.pos.x = i * 9.f - 40;
|
||||||
@ -247,7 +248,43 @@ TEST(hdr_bloom_pipeline, it) {
|
|||||||
col.color = {rng.zeroToOne()*2.f, rng.zeroToOne()*2.f, rng.zeroToOne()*2.f, 1.f};
|
col.color = {rng.zeroToOne()*2.f, rng.zeroToOne()*2.f, rng.zeroToOne()*2.f, 1.f};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 5; i < 10; i++) {
|
||||||
|
auto e = scene.create();
|
||||||
|
auto& p = scene.emplace<MM::Components::Position2D>(e);
|
||||||
|
p.pos.x = i * 9.f - 40;
|
||||||
|
|
||||||
|
// zoffset is created by event
|
||||||
|
|
||||||
|
auto& s = scene.emplace<MM::Components::Scale2D>(e);
|
||||||
|
s.scale = {5,5};
|
||||||
|
|
||||||
|
scene.emplace<MM::Components::Rotation2D>(e);
|
||||||
|
|
||||||
|
auto& v = scene.emplace<MM::Components::Velocity2DRotation>(e);
|
||||||
|
v.rot_vel = i * 0.3f;
|
||||||
|
|
||||||
|
auto& col = scene.emplace<MM::Components::Color>(e);
|
||||||
|
col.color = {rng.zeroToOne()*-2.f, rng.zeroToOne()*-2.f, rng.zeroToOne()*-2.f, 1.f};
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // white background for negatives
|
||||||
|
auto e = scene.create();
|
||||||
|
auto& p = scene.emplace<MM::Components::Position2D>(e);
|
||||||
|
p.pos.y = 30.f;
|
||||||
|
p.pos.x = 25.f;
|
||||||
|
|
||||||
|
auto& s = scene.emplace<MM::Components::Scale2D>(e);
|
||||||
|
s.scale = {50,150};
|
||||||
|
|
||||||
|
auto& col = scene.emplace<MM::Components::Color>(e);
|
||||||
|
col.color = {1.f, 1.f, 1.f, 1.f};
|
||||||
|
}
|
||||||
|
|
||||||
engine.run();
|
engine.run();
|
||||||
|
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
|
engine.cleanup();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
@ -7,7 +7,7 @@ namespace MM::Random {
|
|||||||
|
|
||||||
// Seeded (Pseudo-) Random Number Generator
|
// Seeded (Pseudo-) Random Number Generator
|
||||||
struct SRNG {
|
struct SRNG {
|
||||||
// make shuffle compat
|
// make shuffle compat
|
||||||
// TODO: add more type info
|
// TODO: add more type info
|
||||||
using result_type = uint32_t;
|
using result_type = uint32_t;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ struct SRNG {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool roll(float prob) {
|
bool roll(float prob) {
|
||||||
return zeroToOne() <= prob;
|
return zeroToOne() <= prob; // TODO: just < ?
|
||||||
}
|
}
|
||||||
|
|
||||||
// more advanced
|
// more advanced
|
||||||
|
@ -194,10 +194,6 @@ struct StreamWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] size_t bytesWritten(void) noexcept {
|
[[nodiscard]] size_t bytesWritten(void) noexcept {
|
||||||
// TODO: is this assert valid?
|
|
||||||
assert(_scratch_bits == 0);
|
|
||||||
|
|
||||||
//return _bits_written/8 + ((_bits_written % 8) ? 1 : 0);
|
|
||||||
return (_bits_written+7) / 8;
|
return (_bits_written+7) / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ struct TestStruct {
|
|||||||
double f64 {0.};
|
double f64 {0.};
|
||||||
|
|
||||||
// float compressed [0; 1] range
|
// float compressed [0; 1] range
|
||||||
constexpr static float c0_f32_resolution = 0.001;
|
constexpr static float c0_f32_resolution = 0.001f;
|
||||||
constexpr static MM::ScalarRange2<float> c0_f32_r{0.f, 1.f};
|
constexpr static MM::ScalarRange2<float> c0_f32_r{0.f, 1.f};
|
||||||
float c0_f32_0 {0.f};
|
float c0_f32_0 {0.f};
|
||||||
float c0_f32_1 {0.f};
|
float c0_f32_1 {0.f};
|
||||||
@ -399,7 +399,7 @@ struct TestStruct {
|
|||||||
float c0_f32_3 {0.f};
|
float c0_f32_3 {0.f};
|
||||||
|
|
||||||
// float compressed [-1; 1] range
|
// float compressed [-1; 1] range
|
||||||
constexpr static float c1_f32_resolution = 0.05;
|
constexpr static float c1_f32_resolution = 0.05f;
|
||||||
constexpr static MM::ScalarRange2<float> c1_f32_r{-1.f, 1.f};
|
constexpr static MM::ScalarRange2<float> c1_f32_r{-1.f, 1.f};
|
||||||
float c1_f32_0 {0.f};
|
float c1_f32_0 {0.f};
|
||||||
float c1_f32_1 {0.f};
|
float c1_f32_1 {0.f};
|
||||||
@ -407,7 +407,7 @@ struct TestStruct {
|
|||||||
float c1_f32_3 {0.f};
|
float c1_f32_3 {0.f};
|
||||||
|
|
||||||
// float compressed [-1000; 1000] range
|
// float compressed [-1000; 1000] range
|
||||||
constexpr static float c2_f32_resolution = 0.01;
|
constexpr static float c2_f32_resolution = 0.01f;
|
||||||
constexpr static MM::ScalarRange2<float> c2_f32_r{-1000.f, 1000.f};
|
constexpr static MM::ScalarRange2<float> c2_f32_r{-1000.f, 1000.f};
|
||||||
float c2_f32_0 {0.f};
|
float c2_f32_0 {0.f};
|
||||||
float c2_f32_1 {0.f};
|
float c2_f32_1 {0.f};
|
||||||
|
@ -31,9 +31,10 @@ namespace MM::Services {
|
|||||||
SDLService::SDLService(uint32_t _sdl_init_flags) {
|
SDLService::SDLService(uint32_t _sdl_init_flags) {
|
||||||
MM::Logger::initSectionLogger("SDLService");
|
MM::Logger::initSectionLogger("SDLService");
|
||||||
|
|
||||||
//#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
//_sdl_init_flags &= ~SDL_INIT_HAPTIC;
|
_sdl_init_flags &= ~SDL_INIT_HAPTIC;
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
#if 1 // hack for mingw + wine
|
#if 1 // hack for mingw + wine
|
||||||
_sdl_init_flags &= ~SDL_INIT_SENSOR;
|
_sdl_init_flags &= ~SDL_INIT_SENSOR;
|
||||||
#endif
|
#endif
|
||||||
|
@ -60,6 +60,16 @@ struct ScalarRange2 {
|
|||||||
[[nodiscard]] constexpr bool inRange(T&& value) const {
|
[[nodiscard]] constexpr bool inRange(T&& value) const {
|
||||||
return value >= min() && value <= max();
|
return value >= min() && value <= max();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lerp between min and max
|
||||||
|
[[nodiscard]] constexpr T map(const float a) const {
|
||||||
|
return min() * (1.f-a) + max() * a;
|
||||||
|
}
|
||||||
|
|
||||||
|
// reverse map
|
||||||
|
[[nodiscard]] constexpr float unmap(const T& v) const {
|
||||||
|
return (v - min()) / static_cast<float>(max() - min());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // MM
|
} // MM
|
||||||
|
Reference in New Issue
Block a user