Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Aug 12, 2024
2 parents 6084649 + 593afbc commit be1efa4
Show file tree
Hide file tree
Showing 35 changed files with 1,581 additions and 1,427 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Update vcpkg
shell: pwsh
run: |
$vcpkgCommit = 'f7423ee180c4b7f40d43402c2feb3859161ef625'
$vcpkgCommit = 'a2367ceec5f092d8777606ca110426cadd7ed7db'
pushd "$env:VCPKG_INSTALLATION_ROOT"
git cat-file -e "${vcpkgCommit}^{commit}" 2> $null
if (!$?) {
Expand Down
78 changes: 39 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ else()
cmake_minimum_required(VERSION 3.9)
endif()

option(LEGACY_OPENGL_LIBS "Use legacy OpenGL libraries instead of glvnd library (Default: off)" OFF)

# Plain and keyword target_link_libraries() signatures cannot be mixed
if (POLICY CMP0023)
cmake_policy(SET CMP0023 NEW)
Expand All @@ -33,47 +31,52 @@ if(POLICY CMP0071)
cmake_policy(SET CMP0071 OLD)
endif()

# Prefer GLVND or "legacy" OpenGL library (libOpenGL.so vs libGL.so)
if(POLICY CMP0072)
if(LEGACY_OPENGL_LIBS)
cmake_policy(SET CMP0072 OLD)
else()
cmake_policy(SET CMP0072 NEW)
endif()
endif()

# Remove leading and trailing whitespace from libraries linked
if(POLICY CMP0004)
cmake_policy(SET CMP0004 NEW)
endif()

# Use Boost-provided FindBoost module instead of CMake-provided one
if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()

project(celestia VERSION 1.7.0 LANGUAGES C CXX)
set(DISPLAY_NAME "Celestia")
#
#
#
option(ENABLE_CELX "Enable celx scripting, requires Lua library? (Default: on)" ON)
option(ENABLE_SPICE "Use spice library? (Default: off)" OFF)
option(ENABLE_NLS "Enable interface translation? (Default: on)" ON)
option(ENABLE_GTK "Build GTK2 frontend (Unix only)? (Default: off)" OFF)
option(ENABLE_QT5 "Build Qt frontend? (Default: on)" ON)
option(ENABLE_QT6 "Build Qt6 frontend (Default: off)" OFF)
option(ENABLE_SDL "Build SDL frontend? (Default: off)" OFF)
option(ENABLE_WIN "Build Windows native frontend? (Default: on)" ON)
option(ENABLE_FFMPEG "Support video capture using FFMPEG (Default: off)" OFF)
option(ENABLE_MINIAUDIO "Support audio playback using miniaudio (Default: off)" OFF)
option(ENABLE_TOOLS "Build different tools? (Default: off)" OFF)
option(ENABLE_FAST_MATH "Build with unsafe fast-math compiller option (Default: off)" OFF)
option(ENABLE_TESTS "Enable unit tests? (Default: off)" OFF)
option(ENABLE_GLES "Build for OpenGL ES 2.0 instead of OpenGL 2.1 (Default: off)" OFF)
option(ENABLE_LTO "Enable link time optimizations (Default: off)" OFF)
option(USE_GTKGLEXT "Use libgtkglext1 for GTK2 frontend (Default: on)" ON)
option(USE_GTK3 "Use Gtk3 in GTK2 frontend (Default: off)" OFF)
option(USE_WAYLAND "Use Wayland in Qt frontend (Default: off)" OFF)
option(USE_GLSL_STRUCTS "Use structs in GLSL (Default: off)" OFF)
option(USE_ICU "Use ICU for UTF8 decoding for text rendering (Default: off)" OFF)
option(USE_WIN_ICU "Use Windows SDK's ICU implementation (Default: off)" OFF)
option(USE_WEFFCPP "Use the -Weffc++ option when compiling with GCC (Default: off)" OFF)
option(ENABLE_CELX "Enable celx scripting, requires Lua library? (Default: on)" ON)
option(ENABLE_SPICE "Use spice library? (Default: off)" OFF)
option(ENABLE_NLS "Enable interface translation? (Default: on)" ON)
option(ENABLE_GTK "Build GTK2 frontend (Unix only)? (Default: off)" OFF)
option(ENABLE_QT5 "Build Qt frontend? (Default: off)" OFF)
option(ENABLE_QT6 "Build Qt6 frontend (Default: off)" OFF)
option(ENABLE_SDL "Build SDL frontend? (Default: off)" OFF)
option(ENABLE_WIN "Build Windows native frontend? (Default: on)" ON)
option(ENABLE_FFMPEG "Support video capture using FFMPEG (Default: off)" OFF)
option(ENABLE_MINIAUDIO "Support audio playback using miniaudio (Default: off)" OFF)
option(ENABLE_TOOLS "Build different tools? (Default: off)" OFF)
option(ENABLE_FAST_MATH "Build with unsafe fast-math compiller option (Default: off)" OFF)
option(ENABLE_TESTS "Enable unit tests? (Default: off)" OFF)
option(ENABLE_GLES "Build for OpenGL ES 2.0 instead of OpenGL 2.1 (Default: off)" OFF)
option(ENABLE_LTO "Enable link time optimizations (Default: off)" OFF)
option(USE_GTKGLEXT "Use libgtkglext1 for GTK2 frontend (Default: on)" ON)
option(USE_GTK3 "Use Gtk3 in GTK2 frontend (Default: off)" OFF)
option(USE_WAYLAND "Use Wayland in Qt frontend (Default: off)" OFF)
option(USE_GLSL_STRUCTS "Use structs in GLSL (Default: off)" OFF)
option(USE_ICU "Use ICU for UTF8 decoding for text rendering (Default: off)" OFF)
option(USE_WIN_ICU "Use Windows SDK's ICU implementation (Default: off)" OFF)
option(USE_MESHOPTIMIZER "Use meshoptimizer (Default: off)" OFF)
option(USE_WEFFCPP "Use the -Weffc++ option when compiling with GCC (Default: off)" OFF)
option(LEGACY_OPENGL_LIBS "Use legacy OpenGL libraries instead of glvnd library (Default: off)" OFF)

# Prefer GLVND or "legacy" OpenGL library (libOpenGL.so vs libGL.so)
if(LEGACY_OPENGL_LIBS)
set(OpenGL_GL_PREFERENCE LEGACY)
else()
set(OpenGL_GL_PREFERENCE GLVND)
endif()

# Qt requires -fPIC, so build all code with it
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down Expand Up @@ -269,7 +272,7 @@ find_package(Eigen3 3.3 REQUIRED NO_MODULE) # -DEigen3_DIR=...
message(STATUS "Found Eigen3 ${EIGEN3_VERSION_STRING}")
link_libraries(Eigen3::Eigen)

find_package(fmt 6.1.0 CONFIG QUIET)
find_package(fmt 8.0.0 CONFIG QUIET)
if(NOT fmt_FOUND)
message(STATUS "Using fmt submodule")
add_subdirectory("${CMAKE_SOURCE_DIR}/thirdparty/fmt")
Expand Down Expand Up @@ -304,12 +307,9 @@ endif()
find_package(Freetype REQUIRED)
link_libraries(Freetype::Freetype)

find_package(meshoptimizer CONFIG QUIET)
if(meshoptimizer_FOUND)
message(STATUS "Found meshoptimizer library")
if(USE_MESHOPTIMIZER)
find_package(meshoptimizer CONFIG REQUIRED)
set(HAVE_MESHOPTIMIZER 1)
else()
message(STATUS "meshoptimizer library is missing")
endif()

if(USE_WAYLAND)
Expand Down
43 changes: 22 additions & 21 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,29 +351,30 @@ the following option to cmake: `-DCMAKE_INSTALL_PREFIX=/another/path`.

List of supported parameters (passed as `-DPARAMETER=VALUE`):

Parameter | TYPE | Default | Description
----------------------| ------|---------|--------------------------------------
| CMAKE_INSTALL_PREFIX | path | \* | Prefix where to install Celestia
| CMAKE_PREFIX_PATH | path | | Additional path to look for libraries
Parameter | TYPE | Default | Description
-----------------------|------|-----------|--------------------------------------
| CMAKE_INSTALL_PREFIX | path | \* | Prefix where to install Celestia
| CMAKE_PREFIX_PATH | path | | Additional path to look for libraries
| LEGACY_OPENGL_LIBS | bool | \*\*OFF | Use OpenGL libraries not GLvnd
| ENABLE_CELX | bool | ON | Enable Lua scripting support
| ENABLE_SPICE | bool | OFF | Enable NAIF kernels support
| ENABLE_NLS | bool | ON | Enable interface translation
| ENABLE_CELX | bool | ON | Enable Lua scripting support
| ENABLE_SPICE | bool | OFF | Enable NAIF kernels support
| ENABLE_NLS | bool | ON | Enable interface translation
| ENABLE_GTK | bool | \*\*OFF | Build legacy GTK2 frontend
| ENABLE_QT5 | bool | ON | Build Qt5 frontend
| ENABLE_QT6 | bool | ON | Build Qt6 frontend
| ENABLE_SDL | bool | OFF | Build SDL frontend
| ENABLE_WIN | bool | \*\*\*ON | Build Windows native frontend
| ENABLE_FFMPEG | bool | OFF | Support video capture using ffmpeg
| ENABLE_LIBAVIF | bool | OFF | Support AVIF texture using libavif
| ENABLE_MINIAUDIO | bool | OFF | Support audio playback using miniaudio
| ENABLE_TOOLS | bool | OFF | Build tools for Celestia data files
| ENABLE_GLES | bool | OFF | Use OpenGL ES 2.0 in rendering code
| USE_GTKGLEXT | bool | ON | Use libgtkglext1 in GTK2 frontend
| USE_QT6 | bool | OFF | Use Qt6 in Qt frontend
| USE_GTK3 | bool | OFF | Use Gtk3 instead of Gtk2 in GTK2 frontend
| USE_GLSL_STRUCTS | bool | OFF | Use structs in GLSL
| USE_ICU | bool | OFF | Use ICU for UTF8 decoding for text rendering
| ENABLE_QT5 | bool | OFF | Build Qt5 frontend
| ENABLE_QT6 | bool | OFF | Build Qt6 frontend
| ENABLE_SDL | bool | OFF | Build SDL frontend
| ENABLE_WIN | bool | \*\*\*ON | Build Windows native frontend
| ENABLE_FFMPEG | bool | OFF | Support video capture using ffmpeg
| ENABLE_LIBAVIF | bool | OFF | Support AVIF texture using libavif
| ENABLE_MINIAUDIO | bool | OFF | Support audio playback using miniaudio
| ENABLE_TOOLS | bool | OFF | Build tools for Celestia data files
| ENABLE_GLES | bool | OFF | Use OpenGL ES 2.0 in rendering code
| USE_GTKGLEXT | bool | ON | Use libgtkglext1 in GTK2 frontend
| USE_QT6 | bool | OFF | Use Qt6 in Qt frontend
| USE_GTK3 | bool | OFF | Use Gtk3 instead of Gtk2 in GTK2 frontend
| USE_GLSL_STRUCTS | bool | OFF | Use structs in GLSL
| USE_ICU | bool | OFF | Use ICU for UTF8 decoding for text rendering
| USE_MESHOPTIMIZER | bool | OFF | Use meshoptimizer when loading models

Notes:
\* /usr/local on Unix-like systems, c:\Program Files or c:\Program Files (x86)
Expand Down
7 changes: 4 additions & 3 deletions src/cel3ds/3dsread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ constexpr auto chunkHeaderSize = static_cast<std::int32_t>(sizeof(M3DChunkType)
template<>
struct fmt::formatter<M3DChunkType>
{
constexpr auto parse(const format_parse_context& ctx) const -> decltype(ctx.begin()) {
constexpr auto parse(const format_parse_context& ctx) const
{
// we should validate the format here but exceptions are disabled
return ctx.begin();
}

template<typename FormatContext>
auto format(const M3DChunkType& chunkType, FormatContext& ctx) -> decltype(ctx.out()) {
auto format(const M3DChunkType& chunkType, format_context& ctx) const
{
return format_to(ctx.out(), "{:04x}", static_cast<std::uint16_t>(chunkType));
}
};
Expand Down
12 changes: 10 additions & 2 deletions src/celastro/astro.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,28 @@ float lumToAppMag(float lum, float lyrs);
float absMagToLum(float mag);
float appMagToLum(float mag, float lyrs);

template<class T>
CELESTIA_CMATH_CONSTEXPR T
distanceModulus(T lyrs)
{
using std::log10;
return T(5) * log10(lyrs / LY_PER_PARSEC<T>) - T(5);
}

template<class T>
CELESTIA_CMATH_CONSTEXPR T
absToAppMag(T absMag, T lyrs)
{
using std::log10;
return absMag - T(5) + T(5) * log10(lyrs / LY_PER_PARSEC<T>);
return absMag + distanceModulus(lyrs);
}

template<class T>
CELESTIA_CMATH_CONSTEXPR T
appToAbsMag(T appMag, T lyrs)
{
using std::log10;
return appMag + T(5) - T(5) * log10(lyrs / LY_PER_PARSEC<T>);
return appMag - distanceModulus(lyrs);
}

// Distance conversions
Expand Down
3 changes: 3 additions & 0 deletions src/celengine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ set(CELENGINE_SOURCES
deepskyobj.h
dsodb.cpp
dsodb.h
dsodbbuilder.cpp
dsodbbuilder.h
dsooctree.cpp
dsooctree.h
dsorenderer.cpp
Expand Down Expand Up @@ -70,6 +72,7 @@ set(CELENGINE_SOURCES
observer.cpp
observer.h
octree.h
octreebuilder.h
opencluster.cpp
opencluster.h
orbitsampler.h
Expand Down
Loading

0 comments on commit be1efa4

Please sign in to comment.