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
84 lines
4.6 KiB
C++
84 lines
4.6 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 <ephysics/collision/narrowphase/NarrowPhaseAlgorithm.hpp>
|
|
#include <ephysics/constraint/ContactPoint.hpp>
|
|
#include <ephysics/collision/shapes/ConvexShape.hpp>
|
|
#include <ephysics/collision/narrowphase/EPA/EPAAlgorithm.hpp>
|
|
|
|
namespace ephysics {
|
|
const float REL_ERROR = float(1.0e-3);
|
|
const float REL_ERROR_SQUARE = REL_ERROR * REL_ERROR;
|
|
const int32_t MAX_ITERATIONS_GJK_RAYCAST = 32;
|
|
/**
|
|
* @brief This class implements a narrow-phase collision detection algorithm. This
|
|
* algorithm uses the ISA-GJK algorithm and the EPA algorithm. This
|
|
* implementation is based on the implementation discussed in the book
|
|
* "Collision Detection in Interactive 3D Environments" by Gino van den Bergen.
|
|
* This method implements the Hybrid Technique for calculating the
|
|
* penetration depth. The two objects are enlarged with a small margin. If
|
|
* the object int32_tersects in their margins, the penetration depth is quickly
|
|
* computed using the GJK algorithm on the original objects (without margin).
|
|
* If the original objects (without margin) int32_tersect, we run again the GJK
|
|
* algorithm on the enlarged objects (with margin) to compute simplex
|
|
* polytope that contains the origin and give it to the EPA (Expanding
|
|
* Polytope Algorithm) to compute the correct penetration depth between the
|
|
* enlarged objects.
|
|
*/
|
|
class GJKAlgorithm : public NarrowPhaseAlgorithm {
|
|
private :
|
|
EPAAlgorithm m_algoEPA; //!< EPA Algorithm
|
|
/// Private copy-constructor
|
|
GJKAlgorithm(const GJKAlgorithm& algorithm);
|
|
/// Private assignment operator
|
|
GJKAlgorithm& operator=(const GJKAlgorithm& algorithm);
|
|
/// This method runs the GJK algorithm on the two enlarged objects (with margin)
|
|
/// to compute a simplex polytope that contains the origin. The two objects are
|
|
/// assumed to int32_tersect in the original objects (without margin). Therefore such
|
|
/// a polytope must exist. Then, we give that polytope to the EPA algorithm to
|
|
/// compute the correct penetration depth and contact points of the enlarged objects.
|
|
void computePenetrationDepthForEnlargedObjects(const CollisionShapeInfo& shape1Info,
|
|
const etk::Transform3D& transform1,
|
|
const CollisionShapeInfo& shape2Info,
|
|
const etk::Transform3D& transform2,
|
|
NarrowPhaseCallback* narrowPhaseCallback,
|
|
vec3& v);
|
|
public :
|
|
/// Constructor
|
|
GJKAlgorithm();
|
|
/// Destructor
|
|
~GJKAlgorithm();
|
|
/// Initalize the algorithm
|
|
virtual void init(CollisionDetection* _collisionDetection) {
|
|
NarrowPhaseAlgorithm::init(_collisionDetection);
|
|
m_algoEPA.init();
|
|
};
|
|
// Compute a contact info if the two collision shapes collide.
|
|
/// This method implements the Hybrid Technique for computing the penetration depth by
|
|
/// running the GJK algorithm on original objects (without margin). If the shapes int32_tersect
|
|
/// only in the margins, the method compute the penetration depth and contact points
|
|
/// (of enlarged objects). If the original objects (without margin) int32_tersect, we
|
|
/// call the computePenetrationDepthForEnlargedObjects() method that run the GJK
|
|
/// algorithm on the enlarged object to obtain a simplex polytope that contains the
|
|
/// origin, they we give that simplex polytope to the EPA algorithm which will compute
|
|
/// the correct penetration depth and contact points between the enlarged objects.
|
|
virtual void testCollision(const CollisionShapeInfo& shape1Info,
|
|
const CollisionShapeInfo& shape2Info,
|
|
NarrowPhaseCallback* narrowPhaseCallback);
|
|
/// Use the GJK Algorithm to find if a point is inside a convex collision shape
|
|
bool testPointInside(const vec3& localPoint, ProxyShape* proxyShape);
|
|
/// Ray casting algorithm agains a convex collision shape using the GJK Algorithm
|
|
/// This method implements the GJK ray casting algorithm described by Gino Van Den Bergen in
|
|
/// "Ray Casting against General Convex Objects with Application to Continuous Collision Detection".
|
|
bool raycast(const Ray& ray, ProxyShape* proxyShape, RaycastInfo& raycastInfo);
|
|
};
|
|
}
|
|
|