diff --git a/CHANGELOG.md b/CHANGELOG.md index 2adbeabb..a412ac3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Develop +## Version 0.8.0 ### Added @@ -25,10 +25,12 @@ - In the EventListener, the onContact() and onTrigger() method now reports the type of event (start, stay, exit) for each contact. This way the user can know whether it's a new contact or not or when two colliders are not in contact anymore. - A DebugRenderer class has been added in order to display debug info (colliders, AABBs, contacts, ...) using graphics primities (lines, triangles). - A RigidBody::applyForceAtLocalPosition() method has been added to apply a force at a given position of the rigid body in local-space. + - The CMakeLists.txt file of the library has been refactored to use modern CMake. The targets are now exported when you install the library so that you can import the library with the find_package(ReactPhysics3D) function in your own CMakeLists.txt file + - A Hello World project has been added to show a very simple project that uses the ReactPhysics3D library ### Fixed - - Issues [#125](https://github.com/DanielChappuis/reactphysics3d/issues/125) and [#106](https://github.com/DanielChappuis/reactphysics3d/issues/106) have been fixed. + - Issues [#125](https://github.com/DanielChappuis/reactphysics3d/issues/125) and [#106](https://github.com/DanielChappuis/reactphysics3d/issues/106) with CMake install of the library have been fixed - Issue [#141](https://github.com/DanielChappuis/reactphysics3d/issues/141) with limits of hinge and slider joints has been fixed. ### Changed diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d69d2f5..2c51c399 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -254,7 +254,10 @@ 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) +target_compile_options(reactphysics3d PRIVATE + $<$:/W4> # for Visual Studio + $<$>:-Wall -Wextra -pedantic> # Other compilers +) # Library headers target_include_directories(reactphysics3d PUBLIC diff --git a/helloworld/CMakeLists.txt b/helloworld/CMakeLists.txt new file mode 100644 index 00000000..fccf4b00 --- /dev/null +++ b/helloworld/CMakeLists.txt @@ -0,0 +1,18 @@ +# This is the CMakeLists.txt file of the "hello world" project +# in order to show a simple executable that uses the ReactPhysics3D library + +# Minimum cmake version required +cmake_minimum_required(VERSION 3.8) + +# Import the ReactPhysics3D library that you have installed on your computer using +# the "make install" command +find_package(ReactPhysics3D REQUIRED) + +# Project +project(HelloWorld) + +# Create the executable +add_executable(helloworld Main.cpp) + +# Link with the ReactPhysics3D library +target_link_libraries(helloworld ReactPhysics3D::ReactPhysics3D) diff --git a/helloworld/Main.cpp b/helloworld/Main.cpp new file mode 100644 index 00000000..67f443ad --- /dev/null +++ b/helloworld/Main.cpp @@ -0,0 +1,47 @@ +/* + * This is a "hello world" project with a basic example of how to use + * the ReactPhysics3D library in your project. This example is a simple + * rigid body that is falling down because of gravity. + */ + +// Libraries +#include +#include + +// ReactPhysics3D namespace +using namespace reactphysics3d; + +// Main function +int main(int argc, char** argv) { + + // First you need to create the PhysicsCommon object. This is a factory module + // that you can use to create physics world and other objects. It is also responsible + // for logging and memory management + PhysicsCommon physicsCommon; + + // Create a physics world + PhysicsWorld* world = physicsCommon.createPhysicsWorld(); + + // Create a rigid body in the world + Vector3 position(0, 20, 0); + Quaternion orientation = Quaternion::identity(); + Transform transform(position, orientation); + RigidBody* body = world->createRigidBody(transform); + + const decimal timeStep = 1.0f / 60.0f; + + // Step the simulation a few steps + for (int i=0; i < 20; i++) { + + world->update(timeStep); + + // Ge the updated position of the body + const Transform& transform = body->getTransform(); + const Vector3& position = transform.getPosition(); + + // Display the position of the body + std::cout << "Body Position: (" << position.x << ", " << position.y << ", " << position.z << ")" << std::endl; + } + + return 0; +}