From 35024695ee386c78f6a1b9f299329e7d7dd75343 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Wed, 16 Aug 2023 00:42:01 +0200 Subject: [PATCH] plugins: chose Radiant IQM plugin, iqmmodel for macOS, picomodel for everything else The picomodel IQM code makes NetRadiant crash on macOS. No one has found time to investigate this in month. We need a working NetRadiant IQM plugin to load Unvanquished game entity models on macOS, the plugin from AAradiant (AlienArena project) is known to work. Q3map2 uses picomodel to load IQM on all platforms because iqmmodel plugin is radiant-only, so there may be a remaining bug when baking IQM models in BSP with q3map2 on macOS (not tested), but editing a map with IQM entity models and misc_animated_models will not crash NetRadiant. This patch makes possible to release a macOS NetRadiant build that don't crash when rendering IQM models. We should fix picomodel crash with IQM on macOS in any way, because it is believed q3map2 may need it, but waiting for a picomodel fix will not delay any NetRadiant release. One can force NetRadiant to be built against a given IQM plugin (for example to debug it) whatever the platform by setting the RADIANT_IQM_PLUGIN CMake variable to either `iqmmodel` or `picomodel`. Any other value, including empty string, will set the default plugin for the platform. --- CMakeLists.txt | 16 ++++++++++++++++ libs/picomodel/CMakeLists.txt | 6 +++++- libs/picomodel/picomodules.c | 4 ++++ plugins/CMakeLists.txt | 9 ++++++++- radiant/console.cpp | 1 + 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 839813ea..e5cd0544 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -267,6 +267,22 @@ if (BUILD_RADIANT) add_definitions(-DWORKAROUND_MACOS_GTK2_LAGGYPOINTER=1) endif () endif() + + # Should be set here because the define is used in libs/ + set(RADIANT_IQM_PLUGIN_HELP "IQM Plugin used by NetRadiant (iqmmodel, picomodel)") + set(RADIANT_IQM_PLUGIN "" CACHE STRING "${RADIANT_IQM_PLUGIN_HELP}") + if("${RADIANT_IQM_PLUGIN}" STREQUAL "iqmmodel") + elseif("${RADIANT_IQM_PLUGIN}" STREQUAL "picomodel") + else() + if(APPLE) + # The picomodel iqm library is buggy on recent macOS + set(RADIANT_IQM_PLUGIN "iqmmodel" CACHE STRING "${RADIANT_IQM_PLUGIN_HELP}" FORCE) + else() + set(RADIANT_IQM_PLUGIN "picomodel" CACHE STRING "${RADIANT_IQM_PLUGIN_HELP}" FORCE) + endif() + endif() + add_definitions(-DRADIANT_IQM_PLUGIN_${RADIANT_IQM_PLUGIN}=1) + add_definitions(-DRADIANT_IQM_PLUGIN="${RADIANT_IQM_PLUGIN}") endif () #----------------------------------------------------------------------- diff --git a/libs/picomodel/CMakeLists.txt b/libs/picomodel/CMakeLists.txt index 2e0b9677..6e0ab120 100644 --- a/libs/picomodel/CMakeLists.txt +++ b/libs/picomodel/CMakeLists.txt @@ -1,3 +1,7 @@ +if("${RADIANT_IQM_PLUGIN}" STREQUAL "picomodel") + set(PICO_IQM_FILE "pm_iqm.c") +endif() + add_library(picomodel STATIC lwo/clip.c lwo/envelope.c @@ -16,7 +20,7 @@ add_library(picomodel STATIC pm_3ds.c pm_ase.c pm_fm.c pm_fm.h - pm_iqm.c + ${PICO_IQM_FILE} pm_lwo.c pm_md2.c pm_md3.c diff --git a/libs/picomodel/picomodules.c b/libs/picomodel/picomodules.c index 406ee16f..9a2278f2 100644 --- a/libs/picomodel/picomodules.c +++ b/libs/picomodel/picomodules.c @@ -48,7 +48,9 @@ extern const picoModule_t picoModuleMD2; extern const picoModule_t picoModuleFM; extern const picoModule_t picoModuleLWO; extern const picoModule_t picoModuleTerrain; +#if defined(RADIANT_IQM_PLUGIN_picomodel) extern const picoModule_t picoModuleIQM; +#endif // defined(RADIANT_IQM_PLUGIN_picomodel) @@ -65,7 +67,9 @@ const picoModule_t *picoModules[] = &picoModuleLWO, /* lightwave object */ &picoModuleTerrain, /* picoterrain object */ &picoModuleOBJ, /* wavefront object */ +#if defined(RADIANT_IQM_PLUGIN_picomodel) &picoModuleIQM, /* interquake model */ +#endif // defined(RADIANT_IQM_PLUGIN_picomodel) NULL /* arnold */ }; diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 8db4b7fa..db306aeb 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -26,10 +26,17 @@ add_subdirectory(imagehl) add_subdirectory(imagepng) add_subdirectory(imageq2) add_subdirectory(imagewebp) -add_subdirectory(iqmmodel) + +if("${RADIANT_IQM_PLUGIN}" STREQUAL "iqmmodel") + add_subdirectory(iqmmodel) +endif() + add_subdirectory(mapq3) add_subdirectory(mapxml) add_subdirectory(md3model) + +# picomodel: md3, obj, ase, (optional) iqm add_subdirectory(model) + add_subdirectory(shaders) add_subdirectory(vfspk3) diff --git a/radiant/console.cpp b/radiant/console.cpp index 489f8d61..214bbea7 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -72,6 +72,7 @@ void Sys_EnableLogFile( bool enable ){ time( &localtime ); globalOutputStream() << "Today is: " << ctime( &localtime ) << "This is " RADIANT_NAME " " RADIANT_VERSION " compiled " __DATE__ "\n" RADIANT_ABOUTMSG "\n"; + globalOutputStream() << "IQM plugin: " RADIANT_IQM_PLUGIN "\n"; } else{ ui::alert( ui::root, "Failed to create log file, check write permissions in " RADIANT_NAME " directory.\n", -- 2.39.2