|
|
diff --git a/.gitignore b/.gitignore
|
|
|
index e915029..dd400cf 100644
|
|
|
--- a/.gitignore
|
|
|
+++ b/.gitignore
|
|
|
@@ -3,3 +3,5 @@
|
|
|
################################################################################
|
|
|
|
|
|
/.vs
|
|
|
+/utilities/olcUTIL_AffineView.h
|
|
|
+/utilities/olcUTIL_Maths.h
|
|
|
diff --git a/olcPixelGameEngine.h b/olcPixelGameEngine.h
|
|
|
index 5480a15..92dee60 100644
|
|
|
--- a/olcPixelGameEngine.h
|
|
|
+++ b/olcPixelGameEngine.h
|
|
|
@@ -3,7 +3,7 @@
|
|
|
olcPixelGameEngine.h
|
|
|
|
|
|
+-------------------------------------------------------------+
|
|
|
- | OneLoneCoder Pixel Game Engine v2.21 |
|
|
|
+ | OneLoneCoder Pixel Game Engine v2.23 |
|
|
|
| "What do you need? Pixels... Lots of Pixels..." - javidx9 |
|
|
|
+-------------------------------------------------------------+
|
|
|
|
|
|
@@ -197,7 +197,7 @@
|
|
|
|
|
|
Author
|
|
|
~~~~~~
|
|
|
- David Barr, aka javidx9, <EFBFBD>OneLoneCoder 2018, 2019, 2020, 2021, 2022
|
|
|
+ David Barr, aka javidx9, (c) OneLoneCoder 2018, 2019, 2020, 2021, 2022
|
|
|
*/
|
|
|
#pragma endregion
|
|
|
|
|
|
@@ -315,6 +315,9 @@
|
|
|
+FillTexturedTriangle() - Software rasterizes a textured, coloured, triangle
|
|
|
+FillTexturedPolygon() - Hijacks DecalStructure for configuration
|
|
|
+olc::vf2d arguments for Sprite::Sample() functions
|
|
|
+ 2.22: = Fix typo on dragged file buffers for unicode builds
|
|
|
+ 2.23: Fixed Emscripten host sizing errors - Thanks Moros
|
|
|
+ Fixed v2d_generic.clamp() function
|
|
|
|
|
|
!! Apple Platforms will not see these updates immediately - Sorry, I dont have a mac to test... !!
|
|
|
!! Volunteers willing to help appreciated, though PRs are manually integrated with credit !!
|
|
|
@@ -394,7 +397,7 @@ int main()
|
|
|
#include <cstring>
|
|
|
#pragma endregion
|
|
|
|
|
|
-#define PGE_VER 221
|
|
|
+#define PGE_VER 223
|
|
|
|
|
|
// O------------------------------------------------------------------------------O
|
|
|
// | COMPILER CONFIGURATION ODDITIES |
|
|
|
@@ -682,7 +685,7 @@ namespace olc
|
|
|
v2d_generic min(const v2d_generic& v) const { return v2d_generic(std::min(x, v.x), std::min(y, v.y)); }
|
|
|
v2d_generic cart() { return { std::cos(y) * x, std::sin(y) * x }; }
|
|
|
v2d_generic polar() { return { mag(), std::atan2(y, x) }; }
|
|
|
- v2d_generic clamp(const v2d_generic& v1, const v2d_generic& v2) const { return this->max(v1)->min(v2); }
|
|
|
+ v2d_generic clamp(const v2d_generic& v1, const v2d_generic& v2) const { return this->max(v1).min(v2); }
|
|
|
v2d_generic lerp(const v2d_generic& v1, const double t) { return this->operator*(T(1.0 - t)) + (v1 * T(t)); }
|
|
|
T dot(const v2d_generic& rhs) const { return this->x * rhs.x + this->y * rhs.y; }
|
|
|
T cross(const v2d_generic& rhs) const { return this->x * rhs.y - this->y * rhs.x; }
|
|
|
@@ -1357,8 +1360,9 @@ namespace olc
|
|
|
#endif
|
|
|
|
|
|
#if defined(OLC_PLATFORM_X11)
|
|
|
- namespace X11
|
|
|
- {#include <GL/glx.h>}
|
|
|
+ namespace X11 {
|
|
|
+ #include <GL/glx.h>
|
|
|
+ }
|
|
|
#define CALLSTYLE
|
|
|
#endif
|
|
|
|
|
|
@@ -4594,17 +4598,17 @@ namespace olc
|
|
|
// #include <OpenGL/glu.h>
|
|
|
//#endif
|
|
|
|
|
|
-//#if defined(OLC_PLATFORM_EMSCRIPTEN)
|
|
|
-// #include <EGL/egl.h>
|
|
|
-// #include <GLES2/gl2.h>
|
|
|
-// #define GL_GLEXT_PROTOTYPES
|
|
|
-// #include <GLES2/gl2ext.h>
|
|
|
-// #include <emscripten/emscripten.h>
|
|
|
-// #define CALLSTYLE
|
|
|
-// typedef EGLBoolean(locSwapInterval_t)(EGLDisplay display, EGLint interval);
|
|
|
-// #define GL_CLAMP GL_CLAMP_TO_EDGE
|
|
|
-// #define OGL_LOAD(t, n) n;
|
|
|
-//#endif
|
|
|
+#if defined(OLC_PLATFORM_EMSCRIPTEN)
|
|
|
+ #include <EGL/egl.h>
|
|
|
+ #include <GLES2/gl2.h>
|
|
|
+ #define GL_GLEXT_PROTOTYPES
|
|
|
+ #include <GLES2/gl2ext.h>
|
|
|
+ #include <emscripten/emscripten.h>
|
|
|
+ #define CALLSTYLE
|
|
|
+ typedef EGLBoolean(locSwapInterval_t)(EGLDisplay display, EGLint interval);
|
|
|
+ #define GL_CLAMP GL_CLAMP_TO_EDGE
|
|
|
+ #define OGL_LOAD(t, n) n;
|
|
|
+#endif
|
|
|
|
|
|
namespace olc
|
|
|
{
|
|
|
@@ -5574,7 +5578,7 @@ namespace olc
|
|
|
vFiles.push_back(std::string(buffer));
|
|
|
delete[] buffer;
|
|
|
#else
|
|
|
- vFiles.push_back(std::string(dbuffer));
|
|
|
+ vFiles.push_back(std::string(dfbuffer));
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
@@ -6318,8 +6322,8 @@ namespace olc
|
|
|
let isFullscreen = (document.fullscreenElement != null);
|
|
|
|
|
|
// get the width of the containing element
|
|
|
- let width = (isFullscreen || !Module.olc_AssumeDefaultShells) ? window.innerWidth : Module.canvas.parentNode.clientWidth;
|
|
|
- let height = (isFullscreen || !Module.olc_AssumeDefaultShells) ? window.innerHeight : Module.canvas.parentNode.clientHeight;
|
|
|
+ let width = (isFullscreen) ? window.innerWidth : Module.canvas.parentNode.clientWidth;
|
|
|
+ let height = (isFullscreen) ? window.innerHeight : Module.canvas.parentNode.clientHeight;
|
|
|
|
|
|
// calculate the expected viewport size
|
|
|
let viewWidth = width;
|
|
|
diff --git a/utilities/olcUTIL_Geometry2D.h b/utilities/olcUTIL_Geometry2D.h
|
|
|
index 801c1d3..3b8f363 100644
|
|
|
--- a/utilities/olcUTIL_Geometry2D.h
|
|
|
+++ b/utilities/olcUTIL_Geometry2D.h
|
|
|
@@ -277,43 +277,60 @@ namespace olc::utils::geom2d
|
|
|
|
|
|
// Returns closest point to point
|
|
|
template<typename T1, typename T2>
|
|
|
- inline olc::v2d_generic<T2> closest(const olc::v2d_generic<T1>& p1, const olc::v2d_generic<T2>& p2)
|
|
|
+ inline olc::v2d_generic<T1> closest(const olc::v2d_generic<T1>& p1, const olc::v2d_generic<T2>& p2)
|
|
|
{
|
|
|
return p1;
|
|
|
}
|
|
|
|
|
|
// Returns closest point on line to point
|
|
|
template<typename T1, typename T2>
|
|
|
- inline olc::v2d_generic<T2> closest(const line<T1>& l, const olc::v2d_generic<T2>& p)
|
|
|
+ inline olc::v2d_generic<T1> closest(const line<T1>& l, const olc::v2d_generic<T2>& p)
|
|
|
{
|
|
|
auto d = l.vector();
|
|
|
- double u = std::clamp(double(d.dot(p - l.start) / d.mag2()), 0.0, 1.0);
|
|
|
- return l.start + d * u;
|
|
|
+ double u = std::clamp(double(d.dot(p - l.start)) / d.mag2(), 0.0, 1.0);
|
|
|
+ return l.start + u * d;
|
|
|
}
|
|
|
|
|
|
// Returns closest point on circle to point
|
|
|
template<typename T1, typename T2>
|
|
|
- inline olc::v2d_generic<T2> closest(const circle<T1>& c, const olc::v2d_generic<T2>& p)
|
|
|
+ inline olc::v2d_generic<T1> closest(const circle<T1>& c, const olc::v2d_generic<T2>& p)
|
|
|
{
|
|
|
- return c.pos + (p - c.pos).norm() * c.radius;
|
|
|
+ return c.pos + olc::vd2d(p - c.pos).norm() * c.radius;
|
|
|
}
|
|
|
|
|
|
// Returns closest point on rectangle to point
|
|
|
template<typename T1, typename T2>
|
|
|
- inline olc::v2d_generic<T2> closest(const rect<T1>& r, const olc::v2d_generic<T2>& p)
|
|
|
+ inline olc::v2d_generic<T1> closest(const rect<T1>& r, const olc::v2d_generic<T2>& p)
|
|
|
{
|
|
|
// This could be a "constrain" function hmmmm
|
|
|
// TODO: Not quite what i wanted, should restrain to boundary
|
|
|
- return olc::v2d_generic<T2>{ std::clamp(p.x, r.pos.x, r.pos.x + r.size.x), std::clamp(p.y, r.pos.y, r.pos.y + r.size.y) };
|
|
|
+ return olc::v2d_generic<T1>{ std::clamp(p.x, r.pos.x, r.pos.x + r.size.x), std::clamp(p.y, r.pos.y, r.pos.y + r.size.y) };
|
|
|
|
|
|
}
|
|
|
|
|
|
// Returns closest point on triangle to point
|
|
|
template<typename T1, typename T2>
|
|
|
- inline olc::v2d_generic<T2> closest(const triangle<T1>& t, const olc::v2d_generic<T2>& p)
|
|
|
+ inline olc::v2d_generic<T1> closest(const triangle<T1>& t, const olc::v2d_generic<T2>& p)
|
|
|
{
|
|
|
- // TODO:
|
|
|
- return olc::v2d_generic<T2>();
|
|
|
+ olc::utils::geom2d::line<T1> l{t.pos[0], t.pos[1]};
|
|
|
+ auto p0 = closest(l, p);
|
|
|
+ auto d0 = (p0 - p).mag2();
|
|
|
+
|
|
|
+ l.end = t.pos[2];
|
|
|
+ auto p1 = closest(l, p);
|
|
|
+ auto d1 = (p1 - p).mag2();
|
|
|
+
|
|
|
+ l.start = t.pos[1];
|
|
|
+ auto p2 = closest(l, p);
|
|
|
+ auto d2 = (p2 - p).mag2();
|
|
|
+
|
|
|
+ if((d0 <= d1) && (d0 <= d2)) {
|
|
|
+ return p0;
|
|
|
+ } else if((d1 <= d0) && (d1 <= d2)) {
|
|
|
+ return p1;
|
|
|
+ } else {
|
|
|
+ return p2;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
|