Path: blob/master/modules/jolt_physics/jolt_physics_server_3d.cpp
20951 views
/**************************************************************************/1/* jolt_physics_server_3d.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#include "jolt_physics_server_3d.h"3132#include "joints/jolt_cone_twist_joint_3d.h"33#include "joints/jolt_generic_6dof_joint_3d.h"34#include "joints/jolt_hinge_joint_3d.h"35#include "joints/jolt_joint_3d.h"36#include "joints/jolt_pin_joint_3d.h"37#include "joints/jolt_slider_joint_3d.h"38#include "objects/jolt_area_3d.h"39#include "objects/jolt_body_3d.h"40#include "objects/jolt_soft_body_3d.h"41#include "servers/physics_3d/physics_server_3d_wrap_mt.h"42#include "shapes/jolt_box_shape_3d.h"43#include "shapes/jolt_capsule_shape_3d.h"44#include "shapes/jolt_concave_polygon_shape_3d.h"45#include "shapes/jolt_convex_polygon_shape_3d.h"46#include "shapes/jolt_cylinder_shape_3d.h"47#include "shapes/jolt_height_map_shape_3d.h"48#include "shapes/jolt_separation_ray_shape_3d.h"49#include "shapes/jolt_sphere_shape_3d.h"50#include "shapes/jolt_world_boundary_shape_3d.h"51#include "spaces/jolt_job_system.h"52#include "spaces/jolt_physics_direct_space_state_3d.h"53#include "spaces/jolt_space_3d.h"5455JoltPhysicsServer3D::JoltPhysicsServer3D(bool p_on_separate_thread) :56on_separate_thread(p_on_separate_thread) {57singleton = this;58}5960JoltPhysicsServer3D::~JoltPhysicsServer3D() {61if (singleton == this) {62singleton = nullptr;63}64}6566RID JoltPhysicsServer3D::world_boundary_shape_create() {67JoltShape3D *shape = memnew(JoltWorldBoundaryShape3D);68RID rid = shape_owner.make_rid(shape);69shape->set_rid(rid);70return rid;71}7273RID JoltPhysicsServer3D::separation_ray_shape_create() {74JoltShape3D *shape = memnew(JoltSeparationRayShape3D);75RID rid = shape_owner.make_rid(shape);76shape->set_rid(rid);77return rid;78}7980RID JoltPhysicsServer3D::sphere_shape_create() {81JoltShape3D *shape = memnew(JoltSphereShape3D);82RID rid = shape_owner.make_rid(shape);83shape->set_rid(rid);84return rid;85}8687RID JoltPhysicsServer3D::box_shape_create() {88JoltShape3D *shape = memnew(JoltBoxShape3D);89RID rid = shape_owner.make_rid(shape);90shape->set_rid(rid);91return rid;92}9394RID JoltPhysicsServer3D::capsule_shape_create() {95JoltShape3D *shape = memnew(JoltCapsuleShape3D);96RID rid = shape_owner.make_rid(shape);97shape->set_rid(rid);98return rid;99}100101RID JoltPhysicsServer3D::cylinder_shape_create() {102JoltShape3D *shape = memnew(JoltCylinderShape3D);103RID rid = shape_owner.make_rid(shape);104shape->set_rid(rid);105return rid;106}107108RID JoltPhysicsServer3D::convex_polygon_shape_create() {109JoltShape3D *shape = memnew(JoltConvexPolygonShape3D);110RID rid = shape_owner.make_rid(shape);111shape->set_rid(rid);112return rid;113}114115RID JoltPhysicsServer3D::concave_polygon_shape_create() {116JoltShape3D *shape = memnew(JoltConcavePolygonShape3D);117RID rid = shape_owner.make_rid(shape);118shape->set_rid(rid);119return rid;120}121122RID JoltPhysicsServer3D::heightmap_shape_create() {123JoltShape3D *shape = memnew(JoltHeightMapShape3D);124RID rid = shape_owner.make_rid(shape);125shape->set_rid(rid);126return rid;127}128129RID JoltPhysicsServer3D::custom_shape_create() {130ERR_FAIL_V_MSG(RID(), "Custom shapes are not supported.");131}132133void JoltPhysicsServer3D::shape_set_data(RID p_shape, const Variant &p_data) {134JoltShape3D *shape = shape_owner.get_or_null(p_shape);135ERR_FAIL_NULL(shape);136137shape->set_data(p_data);138}139140Variant JoltPhysicsServer3D::shape_get_data(RID p_shape) const {141const JoltShape3D *shape = shape_owner.get_or_null(p_shape);142ERR_FAIL_NULL_V(shape, Variant());143144return shape->get_data();145}146147void JoltPhysicsServer3D::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {148JoltShape3D *shape = shape_owner.get_or_null(p_shape);149ERR_FAIL_NULL(shape);150151shape->set_solver_bias((float)p_bias);152}153154PhysicsServer3D::ShapeType JoltPhysicsServer3D::shape_get_type(RID p_shape) const {155const JoltShape3D *shape = shape_owner.get_or_null(p_shape);156ERR_FAIL_NULL_V(shape, SHAPE_CUSTOM);157158return shape->get_type();159}160161void JoltPhysicsServer3D::shape_set_margin(RID p_shape, real_t p_margin) {162JoltShape3D *shape = shape_owner.get_or_null(p_shape);163ERR_FAIL_NULL(shape);164165shape->set_margin((float)p_margin);166}167168real_t JoltPhysicsServer3D::shape_get_margin(RID p_shape) const {169const JoltShape3D *shape = shape_owner.get_or_null(p_shape);170ERR_FAIL_NULL_V(shape, 0.0);171172return (real_t)shape->get_margin();173}174175real_t JoltPhysicsServer3D::shape_get_custom_solver_bias(RID p_shape) const {176const JoltShape3D *shape = shape_owner.get_or_null(p_shape);177ERR_FAIL_NULL_V(shape, 0.0);178179return (real_t)shape->get_solver_bias();180}181182RID JoltPhysicsServer3D::space_create() {183JoltSpace3D *space = memnew(JoltSpace3D(job_system));184RID rid = space_owner.make_rid(space);185space->set_rid(rid);186187const RID default_area_rid = area_create();188JoltArea3D *default_area = area_owner.get_or_null(default_area_rid);189ERR_FAIL_NULL_V(default_area, RID());190space->set_default_area(default_area);191default_area->set_space(space);192193return rid;194}195196void JoltPhysicsServer3D::space_set_active(RID p_space, bool p_active) {197JoltSpace3D *space = space_owner.get_or_null(p_space);198ERR_FAIL_NULL(space);199200if (p_active) {201space->set_active(true);202active_spaces.insert(space);203} else {204space->set_active(false);205active_spaces.erase(space);206}207}208209bool JoltPhysicsServer3D::space_is_active(RID p_space) const {210JoltSpace3D *space = space_owner.get_or_null(p_space);211ERR_FAIL_NULL_V(space, false);212213return active_spaces.has(space);214}215216void JoltPhysicsServer3D::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {217JoltSpace3D *space = space_owner.get_or_null(p_space);218ERR_FAIL_NULL(space);219220space->set_param(p_param, (double)p_value);221}222223real_t JoltPhysicsServer3D::space_get_param(RID p_space, SpaceParameter p_param) const {224const JoltSpace3D *space = space_owner.get_or_null(p_space);225ERR_FAIL_NULL_V(space, 0.0);226227return (real_t)space->get_param(p_param);228}229230PhysicsDirectSpaceState3D *JoltPhysicsServer3D::space_get_direct_state(RID p_space) {231JoltSpace3D *space = space_owner.get_or_null(p_space);232ERR_FAIL_NULL_V(space, nullptr);233ERR_FAIL_COND_V_MSG((on_separate_thread && !doing_sync) || space->is_stepping(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification.");234235return space->get_direct_state();236}237238void JoltPhysicsServer3D::space_set_debug_contacts(RID p_space, int p_max_contacts) {239#ifdef DEBUG_ENABLED240JoltSpace3D *space = space_owner.get_or_null(p_space);241ERR_FAIL_NULL(space);242243space->set_max_debug_contacts(p_max_contacts);244#endif245}246247PackedVector3Array JoltPhysicsServer3D::space_get_contacts(RID p_space) const {248#ifdef DEBUG_ENABLED249JoltSpace3D *space = space_owner.get_or_null(p_space);250ERR_FAIL_NULL_V(space, PackedVector3Array());251252return space->get_debug_contacts();253#else254return PackedVector3Array();255#endif256}257258int JoltPhysicsServer3D::space_get_contact_count(RID p_space) const {259#ifdef DEBUG_ENABLED260JoltSpace3D *space = space_owner.get_or_null(p_space);261ERR_FAIL_NULL_V(space, 0);262263return space->get_debug_contact_count();264#else265return 0;266#endif267}268269RID JoltPhysicsServer3D::area_create() {270JoltArea3D *area = memnew(JoltArea3D);271RID rid = area_owner.make_rid(area);272area->set_rid(rid);273return rid;274}275276void JoltPhysicsServer3D::area_set_space(RID p_area, RID p_space) {277JoltArea3D *area = area_owner.get_or_null(p_area);278ERR_FAIL_NULL(area);279280JoltSpace3D *space = nullptr;281282if (p_space.is_valid()) {283space = space_owner.get_or_null(p_space);284ERR_FAIL_NULL(space);285}286287area->set_space(space);288}289290void JoltPhysicsServer3D::soft_body_apply_point_impulse(RID p_body, int p_point_index, const Vector3 &p_impulse) {291JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);292ERR_FAIL_NULL(body);293294body->apply_vertex_impulse(p_point_index, p_impulse);295}296297void JoltPhysicsServer3D::soft_body_apply_point_force(RID p_body, int p_point_index, const Vector3 &p_force) {298JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);299ERR_FAIL_NULL(body);300301body->apply_vertex_force(p_point_index, p_force);302}303304void JoltPhysicsServer3D::soft_body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) {305JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);306ERR_FAIL_NULL(body);307308body->apply_central_impulse(p_impulse);309}310311void JoltPhysicsServer3D::soft_body_apply_central_force(RID p_body, const Vector3 &p_force) {312JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);313ERR_FAIL_NULL(body);314315body->apply_central_force(p_force);316}317318RID JoltPhysicsServer3D::area_get_space(RID p_area) const {319const JoltArea3D *area = area_owner.get_or_null(p_area);320ERR_FAIL_NULL_V(area, RID());321322const JoltSpace3D *space = area->get_space();323324if (space == nullptr) {325return RID();326}327328return space->get_rid();329}330331void JoltPhysicsServer3D::area_add_shape(RID p_area, RID p_shape, const Transform3D &p_transform, bool p_disabled) {332JoltArea3D *area = area_owner.get_or_null(p_area);333ERR_FAIL_NULL(area);334335JoltShape3D *shape = shape_owner.get_or_null(p_shape);336ERR_FAIL_NULL(shape);337338area->add_shape(shape, p_transform, p_disabled);339}340341void JoltPhysicsServer3D::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {342JoltArea3D *area = area_owner.get_or_null(p_area);343ERR_FAIL_NULL(area);344345JoltShape3D *shape = shape_owner.get_or_null(p_shape);346ERR_FAIL_NULL(shape);347348area->set_shape(p_shape_idx, shape);349}350351RID JoltPhysicsServer3D::area_get_shape(RID p_area, int p_shape_idx) const {352const JoltArea3D *area = area_owner.get_or_null(p_area);353ERR_FAIL_NULL_V(area, RID());354355const JoltShape3D *shape = area->get_shape(p_shape_idx);356ERR_FAIL_NULL_V(shape, RID());357358return shape->get_rid();359}360361void JoltPhysicsServer3D::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform3D &p_transform) {362JoltArea3D *area = area_owner.get_or_null(p_area);363ERR_FAIL_NULL(area);364365area->set_shape_transform(p_shape_idx, p_transform);366}367368Transform3D JoltPhysicsServer3D::area_get_shape_transform(RID p_area, int p_shape_idx) const {369const JoltArea3D *area = area_owner.get_or_null(p_area);370ERR_FAIL_NULL_V(area, Transform3D());371372return area->get_shape_transform_scaled(p_shape_idx);373}374375int JoltPhysicsServer3D::area_get_shape_count(RID p_area) const {376const JoltArea3D *area = area_owner.get_or_null(p_area);377ERR_FAIL_NULL_V(area, 0);378379return area->get_shape_count();380}381382void JoltPhysicsServer3D::area_remove_shape(RID p_area, int p_shape_idx) {383JoltArea3D *area = area_owner.get_or_null(p_area);384ERR_FAIL_NULL(area);385386area->remove_shape(p_shape_idx);387}388389void JoltPhysicsServer3D::area_clear_shapes(RID p_area) {390JoltArea3D *area = area_owner.get_or_null(p_area);391ERR_FAIL_NULL(area);392393area->clear_shapes();394}395396void JoltPhysicsServer3D::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {397JoltArea3D *area = area_owner.get_or_null(p_area);398ERR_FAIL_NULL(area);399400area->set_shape_disabled(p_shape_idx, p_disabled);401}402403void JoltPhysicsServer3D::area_attach_object_instance_id(RID p_area, ObjectID p_id) {404RID area_rid = p_area;405406if (space_owner.owns(area_rid)) {407const JoltSpace3D *space = space_owner.get_or_null(area_rid);408area_rid = space->get_default_area()->get_rid();409}410411JoltArea3D *area = area_owner.get_or_null(area_rid);412ERR_FAIL_NULL(area);413414area->set_instance_id(p_id);415}416417ObjectID JoltPhysicsServer3D::area_get_object_instance_id(RID p_area) const {418RID area_rid = p_area;419420if (space_owner.owns(area_rid)) {421const JoltSpace3D *space = space_owner.get_or_null(area_rid);422area_rid = space->get_default_area()->get_rid();423}424425JoltArea3D *area = area_owner.get_or_null(area_rid);426ERR_FAIL_NULL_V(area, ObjectID());427428return area->get_instance_id();429}430431void JoltPhysicsServer3D::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {432RID area_rid = p_area;433434if (space_owner.owns(area_rid)) {435const JoltSpace3D *space = space_owner.get_or_null(area_rid);436area_rid = space->get_default_area()->get_rid();437}438439JoltArea3D *area = area_owner.get_or_null(area_rid);440ERR_FAIL_NULL(area);441442area->set_param(p_param, p_value);443}444445Variant JoltPhysicsServer3D::area_get_param(RID p_area, AreaParameter p_param) const {446RID area_rid = p_area;447448if (space_owner.owns(area_rid)) {449const JoltSpace3D *space = space_owner.get_or_null(area_rid);450area_rid = space->get_default_area()->get_rid();451}452453JoltArea3D *area = area_owner.get_or_null(area_rid);454ERR_FAIL_NULL_V(area, Variant());455456return area->get_param(p_param);457}458459void JoltPhysicsServer3D::area_set_transform(RID p_area, const Transform3D &p_transform) {460JoltArea3D *area = area_owner.get_or_null(p_area);461ERR_FAIL_NULL(area);462463return area->set_transform(p_transform);464}465466Transform3D JoltPhysicsServer3D::area_get_transform(RID p_area) const {467const JoltArea3D *area = area_owner.get_or_null(p_area);468ERR_FAIL_NULL_V(area, Transform3D());469470return area->get_transform_scaled();471}472473void JoltPhysicsServer3D::area_set_collision_mask(RID p_area, uint32_t p_mask) {474JoltArea3D *area = area_owner.get_or_null(p_area);475ERR_FAIL_NULL(area);476477area->set_collision_mask(p_mask);478}479480uint32_t JoltPhysicsServer3D::area_get_collision_mask(RID p_area) const {481const JoltArea3D *area = area_owner.get_or_null(p_area);482ERR_FAIL_NULL_V(area, 0);483484return area->get_collision_mask();485}486487void JoltPhysicsServer3D::area_set_collision_layer(RID p_area, uint32_t p_layer) {488JoltArea3D *area = area_owner.get_or_null(p_area);489ERR_FAIL_NULL(area);490491area->set_collision_layer(p_layer);492}493494uint32_t JoltPhysicsServer3D::area_get_collision_layer(RID p_area) const {495const JoltArea3D *area = area_owner.get_or_null(p_area);496ERR_FAIL_NULL_V(area, 0);497498return area->get_collision_layer();499}500501void JoltPhysicsServer3D::area_set_monitorable(RID p_area, bool p_monitorable) {502JoltArea3D *area = area_owner.get_or_null(p_area);503ERR_FAIL_NULL(area);504505area->set_monitorable(p_monitorable);506}507508void JoltPhysicsServer3D::area_set_monitor_callback(RID p_area, const Callable &p_callback) {509JoltArea3D *area = area_owner.get_or_null(p_area);510ERR_FAIL_NULL(area);511512area->set_body_monitor_callback(p_callback);513}514515void JoltPhysicsServer3D::area_set_area_monitor_callback(RID p_area, const Callable &p_callback) {516JoltArea3D *area = area_owner.get_or_null(p_area);517ERR_FAIL_NULL(area);518519area->set_area_monitor_callback(p_callback);520}521522void JoltPhysicsServer3D::area_set_ray_pickable(RID p_area, bool p_enable) {523JoltArea3D *area = area_owner.get_or_null(p_area);524ERR_FAIL_NULL(area);525526area->set_pickable(p_enable);527}528529RID JoltPhysicsServer3D::body_create() {530JoltBody3D *body = memnew(JoltBody3D);531RID rid = body_owner.make_rid(body);532body->set_rid(rid);533return rid;534}535536void JoltPhysicsServer3D::body_set_space(RID p_body, RID p_space) {537JoltBody3D *body = body_owner.get_or_null(p_body);538ERR_FAIL_NULL(body);539540JoltSpace3D *space = nullptr;541542if (p_space.is_valid()) {543space = space_owner.get_or_null(p_space);544ERR_FAIL_NULL(space);545}546547body->set_space(space);548}549550RID JoltPhysicsServer3D::body_get_space(RID p_body) const {551const JoltBody3D *body = body_owner.get_or_null(p_body);552ERR_FAIL_NULL_V(body, RID());553554const JoltSpace3D *space = body->get_space();555556if (space == nullptr) {557return RID();558}559560return space->get_rid();561}562563void JoltPhysicsServer3D::body_set_mode(RID p_body, BodyMode p_mode) {564JoltBody3D *body = body_owner.get_or_null(p_body);565ERR_FAIL_NULL(body);566567body->set_mode(p_mode);568}569570PhysicsServer3D::BodyMode JoltPhysicsServer3D::body_get_mode(RID p_body) const {571const JoltBody3D *body = body_owner.get_or_null(p_body);572ERR_FAIL_NULL_V(body, BODY_MODE_STATIC);573574return body->get_mode();575}576577void JoltPhysicsServer3D::body_add_shape(RID p_body, RID p_shape, const Transform3D &p_transform, bool p_disabled) {578JoltBody3D *body = body_owner.get_or_null(p_body);579ERR_FAIL_NULL(body);580581JoltShape3D *shape = shape_owner.get_or_null(p_shape);582ERR_FAIL_NULL(shape);583584body->add_shape(shape, p_transform, p_disabled);585}586587void JoltPhysicsServer3D::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {588JoltBody3D *body = body_owner.get_or_null(p_body);589ERR_FAIL_NULL(body);590591JoltShape3D *shape = shape_owner.get_or_null(p_shape);592ERR_FAIL_NULL(shape);593594body->set_shape(p_shape_idx, shape);595}596597RID JoltPhysicsServer3D::body_get_shape(RID p_body, int p_shape_idx) const {598const JoltBody3D *body = body_owner.get_or_null(p_body);599ERR_FAIL_NULL_V(body, RID());600601const JoltShape3D *shape = body->get_shape(p_shape_idx);602ERR_FAIL_NULL_V(shape, RID());603604return shape->get_rid();605}606607void JoltPhysicsServer3D::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform3D &p_transform) {608JoltBody3D *body = body_owner.get_or_null(p_body);609ERR_FAIL_NULL(body);610611body->set_shape_transform(p_shape_idx, p_transform);612}613614Transform3D JoltPhysicsServer3D::body_get_shape_transform(RID p_body, int p_shape_idx) const {615const JoltBody3D *body = body_owner.get_or_null(p_body);616ERR_FAIL_NULL_V(body, Transform3D());617618return body->get_shape_transform_scaled(p_shape_idx);619}620621int JoltPhysicsServer3D::body_get_shape_count(RID p_body) const {622const JoltBody3D *body = body_owner.get_or_null(p_body);623ERR_FAIL_NULL_V(body, 0);624625return body->get_shape_count();626}627628void JoltPhysicsServer3D::body_remove_shape(RID p_body, int p_shape_idx) {629JoltBody3D *body = body_owner.get_or_null(p_body);630ERR_FAIL_NULL(body);631632body->remove_shape(p_shape_idx);633}634635void JoltPhysicsServer3D::body_clear_shapes(RID p_body) {636JoltBody3D *body = body_owner.get_or_null(p_body);637ERR_FAIL_NULL(body);638639body->clear_shapes();640}641642void JoltPhysicsServer3D::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {643JoltBody3D *body = body_owner.get_or_null(p_body);644ERR_FAIL_NULL(body);645646body->set_shape_disabled(p_shape_idx, p_disabled);647}648649void JoltPhysicsServer3D::body_attach_object_instance_id(RID p_body, ObjectID p_id) {650if (JoltBody3D *body = body_owner.get_or_null(p_body)) {651body->set_instance_id(p_id);652} else if (JoltSoftBody3D *soft_body = soft_body_owner.get_or_null(p_body)) {653soft_body->set_instance_id(p_id);654} else {655ERR_FAIL();656}657}658659ObjectID JoltPhysicsServer3D::body_get_object_instance_id(RID p_body) const {660const JoltBody3D *body = body_owner.get_or_null(p_body);661ERR_FAIL_NULL_V(body, ObjectID());662663return body->get_instance_id();664}665666void JoltPhysicsServer3D::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) {667JoltBody3D *body = body_owner.get_or_null(p_body);668ERR_FAIL_NULL(body);669670body->set_ccd_enabled(p_enable);671}672673bool JoltPhysicsServer3D::body_is_continuous_collision_detection_enabled(RID p_body) const {674const JoltBody3D *body = body_owner.get_or_null(p_body);675ERR_FAIL_NULL_V(body, false);676677return body->is_ccd_enabled();678}679680void JoltPhysicsServer3D::body_set_collision_layer(RID p_body, uint32_t p_layer) {681JoltBody3D *body = body_owner.get_or_null(p_body);682ERR_FAIL_NULL(body);683684body->set_collision_layer(p_layer);685}686687uint32_t JoltPhysicsServer3D::body_get_collision_layer(RID p_body) const {688const JoltBody3D *body = body_owner.get_or_null(p_body);689ERR_FAIL_NULL_V(body, 0);690691return body->get_collision_layer();692}693694void JoltPhysicsServer3D::body_set_collision_mask(RID p_body, uint32_t p_mask) {695JoltBody3D *body = body_owner.get_or_null(p_body);696ERR_FAIL_NULL(body);697698body->set_collision_mask(p_mask);699}700701uint32_t JoltPhysicsServer3D::body_get_collision_mask(RID p_body) const {702const JoltBody3D *body = body_owner.get_or_null(p_body);703ERR_FAIL_NULL_V(body, 0);704705return body->get_collision_mask();706}707708void JoltPhysicsServer3D::body_set_collision_priority(RID p_body, real_t p_priority) {709JoltBody3D *body = body_owner.get_or_null(p_body);710ERR_FAIL_NULL(body);711712body->set_collision_priority((float)p_priority);713}714715real_t JoltPhysicsServer3D::body_get_collision_priority(RID p_body) const {716const JoltBody3D *body = body_owner.get_or_null(p_body);717ERR_FAIL_NULL_V(body, 0.0);718719return (real_t)body->get_collision_priority();720}721722void JoltPhysicsServer3D::body_set_user_flags(RID p_body, uint32_t p_flags) {723WARN_PRINT("Body user flags are not supported. Any such value will be ignored.");724}725726uint32_t JoltPhysicsServer3D::body_get_user_flags(RID p_body) const {727return 0;728}729730void JoltPhysicsServer3D::body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) {731JoltBody3D *body = body_owner.get_or_null(p_body);732ERR_FAIL_NULL(body);733734body->set_param(p_param, p_value);735}736737Variant JoltPhysicsServer3D::body_get_param(RID p_body, BodyParameter p_param) const {738const JoltBody3D *body = body_owner.get_or_null(p_body);739ERR_FAIL_NULL_V(body, Variant());740741return body->get_param(p_param);742}743744void JoltPhysicsServer3D::body_reset_mass_properties(RID p_body) {745JoltBody3D *body = body_owner.get_or_null(p_body);746ERR_FAIL_NULL(body);747748body->reset_mass_properties();749}750751void JoltPhysicsServer3D::body_set_state(RID p_body, BodyState p_state, const Variant &p_value) {752JoltBody3D *body = body_owner.get_or_null(p_body);753ERR_FAIL_NULL(body);754755body->set_state(p_state, p_value);756}757758Variant JoltPhysicsServer3D::body_get_state(RID p_body, BodyState p_state) const {759JoltBody3D *body = body_owner.get_or_null(p_body);760ERR_FAIL_NULL_V(body, Variant());761762return body->get_state(p_state);763}764765void JoltPhysicsServer3D::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) {766JoltBody3D *body = body_owner.get_or_null(p_body);767ERR_FAIL_NULL(body);768769return body->apply_central_impulse(p_impulse);770}771772void JoltPhysicsServer3D::body_apply_impulse(RID p_body, const Vector3 &p_impulse, const Vector3 &p_position) {773JoltBody3D *body = body_owner.get_or_null(p_body);774ERR_FAIL_NULL(body);775776return body->apply_impulse(p_impulse, p_position);777}778779void JoltPhysicsServer3D::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) {780JoltBody3D *body = body_owner.get_or_null(p_body);781ERR_FAIL_NULL(body);782783return body->apply_torque_impulse(p_impulse);784}785786void JoltPhysicsServer3D::body_apply_central_force(RID p_body, const Vector3 &p_force) {787JoltBody3D *body = body_owner.get_or_null(p_body);788ERR_FAIL_NULL(body);789790return body->apply_central_force(p_force);791}792793void JoltPhysicsServer3D::body_apply_force(RID p_body, const Vector3 &p_force, const Vector3 &p_position) {794JoltBody3D *body = body_owner.get_or_null(p_body);795ERR_FAIL_NULL(body);796797return body->apply_force(p_force, p_position);798}799800void JoltPhysicsServer3D::body_apply_torque(RID p_body, const Vector3 &p_torque) {801JoltBody3D *body = body_owner.get_or_null(p_body);802ERR_FAIL_NULL(body);803804return body->apply_torque(p_torque);805}806807void JoltPhysicsServer3D::body_add_constant_central_force(RID p_body, const Vector3 &p_force) {808JoltBody3D *body = body_owner.get_or_null(p_body);809ERR_FAIL_NULL(body);810811body->add_constant_central_force(p_force);812}813814void JoltPhysicsServer3D::body_add_constant_force(RID p_body, const Vector3 &p_force, const Vector3 &p_position) {815JoltBody3D *body = body_owner.get_or_null(p_body);816ERR_FAIL_NULL(body);817818body->add_constant_force(p_force, p_position);819}820821void JoltPhysicsServer3D::body_add_constant_torque(RID p_body, const Vector3 &p_torque) {822JoltBody3D *body = body_owner.get_or_null(p_body);823ERR_FAIL_NULL(body);824825body->add_constant_torque(p_torque);826}827828void JoltPhysicsServer3D::body_set_constant_force(RID p_body, const Vector3 &p_force) {829JoltBody3D *body = body_owner.get_or_null(p_body);830ERR_FAIL_NULL(body);831832body->set_constant_force(p_force);833}834835Vector3 JoltPhysicsServer3D::body_get_constant_force(RID p_body) const {836const JoltBody3D *body = body_owner.get_or_null(p_body);837ERR_FAIL_NULL_V(body, Vector3());838839return body->get_constant_force();840}841842void JoltPhysicsServer3D::body_set_constant_torque(RID p_body, const Vector3 &p_torque) {843JoltBody3D *body = body_owner.get_or_null(p_body);844ERR_FAIL_NULL(body);845846body->set_constant_torque(p_torque);847}848849Vector3 JoltPhysicsServer3D::body_get_constant_torque(RID p_body) const {850const JoltBody3D *body = body_owner.get_or_null(p_body);851ERR_FAIL_NULL_V(body, Vector3());852853return body->get_constant_torque();854}855856void JoltPhysicsServer3D::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) {857JoltBody3D *body = body_owner.get_or_null(p_body);858ERR_FAIL_NULL(body);859860body->set_axis_velocity(p_axis_velocity);861}862863void JoltPhysicsServer3D::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {864JoltBody3D *body = body_owner.get_or_null(p_body);865ERR_FAIL_NULL(body);866867body->set_axis_lock(p_axis, p_lock);868}869870bool JoltPhysicsServer3D::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {871const JoltBody3D *body = body_owner.get_or_null(p_body);872ERR_FAIL_NULL_V(body, false);873874return body->is_axis_locked(p_axis);875}876877void JoltPhysicsServer3D::body_add_collision_exception(RID p_body, RID p_excepted_body) {878JoltBody3D *body = body_owner.get_or_null(p_body);879ERR_FAIL_NULL(body);880881body->add_collision_exception(p_excepted_body);882}883884void JoltPhysicsServer3D::body_remove_collision_exception(RID p_body, RID p_excepted_body) {885JoltBody3D *body = body_owner.get_or_null(p_body);886ERR_FAIL_NULL(body);887888body->remove_collision_exception(p_excepted_body);889}890891void JoltPhysicsServer3D::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {892const JoltBody3D *body = body_owner.get_or_null(p_body);893ERR_FAIL_NULL(body);894895for (const RID &exception : body->get_collision_exceptions()) {896p_exceptions->push_back(exception);897}898}899900void JoltPhysicsServer3D::body_set_max_contacts_reported(RID p_body, int p_amount) {901JoltBody3D *body = body_owner.get_or_null(p_body);902ERR_FAIL_NULL(body);903904return body->set_max_contacts_reported(p_amount);905}906907int JoltPhysicsServer3D::body_get_max_contacts_reported(RID p_body) const {908const JoltBody3D *body = body_owner.get_or_null(p_body);909ERR_FAIL_NULL_V(body, 0);910911return body->get_max_contacts_reported();912}913914void JoltPhysicsServer3D::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {915WARN_PRINT("Per-body contact depth threshold is not supported. Any such value will be ignored.");916}917918real_t JoltPhysicsServer3D::body_get_contacts_reported_depth_threshold(RID p_body) const {919return 0.0;920}921922void JoltPhysicsServer3D::body_set_omit_force_integration(RID p_body, bool p_enable) {923JoltBody3D *body = body_owner.get_or_null(p_body);924ERR_FAIL_NULL(body);925926body->set_custom_integrator(p_enable);927}928929bool JoltPhysicsServer3D::body_is_omitting_force_integration(RID p_body) const {930JoltBody3D *body = body_owner.get_or_null(p_body);931ERR_FAIL_NULL_V(body, false);932933return body->has_custom_integrator();934}935936void JoltPhysicsServer3D::body_set_state_sync_callback(RID p_body, const Callable &p_callable) {937JoltBody3D *body = body_owner.get_or_null(p_body);938ERR_FAIL_NULL(body);939940body->set_state_sync_callback(p_callable);941}942943void JoltPhysicsServer3D::body_set_force_integration_callback(RID p_body, const Callable &p_callable, const Variant &p_userdata) {944JoltBody3D *body = body_owner.get_or_null(p_body);945ERR_FAIL_NULL(body);946947body->set_custom_integration_callback(p_callable, p_userdata);948}949950void JoltPhysicsServer3D::body_set_ray_pickable(RID p_body, bool p_enable) {951JoltBody3D *body = body_owner.get_or_null(p_body);952ERR_FAIL_NULL(body);953954body->set_pickable(p_enable);955}956957bool JoltPhysicsServer3D::body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result) {958JoltBody3D *body = body_owner.get_or_null(p_body);959ERR_FAIL_NULL_V(body, false);960961JoltSpace3D *space = body->get_space();962ERR_FAIL_NULL_V(space, false);963964return space->get_direct_state()->body_test_motion(*body, p_parameters, r_result);965}966967PhysicsDirectBodyState3D *JoltPhysicsServer3D::body_get_direct_state(RID p_body) {968ERR_FAIL_COND_V_MSG((on_separate_thread && !doing_sync), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");969970JoltBody3D *body = body_owner.get_or_null(p_body);971if (unlikely(body == nullptr || body->get_space() == nullptr)) {972return nullptr;973}974975ERR_FAIL_COND_V_MSG(body->get_space()->is_stepping(), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");976977return body->get_direct_state();978}979980RID JoltPhysicsServer3D::soft_body_create() {981JoltSoftBody3D *body = memnew(JoltSoftBody3D);982RID rid = soft_body_owner.make_rid(body);983body->set_rid(rid);984return rid;985}986987void JoltPhysicsServer3D::soft_body_update_rendering_server(RID p_body, RequiredParam<PhysicsServer3DRenderingServerHandler> rp_rendering_server_handler) {988JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);989ERR_FAIL_NULL(body);990EXTRACT_PARAM_OR_FAIL(p_rendering_server_handler, rp_rendering_server_handler);991992return body->update_rendering_server(p_rendering_server_handler);993}994995void JoltPhysicsServer3D::soft_body_set_space(RID p_body, RID p_space) {996JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);997ERR_FAIL_NULL(body);998999JoltSpace3D *space = nullptr;10001001if (p_space.is_valid()) {1002space = space_owner.get_or_null(p_space);1003ERR_FAIL_NULL(space);1004}10051006body->set_space(space);1007}10081009RID JoltPhysicsServer3D::soft_body_get_space(RID p_body) const {1010const JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1011ERR_FAIL_NULL_V(body, RID());10121013const JoltSpace3D *space = body->get_space();10141015if (space == nullptr) {1016return RID();1017}10181019return space->get_rid();1020}10211022void JoltPhysicsServer3D::soft_body_set_mesh(RID p_body, RID p_mesh) {1023JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1024ERR_FAIL_NULL(body);10251026body->set_mesh(p_mesh);1027}10281029AABB JoltPhysicsServer3D::soft_body_get_bounds(RID p_body) const {1030const JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1031ERR_FAIL_NULL_V(body, AABB());10321033return body->get_bounds();1034}10351036void JoltPhysicsServer3D::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) {1037JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1038ERR_FAIL_NULL(body);10391040body->set_collision_layer(p_layer);1041}10421043uint32_t JoltPhysicsServer3D::soft_body_get_collision_layer(RID p_body) const {1044const JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1045ERR_FAIL_NULL_V(body, 0);10461047return body->get_collision_layer();1048}10491050void JoltPhysicsServer3D::soft_body_set_collision_mask(RID p_body, uint32_t p_mask) {1051JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1052ERR_FAIL_NULL(body);10531054body->set_collision_mask(p_mask);1055}10561057uint32_t JoltPhysicsServer3D::soft_body_get_collision_mask(RID p_body) const {1058const JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1059ERR_FAIL_NULL_V(body, 0);10601061return body->get_collision_mask();1062}10631064void JoltPhysicsServer3D::soft_body_add_collision_exception(RID p_body, RID p_excepted_body) {1065JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1066ERR_FAIL_NULL(body);10671068body->add_collision_exception(p_excepted_body);1069}10701071void JoltPhysicsServer3D::soft_body_remove_collision_exception(RID p_body, RID p_excepted_body) {1072JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1073ERR_FAIL_NULL(body);10741075body->remove_collision_exception(p_excepted_body);1076}10771078void JoltPhysicsServer3D::soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {1079const JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1080ERR_FAIL_NULL(body);10811082for (const RID &exception : body->get_collision_exceptions()) {1083p_exceptions->push_back(exception);1084}1085}10861087void JoltPhysicsServer3D::soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_value) {1088JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1089ERR_FAIL_NULL(body);10901091body->set_state(p_state, p_value);1092}10931094Variant JoltPhysicsServer3D::soft_body_get_state(RID p_body, BodyState p_state) const {1095JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1096ERR_FAIL_NULL_V(body, Variant());10971098return body->get_state(p_state);1099}11001101void JoltPhysicsServer3D::soft_body_set_transform(RID p_body, const Transform3D &p_transform) {1102JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1103ERR_FAIL_NULL(body);11041105return body->set_transform(p_transform);1106}11071108void JoltPhysicsServer3D::soft_body_set_ray_pickable(RID p_body, bool p_enable) {1109JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1110ERR_FAIL_NULL(body);11111112return body->set_pickable(p_enable);1113}11141115void JoltPhysicsServer3D::soft_body_set_simulation_precision(RID p_body, int p_precision) {1116JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1117ERR_FAIL_NULL(body);11181119return body->set_simulation_precision(p_precision);1120}11211122int JoltPhysicsServer3D::soft_body_get_simulation_precision(RID p_body) const {1123JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1124ERR_FAIL_NULL_V(body, 0);11251126return body->get_simulation_precision();1127}11281129void JoltPhysicsServer3D::soft_body_set_total_mass(RID p_body, real_t p_total_mass) {1130JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1131ERR_FAIL_NULL(body);11321133return body->set_mass((float)p_total_mass);1134}11351136real_t JoltPhysicsServer3D::soft_body_get_total_mass(RID p_body) const {1137JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1138ERR_FAIL_NULL_V(body, 0.0);11391140return (real_t)body->get_mass();1141}11421143void JoltPhysicsServer3D::soft_body_set_linear_stiffness(RID p_body, real_t p_coefficient) {1144JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1145ERR_FAIL_NULL(body);11461147return body->set_stiffness_coefficient((float)p_coefficient);1148}11491150real_t JoltPhysicsServer3D::soft_body_get_linear_stiffness(RID p_body) const {1151JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1152ERR_FAIL_NULL_V(body, 0.0);11531154return (real_t)body->get_stiffness_coefficient();1155}11561157void JoltPhysicsServer3D::soft_body_set_shrinking_factor(RID p_body, real_t p_shrinking_factor) {1158JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1159ERR_FAIL_NULL(body);11601161return body->set_shrinking_factor((float)p_shrinking_factor);1162}11631164real_t JoltPhysicsServer3D::soft_body_get_shrinking_factor(RID p_body) const {1165JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1166ERR_FAIL_NULL_V(body, 0.0);11671168return (real_t)body->get_shrinking_factor();1169}11701171void JoltPhysicsServer3D::soft_body_set_pressure_coefficient(RID p_body, real_t p_coefficient) {1172JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1173ERR_FAIL_NULL(body);11741175return body->set_pressure((float)p_coefficient);1176}11771178real_t JoltPhysicsServer3D::soft_body_get_pressure_coefficient(RID p_body) const {1179JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1180ERR_FAIL_NULL_V(body, 0.0);11811182return (real_t)body->get_pressure();1183}11841185void JoltPhysicsServer3D::soft_body_set_damping_coefficient(RID p_body, real_t p_coefficient) {1186JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1187ERR_FAIL_NULL(body);11881189return body->set_linear_damping((float)p_coefficient);1190}11911192real_t JoltPhysicsServer3D::soft_body_get_damping_coefficient(RID p_body) const {1193JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1194ERR_FAIL_NULL_V(body, 0.0);11951196return (real_t)body->get_linear_damping();1197}11981199void JoltPhysicsServer3D::soft_body_set_drag_coefficient(RID p_body, real_t p_coefficient) {1200JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1201ERR_FAIL_NULL(body);12021203return body->set_drag((float)p_coefficient);1204}12051206real_t JoltPhysicsServer3D::soft_body_get_drag_coefficient(RID p_body) const {1207JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1208ERR_FAIL_NULL_V(body, 0.0);12091210return (real_t)body->get_drag();1211}12121213void JoltPhysicsServer3D::soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) {1214JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1215ERR_FAIL_NULL(body);12161217body->set_vertex_position(p_point_index, p_global_position);1218}12191220Vector3 JoltPhysicsServer3D::soft_body_get_point_global_position(RID p_body, int p_point_index) const {1221JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1222ERR_FAIL_NULL_V(body, Vector3());12231224return body->get_vertex_position(p_point_index);1225}12261227void JoltPhysicsServer3D::soft_body_remove_all_pinned_points(RID p_body) {1228JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1229ERR_FAIL_NULL(body);12301231body->unpin_all_vertices();1232}12331234void JoltPhysicsServer3D::soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) {1235JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1236ERR_FAIL_NULL(body);12371238if (p_pin) {1239body->pin_vertex(p_point_index);1240} else {1241body->unpin_vertex(p_point_index);1242}1243}12441245bool JoltPhysicsServer3D::soft_body_is_point_pinned(RID p_body, int p_point_index) const {1246JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);1247ERR_FAIL_NULL_V(body, false);12481249return body->is_vertex_pinned(p_point_index);1250}12511252RID JoltPhysicsServer3D::joint_create() {1253JoltJoint3D *joint = memnew(JoltJoint3D);1254RID rid = joint_owner.make_rid(joint);1255joint->set_rid(rid);1256return rid;1257}12581259void JoltPhysicsServer3D::joint_clear(RID p_joint) {1260JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1261ERR_FAIL_NULL(joint);12621263if (joint->get_type() != JOINT_TYPE_MAX) {1264JoltJoint3D *empty_joint = memnew(JoltJoint3D);1265empty_joint->set_rid(joint->get_rid());12661267memdelete(joint);1268joint = nullptr;12691270joint_owner.replace(p_joint, empty_joint);1271}1272}12731274void JoltPhysicsServer3D::joint_make_pin(RID p_joint, RID p_body_a, const Vector3 &p_local_a, RID p_body_b, const Vector3 &p_local_b) {1275JoltJoint3D *old_joint = joint_owner.get_or_null(p_joint);1276ERR_FAIL_NULL(old_joint);12771278JoltBody3D *body_a = body_owner.get_or_null(p_body_a);1279ERR_FAIL_NULL(body_a);12801281JoltBody3D *body_b = body_owner.get_or_null(p_body_b);1282ERR_FAIL_COND(body_a == body_b);12831284JoltJoint3D *new_joint = memnew(JoltPinJoint3D(*old_joint, body_a, body_b, p_local_a, p_local_b));12851286memdelete(old_joint);1287old_joint = nullptr;12881289joint_owner.replace(p_joint, new_joint);1290}12911292void JoltPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {1293JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1294ERR_FAIL_NULL(joint);12951296ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);1297JoltPinJoint3D *pin_joint = static_cast<JoltPinJoint3D *>(joint);12981299pin_joint->set_param(p_param, (double)p_value);1300}13011302real_t JoltPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {1303const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1304ERR_FAIL_NULL_V(joint, 0.0);13051306ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, 0.0);1307const JoltPinJoint3D *pin_joint = static_cast<const JoltPinJoint3D *>(joint);13081309return (real_t)pin_joint->get_param(p_param);1310}13111312void JoltPhysicsServer3D::pin_joint_set_local_a(RID p_joint, const Vector3 &p_local_a) {1313JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1314ERR_FAIL_NULL(joint);13151316ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);1317JoltPinJoint3D *pin_joint = static_cast<JoltPinJoint3D *>(joint);13181319pin_joint->set_local_a(p_local_a);1320}13211322Vector3 JoltPhysicsServer3D::pin_joint_get_local_a(RID p_joint) const {1323const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1324ERR_FAIL_NULL_V(joint, Vector3());13251326ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, Vector3());1327const JoltPinJoint3D *pin_joint = static_cast<const JoltPinJoint3D *>(joint);13281329return pin_joint->get_local_a();1330}13311332void JoltPhysicsServer3D::pin_joint_set_local_b(RID p_joint, const Vector3 &p_local_b) {1333JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1334ERR_FAIL_NULL(joint);13351336ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);1337JoltPinJoint3D *pin_joint = static_cast<JoltPinJoint3D *>(joint);13381339pin_joint->set_local_b(p_local_b);1340}13411342Vector3 JoltPhysicsServer3D::pin_joint_get_local_b(RID p_joint) const {1343const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1344ERR_FAIL_NULL_V(joint, Vector3());13451346ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, Vector3());1347const JoltPinJoint3D *pin_joint = static_cast<const JoltPinJoint3D *>(joint);13481349return pin_joint->get_local_b();1350}13511352void JoltPhysicsServer3D::joint_make_hinge(RID p_joint, RID p_body_a, const Transform3D &p_hinge_a, RID p_body_b, const Transform3D &p_hinge_b) {1353JoltJoint3D *old_joint = joint_owner.get_or_null(p_joint);1354ERR_FAIL_NULL(old_joint);13551356JoltBody3D *body_a = body_owner.get_or_null(p_body_a);1357ERR_FAIL_NULL(body_a);13581359JoltBody3D *body_b = body_owner.get_or_null(p_body_b);1360ERR_FAIL_COND(body_a == body_b);13611362JoltJoint3D *new_joint = memnew(JoltHingeJoint3D(*old_joint, body_a, body_b, p_hinge_a, p_hinge_b));13631364memdelete(old_joint);1365old_joint = nullptr;13661367joint_owner.replace(p_joint, new_joint);1368}13691370void JoltPhysicsServer3D::joint_make_hinge_simple(RID p_joint, RID p_body_a, const Vector3 &p_pivot_a, const Vector3 &p_axis_a, RID p_body_b, const Vector3 &p_pivot_b, const Vector3 &p_axis_b) {1371ERR_FAIL_MSG("Simple hinge joints are not supported when using Jolt Physics.");1372}13731374void JoltPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) {1375JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1376ERR_FAIL_NULL(joint);13771378ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);1379JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);13801381return hinge_joint->set_param(p_param, (double)p_value);1382}13831384real_t JoltPhysicsServer3D::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {1385const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1386ERR_FAIL_NULL_V(joint, 0.0);13871388ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, 0.0);1389const JoltHingeJoint3D *hinge_joint = static_cast<const JoltHingeJoint3D *>(joint);13901391return (real_t)hinge_joint->get_param(p_param);1392}13931394void JoltPhysicsServer3D::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_enabled) {1395JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1396ERR_FAIL_NULL(joint);13971398ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);1399JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);14001401return hinge_joint->set_flag(p_flag, p_enabled);1402}14031404bool JoltPhysicsServer3D::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {1405const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1406ERR_FAIL_NULL_V(joint, false);14071408ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, false);1409const JoltHingeJoint3D *hinge_joint = static_cast<const JoltHingeJoint3D *>(joint);14101411return hinge_joint->get_flag(p_flag);1412}14131414void JoltPhysicsServer3D::joint_make_slider(RID p_joint, RID p_body_a, const Transform3D &p_local_ref_a, RID p_body_b, const Transform3D &p_local_ref_b) {1415JoltJoint3D *old_joint = joint_owner.get_or_null(p_joint);1416ERR_FAIL_NULL(old_joint);14171418JoltBody3D *body_a = body_owner.get_or_null(p_body_a);1419ERR_FAIL_NULL(body_a);14201421JoltBody3D *body_b = body_owner.get_or_null(p_body_b);1422ERR_FAIL_COND(body_a == body_b);14231424JoltJoint3D *new_joint = memnew(JoltSliderJoint3D(*old_joint, body_a, body_b, p_local_ref_a, p_local_ref_b));14251426memdelete(old_joint);1427old_joint = nullptr;14281429joint_owner.replace(p_joint, new_joint);1430}14311432void JoltPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) {1433JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1434ERR_FAIL_NULL(joint);14351436ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_SLIDER);1437JoltSliderJoint3D *slider_joint = static_cast<JoltSliderJoint3D *>(joint);14381439return slider_joint->set_param(p_param, (real_t)p_value);1440}14411442real_t JoltPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {1443const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1444ERR_FAIL_NULL_V(joint, 0.0);14451446ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_SLIDER, 0.0);1447const JoltSliderJoint3D *slider_joint = static_cast<const JoltSliderJoint3D *>(joint);14481449return slider_joint->get_param(p_param);1450}14511452void JoltPhysicsServer3D::joint_make_cone_twist(RID p_joint, RID p_body_a, const Transform3D &p_local_ref_a, RID p_body_b, const Transform3D &p_local_ref_b) {1453JoltJoint3D *old_joint = joint_owner.get_or_null(p_joint);1454ERR_FAIL_NULL(old_joint);14551456JoltBody3D *body_a = body_owner.get_or_null(p_body_a);1457ERR_FAIL_NULL(body_a);14581459JoltBody3D *body_b = body_owner.get_or_null(p_body_b);1460ERR_FAIL_COND(body_a == body_b);14611462JoltJoint3D *new_joint = memnew(JoltConeTwistJoint3D(*old_joint, body_a, body_b, p_local_ref_a, p_local_ref_b));14631464memdelete(old_joint);1465old_joint = nullptr;14661467joint_owner.replace(p_joint, new_joint);1468}14691470void JoltPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) {1471JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1472ERR_FAIL_NULL(joint);14731474ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_CONE_TWIST);1475JoltConeTwistJoint3D *cone_twist_joint = static_cast<JoltConeTwistJoint3D *>(joint);14761477return cone_twist_joint->set_param(p_param, (double)p_value);1478}14791480real_t JoltPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {1481const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1482ERR_FAIL_NULL_V(joint, 0.0);14831484ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0.0);1485const JoltConeTwistJoint3D *cone_twist_joint = static_cast<const JoltConeTwistJoint3D *>(joint);14861487return (real_t)cone_twist_joint->get_param(p_param);1488}14891490void JoltPhysicsServer3D::joint_make_generic_6dof(RID p_joint, RID p_body_a, const Transform3D &p_local_ref_a, RID p_body_b, const Transform3D &p_local_ref_b) {1491JoltJoint3D *old_joint = joint_owner.get_or_null(p_joint);1492ERR_FAIL_NULL(old_joint);14931494JoltBody3D *body_a = body_owner.get_or_null(p_body_a);1495ERR_FAIL_NULL(body_a);14961497JoltBody3D *body_b = body_owner.get_or_null(p_body_b);1498ERR_FAIL_COND(body_a == body_b);14991500JoltJoint3D *new_joint = memnew(JoltGeneric6DOFJoint3D(*old_joint, body_a, body_b, p_local_ref_a, p_local_ref_b));15011502memdelete(old_joint);1503old_joint = nullptr;15041505joint_owner.replace(p_joint, new_joint);1506}15071508void JoltPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value) {1509JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1510ERR_FAIL_NULL(joint);15111512ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);1513JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);15141515return g6dof_joint->set_param(p_axis, p_param, (double)p_value);1516}15171518real_t JoltPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const {1519const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1520ERR_FAIL_NULL_V(joint, 0.0);15211522ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, 0.0);1523const JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<const JoltGeneric6DOFJoint3D *>(joint);15241525return (real_t)g6dof_joint->get_param(p_axis, p_param);1526}15271528void JoltPhysicsServer3D::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_enable) {1529JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1530ERR_FAIL_NULL(joint);15311532ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);1533JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);15341535return g6dof_joint->set_flag(p_axis, p_flag, p_enable);1536}15371538bool JoltPhysicsServer3D::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const {1539const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1540ERR_FAIL_NULL_V(joint, false);15411542ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, false);1543const JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<const JoltGeneric6DOFJoint3D *>(joint);15441545return g6dof_joint->get_flag(p_axis, p_flag);1546}15471548PhysicsServer3D::JointType JoltPhysicsServer3D::joint_get_type(RID p_joint) const {1549const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1550ERR_FAIL_NULL_V(joint, JOINT_TYPE_PIN);15511552return joint->get_type();1553}15541555void JoltPhysicsServer3D::joint_set_solver_priority(RID p_joint, int p_priority) {1556JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1557ERR_FAIL_NULL(joint);15581559joint->set_solver_priority(p_priority);1560}15611562int JoltPhysicsServer3D::joint_get_solver_priority(RID p_joint) const {1563const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1564ERR_FAIL_NULL_V(joint, 0);15651566return joint->get_solver_priority();1567}15681569void JoltPhysicsServer3D::joint_disable_collisions_between_bodies(RID p_joint, bool p_disable) {1570JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1571ERR_FAIL_NULL(joint);15721573joint->set_collision_disabled(p_disable);1574}15751576bool JoltPhysicsServer3D::joint_is_disabled_collisions_between_bodies(RID p_joint) const {1577const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1578ERR_FAIL_NULL_V(joint, false);15791580return joint->is_collision_disabled();1581}15821583void JoltPhysicsServer3D::free_rid(RID p_rid) {1584if (JoltShape3D *shape = shape_owner.get_or_null(p_rid)) {1585free_shape(shape);1586} else if (JoltBody3D *body = body_owner.get_or_null(p_rid)) {1587free_body(body);1588} else if (JoltJoint3D *joint = joint_owner.get_or_null(p_rid)) {1589free_joint(joint);1590} else if (JoltArea3D *area = area_owner.get_or_null(p_rid)) {1591free_area(area);1592} else if (JoltSoftBody3D *soft_body = soft_body_owner.get_or_null(p_rid)) {1593free_soft_body(soft_body);1594} else if (JoltSpace3D *space = space_owner.get_or_null(p_rid)) {1595free_space(space);1596} else {1597ERR_FAIL_MSG("Failed to free RID: The specified RID has no owner.");1598}1599}16001601void JoltPhysicsServer3D::set_active(bool p_active) {1602active = p_active;1603}16041605void JoltPhysicsServer3D::init() {1606job_system = new JoltJobSystem();1607}16081609void JoltPhysicsServer3D::finish() {1610if (job_system != nullptr) {1611delete job_system;1612job_system = nullptr;1613}1614}16151616void JoltPhysicsServer3D::step(real_t p_step) {1617if (!active) {1618return;1619}16201621for (JoltSpace3D *active_space : active_spaces) {1622job_system->pre_step();16231624active_space->step((float)p_step);16251626job_system->post_step();1627}1628}16291630void JoltPhysicsServer3D::sync() {1631doing_sync = true;1632}16331634void JoltPhysicsServer3D::end_sync() {1635doing_sync = false;1636}16371638void JoltPhysicsServer3D::flush_queries() {1639if (!active) {1640return;1641}16421643flushing_queries = true;16441645for (JoltSpace3D *space : active_spaces) {1646space->call_queries();1647}16481649flushing_queries = false;16501651#ifdef DEBUG_ENABLED1652job_system->flush_timings();1653#endif1654}16551656bool JoltPhysicsServer3D::is_flushing_queries() const {1657return flushing_queries;1658}16591660int JoltPhysicsServer3D::get_process_info(ProcessInfo p_process_info) {1661return 0;1662}16631664void JoltPhysicsServer3D::free_space(JoltSpace3D *p_space) {1665ERR_FAIL_NULL(p_space);16661667free_area(p_space->get_default_area());1668space_set_active(p_space->get_rid(), false);1669space_owner.free(p_space->get_rid());1670memdelete(p_space);1671}16721673void JoltPhysicsServer3D::free_area(JoltArea3D *p_area) {1674ERR_FAIL_NULL(p_area);16751676p_area->set_space(nullptr);1677area_owner.free(p_area->get_rid());1678memdelete(p_area);1679}16801681void JoltPhysicsServer3D::free_body(JoltBody3D *p_body) {1682ERR_FAIL_NULL(p_body);16831684p_body->set_space(nullptr);1685body_owner.free(p_body->get_rid());1686memdelete(p_body);1687}16881689void JoltPhysicsServer3D::free_soft_body(JoltSoftBody3D *p_body) {1690ERR_FAIL_NULL(p_body);16911692p_body->set_space(nullptr);1693soft_body_owner.free(p_body->get_rid());1694memdelete(p_body);1695}16961697void JoltPhysicsServer3D::free_shape(JoltShape3D *p_shape) {1698ERR_FAIL_NULL(p_shape);16991700p_shape->remove_self();1701shape_owner.free(p_shape->get_rid());1702memdelete(p_shape);1703}17041705void JoltPhysicsServer3D::free_joint(JoltJoint3D *p_joint) {1706ERR_FAIL_NULL(p_joint);17071708joint_owner.free(p_joint->get_rid());1709memdelete(p_joint);1710}17111712#ifdef DEBUG_ENABLED17131714void JoltPhysicsServer3D::dump_debug_snapshots(const String &p_dir) {1715for (JoltSpace3D *space : active_spaces) {1716space->dump_debug_snapshot(p_dir);1717}1718}17191720void JoltPhysicsServer3D::space_dump_debug_snapshot(RID p_space, const String &p_dir) {1721JoltSpace3D *space = space_owner.get_or_null(p_space);1722ERR_FAIL_NULL(space);17231724space->dump_debug_snapshot(p_dir);1725}17261727#endif17281729bool JoltPhysicsServer3D::joint_get_enabled(RID p_joint) const {1730JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1731ERR_FAIL_NULL_V(joint, false);17321733return joint->is_enabled();1734}17351736void JoltPhysicsServer3D::joint_set_enabled(RID p_joint, bool p_enabled) {1737JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1738ERR_FAIL_NULL(joint);17391740joint->set_enabled(p_enabled);1741}17421743int JoltPhysicsServer3D::joint_get_solver_velocity_iterations(RID p_joint) {1744JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1745ERR_FAIL_NULL_V(joint, 0);17461747return joint->get_solver_velocity_iterations();1748}17491750void JoltPhysicsServer3D::joint_set_solver_velocity_iterations(RID p_joint, int p_value) {1751JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1752ERR_FAIL_NULL(joint);17531754return joint->set_solver_velocity_iterations(p_value);1755}17561757int JoltPhysicsServer3D::joint_get_solver_position_iterations(RID p_joint) {1758JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1759ERR_FAIL_NULL_V(joint, 0);17601761return joint->get_solver_position_iterations();1762}17631764void JoltPhysicsServer3D::joint_set_solver_position_iterations(RID p_joint, int p_value) {1765JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1766ERR_FAIL_NULL(joint);17671768return joint->set_solver_position_iterations(p_value);1769}17701771float JoltPhysicsServer3D::pin_joint_get_applied_force(RID p_joint) {1772JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1773ERR_FAIL_NULL_V(joint, 0.0f);17741775ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, 0.0);1776JoltPinJoint3D *pin_joint = static_cast<JoltPinJoint3D *>(joint);17771778return pin_joint->get_applied_force();1779}17801781double JoltPhysicsServer3D::hinge_joint_get_jolt_param(RID p_joint, HingeJointParamJolt p_param) const {1782JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1783ERR_FAIL_NULL_V(joint, 0.0);17841785ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, 0.0);1786JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);17871788return hinge_joint->get_jolt_param(p_param);1789}17901791void JoltPhysicsServer3D::hinge_joint_set_jolt_param(RID p_joint, HingeJointParamJolt p_param, double p_value) {1792JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1793ERR_FAIL_NULL(joint);17941795ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);1796JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);17971798return hinge_joint->set_jolt_param(p_param, p_value);1799}18001801bool JoltPhysicsServer3D::hinge_joint_get_jolt_flag(RID p_joint, HingeJointFlagJolt p_flag) const {1802const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1803ERR_FAIL_NULL_V(joint, false);18041805ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, false);1806const JoltHingeJoint3D *hinge_joint = static_cast<const JoltHingeJoint3D *>(joint);18071808return hinge_joint->get_jolt_flag(p_flag);1809}18101811void JoltPhysicsServer3D::hinge_joint_set_jolt_flag(RID p_joint, HingeJointFlagJolt p_flag, bool p_enabled) {1812JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1813ERR_FAIL_NULL(joint);18141815ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);1816JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);18171818return hinge_joint->set_jolt_flag(p_flag, p_enabled);1819}18201821float JoltPhysicsServer3D::hinge_joint_get_applied_force(RID p_joint) {1822JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1823ERR_FAIL_NULL_V(joint, 0.0f);18241825ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, 0.0f);1826JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);18271828return hinge_joint->get_applied_force();1829}18301831float JoltPhysicsServer3D::hinge_joint_get_applied_torque(RID p_joint) {1832JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1833ERR_FAIL_NULL_V(joint, 0.0f);18341835ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, 0.0f);1836JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);18371838return hinge_joint->get_applied_torque();1839}18401841double JoltPhysicsServer3D::slider_joint_get_jolt_param(RID p_joint, SliderJointParamJolt p_param) const {1842JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1843ERR_FAIL_NULL_V(joint, 0.0);18441845ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_SLIDER, 0.0);1846JoltSliderJoint3D *slider_joint = static_cast<JoltSliderJoint3D *>(joint);18471848return slider_joint->get_jolt_param(p_param);1849}18501851void JoltPhysicsServer3D::slider_joint_set_jolt_param(RID p_joint, SliderJointParamJolt p_param, double p_value) {1852JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1853ERR_FAIL_NULL(joint);18541855ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_SLIDER);1856JoltSliderJoint3D *slider_joint = static_cast<JoltSliderJoint3D *>(joint);18571858return slider_joint->set_jolt_param(p_param, p_value);1859}18601861bool JoltPhysicsServer3D::slider_joint_get_jolt_flag(RID p_joint, SliderJointFlagJolt p_flag) const {1862const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1863ERR_FAIL_NULL_V(joint, false);18641865ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_SLIDER, false);1866const JoltSliderJoint3D *slider_joint = static_cast<const JoltSliderJoint3D *>(joint);18671868return slider_joint->get_jolt_flag(p_flag);1869}18701871void JoltPhysicsServer3D::slider_joint_set_jolt_flag(RID p_joint, SliderJointFlagJolt p_flag, bool p_enabled) {1872JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1873ERR_FAIL_NULL(joint);18741875ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_SLIDER);1876JoltSliderJoint3D *slider_joint = static_cast<JoltSliderJoint3D *>(joint);18771878return slider_joint->set_jolt_flag(p_flag, p_enabled);1879}18801881float JoltPhysicsServer3D::slider_joint_get_applied_force(RID p_joint) {1882JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1883ERR_FAIL_NULL_V(joint, 0.0f);18841885ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_SLIDER, 0.0f);1886JoltSliderJoint3D *slider_joint = static_cast<JoltSliderJoint3D *>(joint);18871888return slider_joint->get_applied_force();1889}18901891float JoltPhysicsServer3D::slider_joint_get_applied_torque(RID p_joint) {1892JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1893ERR_FAIL_NULL_V(joint, 0.0f);18941895ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_SLIDER, 0.0f);1896JoltSliderJoint3D *slider_joint = static_cast<JoltSliderJoint3D *>(joint);18971898return slider_joint->get_applied_torque();1899}19001901double JoltPhysicsServer3D::cone_twist_joint_get_jolt_param(RID p_joint, ConeTwistJointParamJolt p_param) const {1902JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1903ERR_FAIL_NULL_V(joint, 0.0);19041905ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0.0);1906JoltConeTwistJoint3D *cone_twist_joint = static_cast<JoltConeTwistJoint3D *>(joint);19071908return cone_twist_joint->get_jolt_param(p_param);1909}19101911void JoltPhysicsServer3D::cone_twist_joint_set_jolt_param(RID p_joint, ConeTwistJointParamJolt p_param, double p_value) {1912JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1913ERR_FAIL_NULL(joint);19141915ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_CONE_TWIST);1916JoltConeTwistJoint3D *cone_twist_joint = static_cast<JoltConeTwistJoint3D *>(joint);19171918return cone_twist_joint->set_jolt_param(p_param, p_value);1919}19201921bool JoltPhysicsServer3D::cone_twist_joint_get_jolt_flag(RID p_joint, ConeTwistJointFlagJolt p_flag) const {1922const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1923ERR_FAIL_NULL_V(joint, false);19241925ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, false);1926const JoltConeTwistJoint3D *cone_twist_joint = static_cast<const JoltConeTwistJoint3D *>(joint);19271928return cone_twist_joint->get_jolt_flag(p_flag);1929}19301931void JoltPhysicsServer3D::cone_twist_joint_set_jolt_flag(RID p_joint, ConeTwistJointFlagJolt p_flag, bool p_enabled) {1932JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1933ERR_FAIL_NULL(joint);19341935ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_CONE_TWIST);1936JoltConeTwistJoint3D *cone_twist_joint = static_cast<JoltConeTwistJoint3D *>(joint);19371938return cone_twist_joint->set_jolt_flag(p_flag, p_enabled);1939}19401941float JoltPhysicsServer3D::cone_twist_joint_get_applied_force(RID p_joint) {1942JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1943ERR_FAIL_NULL_V(joint, 0.0f);19441945ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0.0f);1946JoltConeTwistJoint3D *cone_twist_joint = static_cast<JoltConeTwistJoint3D *>(joint);19471948return cone_twist_joint->get_applied_force();1949}19501951float JoltPhysicsServer3D::cone_twist_joint_get_applied_torque(RID p_joint) {1952JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1953ERR_FAIL_NULL_V(joint, 0.0f);19541955ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0.0f);1956JoltConeTwistJoint3D *cone_twist_joint = static_cast<JoltConeTwistJoint3D *>(joint);19571958return cone_twist_joint->get_applied_torque();1959}19601961double JoltPhysicsServer3D::generic_6dof_joint_get_jolt_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParamJolt p_param) const {1962JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1963ERR_FAIL_NULL_V(joint, 0.0);19641965ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, 0.0);1966JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);19671968return g6dof_joint->get_jolt_param(p_axis, p_param);1969}19701971void JoltPhysicsServer3D::generic_6dof_joint_set_jolt_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParamJolt p_param, double p_value) {1972JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1973ERR_FAIL_NULL(joint);19741975ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);1976JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);19771978return g6dof_joint->set_jolt_param(p_axis, p_param, p_value);1979}19801981bool JoltPhysicsServer3D::generic_6dof_joint_get_jolt_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlagJolt p_flag) const {1982const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1983ERR_FAIL_NULL_V(joint, false);19841985ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, false);1986const JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<const JoltGeneric6DOFJoint3D *>(joint);19871988return g6dof_joint->get_jolt_flag(p_axis, p_flag);1989}19901991void JoltPhysicsServer3D::generic_6dof_joint_set_jolt_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlagJolt p_flag, bool p_enabled) {1992JoltJoint3D *joint = joint_owner.get_or_null(p_joint);1993ERR_FAIL_NULL(joint);19941995ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);1996JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);19971998return g6dof_joint->set_jolt_flag(p_axis, p_flag, p_enabled);1999}20002001float JoltPhysicsServer3D::generic_6dof_joint_get_applied_force(RID p_joint) {2002JoltJoint3D *joint = joint_owner.get_or_null(p_joint);2003ERR_FAIL_NULL_V(joint, 0.0f);20042005ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, 0.0f);2006JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);20072008return g6dof_joint->get_applied_force();2009}20102011float JoltPhysicsServer3D::generic_6dof_joint_get_applied_torque(RID p_joint) {2012JoltJoint3D *joint = joint_owner.get_or_null(p_joint);2013ERR_FAIL_NULL_V(joint, 0.0f);20142015ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, 0.0f);2016JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);20172018return g6dof_joint->get_applied_torque();2019}202020212022