/**************************************************************************/ /* godot_body_pair_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_body_pair_3d.h" #include "godot_collision_solver_3d.h" #include "godot_space_3d.h" #include "core/os/os.h" #define MIN_VELOCITY … #define MAX_BIAS_ROTATION … void GodotBodyPair3D::_contact_added_callback(const Vector3 &p_point_A, int p_index_A, const Vector3 &p_point_B, int p_index_B, const Vector3 &normal, void *p_userdata) { … } void GodotBodyPair3D::contact_added_callback(const Vector3 &p_point_A, int p_index_A, const Vector3 &p_point_B, int p_index_B, const Vector3 &normal) { … } void GodotBodyPair3D::validate_contacts() { … } // `_test_ccd` prevents tunneling by slowing down a high velocity body that is about to collide so // that next frame it will be at an appropriate location to collide (i.e. slight overlap). // WARNING: The way velocity is adjusted down to cause a collision means the momentum will be // weaker than it should for a bounce! // Process: Only proceed if body A's motion is high relative to its size. // Cast forward along motion vector to see if A is going to enter/pass B's collider next frame, only proceed if it does. // Adjust the velocity of A down so that it will just slightly intersect the collider instead of blowing right past it. bool GodotBodyPair3D::_test_ccd(real_t p_step, GodotBody3D *p_A, int p_shape_A, const Transform3D &p_xform_A, GodotBody3D *p_B, int p_shape_B, const Transform3D &p_xform_B) { … } real_t combine_bounce(GodotBody3D *A, GodotBody3D *B) { … } real_t combine_friction(GodotBody3D *A, GodotBody3D *B) { … } bool GodotBodyPair3D::setup(real_t p_step) { … } bool GodotBodyPair3D::pre_solve(real_t p_step) { … } void GodotBodyPair3D::solve(real_t p_step) { … } GodotBodyPair3D::GodotBodyPair3D(GodotBody3D *p_A, int p_shape_A, GodotBody3D *p_B, int p_shape_B) : … { … } GodotBodyPair3D::~GodotBodyPair3D() { … } void GodotBodySoftBodyPair3D::_contact_added_callback(const Vector3 &p_point_A, int p_index_A, const Vector3 &p_point_B, int p_index_B, const Vector3 &normal, void *p_userdata) { … } void GodotBodySoftBodyPair3D::contact_added_callback(const Vector3 &p_point_A, int p_index_A, const Vector3 &p_point_B, int p_index_B, const Vector3 &normal) { … } void GodotBodySoftBodyPair3D::validate_contacts() { … } bool GodotBodySoftBodyPair3D::setup(real_t p_step) { … } bool GodotBodySoftBodyPair3D::pre_solve(real_t p_step) { … } void GodotBodySoftBodyPair3D::solve(real_t p_step) { … } GodotBodySoftBodyPair3D::GodotBodySoftBodyPair3D(GodotBody3D *p_A, int p_shape_A, GodotSoftBody3D *p_B) : … { … } GodotBodySoftBodyPair3D::~GodotBodySoftBodyPair3D() { … }