godot/modules/godot_physics_3d/godot_shape_3d.cpp

/**************************************************************************/
/*  godot_shape_3d.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 "godot_shape_3d.h"

#include "core/io/image.h"
#include "core/math/convex_hull.h"
#include "core/math/geometry_3d.h"
#include "core/templates/sort_array.h"

// GodotHeightMapShape3D is based on Bullet btHeightfieldTerrainShape.

/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org

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.
*/

const double edge_support_threshold =;
const double edge_support_threshold_lower =;
// For a unit normal vector n, the horizontality condition
//     sqrt(n.x * n.x + n.z * n.z) > edge_support_threshold
// is equivalent to the condition
//     abs(n.y) < edge_support_threshold_lower,
// which is cheaper to test.
const double face_support_threshold =;

const double cylinder_edge_support_threshold =;
const double cylinder_edge_support_threshold_lower =;
const double cylinder_face_support_threshold =;

void GodotShape3D::configure(const AABB &p_aabb) {}

Vector3 GodotShape3D::get_support(const Vector3 &p_normal) const {}

void GodotShape3D::add_owner(GodotShapeOwner3D *p_owner) {}

void GodotShape3D::remove_owner(GodotShapeOwner3D *p_owner) {}

bool GodotShape3D::is_owner(GodotShapeOwner3D *p_owner) const {}

const HashMap<GodotShapeOwner3D *, int> &GodotShape3D::get_owners() const {}

GodotShape3D::~GodotShape3D() {}

Plane GodotWorldBoundaryShape3D::get_plane() const {}

void GodotWorldBoundaryShape3D::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {}

Vector3 GodotWorldBoundaryShape3D::get_support(const Vector3 &p_normal) const {}

bool GodotWorldBoundaryShape3D::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal, int &r_face_index, bool p_hit_back_faces) const {}

bool GodotWorldBoundaryShape3D::intersect_point(const Vector3 &p_point) const {}

Vector3 GodotWorldBoundaryShape3D::get_closest_point_to(const Vector3 &p_point) const {}

Vector3 GodotWorldBoundaryShape3D::get_moment_of_inertia(real_t p_mass) const {}

void GodotWorldBoundaryShape3D::_setup(const Plane &p_plane) {}

void GodotWorldBoundaryShape3D::set_data(const Variant &p_data) {}

Variant GodotWorldBoundaryShape3D::get_data() const {}

GodotWorldBoundaryShape3D::GodotWorldBoundaryShape3D() {}

//

real_t GodotSeparationRayShape3D::get_length() const {}

bool GodotSeparationRayShape3D::get_slide_on_slope() const {}

void GodotSeparationRayShape3D::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {}

Vector3 GodotSeparationRayShape3D::get_support(const Vector3 &p_normal) const {}

void GodotSeparationRayShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const {}

bool GodotSeparationRayShape3D::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal, int &r_face_index, bool p_hit_back_faces) const {}

bool GodotSeparationRayShape3D::intersect_point(const Vector3 &p_point) const {}

Vector3 GodotSeparationRayShape3D::get_closest_point_to(const Vector3 &p_point) const {}

Vector3 GodotSeparationRayShape3D::get_moment_of_inertia(real_t p_mass) const {}

void GodotSeparationRayShape3D::_setup(real_t p_length, bool p_slide_on_slope) {}

void GodotSeparationRayShape3D::set_data(const Variant &p_data) {}

Variant GodotSeparationRayShape3D::get_data() const {}

GodotSeparationRayShape3D::GodotSeparationRayShape3D() {}

/********** SPHERE *************/

real_t GodotSphereShape3D::get_radius() const {}

void GodotSphereShape3D::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {}

Vector3 GodotSphereShape3D::get_support(const Vector3 &p_normal) const {}

void GodotSphereShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const {}

bool GodotSphereShape3D::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal, int &r_face_index, bool p_hit_back_faces) const {}

bool GodotSphereShape3D::intersect_point(const Vector3 &p_point) const {}

Vector3 GodotSphereShape3D::get_closest_point_to(const Vector3 &p_point) const {}

Vector3 GodotSphereShape3D::get_moment_of_inertia(real_t p_mass) const {}

void GodotSphereShape3D::_setup(real_t p_radius) {}

void GodotSphereShape3D::set_data(const Variant &p_data) {}

Variant GodotSphereShape3D::get_data() const {}

GodotSphereShape3D::GodotSphereShape3D() {}

/********** BOX *************/

void GodotBoxShape3D::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {}

Vector3 GodotBoxShape3D::get_support(const Vector3 &p_normal) const {}

void GodotBoxShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const {}

bool GodotBoxShape3D::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal, int &r_face_index, bool p_hit_back_faces) const {}

bool GodotBoxShape3D::intersect_point(const Vector3 &p_point) const {}

Vector3 GodotBoxShape3D::get_closest_point_to(const Vector3 &p_point) const {}

Vector3 GodotBoxShape3D::get_moment_of_inertia(real_t p_mass) const {}

void GodotBoxShape3D::_setup(const Vector3 &p_half_extents) {}

void GodotBoxShape3D::set_data(const Variant &p_data) {}

Variant GodotBoxShape3D::get_data() const {}

GodotBoxShape3D::GodotBoxShape3D() {}

/********** CAPSULE *************/

void GodotCapsuleShape3D::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {}

Vector3 GodotCapsuleShape3D::get_support(const Vector3 &p_normal) const {}

void GodotCapsuleShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const {}

bool GodotCapsuleShape3D::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal, int &r_face_index, bool p_hit_back_faces) const {}

bool GodotCapsuleShape3D::intersect_point(const Vector3 &p_point) const {}

Vector3 GodotCapsuleShape3D::get_closest_point_to(const Vector3 &p_point) const {}

Vector3 GodotCapsuleShape3D::get_moment_of_inertia(real_t p_mass) const {}

void GodotCapsuleShape3D::_setup(real_t p_height, real_t p_radius) {}

void GodotCapsuleShape3D::set_data(const Variant &p_data) {}

Variant GodotCapsuleShape3D::get_data() const {}

GodotCapsuleShape3D::GodotCapsuleShape3D() {}

/********** CYLINDER *************/

void GodotCylinderShape3D::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {}

Vector3 GodotCylinderShape3D::get_support(const Vector3 &p_normal) const {}

void GodotCylinderShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const {}

bool GodotCylinderShape3D::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal, int &r_face_index, bool p_hit_back_faces) const {}

bool GodotCylinderShape3D::intersect_point(const Vector3 &p_point) const {}

Vector3 GodotCylinderShape3D::get_closest_point_to(const Vector3 &p_point) const {}

Vector3 GodotCylinderShape3D::get_moment_of_inertia(real_t p_mass) const {}

void GodotCylinderShape3D::_setup(real_t p_height, real_t p_radius) {}

void GodotCylinderShape3D::set_data(const Variant &p_data) {}

Variant GodotCylinderShape3D::get_data() const {}

GodotCylinderShape3D::GodotCylinderShape3D() {}

/********** CONVEX POLYGON *************/

void GodotConvexPolygonShape3D::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {}

Vector3 GodotConvexPolygonShape3D::get_support(const Vector3 &p_normal) const {}

void GodotConvexPolygonShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const {}

bool GodotConvexPolygonShape3D::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal, int &r_face_index, bool p_hit_back_faces) const {}

bool GodotConvexPolygonShape3D::intersect_point(const Vector3 &p_point) const {}

Vector3 GodotConvexPolygonShape3D::get_closest_point_to(const Vector3 &p_point) const {}

Vector3 GodotConvexPolygonShape3D::get_moment_of_inertia(real_t p_mass) const {}

void GodotConvexPolygonShape3D::_setup(const Vector<Vector3> &p_vertices) {}

void GodotConvexPolygonShape3D::set_data(const Variant &p_data) {}

Variant GodotConvexPolygonShape3D::get_data() const {}

GodotConvexPolygonShape3D::GodotConvexPolygonShape3D() {}

/********** FACE POLYGON *************/

void GodotFaceShape3D::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {}

Vector3 GodotFaceShape3D::get_support(const Vector3 &p_normal) const {}

void GodotFaceShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const {}

bool GodotFaceShape3D::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal, int &r_face_index, bool p_hit_back_faces) const {}

bool GodotFaceShape3D::intersect_point(const Vector3 &p_point) const {}

Vector3 GodotFaceShape3D::get_closest_point_to(const Vector3 &p_point) const {}

Vector3 GodotFaceShape3D::get_moment_of_inertia(real_t p_mass) const {}

GodotFaceShape3D::GodotFaceShape3D() {}

Vector<Vector3> GodotConcavePolygonShape3D::get_faces() const {}

void GodotConcavePolygonShape3D::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {}

Vector3 GodotConcavePolygonShape3D::get_support(const Vector3 &p_normal) const {}

void GodotConcavePolygonShape3D::_cull_segment(int p_idx, _SegmentCullParams *p_params) const {}

bool GodotConcavePolygonShape3D::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal, int &r_face_index, bool p_hit_back_faces) const {}

bool GodotConcavePolygonShape3D::intersect_point(const Vector3 &p_point) const {}

Vector3 GodotConcavePolygonShape3D::get_closest_point_to(const Vector3 &p_point) const {}

bool GodotConcavePolygonShape3D::_cull(int p_idx, _CullParams *p_params) const {}

void GodotConcavePolygonShape3D::cull(const AABB &p_local_aabb, QueryCallback p_callback, void *p_userdata, bool p_invert_backface_collision) const {}

Vector3 GodotConcavePolygonShape3D::get_moment_of_inertia(real_t p_mass) const {}

struct _Volume_BVH_Element {};

struct _Volume_BVH_CompareX {};

struct _Volume_BVH_CompareY {};

struct _Volume_BVH_CompareZ {};

struct _Volume_BVH {};

_Volume_BVH *_volume_build_bvh(_Volume_BVH_Element *p_elements, int p_size, int &count) {}

void GodotConcavePolygonShape3D::_fill_bvh(_Volume_BVH *p_bvh_tree, BVH *p_bvh_array, int &p_idx) {}

void GodotConcavePolygonShape3D::_setup(const Vector<Vector3> &p_faces, bool p_backface_collision) {}

void GodotConcavePolygonShape3D::set_data(const Variant &p_data) {}

Variant GodotConcavePolygonShape3D::get_data() const {}

GodotConcavePolygonShape3D::GodotConcavePolygonShape3D() {}

/* HEIGHT MAP SHAPE */

Vector<real_t> GodotHeightMapShape3D::get_heights() const {}

int GodotHeightMapShape3D::get_width() const {}

int GodotHeightMapShape3D::get_depth() const {}

void GodotHeightMapShape3D::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {}

Vector3 GodotHeightMapShape3D::get_support(const Vector3 &p_normal) const {}

struct _HeightmapSegmentCullParams {};

struct _HeightmapGridCullState {};

_FORCE_INLINE_ bool _heightmap_face_cull_segment(_HeightmapSegmentCullParams &p_params) {}

_FORCE_INLINE_ bool _heightmap_cell_cull_segment(_HeightmapSegmentCullParams &p_params, const _HeightmapGridCullState &p_state) {}

_FORCE_INLINE_ bool _heightmap_chunk_cull_segment(_HeightmapSegmentCullParams &p_params, const _HeightmapGridCullState &p_state) {}

template <typename ProcessFunction>
bool GodotHeightMapShape3D::_intersect_grid_segment(ProcessFunction &p_process, const Vector3 &p_begin, const Vector3 &p_end, int p_width, int p_depth, const Vector3 &offset, Vector3 &r_point, Vector3 &r_normal) const {}

bool GodotHeightMapShape3D::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal, int &r_face_index, bool p_hit_back_faces) const {}

bool GodotHeightMapShape3D::intersect_point(const Vector3 &p_point) const {}

Vector3 GodotHeightMapShape3D::get_closest_point_to(const Vector3 &p_point) const {}

void GodotHeightMapShape3D::_get_cell(const Vector3 &p_point, int &r_x, int &r_y, int &r_z) const {}

void GodotHeightMapShape3D::cull(const AABB &p_local_aabb, QueryCallback p_callback, void *p_userdata, bool p_invert_backface_collision) const {}

Vector3 GodotHeightMapShape3D::get_moment_of_inertia(real_t p_mass) const {}

void GodotHeightMapShape3D::_build_accelerator() {}

void GodotHeightMapShape3D::_setup(const Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {}

void GodotHeightMapShape3D::set_data(const Variant &p_data) {}

Variant GodotHeightMapShape3D::get_data() const {}

GodotHeightMapShape3D::GodotHeightMapShape3D() {}