ephysics/ephysics/engine/CollisionWorld.hpp
Edouard DUPIN 66a20f94b3 [LICENCE] change ZLib to MPL-2 with athoriqzation of author:
Email exchange:

On 29.09.2017 14:35 Edouard DUPIN wrote:
Hello,

I have fork your physic engine and update it to fit better with my 3d
game engine and my framework.

I do many change:
  - on assert policy (I do not like it)
  - the back-end use of the vector3D and quaternion, that I have
already an other implementation...
  - Log management
  - Other build system (lutin)
  - organisation of doxygen (all in the header)
  - remove dependency of the STL (in progress)
  - some bugs ...
  - ...

And I have a problem with the licence. You use BSD-3 that is a good
point, but this licence does not force the user to send your their
modification. Then I ask you to permit me to change the licence of the
FORK in MPL-2 that have the benefit to force developer to publish the
modification and permit to use the software in a proprietary
application without contamination.

Best regards

Edouard DUPIN

https://github.com/HeeroYui
https://github.com/atria-soft
https://github.com/musicdsp

answers from chappuis.daniel@XXXXXXX.yyy
Hello,

I am glad that you have found the ReactPhysics3D library to be useful.
You said that you have found bugs. Maybe I have already found and fixed some of them but do not hesitate to report them
here (https://github.com/DanielChappuis/reactphysics3d/issues) if not done yet.

Concerning the license. The library is not under the BSD-3 license but under the zlib license (https://opensource.org/licenses/Zlib).
With this license, it is allowed to use the software in a proprietary application without contamination. Regarding your request to
change the license to the MPL-2, you can do it with the following condition : You need to add the following text in all the source files
of ReactPhysics3D where the license will change. It must always be clear where the original code is coming from.

--------------- TEXT TO ADD TO THE LICENSE IN EACH FILE -------------------------
Original ReactPhysics3D C++ library by Daniel Chappuis <http://www.reactphysics3d.com/>
This code is re-licensed with permission from ReactPhysics3D author.
---------------------------------------------------------------------------------

For example, you can see here how the flow/react library (java port of ReactPhysics3D) has been re-licensed from
ReactPhysics3D (https://github.com/flow/react/blob/develop/src/main/java/com/flowpowered/react/constraint/ContactPoint.java)

I hope it fits your needs.

Best Regards,

Daniel Chappuis
2017-10-02 16:20:11 +02:00

143 lines
5.9 KiB
C++

/** @file
* Original ReactPhysics3D C++ library by Daniel Chappuis <http://www.reactphysics3d.com/> This code is re-licensed with permission from ReactPhysics3D author.
* @author Daniel CHAPPUIS
* @author Edouard DUPIN
* @copyright 2010-2016, Daniel Chappuis
* @copyright 2017, Edouard DUPIN
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/Vector.hpp>
#include <ephysics/mathematics/mathematics.hpp>
#include <ephysics/engine/Profiler.hpp>
#include <ephysics/body/CollisionBody.hpp>
#include <ephysics/collision/RaycastInfo.hpp>
#include <ephysics/engine/OverlappingPair.hpp>
#include <ephysics/collision/CollisionDetection.hpp>
#include <ephysics/constraint/Joint.hpp>
#include <ephysics/constraint/ContactPoint.hpp>
#include <ephysics/engine/EventListener.hpp>
namespace ephysics {
class CollisionCallback;
/**
* @brief This class represent a world where it is possible to move bodies
* by hand and to test collision between each other. In this kind of
* world, the bodies movement is not computed using the laws of physics.
*/
class CollisionWorld {
protected :
CollisionDetection m_collisionDetection; //!< Reference to the collision detection
etk::Set<CollisionBody*> m_bodies; //!< All the bodies (rigid and soft) of the world
bodyindex m_currentBodyID; //!< Current body ID
etk::Vector<uint64_t> m_freeBodiesIDs; //!< List of free ID for rigid bodies
EventListener* m_eventListener; //!< Pointer to an event listener object
/// Private copy-constructor
CollisionWorld(const CollisionWorld& world);
/// Private assignment operator
CollisionWorld& operator=(const CollisionWorld& world);
/// Return the next available body ID
bodyindex computeNextAvailableBodyID();
/// Reset all the contact manifolds linked list of each body
void resetContactManifoldListsOfBodies();
public :
/// Constructor
CollisionWorld();
/// Destructor
virtual ~CollisionWorld();
/**
* @brief Get an iterator to the beginning of the bodies of the physics world
* @return An starting iterator to the set of bodies of the world
*/
etk::Set<CollisionBody*>::Iterator getBodiesBeginIterator() {
return m_bodies.begin();
}
/**
* @brief Get an iterator to the end of the bodies of the physics world
* @return An ending iterator to the set of bodies of the world
*/
etk::Set<CollisionBody*>::Iterator getBodiesEndIterator() {
return m_bodies.end();
}
/// Create a collision body
CollisionBody* createCollisionBody(const etk::Transform3D& transform);
/// Destroy a collision body
void destroyCollisionBody(CollisionBody* collisionBody);
/**
* @brief Set the collision dispatch configuration
* This can be used to replace default collision detection algorithms by your
* custom algorithm for instance.
* @param[in] _CollisionDispatch Pointer to a collision dispatch object describing
* which collision detection algorithm to use for two given collision shapes
*/
void setCollisionDispatch(CollisionDispatch* _collisionDispatch) {
m_collisionDetection.setCollisionDispatch(_collisionDispatch);
}
/**
* @brief Ray cast method
* @param _ray Ray to use for raycasting
* @param _raycastCallback Pointer to the class with the callback method
* @param _raycastWithCategoryMaskBits Bits mask corresponding to the category of bodies to be raycasted
*/
void raycast(const Ray& _ray,
RaycastCallback* _raycastCallback,
unsigned short _raycastWithCategoryMaskBits = 0xFFFF) const {
m_collisionDetection.raycast(_raycastCallback, _ray, _raycastWithCategoryMaskBits);
}
/// Test if the AABBs of two bodies overlap
bool testAABBOverlap(const CollisionBody* _body1,
const CollisionBody* _body2) const;
/**
* @brief Test if the AABBs of two proxy shapes overlap
* @param _shape1 Pointer to the first proxy shape to test
* @param _shape2 Pointer to the second proxy shape to test
*/
bool testAABBOverlap(const ProxyShape* _shape1,
const ProxyShape* _shape2) const {
return m_collisionDetection.testAABBOverlap(_shape1, _shape2);
}
/// Test and report collisions between a given shape and all the others
/// shapes of the world
virtual void testCollision(const ProxyShape* _shape,
CollisionCallback* _callback);
/// Test and report collisions between two given shapes
virtual void testCollision(const ProxyShape* _shape1,
const ProxyShape* _shape2,
CollisionCallback* _callback);
/// Test and report collisions between a body and all the others bodies of the
/// world
virtual void testCollision(const CollisionBody* _body,
CollisionCallback* _callback);
/// Test and report collisions between two bodies
virtual void testCollision(const CollisionBody* _body1,
const CollisionBody* _body2,
CollisionCallback* _callback);
/// Test and report collisions between all shapes of the world
virtual void testCollision(CollisionCallback* _callback);
friend class CollisionDetection;
friend class CollisionBody;
friend class RigidBody;
friend class ConvexMeshShape;
};
/**
* @brief This class can be used to register a callback for collision test queries.
* You should implement your own class inherited from this one and implement
* the notifyRaycastHit() method. This method will be called for each ProxyShape
* that is hit by the ray.
*/
class CollisionCallback {
public:
/**
* @brief Virtualisation of the destructor.
*/
virtual ~CollisionCallback() = default;
/**
* @brief This method will be called for contact.
* @param[in] _contactPointInfo Contact information property.
*/
virtual void notifyContact(const ContactPointInfo& _contactPointInfo)=0;
};
}