From 35955b2ac1a22188812995527bc76bb59a07ede8 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 6 Mar 2020 13:17:43 +0100 Subject: [PATCH] Remove several deprecated headers. --- doc/samples/btphystest.cpp | 1 + doc/tutorial/02_cube.cpp | 3 +- doc/tutorial/11_fractal.cpp | 1 + lol-core | 2 +- src/Makefile.am | 5 +- src/debug/lines.cpp | 1 + src/gpu/renderer.cpp | 4 +- src/image/filter/yuv.cpp | 1 + src/lol-core.vcxproj | 2 - src/lol-core.vcxproj.filters | 9 - src/lol/algorithm/all.h | 17 -- src/lol/algorithm/portal.h | 392 ----------------------------------- src/lol/engine-internal.h | 5 +- src/lol/engine.h | 1 - src/lol/legacy.h | 26 --- src/lol/public.h | 1 - src/textureimage-private.h | 2 +- src/tileset.cpp | 4 +- src/ui/gui.cpp | 6 +- src/video.cpp | 4 +- 20 files changed, 20 insertions(+), 467 deletions(-) delete mode 100644 src/lol/algorithm/all.h delete mode 100644 src/lol/algorithm/portal.h delete mode 100644 src/lol/legacy.h diff --git a/doc/samples/btphystest.cpp b/doc/samples/btphystest.cpp index f9a8f01e..22ded86c 100644 --- a/doc/samples/btphystest.cpp +++ b/doc/samples/btphystest.cpp @@ -16,6 +16,7 @@ #endif #include +#include #include "loldebug.h" using namespace lol; diff --git a/doc/tutorial/02_cube.cpp b/doc/tutorial/02_cube.cpp index 9c74b87a..4bae4a30 100644 --- a/doc/tutorial/02_cube.cpp +++ b/doc/tutorial/02_cube.cpp @@ -1,7 +1,7 @@ // // Lol Engine — Cube tutorial // -// Copyright © 2011—2019 Sam Hocevar +// Copyright © 2011—2020 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -15,6 +15,7 @@ #endif #include +#include #include "loldebug.h" using namespace lol; diff --git a/doc/tutorial/11_fractal.cpp b/doc/tutorial/11_fractal.cpp index efd23439..887a7a3f 100644 --- a/doc/tutorial/11_fractal.cpp +++ b/doc/tutorial/11_fractal.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "loldebug.h" diff --git a/lol-core b/lol-core index ec5f308b..e7984246 160000 --- a/lol-core +++ b/lol-core @@ -1 +1 @@ -Subproject commit ec5f308bd3b69183359e6a16a151acca4fa69f46 +Subproject commit e7984246c375a93755c74fe78e4c254a8931533d diff --git a/src/Makefile.am b/src/Makefile.am index 818751f9..e12a9ba6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,16 +27,13 @@ liblol_core_a_SOURCES = \ liblol_core_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/3rdparty/lua/src liblol_core_headers = \ - lol/engine-internal.h lol/engine.h lol/public.h lol/extras.h lol/legacy.h \ + lol/engine-internal.h lol/engine.h lol/public.h lol/extras.h \ lol/lua.h \ \ lol/base/all.h \ lol/base/array.h lol/base/map.h lol/base/enum.h \ lol/base/log.h \ \ - lol/algorithm/all.h \ - lol/algorithm/portal.h \ - \ lol/audio/all.h \ lol/audio/audio.h lol/audio/sample.h \ \ diff --git a/src/debug/lines.cpp b/src/debug/lines.cpp index b874776a..d54c7ac6 100644 --- a/src/debug/lines.cpp +++ b/src/debug/lines.cpp @@ -11,6 +11,7 @@ // #include +#include namespace lol { diff --git a/src/gpu/renderer.cpp b/src/gpu/renderer.cpp index bd5b9998..5c5f3175 100644 --- a/src/gpu/renderer.cpp +++ b/src/gpu/renderer.cpp @@ -18,8 +18,8 @@ # define WIN32_LEAN_AND_MEAN 1 # include # undef WIN32_LEAN_AND_MEAN -# undef near /* Fuck Microsoft */ -# undef far /* Fuck Microsoft again */ +# undef near +# undef far #endif // FIXME: fine-tune this define diff --git a/src/image/filter/yuv.cpp b/src/image/filter/yuv.cpp index 7ebfbd85..b86ede12 100644 --- a/src/image/filter/yuv.cpp +++ b/src/image/filter/yuv.cpp @@ -11,6 +11,7 @@ // #include +#include /* * YUV conversion functions diff --git a/src/lol-core.vcxproj b/src/lol-core.vcxproj index 0cf0d650..161b1d54 100644 --- a/src/lol-core.vcxproj +++ b/src/lol-core.vcxproj @@ -235,8 +235,6 @@ - - diff --git a/src/lol-core.vcxproj.filters b/src/lol-core.vcxproj.filters index 7f50f696..b07552aa 100644 --- a/src/lol-core.vcxproj.filters +++ b/src/lol-core.vcxproj.filters @@ -305,12 +305,6 @@ lolua - - lol\algorithm - - - lol\algorithm - lol\base @@ -536,9 +530,6 @@ {0edcf1a5-3c9c-4425-918c-aa2cbebc51c1} - - {39f6f872-186f-48af-8e87-bcceb06b1b21} - {a20b47c1-a0f8-4a02-a7a8-6da2ccd8bb02} diff --git a/src/lol/algorithm/all.h b/src/lol/algorithm/all.h deleted file mode 100644 index bb57e36e..00000000 --- a/src/lol/algorithm/all.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// Lol Engine -// -// Copyright © 2010—2020 Sam Hocevar -// -// 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 <../legacy/lol/algorithm/aabb_tree.h> -#include - diff --git a/src/lol/algorithm/portal.h b/src/lol/algorithm/portal.h deleted file mode 100644 index 53895dd2..00000000 --- a/src/lol/algorithm/portal.h +++ /dev/null @@ -1,392 +0,0 @@ -// -// Lol Engine -// -// Copyright © 2010—2020 Sam Hocevar -// © 2013—2015 Benjamin “Touky” Huet -// -// 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 -#include // vec_t -#include // mat_t -#include -#include - -#include /* for FLT_MAX */ - -namespace lol -{ - -//------ PORTAL SYSTEM -------- -template class PortalRoom; -template class PortalDoor; -template class PortalSet; - -//-- -namespace Debug { -template -void Draw(PortalDoor& port, vec4 color) -{ - vec3 points[4]; port.GetPoints(points); - - // Draw normal - vec3 p = port.m_center + port.m_up * port.m_size.y * .5f; - Debug::DrawLine(p, p + port.m_normal, color::red); - Debug::DrawLine(p, p + port.m_up, color::green); - // Draw door - for (int l = 0; l < 4; l++) - Debug::DrawLine(points[l], points[(l + 1) % 4], color); - Debug::DrawLine(points[0], points[2], color); - Debug::DrawLine(points[1], points[3], color); -} -} - -//PortalDoor base class -template -class PortalDoor -{ - friend class PortalSet; - friend class PortalRoom; - friend void Debug::Draw(PortalDoor& port, vec4 color); - -private: - void Init() - { - m_center = vec3::zero; - m_normal = vec3::zero; - m_up = vec3::zero; - m_size = vec2::zero; - - m_view = mat4::identity; - m_proj = mat4::identity; - - m_rooms[0] = nullptr; - m_rooms[1] = nullptr; - } - -public: - //Normal portal - PortalDoor(vec3 center, vec3 normal, vec3 up, vec2 size) - { - Init(); - - m_center = center; - m_normal = normal; - m_up = up; - m_size = size; - } - //Camera portal - PortalDoor(mat4 view, mat4 proj) - { - Init(); - - m_view = view; - m_proj = proj; - } - //D.Tor - ~PortalDoor() - { - ConnectRooms(nullptr, nullptr); - } - - //Connect door to room - void ConnectRooms(class PortalRoom* front_room, class PortalRoom* back_room) - { - for (int i = 0; i < 2; i++) - if (m_rooms[i] != nullptr) - *m_rooms[i] >> this; - - m_rooms[0] = back_room; - m_rooms[1] = front_room; - - for (int i = 0; i < 2; i++) - if (m_rooms[i] != nullptr) - *m_rooms[i] << this; - } - - //-- - void DisconnectRoom(class PortalRoom* room) - { - for (int i = 0; i < 2; i++) - if (m_rooms[i] != nullptr && m_rooms[i] == room) - m_rooms[i] = nullptr; - } - - //-- - PortalRoom* GetRoom(bool front) { return m_rooms[(int)front]; } - PortalRoom* GetRoom(PortalRoom* room) { return (m_rooms[0] == room) ? m_rooms[1] : m_rooms[0]; } - - //Get Four portal point - void GetPoints(vec3 *points) const - { - vec3 right = cross(m_normal, m_up); - points[0] = m_center + right * m_size.x * .5f + m_up * m_size.y; - points[1] = m_center + right * m_size.x * .5f; - points[2] = m_center + right * m_size.x * -.5f; - points[3] = m_center + right * m_size.x * -.5f + m_up * m_size.y; - } - //Builds the portal view proj. - //Returns false if portal is out of the view or points are on each others. - bool BuildViewProj(mat4 view, mat4 proj) - { - mat4 cam_mx = proj * view; - mat4 inv_proj_mx = inverse(proj); - - // First: Check normal dot - if (lol::fabs(dot(mat3(inverse(view)) * vec3(0.f, 0.f, 1.f), m_normal)) < .00001f) - return false; - - // Second: convert to screen coordinates - vec3 port_2d[2] = { vec3(FLT_MAX), vec3(-FLT_MAX) }; - vec3 door_points[4]; - vec4 proj_p[4]; - - GetPoints(door_points); - - for (int i = 0; i < 4; i++) - { - //W to S calculations - proj_p[i] = cam_mx * vec4(door_points[i], 1.f); - proj_p[i] /= proj_p[i].w; - - //Clamp points within screen - port_2d[0] = lol::min(proj_p[i].xyz, port_2d[0]); - port_2d[1] = lol::max(proj_p[i].xyz, port_2d[1]); - port_2d[0] = vec3(lol::clamp(port_2d[0].xy, vec2(-1.f), vec2(1.f)), port_2d[0].z); - port_2d[1] = vec3(lol::clamp(port_2d[1].xy, vec2(-1.f), vec2(1.f)), port_2d[1].z); - } - - //Quit if door not within the screen - for (int i = 0; i < 3; i++) - if (port_2d[0][i] == port_2d[1][i]) - return false; - - //Third: Convert back to view - ivec2 j[4] = { ivec2(0), ivec2(0, 1), ivec2(1), ivec2(1, 0) }; - vec3 frust[2] = { vec3(FLT_MAX), vec3(-FLT_MAX) }; - for (int i = 0; i < 5; i++) - { - int k = i % 4; - //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::fabs(proj_p[k].z); - - for (int h = 0; h < 3; h++) - { - if (i < 4 || h > 1) - { - frust[0][h] = lol::min(frust[0][h], proj_p[k][h]); - frust[1][h] = lol::max(frust[1][h], proj_p[k][h]); - } - } - } - - //Fourth: Create frustum - m_proj = mat4::frustum(frust[0].x, frust[1].x, frust[0].y, frust[1].y, frust[0].z, frust[1].z); - m_view = view; - - return true; - } - - //View proj getter (doesn't check matrix validity) - mat4 GetViewProj() { return m_proj * m_view; } - - //-- - bool TestCollide(const vec3& point) - { - return TestPointVsFrustum(point, GetViewProj()); - } - - //-- - bool TestCollide(const PortalDoor& door) - { - vec3 door_points[4]; - vec3 res_points[4]; - ivec3 pos_test = ivec3::zero; - bool is_in = false; - - //Get points and test them on frustum - door.GetPoints(door_points); - for (int i = 0; i < 4; i++) - { - is_in = is_in || TestPointVsFrustum(door_points[i], GetViewProj(), &res_points[i]); - - if (is_in) - return true; - - //Add points on test stuff - pos_test += ivec3(lol::clamp(res_points[i], vec3(-1.1f), vec3(1.1f))); - } - - return false; - - //Check if at least one point is not on the same side as the others - for (int i = 0; i < 3; i++) - if (lol::fabs(pos_test[i]) == 4) - return false; - - return true; - } - -private: - mat4 m_view; - mat4 m_proj; - vec3 m_center; - vec3 m_normal; - vec3 m_up; - vec2 m_size; - PortalRoom* m_rooms[2]; //0: Back, 1: Front -}; - -//-- -template -class PortalRoom -{ - friend class PortalSet; - friend class PortalDoor; - -public: - PortalRoom(TE* element = nullptr) - { - m_element = element; - } - ~PortalRoom() - { - for (auto door : m_doors) - door->DisconnectRoom(this); - m_doors.clear(); - } - - PortalRoom& operator<<(class PortalDoor* door) - { - m_doors.push_unique(door); - return *this; - } - PortalRoom& operator>>(class PortalDoor* door) - { - m_doors.remove_swap_item(door); - return *this; - } - - int GetDoorCount() { return m_doors.count(); } - PortalDoor* GetDoor(int i) { return m_doors[i]; } - -private: - //Portals associated with this room. - array*> m_doors; - TE* m_element; -}; - -//-- -template -class PortalSet -{ -public: - ~PortalSet() - { - for (auto door : m_doors) - delete door; - for (auto room : m_rooms) - delete room; - m_doors.clear(); - m_rooms.clear(); - } - - //Visible room getter - void GetVisibleRooms(PortalDoor* see_through, PortalRoom* start_room, array*>& visible_rooms) - { - array*> ignore_doors; - GetVisibleRooms(see_through, start_room, visible_rooms, ignore_doors); - #if LOL_BUILD_DEBUG - for (auto room : visible_rooms) - { - vec4 tmp = vec4::zero; - for (auto port : room->m_doors) - { - Debug::Draw(*port, color::cyan); - tmp += vec4(port->m_center, 1.f); - } - tmp /= tmp.w; - Debug::DrawBox(tmp.xyz - vec3(1.f), tmp.xyz + vec3(1.f), color::yellow); - } - for (auto port : ignore_doors) - { - Debug::Draw(*port, color::magenta); - Debug::DrawViewProj(port->m_view, port->m_proj, color::magenta); - } - #endif //LOL_BUILD_DEBUG - } -private: - void GetVisibleRooms(PortalDoor* see_through, PortalRoom* start_room, array*>& visible_rooms, array*>& ignore_doors) - { - for (auto door : start_room->m_doors) - { - if (door == see_through || ignore_doors.Find(door) != INDEX_NONE) - continue; - - if (see_through->TestCollide(*door)) - { - PortalRoom* other_room = door->GetRoom(start_room); - if (visible_rooms.Find(other_room) != INDEX_NONE) - continue; - - ignore_doors.push_unique(door); - visible_rooms.push_unique(other_room); - door->BuildViewProj(see_through->m_view, see_through->m_proj); - GetVisibleRooms(door, other_room, visible_rooms, ignore_doors); - } - } - } -public: - - //Operator - PortalSet& operator<<(class PortalRoom* room) - { - m_rooms.push_unique(room); - for (auto door : room->m_doors) - m_doors.push_unique(door); - return *this; - } - //-- - PortalSet& operator>>(class PortalRoom* room) - { - for (auto door : room->m_doors) - *this >> door; - m_rooms.remove_item(room); - return *this; - } - //-- - PortalSet& operator<<(class PortalDoor* door) - { - m_doors.push_unique(door); - return *this; - } - //-- - PortalSet& operator>>(class PortalDoor* door) - { - m_doors.remove_item(door); - return *this; - } - - //-- - int GetDoorCount() { return m_doors.count(); } - PortalDoor* GetDoor(int i) { return m_doors[i]; } - int GetRoomCount() { return m_rooms.count(); } - PortalRoom* GetRoom(int i) { return m_rooms[i]; } - -private: - //Portals associated with this room. - array*> m_rooms; - array*> m_doors; -}; - -} /* namespace lol */ - diff --git a/src/lol/engine-internal.h b/src/lol/engine-internal.h index c67ba1bd..e0073dbf 100644 --- a/src/lol/engine-internal.h +++ b/src/lol/engine-internal.h @@ -34,10 +34,9 @@ #include #include -#include #if defined _WIN32 -# undef near /* Fuck Microsoft */ -# undef far /* Fuck Microsoft again */ +# undef near +# undef far #endif diff --git a/src/lol/engine.h b/src/lol/engine.h index 1ab6f42b..ba65a8d8 100644 --- a/src/lol/engine.h +++ b/src/lol/engine.h @@ -34,5 +34,4 @@ #include #include -#include diff --git a/src/lol/legacy.h b/src/lol/legacy.h deleted file mode 100644 index aae63039..00000000 --- a/src/lol/legacy.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// Lol Engine -// -// Copyright © 2010—2017 Sam Hocevar -// -// 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 - -// -// Legacy types that will disappear one day -// ---------------------------------------- -// - -namespace lol -{ - -typedef image Image; - -} /* namespace lol */ - diff --git a/src/lol/public.h b/src/lol/public.h index 13a2f7e2..b066be43 100644 --- a/src/lol/public.h +++ b/src/lol/public.h @@ -18,7 +18,6 @@ // #include -#include #include #include #include diff --git a/src/textureimage-private.h b/src/textureimage-private.h index da1ef7a9..7b8a2b55 100644 --- a/src/textureimage-private.h +++ b/src/textureimage-private.h @@ -34,7 +34,7 @@ public: /* Pixels, then texture coordinates */ ivec2 m_image_size, m_texture_size; - Image *m_image = nullptr; + image *m_image = nullptr; Texture *m_texture = nullptr; }; diff --git a/src/tileset.cpp b/src/tileset.cpp index 8ac5fe03..69767a51 100644 --- a/src/tileset.cpp +++ b/src/tileset.cpp @@ -171,9 +171,9 @@ void TileSet::Init(std::string const &path, ResourceCodecData* loaded_data) super::Init(path, loaded_data); } -void TileSet::Init(std::string const &path, Image* image) +void TileSet::Init(std::string const &path, image* img) { - super::Init(path, image); + super::Init(path, img); m_data->m_name = " " + path; } diff --git a/src/ui/gui.cpp b/src/ui/gui.cpp index 11beeecd..2fc04a07 100644 --- a/src/ui/gui.cpp +++ b/src/ui/gui.cpp @@ -142,10 +142,10 @@ void gui::refresh_fonts() ImGuiIO& io = ImGui::GetIO(); io.Fonts->GetTexDataAsRGBA32(&pixels, &size.x, &size.y); - Image* image = new Image(); - image->Copy(pixels, size, PixelFormat::RGBA_8); + image* img = new image(); + img->Copy(pixels, size, PixelFormat::RGBA_8); - Ticker::Ref(g_gui->m_font = new TextureImage("", image)); + Ticker::Ref(g_gui->m_font = new TextureImage("", img)); } bool gui::init_game() diff --git a/src/video.cpp b/src/video.cpp index c342cac3..f37ff5ed 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -16,8 +16,8 @@ # define WIN32_LEAN_AND_MEAN # include # undef WIN32_LEAN_AND_MEAN -# undef near /* Fuck Microsoft */ -# undef far /* Fuck Microsoft again */ +# undef near +# undef far #endif #include "lolgl.h"