@@ -60,6 +60,15 @@ int gNumObjects = 16; | |||||
LOLFX_RESOURCE_DECLARE(front_camera_sprite); | LOLFX_RESOURCE_DECLARE(front_camera_sprite); | ||||
//Damp for float | |||||
template <typename T1, typename T2, typename Tf> | |||||
static inline T1 damp(const T1 &a, const T2 &b, const Tf &x, const Tf &dt) | |||||
{ | |||||
if (dt <= .0f) | |||||
return a; | |||||
return lol::lerp(a, b, dt / (dt + x)); | |||||
} | |||||
BtPhysTest::BtPhysTest(bool editor) | BtPhysTest::BtPhysTest(bool editor) | ||||
{ | { | ||||
m_init_status = 0; | m_init_status = 0; | ||||
@@ -1 +1 @@ | |||||
Subproject commit d22746ebaf889679f9fd5f5aecb8882ff614ee73 | |||||
Subproject commit 80481a587ce2ed0ca69f4a1c117ed903a1ae816a |
@@ -12,7 +12,7 @@ liblol_core_a_SOURCES = \ | |||||
textureimage.cpp textureimage.h textureimage-private.h \ | textureimage.cpp textureimage.h textureimage-private.h \ | ||||
tileset.cpp tileset.h video.cpp video.h \ | tileset.cpp tileset.h video.cpp video.h \ | ||||
profiler.cpp profiler.h text.cpp text.h emitter.cpp emitter.h \ | profiler.cpp profiler.h text.cpp text.h emitter.cpp emitter.h \ | ||||
numeric.h messageservice.cpp messageservice.h \ | |||||
messageservice.cpp messageservice.h \ | |||||
gradient.cpp gradient.h gradient.lolfx \ | gradient.cpp gradient.h gradient.lolfx \ | ||||
platform.cpp platform.h sprite.cpp sprite.h camera.cpp camera.h \ | platform.cpp platform.h sprite.cpp sprite.h camera.cpp camera.h \ | ||||
light.cpp light.h \ | light.cpp light.h \ | ||||
@@ -270,7 +270,6 @@ | |||||
<ClInclude Include="mesh\mesh.h" /> | <ClInclude Include="mesh\mesh.h" /> | ||||
<ClInclude Include="mesh\primitivemesh.h" /> | <ClInclude Include="mesh\primitivemesh.h" /> | ||||
<ClInclude Include="messageservice.h" /> | <ClInclude Include="messageservice.h" /> | ||||
<ClInclude Include="numeric.h" /> | |||||
<ClInclude Include="platform.h" /> | <ClInclude Include="platform.h" /> | ||||
<ClInclude Include="private\nx\nx-app.h"> | <ClInclude Include="private\nx\nx-app.h"> | ||||
<ExcludedFromBuild Condition="'$(Platform)'!='NX64'">true</ExcludedFromBuild> | <ExcludedFromBuild Condition="'$(Platform)'!='NX64'">true</ExcludedFromBuild> | ||||
@@ -374,4 +373,4 @@ | |||||
<ImportGroup Label="ExtensionTargets"> | <ImportGroup Label="ExtensionTargets"> | ||||
<Import Project="$(LolDir)\build\msbuild\lolfx.targets" /> | <Import Project="$(LolDir)\build\msbuild\lolfx.targets" /> | ||||
</ImportGroup> | </ImportGroup> | ||||
</Project> | |||||
</Project> |
@@ -396,7 +396,6 @@ | |||||
<Filter>mesh</Filter> | <Filter>mesh</Filter> | ||||
</ClInclude> | </ClInclude> | ||||
<ClInclude Include="messageservice.h" /> | <ClInclude Include="messageservice.h" /> | ||||
<ClInclude Include="numeric.h" /> | |||||
<ClInclude Include="platform.h" /> | <ClInclude Include="platform.h" /> | ||||
<ClInclude Include="profiler.h" /> | <ClInclude Include="profiler.h" /> | ||||
<ClInclude Include="scene.h" /> | <ClInclude Include="scene.h" /> | ||||
@@ -646,4 +645,4 @@ | |||||
<Filter>external</Filter> | <Filter>external</Filter> | ||||
</CopyFileToFolders> | </CopyFileToFolders> | ||||
</ItemGroup> | </ItemGroup> | ||||
</Project> | |||||
</Project> |
@@ -17,8 +17,6 @@ | |||||
// -------------------------------------------------------- | // -------------------------------------------------------- | ||||
// | // | ||||
#include <lol/../numeric.h> | |||||
// Static classes | // Static classes | ||||
#include <lol/../platform.h> | #include <lol/../platform.h> | ||||
#include <lol/../video.h> | #include <lol/../video.h> | ||||
@@ -1,82 +0,0 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#pragma once | |||||
// | |||||
// The Matrix classes | |||||
// ------------------ | |||||
// | |||||
#include <lol/math> // lol::lerp, lol::clamp | |||||
#include <algorithm> // std::swap | |||||
#include <cstdlib> | |||||
#include <stdint.h> | |||||
namespace lol | |||||
{ | |||||
/* Next power of two. */ | |||||
template <typename T> static inline T PotUp(T val) | |||||
{ | |||||
val = val - 1; | |||||
if (sizeof(val) > 4) val = val | ((uint64_t)val >> 32); | |||||
if (sizeof(val) > 2) val = val | ((uint64_t)val >> 16); | |||||
if (sizeof(val) > 1) val = val | ((uint64_t)val >> 8); | |||||
val = val | ((uint64_t)val >> 4); | |||||
val = val | ((uint64_t)val >> 2); | |||||
val = val | ((uint64_t)val >> 1); | |||||
return val + 1; | |||||
} | |||||
//Damp for float | |||||
template <typename T1, typename T2, typename Tf> static inline T1 damp(const T1 &a, const T2 &b, const Tf &x, const Tf &dt) | |||||
{ | |||||
if (dt <= .0f) | |||||
return a; | |||||
return lol::lerp(a, b, dt / (dt + x)); | |||||
} | |||||
//SmoothClamp clamps x in [a - sd, b + sd] and returns a value in [a, b] that is smoothed at the borders. | |||||
static inline float SmoothClamp(float &x, float a, float b, float sd) | |||||
{ | |||||
if (b < a) | |||||
std::swap(a, b); | |||||
float tx = x; | |||||
float ta = a - sd; | |||||
float tb = b + sd; | |||||
if (sd > 0.f) | |||||
{ | |||||
if ((b - a) < 2.f * sd) | |||||
sd = .5f * (b - a); | |||||
if (tx < a + sd && tx > a - sd) | |||||
{ | |||||
float t = (tx - a) / sd; | |||||
t = 0.25f * (t + 1.0f) * (t + 1.0f); | |||||
tx = a + t * sd; | |||||
} | |||||
else if (tx < b + sd && tx > b - sd) | |||||
{ | |||||
float t = -(tx - b) / sd; | |||||
t = 0.25f * (t + 1.0f) * (t + 1.0f); | |||||
tx = b - t * sd; | |||||
} | |||||
} | |||||
x = lol::clamp(x, ta, tb); | |||||
return lol::clamp(tx, a, b); | |||||
} | |||||
} /* namespace lol */ | |||||
@@ -33,9 +33,9 @@ test_base_DEPENDENCIES = @LOL_DEPS@ | |||||
test_math_SOURCES = test-common.cpp \ | test_math_SOURCES = test-common.cpp \ | ||||
math/array2d.cpp math/array3d.cpp math/arraynd.cpp math/box.cpp \ | math/array2d.cpp math/array3d.cpp math/arraynd.cpp math/box.cpp \ | ||||
math/cmplx.cpp math/half.cpp math/interp.cpp math/matrix.cpp \ | |||||
math/quat.cpp math/rand.cpp math/real.cpp math/rotation.cpp \ | |||||
math/trig.cpp math/vector.cpp math/polynomial.cpp math/noise/simplex.cpp \ | |||||
math/cmplx.cpp math/half.cpp math/matrix.cpp math/quat.cpp \ | |||||
math/rand.cpp math/real.cpp math/rotation.cpp math/trig.cpp \ | |||||
math/vector.cpp math/polynomial.cpp math/noise/simplex.cpp \ | |||||
math/bigint.cpp math/sqt.cpp math/numbers.cpp | math/bigint.cpp math/sqt.cpp math/numbers.cpp | ||||
test_math_DEPENDENCIES = @LOL_DEPS@ | test_math_DEPENDENCIES = @LOL_DEPS@ | ||||
@@ -1,42 +0,0 @@ | |||||
// | |||||
// Lol Engine — Unit tests | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#if HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include <lol/unit_test> | |||||
#include <../legacy/lol/math/interp.h> | |||||
namespace lol | |||||
{ | |||||
lolunit_declare_fixture(interp_test) | |||||
{ | |||||
lolunit_declare_test(time_interp_test) | |||||
{ | |||||
TimeInterp<float> ti; | |||||
ti.Set(1.f, 10.f); | |||||
ti.Set(1.f, 20.f); | |||||
ti.Set(1.f, 30.f); | |||||
lolunit_assert_doubles_equal(0.f, ti.Get(-3.0f), 1.e-5f); | |||||
lolunit_assert_doubles_equal(10.f, ti.Get(-2.0f), 1.e-5f); | |||||
lolunit_assert_doubles_equal(20.f, ti.Get(-1.0f), 1.e-5f); | |||||
lolunit_assert_doubles_equal(30.f, ti.Get(0.0f), 1.e-5f); | |||||
lolunit_assert_doubles_equal(40.f, ti.Get(1.0f), 1.e-5f); | |||||
} | |||||
}; | |||||
} /* namespace lol */ | |||||
@@ -47,7 +47,6 @@ | |||||
<ClCompile Include="math\bigint.cpp" /> | <ClCompile Include="math\bigint.cpp" /> | ||||
<ClCompile Include="math\cmplx.cpp" /> | <ClCompile Include="math\cmplx.cpp" /> | ||||
<ClCompile Include="math\half.cpp" /> | <ClCompile Include="math\half.cpp" /> | ||||
<ClCompile Include="math\interp.cpp" /> | |||||
<ClCompile Include="math\matrix.cpp" /> | <ClCompile Include="math\matrix.cpp" /> | ||||
<ClCompile Include="math\noise\simplex.cpp" /> | <ClCompile Include="math\noise\simplex.cpp" /> | ||||
<ClCompile Include="math\numbers.cpp" /> | <ClCompile Include="math\numbers.cpp" /> | ||||
@@ -82,4 +81,4 @@ | |||||
<ImportGroup Label="ExtensionTargets"> | <ImportGroup Label="ExtensionTargets"> | ||||
<Import Project="$(LolDir)\build\msbuild\lolfx.targets" /> | <Import Project="$(LolDir)\build\msbuild\lolfx.targets" /> | ||||
</ImportGroup> | </ImportGroup> | ||||
</Project> | |||||
</Project> |
@@ -81,8 +81,8 @@ void TextureImage::Init(std::string const &path, image* img) | |||||
m_data->m_texture = nullptr; | m_data->m_texture = nullptr; | ||||
m_data->m_image = img; | m_data->m_image = img; | ||||
m_data->m_image_size = m_data->m_image->size(); | m_data->m_image_size = m_data->m_image->size(); | ||||
m_data->m_texture_size = ivec2(PotUp(m_data->m_image_size.x), | |||||
PotUp(m_data->m_image_size.y)); | |||||
m_data->m_texture_size = ivec2(lol::bit_ceil(m_data->m_image_size.x), | |||||
lol::bit_ceil(m_data->m_image_size.y)); | |||||
m_drawgroup = tickable::group::draw::texture; | m_drawgroup = tickable::group::draw::texture; | ||||
} | } | ||||
@@ -153,8 +153,8 @@ void TextureImage::UpdateTexture(image* img) | |||||
{ | { | ||||
m_data->m_image = img; | m_data->m_image = img; | ||||
m_data->m_image_size = m_data->m_image->size(); | m_data->m_image_size = m_data->m_image->size(); | ||||
m_data->m_texture_size = ivec2(PotUp(m_data->m_image_size.x), | |||||
PotUp(m_data->m_image_size.y)); | |||||
m_data->m_texture_size = ivec2(lol::bit_ceil(m_data->m_image_size.x), | |||||
lol::bit_ceil(m_data->m_image_size.y)); | |||||
} | } | ||||
Texture * TextureImage::GetTexture() | Texture * TextureImage::GetTexture() | ||||