Merge remote-tracking branch 'origin/master' into qbsp-use-common

This commit is contained in:
Eric Wasylishen 2021-09-12 23:04:42 -06:00
commit d2ea0cee41
14 changed files with 125 additions and 70 deletions

32
.github/workflows/cmake.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: CMake
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# Don't cancel the macOS build if the Linux build fails, etc.
fail-fast: false
matrix:
os: [ubuntu-18.04, macos-10.15]
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Linux Build
if: runner.os == 'Linux'
run: |
sudo apt install -y groff
./build-linux-64.sh
- name: macOS Build
if: runner.os == 'macOS'
run: |
./build-osx.sh

View File

@ -593,11 +593,12 @@ main(int argc, char **argv)
WriteBSPFile(source, &bspdata); WriteBSPFile(source, &bspdata);
} else if (!strcmp(argv[i], "--extract-entities")) { } else if (!strcmp(argv[i], "--extract-entities")) {
unsigned int crc = CRC_Block((unsigned char *)bsp->dentdata, bsp->entdatasize - 1);
StripExtension(source); StripExtension(source);
DefaultExtension(source, ".ent"); DefaultExtension(source, ".ent");
printf("-> writing %s... ", source); printf("-> writing %s [CRC: %04x]... ", source, crc);
f = fopen(source, "w"); f = fopen(source, "wb");
if (!f) if (!f)
Error("couldn't open %s for writing\n", source); Error("couldn't open %s for writing\n", source);

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
BUILD_DIR=build BUILD_DIR=build-linux
if [ -d "$BUILD_DIR" ]; then if [ -d "$BUILD_DIR" ]; then
echo "$BUILD_DIR already exists, remove it first" echo "$BUILD_DIR already exists, remove it first"
@ -11,15 +11,20 @@ cmake --version
mkdir "$BUILD_DIR" mkdir "$BUILD_DIR"
cd "$BUILD_DIR" cd "$BUILD_DIR"
wget https://github.com/embree/embree/releases/download/v2.17.7/embree-2.17.7.x86_64.linux.tar.gz -O embree.tgz wget -q https://github.com/embree/embree/releases/download/v3.13.1/embree-3.13.1.x86_64.linux.tar.gz -O embree.tgz
wget https://github.com/intel/tbb/releases/download/2017_U7/tbb2017_20170604oss_lin.tgz -O tbb.tgz wget -q https://github.com/oneapi-src/oneTBB/releases/download/v2021.3.0/oneapi-tbb-2021.3.0-lin.tgz -O tbb.tgz
tar xf embree.tgz tar xf embree.tgz
tar xf tbb.tgz tar xf tbb.tgz
cmake .. -DCMAKE_BUILD_TYPE=Release -Dembree_DIR="$(pwd)/embree-2.17.7.x86_64.linux" -DTBB_DIR="$(pwd)/tbb2017_20170604oss/cmake"
make -j8 VERBOSE=1 EMBREE_CMAKE_DIR="$(pwd)/embree-3.13.1.x86_64.linux/lib/cmake/embree-3.13.1"
make -j8 VERBOSE=1 testlight TBB_CMAKE_DIR="$(pwd)/oneapi-tbb-2021.3.0/lib/cmake"
make -j8 VERBOSE=1 testqbsp
cpack cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR"
make -j8 VERBOSE=1 || exit 1
make -j8 VERBOSE=1 testlight || exit 1
make -j8 VERBOSE=1 testqbsp || exit 1
cpack || exit 1
# run tests # run tests
./light/testlight || exit 1 ./light/testlight || exit 1

View File

@ -1,14 +1,17 @@
#!/bin/bash #!/bin/bash
BUILD_DIR=build-osx BUILD_DIR=build-osx
EMBREE_TGZ="https://github.com/embree/embree/releases/download/v2.17.7/embree-2.17.7.x86_64.macosx.tar.gz" EMBREE_ZIP="https://github.com/embree/embree/releases/download/v3.13.0/embree-3.13.0.x86_64.macosx.zip"
EMBREE_TGZ_NAME=$(basename "$EMBREE_TGZ")
EMBREE_DIR_NAME=$(basename "$EMBREE_TGZ" ".tar.gz")
EMBREE_WITH_VERSION=$(basename "$EMBREE_TGZ" ".x86_64.macosx.tar.gz")
TBB_TGZ="https://github.com/intel/tbb/releases/download/2017_U7/tbb2017_20170604oss_mac.tgz" # embree-3.13.1.x86_64.macosx.zip
EMBREE_ZIP_NAME=$(basename "$EMBREE_ZIP")
# embree-3.13.1.x86_64.macosx
EMBREE_DIR_NAME=$(basename "$EMBREE_ZIP_NAME" ".zip")
TBB_TGZ="https://github.com/oneapi-src/oneTBB/releases/download/v2021.2.0/oneapi-tbb-2021.2.0-mac.tgz"
TBB_TGZ_NAME=$(basename "$TBB_TGZ") TBB_TGZ_NAME=$(basename "$TBB_TGZ")
TBB_DIR_NAME="tbb2017_20170604oss" TBB_DIR_NAME="oneapi-tbb-2021.2.0"
if [ -d "$BUILD_DIR" ]; then if [ -d "$BUILD_DIR" ]; then
echo "$BUILD_DIR already exists, remove it first" echo "$BUILD_DIR already exists, remove it first"
@ -17,18 +20,27 @@ fi
mkdir "$BUILD_DIR" mkdir "$BUILD_DIR"
cd "$BUILD_DIR" cd "$BUILD_DIR"
wget "$EMBREE_TGZ"
wget "$TBB_TGZ" wget -q "$EMBREE_ZIP"
tar xf "$EMBREE_TGZ_NAME" unzip -q "$EMBREE_ZIP_NAME"
wget -q "$TBB_TGZ"
tar xf "$TBB_TGZ_NAME" tar xf "$TBB_TGZ_NAME"
EMBREE_CMAKE_DIR="$(pwd)/$EMBREE_DIR_NAME" EMBREE_CMAKE_DIR="$(pwd)/$EMBREE_DIR_NAME/lib/cmake/embree-3.13.0"
TBB_CMAKE_DIR="$(pwd)/${TBB_DIR_NAME}/cmake" TBB_CMAKE_DIR="$(pwd)/${TBB_DIR_NAME}/lib/cmake"
cmake .. -DCMAKE_BUILD_TYPE=Release -Dembree_DIR="$EMBREE_CMAKE_DIR" -DTBB_DIR="$TBB_CMAKE_DIR" cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR"
make -j8 make -j8 || exit 1
make -j8 testlight make -j8 testlight || exit 1
make -j8 testqbsp make -j8 testqbsp || exit 1
cpack cpack || exit 1
# print shared libraries used
otool -L ./light/light
otool -L ./qbsp/qbsp
otool -L ./vis/vis
otool -L ./bspinfo/bspinfo
otool -L ./bsputil/bsputil
# run tests # run tests
./light/testlight || exit 1 ./light/testlight || exit 1

View File

@ -22,6 +22,7 @@
#include <common/bspfile.hh> #include <common/bspfile.hh>
#include <cstdint> #include <cstdint>
#include <limits.h>
/* hexen2, quake2 */ /* hexen2, quake2 */
const bspversion_t bspver_generic { NO_VERSION, NO_VERSION, "mbsp", "generic BSP", false, false }; const bspversion_t bspver_generic { NO_VERSION, NO_VERSION, "mbsp", "generic BSP", false, false };
@ -3927,4 +3928,4 @@ DecompressRow (const uint8_t *in, const int numbytes, uint8_t *decompressed)
c--; c--;
} }
} while (out - decompressed < row); } while (out - decompressed < row);
} }

View File

@ -1116,6 +1116,15 @@ CRC_Value(unsigned short crcvalue)
return crcvalue ^ CRC_XOR_VALUE; return crcvalue ^ CRC_XOR_VALUE;
} }
unsigned short CRC_Block (const unsigned char *start, int count)
{
unsigned short crc;
CRC_Init (&crc);
while (count--)
crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++];
return crc;
}
/* ========================================================================= */ /* ========================================================================= */
/* /*

View File

@ -125,6 +125,7 @@ char *copystring(const char *s);
void CRC_Init(unsigned short *crcvalue); void CRC_Init(unsigned short *crcvalue);
void CRC_ProcessByte(unsigned short *crcvalue, uint8_t data); void CRC_ProcessByte(unsigned short *crcvalue, uint8_t data);
unsigned short CRC_Value(unsigned short crcvalue); unsigned short CRC_Value(unsigned short crcvalue);
unsigned short CRC_Block (const unsigned char *start, int count);
void CreatePath(char *path); void CreatePath(char *path);
void Q_CopyFile(const char *from, char *to); void Q_CopyFile(const char *from, char *to);

View File

@ -60,57 +60,44 @@ target_link_libraries (light PRIVATE ${CMAKE_THREAD_LIBS_INIT})
if (embree_FOUND) if (embree_FOUND)
target_link_libraries (light PRIVATE embree) target_link_libraries (light PRIVATE embree)
add_definitions(-DHAVE_EMBREE) add_definitions(-DHAVE_EMBREE)
find_file(EMBREE_LICENSE LICENSE.txt find_file(EMBREE_LICENSE LICENSE.txt
"${embree_DIR}/doc" "${embree_DIR}/doc"
"${embree_DIR}/../../../doc"
"${embree_DIR}/../embree3/embree3" # vcpkg puts it here "${embree_DIR}/../embree3/embree3" # vcpkg puts it here
"${embree_DIR}/../../.." # homebrew puts it here
NO_DEFAULT_PATH) NO_DEFAULT_PATH)
if (EMBREE_LICENSE STREQUAL EMBREE_LICENSE-NOTFOUND) if (EMBREE_LICENSE STREQUAL EMBREE_LICENSE-NOTFOUND)
message(WARNING "Couldn't find embree license") message(WARNING "Couldn't find embree license. embree_DIR is ${embree_DIR}")
else() else()
message(STATUS "Found embree license: ${EMBREE_LICENSE}") message(STATUS "Found embree license: ${EMBREE_LICENSE}")
endif() endif()
if(WIN32) add_custom_command(TARGET light POST_BUILD
file(GLOB EMBREE_DLLS "${embree_DIR}/bin/*.dll") COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:embree>" "$<TARGET_FILE_DIR:light>"
foreach(EMBREE_DLL ${EMBREE_DLLS}) COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:light>"
add_custom_command(TARGET light POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${EMBREE_DLL} $<TARGET_FILE_DIR:light>) COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EMBREE_LICENSE}" "$<TARGET_FILE_DIR:light>/LICENSE-embree.txt")
endforeach(EMBREE_DLL)
add_custom_command(TARGET light POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${EMBREE_LICENSE} $<TARGET_FILE_DIR:light>/LICENSE-embree.txt)
install(FILES ${EMBREE_DLLS} DESTINATION bin) # so the executable will search for dylib's in the same directory as the executable
if(APPLE)
add_custom_command(TARGET light POST_BUILD
COMMAND bash ARGS -c \"install_name_tool -add_rpath @loader_path $<TARGET_FILE:light> || true\")
endif() endif()
install(FILES $<TARGET_FILE:embree> DESTINATION bin)
# install TBB
if(UNIX) if(UNIX)
if (APPLE) # HACK: preferred method is installing the symlink instead of the actual .so
set(SHARED_LIB_EXT dylib) get_target_property(TBB_SO_FILE_SYMLINK TBB::tbb IMPORTED_LOCATION_RELEASE)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") get_filename_component(TBB_SO_FILE "${TBB_SO_FILE_SYMLINK}" REALPATH)
set(SHARED_LIB_EXT "so.*")
else ()
message(FATAL_ERROR "only Linux and macOS currently supported")
endif()
message(STATUS "TBB .so file: ${TBB_SO_FILE}")
file(GLOB EMBREE_DYLIBS_WITH_SYMLINKS "${embree_DIR}/lib/*.${SHARED_LIB_EXT}") install(FILES ${TBB_SO_FILE} DESTINATION bin)
else()
# Gather all .dylib's that are not symlinks # preferred method
foreach(EMBREE_DYLIB ${EMBREE_DYLIBS_WITH_SYMLINKS}) install(FILES $<TARGET_FILE:TBB::tbb> DESTINATION bin)
if(NOT IS_SYMLINK ${EMBREE_DYLIB})
list(APPEND EMBREE_DYLIBS ${EMBREE_DYLIB})
endif()
endforeach()
foreach(EMBREE_DYLIB ${EMBREE_DYLIBS})
message(STATUS "Copying dylib: ${EMBREE_DYLIB}")
add_custom_command(TARGET light POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${EMBREE_DYLIB} $<TARGET_FILE_DIR:light>)
endforeach()
# so the executable will search for dylib's in the same directory as the executable
if(APPLE)
add_custom_command(TARGET light POST_BUILD COMMAND bash ARGS -c \"install_name_tool -add_rpath @loader_path $<TARGET_FILE:light> || true\")
endif()
install(FILES ${EMBREE_DYLIBS} DESTINATION bin)
endif() endif()
install(FILES ${EMBREE_LICENSE} DESTINATION bin RENAME LICENSE-embree.txt) install(FILES ${EMBREE_LICENSE} DESTINATION bin RENAME LICENSE-embree.txt)

View File

@ -1,4 +1,3 @@
cmake_minimum_required (VERSION 3.0)
project (lightpreview CXX) project (lightpreview CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)

View File

@ -1,4 +1,3 @@
cmake_minimum_required (VERSION 2.8)
project (man) project (man)
find_program (GROFF groff) find_program (GROFF groff)

View File

@ -945,7 +945,7 @@ brush_t *LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, int conte
facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum); facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum);
} }
else if (hullnum == 3) { else if (hullnum == 3) {
vec3_t size[2] = { {-16, -16, -12}, {16, 16, 16} }; vec3_t size[2] = { {-16, -16, -16}, {16, 16, 12} };
ExpandBrush(&hullbrush, size, facelist); ExpandBrush(&hullbrush, size, facelist);
FreeBrushFaces(facelist); FreeBrushFaces(facelist);
facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum); facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum);
@ -967,10 +967,20 @@ brush_t *LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, int conte
} }
} }
else if (hullnum == 5) { else if (hullnum == 5) {
#if 0
if (options.hexen2 == 1) { /*original game*/
vec3_t size[2] = { {-48, -48, -50}, {48, 48, 50} }; vec3_t size[2] = { {-48, -48, -50}, {48, 48, 50} };
ExpandBrush(&hullbrush, size, facelist); ExpandBrush(&hullbrush, size, facelist);
FreeBrushFaces(facelist); FreeBrushFaces(facelist);
facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum); facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum);
} else
#endif
{
vec3_t size[2] = { {-28, -28, -40}, {28, 28, 40} };
ExpandBrush(&hullbrush, size, facelist);
FreeBrushFaces(facelist);
facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum);
}
} }
} }
else else

View File

@ -2,6 +2,6 @@
set -x set -x
qbsp invalid_texture_axes.map || exit 1 qbsp -noverbose invalid_texture_axes.map || exit 1
light invalid_texture_axes.map || exit 1 light invalid_texture_axes.map || exit 1

View File

@ -3,6 +3,6 @@
set -x set -x
for file in *.map; do for file in *.map; do
qbsp -leaktest "$file" || exit 1 qbsp -leaktest -noverbose "$file" || exit 1
done done

View File

@ -1,4 +1,3 @@
cmake_minimum_required (VERSION 2.8)
project (vis CXX) project (vis CXX)
set(VIS_INCLUDES set(VIS_INCLUDES