Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ env:
jobs:
build:
strategy:
# Linux runs alongside Windows/macOS, but the engine's own Linux support is
# not yet verified -- keep a failing Linux leg from cancelling the others.
fail-fast: false
matrix:
os: ['windows-2022', 'macOS-latest']
os: ['windows-2022', 'macOS-latest', 'ubuntu-latest']

runs-on: ${{ matrix.os }}

Expand All @@ -38,6 +41,14 @@ jobs:
uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'

# Qt's prebuilt Qt6::Gui transitively requires WrapOpenGL, so CMake's FindOpenGL needs the GL dev
# files (libOpenGL.so, libGLX.so, GL/gl.h). The runners only ship the runtime libraries by default.
- name: Setup Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev
if: runner.os == 'Linux'

- name: Checkout Repo
uses: actions/checkout@v4

Expand All @@ -62,6 +73,15 @@ jobs:
- name: Config Conan Remote
run: conan remote add explosion https://conan.kindem.online/artifactory/api/conan/conan

# xorg/system (pulled in transitively by Qt on Linux) declares its X11 dev packages as system
# requirements; let Conan install them via apt instead of erroring out in the default 'check' mode.
- name: Allow Conan System Package Install
run: |
conf="$(conan config home)/global.conf"
echo "tools.system.package_manager:mode=install" >> "$conf"
echo "tools.system.package_manager:sudo=True" >> "$conf"
if: runner.os == 'Linux'

# Register the in-repo recipes in the local cache so the engine's 'conan install --build=missing'
# resolves them from this checkout: unchanged recipes hash to the revision already published on the
# remote (binaries are downloaded), changed ones get built locally, making recipe PRs self-contained.
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/publish-conan-recipes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
cppstd: '17'
- os: macOS-latest
cppstd: gnu17
- os: ubuntu-latest
cppstd: gnu17

runs-on: ${{ matrix.os }}

Expand All @@ -45,6 +47,20 @@ jobs:
uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'

# The Linux leg runs Qt's test_package, a headless QWebEngineView smoke test, which needs:
# - GL dev files (libOpenGL.so, libGLX.so, GL/gl.h) for CMake's FindOpenGL at configure time, since
# Qt6::Gui transitively requires WrapOpenGL; runners ship only the GL runtime libraries.
# - QtWebEngine's Chromium runtime libs (NSS/NSPR, ALSA, libxkbfile) so libQt6WebEngineCore loads.
# The headless run env (QT_QPA_PLATFORM=offscreen, QTWEBENGINE_DISABLE_SANDBOX=1) is set by the qt
# recipe's test_package itself, so it is not configured here.
- name: Setup Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libgl1-mesa-dev libglu1-mesa-dev \
libnss3 libnspr4 libxkbfile1 libasound2t64
if: runner.os == 'Linux'

- name: Checkout Repo
uses: actions/checkout@v4

Expand Down
4 changes: 4 additions & 0 deletions CMake/Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_UNITY_BUILD ${USE_UNITY_BUILD})
set(CMAKE_EXPORT_COMPILE_COMMANDS ${EXPORT_COMPILE_COMMANDS})

# Static libraries such as Common get linked into the engine's shared libraries, so on ELF platforms every object must be
# position-independent or the shared link fails with "relocation ... can not be used when making a shared object".
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if (${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/Installed CACHE PATH "" FORCE)
endif()
Expand Down
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ set(SUB_PROJECT_VERSION_PATCH 1 CACHE STRING "" FORCE)
set(SUB_PROJECT_CMAKE_LIBS "ThirdParty/Registry.cmake" CACHE STRING "" FORCE)
set(USE_CONAN ON CACHE BOOL "" FORCE)

set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG "Release" CACHE STRING "" FORCE)
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Release" CACHE STRING "" FORCE)
set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL "Release" CACHE STRING "" FORCE)
# Conan builds its dependencies as Release, so map the other configs onto Release imported locations. The trailing
# empty element keeps the configuration-less IMPORTED_LOCATION as a fallback; system find-modules such as FindOpenGL
# create UNKNOWN imported targets (OpenGL::OpenGL / OpenGL::GLX on Linux) that only set the suffix-less location, and
# without this fallback CMake reports "IMPORTED_LOCATION not set ... configuration Debug" at generate time.
set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG "Release;" CACHE STRING "" FORCE)
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Release;" CACHE STRING "" FORCE)
set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL "Release;" CACHE STRING "" FORCE)

add_compile_definitions(BUILD_EDITOR=$<BOOL:${BUILD_EDITOR}>)

Expand Down
6 changes: 5 additions & 1 deletion Editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ exp_add_resources_copy_command(
# ---- end shaders -----------------------------------------------------------------------------------

# ---- begin web project -----------------------------------------------------------------------------
find_program(npm_executable NAMES npm.cmd npm REQUIRED NO_CACHE)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
find_program(npm_executable NAMES npm.cmd npm REQUIRED NO_CACHE)
else ()
find_program(npm_executable NAMES npm REQUIRED NO_CACHE)
endif ()
message("Perform web project npm install......")
execute_process(
COMMAND ${CMAKE_COMMAND} -E env ${npm_executable} install --no-fund --registry=https://registry.npmmirror.com
Expand Down
4 changes: 2 additions & 2 deletions Editor/Include/Editor/Qt/JsonSerialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ namespace Editor {
struct QtJsonSerializer<int64_t> {
static void QtJsonSerialize(QJsonValue& outJsonValue, int64_t inValue)
{
outJsonValue = inValue;
outJsonValue = static_cast<qint64>(inValue);
}

static void QtJsonDeserialize(const QJsonValue& inJsonValue, int64_t& outValue)
Expand All @@ -191,7 +191,7 @@ namespace Editor {
struct QtJsonSerializer<uint64_t> {
static void QtJsonSerialize(QJsonValue& outJsonValue, uint64_t inValue)
{
outJsonValue = static_cast<int64_t>(inValue);
outJsonValue = static_cast<qint64>(inValue);
}

static void QtJsonDeserialize(const QJsonValue& inJsonValue, uint64_t& outValue)
Expand Down
1 change: 1 addition & 0 deletions Engine/Source/Common/Include/Common/Delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma once

#include <algorithm>
#include <utility>
#include <vector>
#include <functional>
Expand Down
22 changes: 18 additions & 4 deletions Engine/Source/Common/Include/Common/Math/Quaternion.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace Common {

Quaternion& operator+=(const Quaternion& rhs);
Quaternion& operator-=(const Quaternion& rhs);
Quaternion& operator*=(T rhs) const;
Quaternion& operator*=(T rhs);
Quaternion& operator*=(const Quaternion& rhs);
Quaternion& operator/=(T rhs);

Expand All @@ -97,6 +97,9 @@ namespace Common {
// when axis faced to us, ccw as positive direction
Vec<T, 3> RotateVector(const Vec<T, 3>& inVector) const;
Mat<T, 4, 4> GetRotationMatrix() const;

template <typename IT>
Quaternion<IT> CastTo() const;
};

template <typename T>
Expand Down Expand Up @@ -541,7 +544,7 @@ namespace Common {
}

template <typename T>
Quaternion<T>& Quaternion<T>::operator*=(T rhs) const
Quaternion<T>& Quaternion<T>::operator*=(T rhs)
{
this->w *= rhs;
this->x *= rhs;
Expand All @@ -553,7 +556,7 @@ namespace Common {
template <typename T>
Quaternion<T>& Quaternion<T>::operator*=(const Quaternion& rhs)
{
*this = this * rhs;
*this = *this * rhs;
return *this;
}

Expand Down Expand Up @@ -610,7 +613,7 @@ namespace Common {
template <typename T>
T Quaternion<T>::Dot(const Quaternion& rhs) const
{
return this->w * rhs.w * this->x * rhs.x + this->y * rhs.y + this->z * rhs.z;
return this->w * rhs.w + this->x * rhs.x + this->y * rhs.y + this->z * rhs.z;
}

template <typename T>
Expand Down Expand Up @@ -643,4 +646,15 @@ namespace Common {
);
}

template <typename T>
template <typename IT>
Quaternion<IT> Quaternion<T>::CastTo() const
{
Quaternion<IT> result;
result.w = static_cast<IT>(this->w);
result.x = static_cast<IT>(this->x);
result.y = static_cast<IT>(this->y);
result.z = static_cast<IT>(this->z);
return result;
}
}
2 changes: 1 addition & 1 deletion Engine/Source/Common/Include/Common/Math/Rect.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ namespace Common {
template <typename T>
T Rect<T>::Size() const
{
Vec<T, 3> diagonal = this->max - this->min;
Vec<T, 2> diagonal = this->max - this->min;
return diagonal.Model() / T(2);
}

Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Common/Include/Common/Math/Transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ namespace Common {
template <typename T>
Vec<T, 4> Transform<T>::TransformPosition(const Vec<T, 4>& inPosition) const
{
Mat<T, 4, 1> posColMat = Mat<T, 4, 1>::FromColVecs(inPosition);
Mat<T, 4, 1> posColMat = Mat<T, 4, 1>::FromColVecs(Vec<T, 4>(inPosition));
return (GetTransformMatrix() * posColMat).Col(0);
}

Expand Down
4 changes: 2 additions & 2 deletions Engine/Source/Common/Include/Common/Math/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace Common {
static const Vec<T, 4> unit;
static const Vec<T, 4> negaUnitX;
static const Vec<T, 4> negaUnitY;
static const Vec<T, 4> negaUintZ;
static const Vec<T, 4> negaUnitZ;
static const Vec<T, 4> negaUnitW;
static const Vec<T, 4> negaUnit;
};
Expand Down Expand Up @@ -492,7 +492,7 @@ namespace Common {
const Vec<T, 4> VecConsts<T, 4>::negaUnitY = Vec<T, 4>(0, -1, 0, 0);

template <typename T>
const Vec<T, 4> VecConsts<T, 4>::negaUintZ = Vec<T, 4>(0, 0, -1, 0);
const Vec<T, 4> VecConsts<T, 4>::negaUnitZ = Vec<T, 4>(0, 0, -1, 0);

template <typename T>
const Vec<T, 4> VecConsts<T, 4>::negaUnitW = Vec<T, 4>(0, 0, 0, -1);
Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Common/Include/Common/Math/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Common {
template <typename T>
ViewTransform<T> ViewTransform<T>::LookAt(const Vec<T, 3>& inPosition, const Vec<T, 3>& inTargetPosition, const Vec<T, 3>& inUpDirection)
{
return Transform<T>::LookAt(inPosition, inTargetPosition, inUpDirection);
return ViewTransform<T>(Transform<T>::LookAt(inPosition, inTargetPosition, inUpDirection));
}

template <typename T>
Expand Down
6 changes: 6 additions & 0 deletions Engine/Source/Common/Include/Common/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

#include <string>

// GCC and Clang in GNU mode predefine the bare macro `linux` as 1, which collides with the linux enumerators below.
// Drop it so the lowercase enumerator stays valid; the canonical `__linux__` is unaffected.
#ifdef linux
#undef linux
#endif

namespace Common {
enum class DevelopmentPlatform {
windows,
Expand Down
1 change: 1 addition & 0 deletions Engine/Source/Common/Include/Common/Serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include <cstdint>
#include <cmath>
#include <fstream>
#include <string>
#include <optional>
Expand Down
5 changes: 4 additions & 1 deletion Engine/Source/Common/Src/Concurrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ namespace Common {
#elif PLATFORM_MACOS
pthread_setname_np(name.c_str());
#else
pthread_setname_np(thread.native_handle(), name.c_str());
// SetThreadName always runs inside the freshly spawned thread, so name the current thread via pthread_self();
// reading thread.native_handle() here would race with the std::thread move-assignment in the constructor and
// could observe a null handle, crashing pthread_setname_np.
pthread_setname_np(pthread_self(), name.c_str());
#endif
}

Expand Down
15 changes: 10 additions & 5 deletions Engine/Source/Common/Src/Math/Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <cmath>
#include <sstream>
#include <iomanip>

#include <Common/Math/Color.h>
#include <Common/Math/Common.h>
Expand Down Expand Up @@ -59,7 +60,11 @@ namespace Common {
std::string Color::ToHexString() const
{
std::stringstream result;
result << "0x" << std::hex << r << std::hex << g << std::hex << b << std::hex << a;
result << "0x" << std::hex << std::setfill('0')
<< std::setw(2) << static_cast<uint32_t>(r)
<< std::setw(2) << static_cast<uint32_t>(g)
<< std::setw(2) << static_cast<uint32_t>(b)
<< std::setw(2) << static_cast<uint32_t>(a);
return result.str();
}

Expand Down Expand Up @@ -136,10 +141,10 @@ namespace Common {
}

const Color ColorConsts::white = Color(255, 255, 255, 255);
const Color ColorConsts::black = Color(0, 0, 0, 1);
const Color ColorConsts::red = Color(1, 0, 0, 1);
const Color ColorConsts::green = Color(0, 1, 0, 1);
const Color ColorConsts::blue = Color(0, 0, 1, 1);
const Color ColorConsts::black = Color(0, 0, 0, 255);
const Color ColorConsts::red = Color(255, 0, 0, 255);
const Color ColorConsts::green = Color(0, 255, 0, 255);
const Color ColorConsts::blue = Color(0, 0, 255, 255);

const LinearColor LinearColorConsts::white = LinearColor(1.0f, 1.0f, 1.0f, 1.0f);
const LinearColor LinearColorConsts::black = LinearColor(0.0f, 0.0f, 0.0f, 1.0f);
Expand Down
1 change: 1 addition & 0 deletions Engine/Source/Common/Src/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Created by johnk on 2024/4/14.
//

#include <algorithm>
#include <locale>
#include <codecvt>
#include <regex>
Expand Down
Loading
Loading