Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assimp update #1627

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
[submodule "rts/lib/cereal"]
path = rts/lib/cereal
url = https://github.com/USCiLab/cereal.git
[submodule "rts/lib/assimp"]
path = rts/lib/assimp
url = https://github.com/recoilengine/assimp
1 change: 0 additions & 1 deletion rts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ make_global_var(engineSources
${sources_engine_System}
${sources_engine_ExternalAI}
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/assimp/include) #FIXME: hack for rts/Rendering/Models/IModelParser.cpp

### Add headers for generated project files (e.g. Code::Blocks)
file(GLOB_RECURSE engineHeaders "*.h" "*.hpp" "*.inl")
Expand Down
2 changes: 1 addition & 1 deletion rts/Game/AviVideoCapturing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "System/SafeUtil.h"
#include "System/StringUtil.h"
#include "System/FileSystem/FileHandler.h"
#include "lib/streflop/streflop_cond.h"
#include <streflop/streflop_cond.h>
#include <SDL_mouse.h>
#include <SDL_events.h>

Expand Down
2 changes: 1 addition & 1 deletion rts/Lua/LuaMathExtra.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#include "lib/streflop/streflop_cond.h"
#include <streflop/streflop_cond.h>
#include "System/SpringMath.h"
#include "LuaMathExtra.h"
#include "LuaInclude.h"
Expand Down
2 changes: 1 addition & 1 deletion rts/Lua/LuaParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <algorithm>
#include <climits>

#include "lib/streflop/streflop_cond.h"
#include <streflop/streflop_cond.h>

#include "System/float3.h"
#include "System/float4.h"
Expand Down
4 changes: 2 additions & 2 deletions rts/Rendering/Models/AssIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#ifndef ASS_IO_H
#define ASS_IO_H

#include "lib/assimp/include/assimp/IOStream.hpp"
#include "lib/assimp/include/assimp/IOSystem.hpp"
#include <assimp/IOStream.hpp>
#include <assimp/IOSystem.hpp>
class CFileHandler;

// Custom implementation of Assimp IOStream to support Spring's VFS
Expand Down
18 changes: 9 additions & 9 deletions rts/Rendering/Models/AssParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include "System/FileSystem/FileHandler.h"
#include "System/FileSystem/FileSystem.h"

#include "lib/assimp/include/assimp/config.h"
#include "lib/assimp/include/assimp/defs.h"
#include "lib/assimp/include/assimp/types.h"
#include "lib/assimp/include/assimp/scene.h"
#include "lib/assimp/include/assimp/postprocess.h"
#include "lib/assimp/include/assimp/Importer.hpp"
#include "lib/assimp/include/assimp/DefaultLogger.hpp"
#include <assimp/config.h>
#include <assimp/defs.h>
#include <assimp/types.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
#include <assimp/DefaultLogger.hpp>

#include <regex>
#include <algorithm>
Expand Down Expand Up @@ -265,8 +265,8 @@ void CAssParser::Load(S3DModel& model, const std::string& modelFilePath)
}

if (modelTable.GetBool("nodenamesfromids", false)) {
assert(FileSystem::GetExtension(modelFilePath) == "dae");
PreProcessFileBuffer(fileBuf);
if (FileSystem::GetExtension(modelFilePath) == "dae");
PreProcessFileBuffer(fileBuf);
}


Expand Down
10 changes: 8 additions & 2 deletions rts/Rendering/Models/IModelParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "System/Threading/ThreadPool.h"
#include "System/ContainerUtil.h"
#include "System/LoadLock.h"
#include "lib/assimp/include/assimp/Importer.hpp"
#include <assimp/Importer.hpp>

#include "System/Misc/TracyDefs.h"

Expand All @@ -36,12 +36,18 @@ static CAssParser gAssParser;


static bool CheckAssimpWhitelist(const char* aiExt) {
constexpr std::array<const char*, 5> whitelist = {
static constexpr std::array whitelist = {
"3ds" , // 3DSMax
"dae" , // Collada
"lwo" , // LightWave
"obj" ,
"blend", // Blender
"gltf" , // GLTF
"glb" , // GLTF (binary)
"usd" , // USD ASCII or binary-encoded
"usda" , // USD ASCII encoded
"usdc" , // USD binary encoded
"usdz" // USD compressed, ASCII or binary-encoded
};

const auto pred = [&aiExt](const char* wlExt) { return (strcmp(aiExt, wlExt) == 0); };
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Path/QTPFS/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <cassert>
#include <limits>

#include "lib/streflop/streflop_cond.h"
#include <streflop/streflop_cond.h>

#include "Node.h"
#include "NodeLayer.h"
Expand Down
2 changes: 1 addition & 1 deletion rts/System/FastMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#endif
#include <cinttypes>

#include "lib/streflop/streflop_cond.h"
#include <streflop/streflop_cond.h>
#include "System/MainDefines.h"
#include "System/MathConstants.h"

Expand Down
2 changes: 1 addition & 1 deletion rts/System/GameLoadThread.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#include "lib/streflop/streflop_cond.h" //! must happen before OffscreenGLContext.h, which includes agl.h
#include <streflop/streflop_cond.h> //! must happen before OffscreenGLContext.h, which includes agl.h
#include "System/GameLoadThread.h"

#include <functional>
Expand Down
2 changes: 1 addition & 1 deletion rts/System/GlobalRNG.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <limits>

#include "lib/streflop/streflop_cond.h"
#include <streflop/streflop_cond.h>
#include "System/float3.h"


Expand Down
3 changes: 1 addition & 2 deletions rts/System/Net/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ add_library(engineSystemNet STATIC
"${CMAKE_CURRENT_SOURCE_DIR}/UDPConnection.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/UDPListener.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/UnpackPacket.cpp"
)

)
2 changes: 1 addition & 1 deletion rts/System/Platform/Win/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#endif

// do not include <cmath> or <math.h> before this, it'll cause ambiguous call er
#include "lib/streflop/streflop_cond.h"
#include <streflop/streflop_cond.h>

#ifdef HEADLESS
// workaround for mingw64 bug which leads to undefined reference to _imp__gl*
Expand Down
2 changes: 1 addition & 1 deletion rts/System/ScopedFPUSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// dedicated is compiled w/o streflop!
#if defined(__SUPPORT_SNAN__) && !defined(DEDICATED) && !defined(UNITSYNC)

#include "lib/streflop/streflop_cond.h"
#include <streflop/streflop_cond.h>

class ScopedDisableFpuExceptions {
public:
Expand Down
2 changes: 1 addition & 1 deletion rts/System/Sync/FPUCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#endif

#include "FPUCheck.h"
#include "lib/streflop/streflop_cond.h"
#include <streflop/streflop_cond.h>
#include "System/Exceptions.h"
#include "System/Threading/ThreadPool.h"
#include "System/Log/ILog.h"
Expand Down
2 changes: 1 addition & 1 deletion rts/System/Sync/SyncedFloat3.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#if defined(SYNCDEBUG) || defined(SYNCCHECK)

#include "lib/streflop/streflop_cond.h"
#include <streflop/streflop_cond.h>
#include "SyncedPrimitive.h"
#include "System/FastMath.h" //SSE (I)SQRT

Expand Down
2 changes: 1 addition & 1 deletion rts/System/float3.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <array>

#include "System/BranchPrediction.h"
#include "lib/streflop/streflop_cond.h"
#include <streflop/streflop_cond.h>
#include "System/creg/creg_cond.h"
#include "System/FastMath.h"
#ifdef _MSC_VER
Expand Down
2 changes: 1 addition & 1 deletion rts/System/type2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#pragma once

#include <array>
#include "lib/streflop/streflop_cond.h"
#include <streflop/streflop_cond.h>
#include "System/BranchPrediction.h"
#include "System/creg/creg_cond.h"
#include "System/FastMath.h"
Expand Down
33 changes: 25 additions & 8 deletions rts/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ADD_SUBDIRECTORY(luasocket)
ADD_SUBDIRECTORY(minizip)
ADD_SUBDIRECTORY(headlessStubs)
if (ENABLE_STREFLOP)
ADD_SUBDIRECTORY(streflop)
ADD_SUBDIRECTORY(streflop)
endif ()

SET(GFLAGS_BUILD_SHARED_LIBS FALSE)
Expand All @@ -29,14 +29,16 @@ ADD_SUBDIRECTORY(gflags)
# sadly still manual changes are needed!

set(DISABLED_ASSIMP_FORMATS "")
foreach(var AMF AC ASE ASSBIN ASSXML B3D BVH DXF CSM HMP IRRMESH IRR LWS MD2 MD3 MD5 MDC MDL MMD NFF NDO OFF OGRE OPENGEX PLY MS3D COB IFC XGL FBX Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D GLTF 3MF)
foreach(var AMF AC ASE ASSBIN ASSXML B3D BVH DXF CSM HMP IRRMESH IRR LWS MD2 MD3 MD5 MDC MDL MMD NFF NDO OFF OGRE OPENGEX PLY MS3D COB IFC XGL FBX Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D 3MF)
list(APPEND DISABLED_ASSIMP_FORMATS "ASSIMP_BUILD_${var}_IMPORTER")
endforeach()

set(ENABLED_ASSIMP_FORMATS "")
foreach(var 3DS COLLADA LWO OBJ BLEND)
foreach(var 3DS COLLADA LWO OBJ BLEND GLTF USD)
list(APPEND ENABLED_ASSIMP_FORMATS "ASSIMP_BUILD_${var}_IMPORTER")
endforeach()


foreach(var
${DISABLED_ASSIMP_FORMATS}
BUILD_SHARED_LIBS
Expand All @@ -47,23 +49,38 @@ foreach(var
ASSIMP_BUILD_ASSIMP_TOOLS
ASSIMP_BUILD_NONFREE_C4D_IMPORTER
ASSIMP_DOUBLE_PRECISION
ASSIMP_INSTALL
ASSIMP_INJECT_DEBUG_POSTFIX # handle https://github.com/beyond-all-reason/spring/commit/479b42e61a9ee8d5bc8b5a3d772708276c5900e5
)
set("${var}" OFF CACHE STRING "forced off by spring build env" FORCE)
set("${var}" OFF CACHE STRING "forced off by Recoil build env" FORCE)
endforeach()

foreach(var
${ENABLED_ASSIMP_FORMATS}
)
set("${var}" ON CACHE STRING "forced on by spring build env" FORCE)
set("${var}" ON CACHE STRING "forced on by Recoil build env" FORCE)
endforeach()

foreach(var ASSIMP_BUILD_STATIC_LIB ASSIMP_NO_EXPORT)
message(STATUS "Forcing assimp option ${var} to on")
set("${var}" ON CACHE STRING "forced on by spring build env" FORCE)
set("${var}" ON CACHE STRING "forced on by Recoil build env" FORCE)
endforeach()

FIND_PACKAGE(ZLIB)
IF (NOT ZLIB_FOUND)
set("ASSIMP_BUILD_ZLIB" ON CACHE BOOL "forced on by Recoil build env" FORCE)
endif()


set(CMAKE_CXX_FLAGS_ORIG ${CMAKE_CXX_FLAGS})
if (CMAKE_COMPILER_IS_GNUCXX)
# Assimp cannot be compiled with "-fsingle-precision-constant"
string(REPLACE "-fsingle-precision-constant" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
endif(CMAKE_COMPILER_IS_GNUCXX)

ADD_SUBDIRECTORY(assimp)
target_compile_definitions(assimp PRIVATE -DASSIMP_BUILD_NO_OWN_ZLIB)

set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_ORIG})

ADD_SUBDIRECTORY(squish)
ADD_SUBDIRECTORY(rg-etc1)
Expand All @@ -79,4 +96,4 @@ option(TRACY_ON_DEMAND "Enable tracy profiling" ON)
# raw malloc have to be used with care.
option(TRACY_PROFILE_MEMORY "Profile memory allocations" OFF)

add_subdirectory(tracy)
ADD_SUBDIRECTORY(tracy)
1 change: 1 addition & 0 deletions rts/lib/assimp
Submodule assimp added at 3fd255
76 changes: 0 additions & 76 deletions rts/lib/assimp/.gitignore

This file was deleted.

Loading