mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Make meshoptim optional
This commit is contained in:
@@ -26,7 +26,6 @@ set(QT_VERSION 6 CACHE STRING "Qt version")
|
|||||||
find_package(Qt${QT_VERSION} COMPONENTS Core Gui Widgets OpenGL REQUIRED PATHS ${QT_DIR})
|
find_package(Qt${QT_VERSION} COMPONENTS Core Gui Widgets OpenGL REQUIRED PATHS ${QT_DIR})
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
find_package(meshoptimizer REQUIRED)
|
|
||||||
|
|
||||||
file(GLOB IFCVIEWER_CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
file(GLOB IFCVIEWER_CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||||
file(GLOB IFCVIEWER_H_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
|
file(GLOB IFCVIEWER_H_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
|
||||||
@@ -40,6 +39,12 @@ set_target_properties(IfcViewer PROPERTIES
|
|||||||
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
|
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (WITH_MESH_OPTIMIZER)
|
||||||
|
find_package(meshoptimizer REQUIRED)
|
||||||
|
set(MESH_OPTIMIZER_LIB meshoptimizer::meshoptimizer)
|
||||||
|
target_compile_definitions(IfcViewer PUBLIC -DWITH_MESH_OPTIMIZER)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Consumers include headers as `#include "ViewportWindow.h"`, so expose this
|
# Consumers include headers as `#include "ViewportWindow.h"`, so expose this
|
||||||
# directory on the public interface.
|
# directory on the public interface.
|
||||||
target_include_directories(IfcViewer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(IfcViewer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
@@ -57,7 +62,7 @@ target_link_libraries(IfcViewer PUBLIC
|
|||||||
Qt${QT_VERSION}::Widgets
|
Qt${QT_VERSION}::Widgets
|
||||||
Qt${QT_VERSION}::OpenGL
|
Qt${QT_VERSION}::OpenGL
|
||||||
OpenGL::GL
|
OpenGL::GL
|
||||||
meshoptimizer::meshoptimizer
|
${MESH_OPTIMIZER_LIB}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
|
|
||||||
#include "LodBuilder.h"
|
#include "LodBuilder.h"
|
||||||
|
|
||||||
|
#ifdef WITH_MESH_OPTIMIZER
|
||||||
#include <meshoptimizer.h>
|
#include <meshoptimizer.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@@ -31,6 +33,13 @@ void buildLods(SidecarData& sd,
|
|||||||
int min_triangles,
|
int min_triangles,
|
||||||
float target_ratio,
|
float target_ratio,
|
||||||
float target_error) {
|
float target_error) {
|
||||||
|
#ifndef WITH_MESH_OPTIMIZER
|
||||||
|
(void)sd;
|
||||||
|
(void)min_triangles;
|
||||||
|
(void)target_ratio;
|
||||||
|
(void)target_error;
|
||||||
|
return;
|
||||||
|
#else
|
||||||
if (sd.meshes.empty() || sd.vertices.empty() || sd.indices.empty()) return;
|
if (sd.meshes.empty() || sd.vertices.empty() || sd.indices.empty()) return;
|
||||||
|
|
||||||
const size_t vtx_stride_bytes = INSTANCED_VERTEX_STRIDE_BYTES;
|
const size_t vtx_stride_bytes = INSTANCED_VERTEX_STRIDE_BYTES;
|
||||||
@@ -165,6 +174,7 @@ void buildLods(SidecarData& sd,
|
|||||||
dbg_accepted, dbg_rejected_noreduce, dbg_rejected_savings,
|
dbg_accepted, dbg_rejected_noreduce, dbg_rejected_savings,
|
||||||
target_error, target_ratio, min_savings);
|
target_error, target_ratio, min_savings);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
LodStats summariseLods(const SidecarData& sd) {
|
LodStats summariseLods(const SidecarData& sd) {
|
||||||
|
|||||||
Reference in New Issue
Block a user