From 39bbd6ec6d3dcc00ce46fe4498525c98524b4db6 Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Mon, 11 May 2020 12:38:59 +0200 Subject: [PATCH] Refactor CMakeLists.txt files to use more modern CMAKE --- .travis.yml | 18 +-- CMakeLists.txt | 120 ++++++++---------- include/reactphysics3d/body/CollisionBody.h | 6 +- include/reactphysics3d/body/RigidBody.h | 2 +- include/reactphysics3d/collision/Collider.h | 4 +- .../collision/broadphase/DynamicAABBTree.h | 6 +- .../collision/narrowphase/CollisionDispatch.h | 6 +- .../collision/narrowphase/GJK/GJKAlgorithm.h | 6 +- .../narrowphase/NarrowPhaseAlgorithm.h | 6 +- .../collision/narrowphase/SAT/SATAlgorithm.h | 6 +- .../collision/shapes/CollisionShape.h | 6 +- .../collision/shapes/ConcaveMeshShape.h | 8 +- include/reactphysics3d/decimal.h | 2 +- .../reactphysics3d/engine/OverlappingPairs.h | 6 +- include/reactphysics3d/engine/PhysicsCommon.h | 2 +- include/reactphysics3d/engine/PhysicsWorld.h | 6 +- .../reactphysics3d/systems/BroadPhaseSystem.h | 6 +- .../systems/CollisionDetectionSystem.h | 6 +- .../systems/ConstraintSolverSystem.h | 6 +- .../systems/ContactSolverSystem.h | 6 +- .../reactphysics3d/systems/DynamicsSystem.h | 6 +- .../systems/SolveBallAndSocketJointSystem.h | 6 +- .../systems/SolveFixedJointSystem.h | 6 +- .../systems/SolveHingeJointSystem.h | 6 +- .../systems/SolveSliderJointSystem.h | 6 +- include/reactphysics3d/utils/Profiler.h | 3 +- src/body/CollisionBody.cpp | 6 +- src/body/RigidBody.cpp | 6 +- src/collision/Collider.cpp | 3 +- .../CapsuleVsConvexPolyhedronAlgorithm.cpp | 3 +- ...xPolyhedronVsConvexPolyhedronAlgorithm.cpp | 3 +- .../narrowphase/SAT/SATAlgorithm.cpp | 3 +- .../SphereVsConvexPolyhedronAlgorithm.cpp | 6 +- src/collision/shapes/CollisionShape.cpp | 3 +- src/collision/shapes/ConcaveMeshShape.cpp | 6 +- src/collision/shapes/HeightFieldShape.cpp | 3 +- src/engine/PhysicsCommon.cpp | 9 +- src/engine/PhysicsWorld.cpp | 15 ++- src/systems/BroadPhaseSystem.cpp | 3 +- src/systems/CollisionDetectionSystem.cpp | 6 +- src/systems/ConstraintSolverSystem.cpp | 3 +- src/systems/ContactSolverSystem.cpp | 3 +- src/utils/Profiler.cpp | 3 +- test/CMakeLists.txt | 16 +-- test/tests/collision/TestDynamicAABBTree.h | 18 ++- testbed/CMakeLists.txt | 40 +++--- 46 files changed, 218 insertions(+), 207 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2dee5e61..d578b516 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,7 +55,7 @@ matrix: packages: - g++-7 env: - - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" BUILD_TYPE="Debug" DOUBLE_PRECISION="False" LOGGER="True" Profiler="True" + - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" BUILD_TYPE="Debug" DOUBLE_PRECISION="False" Profiler="True" - os: linux addons: apt: @@ -64,7 +64,7 @@ matrix: packages: - g++-7 env: - - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" BUILD_TYPE="Release" DOUBLE_PRECISION="False" LOGGER="True" Profiler="True" + - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" BUILD_TYPE="Release" DOUBLE_PRECISION="False" Profiler="True" - os: linux addons: apt: @@ -108,11 +108,11 @@ matrix: #- os: osx # osx_image: xcode9.3 # env: - # - MATRIX_EVAL="brew update && brew install gcc && CC=gcc-7 && CXX=g++-7" BUILD_TYPE="Debug" DOUBLE_PRECISION="True" LOGGER="True" PROFILER="True" + # - MATRIX_EVAL="brew update && brew install gcc && CC=gcc-7 && CXX=g++-7" BUILD_TYPE="Debug" DOUBLE_PRECISION="True" PROFILER="True" #- os: osx # osx_image: xcode9.3 # env: - # - MATRIX_EVAL="brew update && brew install gcc && CC=gcc-7 && CXX=g++-7" BUILD_TYPE="Release" DOUBLE_PRECISION="True" LOGGER="True" PROFILER="True" + # - MATRIX_EVAL="brew update && brew install gcc && CC=gcc-7 && CXX=g++-7" BUILD_TYPE="Release" DOUBLE_PRECISION="True" PROFILER="True" # ----- Linux / Clang ----- - os: linux @@ -172,7 +172,7 @@ matrix: - clang-3.8 - g++-7 env: - - MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8" BUILD_TYPE="Debug" DOUBLE_PRECISION="True" LOGGER="True" PROFILER="True" + - MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8" BUILD_TYPE="Debug" DOUBLE_PRECISION="True" PROFILER="True" - os: linux addons: apt: @@ -183,7 +183,7 @@ matrix: - clang-3.8 - g++-7 env: - - MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8" BUILD_TYPE="Release" DOUBLE_PRECISION="True" LOGGER="True" PROFILER="True" + - MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8" BUILD_TYPE="Release" DOUBLE_PRECISION="True" PROFILER="True" # ----- OS X / Clang ----- - os: osx @@ -209,12 +209,12 @@ matrix: - os: osx osx_image: xcode8 env: - - BUILD_TYPE="Debug" DOUBLE_PRECISION="True" LOGGER="True" PROFILER="True" + - BUILD_TYPE="Debug" DOUBLE_PRECISION="True" PROFILER="True" - os: osx osx_image: xcode8 env: - - BUILD_TYPE="Release" DOUBLE_PRECISION="True" LOGGER="True" PROFILER="True" + - BUILD_TYPE="Release" DOUBLE_PRECISION="True" PROFILER="True" before_install: - eval "${MATRIX_EVAL}" @@ -227,7 +227,7 @@ branches: script: - mkdir build_directory - cd build_directory - - cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} —DRP3D_DOUBLE_PRECISION_ENABLED=${DOUBLE_PRECISION} -DRP3D_COMPILE_TESTS=True -DRP3D_LOGS_ENABLE=${LOGGER} -DRP3D_PROFILING_ENABLED=${PROFILER} -DRP3D_CODE_COVERAGE_ENABLED=${CODE_COVERAGE} ../ + - cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} —DRP3D_DOUBLE_PRECISION_ENABLED=${DOUBLE_PRECISION} -DRP3D_COMPILE_TESTS=True -DRP3D_PROFILING_ENABLED=${PROFILER} -DRP3D_CODE_COVERAGE_ENABLED=${CODE_COVERAGE} ../ - make && make test ARGS="-V" - if [ "${VALGRIND}" == "True" ]; then valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --error-exitcode=1 test/tests; diff --git a/CMakeLists.txt b/CMakeLists.txt index 960fd1c7..658cb441 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,79 +1,46 @@ # Minimum cmake version required -CMAKE_MINIMUM_REQUIRED(VERSION 3.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.8) # Project configuration -PROJECT(REACTPHYSICS3D LANGUAGES CXX) +project(REACTPHYSICS3D LANGUAGES CXX) # In order to install libraries into correct locations on all platforms. include(GNUInstallDirs) -# Build type -IF (NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE "Release") -ENDIF() - -# Where to build the library -SET(LIBRARY_OUTPUT_PATH "lib") - -# Where to build the executables -SET(OUR_EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin") +# Set default build type +set(default_build_type "Release") +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to '${default_build_type}' as none was specified.") + set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE + STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() # CMake modules path -SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) +set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) # Enable testing -ENABLE_TESTING() +enable_testing() # Options -OPTION(RP3D_COMPILE_TESTBED "Select this if you want to build the testbed application" OFF) -OPTION(RP3D_COMPILE_TESTS "Select this if you want to build the tests" OFF) -OPTION(RP3D_PROFILING_ENABLED "Select this if you want to compile with enabled profiling" OFF) -OPTION(RP3D_LOGS_ENABLED "Select this if you want to compile with logs enabled during execution" OFF) -OPTION(RP3D_CODE_COVERAGE_ENABLED "Select this if you need to build for code coverage calculation" OFF) -OPTION(RP3D_DOUBLE_PRECISION_ENABLED "Select this if you want to compile using double precision floating - values" OFF) +option(RP3D_COMPILE_TESTBED "Select this if you want to build the testbed application with demos" OFF) +option(RP3D_COMPILE_TESTS "Select this if you want to build the unit tests" OFF) +option(RP3D_PROFILING_ENABLED "Select this if you want to compile for performanace profiling" OFF) +option(RP3D_CODE_COVERAGE_ENABLED "Select this if you need to build for code coverage calculation" OFF) +option(RP3D_DOUBLE_PRECISION_ENABLED "Select this if you want to compile using double precision floating values" OFF) -# Warning Compiler flags -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") - -IF(RP3D_CODE_COVERAGE_ENABLED) - IF(CMAKE_COMPILER_IS_GNUCXX) +if(RP3D_CODE_COVERAGE_ENABLED) + if(CMAKE_COMPILER_IS_GNUCXX) INCLUDE(CodeCoverage) SETUP_TARGET_FOR_COVERAGE(${PROJECT_NAME}_coverage tests coverage) - ENDIF() - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") -ENDIF() - -# C++11 flags -IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") - include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) - IF(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - ELSE() - message("The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") - ENDIF() -ENDIF() - -# Use libc++ with Clang -#IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") -# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") -#ENDIF() - -IF(RP3D_PROFILING_ENABLED) - ADD_DEFINITIONS(-DIS_PROFILING_ACTIVE) -ENDIF() - -IF(RP3D_LOGS_ENABLED) - ADD_DEFINITIONS(-DIS_LOGGING_ACTIVE) -ENDIF() - -IF(RP3D_DOUBLE_PRECISION_ENABLED) - ADD_DEFINITIONS(-DIS_DOUBLE_PRECISION_ENABLED) -ENDIF() + endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") +endif() # Headers filen1s -SET (REACTPHYSICS3D_HEADERS +set (REACTPHYSICS3D_HEADERS "include/reactphysics3d/configuration.h" "include/reactphysics3d/decimal.h" "include/reactphysics3d/reactphysics3d.h" @@ -185,7 +152,7 @@ SET (REACTPHYSICS3D_HEADERS ) # Source files -SET (REACTPHYSICS3D_SOURCES +set (REACTPHYSICS3D_SOURCES "src/body/CollisionBody.cpp" "src/body/RigidBody.cpp" "src/collision/broadphase/DynamicAABBTree.cpp" @@ -276,38 +243,53 @@ SET (REACTPHYSICS3D_SOURCES ) # Create the library -ADD_LIBRARY(reactphysics3d ${REACTPHYSICS3D_HEADERS} ${REACTPHYSICS3D_SOURCES}) +add_library(reactphysics3d ${REACTPHYSICS3D_HEADERS} ${REACTPHYSICS3D_SOURCES}) + +# C++11 compiler features +target_compile_features(reactphysics3d PUBLIC cxx_std_11) +set_target_properties(reactphysics3d PROPERTIES CXX_EXTENSIONS OFF) + +# Compile with warning messages +target_compile_options(reactphysics3d PRIVATE -Wall) # Headers -TARGET_INCLUDE_DIRECTORIES(reactphysics3d PUBLIC +target_include_directories(reactphysics3d PUBLIC $ $ ) # If we need to compile the testbed application -IF(RP3D_COMPILE_TESTBED) +if(RP3D_COMPILE_TESTBED) add_subdirectory(testbed/) -ENDIF() +endif() # If we need to compile the tests -IF(RP3D_COMPILE_TESTS) +if(RP3D_COMPILE_TESTS) add_subdirectory(test/) -ENDIF() +endif() -#SET_TARGET_PROPERTIES(reactphysics3d PROPERTIES PUBLIC_HEADER "${REACTPHYSICS3D_HEADERS}") +# Enable profiling if necessary +if(RP3D_PROFILING_ENABLED) + target_compile_definitions(reactphysics3d PUBLIC IS_RP3D_PROFILING_ENABLED) +endif() + +# Enable double precision if necessary +if(RP3D_DOUBLE_PRECISION_ENABLED) + target_compile_definitions(reactphysics3d PUBLIC IS_RP3D_DOUBLE_PRECISION_ENABLED) +endif() # Version number and soname for the library -SET_TARGET_PROPERTIES(reactphysics3d PROPERTIES +set_target_properties(reactphysics3d PROPERTIES VERSION "0.7.1" SOVERSION "0.7" ) # Install target (install library only, not headers) -INSTALL(TARGETS reactphysics3d +install(TARGETS reactphysics3d ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) # Install the headers separately (because INSTALL(TARGETS ... PUBLIC_HEADER DESTINATION ...) does not support subfolders -INSTALL(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/include/reactphysics3d/body/CollisionBody.h b/include/reactphysics3d/body/CollisionBody.h index c7a14826..70cb5d55 100644 --- a/include/reactphysics3d/body/CollisionBody.h +++ b/include/reactphysics3d/body/CollisionBody.h @@ -62,7 +62,7 @@ class CollisionBody { /// Reference to the world the body belongs to PhysicsWorld& mWorld; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -157,7 +157,7 @@ class CollisionBody { /// Return the body local-space coordinates of a vector given in the world-space coordinates Vector3 getLocalVector(const Vector3& worldVector) const; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler virtual void setProfiler(Profiler* profiler); @@ -190,7 +190,7 @@ inline Entity CollisionBody::getEntity() const { return mEntity; } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void CollisionBody::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/body/RigidBody.h b/include/reactphysics3d/body/RigidBody.h index eb544e98..7024804d 100644 --- a/include/reactphysics3d/body/RigidBody.h +++ b/include/reactphysics3d/body/RigidBody.h @@ -183,7 +183,7 @@ class RigidBody : public CollisionBody { /// Remove a collider from the body virtual void removeCollider(Collider* collider) override; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler) override; diff --git a/include/reactphysics3d/collision/Collider.h b/include/reactphysics3d/collision/Collider.h index 92d50d1d..e24af1fe 100644 --- a/include/reactphysics3d/collision/Collider.h +++ b/include/reactphysics3d/collision/Collider.h @@ -65,7 +65,7 @@ class Collider { /// Pointer to user data void* mUserData; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -160,7 +160,7 @@ class Collider { /// Set whether the collider is a trigger void setIsTrigger(bool isTrigger) const; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); diff --git a/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h b/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h index 535b2819..70cd46ca 100644 --- a/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h +++ b/include/reactphysics3d/collision/broadphase/DynamicAABBTree.h @@ -161,7 +161,7 @@ class DynamicAABBTree { /// The fat AABB is the initial AABB inflated by a given percentage of its size. decimal mFatAABBInflatePercentage; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -254,7 +254,7 @@ class DynamicAABBTree { /// Clear all the nodes and reset the tree void reset(); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -316,7 +316,7 @@ inline int32 DynamicAABBTree::addObject(const AABB& aabb, void* data) { return nodeId; } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void DynamicAABBTree::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/collision/narrowphase/CollisionDispatch.h b/include/reactphysics3d/collision/narrowphase/CollisionDispatch.h index 692c9e1f..d6175073 100644 --- a/include/reactphysics3d/collision/narrowphase/CollisionDispatch.h +++ b/include/reactphysics3d/collision/narrowphase/CollisionDispatch.h @@ -105,7 +105,7 @@ class CollisionDispatch { /// use between two types of collision shapes. NarrowPhaseAlgorithmType selectAlgorithm(int type1, int type2); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -163,7 +163,7 @@ class CollisionDispatch { NarrowPhaseAlgorithmType selectNarrowPhaseAlgorithm(const CollisionShapeType& shape1Type, const CollisionShapeType& shape2Type) const; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -202,7 +202,7 @@ inline ConvexPolyhedronVsConvexPolyhedronAlgorithm* CollisionDispatch::getConvex return mConvexPolyhedronVsConvexPolyhedronAlgorithm; } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void CollisionDispatch::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h b/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h index ab1d605d..7b4474de 100644 --- a/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h +++ b/include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h @@ -65,7 +65,7 @@ class GJKAlgorithm { // -------------------- Attributes -------------------- // -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -100,7 +100,7 @@ class GJKAlgorithm { void testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems, List& gjkResults); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -109,7 +109,7 @@ class GJKAlgorithm { }; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void GJKAlgorithm::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/collision/narrowphase/NarrowPhaseAlgorithm.h b/include/reactphysics3d/collision/narrowphase/NarrowPhaseAlgorithm.h index 82ce4b90..49d26a35 100644 --- a/include/reactphysics3d/collision/narrowphase/NarrowPhaseAlgorithm.h +++ b/include/reactphysics3d/collision/narrowphase/NarrowPhaseAlgorithm.h @@ -70,7 +70,7 @@ class NarrowPhaseAlgorithm { // -------------------- Attributes -------------------- // -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -94,7 +94,7 @@ class NarrowPhaseAlgorithm { /// Deleted assignment operator NarrowPhaseAlgorithm& operator=(const NarrowPhaseAlgorithm& algorithm) = delete; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -103,7 +103,7 @@ class NarrowPhaseAlgorithm { }; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void NarrowPhaseAlgorithm::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/collision/narrowphase/SAT/SATAlgorithm.h b/include/reactphysics3d/collision/narrowphase/SAT/SATAlgorithm.h index 30479921..c9fa31f6 100644 --- a/include/reactphysics3d/collision/narrowphase/SAT/SATAlgorithm.h +++ b/include/reactphysics3d/collision/narrowphase/SAT/SATAlgorithm.h @@ -78,7 +78,7 @@ class SATAlgorithm { /// Memory allocator MemoryAllocator& mMemoryAllocator; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -173,7 +173,7 @@ class SATAlgorithm { /// Test collision between two convex meshes bool testCollisionConvexPolyhedronVsConvexPolyhedron(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint batchStartIndex, uint batchNbItems) const; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -182,7 +182,7 @@ class SATAlgorithm { }; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void SATAlgorithm::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/collision/shapes/CollisionShape.h b/include/reactphysics3d/collision/shapes/CollisionShape.h index 90b25b1d..803545de 100644 --- a/include/reactphysics3d/collision/shapes/CollisionShape.h +++ b/include/reactphysics3d/collision/shapes/CollisionShape.h @@ -79,7 +79,7 @@ class CollisionShape { /// List of the colliders associated with this shape List mColliders; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -152,7 +152,7 @@ class CollisionShape { /// Return the string representation of the shape virtual std::string to_string() const=0; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler virtual void setProfiler(Profiler* profiler); @@ -199,7 +199,7 @@ inline void CollisionShape::removeCollider(Collider* collider) { mColliders.remove(collider); } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void CollisionShape::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h b/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h index 087e7092..16721c62 100644 --- a/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h +++ b/include/reactphysics3d/collision/shapes/ConcaveMeshShape.h @@ -82,7 +82,7 @@ class ConcaveMeshRaycastCallback : public DynamicAABBTreeRaycastCallback { MemoryAllocator& mAllocator; const Vector3& mMeshScale; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -110,7 +110,7 @@ class ConcaveMeshRaycastCallback : public DynamicAABBTreeRaycastCallback { return mIsHit; } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler) { @@ -196,7 +196,7 @@ class ConcaveMeshShape : public ConcaveShape { /// Return the string representation of the shape virtual std::string to_string() const override; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler virtual void setProfiler(Profiler* profiler) override; @@ -250,7 +250,7 @@ inline void ConvexTriangleAABBOverlapCallback::notifyOverlappingNode(int nodeId) mTriangleTestCallback.testTriangle(trianglePoints, verticesNormals, mConcaveMeshShape.computeTriangleShapeId(data[0], data[1])); } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void ConcaveMeshShape::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/decimal.h b/include/reactphysics3d/decimal.h index 5722d949..f3bd1631 100644 --- a/include/reactphysics3d/decimal.h +++ b/include/reactphysics3d/decimal.h @@ -29,7 +29,7 @@ /// ReactPhysiscs3D namespace namespace reactphysics3d { -#if defined(IS_DOUBLE_PRECISION_ENABLED) // If we are compiling for double precision +#if defined(IS_RP3D_DOUBLE_PRECISION_ENABLED) // If we are compiling for double precision using decimal = double; #else // If we are compiling for single precision using decimal = float; diff --git a/include/reactphysics3d/engine/OverlappingPairs.h b/include/reactphysics3d/engine/OverlappingPairs.h index 35a5342f..1aa7ddf6 100644 --- a/include/reactphysics3d/engine/OverlappingPairs.h +++ b/include/reactphysics3d/engine/OverlappingPairs.h @@ -194,7 +194,7 @@ class OverlappingPairs { /// Reference to the collision dispatch CollisionDispatch& mCollisionDispatch; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -297,7 +297,7 @@ class OverlappingPairs { /// Set to true if the two colliders of the pair were already colliding the previous frame void setCollidingInPreviousFrame(uint64 pairId, bool wereCollidingInPreviousFrame); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -407,7 +407,7 @@ inline void OverlappingPairs::setCollidingInPreviousFrame(uint64 pairId, bool we mCollidingInPreviousFrame[mMapPairIdToPairIndex[pairId]] = wereCollidingInPreviousFrame; } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void OverlappingPairs::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/engine/PhysicsCommon.h b/include/reactphysics3d/engine/PhysicsCommon.h index 54de743f..ba117d05 100644 --- a/include/reactphysics3d/engine/PhysicsCommon.h +++ b/include/reactphysics3d/engine/PhysicsCommon.h @@ -98,7 +98,7 @@ class PhysicsCommon { void release(); // If profiling is enabled -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Create and return a new profiler Profiler* createProfiler(); diff --git a/include/reactphysics3d/engine/PhysicsWorld.h b/include/reactphysics3d/engine/PhysicsWorld.h index 2a894ae4..e3ce366b 100644 --- a/include/reactphysics3d/engine/PhysicsWorld.h +++ b/include/reactphysics3d/engine/PhysicsWorld.h @@ -229,7 +229,7 @@ class PhysicsWorld { /// Name of the physics world std::string mName; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Real-time hierarchical profiler Profiler* mProfiler; @@ -461,7 +461,7 @@ class PhysicsWorld { /// Return a reference to the Debug Renderer of the world DebugRenderer& getDebugRenderer(); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Return a reference to the profiler Profiler* getProfiler(); @@ -584,7 +584,7 @@ inline const std::string& PhysicsWorld::getName() const { return mName; } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Return a pointer to the profiler /** diff --git a/include/reactphysics3d/systems/BroadPhaseSystem.h b/include/reactphysics3d/systems/BroadPhaseSystem.h index ee29832b..66a2cacc 100644 --- a/include/reactphysics3d/systems/BroadPhaseSystem.h +++ b/include/reactphysics3d/systems/BroadPhaseSystem.h @@ -131,7 +131,7 @@ class BroadPhaseSystem { /// Reference to the collision detection object CollisionDetectionSystem& mCollisionDetection; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -198,7 +198,7 @@ class BroadPhaseSystem { /// Ray casting method void raycast(const Ray& ray, RaycastTest& raycastTest, unsigned short raycastWithCategoryMaskBits) const; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -225,7 +225,7 @@ inline Collider* BroadPhaseSystem::getColliderForBroadPhaseId(int broadPhaseId) return static_cast(mDynamicAABBTree.getNodeDataPointer(broadPhaseId)); } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void BroadPhaseSystem::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/systems/CollisionDetectionSystem.h b/include/reactphysics3d/systems/CollisionDetectionSystem.h index f2928fa3..677b6733 100644 --- a/include/reactphysics3d/systems/CollisionDetectionSystem.h +++ b/include/reactphysics3d/systems/CollisionDetectionSystem.h @@ -166,7 +166,7 @@ class CollisionDetectionSystem { /// Map a body entity to the list of contact pairs in which it is involved Map> mMapBodyToContactPairs; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -361,7 +361,7 @@ class CollisionDetectionSystem { /// Return the world event listener EventListener* getWorldEventListener(); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -440,7 +440,7 @@ inline void CollisionDetectionSystem::updateColliders(decimal timeStep) { mBroadPhaseSystem.updateColliders(timeStep); } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void CollisionDetectionSystem::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/systems/ConstraintSolverSystem.h b/include/reactphysics3d/systems/ConstraintSolverSystem.h index 5460cac2..3458b1ee 100644 --- a/include/reactphysics3d/systems/ConstraintSolverSystem.h +++ b/include/reactphysics3d/systems/ConstraintSolverSystem.h @@ -173,7 +173,7 @@ class ConstraintSolverSystem { /// Solver for the SliderJoint constraints SolveSliderJointSystem mSolveSliderJointSystem; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -209,7 +209,7 @@ class ConstraintSolverSystem { /// Enable/Disable the Non-Linear-Gauss-Seidel position correction technique. void setIsNonLinearGaussSeidelPositionCorrectionActive(bool isActive); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -218,7 +218,7 @@ class ConstraintSolverSystem { }; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void ConstraintSolverSystem::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/systems/ContactSolverSystem.h b/include/reactphysics3d/systems/ContactSolverSystem.h index b98c294b..6afc3d5f 100644 --- a/include/reactphysics3d/systems/ContactSolverSystem.h +++ b/include/reactphysics3d/systems/ContactSolverSystem.h @@ -330,7 +330,7 @@ class ContactSolverSystem { /// True if the split impulse position correction is active bool mIsSplitImpulseActive; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -391,7 +391,7 @@ class ContactSolverSystem { /// Activate or Deactivate the split impulses for contacts void setIsSplitImpulseActive(bool isActive); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -409,7 +409,7 @@ inline void ContactSolverSystem::setIsSplitImpulseActive(bool isActive) { mIsSplitImpulseActive = isActive; } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void ContactSolverSystem::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/systems/DynamicsSystem.h b/include/reactphysics3d/systems/DynamicsSystem.h index 4b52a45e..ca0a90f5 100644 --- a/include/reactphysics3d/systems/DynamicsSystem.h +++ b/include/reactphysics3d/systems/DynamicsSystem.h @@ -69,7 +69,7 @@ class DynamicsSystem { /// Reference to the world gravity vector Vector3& mGravity; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -87,7 +87,7 @@ class DynamicsSystem { /// Destructor ~DynamicsSystem() = default; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -111,7 +111,7 @@ class DynamicsSystem { }; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void DynamicsSystem::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/systems/SolveBallAndSocketJointSystem.h b/include/reactphysics3d/systems/SolveBallAndSocketJointSystem.h index 2e18ba79..fbfde73a 100644 --- a/include/reactphysics3d/systems/SolveBallAndSocketJointSystem.h +++ b/include/reactphysics3d/systems/SolveBallAndSocketJointSystem.h @@ -74,7 +74,7 @@ class SolveBallAndSocketJointSystem { /// True if warm starting of the solver is active bool mIsWarmStartingActive; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -111,7 +111,7 @@ class SolveBallAndSocketJointSystem { /// Set to true to enable warm starting void setIsWarmStartingActive(bool isWarmStartingActive); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -120,7 +120,7 @@ class SolveBallAndSocketJointSystem { }; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void SolveBallAndSocketJointSystem::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/systems/SolveFixedJointSystem.h b/include/reactphysics3d/systems/SolveFixedJointSystem.h index 7640f096..45d6f53f 100644 --- a/include/reactphysics3d/systems/SolveFixedJointSystem.h +++ b/include/reactphysics3d/systems/SolveFixedJointSystem.h @@ -73,7 +73,7 @@ class SolveFixedJointSystem { /// True if warm starting of the solver is active bool mIsWarmStartingActive; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -108,7 +108,7 @@ class SolveFixedJointSystem { /// Set to true to enable warm starting void setIsWarmStartingActive(bool isWarmStartingActive); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -117,7 +117,7 @@ class SolveFixedJointSystem { }; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void SolveFixedJointSystem::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/systems/SolveHingeJointSystem.h b/include/reactphysics3d/systems/SolveHingeJointSystem.h index 9e120863..94e38de3 100644 --- a/include/reactphysics3d/systems/SolveHingeJointSystem.h +++ b/include/reactphysics3d/systems/SolveHingeJointSystem.h @@ -73,7 +73,7 @@ class SolveHingeJointSystem { /// True if warm starting of the solver is active bool mIsWarmStartingActive; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -126,7 +126,7 @@ class SolveHingeJointSystem { /// Set to true to enable warm starting void setIsWarmStartingActive(bool isWarmStartingActive); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -135,7 +135,7 @@ class SolveHingeJointSystem { }; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void SolveHingeJointSystem::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/systems/SolveSliderJointSystem.h b/include/reactphysics3d/systems/SolveSliderJointSystem.h index 651aafbe..f0e56c87 100644 --- a/include/reactphysics3d/systems/SolveSliderJointSystem.h +++ b/include/reactphysics3d/systems/SolveSliderJointSystem.h @@ -73,7 +73,7 @@ class SolveSliderJointSystem { /// True if warm starting of the solver is active bool mIsWarmStartingActive; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler Profiler* mProfiler; @@ -112,7 +112,7 @@ class SolveSliderJointSystem { /// Set to true to enable warm starting void setIsWarmStartingActive(bool isWarmStartingActive); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler void setProfiler(Profiler* profiler); @@ -121,7 +121,7 @@ class SolveSliderJointSystem { }; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED // Set the profiler inline void SolveSliderJointSystem::setProfiler(Profiler* profiler) { diff --git a/include/reactphysics3d/utils/Profiler.h b/include/reactphysics3d/utils/Profiler.h index 631cc7e6..fc582fc2 100644 --- a/include/reactphysics3d/utils/Profiler.h +++ b/include/reactphysics3d/utils/Profiler.h @@ -27,7 +27,8 @@ #define REACTPHYSICS3D_PROFILER_H // If profiling is enabled -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + // Libraries #include diff --git a/src/body/CollisionBody.cpp b/src/body/CollisionBody.cpp index fedb9f7b..47ca30fc 100644 --- a/src/body/CollisionBody.cpp +++ b/src/body/CollisionBody.cpp @@ -43,7 +43,8 @@ using namespace reactphysics3d; CollisionBody::CollisionBody(PhysicsWorld& world, Entity entity) : mEntity(entity), mWorld(world) { -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + mProfiler = nullptr; #endif @@ -92,7 +93,8 @@ Collider* CollisionBody::addCollider(CollisionShape* collisionShape, const Trans // Assign the collider with the collision shape collisionShape->addCollider(collider); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + // Set the profiler collider->setProfiler(mProfiler); diff --git a/src/body/RigidBody.cpp b/src/body/RigidBody.cpp index 2c242c48..e099adb9 100644 --- a/src/body/RigidBody.cpp +++ b/src/body/RigidBody.cpp @@ -582,7 +582,8 @@ Collider* RigidBody::addCollider(CollisionShape* collisionShape, const Transform // Assign the collider with the collision shape collisionShape->addCollider(collider); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + // Set the profiler collider->setProfiler(mProfiler); @@ -905,7 +906,8 @@ void RigidBody::setIsActive(bool isActive) { CollisionBody::setIsActive(isActive); } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + // Set the profiler void RigidBody::setProfiler(Profiler* profiler) { diff --git a/src/collision/Collider.cpp b/src/collision/Collider.cpp index 68ed01de..85059f7b 100644 --- a/src/collision/Collider.cpp +++ b/src/collision/Collider.cpp @@ -247,7 +247,8 @@ void Collider::setIsTrigger(bool isTrigger) const { mBody->mWorld.mCollidersComponents.setIsTrigger(mEntity, isTrigger); } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + // Set the profiler void Collider::setProfiler(Profiler* profiler) { diff --git a/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp b/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp index efcaf3c3..643e569f 100644 --- a/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp +++ b/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp @@ -50,7 +50,8 @@ bool CapsuleVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& nar GJKAlgorithm gjkAlgorithm; SATAlgorithm satAlgorithm(clipWithPreviousAxisIfStillColliding, memoryAllocator); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + gjkAlgorithm.setProfiler(mProfiler); satAlgorithm.setProfiler(mProfiler); diff --git a/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp b/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp index 7cea8c2b..021d533b 100644 --- a/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp +++ b/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp @@ -42,7 +42,8 @@ bool ConvexPolyhedronVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoB // Run the SAT algorithm to find the separating axis and compute contact point SATAlgorithm satAlgorithm(clipWithPreviousAxisIfStillColliding, memoryAllocator); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + satAlgorithm.setProfiler(mProfiler); diff --git a/src/collision/narrowphase/SAT/SATAlgorithm.cpp b/src/collision/narrowphase/SAT/SATAlgorithm.cpp index 69b0c236..6c11b444 100644 --- a/src/collision/narrowphase/SAT/SATAlgorithm.cpp +++ b/src/collision/narrowphase/SAT/SATAlgorithm.cpp @@ -47,7 +47,8 @@ const decimal SATAlgorithm::SEPARATING_AXIS_ABSOLUTE_TOLERANCE = decimal(0.0005) SATAlgorithm::SATAlgorithm(bool clipWithPreviousAxisIfStillColliding, MemoryAllocator& memoryAllocator) : mClipWithPreviousAxisIfStillColliding(clipWithPreviousAxisIfStillColliding), mMemoryAllocator(memoryAllocator) { -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + mProfiler = nullptr; #endif diff --git a/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp b/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp index 9c677fa4..260e5be9 100644 --- a/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp +++ b/src/collision/narrowphase/SphereVsConvexPolyhedronAlgorithm.cpp @@ -43,7 +43,8 @@ bool SphereVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& narr bool isCollisionFound = false; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + gjkAlgorithm.setProfiler(mProfiler); @@ -82,7 +83,8 @@ bool SphereVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& narr // Run the SAT algorithm to find the separating axis and compute contact point SATAlgorithm satAlgorithm(clipWithPreviousAxisIfStillColliding, memoryAllocator); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + satAlgorithm.setProfiler(mProfiler); diff --git a/src/collision/shapes/CollisionShape.cpp b/src/collision/shapes/CollisionShape.cpp index e49aa2e8..50879915 100644 --- a/src/collision/shapes/CollisionShape.cpp +++ b/src/collision/shapes/CollisionShape.cpp @@ -36,7 +36,8 @@ using namespace reactphysics3d; CollisionShape::CollisionShape(CollisionShapeName name, CollisionShapeType type, MemoryAllocator &allocator) : mType(type), mName(name), mId(0), mColliders(allocator) { -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + mProfiler = nullptr; #endif diff --git a/src/collision/shapes/ConcaveMeshShape.cpp b/src/collision/shapes/ConcaveMeshShape.cpp index 37c3c729..053d221f 100644 --- a/src/collision/shapes/ConcaveMeshShape.cpp +++ b/src/collision/shapes/ConcaveMeshShape.cpp @@ -182,7 +182,8 @@ bool ConcaveMeshShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collide // Create the callback object that will compute ray casting against triangles ConcaveMeshRaycastCallback raycastCallback(mDynamicAABBTree, *this, collider, raycastInfo, scaledRay, mScale, allocator); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + // Set the profiler raycastCallback.setProfiler(mProfiler); @@ -249,7 +250,8 @@ void ConcaveMeshRaycastCallback::raycastTriangles() { TriangleShape triangleShape(trianglePoints, verticesNormals, mConcaveMeshShape.computeTriangleShapeId(data[0], data[1]), mAllocator); triangleShape.setRaycastTestType(mConcaveMeshShape.getRaycastTestType()); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + // Set the profiler to the triangle shape triangleShape.setProfiler(mProfiler); diff --git a/src/collision/shapes/HeightFieldShape.cpp b/src/collision/shapes/HeightFieldShape.cpp index 7553960d..892f5238 100644 --- a/src/collision/shapes/HeightFieldShape.cpp +++ b/src/collision/shapes/HeightFieldShape.cpp @@ -256,7 +256,8 @@ bool HeightFieldShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, Collide TriangleShape triangleShape(&(triangleVertices[i * 3]), &(triangleVerticesNormals[i * 3]), shapeIds[i], allocator); triangleShape.setRaycastTestType(getRaycastTestType()); - #ifdef IS_PROFILING_ACTIVE + #ifdef IS_RP3D_PROFILING_ENABLED + // Set the profiler to the triangle shape triangleShape.setProfiler(mProfiler); diff --git a/src/engine/PhysicsCommon.cpp b/src/engine/PhysicsCommon.cpp index 6f08486c..3d3235e4 100644 --- a/src/engine/PhysicsCommon.cpp +++ b/src/engine/PhysicsCommon.cpp @@ -104,7 +104,8 @@ void PhysicsCommon::release() { } // If profiling is enabled -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + // Destroy the profilers for (auto it = mProfilers.begin(); it != mProfilers.end(); ++it) { @@ -120,7 +121,8 @@ PhysicsWorld* PhysicsCommon::createPhysicsWorld(const PhysicsWorld::WorldSetting Profiler* profiler = nullptr; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + profiler = createProfiler(); @@ -373,7 +375,8 @@ void PhysicsCommon::destroyDefaultLogger(DefaultLogger* logger) { } // If profiling is enabled -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + // Create and return a new profiler /// Note that you need to use a different profiler for each PhysicsWorld. diff --git a/src/engine/PhysicsWorld.cpp b/src/engine/PhysicsWorld.cpp index 8480f640..bc04aaad 100644 --- a/src/engine/PhysicsWorld.cpp +++ b/src/engine/PhysicsWorld.cpp @@ -85,7 +85,8 @@ PhysicsWorld::PhysicsWorld(MemoryManager& memoryManager, const WorldSettings& wo mName = ss.str(); } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + assert(profiler != nullptr); mProfiler = profiler; @@ -121,7 +122,8 @@ PhysicsWorld::~PhysicsWorld() { destroyCollisionBody(mCollisionBodies[i]); } -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + // Print the profiling report into the destinations mProfiler->printReport(); @@ -175,7 +177,8 @@ CollisionBody* PhysicsWorld::createCollisionBody(const Transform& transform) { // Add the collision body to the world mCollisionBodies.add(collisionBody); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + collisionBody->setProfiler(mProfiler); @@ -313,7 +316,8 @@ AABB PhysicsWorld::getWorldAABB(const Collider* collider) const { */ void PhysicsWorld::update(decimal timeStep) { -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + // Increment the frame counter of the profiler mProfiler->incrementFrameCounter(); #endif @@ -462,7 +466,8 @@ RigidBody* PhysicsWorld::createRigidBody(const Transform& transform) { // Add the rigid body to the physics world mRigidBodies.add(rigidBody); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + rigidBody->setProfiler(mProfiler); #endif diff --git a/src/systems/BroadPhaseSystem.cpp b/src/systems/BroadPhaseSystem.cpp index fdd0594e..58b270e0 100644 --- a/src/systems/BroadPhaseSystem.cpp +++ b/src/systems/BroadPhaseSystem.cpp @@ -42,7 +42,8 @@ BroadPhaseSystem::BroadPhaseSystem(CollisionDetectionSystem& collisionDetection, mRigidBodyComponents(rigidBodyComponents), mMovedShapes(collisionDetection.getMemoryManager().getPoolAllocator()), mCollisionDetection(collisionDetection) { -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + mProfiler = nullptr; diff --git a/src/systems/CollisionDetectionSystem.cpp b/src/systems/CollisionDetectionSystem.cpp index 0cf1ddec..817fb12e 100644 --- a/src/systems/CollisionDetectionSystem.cpp +++ b/src/systems/CollisionDetectionSystem.cpp @@ -69,7 +69,8 @@ CollisionDetectionSystem::CollisionDetectionSystem(PhysicsWorld* world, Collider mContactPoints2(mMemoryManager.getPoolAllocator()), mPreviousContactPoints(&mContactPoints1), mCurrentContactPoints(&mContactPoints2), mMapBodyToContactPairs(mMemoryManager.getSingleFrameAllocator()) { -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + mProfiler = nullptr; mCollisionDispatch.setProfiler(mProfiler); @@ -412,7 +413,8 @@ void CollisionDetectionSystem::computeConvexVsConcaveMiddlePhase(uint64 pairInde TriangleShape* triangleShape = new (allocator.allocate(sizeof(TriangleShape))) TriangleShape(&(triangleVertices[i * 3]), &(triangleVerticesNormals[i * 3]), shapeIds[i], allocator); - #ifdef IS_PROFILING_ACTIVE + #ifdef IS_RP3D_PROFILING_ENABLED + // Set the profiler to the triangle shape triangleShape->setProfiler(mProfiler); diff --git a/src/systems/ConstraintSolverSystem.cpp b/src/systems/ConstraintSolverSystem.cpp index 43f56330..844a7afc 100644 --- a/src/systems/ConstraintSolverSystem.cpp +++ b/src/systems/ConstraintSolverSystem.cpp @@ -47,7 +47,8 @@ ConstraintSolverSystem::ConstraintSolverSystem(PhysicsWorld& world, Islands& isl mSolveHingeJointSystem(world, rigidBodyComponents, transformComponents, jointComponents, hingeJointComponents), mSolveSliderJointSystem(world, rigidBodyComponents, transformComponents, jointComponents, sliderJointComponents) { -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + mProfiler = nullptr; diff --git a/src/systems/ContactSolverSystem.cpp b/src/systems/ContactSolverSystem.cpp index 157cab57..a454d1f9 100644 --- a/src/systems/ContactSolverSystem.cpp +++ b/src/systems/ContactSolverSystem.cpp @@ -53,7 +53,8 @@ ContactSolverSystem::ContactSolverSystem(MemoryManager& memoryManager, PhysicsWo mBodyComponents(bodyComponents), mRigidBodyComponents(rigidBodyComponents), mColliderComponents(colliderComponents), mIsSplitImpulseActive(true) { -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + mProfiler = nullptr; #endif diff --git a/src/utils/Profiler.cpp b/src/utils/Profiler.cpp index 6c1b6e10..152bb531 100644 --- a/src/utils/Profiler.cpp +++ b/src/utils/Profiler.cpp @@ -24,7 +24,8 @@ ********************************************************************************/ // If profiling is enabled -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + // Libraries #include diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 69e5c45e..804f7cb8 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,11 +1,11 @@ # Minimum cmake version required -CMAKE_MINIMUM_REQUIRED(VERSION 3.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.8) # Project configuration -PROJECT(TESTS) +project(TESTS) # Header files -SET (RP3D_TESTS_HEADERS +set (RP3D_TESTS_HEADERS "Test.h" "TestSuite.h" "tests/collision/TestAABB.h" @@ -30,20 +30,20 @@ SET (RP3D_TESTS_HEADERS ) # Source files -SET (RP3D_TESTS_SOURCES +set (RP3D_TESTS_SOURCES "main.cpp" "Test.cpp" "TestSuite.cpp" ) # Create the tests executable -ADD_EXECUTABLE(tests ${RP3D_TESTS_HEADERS} ${RP3D_TESTS_SOURCES}) +add_executable(tests ${RP3D_TESTS_HEADERS} ${RP3D_TESTS_SOURCES}) # Headers -TARGET_INCLUDE_DIRECTORIES(reactphysics3d PUBLIC +target_include_directories(reactphysics3d PUBLIC $ ) -TARGET_LINK_LIBRARIES(tests reactphysics3d) +target_link_libraries(tests reactphysics3d) -ADD_TEST(Test tests) +add_test(Test tests) diff --git a/test/tests/collision/TestDynamicAABBTree.h b/test/tests/collision/TestDynamicAABBTree.h index 8150f165..69b876be 100755 --- a/test/tests/collision/TestDynamicAABBTree.h +++ b/test/tests/collision/TestDynamicAABBTree.h @@ -97,7 +97,8 @@ class TestDynamicAABBTree : public Test { PhysicsCommon mPhysicsCommon; -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + Profiler* mProfiler; #endif @@ -108,7 +109,8 @@ class TestDynamicAABBTree : public Test { /// Constructor TestDynamicAABBTree(const std::string& name): Test(name) { -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + mProfiler = new Profiler(); #endif @@ -117,7 +119,8 @@ class TestDynamicAABBTree : public Test { /// Constructor ~TestDynamicAABBTree() { -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + delete mProfiler; #endif @@ -142,7 +145,8 @@ class TestDynamicAABBTree : public Test { // Dynamic AABB Tree DynamicAABBTree tree(mAllocator); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + tree.setProfiler(mProfiler); #endif @@ -191,7 +195,8 @@ class TestDynamicAABBTree : public Test { // Dynamic AABB Tree DynamicAABBTree tree(mAllocator); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + tree.setProfiler(mProfiler); #endif @@ -386,7 +391,8 @@ class TestDynamicAABBTree : public Test { // Dynamic AABB Tree DynamicAABBTree tree(mAllocator); -#ifdef IS_PROFILING_ACTIVE +#ifdef IS_RP3D_PROFILING_ENABLED + tree.setProfiler(mProfiler); #endif diff --git a/testbed/CMakeLists.txt b/testbed/CMakeLists.txt index 038ff1e4..0ff2051f 100755 --- a/testbed/CMakeLists.txt +++ b/testbed/CMakeLists.txt @@ -1,28 +1,22 @@ # Minimum cmake version required -CMAKE_MINIMUM_REQUIRED(VERSION 3.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.8) # Project configuration -PROJECT(Testbed) +project(Testbed) -# Where to build the executables -SET(EXECUTABLE_OUTPUT_PATH "${OUR_EXECUTABLE_OUTPUT_PATH}/testbed") -SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) -SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH}) -SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH}) - -ADD_SUBDIRECTORY(nanogui/) +add_subdirectory(nanogui/) # Copy the shaders used for the demo into the build directory -FILE(COPY "shaders/" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/shaders/") +file(COPY "shaders/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/shaders/") # Copy the meshes used for the demo into the build directory -FILE(COPY "meshes/" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/meshes/") +file(COPY "meshes/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/meshes/") # Headers -INCLUDE_DIRECTORIES("src/" "nanogui/include/" "opengl-framework/src/" "common/" "scenes/" ${NANOGUI_EXTRA_INCS}) +include_directories("src/" "nanogui/include/" "opengl-framework/src/" "common/" "scenes/" ${NANOGUI_EXTRA_INCS}) # OpenGLFramework source files -SET(OPENGLFRAMEWORK_SOURCES +set(OPENGLFRAMEWORK_SOURCES opengl-framework/src/maths/Color.h opengl-framework/src/maths/Matrix3.h opengl-framework/src/maths/Matrix4.h @@ -56,7 +50,7 @@ SET(OPENGLFRAMEWORK_SOURCES ) # Testbed source files -SET(TESTBED_SOURCES +set(TESTBED_SOURCES src/Main.cpp src/TestbedApplication.h src/TestbedApplication.cpp @@ -71,7 +65,7 @@ SET(TESTBED_SOURCES ) # Common source files -SET(COMMON_SOURCES +set(COMMON_SOURCES common/Box.h common/Box.cpp common/Sphere.h @@ -99,7 +93,7 @@ SET(COMMON_SOURCES ) # Examples scenes source files -SET(SCENES_SOURCES +set(SCENES_SOURCES scenes/cubes/CubesScene.h scenes/cubes/CubesScene.cpp scenes/joints/JointsScene.h @@ -121,20 +115,20 @@ SET(SCENES_SOURCES ) # Add .user file to set debug path in Visual Studio -SET(USER_FILE testbed.vcxproj.user) -SET(VS_USERFILE_WORKING_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH}) -SET(OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${USER_FILE}) -CONFIGURE_FILE(VisualStudioUserTemplate.user ${USER_FILE} @ONLY) +set(USER_FILE testbed.vcxproj.user) +set(VS_USERFILE_WORKING_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH}) +set(OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${USER_FILE}) +configure_file(VisualStudioUserTemplate.user ${USER_FILE} @ONLY) # Compile definitions -ADD_DEFINITIONS(${NANOGUI_EXTRA_DEFS}) +add_definitions(${NANOGUI_EXTRA_DEFS}) # Create the executable -ADD_EXECUTABLE(testbed ${TESTBED_SOURCES} ${SCENES_SOURCES} ${COMMON_SOURCES} ${OPENGLFRAMEWORK_SOURCES}) +add_executable(testbed ${TESTBED_SOURCES} ${SCENES_SOURCES} ${COMMON_SOURCES} ${OPENGLFRAMEWORK_SOURCES}) # Enable C++11 features set_property(TARGET testbed PROPERTY CXX_STANDARD 11) set_property(TARGET testbed PROPERTY CXX_STANDARD_REQUIRED ON) # Link with libraries -TARGET_LINK_LIBRARIES(testbed reactphysics3d nanogui ${NANOGUI_EXTRA_LIBS}) +target_link_libraries(testbed reactphysics3d nanogui ${NANOGUI_EXTRA_LIBS})