Skip to content

Commit

Permalink
Merge pull request #263 from afritz1/jolt-integration
Browse files Browse the repository at this point in the history
Jolt Physics integration
  • Loading branch information
afritz1 authored Nov 13, 2024
2 parents e2baf89 + 244c095 commit 67c3259
Show file tree
Hide file tree
Showing 376 changed files with 4,743 additions and 6,656 deletions.
Empty file added .gitmodules
Empty file.
26 changes: 24 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.16.0)
CMAKE_MINIMUM_REQUIRED(VERSION 3.18.0 FATAL_ERROR)

IF (COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
cmake_policy(SET CMP0003 NEW) # Relative linker paths for more portability
ENDIF (COMMAND cmake_policy)

PROJECT(OpenTESArena)

include(FetchContent)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")

# Set global C++ standard for all targets.
Expand All @@ -27,9 +29,15 @@ SET(CMAKE_EXE_LINKER_FLAGS_RELEASENATIVE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")

# Compiler settings (optimizations, debugging, etc.)
IF (MSVC)
# Statically link runtime lib via /MT or /MTd.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

# Multi-processor compilation.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")

# Disable runtime type info.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")

# Add various optimizations to release builds.
SET(CMAKE_CXX_FLAGS_RELEASEGENERICNOLTO "/O2 /Ob2 /Oi /Ot /Oy /fp:fast /Zi")
SET(CMAKE_CXX_FLAGS_RELEASEGENERIC "${CMAKE_CXX_FLAGS_RELEASEGENERICNOLTO} /GL")
Expand All @@ -45,6 +53,9 @@ ELSEIF (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") # GCC
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lpthread -pthread")
ENDIF ()

# Disable runtime type info (avoids linker error w/ Jolt DebugRendererSimple).
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")

# Debug builds.
SET(CMAKE_CXX_FLAGS_DEBUG "-g")

Expand All @@ -63,5 +74,16 @@ ELSEIF (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") # GCC
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
ENDIF ()

ADD_COMPILE_DEFINITIONS(JPH_NO_FORCE_INLINE) # Fix __forceinline compile error in LTO builds.
ADD_COMPILE_DEFINITIONS(JPH_DEBUG_RENDERER) # Enable Jolt Physics debug rendering in all builds.

# Include Jolt
FetchContent_Declare(
JoltPhysics
GIT_REPOSITORY "https://github.com/jrouwe/JoltPhysics"
GIT_TAG cede24d2733a4a473c6d486650ca9b6d0481681a # 5.1.0
SOURCE_SUBDIR "Build")
FetchContent_MakeAvailable(JoltPhysics)

ADD_SUBDIRECTORY(components)
ADD_SUBDIRECTORY(OpenTESArena)
105 changes: 29 additions & 76 deletions OpenTESArena/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FIND_PACKAGE(OpenAL REQUIRED)
FIND_PACKAGE(WildMidi)

SET(EXTERNAL_LIBS ${OPENAL_LIBRARY} ${SDL2_LIBRARY})
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}" ${SDL2_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR})
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}" ${SDL2_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR} ${JOLT_INCLUDE_DIR})
IF(WILDMIDI_FOUND)
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${WILDMIDI_LIBRARIES})
INCLUDE_DIRECTORIES(${WILDMIDI_INCLUDE_DIRS})
Expand Down Expand Up @@ -115,10 +115,16 @@ SET(TES_COLLISION
"${SRC_ROOT}/Collision/CollisionChunk.h"
"${SRC_ROOT}/Collision/CollisionChunkManager.cpp"
"${SRC_ROOT}/Collision/CollisionChunkManager.h"
"${SRC_ROOT}/Collision/CollisionMeshDefinition.cpp"
"${SRC_ROOT}/Collision/CollisionMeshDefinition.h"
"${SRC_ROOT}/Collision/CollisionShapeDefinition.cpp"
"${SRC_ROOT}/Collision/CollisionShapeDefinition.h"
"${SRC_ROOT}/Collision/Physics.cpp"
"${SRC_ROOT}/Collision/Physics.h"
"${SRC_ROOT}/Collision/PhysicsBodyActivationListener.cpp"
"${SRC_ROOT}/Collision/PhysicsBodyActivationListener.h"
"${SRC_ROOT}/Collision/PhysicsContactListener.cpp"
"${SRC_ROOT}/Collision/PhysicsContactListener.h"
"${SRC_ROOT}/Collision/PhysicsLayer.cpp"
"${SRC_ROOT}/Collision/PhysicsLayer.h"
"${SRC_ROOT}/Collision/RayCastTypes.cpp"
"${SRC_ROOT}/Collision/RayCastTypes.h"
"${SRC_ROOT}/Collision/SelectionUtils.h")
Expand All @@ -127,17 +133,10 @@ SET(TES_ENTITIES
"${SRC_ROOT}/Entities/AttributeModifier.cpp"
"${SRC_ROOT}/Entities/AttributeModifier.h"
"${SRC_ROOT}/Entities/AttributeModifierName.h"
"${SRC_ROOT}/Entities/BodyPart.cpp"
"${SRC_ROOT}/Entities/BodyPart.h"
"${SRC_ROOT}/Entities/BodyPartName.h"
"${SRC_ROOT}/Entities/Camera3D.cpp"
"${SRC_ROOT}/Entities/Camera3D.h"
"${SRC_ROOT}/Entities/CharacterClassDefinition.cpp"
"${SRC_ROOT}/Entities/CharacterClassDefinition.h"
"${SRC_ROOT}/Entities/CharacterClassLibrary.cpp"
"${SRC_ROOT}/Entities/CharacterClassLibrary.h"
"${SRC_ROOT}/Entities/CharacterEquipment.cpp"
"${SRC_ROOT}/Entities/CharacterEquipment.h"
"${SRC_ROOT}/Entities/CitizenUtils.cpp"
"${SRC_ROOT}/Entities/CitizenUtils.h"
"${SRC_ROOT}/Entities/DerivedAttribute.cpp"
Expand Down Expand Up @@ -194,6 +193,8 @@ SET(TES_GAME
"${SRC_ROOT}/Game/CharacterQuestion.h"
"${SRC_ROOT}/Game/Clock.cpp"
"${SRC_ROOT}/Game/Clock.h"
"${SRC_ROOT}/Game/ClockLibrary.cpp"
"${SRC_ROOT}/Game/ClockLibrary.h"
"${SRC_ROOT}/Game/Date.cpp"
"${SRC_ROOT}/Game/Date.h"
"${SRC_ROOT}/Game/Game.cpp"
Expand Down Expand Up @@ -379,66 +380,18 @@ SET(TES_INTERFACE
"${SRC_ROOT}/Interface/WorldMapUiView.h")

SET(TES_ITEMS
"${SRC_ROOT}/Items/Accessory.cpp"
"${SRC_ROOT}/Items/Accessory.h"
"${SRC_ROOT}/Items/AccessoryArtifactData.cpp"
"${SRC_ROOT}/Items/AccessoryArtifactData.h"
"${SRC_ROOT}/Items/AccessoryType.h"
"${SRC_ROOT}/Items/Armor.cpp"
"${SRC_ROOT}/Items/Armor.h"
"${SRC_ROOT}/Items/ArmorArtifactData.cpp"
"${SRC_ROOT}/Items/ArmorArtifactData.h"
"${SRC_ROOT}/Items/ArmorMaterial.cpp"
"${SRC_ROOT}/Items/ArmorMaterial.h"
"${SRC_ROOT}/Items/ArmorMaterialType.h"
"${SRC_ROOT}/Items/ArmorType.h"
"${SRC_ROOT}/Items/ArtifactData.cpp"
"${SRC_ROOT}/Items/ArtifactData.h"
"${SRC_ROOT}/Items/BodyArmor.cpp"
"${SRC_ROOT}/Items/BodyArmor.h"
"${SRC_ROOT}/Items/BodyArmorArtifactData.cpp"
"${SRC_ROOT}/Items/BodyArmorArtifactData.h"
"${SRC_ROOT}/Items/Consumable.cpp"
"${SRC_ROOT}/Items/Consumable.h"
"${SRC_ROOT}/Items/ConsumableType.h"
"${SRC_ROOT}/Items/HeavyArmorMaterial.cpp"
"${SRC_ROOT}/Items/HeavyArmorMaterial.h"
"${SRC_ROOT}/Items/Item.cpp"
"${SRC_ROOT}/Items/Item.h"
"${SRC_ROOT}/Items/ItemCondition.cpp"
"${SRC_ROOT}/Items/ItemCondition.h"
"${SRC_ROOT}/Items/ItemConditionName.h"
"${SRC_ROOT}/Items/ItemType.h"
"${SRC_ROOT}/Items/LightArmorMaterial.cpp"
"${SRC_ROOT}/Items/LightArmorMaterial.h"
"${SRC_ROOT}/Items/MediumArmorMaterial.cpp"
"${SRC_ROOT}/Items/MediumArmorMaterial.h"
"${SRC_ROOT}/Items/Metal.cpp"
"${SRC_ROOT}/Items/Metal.h"
"${SRC_ROOT}/Items/Metallic.cpp"
"${SRC_ROOT}/Items/Metallic.h"
"${SRC_ROOT}/Items/MetalType.h"
"${SRC_ROOT}/Items/MiscellaneousArtifactData.cpp"
"${SRC_ROOT}/Items/MiscellaneousArtifactData.h"
"${SRC_ROOT}/Items/MiscellaneousItem.cpp"
"${SRC_ROOT}/Items/MiscellaneousItem.h"
"${SRC_ROOT}/Items/MiscellaneousItemType.h"
"${SRC_ROOT}/Items/Potion.cpp"
"${SRC_ROOT}/Items/Potion.h"
"${SRC_ROOT}/Items/Shield.cpp"
"${SRC_ROOT}/Items/Shield.h"
"${SRC_ROOT}/Items/ShieldArtifactData.cpp"
"${SRC_ROOT}/Items/ShieldArtifactData.h"
"${SRC_ROOT}/Items/ShieldType.h"
"${SRC_ROOT}/Items/Trinket.cpp"
"${SRC_ROOT}/Items/Trinket.h"
"${SRC_ROOT}/Items/TrinketType.h"
"${SRC_ROOT}/Items/Weapon.cpp"
"${SRC_ROOT}/Items/Weapon.h"
"${SRC_ROOT}/Items/WeaponArtifactData.cpp"
"${SRC_ROOT}/Items/WeaponArtifactData.h"
"${SRC_ROOT}/Items/WeaponHandCount.h"
"${SRC_ROOT}/Items/WeaponRangeType.h")
"${SRC_ROOT}/Items/ItemConditionLibrary.cpp"
"${SRC_ROOT}/Items/ItemConditionLibrary.h"
"${SRC_ROOT}/Items/ItemDefinition.cpp"
"${SRC_ROOT}/Items/ItemDefinition.h"
"${SRC_ROOT}/Items/ItemInstance.cpp"
"${SRC_ROOT}/Items/ItemInstance.h"
"${SRC_ROOT}/Items/ItemInventory.cpp"
"${SRC_ROOT}/Items/ItemInventory.h"
"${SRC_ROOT}/Items/ItemLibrary.cpp"
"${SRC_ROOT}/Items/ItemLibrary.h"
"${SRC_ROOT}/Items/ItemMaterialLibrary.cpp"
"${SRC_ROOT}/Items/ItemMaterialLibrary.h")

SET(TES_MATH
"${SRC_ROOT}/Math/BoundingBox.cpp"
Expand Down Expand Up @@ -618,8 +571,8 @@ SET(TES_VOXELS
"${SRC_ROOT}/Voxels/VoxelFacing3D.h"
"${SRC_ROOT}/Voxels/VoxelFadeAnimationInstance.cpp"
"${SRC_ROOT}/Voxels/VoxelFadeAnimationInstance.h"
"${SRC_ROOT}/Voxels/VoxelMeshDefinition.cpp"
"${SRC_ROOT}/Voxels/VoxelMeshDefinition.h"
"${SRC_ROOT}/Voxels/VoxelShapeDefinition.cpp"
"${SRC_ROOT}/Voxels/VoxelShapeDefinition.h"
"${SRC_ROOT}/Voxels/VoxelTextureDefinition.cpp"
"${SRC_ROOT}/Voxels/VoxelTextureDefinition.h"
"${SRC_ROOT}/Voxels/VoxelTraitsDefinition.cpp"
Expand Down Expand Up @@ -768,14 +721,14 @@ ELSE (APPLE)
ADD_EXECUTABLE(otesa MACOSX_BUNDLE ${TES_SOURCES} ${TES_MAC_ICON})
ENDIF()

TARGET_LINK_LIBRARIES(otesa components ${EXTERNAL_LIBS})
TARGET_INCLUDE_DIRECTORIES(otesa PUBLIC "${JoltPhysics_SOURCE_DIR}/..")
TARGET_LINK_LIBRARIES(otesa Jolt components ${EXTERNAL_LIBS})
SET_TARGET_PROPERTIES(otesa PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${OpenTESArena_BINARY_DIR})

# Visual Studio filters.
SOURCE_GROUP(TREE ${CMAKE_SOURCE_DIR}/OpenTESArena FILES ${TES_SOURCES})

# DPI-awareness for Visual Studio project (no manifest required).
# Note this is a CMake 3.16 feature.
IF (MSVC)
SET_TARGET_PROPERTIES(otesa PROPERTIES VS_DPI_AWARE "PerMonitor")
SET_TARGET_PROPERTIES(otesa PROPERTIES VS_DPI_AWARE "PerMonitor") # DPI awareness
SET_PROPERTY(DIRECTORY PROPERTY VS_STARTUP_PROJECT "otesa") # Default startup project
ENDIF()
3 changes: 1 addition & 2 deletions OpenTESArena/src/Assets/ArenaAnimUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "../Assets/TextureManager.h"
#include "../Entities/CharacterClassDefinition.h"
#include "../Entities/CharacterClassLibrary.h"
#include "../Items/ArmorMaterialType.h"
#include "../World/MapType.h"

#include "components/debug/Debug.h"
Expand Down Expand Up @@ -867,7 +866,7 @@ bool ArenaAnimUtils::trySetHumanFilenameGender(std::string &filename, bool isMal
return true;
}

bool ArenaAnimUtils::trySetHumanFilenameType(std::string &filename, const std::string_view &type)
bool ArenaAnimUtils::trySetHumanFilenameType(std::string &filename, const std::string_view type)
{
if (filename.size() == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion OpenTESArena/src/Assets/ArenaAnimUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ namespace ArenaAnimUtils
bool trySetHumanFilenameGender(std::string &filename, bool isMale);

// Writes the human type data into the given filename if possible.
bool trySetHumanFilenameType(std::string &filename, const std::string_view &type);
bool trySetHumanFilenameType(std::string &filename, const std::string_view type);

// Writes out static entity animation data to animation states.
bool tryMakeStaticEntityAnims(ArenaTypes::FlatIndex flatIndex, MapType mapType,
Expand Down
1 change: 0 additions & 1 deletion OpenTESArena/src/Assets/ArenaPortraitUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "../Math/Vector2.h"

// Gets the filenames for images relevant to character portraits.

namespace ArenaPortraitUtils
{
// Gets the heads filename for a given gender, race, and whether the heads
Expand Down
1 change: 0 additions & 1 deletion OpenTESArena/src/Assets/ArenaSave.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "ArenaTypes.h"

// Loads various files saved by the original game.

namespace ArenaSave
{
// Using heap-allocated pointers to avoid stack overflow warnings.
Expand Down
1 change: 0 additions & 1 deletion OpenTESArena/src/Assets/ArenaSoundName.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <string>

// Various sound filenames not otherwise obtained automatically by loading the original game's data.

namespace ArenaSoundName
{
// Combat.
Expand Down
1 change: 0 additions & 1 deletion OpenTESArena/src/Assets/ArenaTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

// Various types used with Arena's binary data files. Struct sizes are hardcoded to show
// intent and to avoid issues with padding since they map directly to Arena's data.

namespace ArenaTypes
{
// For .MIF and .RMD FLOR/MAP1/MAP2 voxels.
Expand Down
3 changes: 1 addition & 2 deletions OpenTESArena/src/Assets/BinaryAssetLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
#include "components/utilities/BufferView.h"
#include "components/utilities/Singleton.h"

// Contains assets that are generally not human-readable.

class ArenaRandom;

// Contains assets that are generally not human-readable.
class BinaryAssetLibrary : public Singleton<BinaryAssetLibrary>
{
public:
Expand Down
1 change: 0 additions & 1 deletion OpenTESArena/src/Assets/CFAFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "components/utilities/Buffer2D.h"

// A .CFA file is for creatures and spell animations.

class CFAFile
{
private:
Expand Down
4 changes: 1 addition & 3 deletions OpenTESArena/src/Assets/CIFFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#include "components/utilities/Buffer2D.h"

// A .CIF file has one or more images, and each image has some frames associated
// with it. Examples of .CIF images are character faces, cursors, and weapon
// animations.

// with it. Examples of .CIF images are character faces, cursors, and weapon animations.
class CIFFile
{
private:
Expand Down
1 change: 0 additions & 1 deletion OpenTESArena/src/Assets/COLFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "../Utilities/Palette.h"

// A COL file (assuming it means "color" file) has the colors for a palette.

class COLFile
{
private:
Expand Down
8 changes: 3 additions & 5 deletions OpenTESArena/src/Assets/CityDataFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
#include "../Math/Rect.h"

// CITYDATA.00 contains basic data for locations in each province on the world map.
// It has the names of each place and their XY coordinates on the screen.

// *.64 files are for swapping, *.65 files are templates for new characters, and
// *.0x files contain save-specific modifications (i.e., to save random dungeon names).

// It has the names of each place and their XY coordinates on the screen. *.64 files are
// for swapping, *.65 files are templates for new characters, and *.0x files contain
// save-specific modifications (i.e., to save random dungeon names).
class CityDataFile
{
public:
Expand Down
1 change: 0 additions & 1 deletion OpenTESArena/src/Assets/Compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

// There are a few different methods used for compressing textures in Arena.
// The reusable decompression algorithms will be kept in this namespace.

namespace Compression
{
// Uncompresses an RLE run of bytes.
Expand Down
1 change: 0 additions & 1 deletion OpenTESArena/src/Assets/DFAFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

// A .DFA file contains images for entities that animate but don't move in the world,
// like shopkeepers, tavern folk, lamps, fountains, staff pieces, and torches.

class DFAFile
{
private:
Expand Down
Loading

0 comments on commit 67c3259

Please sign in to comment.