From 32e81a037b514020ce2fba163f97189b5b0b2955 Mon Sep 17 00:00:00 2001 From: Vsevolod Kremianskii Date: Mon, 8 Mar 2021 14:45:59 +0700 Subject: [PATCH] build: Make libvideo non-optional --- CMakeLists.txt | 25 +++++-------------------- src/scene/scenegraph.cpp | 20 +------------------- src/video/bikfile.cpp | 10 ---------- 3 files changed, 6 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25d3f908..1e2c141f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,6 @@ add_subdirectory(external/s3tc) option(BUILD_TOOLS "build tools executable" ON) option(BUILD_TESTS "build unit tests" OFF) -option(ENABLE_VIDEO "enable video playback" ON) option(USE_EXTERNAL_GLM "use GLM library from external subdirectory" ON) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) @@ -33,23 +32,16 @@ find_package(MAD REQUIRED) if(WIN32) find_package(OpenAL CONFIG REQUIRED) find_package(SDL2 CONFIG REQUIRED) + find_package(FFMPEG REQUIRED) else() find_package(PkgConfig REQUIRED) pkg_check_modules(OpenAL REQUIRED openal) pkg_check_modules(SDL2 REQUIRED sdl2) + pkg_check_modules(FFMPEG REQUIRED libavcodec libavformat libavutil libswresample libswscale) find_package(Threads REQUIRED) endif() -include_directories(${Boost_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS} ${MAD_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/external/libtga ${CMAKE_SOURCE_DIR}/external/s3tc) - -if(ENABLE_VIDEO) - if(WIN32) - find_package(FFMPEG REQUIRED) - else() - pkg_check_modules(FFMPEG REQUIRED libavcodec libavformat libavutil libswresample libswscale) - endif() - include_directories(${FFMPEG_INCLUDE_DIRS}) -endif() +include_directories(${Boost_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS} ${MAD_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/external/libtga ${CMAKE_SOURCE_DIR}/external/s3tc) if(USE_EXTERNAL_GLM) include_directories(${CMAKE_SOURCE_DIR}/external/glm) @@ -275,10 +267,6 @@ set(VIDEO_SOURCES add_library(libvideo STATIC ${VIDEO_HEADERS} ${VIDEO_SOURCES}) set_target_properties(libvideo PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -if(ENABLE_VIDEO) - target_compile_definitions(libvideo PRIVATE -DREONE_ENABLE_VIDEO) -endif() - ## END libvideo static library ## libscene static library @@ -676,11 +664,8 @@ target_link_libraries(reone PRIVATE ${Boost_FILESYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SYSTEM_LIBRARY} GLEW::GLEW ${OPENGL_LIBRARIES} - ${MAD_LIBRARY}) - -if(ENABLE_VIDEO) - target_link_libraries(reone PRIVATE ${FFMPEG_LIBRARIES}) -endif() + ${MAD_LIBRARY} + ${FFMPEG_LIBRARIES}) if(WIN32) target_link_libraries(reone PRIVATE SDL2::SDL2 OpenAL::OpenAL) diff --git a/src/scene/scenegraph.cpp b/src/scene/scenegraph.cpp index 3c45723f..b0a10303 100644 --- a/src/scene/scenegraph.cpp +++ b/src/scene/scenegraph.cpp @@ -85,24 +85,6 @@ void SceneGraph::prepareFrame() { return leftDistance > rightDistance; }); - - // Sort emitters by render order and distance to camera - unordered_map emitterToCamera; - for (auto &emitter : _emitters) { - emitterToCamera.insert(make_pair(emitter, emitter->getDistanceTo(cameraPosition))); - } - sort(_emitters.begin(), _emitters.end(), [&emitterToCamera](auto &left, auto &right) { - int leftRenderOrder = left->emitter()->renderOrder(); - int rightRenderOrder = right->emitter()->renderOrder(); - - if (leftRenderOrder > rightRenderOrder) return true; - if (leftRenderOrder < rightRenderOrder) return false; - - float leftDistance = emitterToCamera.find(left)->second; - float rightDistance = emitterToCamera.find(right)->second; - - return leftDistance > rightDistance; - }); } void SceneGraph::refreshNodeLists() { @@ -238,7 +220,7 @@ void SceneGraph::render(bool shadowPass) { mesh->renderSingle(false); } - // Render emitter particles + // Render particles for (auto &emitter : _emitters) { emitter->renderSingle(false); } diff --git a/src/video/bikfile.cpp b/src/video/bikfile.cpp index 663d2b35..0941ceb4 100644 --- a/src/video/bikfile.cpp +++ b/src/video/bikfile.cpp @@ -27,8 +27,6 @@ #include "video.h" -#if REONE_ENABLE_VIDEO - extern "C" { #include "libavformat/avformat.h" @@ -37,8 +35,6 @@ extern "C" { } -#endif - namespace fs = boost::filesystem; using namespace std; @@ -51,8 +47,6 @@ namespace video { static const char kSignature[] = "BIKi"; -#if REONE_ENABLE_VIDEO - class BinkVideoDecoder : public MediaStream { public: BinkVideoDecoder(const fs::path &path) : _path(path) { @@ -318,13 +312,10 @@ private: } }; -#endif - BikFile::BikFile(const fs::path &path) : _path(path) { } void BikFile::load() { -#if REONE_ENABLE_VIDEO if (!fs::exists(_path)) { throw runtime_error("BIK: file not found: " + _path.string()); } @@ -335,7 +326,6 @@ void BikFile::load() { _video = decoder->video(); _video->setMediaStream(decoder); _video->init(); -#endif // REONE_ENABLE_VIDEO } } // namespace video