Skip to content

Commit 61c75a1

Browse files
committed
Add options in CMakeLists
1 parent 35ac17e commit 61c75a1

File tree

3 files changed

+61
-23
lines changed

3 files changed

+61
-23
lines changed

CMakeLists.txt

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,29 @@ set(DISPLAY_NAME "Celestia")
4747
#
4848
#
4949
#
50-
option(ENABLE_CELX "Enable celx scripting, requires Lua library? (Default: on)" ON)
51-
option(ENABLE_SPICE "Use spice library? (Default: off)" OFF)
52-
option(ENABLE_NLS "Enable interface translation? (Default: on)" ON)
53-
option(ENABLE_GTK "Build GTK2 frontend (Unix only)? (Default: off)" OFF)
54-
option(ENABLE_QT5 "Build Qt frontend? (Default: on)" ON)
55-
option(ENABLE_QT6 "Build Qt6 frontend (Default: off)" OFF)
56-
option(ENABLE_SDL "Build SDL frontend? (Default: off)" OFF)
57-
option(ENABLE_WIN "Build Windows native frontend? (Default: on)" ON)
58-
option(ENABLE_FFMPEG "Support video capture using FFMPEG (Default: off)" OFF)
59-
option(ENABLE_MINIAUDIO "Support audio playback using miniaudio (Default: off)" OFF)
60-
option(ENABLE_TOOLS "Build different tools? (Default: off)" OFF)
61-
option(ENABLE_FAST_MATH "Build with unsafe fast-math compiller option (Default: off)" OFF)
62-
option(ENABLE_TESTS "Enable unit tests? (Default: off)" OFF)
63-
option(ENABLE_GLES "Build for OpenGL ES 2.0 instead of OpenGL 2.1 (Default: off)" OFF)
64-
option(ENABLE_LTO "Enable link time optimizations (Default: off)" OFF)
65-
option(USE_GTKGLEXT "Use libgtkglext1 for GTK2 frontend (Default: on)" ON)
66-
option(USE_GTK3 "Use Gtk3 in GTK2 frontend (Default: off)" OFF)
67-
option(USE_WAYLAND "Use Wayland in Qt frontend (Default: off)" OFF)
68-
option(USE_GLSL_STRUCTS "Use structs in GLSL (Default: off)" OFF)
69-
option(USE_ICU "Use ICU for UTF8 decoding for text rendering (Default: off)" OFF)
70-
option(USE_WIN_ICU "Use Windows SDK's ICU implementation (Default: off)" OFF)
71-
option(USE_WEFFCPP "Use the -Weffc++ option when compiling with GCC (Default: off)" OFF)
50+
option(ENABLE_CELX "Enable celx scripting, requires Lua library? (Default: on)" ON)
51+
option(ENABLE_SPICE "Use spice library? (Default: off)" OFF)
52+
option(ENABLE_NLS "Enable interface translation? (Default: on)" ON)
53+
option(ENABLE_GTK "Build GTK2 frontend (Unix only)? (Default: off)" OFF)
54+
option(ENABLE_QT5 "Build Qt frontend? (Default: on)" ON)
55+
option(ENABLE_QT6 "Build Qt6 frontend (Default: off)" OFF)
56+
option(ENABLE_SDL "Build SDL frontend? (Default: off)" OFF)
57+
option(ENABLE_WIN "Build Windows native frontend? (Default: on)" ON)
58+
option(ENABLE_FFMPEG "Support video capture using FFMPEG (Default: off)" OFF)
59+
option(ENABLE_MINIAUDIO "Support audio playback using miniaudio (Default: off)" OFF)
60+
option(ENABLE_TOOLS "Build different tools? (Default: off)" OFF)
61+
option(ENABLE_FAST_MATH "Build with unsafe fast-math compiller option (Default: off)" OFF)
62+
option(ENABLE_TESTS "Enable unit tests? (Default: off)" OFF)
63+
option(ENABLE_GLES "Build for OpenGL ES 2.0 instead of OpenGL 2.1 (Default: off)" OFF)
64+
option(ENABLE_LTO "Enable link time optimizations (Default: off)" OFF)
65+
option(ENABLE_RAY_BASED_DRAGGING "Enable the dragging behavior that based on change of pick rays instead of screen coordinates (Default: off)" OFF)
66+
option(USE_GTKGLEXT "Use libgtkglext1 for GTK2 frontend (Default: on)" ON)
67+
option(USE_GTK3 "Use Gtk3 in GTK2 frontend (Default: off)" OFF)
68+
option(USE_WAYLAND "Use Wayland in Qt frontend (Default: off)" OFF)
69+
option(USE_GLSL_STRUCTS "Use structs in GLSL (Default: off)" OFF)
70+
option(USE_ICU "Use ICU for UTF8 decoding for text rendering (Default: off)" OFF)
71+
option(USE_WIN_ICU "Use Windows SDK's ICU implementation (Default: off)" OFF)
72+
option(USE_WEFFCPP "Use the -Weffc++ option when compiling with GCC (Default: off)" OFF)
7273

7374
# Qt requires -fPIC, so build all code with it
7475
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -239,6 +240,10 @@ if(ENABLE_LIBAVIF)
239240
add_definitions(-DUSE_LIBAVIF)
240241
endif()
241242

243+
if (ENABLE_RAY_BASED_DRAGGING)
244+
add_definitions(-DENABLE_RAY_BASED_DRAGGING)
245+
endif()
246+
242247
if(_UNIX)
243248
find_package(PkgConfig)
244249
endif()

src/celestia/celestiacore.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,14 @@ void CelestiaCore::mouseButtonDown(float x, float y, int button)
407407
{
408408
mouseMotion = 0.0f;
409409

410+
#ifdef ENABLE_RAY_BASED_DRAGGING
410411
MouseLocation newLocation;
411412
newLocation.x = x;
412413
newLocation.y = y;
413414
dragLocation = newLocation;
414415

415416
dragStartFromSurface = std::nullopt;
417+
#endif
416418

417419
#ifdef CELX
418420
if (m_script != nullptr)
@@ -436,8 +438,10 @@ void CelestiaCore::mouseButtonDown(float x, float y, int button)
436438

437439
void CelestiaCore::mouseButtonUp(float x, float y, int button)
438440
{
441+
#ifdef ENABLE_RAY_BASED_DRAGGING
439442
dragLocation = std::nullopt;
440443
dragStartFromSurface = std::nullopt;
444+
#endif
441445

442446
// Four pixel tolerance for picking
443447
float obsPickTolerance = sim->getActiveObserver()->getFOV() / static_cast<float>(metrics.height) * this->pickTolerance;
@@ -560,12 +564,14 @@ void CelestiaCore::mouseMove(float x, float y)
560564

561565
void CelestiaCore::mouseMove(float dx, float dy, int modifiers)
562566
{
567+
#ifdef ENABLE_RAY_BASED_DRAGGING
563568
auto oldLocation = dragLocation;
564569
if (dragLocation.has_value())
565570
{
566571
dragLocation.value().x += dx;
567572
dragLocation.value().y += dy;
568573
}
574+
#endif
569575

570576
if (viewManager->resizeViews(metrics, dx, dy))
571577
{
@@ -659,6 +665,7 @@ void CelestiaCore::mouseMove(float dx, float dy, int modifiers)
659665
flash(fmt::sprintf(_("Magnitude limit: %.2f"), sim->getFaintestVisible()));
660666
}
661667
}
668+
#ifdef ENABLE_RAY_BASED_DRAGGING
662669
else if (oldLocation.has_value() && dragLocation.has_value())
663670
{
664671
auto view = viewManager->activeView();
@@ -681,7 +688,7 @@ void CelestiaCore::mouseMove(float dx, float dy, int modifiers)
681688
float coarseness = ComputeRotationCoarseness(*sim);
682689

683690
Quaternionf q = math::XRotation(dy / static_cast<float>(metrics.height) * coarseness) *
684-
math::YRotation(dx / static_cast<float>(metrics.width) * coarseness);
691+
math::YRotation(dx / static_cast<float>(metrics.width) * coarseness);
685692
sim->orbit(q);
686693
}
687694
}
@@ -690,6 +697,30 @@ void CelestiaCore::mouseMove(float dx, float dy, int modifiers)
690697
sim->rotate(Eigen::Quaternionf::FromTwoVectors(oldPickRay, newPickRay));
691698
}
692699
}
700+
#else
701+
else
702+
{
703+
// For a small field of view, rotate the camera more finely
704+
float coarseness = 1.5f;
705+
if ((modifiers & RightButton) == 0)
706+
{
707+
coarseness = math::radToDeg(sim->getActiveObserver()->getFOV()) / 30.0f;
708+
}
709+
else
710+
{
711+
// If right dragging to rotate, adjust the rotation rate
712+
// based on the distance from the reference object.
713+
coarseness = ComputeRotationCoarseness(*sim);
714+
}
715+
716+
Quaternionf q = math::XRotation(dy / static_cast<float>(metrics.height) * coarseness) *
717+
math::YRotation(dx / static_cast<float>(metrics.width) * coarseness);
718+
if ((modifiers & RightButton) != 0)
719+
sim->orbit(q);
720+
else
721+
sim->rotate(q.conjugate());
722+
}
723+
#endif
693724

694725
mouseMotion += abs(dy) + abs(dx);
695726
}

src/celestia/celestiacore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,13 +495,15 @@ class CelestiaCore // : public Watchable<CelestiaCore>
495495

496496
float pickTolerance { 4.0f };
497497

498+
#ifdef ENABLE_RAY_BASED_DRAGGING
498499
struct MouseLocation
499500
{
500501
float x;
501502
float y;
502503
};
503504
std::optional<MouseLocation> dragLocation { std::nullopt };
504505
std::optional<bool> dragStartFromSurface { std::nullopt };
506+
#endif
505507

506508
std::unique_ptr<ViewportEffect> viewportEffect { nullptr };
507509
bool isViewportEffectUsed { false };

0 commit comments

Comments
 (0)