godot/modules/godot_physics_3d/gjk_epa.cpp

/**************************************************************************/
/*  gjk_epa.cpp                                                           */
/**************************************************************************/
/*                         This file is part of:                          */
/*                             GODOT ENGINE                               */
/*                        https://godotengine.org                         */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */
/*                                                                        */
/* Permission is hereby granted, free of charge, to any person obtaining  */
/* a copy of this software and associated documentation files (the        */
/* "Software"), to deal in the Software without restriction, including    */
/* without limitation the rights to use, copy, modify, merge, publish,    */
/* distribute, sublicense, and/or sell copies of the Software, and to     */
/* permit persons to whom the Software is furnished to do so, subject to  */
/* the following conditions:                                              */
/*                                                                        */
/* The above copyright notice and this permission notice shall be         */
/* included in all copies or substantial portions of the Software.        */
/*                                                                        */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */
/**************************************************************************/

#include "gjk_epa.h"

/* Disabling formatting for thirdparty code snippet */
/* clang-format off */

/*************** Bullet's GJK-EPA2 IMPLEMENTATION *******************/

/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the
use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software in a
product, an acknowledgment in the product documentation would be appreciated
but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/

/*
GJK-EPA collision solver by Nathanael Presson, 2008
*/

	// Config

/* GJK	*/
#define GJK_MAX_ITERATIONS
#define GJK_ACCURACY
#define GJK_MIN_DISTANCE
#define GJK_DUPLICATED_EPS
#define GJK_SIMPLEX2_EPS
#define GJK_SIMPLEX3_EPS
#define GJK_SIMPLEX4_EPS

/* EPA	*/
#define EPA_MAX_VERTICES
#define EPA_MAX_FACES
#define EPA_MAX_ITERATIONS
// -- GODOT start --
//#define EPA_ACCURACY		((real_t)0.0001)
#define EPA_ACCURACY
// -- GODOT end --
#define EPA_FALLBACK
#define EPA_PLANE_EPS
#define EPA_INSIDE_EPS

namespace GjkEpa2 {


struct sResults	{};

// Shorthands
U;
U1;

// MinkowskiDiff
struct	MinkowskiDiff {};

tShape;


// GJK
struct	GJK
{};

	// EPA
	struct	EPA
	{};

	//
	static void	Initialize(	const GodotShape3D* shape0, const Transform3D& wtrs0, real_t margin0,
		const GodotShape3D* shape1, const Transform3D& wtrs1, real_t margin1,
		sResults& results,
		tShape& shape)
	{}



//
// Api
//

//

//
bool Distance(	const GodotShape3D*	shape0,
									  const Transform3D&		wtrs0,
									  real_t				margin0,
									  const GodotShape3D*		shape1,
									  const Transform3D&		wtrs1,
									  real_t				margin1,
									  const Vector3&		guess,
									  sResults&				results)
{}


//
bool Penetration(	const GodotShape3D*	shape0,
									 const Transform3D&		wtrs0,
									 real_t					margin0,
									 const GodotShape3D*		shape1,
									 const Transform3D&		wtrs1,
									 real_t					margin1,
									 const Vector3&			guess,
									 sResults&				results
									)
{}



/* Symbols cleanup		*/

#undef GJK_MAX_ITERATIONS
#undef GJK_ACCURARY
#undef GJK_MIN_DISTANCE
#undef GJK_DUPLICATED_EPS
#undef GJK_SIMPLEX2_EPS
#undef GJK_SIMPLEX3_EPS
#undef GJK_SIMPLEX4_EPS

#undef EPA_MAX_VERTICES
#undef EPA_MAX_FACES
#undef EPA_MAX_ITERATIONS
#undef EPA_ACCURACY
#undef EPA_FALLBACK
#undef EPA_PLANE_EPS
#undef EPA_INSIDE_EPS
} // end of namespace

/* clang-format on */

bool gjk_epa_calculate_distance(const GodotShape3D *p_shape_A, const Transform3D &p_transform_A, const GodotShape3D *p_shape_B, const Transform3D &p_transform_B, Vector3 &r_result_A, Vector3 &r_result_B) {}

bool gjk_epa_calculate_penetration(const GodotShape3D *p_shape_A, const Transform3D &p_transform_A, const GodotShape3D *p_shape_B, const Transform3D &p_transform_B, GodotCollisionSolver3D::CallbackResult p_result_callback, void *p_userdata, bool p_swap, real_t p_margin_A, real_t p_margin_B) {}