| @@ -459,7 +459,7 @@ void BtPhysTest::tick_game(float seconds) | |||||
| //Jump handling | //Jump handling | ||||
| //if (length(PhysObj->GetPhysic()->GetLinearVelocity()) < ZERO_SPEED) | //if (length(PhysObj->GetPhysic()->GetLinearVelocity()) < ZERO_SPEED) | ||||
| if (lol::abs(PhysObj->GetPhysic()->GetLinearVelocity().y) < ZERO_SPEED) | |||||
| if (lol::fabs(PhysObj->GetPhysic()->GetLinearVelocity().y) < ZERO_SPEED) | |||||
| obj_timer -= seconds; | obj_timer -= seconds; | ||||
| if (obj_timer < .0f) | if (obj_timer < .0f) | ||||
| @@ -472,15 +472,15 @@ void BtPhysTest::tick_game(float seconds) | |||||
| } | } | ||||
| } | } | ||||
| float fov_ratio = max(max(lol::abs(screen_min_max[0].x), lol::abs(screen_min_max[0].y)), | |||||
| max(lol::abs(screen_min_max[1].x), lol::abs(screen_min_max[1].y))); | |||||
| float fov_ratio = max(max(lol::fabs(screen_min_max[0].x), lol::fabs(screen_min_max[0].y)), | |||||
| max(lol::fabs(screen_min_max[1].x), lol::fabs(screen_min_max[1].y))); | |||||
| vec3 new_target = cam_center / cam_factor; | vec3 new_target = cam_center / cam_factor; | ||||
| float fov_dp = .0f; | float fov_dp = .0f; | ||||
| float loc_dp = .0f; | float loc_dp = .0f; | ||||
| //ideally fov is on the target | //ideally fov is on the target | ||||
| if (lol::abs(fov_ratio - 1.f) < .2f) | |||||
| if (lol::fabs(fov_ratio - 1.f) < .2f) | |||||
| fov_dp = ((m_cam_target == -1)?(.7f):(.2f)); | fov_dp = ((m_cam_target == -1)?(.7f):(.2f)); | ||||
| else | else | ||||
| fov_dp = ((m_cam_target == -1)?(1.7f):(.9f)); | fov_dp = ((m_cam_target == -1)?(1.7f):(.9f)); | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine — Input tutorial | // Lol Engine — Input tutorial | ||||
| // | // | ||||
| // Copyright © 2011—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2011—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -55,9 +55,9 @@ public: | |||||
| auto joystick = input::joystick(0); | auto joystick = input::joystick(0); | ||||
| if ((bool)joystick) | if ((bool)joystick) | ||||
| { | { | ||||
| if (lol::abs(joystick->axis(input::axis::LeftY)) > 0.2f) | |||||
| if (lol::fabs(joystick->axis(input::axis::LeftY)) > 0.2f) | |||||
| m_pitch_angle += joystick->axis(input::axis::LeftY) * seconds; | m_pitch_angle += joystick->axis(input::axis::LeftY) * seconds; | ||||
| if (lol::abs(joystick->axis(input::axis::LeftX)) > 0.2f) | |||||
| if (lol::fabs(joystick->axis(input::axis::LeftX)) > 0.2f) | |||||
| m_yaw_angle += joystick->axis(input::axis::LeftX) * seconds; | m_yaw_angle += joystick->axis(input::axis::LeftX) * seconds; | ||||
| } | } | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine — Sound tutorial | // Lol Engine — Sound tutorial | ||||
| // | // | ||||
| // Copyright © 2011—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2011—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -35,7 +35,7 @@ public: | |||||
| } | } | ||||
| for (size_t i = 0; i < m_instrument.size(); ++i) | for (size_t i = 0; i < m_instrument.size(); ++i) | ||||
| m_instrument[i] = (int16_t)(i % 80 * (10000 - lol::abs(i - 10000)) * 40 / 10000); | |||||
| m_instrument[i] = (int16_t)(i % 80 * (10000 - lol::fabs(i - 10000)) * 40 / 10000); | |||||
| m_sample = sample::create(m_instrument.data(), 40000); | m_sample = sample::create(m_instrument.data(), 40000); | ||||
| m_text = new Text("SPACE for sine wave, Left Click for white noise", | m_text = new Text("SPACE for sine wave, Left Click for white noise", | ||||
| @@ -216,7 +216,7 @@ public: | |||||
| else if (m_zoom_speed) | else if (m_zoom_speed) | ||||
| { | { | ||||
| m_zoom_speed *= std::pow(2.0, -seconds * 5.0); | m_zoom_speed *= std::pow(2.0, -seconds * 5.0); | ||||
| if (lol::abs(m_zoom_speed) < 1e-5 || m_drag) | |||||
| if (lol::fabs(m_zoom_speed) < 1e-5 || m_drag) | |||||
| m_zoom_speed = 0.0; | m_zoom_speed = 0.0; | ||||
| } | } | ||||
| @@ -1 +1 @@ | |||||
| Subproject commit 4446947aec179186e165d36f36425ee568a71a34 | |||||
| Subproject commit ec5f308bd3b69183359e6a16a151acca4fa69f46 | |||||
| @@ -35,7 +35,7 @@ liblol_core_headers = \ | |||||
| lol/base/log.h \ | lol/base/log.h \ | ||||
| \ | \ | ||||
| lol/algorithm/all.h \ | lol/algorithm/all.h \ | ||||
| lol/algorithm/sort.h lol/algorithm/portal.h \ | |||||
| lol/algorithm/portal.h \ | |||||
| \ | \ | ||||
| lol/audio/all.h \ | lol/audio/all.h \ | ||||
| lol/audio/audio.h lol/audio/sample.h \ | lol/audio/audio.h lol/audio/sample.h \ | ||||
| @@ -80,7 +80,7 @@ void msg::helper(message_type type, char const *fmt, va_list ap) | |||||
| #if !defined LOL_BUILD_DEBUG && !_DEBUG | #if !defined LOL_BUILD_DEBUG && !_DEBUG | ||||
| if (type == message_type::debug) | if (type == message_type::debug) | ||||
| { | { | ||||
| static bool const disable_debug = sys::getenv("LOL_DEBUG").size() > 0; | |||||
| static bool const disable_debug = os::getenv("LOL_DEBUG").size() > 0; | |||||
| if (disable_debug) | if (disable_debug) | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // © 2009—2015 Cédric Lecacheur <jordx@free.fr> | // © 2009—2015 Cédric Lecacheur <jordx@free.fr> | ||||
| // © 2009—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | // © 2009—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | ||||
| // | // | ||||
| @@ -207,7 +207,7 @@ void EasyMesh::AppendCapsule(int ndivisions, float h, float d) | |||||
| p[k] = normalize(p[k]); | p[k] = normalize(p[k]); | ||||
| uv[k].x = (lol::atan2(p[k].z, p[k].x) + F_PI) / (F_PI * 2.f); | uv[k].x = (lol::atan2(p[k].z, p[k].x) + F_PI) / (F_PI * 2.f); | ||||
| if (abs(p[k].y) >= 1.0f) | |||||
| if (fabs(p[k].y) >= 1.0f) | |||||
| uv[k].x = -1.f; | uv[k].x = -1.f; | ||||
| uv[k].y = lol::atan2(p[k].y, dot(p[k], normalize(p[k] * vec3(1.f,0.f,1.f)))) / F_PI + 0.5f; | uv[k].y = lol::atan2(p[k].y, dot(p[k], normalize(p[k] * vec3(1.f,0.f,1.f)))) / F_PI + 0.5f; | ||||
| if (h) | if (h) | ||||
| @@ -241,7 +241,7 @@ void EasyMesh::AppendCapsule(int ndivisions, float h, float d) | |||||
| int rid[] = { id[k + l], id[(k + 1) % 3 + l] }; | int rid[] = { id[k + l], id[(k + 1) % 3 + l] }; | ||||
| if (uv[rid[0]].x >= .0f && | if (uv[rid[0]].x >= .0f && | ||||
| uv[rid[1]].x >= .0f && | uv[rid[1]].x >= .0f && | ||||
| abs(uv[rid[0]].x - uv[rid[1]].x) > .5f) | |||||
| fabs(uv[rid[0]].x - uv[rid[1]].x) > .5f) | |||||
| { | { | ||||
| if (uv[rid[0]].x < uv[rid[1]].x) | if (uv[rid[0]].x < uv[rid[1]].x) | ||||
| uv[rid[0]].x += 1.0f; | uv[rid[0]].x += 1.0f; | ||||
| @@ -155,7 +155,7 @@ void EasyMesh::DoMeshTransform(MeshTransform ct, Axis axis0, Axis axis1, float n | |||||
| case MeshTransform::Taper: | case MeshTransform::Taper: | ||||
| { | { | ||||
| float value = m_vert[i].m_coord[axis0.ToScalar()]; | float value = m_vert[i].m_coord[axis0.ToScalar()]; | ||||
| if (absolute) value = abs(value); | |||||
| if (absolute) value = fabs(value); | |||||
| m_vert[i].m_coord[(axis0.ToScalar() + 1) % 3] *= max(0.f, 1.f + (n0 * value + noff)); | m_vert[i].m_coord[(axis0.ToScalar() + 1) % 3] *= max(0.f, 1.f + (n0 * value + noff)); | ||||
| m_vert[i].m_coord[(axis0.ToScalar() + 2) % 3] *= max(0.f, 1.f + (n1 * value + noff)); | m_vert[i].m_coord[(axis0.ToScalar() + 2) % 3] *= max(0.f, 1.f + (n1 * value + noff)); | ||||
| break; | break; | ||||
| @@ -169,14 +169,14 @@ void EasyMesh::DoMeshTransform(MeshTransform ct, Axis axis0, Axis axis1, float n | |||||
| case MeshTransform::Shear: | case MeshTransform::Shear: | ||||
| { | { | ||||
| float value = m_vert[i].m_coord[axis0.ToScalar()]; | float value = m_vert[i].m_coord[axis0.ToScalar()]; | ||||
| if (absolute) value = abs(value); | |||||
| if (absolute) value = fabs(value); | |||||
| m_vert[i].m_coord[(axis0.ToScalar() + 1) % 3] += (n0 * value + noff); | m_vert[i].m_coord[(axis0.ToScalar() + 1) % 3] += (n0 * value + noff); | ||||
| m_vert[i].m_coord[(axis0.ToScalar() + 2) % 3] += (n1 * value + noff); | m_vert[i].m_coord[(axis0.ToScalar() + 2) % 3] += (n1 * value + noff); | ||||
| break; | break; | ||||
| } | } | ||||
| case MeshTransform::Stretch: | case MeshTransform::Stretch: | ||||
| { | { | ||||
| //float value = abs(std::get<0>(m_vert[i])[axis0.ToScalar()]); | |||||
| //float value = fabs(std::get<0>(m_vert[i])[axis0.ToScalar()]); | |||||
| //std::get<0>(m_vert[i])[(axis0.ToScalar() + 1) % 3] += (lol::pow(value, n0) + noff); | //std::get<0>(m_vert[i])[(axis0.ToScalar() + 1) % 3] += (lol::pow(value, n0) + noff); | ||||
| //std::get<0>(m_vert[i])[(axis0.ToScalar() + 2) % 3] += (lol::pow(value, n1) + noff); | //std::get<0>(m_vert[i])[(axis0.ToScalar() + 2) % 3] += (lol::pow(value, n1) + noff); | ||||
| break; | break; | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -13,8 +13,8 @@ | |||||
| #include <lol/engine-internal.h> | #include <lol/engine-internal.h> | ||||
| #include <cstdlib> | #include <cstdlib> | ||||
| #include <cstdint> | |||||
| #include <functional> | #include <functional> | ||||
| #include <stdint.h> | |||||
| namespace lol | namespace lol | ||||
| { | { | ||||
| @@ -13,8 +13,8 @@ | |||||
| #include <lol/engine-internal.h> | #include <lol/engine-internal.h> | ||||
| #include <cstdlib> | #include <cstdlib> | ||||
| #include <cstdint> | |||||
| #include <functional> | #include <functional> | ||||
| #include <stdint.h> | |||||
| namespace lol | namespace lol | ||||
| { | { | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -20,8 +20,8 @@ | |||||
| #include <lol/engine/tickable.h> | #include <lol/engine/tickable.h> | ||||
| #include <cstdint> | |||||
| #include <memory> | |||||
| #include <stdint.h> // uint32_t | |||||
| #include <memory> // std::shared_ptr | |||||
| namespace lol | namespace lol | ||||
| { | { | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2004—2017 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2004—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -37,6 +37,8 @@ enum class MergeMode | |||||
| template<PixelFormat FORMAT, MergeMode MODE> | template<PixelFormat FORMAT, MergeMode MODE> | ||||
| static image generic_merge(image &src1, image &src2, float alpha) | static image generic_merge(image &src1, image &src2, float alpha) | ||||
| { | { | ||||
| using std::min, std::max, std::fabs; | |||||
| typedef typename PixelType<FORMAT>::type pixel_t; | typedef typename PixelType<FORMAT>::type pixel_t; | ||||
| ASSERT(src1.size() == src2.size()); | ASSERT(src1.size() == src2.size()); | ||||
| @@ -70,7 +72,7 @@ static image generic_merge(image &src1, image &src2, float alpha) | |||||
| else if (MODE == MergeMode::Sub) | else if (MODE == MergeMode::Sub) | ||||
| dstp[n] = lol::max(src1p[n] - src2p[n], pixel_t(0.f)); | dstp[n] = lol::max(src1p[n] - src2p[n], pixel_t(0.f)); | ||||
| else if (MODE == MergeMode::Difference) | else if (MODE == MergeMode::Difference) | ||||
| dstp[n] = lol::abs(src1p[n] - src2p[n]); | |||||
| dstp[n] = lol::fabs(src1p[n] - src2p[n]); | |||||
| } | } | ||||
| src1.unlock(src1p); | src1.unlock(src1p); | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2004—2017 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2004—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -57,7 +57,7 @@ image image::Convolution(array2d<float> const &in_kernel) | |||||
| float p = in_kernel[dx][dy] * in_kernel[bestx][besty]; | float p = in_kernel[dx][dy] * in_kernel[bestx][besty]; | ||||
| float q = in_kernel[dx][besty] * in_kernel[bestx][dy]; | float q = in_kernel[dx][besty] * in_kernel[bestx][dy]; | ||||
| if (lol::abs(p - q) > 1.0e-8f) | |||||
| if (lol::fabs(p - q) > 1.0e-8f) | |||||
| separable = false; | separable = false; | ||||
| } | } | ||||
| } | } | ||||
| @@ -67,7 +67,7 @@ image image::Convolution(array2d<float> const &in_kernel) | |||||
| /* Matrix rank is 1! Separate the filter. */ | /* Matrix rank is 1! Separate the filter. */ | ||||
| array<float> hvec, vvec; | array<float> hvec, vvec; | ||||
| float norm = 1.0f / lol::sqrt(lol::abs(in_kernel[bestx][besty])); | |||||
| float norm = 1.0f / lol::sqrt(lol::fabs(in_kernel[bestx][besty])); | |||||
| for (int dx = 0; dx < ksize.x; dx++) | for (int dx = 0; dx < ksize.x; dx++) | ||||
| hvec << norm * in_kernel[dx][besty]; | hvec << norm * in_kernel[dx][besty]; | ||||
| for (int dy = 0; dy < ksize.y; dy++) | for (int dy = 0; dy < ksize.y; dy++) | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2004—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2004—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -290,8 +290,8 @@ array2d<float> image::kernel::gaussian(vec2 radius, float angle, vec2 delta) | |||||
| /* FIXME: the kernel becomes far too big with large values of dx, because | /* FIXME: the kernel becomes far too big with large values of dx, because | ||||
| * we grow both left and right. Fix the growing direction. */ | * we grow both left and right. Fix the growing direction. */ | ||||
| int const krx = (int)(3.f * bbx + .99999f + lol::ceil(lol::abs(delta.x))); | |||||
| int const kry = (int)(3.f * bby + .99999f + lol::ceil(lol::abs(delta.y))); | |||||
| int const krx = (int)(3.f * bbx + .99999f + lol::ceil(lol::fabs(delta.x))); | |||||
| int const kry = (int)(3.f * bby + .99999f + lol::ceil(lol::fabs(delta.y))); | |||||
| ivec2 size(2 * krx + 1, 2 * kry + 1); | ivec2 size(2 * krx + 1, 2 * kry + 1); | ||||
| float const Kx = -1.f / (2.f * radius.x * radius.x); | float const Kx = -1.f / (2.f * radius.x * radius.x); | ||||
| float const Ky = -1.f / (2.f * radius.y * radius.y); | float const Ky = -1.f / (2.f * radius.y * radius.y); | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -57,7 +57,7 @@ struct LightType | |||||
| { | { | ||||
| LightType lv = LightType(i); | LightType lv = LightType(i); | ||||
| float nv = lv.f(); | float nv = lv.f(); | ||||
| float ntop = lol::abs(nv - v); | |||||
| float ntop = lol::fabs(nv - v); | |||||
| if (ntop < top) | if (ntop < top) | ||||
| { | { | ||||
| top = ntop; | top = ntop; | ||||
| @@ -237,7 +237,6 @@ | |||||
| <ClInclude Include="lolua\baselua.h" /> | <ClInclude Include="lolua\baselua.h" /> | ||||
| <ClInclude Include="lol\algorithm\all.h" /> | <ClInclude Include="lol\algorithm\all.h" /> | ||||
| <ClInclude Include="lol\algorithm\portal.h" /> | <ClInclude Include="lol\algorithm\portal.h" /> | ||||
| <ClInclude Include="lol\algorithm\sort.h" /> | |||||
| <ClInclude Include="lol\audio\all.h" /> | <ClInclude Include="lol\audio\all.h" /> | ||||
| <ClInclude Include="lol\audio\audio.h" /> | <ClInclude Include="lol\audio\audio.h" /> | ||||
| <ClInclude Include="lol\audio\sample.h" /> | <ClInclude Include="lol\audio\sample.h" /> | ||||
| @@ -311,9 +311,6 @@ | |||||
| <ClInclude Include="lol\algorithm\portal.h"> | <ClInclude Include="lol\algorithm\portal.h"> | ||||
| <Filter>lol\algorithm</Filter> | <Filter>lol\algorithm</Filter> | ||||
| </ClInclude> | </ClInclude> | ||||
| <ClInclude Include="lol\algorithm\sort.h"> | |||||
| <Filter>lol\algorithm</Filter> | |||||
| </ClInclude> | |||||
| <ClInclude Include="lol\base\array.h"> | <ClInclude Include="lol\base\array.h"> | ||||
| <Filter>lol\base</Filter> | <Filter>lol\base</Filter> | ||||
| </ClInclude> | </ClInclude> | ||||
| @@ -12,7 +12,6 @@ | |||||
| #pragma once | #pragma once | ||||
| #include <lol/algorithm/sort.h> | |||||
| #include <../legacy/lol/algorithm/aabb_tree.h> | #include <../legacy/lol/algorithm/aabb_tree.h> | ||||
| #include <lol/algorithm/portal.h> | #include <lol/algorithm/portal.h> | ||||
| @@ -140,7 +140,7 @@ public: | |||||
| mat4 inv_proj_mx = inverse(proj); | mat4 inv_proj_mx = inverse(proj); | ||||
| // First: Check normal dot | // First: Check normal dot | ||||
| if (lol::abs(dot(mat3(inverse(view)) * vec3(0.f, 0.f, 1.f), m_normal)) < .00001f) | |||||
| if (lol::fabs(dot(mat3(inverse(view)) * vec3(0.f, 0.f, 1.f), m_normal)) < .00001f) | |||||
| return false; | return false; | ||||
| // Second: convert to screen coordinates | // Second: convert to screen coordinates | ||||
| @@ -177,7 +177,7 @@ public: | |||||
| //world calculations | //world calculations | ||||
| proj_p[k] = inv_proj_mx * vec4(port_2d[j[k].x].x, port_2d[j[k].y].y, (i<4)?(port_2d[0].z):(1.f), 1.f); | proj_p[k] = inv_proj_mx * vec4(port_2d[j[k].x].x, port_2d[j[k].y].y, (i<4)?(port_2d[0].z):(1.f), 1.f); | ||||
| proj_p[k] /= proj_p[k].w; | proj_p[k] /= proj_p[k].w; | ||||
| proj_p[k].z = lol::abs(proj_p[k].z); | |||||
| proj_p[k].z = lol::fabs(proj_p[k].z); | |||||
| for (int h = 0; h < 3; h++) | for (int h = 0; h < 3; h++) | ||||
| { | { | ||||
| @@ -230,7 +230,7 @@ public: | |||||
| //Check if at least one point is not on the same side as the others | //Check if at least one point is not on the same side as the others | ||||
| for (int i = 0; i < 3; i++) | for (int i = 0; i < 3; i++) | ||||
| if (lol::abs(pos_test[i]) == 4) | |||||
| if (lol::fabs(pos_test[i]) == 4) | |||||
| return false; | return false; | ||||
| return true; | return true; | ||||
| @@ -1,130 +0,0 @@ | |||||
| // | |||||
| // Lol Engine | |||||
| // | |||||
| // Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||||
| // © 2013—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||||
| // | |||||
| // 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 | |||||
| #include <lol/base/array.h> | |||||
| #include <lol/math/rand.h> | |||||
| #include <../legacy/lol/math/functions.h> // lol::max | |||||
| namespace lol | |||||
| { | |||||
| /* | |||||
| * Shuffle an array. | |||||
| */ | |||||
| template<typename T, typename ARRAY> | |||||
| void array_base<T, ARRAY>::shuffle() | |||||
| { | |||||
| auto n = count(); | |||||
| auto ni = n; | |||||
| while (n > 0) | |||||
| { | |||||
| ni = lol::rand(n--) | 0; | |||||
| this->swap(ni, n); | |||||
| } | |||||
| } | |||||
| /* | |||||
| * Sort an array | |||||
| */ | |||||
| template<typename T, typename ARRAY> | |||||
| static void quick_swap_sort(array_base<T, ARRAY> &a, | |||||
| ptrdiff_t start, ptrdiff_t stop); | |||||
| template<typename T, typename ARRAY> | |||||
| void array_base<T, ARRAY>::sort(SortAlgorithm algorithm) | |||||
| { | |||||
| #if !SORT_WORKS // yeah cause it's shite. | |||||
| algorithm = SortAlgorithm::Bubble; | |||||
| #endif | |||||
| // Classic bubble | |||||
| if (algorithm == SortAlgorithm::Bubble) | |||||
| { | |||||
| int d = 1; | |||||
| for (ptrdiff_t i = 0; i < count_s() - 1; i = lol::max(i + d, (ptrdiff_t)0)) | |||||
| { | |||||
| if (i <= 0 || m_data[i] < m_data[i + 1]) | |||||
| d = 1; | |||||
| if (m_data[i + 1] < m_data[i]) | |||||
| { | |||||
| this->swap(i, i + 1); | |||||
| d = -1; | |||||
| } | |||||
| } | |||||
| } | |||||
| // Quick sort with swap | |||||
| else if (algorithm == SortAlgorithm::QuickSwap) | |||||
| { | |||||
| quick_swap_sort(*this, 0, count_s()); | |||||
| } | |||||
| } | |||||
| template<typename T, typename ARRAY> | |||||
| static void quick_swap_sort(array_base<T, ARRAY> &a, | |||||
| ptrdiff_t start, ptrdiff_t stop) | |||||
| { | |||||
| ptrdiff_t m[3] = | |||||
| { | |||||
| rand(start, stop), | |||||
| rand(start, stop), | |||||
| rand(start, stop) | |||||
| }; | |||||
| for (int i = 0; i < 2; ) | |||||
| { | |||||
| if (a[m[i+1]] < a[m[i]]) | |||||
| { | |||||
| ptrdiff_t mt = m[i+1]; | |||||
| m[i+1] = m[i]; | |||||
| m[i] = mt; | |||||
| i = 0; | |||||
| } | |||||
| else | |||||
| i++; | |||||
| } | |||||
| // actual stuff | |||||
| T median = a[m[1]]; | |||||
| ptrdiff_t i0 = start, i1 = stop - 1; | |||||
| bool b_swap = false; | |||||
| while (i0 < i1) | |||||
| { | |||||
| if (!(a[i0] < median) && a[i1] < median) | |||||
| { | |||||
| a.swap(i0, i1); | |||||
| i0++; | |||||
| i1--; | |||||
| b_swap = true; | |||||
| } | |||||
| else | |||||
| { | |||||
| if (a[i0] < median) | |||||
| i0++; | |||||
| if (!(a[i1] < median)) | |||||
| i1--; | |||||
| } | |||||
| } | |||||
| if (stop - start == 1 || !b_swap) | |||||
| return; | |||||
| if (start < i0) | |||||
| quick_swap_sort(a, start, i0); | |||||
| if (i0 < stop) | |||||
| quick_swap_sort(a, i0, stop); | |||||
| } | |||||
| } /* namespace lol */ | |||||
| @@ -20,8 +20,7 @@ | |||||
| #include <lol/base/private/features.h> | #include <lol/base/private/features.h> | ||||
| #include <cstdint> | |||||
| #include <cstdarg> | |||||
| #include <cstdarg> // va_list | |||||
| namespace lol | namespace lol | ||||
| { | { | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -19,8 +19,7 @@ | |||||
| // loop. | // loop. | ||||
| // | // | ||||
| #include <cstdint> | |||||
| #include <memory> | |||||
| #include <memory> // std::shared_ptr | |||||
| namespace lol | namespace lol | ||||
| { | { | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -17,10 +17,10 @@ | |||||
| // ---------------- | // ---------------- | ||||
| // | // | ||||
| #include <string> | |||||
| #include <map> | |||||
| #include <memory> | |||||
| #include <cstdint> | |||||
| #include <string> // std::string | |||||
| #include <map> // std::map | |||||
| #include <memory> // std::shared_ptr | |||||
| #include <stdint.h> // int64_t | |||||
| #include "engine/entity.h" | #include "engine/entity.h" | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -17,8 +17,9 @@ | |||||
| // ----------------------- | // ----------------------- | ||||
| // | // | ||||
| #include <map> | |||||
| #include <cstdint> | |||||
| #include <string> // std::string | |||||
| #include <map> // std::map | |||||
| #include <stdint.h> // int64_t | |||||
| namespace lol | namespace lol | ||||
| { | { | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -17,9 +17,8 @@ | |||||
| // ------------------------------- | // ------------------------------- | ||||
| // | // | ||||
| #include <string> | |||||
| #include <cstdint> | |||||
| #include <cstdlib> | |||||
| #include <string> // std::string | |||||
| #include <cstdlib> // std::getenv | |||||
| namespace lol | namespace lol | ||||
| { | { | ||||
| @@ -57,24 +56,6 @@ extern void init(int argc, char *argv[], | |||||
| extern void add_data_dir(std::string const &dir); | extern void add_data_dir(std::string const &dir); | ||||
| extern array<std::string> get_path_list(std::string const &file); | extern array<std::string> get_path_list(std::string const &file); | ||||
| static inline std::string getenv(std::string const &var) | |||||
| { | |||||
| #if _MSC_VER | |||||
| char *buf = nullptr; | |||||
| size_t count = 0; | |||||
| if (_dupenv_s(&buf, &count, var.c_str()) == 0 && buf) | |||||
| { | |||||
| std::string ret(buf); | |||||
| free(buf); | |||||
| return ret; | |||||
| } | |||||
| #else | |||||
| if (auto val = std::getenv(var.c_str())) | |||||
| return std::string(val); | |||||
| #endif | |||||
| return std::string(); | |||||
| } | |||||
| } /* namespace sys */ | } /* namespace sys */ | ||||
| } /* namespace lol */ | } /* namespace lol */ | ||||
| @@ -1,27 +1,27 @@ | |||||
| // | // | ||||
| // Lol Engine | |||||
| // Lol Engine | |||||
| // | // | ||||
| // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||||
| // (c) 2010-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com> | |||||
| // This program is free software; 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 Sam Hocevar. See | |||||
| // http://www.wtfpl.net/ for more details. | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // © 2010—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||||
| // | |||||
| // 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. | |||||
| // | // | ||||
| #include <lol/engine-internal.h> | #include <lol/engine-internal.h> | ||||
| #include <cstdlib> /* free() */ | |||||
| #include <cstring> /* strdup() */ | |||||
| #include <ostream> /* std::ostream */ | |||||
| #include <algorithm> // std::min | |||||
| #include <cmath> // std::fabs | |||||
| namespace lol | namespace lol | ||||
| { | { | ||||
| //Test epsilon stuff | //Test epsilon stuff | ||||
| TestEpsilon g_test_epsilon; | TestEpsilon g_test_epsilon; | ||||
| float TestEpsilon::Get() { return g_test_epsilon.m_epsilon; } | float TestEpsilon::Get() { return g_test_epsilon.m_epsilon; } | ||||
| void TestEpsilon::Set(float epsilon) { g_test_epsilon.m_epsilon = lol::max(epsilon, .0f); } | |||||
| void TestEpsilon::Set(float epsilon) { using std::max; g_test_epsilon.m_epsilon = max(epsilon, .0f); } | |||||
| const TestEpsilon& TestEpsilon::F(float value) { g_test_epsilon.m_value = value; return g_test_epsilon; } | const TestEpsilon& TestEpsilon::F(float value) { g_test_epsilon.m_value = value; return g_test_epsilon; } | ||||
| float TestEpsilon::Minus()const { return m_value - m_epsilon; } | float TestEpsilon::Minus()const { return m_value - m_epsilon; } | ||||
| float TestEpsilon::Plus() const { return m_value + m_epsilon; } | float TestEpsilon::Plus() const { return m_value + m_epsilon; } | ||||
| @@ -102,7 +102,7 @@ namespace lol | |||||
| //Check the normal before doing any other calculations | //Check the normal before doing any other calculations | ||||
| vec3 plane_norm[2] = { cross(normalize(triD[0]), normalize(triD[1])), | vec3 plane_norm[2] = { cross(normalize(triD[0]), normalize(triD[1])), | ||||
| cross(normalize(triD[3]), normalize(triD[4])) }; | cross(normalize(triD[3]), normalize(triD[4])) }; | ||||
| if (abs(dot(plane_norm[0], plane_norm[1])) == 1.0f) | |||||
| if (fabs(dot(plane_norm[0], plane_norm[1])) == 1.0f) | |||||
| return false; | return false; | ||||
| #if 0 | #if 0 | ||||
| @@ -256,13 +256,15 @@ namespace lol | |||||
| //-- | //-- | ||||
| bool TestPointVsFrustum(const vec3& point, const mat4& frustum, vec3* result_point) | bool TestPointVsFrustum(const vec3& point, const mat4& frustum, vec3* result_point) | ||||
| { | { | ||||
| using std::fabs; | |||||
| vec4 proj_point = frustum * vec4(point, 1.f); | vec4 proj_point = frustum * vec4(point, 1.f); | ||||
| proj_point /= proj_point.w; | proj_point /= proj_point.w; | ||||
| if (result_point) | if (result_point) | ||||
| *result_point = proj_point.xyz; | *result_point = proj_point.xyz; | ||||
| for (int i = 0; i < 3; i++) | for (int i = 0; i < 3; i++) | ||||
| if (lol::abs(proj_point[i]) > 1.f) | |||||
| if (fabs(proj_point[i]) > 1.f) | |||||
| return false; | return false; | ||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -414,7 +414,7 @@ void Scene::AddLine(vec3 a, vec3 b, vec4 col) | |||||
| m_line_api.m_lines.push(l); | m_line_api.m_lines.push(l); | ||||
| } | } | ||||
| void Scene::AddLine(vec3 a, vec3 b, vec4 col, float duration, int mask) | |||||
| void Scene::AddLine(vec3 a, vec3 b, vec4 col, float duration, uint32_t mask) | |||||
| { | { | ||||
| struct line l { a, b, col, duration, mask, false, false }; | struct line l { a, b, col, duration, mask, false, false }; | ||||
| m_line_api.m_lines.push(l); | m_line_api.m_lines.push(l); | ||||
| @@ -245,7 +245,7 @@ public: | |||||
| public: | public: | ||||
| void AddLine(vec3 a, vec3 b, vec4 color); | void AddLine(vec3 a, vec3 b, vec4 color); | ||||
| void AddLine(vec3 a, vec3 b, vec4 color, float duration, int mask); | |||||
| void AddLine(vec3 a, vec3 b, vec4 color, float duration, uint32_t mask); | |||||
| void AddLight(Light *light); | void AddLight(Light *light); | ||||
| array<Light *> const &GetLights(); | array<Light *> const &GetLights(); | ||||
| @@ -19,6 +19,7 @@ | |||||
| // | // | ||||
| #include <lol/base/utils.h> | #include <lol/base/utils.h> | ||||
| #include <lol/math/rand.h> | |||||
| #include <string> | #include <string> | ||||