Skip to content

Commit

Permalink
v168 - further support for clang & macos
Browse files Browse the repository at this point in the history
  • Loading branch information
inanevin committed Nov 18, 2023
1 parent e5246f7 commit ed65ae0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_SUPPRESS_REGENERATION true)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
##set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
## set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")

#--------------------------------------------------------------------
# Set sources
Expand Down Expand Up @@ -75,7 +75,7 @@ add_library(Lina::VG ALIAS ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_compile_definitions(${PROJECT_NAME} PUBLIC LINAVG_VERSION_MAJOR=1)
target_compile_definitions(${PROJECT_NAME} PUBLIC LINAVG_VERSION_MINOR=6)
target_compile_definitions(${PROJECT_NAME} PUBLIC LINAVG_VERSION_PATCH=7)
target_compile_definitions(${PROJECT_NAME} PUBLIC LINAVG_VERSION_PATCH=8)

#--------------------------------------------------------------------
# Subdirectories & linking
Expand Down
19 changes: 11 additions & 8 deletions include/LinaVG/Core/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ SOFTWARE.
#include <string>
#include <unordered_map>
#include <vector>
#include <cassert>
#include <cstring>
#include <cstddef>
#include "Vectors.hpp"

namespace LinaVG
Expand Down Expand Up @@ -198,7 +201,7 @@ namespace LinaVG

inline void shrink(int size)
{
_ASSERT(size <= m_size);
assert(size <= m_size);
m_size = size;
}

Expand Down Expand Up @@ -235,8 +238,8 @@ namespace LinaVG

inline T* erase(const T* it)
{
_ASSERT(it >= m_data && it < m_data + m_size);
const ptrdiff_t off = it - m_data;
assert(it >= m_data && it < m_data + m_size);
const std::ptrdiff_t off = it - m_data;
std::memmove(m_data + off, m_data + off + 1, ((size_t)m_size - (size_t)off - 1) * sizeof(T));
m_size--;
return m_data + off;
Expand All @@ -254,13 +257,13 @@ namespace LinaVG

inline T& operator[](int i)
{
_ASSERT(i >= 0 && i < m_capacity);
assert(i >= 0 && i < m_capacity);
return m_data[i];
}

inline const T& operator[](int i) const
{
_ASSERT(i >= 0 && i < m_capacity);
assert(i >= 0 && i < m_capacity);
return m_data[i];
}

Expand Down Expand Up @@ -289,7 +292,7 @@ namespace LinaVG

inline void swap(int start, int end)
{
_ASSERT(start > -1 && start < m_size && end > -1 && end < m_size);
assert(start > -1 && start < m_size && end > -1 && end < m_size);
T temp = m_data[start];
m_data[start] = m_data[end];
m_data[end] = temp;
Expand Down Expand Up @@ -842,9 +845,9 @@ namespace LinaVG
BackendHandle clipSizeX = 0;
BackendHandle clipSizeY = 0;

bool IsClipDifferent(BackendHandle clipPosX, BackendHandle clipPosY, BackendHandle clipSizeX, BackendHandle clipSizeY)
bool IsClipDifferent(BackendHandle cpx, BackendHandle cpy, BackendHandle csx, BackendHandle csy)
{
return (this->clipPosX != clipPosX || this->clipPosY != clipPosY || this->clipSizeX != clipSizeX || this->clipSizeY != clipSizeY);
return (this->clipPosX != cpx || this->clipPosY != cpy || this->clipSizeX != csx || this->clipSizeY != csy);
}

inline void Clear()
Expand Down
13 changes: 7 additions & 6 deletions src/Core/Math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SOFTWARE.

#include "LinaVG/Core/Math.hpp"
#include <cmath>
#include <cassert>

namespace LinaVG
{
Expand Down Expand Up @@ -55,22 +56,22 @@ namespace LinaVG

float Math::GetAngleFromCenter(const Vec2& center, const Vec2& point)
{
return LVG_RAD2DEG * (std::atan2(point.y - center.y, point.x - center.x));
return LVG_RAD2DEG * (atan2(point.y - center.y, point.x - center.x));
}

float Math::GetAngleBetween(const Vec2& p1, const Vec2& p2)
{
return LVG_RAD2DEG * (std::atan2(p2.y, p2.x) - atan2(p1.y, p1.x));
return LVG_RAD2DEG * (atan2(p2.y, p2.x) - atan2(p1.y, p1.x));
}

float Math::GetAngleBetweenDirs(const Vec2& dir1, const Vec2& dir2)
{
return LVG_RAD2DEG * std::atan2f(dir1.x * dir2.y - dir1.y * dir2.x, dir1.x * dir2.x + dir1.y * dir2.y);
return LVG_RAD2DEG * atan2f(dir1.x * dir2.y - dir1.y * dir2.x, dir1.x * dir2.x + dir1.y * dir2.y);
}

float Math::GetAngleBetweenShort(const Vec2& p1, const Vec2& p2)
{
float ang = LVG_RAD2DEG * (std::atan2(p2.y, p2.x) - atan2(p1.y, p1.x));
float ang = LVG_RAD2DEG * (atan2(p2.y, p2.x) - atan2(p1.y, p1.x));

if (ang > 180.0f)
ang = 360.0f - ang;
Expand Down Expand Up @@ -165,8 +166,8 @@ namespace LinaVG
// Parallel
if (det == 0.0f)
return p10;

_ASSERT(det != 0.0f);
assert(det != 0.0f);

float x = (b2 * c1 - b1 * c2) / det;
float y = (a1 * c2 - a2 * c1) / det;
Expand Down
3 changes: 2 additions & 1 deletion src/Core/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ SOFTWARE.
#include "LinaVG/Core/Text.hpp"
#include "LinaVG/Utility/Utility.hpp"
#include <math.h>
#include <cassert>

namespace LinaVG
{
Expand Down Expand Up @@ -102,7 +103,7 @@ namespace LinaVG
{
Internal::InitThreadedData();

_ASSERT(Backend::BaseBackend::Get() != nullptr);
assert(Backend::BaseBackend::Get() != nullptr);

if (!Backend::BaseBackend::Get()->Initialize())
{
Expand Down

0 comments on commit ed65ae0

Please sign in to comment.