Procházet zdrojové kódy

Clean up header usage.

legacy
Sam Hocevar před 5 roky
rodič
revize
53e86aa9c5
30 změnil soubory, kde provedl 74 přidání a 224 odebrání
  1. +4
    -4
      doc/samples/btphystest.cpp
  2. +3
    -3
      doc/tutorial/07_input.cpp
  3. +2
    -2
      doc/tutorial/09_sound.cpp
  4. +1
    -1
      doc/tutorial/11_fractal.cpp
  5. +1
    -1
      lol-core
  6. +1
    -1
      src/Makefile.am
  7. +1
    -1
      src/base/log.cpp
  8. +3
    -3
      src/easymesh/easymeshprimitive.cpp
  9. +3
    -3
      src/easymesh/easymeshtransform.cpp
  10. +2
    -2
      src/engine/tickable.cpp
  11. +1
    -1
      src/engine/ticker.cpp
  12. +3
    -3
      src/engine/ticker.h
  13. +4
    -2
      src/image/combine.cpp
  14. +3
    -3
      src/image/filter/convolution.cpp
  15. +3
    -3
      src/image/kernel.cpp
  16. +2
    -2
      src/light.h
  17. +0
    -1
      src/lol-core.vcxproj
  18. +0
    -3
      src/lol-core.vcxproj.filters
  19. +0
    -1
      src/lol/algorithm/all.h
  20. +3
    -3
      src/lol/algorithm/portal.h
  21. +0
    -130
      src/lol/algorithm/sort.h
  22. +1
    -2
      src/lol/base/log.h
  23. +2
    -3
      src/lol/engine/tickable.h
  24. +5
    -5
      src/lol/gpu/shader.h
  25. +4
    -3
      src/lol/sys/file.h
  26. +3
    -22
      src/lol/sys/init.h
  27. +16
    -14
      src/math/geometry.cpp
  28. +1
    -1
      src/scene.cpp
  29. +1
    -1
      src/scene.h
  30. +1
    -0
      src/utils.h

+ 4
- 4
doc/samples/btphystest.cpp Zobrazit soubor

@@ -459,7 +459,7 @@ void BtPhysTest::tick_game(float seconds)

//Jump handling
//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;

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;
float fov_dp = .0f;
float loc_dp = .0f;

//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));
else
fov_dp = ((m_cam_target == -1)?(1.7f):(.9f));


+ 3
- 3
doc/tutorial/07_input.cpp Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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
// the extent permitted by applicable law. You can redistribute it
@@ -55,9 +55,9 @@ public:
auto joystick = input::joystick(0);
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;
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;
}



+ 2
- 2
doc/tutorial/09_sound.cpp Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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
// 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)
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_text = new Text("SPACE for sine wave, Left Click for white noise",


+ 1
- 1
doc/tutorial/11_fractal.cpp Zobrazit soubor

@@ -216,7 +216,7 @@ public:
else if (m_zoom_speed)
{
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;
}



+ 1
- 1
lol-core

@@ -1 +1 @@
Subproject commit 4446947aec179186e165d36f36425ee568a71a34
Subproject commit ec5f308bd3b69183359e6a16a151acca4fa69f46

+ 1
- 1
src/Makefile.am Zobrazit soubor

@@ -35,7 +35,7 @@ liblol_core_headers = \
lol/base/log.h \
\
lol/algorithm/all.h \
lol/algorithm/sort.h lol/algorithm/portal.h \
lol/algorithm/portal.h \
\
lol/audio/all.h \
lol/audio/audio.h lol/audio/sample.h \


+ 1
- 1
src/base/log.cpp Zobrazit soubor

@@ -80,7 +80,7 @@ void msg::helper(message_type type, char const *fmt, va_list ap)
#if !defined LOL_BUILD_DEBUG && !_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)
return;
}


+ 3
- 3
src/easymesh/easymeshprimitive.cpp Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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 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]);

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].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)
@@ -241,7 +241,7 @@ void EasyMesh::AppendCapsule(int ndivisions, float h, float d)
int rid[] = { id[k + l], id[(k + 1) % 3 + l] };
if (uv[rid[0]].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)
uv[rid[0]].x += 1.0f;


+ 3
- 3
src/easymesh/easymeshtransform.cpp Zobrazit soubor

@@ -155,7 +155,7 @@ void EasyMesh::DoMeshTransform(MeshTransform ct, Axis axis0, Axis axis1, float n
case MeshTransform::Taper:
{
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() + 2) % 3] *= max(0.f, 1.f + (n1 * value + noff));
break;
@@ -169,14 +169,14 @@ void EasyMesh::DoMeshTransform(MeshTransform ct, Axis axis0, Axis axis1, float n
case MeshTransform::Shear:
{
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() + 2) % 3] += (n1 * value + noff);
break;
}
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() + 2) % 3] += (lol::pow(value, n1) + noff);
break;


+ 2
- 2
src/engine/tickable.cpp Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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
// the extent permitted by applicable law. You can redistribute it
@@ -13,8 +13,8 @@
#include <lol/engine-internal.h>

#include <cstdlib>
#include <cstdint>
#include <functional>
#include <stdint.h>

namespace lol
{


+ 1
- 1
src/engine/ticker.cpp Zobrazit soubor

@@ -13,8 +13,8 @@
#include <lol/engine-internal.h>

#include <cstdlib>
#include <cstdint>
#include <functional>
#include <stdint.h>

namespace lol
{


+ 3
- 3
src/engine/ticker.h Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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
// the extent permitted by applicable law. You can redistribute it
@@ -20,8 +20,8 @@

#include <lol/engine/tickable.h>

#include <cstdint>
#include <memory>
#include <stdint.h> // uint32_t
#include <memory> // std::shared_ptr

namespace lol
{


+ 4
- 2
src/image/combine.cpp Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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
// the extent permitted by applicable law. You can redistribute it
@@ -37,6 +37,8 @@ enum class MergeMode
template<PixelFormat FORMAT, MergeMode MODE>
static image generic_merge(image &src1, image &src2, float alpha)
{
using std::min, std::max, std::fabs;

typedef typename PixelType<FORMAT>::type pixel_t;

ASSERT(src1.size() == src2.size());
@@ -70,7 +72,7 @@ static image generic_merge(image &src1, image &src2, float alpha)
else if (MODE == MergeMode::Sub)
dstp[n] = lol::max(src1p[n] - src2p[n], pixel_t(0.f));
else if (MODE == MergeMode::Difference)
dstp[n] = lol::abs(src1p[n] - src2p[n]);
dstp[n] = lol::fabs(src1p[n] - src2p[n]);
}

src1.unlock(src1p);


+ 3
- 3
src/image/filter/convolution.cpp Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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
// 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 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;
}
}
@@ -67,7 +67,7 @@ image image::Convolution(array2d<float> const &in_kernel)
/* Matrix rank is 1! Separate the filter. */
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++)
hvec << norm * in_kernel[dx][besty];
for (int dy = 0; dy < ksize.y; dy++)


+ 3
- 3
src/image/kernel.cpp Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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
// 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
* 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);
float const Kx = -1.f / (2.f * radius.x * radius.x);
float const Ky = -1.f / (2.f * radius.y * radius.y);


+ 2
- 2
src/light.h Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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
// the extent permitted by applicable law. You can redistribute it
@@ -57,7 +57,7 @@ struct LightType
{
LightType lv = LightType(i);
float nv = lv.f();
float ntop = lol::abs(nv - v);
float ntop = lol::fabs(nv - v);
if (ntop < top)
{
top = ntop;


+ 0
- 1
src/lol-core.vcxproj Zobrazit soubor

@@ -237,7 +237,6 @@
<ClInclude Include="lolua\baselua.h" />
<ClInclude Include="lol\algorithm\all.h" />
<ClInclude Include="lol\algorithm\portal.h" />
<ClInclude Include="lol\algorithm\sort.h" />
<ClInclude Include="lol\audio\all.h" />
<ClInclude Include="lol\audio\audio.h" />
<ClInclude Include="lol\audio\sample.h" />


+ 0
- 3
src/lol-core.vcxproj.filters Zobrazit soubor

@@ -311,9 +311,6 @@
<ClInclude Include="lol\algorithm\portal.h">
<Filter>lol\algorithm</Filter>
</ClInclude>
<ClInclude Include="lol\algorithm\sort.h">
<Filter>lol\algorithm</Filter>
</ClInclude>
<ClInclude Include="lol\base\array.h">
<Filter>lol\base</Filter>
</ClInclude>


+ 0
- 1
src/lol/algorithm/all.h Zobrazit soubor

@@ -12,7 +12,6 @@

#pragma once

#include <lol/algorithm/sort.h>
#include <../legacy/lol/algorithm/aabb_tree.h>
#include <lol/algorithm/portal.h>


+ 3
- 3
src/lol/algorithm/portal.h Zobrazit soubor

@@ -140,7 +140,7 @@ public:
mat4 inv_proj_mx = inverse(proj);

// 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;

// Second: convert to screen coordinates
@@ -177,7 +177,7 @@ public:
//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] /= 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++)
{
@@ -230,7 +230,7 @@ public:

//Check if at least one point is not on the same side as the others
for (int i = 0; i < 3; i++)
if (lol::abs(pos_test[i]) == 4)
if (lol::fabs(pos_test[i]) == 4)
return false;

return true;


+ 0
- 130
src/lol/algorithm/sort.h Zobrazit soubor

@@ -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 */


+ 1
- 2
src/lol/base/log.h Zobrazit soubor

@@ -20,8 +20,7 @@

#include <lol/base/private/features.h>

#include <cstdint>
#include <cstdarg>
#include <cstdarg> // va_list

namespace lol
{


+ 2
- 3
src/lol/engine/tickable.h Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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
// the extent permitted by applicable law. You can redistribute it
@@ -19,8 +19,7 @@
// loop.
//

#include <cstdint>
#include <memory>
#include <memory> // std::shared_ptr

namespace lol
{


+ 5
- 5
src/lol/gpu/shader.h Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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
// 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"



+ 4
- 3
src/lol/sys/file.h Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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
// 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
{


+ 3
- 22
src/lol/sys/init.h Zobrazit soubor

@@ -1,7 +1,7 @@
//
// 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
// 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
{
@@ -57,24 +56,6 @@ extern void init(int argc, char *argv[],
extern void add_data_dir(std::string const &dir);
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 lol */


+ 16
- 14
src/math/geometry.cpp Zobrazit soubor

@@ -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 <cstdlib> /* free() */
#include <cstring> /* strdup() */

#include <ostream> /* std::ostream */
#include <algorithm> // std::min
#include <cmath> // std::fabs

namespace lol
{
//Test epsilon stuff
TestEpsilon g_test_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; }
float TestEpsilon::Minus()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
vec3 plane_norm[2] = { cross(normalize(triD[0]), normalize(triD[1])),
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;

#if 0
@@ -256,13 +256,15 @@ namespace lol
//--
bool TestPointVsFrustum(const vec3& point, const mat4& frustum, vec3* result_point)
{
using std::fabs;

vec4 proj_point = frustum * vec4(point, 1.f);
proj_point /= proj_point.w;

if (result_point)
*result_point = proj_point.xyz;
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 true;
}


+ 1
- 1
src/scene.cpp Zobrazit soubor

@@ -414,7 +414,7 @@ void Scene::AddLine(vec3 a, vec3 b, vec4 col)
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 };
m_line_api.m_lines.push(l);


+ 1
- 1
src/scene.h Zobrazit soubor

@@ -245,7 +245,7 @@ public:

public:
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);
array<Light *> const &GetLights();


+ 1
- 0
src/utils.h Zobrazit soubor

@@ -19,6 +19,7 @@
//

#include <lol/base/utils.h>
#include <lol/math/rand.h>

#include <string>



Načítá se…
Zrušit
Uložit