| @@ -187,7 +187,7 @@ public: | |||||
| while (i-- > 0) | while (i-- > 0) | ||||
| voronoi_points.Push(vec3(rand<float>(512.f), rand<float>(512.f), .0f), | voronoi_points.Push(vec3(rand<float>(512.f), rand<float>(512.f), .0f), | ||||
| vec2(64.f + rand<float>(64.f), 64.f + rand<float>(64.f)) | vec2(64.f + rand<float>(64.f), 64.f + rand<float>(64.f)) | ||||
| //vec2(0.f) | |||||
| //vec2::zero | |||||
| ); | ); | ||||
| mode = 1; | mode = 1; | ||||
| } | } | ||||
| @@ -316,7 +316,7 @@ public: | |||||
| Framebuffer *src_buf; | Framebuffer *src_buf; | ||||
| Shader *shader; | Shader *shader; | ||||
| if (curres == ivec2(0)) | |||||
| if (curres == ivec2::zero) | |||||
| shader = m_screen_shader; | shader = m_screen_shader; | ||||
| else | else | ||||
| shader = m_fbos[m_cur_fbo].m2; | shader = m_fbos[m_cur_fbo].m2; | ||||
| @@ -352,7 +352,7 @@ public: | |||||
| #endif | #endif | ||||
| int i = 0; | int i = 0; | ||||
| if (curres == ivec2(0)) | |||||
| if (curres == ivec2::zero) | |||||
| m_screen_shader->SetUniform(m_screen_texture, src_buf->GetTexture(), 0); | m_screen_shader->SetUniform(m_screen_texture, src_buf->GetTexture(), 0); | ||||
| else if (m_cur_fbo == VoronoiFbo) | else if (m_cur_fbo == VoronoiFbo) | ||||
| { | { | ||||
| @@ -368,12 +368,12 @@ public: | |||||
| m_fbos[m_cur_fbo].m2->Unbind(); | m_fbos[m_cur_fbo].m2->Unbind(); | ||||
| dst_buf->Unbind(); | dst_buf->Unbind(); | ||||
| if (curres == ivec2(0)) | |||||
| if (curres == ivec2::zero) | |||||
| break; | break; | ||||
| if (curres == ivec2(1)) | if (curres == ivec2(1)) | ||||
| { | { | ||||
| if (buf == 1) | if (buf == 1) | ||||
| curres = ivec2(0); | |||||
| curres = ivec2::zero; | |||||
| else | else | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -76,7 +76,7 @@ liblolcore_sources = \ | |||||
| base/assert.cpp base/hash.cpp base/log.cpp base/string.cpp \ | base/assert.cpp base/hash.cpp base/log.cpp base/string.cpp \ | ||||
| \ | \ | ||||
| math/vector.cpp math/real.cpp math/half.cpp math/trig.cpp \ | math/vector.cpp math/real.cpp math/half.cpp math/trig.cpp \ | ||||
| math/geometry.cpp \ | |||||
| math/constants.cpp math/geometry.cpp \ | |||||
| \ | \ | ||||
| gpu/shader.cpp gpu/indexbuffer.cpp gpu/vertexbuffer.cpp \ | gpu/shader.cpp gpu/indexbuffer.cpp gpu/vertexbuffer.cpp \ | ||||
| gpu/framebuffer.cpp gpu/texture.cpp gpu/renderer.cpp \ | gpu/framebuffer.cpp gpu/texture.cpp gpu/renderer.cpp \ | ||||
| @@ -46,7 +46,7 @@ Camera::Camera() | |||||
| /* Create a default perspective */ | /* Create a default perspective */ | ||||
| SetProjection(m_fov, m_near, m_far, m_screen_size, m_screen_ratio); | SetProjection(m_fov, m_near, m_far, m_screen_size, m_screen_ratio); | ||||
| SetView(mat4::lookat(vec3(0.f, 50.f, 50.f), vec3(0.f), vec3(0.f, 1.f, 0.f))); | |||||
| SetView(mat4::lookat(vec3(0.f, 50.f, 50.f), vec3::zero, vec3::axis_y)); | |||||
| } | } | ||||
| Camera::~Camera() | Camera::~Camera() | ||||
| @@ -55,16 +55,8 @@ | |||||
| #if LOL_FEATURE_CXX11_CONSTEXPR | #if LOL_FEATURE_CXX11_CONSTEXPR | ||||
| # define LOL_CONSTEXPR constexpr | # define LOL_CONSTEXPR constexpr | ||||
| # define LOL_CONSTEXPR_DECLARATION(type, name, value) \ | |||||
| static type constexpr name = value; | |||||
| # define LOL_CONSTEXPR_DEFINITION(type, name, value) \ | |||||
| /* Nothing */ | |||||
| #else | #else | ||||
| # define LOL_CONSTEXPR /* Nothing */ | # define LOL_CONSTEXPR /* Nothing */ | ||||
| # define LOL_CONSTEXPR_DECLARATION(type, name, value) \ | |||||
| static type const name; | |||||
| # define LOL_CONSTEXPR_DEFINITION(type, name, value) \ | |||||
| type const name = value; | |||||
| #endif | #endif | ||||
| @@ -53,7 +53,7 @@ DebugRecord::DebugRecord(char const *path, float fps) | |||||
| Ticker::StartRecording(); | Ticker::StartRecording(); | ||||
| data->path = strdup(path); | data->path = strdup(path); | ||||
| data->size = ivec2(0); | |||||
| data->size = ivec2::zero; | |||||
| data->fps = (int)(fps + 0.5f); | data->fps = (int)(fps + 0.5f); | ||||
| #if defined USE_PIPI | #if defined USE_PIPI | ||||
| data->sequence = nullptr; | data->sequence = nullptr; | ||||
| @@ -146,7 +146,7 @@ void DefaultShaderData::SetupShaderDatas(mat4 const &model) | |||||
| for (int i = 0; i < lights.Count(); ++i) | for (int i = 0; i < lights.Count(); ++i) | ||||
| light_data << lights[i]->GetPosition() << lights[i]->GetColor(); | light_data << lights[i]->GetPosition() << lights[i]->GetColor(); | ||||
| while (light_data.Count() < 8) | while (light_data.Count() < 8) | ||||
| light_data << vec4(0.f) << vec4(0.f); | |||||
| light_data << vec4::zero << vec4::zero; | |||||
| m_shader->SetUniform(*GetUniform("u_Lights"), light_data); | m_shader->SetUniform(*GetUniform("u_Lights"), light_data); | ||||
| m_shader->SetUniform(*GetUniform("in_ModelView"), modelview); | m_shader->SetUniform(*GetUniform("in_ModelView"), modelview); | ||||
| @@ -45,7 +45,7 @@ Font::Font(char const *path) | |||||
| { | { | ||||
| data->m_name = String("<font> ") + path; | data->m_name = String("<font> ") + path; | ||||
| data->tileset = Tiler::Register(path, ivec2(0), ivec2(16)); | |||||
| data->tileset = Tiler::Register(path, ivec2::zero, ivec2(16)); | |||||
| data->size = data->tileset->GetTileSize(0); | data->size = data->tileset->GetTileSize(0); | ||||
| m_drawgroup = DRAWGROUP_BEFORE; | m_drawgroup = DRAWGROUP_BEFORE; | ||||
| @@ -471,7 +471,7 @@ void Framebuffer::Bind() | |||||
| * instead, maybe by getting rid of Framebuffer::Bind() and | * instead, maybe by getting rid of Framebuffer::Bind() and | ||||
| * creating RenderContext::SetFramebuffer() instead. */ | * creating RenderContext::SetFramebuffer() instead. */ | ||||
| m_data->m_saved_viewport = g_renderer->GetViewport(); | m_data->m_saved_viewport = g_renderer->GetViewport(); | ||||
| g_renderer->SetViewport(ibox2(ivec2(0), m_data->m_size)); | |||||
| g_renderer->SetViewport(ibox2(ivec2::zero, m_data->m_size)); | |||||
| m_data->m_bound = true; | m_data->m_bound = true; | ||||
| } | } | ||||
| @@ -138,7 +138,7 @@ Renderer::Renderer(ivec2 size) | |||||
| /* Initialise rendering states */ | /* Initialise rendering states */ | ||||
| m_data->m_viewport = ibox2(0, 0, 0, 0); | m_data->m_viewport = ibox2(0, 0, 0, 0); | ||||
| SetViewport(ibox2(vec2(0), size)); | |||||
| SetViewport(ibox2(vec2::zero, size)); | |||||
| m_data->m_clear_color = vec4(-1.f); | m_data->m_clear_color = vec4(-1.f); | ||||
| SetClearColor(vec4(0.1f, 0.2f, 0.3f, 1.0f)); | SetClearColor(vec4(0.1f, 0.2f, 0.3f, 1.0f)); | ||||
| @@ -582,7 +582,7 @@ vec3 Color::WavelengthToCIExyY(float nm) | |||||
| int i = (int)nm; | int i = (int)nm; | ||||
| if (i < 0 || i > 830 - 360) | if (i < 0 || i > 830 - 360) | ||||
| return vec3(0.0f); | |||||
| return vec3::zero; | |||||
| float t = nm - i, s = 1.0 - t; | float t = nm - i, s = 1.0 - t; | ||||
| float x = s * cie_1931_xyz[i * 3 + 0] + t * cie_1931_xyz[i * 3 + 3]; | float x = s * cie_1931_xyz[i * 3 + 0] + t * cie_1931_xyz[i * 3 + 3]; | ||||
| @@ -47,7 +47,7 @@ void InputDeviceInternal::AddAxis(const char* name, float sensitivity) | |||||
| void InputDeviceInternal::AddCursor(const char* name) | void InputDeviceInternal::AddCursor(const char* name) | ||||
| { | { | ||||
| m_cursornames.Push(name); | m_cursornames.Push(name); | ||||
| m_cursors.Push(vec2(0.0), ivec2(0)); | |||||
| m_cursors.Push(vec2::zero, ivec2::zero); | |||||
| } | } | ||||
| InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard() | InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard() | ||||
| @@ -27,7 +27,7 @@ Light::Light() | |||||
| m_gamegroup = GAMEGROUP_BEFORE; | m_gamegroup = GAMEGROUP_BEFORE; | ||||
| m_drawgroup = DRAWGROUP_CAMERA; | m_drawgroup = DRAWGROUP_CAMERA; | ||||
| SetPosition(vec4(0.f)); | |||||
| SetPosition(vec4::zero); | |||||
| } | } | ||||
| Light::~Light() | Light::~Light() | ||||
| @@ -168,8 +168,8 @@ template<typename T, int N> struct XVec4 | |||||
| template <typename T> struct BVec2 | template <typename T> struct BVec2 | ||||
| { | { | ||||
| explicit inline BVec2() {} | |||||
| explicit inline BVec2(T X, T Y) : x(X), y(Y) {} | |||||
| explicit inline LOL_CONSTEXPR BVec2() {} | |||||
| explicit inline LOL_CONSTEXPR BVec2(T X, T Y) : x(X), y(Y) {} | |||||
| union | union | ||||
| { | { | ||||
| @@ -236,21 +236,25 @@ template <> struct BVec2<real> | |||||
| template <typename T> struct Vec2 : BVec2<T> | template <typename T> struct Vec2 : BVec2<T> | ||||
| { | { | ||||
| inline Vec2() {} | |||||
| inline Vec2(T X, T Y) : BVec2<T>(X, Y) {} | |||||
| inline LOL_CONSTEXPR Vec2() {} | |||||
| inline LOL_CONSTEXPR Vec2(T X, T Y) : BVec2<T>(X, Y) {} | |||||
| explicit inline Vec2(T X) : BVec2<T>(X, X) {} | |||||
| explicit LOL_CONSTEXPR inline Vec2(T X) : BVec2<T>(X, X) {} | |||||
| template<int N> | template<int N> | ||||
| inline Vec2(XVec2<T, N> const &v) | |||||
| inline LOL_CONSTEXPR Vec2(XVec2<T, N> const &v) | |||||
| : BVec2<T>(v[0], v[1]) {} | : BVec2<T>(v[0], v[1]) {} | ||||
| template<typename U, int N> | template<typename U, int N> | ||||
| explicit inline Vec2(XVec2<U, N> const &v) | |||||
| explicit inline LOL_CONSTEXPR Vec2(XVec2<U, N> const &v) | |||||
| : BVec2<T>(v[0], v[1]) {} | : BVec2<T>(v[0], v[1]) {} | ||||
| LOL_MEMBER_OPS(Vec2, x) | LOL_MEMBER_OPS(Vec2, x) | ||||
| static const Vec2<T> zero; | |||||
| static const Vec2<T> axis_x; | |||||
| static const Vec2<T> axis_y; | |||||
| template<typename U> | template<typename U> | ||||
| friend std::ostream &operator<<(std::ostream &stream, Vec2<U> const &v); | friend std::ostream &operator<<(std::ostream &stream, Vec2<U> const &v); | ||||
| }; | }; | ||||
| @@ -261,9 +265,9 @@ template <typename T> struct Vec2 : BVec2<T> | |||||
| template <typename T> struct Cmplx | template <typename T> struct Cmplx | ||||
| { | { | ||||
| inline Cmplx() {} | |||||
| inline Cmplx(T X) : x(X), y(0) {} | |||||
| inline Cmplx(T X, T Y) : x(X), y(Y) {} | |||||
| inline LOL_CONSTEXPR Cmplx() {} | |||||
| inline LOL_CONSTEXPR Cmplx(T X) : x(X), y(0) {} | |||||
| inline LOL_CONSTEXPR Cmplx(T X, T Y) : x(X), y(Y) {} | |||||
| LOL_MEMBER_OPS(Cmplx, x) | LOL_MEMBER_OPS(Cmplx, x) | ||||
| @@ -331,8 +335,8 @@ static inline bool operator !=(T a, Cmplx<T> const &b) { return b != a; } | |||||
| template <typename T> struct BVec3 | template <typename T> struct BVec3 | ||||
| { | { | ||||
| explicit inline BVec3() {} | |||||
| explicit inline BVec3(T X, T Y, T Z) : x(X), y(Y), z(Z) {} | |||||
| explicit inline LOL_CONSTEXPR BVec3() {} | |||||
| explicit inline LOL_CONSTEXPR BVec3(T X, T Y, T Z) : x(X), y(Y), z(Z) {} | |||||
| union | union | ||||
| { | { | ||||
| @@ -473,7 +477,8 @@ template <typename T> struct BVec3 | |||||
| template <> struct BVec3<half> | template <> struct BVec3<half> | ||||
| { | { | ||||
| explicit inline BVec3() {} | explicit inline BVec3() {} | ||||
| explicit inline BVec3(half X, half Y, half Z) : x(X), y(Y), z(Z) {} | |||||
| explicit inline BVec3(half X, half Y, half Z) | |||||
| : x(X), y(Y), z(Z) {} | |||||
| half x, y, z; | half x, y, z; | ||||
| }; | }; | ||||
| @@ -488,19 +493,19 @@ template <> struct BVec3<real> | |||||
| template <typename T> struct Vec3 : BVec3<T> | template <typename T> struct Vec3 : BVec3<T> | ||||
| { | { | ||||
| inline Vec3() {} | |||||
| inline Vec3(T X, T Y, T Z) : BVec3<T>(X, Y, Z) {} | |||||
| inline Vec3(Vec2<T> XY, T Z) : BVec3<T>(XY.x, XY.y, Z) {} | |||||
| inline Vec3(T X, Vec2<T> YZ) : BVec3<T>(X, YZ.x, YZ.y) {} | |||||
| inline LOL_CONSTEXPR Vec3() {} | |||||
| inline LOL_CONSTEXPR Vec3(T X, T Y, T Z) : BVec3<T>(X, Y, Z) {} | |||||
| inline LOL_CONSTEXPR Vec3(Vec2<T> XY, T Z) : BVec3<T>(XY.x, XY.y, Z) {} | |||||
| inline LOL_CONSTEXPR Vec3(T X, Vec2<T> YZ) : BVec3<T>(X, YZ.x, YZ.y) {} | |||||
| explicit inline Vec3(T X) : BVec3<T>(X, X, X) {} | |||||
| explicit inline LOL_CONSTEXPR Vec3(T X) : BVec3<T>(X, X, X) {} | |||||
| template<int N> | template<int N> | ||||
| inline Vec3(XVec3<T, N> const &v) | |||||
| inline LOL_CONSTEXPR Vec3(XVec3<T, N> const &v) | |||||
| : BVec3<T>(v[0], v[1], v[2]) {} | : BVec3<T>(v[0], v[1], v[2]) {} | ||||
| template<typename U, int N> | template<typename U, int N> | ||||
| explicit inline Vec3(XVec3<U, N> const &v) | |||||
| explicit inline LOL_CONSTEXPR Vec3(XVec3<U, N> const &v) | |||||
| : BVec3<T>(v[0], v[1], v[2]) {} | : BVec3<T>(v[0], v[1], v[2]) {} | ||||
| static Vec3<T> toeuler_xyx(Quat<T> const &q); | static Vec3<T> toeuler_xyx(Quat<T> const &q); | ||||
| @@ -519,6 +524,11 @@ template <typename T> struct Vec3 : BVec3<T> | |||||
| LOL_MEMBER_OPS(Vec3, x) | LOL_MEMBER_OPS(Vec3, x) | ||||
| static const Vec3<T> zero; | |||||
| static const Vec3<T> axis_x; | |||||
| static const Vec3<T> axis_y; | |||||
| static const Vec3<T> axis_z; | |||||
| template<typename U> | template<typename U> | ||||
| friend std::ostream &operator<<(std::ostream &stream, Vec3<U> const &v); | friend std::ostream &operator<<(std::ostream &stream, Vec3<U> const &v); | ||||
| }; | }; | ||||
| @@ -529,8 +539,9 @@ template <typename T> struct Vec3 : BVec3<T> | |||||
| template <typename T> struct BVec4 | template <typename T> struct BVec4 | ||||
| { | { | ||||
| explicit inline BVec4() {} | |||||
| explicit inline BVec4(T X, T Y, T Z, T W) : x(X), y(Y), z(Z), w(W) {} | |||||
| explicit inline LOL_CONSTEXPR BVec4() {} | |||||
| explicit inline LOL_CONSTEXPR BVec4(T X, T Y, T Z, T W) | |||||
| : x(X), y(Y), z(Z), w(W) {} | |||||
| union | union | ||||
| { | { | ||||
| @@ -907,27 +918,40 @@ template <> struct BVec4<real> | |||||
| template <typename T> struct Vec4 : BVec4<T> | template <typename T> struct Vec4 : BVec4<T> | ||||
| { | { | ||||
| inline Vec4() {} | |||||
| inline Vec4(T X, T Y, T Z, T W) : BVec4<T>(X, Y, Z, W) {} | |||||
| inline Vec4(Vec2<T> XY, T Z, T W) : BVec4<T>(XY.x, XY.y, Z, W) {} | |||||
| inline Vec4(T X, Vec2<T> YZ, T W) : BVec4<T>(X, YZ.x, YZ.y, W) {} | |||||
| inline Vec4(T X, T Y, Vec2<T> ZW) : BVec4<T>(X, Y, ZW.x, ZW.y) {} | |||||
| inline Vec4(Vec2<T> XY, Vec2<T> ZW) : BVec4<T>(XY.x, XY.y, ZW.x, ZW.y) {} | |||||
| inline Vec4(Vec3<T> XYZ, T W) : BVec4<T>(XYZ.x, XYZ.y, XYZ.z, W) {} | |||||
| inline Vec4(T X, Vec3<T> YZW) : BVec4<T>(X, YZW.x, YZW.y, YZW.z) {} | |||||
| explicit inline Vec4(T X) : BVec4<T>(X, X, X, X) {} | |||||
| inline LOL_CONSTEXPR Vec4() {} | |||||
| inline LOL_CONSTEXPR Vec4(T X, T Y, T Z, T W) | |||||
| : BVec4<T>(X, Y, Z, W) {} | |||||
| inline LOL_CONSTEXPR Vec4(Vec2<T> XY, T Z, T W) | |||||
| : BVec4<T>(XY.x, XY.y, Z, W) {} | |||||
| inline LOL_CONSTEXPR Vec4(T X, Vec2<T> YZ, T W) | |||||
| : BVec4<T>(X, YZ.x, YZ.y, W) {} | |||||
| inline LOL_CONSTEXPR Vec4(T X, T Y, Vec2<T> ZW) | |||||
| : BVec4<T>(X, Y, ZW.x, ZW.y) {} | |||||
| inline LOL_CONSTEXPR Vec4(Vec2<T> XY, Vec2<T> ZW) | |||||
| : BVec4<T>(XY.x, XY.y, ZW.x, ZW.y) {} | |||||
| inline LOL_CONSTEXPR Vec4(Vec3<T> XYZ, T W) | |||||
| : BVec4<T>(XYZ.x, XYZ.y, XYZ.z, W) {} | |||||
| inline LOL_CONSTEXPR Vec4(T X, Vec3<T> YZW) | |||||
| : BVec4<T>(X, YZW.x, YZW.y, YZW.z) {} | |||||
| explicit inline LOL_CONSTEXPR Vec4(T X) : BVec4<T>(X, X, X, X) {} | |||||
| template<int N> | template<int N> | ||||
| inline Vec4(XVec4<T, N> const &v) | |||||
| inline LOL_CONSTEXPR Vec4(XVec4<T, N> const &v) | |||||
| : BVec4<T>(v[0], v[1], v[2], v[3]) {} | : BVec4<T>(v[0], v[1], v[2], v[3]) {} | ||||
| template<typename U, int N> | template<typename U, int N> | ||||
| explicit inline Vec4(XVec4<U, N> const &v) | |||||
| explicit inline LOL_CONSTEXPR Vec4(XVec4<U, N> const &v) | |||||
| : BVec4<T>(v[0], v[1], v[2], v[3]) {} | : BVec4<T>(v[0], v[1], v[2], v[3]) {} | ||||
| LOL_MEMBER_OPS(Vec4, x) | LOL_MEMBER_OPS(Vec4, x) | ||||
| static const Vec4<T> zero; | |||||
| static const Vec4<T> axis_x; | |||||
| static const Vec4<T> axis_y; | |||||
| static const Vec4<T> axis_z; | |||||
| static const Vec4<T> axis_w; | |||||
| template<typename U> | template<typename U> | ||||
| friend std::ostream &operator<<(std::ostream &stream, Vec4<U> const &v); | friend std::ostream &operator<<(std::ostream &stream, Vec4<U> const &v); | ||||
| }; | }; | ||||
| @@ -938,9 +962,9 @@ template <typename T> struct Vec4 : BVec4<T> | |||||
| template <typename T> struct Quat | template <typename T> struct Quat | ||||
| { | { | ||||
| inline Quat() {} | |||||
| inline Quat(T W) : w(W), x(0), y(0), z(0) {} | |||||
| inline Quat(T W, T X, T Y, T Z) : w(W), x(X), y(Y), z(Z) {} | |||||
| inline LOL_CONSTEXPR Quat() {} | |||||
| inline LOL_CONSTEXPR Quat(T W) : w(W), x(0), y(0), z(0) {} | |||||
| inline LOL_CONSTEXPR Quat(T W, T X, T Y, T Z) : w(W), x(X), y(Y), z(Z) {} | |||||
| Quat(Mat3<T> const &m); | Quat(Mat3<T> const &m); | ||||
| Quat(Mat4<T> const &m); | Quat(Mat4<T> const &m); | ||||
| @@ -149,6 +149,7 @@ | |||||
| <ClCompile Include="layer.cpp" /> | <ClCompile Include="layer.cpp" /> | ||||
| <ClCompile Include="light.cpp" /> | <ClCompile Include="light.cpp" /> | ||||
| <ClCompile Include="map.cpp" /> | <ClCompile Include="map.cpp" /> | ||||
| <ClCompile Include="math\constants.cpp" /> | |||||
| <ClCompile Include="math\geometry.cpp" /> | <ClCompile Include="math\geometry.cpp" /> | ||||
| <ClCompile Include="math\half.cpp" /> | <ClCompile Include="math\half.cpp" /> | ||||
| <ClCompile Include="math\real.cpp" /> | <ClCompile Include="math\real.cpp" /> | ||||
| @@ -314,4 +315,4 @@ | |||||
| <ImportGroup Label="ExtensionTargets"> | <ImportGroup Label="ExtensionTargets"> | ||||
| <Import Project="$(SolutionDir)\Lol.Fx.targets" /> | <Import Project="$(SolutionDir)\Lol.Fx.targets" /> | ||||
| </ImportGroup> | </ImportGroup> | ||||
| </Project> | |||||
| </Project> | |||||
| @@ -131,7 +131,7 @@ LevelMap::LevelMap(char const *path) | |||||
| { | { | ||||
| /* This is a tileset image file. Associate it with firstgid. */ | /* This is a tileset image file. Associate it with firstgid. */ | ||||
| data->tilesets[data->ntilers] = Tiler::Register(str, ivec2(32), | data->tilesets[data->ntilers] = Tiler::Register(str, ivec2(32), | ||||
| ivec2(0)); | |||||
| ivec2::zero); | |||||
| data->ntilers++; | data->ntilers++; | ||||
| //Log::Debug("new tiler %s\n", str); | //Log::Debug("new tiler %s\n", str); | ||||
| } | } | ||||
| @@ -0,0 +1,63 @@ | |||||
| // | |||||
| // Lol Engine | |||||
| // | |||||
| // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||||
| // 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. | |||||
| // | |||||
| #if defined HAVE_CONFIG_H | |||||
| # include "config.h" | |||||
| #endif | |||||
| #include "core.h" | |||||
| namespace lol { | |||||
| #define LOL_VEC_2_CONST(type, name, a, b) \ | |||||
| template<> \ | |||||
| Vec2<type> const Vec2<type>::name = Vec2<type>((type)a, (type)b); | |||||
| #define LOL_VEC_3_CONST(type, name, a, b, c) \ | |||||
| template<> \ | |||||
| Vec3<type> const Vec3<type>::name = Vec3<type>((type)a, (type)b, (type)c); | |||||
| #define LOL_VEC_4_CONST(type, name, a, b, c, d) \ | |||||
| template<> \ | |||||
| Vec4<type> const Vec4<type>::name = Vec4<type>((type)a, (type)b, (type)c, (type)d); | |||||
| #define LOL_ALL_VECTOR_CONST_INNER(type) \ | |||||
| LOL_VEC_2_CONST(type, zero, 0, 0) \ | |||||
| LOL_VEC_2_CONST(type, axis_x, 1, 0) \ | |||||
| LOL_VEC_2_CONST(type, axis_y, 0, 1) \ | |||||
| \ | |||||
| LOL_VEC_3_CONST(type, zero, 0, 0, 0) \ | |||||
| LOL_VEC_3_CONST(type, axis_x, 1, 0, 0) \ | |||||
| LOL_VEC_3_CONST(type, axis_y, 0, 1, 0) \ | |||||
| LOL_VEC_3_CONST(type, axis_z, 0, 0, 1) \ | |||||
| \ | |||||
| LOL_VEC_4_CONST(type, zero, 0, 0, 0, 0) \ | |||||
| LOL_VEC_4_CONST(type, axis_x, 1, 0, 0, 0) \ | |||||
| LOL_VEC_4_CONST(type, axis_y, 0, 1, 0, 0) \ | |||||
| LOL_VEC_4_CONST(type, axis_z, 0, 0, 1, 0) \ | |||||
| LOL_VEC_4_CONST(type, axis_w, 0, 0, 0, 1) | |||||
| LOL_ALL_VECTOR_CONST_INNER(half) | |||||
| LOL_ALL_VECTOR_CONST_INNER(float) | |||||
| LOL_ALL_VECTOR_CONST_INNER(double) | |||||
| LOL_ALL_VECTOR_CONST_INNER(ldouble) | |||||
| LOL_ALL_VECTOR_CONST_INNER(real) | |||||
| LOL_ALL_VECTOR_CONST_INNER(int8_t) | |||||
| LOL_ALL_VECTOR_CONST_INNER(uint8_t) | |||||
| LOL_ALL_VECTOR_CONST_INNER(int16_t) | |||||
| LOL_ALL_VECTOR_CONST_INNER(uint16_t) | |||||
| LOL_ALL_VECTOR_CONST_INNER(int32_t) | |||||
| LOL_ALL_VECTOR_CONST_INNER(uint32_t) | |||||
| LOL_ALL_VECTOR_CONST_INNER(int64_t) | |||||
| LOL_ALL_VECTOR_CONST_INNER(uint64_t) | |||||
| }; /* namespace lol */ | |||||
| @@ -535,7 +535,7 @@ static inline vec3 quat_toeuler_generic(quat const &q, int i, int j, int k) | |||||
| float n = norm(q); | float n = norm(q); | ||||
| if (!n) | if (!n) | ||||
| return vec3(0.f); | |||||
| return vec3::zero; | |||||
| /* (2 + i - j) % 3 means x-y-z direct order; otherwise indirect */ | /* (2 + i - j) % 3 means x-y-z direct order; otherwise indirect */ | ||||
| float const sign = ((2 + i - j) % 3) ? 1.f : -1.f; | float const sign = ((2 + i - j) % 3) ? 1.f : -1.f; | ||||
| @@ -48,7 +48,7 @@ private: | |||||
| #if USE_SDL | #if USE_SDL | ||||
| SdlInputData(int app_w, int app_h, int screen_w, int screen_h) : | SdlInputData(int app_w, int app_h, int screen_w, int screen_h) : | ||||
| m_prevmouse(ivec2(0)), | |||||
| m_prevmouse(ivec2::zero), | |||||
| m_app_w((float)app_w), | m_app_w((float)app_w), | ||||
| m_app_h((float)app_h), | m_app_h((float)app_h), | ||||
| m_screen_w((float)screen_w), | m_screen_w((float)screen_w), | ||||
| @@ -25,11 +25,11 @@ namespace lol | |||||
| WorldEntity::WorldEntity() | WorldEntity::WorldEntity() | ||||
| { | { | ||||
| m_position = vec3(0); | |||||
| m_position = vec3::zero; | |||||
| m_rotation = quat(1); | m_rotation = quat(1); | ||||
| m_velocity = vec3(0); | |||||
| m_rotation_velocity = vec3(0); | |||||
| m_bbox[0] = m_bbox[1] = vec3(0); | |||||
| m_velocity = vec3::zero; | |||||
| m_rotation_velocity = vec3::zero; | |||||
| m_bbox[0] = m_bbox[1] = vec3::zero; | |||||
| } | } | ||||
| WorldEntity::~WorldEntity() | WorldEntity::~WorldEntity() | ||||
| @@ -66,7 +66,7 @@ void BtPhysTest::InitApp() | |||||
| #if CAT_MODE | #if CAT_MODE | ||||
| /* cat datas setup */ | /* cat datas setup */ | ||||
| m_cat_texture = Tiler::Register("data/CatsSheet.png", ivec2(0), ivec2(0,1)); | |||||
| m_cat_texture = Tiler::Register("data/CatsSheet.png", ivec2::zero, ivec2(0,1)); | |||||
| m_fov_dp = .0f; | m_fov_dp = .0f; | ||||
| m_loc_dp = .0f; | m_loc_dp = .0f; | ||||
| #endif //CAT_MODE | #endif //CAT_MODE | ||||
| @@ -136,12 +136,12 @@ public: | |||||
| m_zoom_mesh = 0.f; | m_zoom_mesh = 0.f; | ||||
| m_zoom_speed = 0.f; | m_zoom_speed = 0.f; | ||||
| m_rot = vec2(45.f); | m_rot = vec2(45.f); | ||||
| m_rot_mesh = vec2(0.f); | |||||
| m_rot_speed = vec2(0.f); | |||||
| m_pos = vec2(0.f); | |||||
| m_pos_mesh = vec2(0.f); | |||||
| m_pos_speed = vec2(0.f); | |||||
| m_screen_offset = vec2(0.f); | |||||
| m_rot_mesh = vec2::zero; | |||||
| m_rot_speed = vec2::zero; | |||||
| m_pos = vec2::zero; | |||||
| m_pos_mesh = vec2::zero; | |||||
| m_pos_speed = vec2::zero; | |||||
| m_screen_offset = vec2::zero; | |||||
| m_camera = new Camera(); | m_camera = new Camera(); | ||||
| m_camera->SetView(vec3(0.f, 0.f, 10.f), vec3(0.f, 0.f, 0.f), vec3(0.f, 1.f, 0.f)); | m_camera->SetView(vec3(0.f, 0.f, 10.f), vec3(0.f, 0.f, 0.f), vec3(0.f, 1.f, 0.f)); | ||||
| @@ -206,7 +206,7 @@ public: | |||||
| //Camera update | //Camera update | ||||
| bool is_pos = false; | bool is_pos = false; | ||||
| bool is_fov = false; | bool is_fov = false; | ||||
| vec2 tmp = vec2(0.f); | |||||
| vec2 tmp = vec2::zero; | |||||
| #if !__native_client__ | #if !__native_client__ | ||||
| is_pos = m_controller->GetKey(KEY_CAM_POS).IsDown(); | is_pos = m_controller->GetKey(KEY_CAM_POS).IsDown(); | ||||
| @@ -252,7 +252,7 @@ public: | |||||
| #if !__native_client__ | #if !__native_client__ | ||||
| if (m_controller->GetKey(KEY_CAM_RESET).IsDown()) | if (m_controller->GetKey(KEY_CAM_RESET).IsDown()) | ||||
| { | { | ||||
| pos_mesh = vec2(0.f); | |||||
| pos_mesh = vec2::zero; | |||||
| zoom_mesh = 0.f; | zoom_mesh = 0.f; | ||||
| } | } | ||||
| #endif //!__native_client__ | #endif //!__native_client__ | ||||
| @@ -426,7 +426,7 @@ public: | |||||
| { | { | ||||
| m_texture_shader = Shader::Create(LOLFX_RESOURCE_NAME(shinymvtexture)); | m_texture_shader = Shader::Create(LOLFX_RESOURCE_NAME(shinymvtexture)); | ||||
| m_texture_uni = m_texture_shader->GetUniformLocation("u_Texture"); | m_texture_uni = m_texture_shader->GetUniformLocation("u_Texture"); | ||||
| m_default_texture = Tiler::Register("data/test-texture.png", ivec2(0), ivec2(0,1)); | |||||
| m_default_texture = Tiler::Register("data/test-texture.png", ivec2::zero, ivec2(0,1)); | |||||
| } | } | ||||
| else if (m_texture && m_default_texture) | else if (m_texture && m_default_texture) | ||||
| m_texture_shader->SetUniform(m_texture_uni, m_default_texture->GetTexture(), 0); | m_texture_shader->SetUniform(m_texture_uni, m_default_texture->GetTexture(), 0); | ||||
| @@ -38,8 +38,8 @@ LOLUNIT_FIXTURE(CameraTest) | |||||
| void SetUp() | void SetUp() | ||||
| { | { | ||||
| eye = vec3(0.f, 0.f, 50.f); | eye = vec3(0.f, 0.f, 50.f); | ||||
| target = vec3(0.f); | |||||
| up = vec3(0.f, 1.f, 0.f); | |||||
| target = vec3::zero; | |||||
| up = vec3::axis_y; | |||||
| m_lookat = mat4::lookat(eye, target, up); | m_lookat = mat4::lookat(eye, target, up); | ||||
| q_lookat = quat(m_lookat); | q_lookat = quat(m_lookat); | ||||
| v_lookat = vec3::toeuler_zyx(q_lookat); | v_lookat = vec3::toeuler_zyx(q_lookat); | ||||