Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Move PhysicServer enums, structs and sub-objects to dedicated files

smix8099c7c949209
diff --git a/editor/scene/3d/node_3d_editor_plugin.cpp b/editor/scene/3d/node_3d_editor_plugin.cpp
index 43a978882be..9371a8ea5e8 100644
--- a/editor/scene/3d/node_3d_editor_plugin.cpp
+++ b/editor/scene/3d/node_3d_editor_plugin.cpp
@@ -105,6 +105,7 @@
#include "scene/resources/3d/sky_material.h"
#include "scene/resources/sky.h"
#include "scene/resources/surface_tool.h"
+#include "servers/physics_3d/physics_server_3d_types.h"
#include "servers/rendering/rendering_server.h"
using namespace Node3DEditorConstants;
@@ -2223,7 +2224,7 @@ void Node3DEditor::_snap_selected_nodes_to_floor() {
}
PhysicsDirectSpaceState3D *ss = get_tree()->get_root()->get_world_3d()->get_direct_space_state();
- PhysicsDirectSpaceState3D::RayResult result;
+ PS3DT::RayResult result;
// The maximum height an object can travel to be snapped
const float max_snap_height = 500.0;
@@ -2242,7 +2243,7 @@ void Node3DEditor::_snap_selected_nodes_to_floor() {
Vector3 to = from - Vector3(0.0, max_snap_height, 0.0);
HashSet<RID> excluded = _get_physics_bodies_rid(sp);
- PhysicsDirectSpaceState3D::RayParameters ray_params;
+ PS3DT::RayParameters ray_params;
ray_params.from = from;
ray_params.to = to;
ray_params.exclude = excluded;
@@ -2265,7 +2266,7 @@ void Node3DEditor::_snap_selected_nodes_to_floor() {
Vector3 to = from - Vector3(0.0, max_snap_height, 0.0);
HashSet<RID> excluded = _get_physics_bodies_rid(sp);
- PhysicsDirectSpaceState3D::RayParameters ray_params;
+ PS3DT::RayParameters ray_params;
ray_params.from = from;
ray_params.to = to;
ray_params.exclude = excluded;
diff --git a/editor/scene/3d/node_3d_editor_viewport.cpp b/editor/scene/3d/node_3d_editor_viewport.cpp
index 4c894fbd8f6..854dc878459 100644
--- a/editor/scene/3d/node_3d_editor_viewport.cpp
+++ b/editor/scene/3d/node_3d_editor_viewport.cpp
@@ -72,6 +72,7 @@
#include "scene/resources/gradient.h"
#include "scene/resources/immediate_mesh.h"
#include "scene/resources/packed_scene.h"
+#include "servers/physics_3d/physics_server_3d_types.h"
#include "servers/rendering/rendering_server.h"
using namespace Node3DEditorConstants;
@@ -5416,13 +5417,14 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos, Node3D
}
}
- PhysicsDirectSpaceState3D::RayParameters ray_params;
+ PS3DT::RayParameters ray_params;
ray_params.exclude = col_obj_rids_to_exclude;
ray_params.from = world_pos;
ray_params.to = world_pos + world_ray * camera->get_far();
PhysicsDirectSpaceState3D *ss = get_tree()->get_root()->get_world_3d()->get_direct_space_state();
- PhysicsDirectSpaceState3D::RayResult result;
+ PS3DT::RayResult result;
+
if (ss->intersect_ray(ray_params, result) && (preview_node->get_child_count() > 0 || !preview_node->is_inside_tree())) {
// Calculate an offset for the `p_node` such that the its bounding box is on top of and touching the contact surface's plane.
diff --git a/editor/scene/3d/path_3d_editor_plugin.cpp b/editor/scene/3d/path_3d_editor_plugin.cpp
index f5f13f1f19c..a483a5c0467 100644
--- a/editor/scene/3d/path_3d_editor_plugin.cpp
+++ b/editor/scene/3d/path_3d_editor_plugin.cpp
@@ -131,10 +131,10 @@ void Path3DGizmo::set_handle(int p_id, bool p_secondary, Camera3D *p_camera, con
if (Path3DEditorPlugin::singleton->snap_to_collider) {
PhysicsDirectSpaceState3D *ss = p_camera->get_world_3d()->get_direct_space_state();
- PhysicsDirectSpaceState3D::RayParameters ray_params;
+ PS3DT::RayParameters ray_params;
ray_params.from = ray_from;
ray_params.to = ray_from + ray_dir * p_camera->get_far();
- PhysicsDirectSpaceState3D::RayResult result;
+ PS3DT::RayResult result;
if (ss->intersect_ray(ray_params, result)) {
Vector3 local = gi.xform(result.position);
c->set_point_position(idx, local);
@@ -964,8 +964,8 @@ void Path3DEditorPlugin::_notification(int p_what) {
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
PhysicsDirectSpaceState3D *ss = get_tree()->get_root()->get_world_3d()->get_direct_space_state();
if (ss) {
- PhysicsDirectSpaceState3D::RayParameters ray_params;
- PhysicsDirectSpaceState3D::RayResult result;
+ PS3DT::RayParameters ray_params;
+ PS3DT::RayResult result;
ray_params.from = _edit.click_ray_pos;
ray_params.to = ray_params.from + _edit.click_ray_dir;
bool hit_something = false;
diff --git a/main/performance.cpp b/main/performance.cpp
index 93d9e66ba3a..cb4cac0d698 100644
--- a/main/performance.cpp
+++ b/main/performance.cpp
@@ -286,11 +286,11 @@ double Performance::get_monitor(Monitor p_monitor) const {
return RS::get_singleton()->get_rendering_info(RSE::RENDERING_INFO_PIPELINE_COMPILATIONS_SPECIALIZATION);
#ifndef PHYSICS_2D_DISABLED
case PHYSICS_2D_ACTIVE_OBJECTS:
- return PhysicsServer2D::get_singleton()->get_process_info(PhysicsServer2D::INFO_ACTIVE_OBJECTS);
+ return PhysicsServer2D::get_singleton()->get_process_info(PS2DE::INFO_ACTIVE_OBJECTS);
case PHYSICS_2D_COLLISION_PAIRS:
- return PhysicsServer2D::get_singleton()->get_process_info(PhysicsServer2D::INFO_COLLISION_PAIRS);
+ return PhysicsServer2D::get_singleton()->get_process_info(PS2DE::INFO_COLLISION_PAIRS);
case PHYSICS_2D_ISLAND_COUNT:
- return PhysicsServer2D::get_singleton()->get_process_info(PhysicsServer2D::INFO_ISLAND_COUNT);
+ return PhysicsServer2D::get_singleton()->get_process_info(PS2DE::INFO_ISLAND_COUNT);
#else
case PHYSICS_2D_ACTIVE_OBJECTS:
return 0;
@@ -301,11 +301,11 @@ double Performance::get_monitor(Monitor p_monitor) const {
#endif // PHYSICS_2D_DISABLED
#ifndef PHYSICS_3D_DISABLED
case PHYSICS_3D_ACTIVE_OBJECTS:
- return PhysicsServer3D::get_singleton()->get_process_info(PhysicsServer3D::INFO_ACTIVE_OBJECTS);
+ return PhysicsServer3D::get_singleton()->get_process_info(PS3DE::INFO_ACTIVE_OBJECTS);
case PHYSICS_3D_COLLISION_PAIRS:
- return PhysicsServer3D::get_singleton()->get_process_info(PhysicsServer3D::INFO_COLLISION_PAIRS);
+ return PhysicsServer3D::get_singleton()->get_process_info(PS3DE::INFO_COLLISION_PAIRS);
case PHYSICS_3D_ISLAND_COUNT:
- return PhysicsServer3D::get_singleton()->get_process_info(PhysicsServer3D::INFO_ISLAND_COUNT);
+ return PhysicsServer3D::get_singleton()->get_process_info(PS3DE::INFO_ISLAND_COUNT);
#else
case PHYSICS_3D_ACTIVE_OBJECTS:
return 0;
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 135a781000e..9dcf9db49ee 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -106,8 +106,8 @@ void CSGShape3D::set_use_collision(bool p_enable) {
if (use_collision) {
root_collision_shape.instantiate();
root_collision_body = PhysicsServer3D::get_singleton()->body_create();
- PhysicsServer3D::get_singleton()->body_set_mode(root_collision_body, PhysicsServer3D::BODY_MODE_STATIC);
- PhysicsServer3D::get_singleton()->body_set_state(root_collision_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_mode(root_collision_body, PS3DE::BODY_MODE_STATIC);
+ PhysicsServer3D::get_singleton()->body_set_state(root_collision_body, PS3DE::BODY_STATE_TRANSFORM, get_global_transform());
PhysicsServer3D::get_singleton()->body_add_shape(root_collision_body, root_collision_shape->get_rid());
PhysicsServer3D::get_singleton()->body_set_space(root_collision_body, get_world_3d()->get_space());
PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_body, get_instance_id());
@@ -1035,8 +1035,8 @@ void CSGShape3D::_notification(int p_what) {
if (use_collision && is_root_shape()) {
root_collision_shape.instantiate();
root_collision_body = PhysicsServer3D::get_singleton()->body_create();
- PhysicsServer3D::get_singleton()->body_set_mode(root_collision_body, PhysicsServer3D::BODY_MODE_STATIC);
- PhysicsServer3D::get_singleton()->body_set_state(root_collision_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_mode(root_collision_body, PS3DE::BODY_MODE_STATIC);
+ PhysicsServer3D::get_singleton()->body_set_state(root_collision_body, PS3DE::BODY_STATE_TRANSFORM, get_global_transform());
PhysicsServer3D::get_singleton()->body_add_shape(root_collision_body, root_collision_shape->get_rid());
PhysicsServer3D::get_singleton()->body_set_space(root_collision_body, get_world_3d()->get_space());
PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_body, get_instance_id());
@@ -1059,7 +1059,7 @@ void CSGShape3D::_notification(int p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
if (use_collision && is_root_shape() && root_collision_body.is_valid()) {
- PhysicsServer3D::get_singleton()->body_set_state(root_collision_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_state(root_collision_body, PS3DE::BODY_STATE_TRANSFORM, get_global_transform());
}
_on_transform_changed();
} break;
diff --git a/modules/godot_physics_2d/godot_area_2d.cpp b/modules/godot_physics_2d/godot_area_2d.cpp
index caf0048042b..2e5cf1babd5 100644
--- a/modules/godot_physics_2d/godot_area_2d.cpp
+++ b/modules/godot_physics_2d/godot_area_2d.cpp
@@ -112,9 +112,9 @@ void GodotArea2D::set_area_monitor_callback(const Callable &p_callback) {
}
}
-void GodotArea2D::_set_space_override_mode(PhysicsServer2D::AreaSpaceOverrideMode &r_mode, PhysicsServer2D::AreaSpaceOverrideMode p_new_mode) {
- bool do_override = p_new_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED;
- if (do_override == (r_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED)) {
+void GodotArea2D::_set_space_override_mode(PS2DE::AreaSpaceOverrideMode &r_mode, PS2DE::AreaSpaceOverrideMode p_new_mode) {
+ bool do_override = p_new_mode != PS2DE::AREA_SPACE_OVERRIDE_DISABLED;
+ if (do_override == (r_mode != PS2DE::AREA_SPACE_OVERRIDE_DISABLED)) {
return;
}
_unregister_shapes();
@@ -122,62 +122,62 @@ void GodotArea2D::_set_space_override_mode(PhysicsServer2D::AreaSpaceOverrideMod
_shape_changed();
}
-void GodotArea2D::set_param(PhysicsServer2D::AreaParameter p_param, const Variant &p_value) {
+void GodotArea2D::set_param(PS2DE::AreaParameter p_param, const Variant &p_value) {
switch (p_param) {
- case PhysicsServer2D::AREA_PARAM_GRAVITY_OVERRIDE_MODE:
- _set_space_override_mode(gravity_override_mode, (PhysicsServer2D::AreaSpaceOverrideMode)(int)p_value);
+ case PS2DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE:
+ _set_space_override_mode(gravity_override_mode, (PS2DE::AreaSpaceOverrideMode)(int)p_value);
break;
- case PhysicsServer2D::AREA_PARAM_GRAVITY:
+ case PS2DE::AREA_PARAM_GRAVITY:
gravity = p_value;
break;
- case PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR:
+ case PS2DE::AREA_PARAM_GRAVITY_VECTOR:
gravity_vector = p_value;
break;
- case PhysicsServer2D::AREA_PARAM_GRAVITY_IS_POINT:
+ case PS2DE::AREA_PARAM_GRAVITY_IS_POINT:
gravity_is_point = p_value;
break;
- case PhysicsServer2D::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE:
+ case PS2DE::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE:
gravity_point_unit_distance = p_value;
break;
- case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
- _set_space_override_mode(linear_damping_override_mode, (PhysicsServer2D::AreaSpaceOverrideMode)(int)p_value);
+ case PS2DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
+ _set_space_override_mode(linear_damping_override_mode, (PS2DE::AreaSpaceOverrideMode)(int)p_value);
break;
- case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP:
+ case PS2DE::AREA_PARAM_LINEAR_DAMP:
linear_damp = p_value;
break;
- case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
- _set_space_override_mode(angular_damping_override_mode, (PhysicsServer2D::AreaSpaceOverrideMode)(int)p_value);
+ case PS2DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
+ _set_space_override_mode(angular_damping_override_mode, (PS2DE::AreaSpaceOverrideMode)(int)p_value);
break;
- case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP:
+ case PS2DE::AREA_PARAM_ANGULAR_DAMP:
angular_damp = p_value;
break;
- case PhysicsServer2D::AREA_PARAM_PRIORITY:
+ case PS2DE::AREA_PARAM_PRIORITY:
priority = p_value;
break;
}
}
-Variant GodotArea2D::get_param(PhysicsServer2D::AreaParameter p_param) const {
+Variant GodotArea2D::get_param(PS2DE::AreaParameter p_param) const {
switch (p_param) {
- case PhysicsServer2D::AREA_PARAM_GRAVITY_OVERRIDE_MODE:
+ case PS2DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE:
return gravity_override_mode;
- case PhysicsServer2D::AREA_PARAM_GRAVITY:
+ case PS2DE::AREA_PARAM_GRAVITY:
return gravity;
- case PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR:
+ case PS2DE::AREA_PARAM_GRAVITY_VECTOR:
return gravity_vector;
- case PhysicsServer2D::AREA_PARAM_GRAVITY_IS_POINT:
+ case PS2DE::AREA_PARAM_GRAVITY_IS_POINT:
return gravity_is_point;
- case PhysicsServer2D::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE:
+ case PS2DE::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE:
return gravity_point_unit_distance;
- case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
+ case PS2DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
return linear_damping_override_mode;
- case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP:
+ case PS2DE::AREA_PARAM_LINEAR_DAMP:
return linear_damp;
- case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
+ case PS2DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
return angular_damping_override_mode;
- case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP:
+ case PS2DE::AREA_PARAM_ANGULAR_DAMP:
return angular_damp;
- case PhysicsServer2D::AREA_PARAM_PRIORITY:
+ case PS2DE::AREA_PARAM_PRIORITY:
return priority;
}
@@ -220,7 +220,7 @@ void GodotArea2D::call_queries() {
continue;
}
- res[0] = E->value.state > 0 ? PhysicsServer2D::AREA_BODY_ADDED : PhysicsServer2D::AREA_BODY_REMOVED;
+ res[0] = E->value.state > 0 ? PS2DE::AREA_BODY_ADDED : PS2DE::AREA_BODY_REMOVED;
res[1] = E->key.rid;
res[2] = E->key.instance_id;
res[3] = E->key.body_shape;
@@ -262,7 +262,7 @@ void GodotArea2D::call_queries() {
continue;
}
- res[0] = E->value.state > 0 ? PhysicsServer2D::AREA_BODY_ADDED : PhysicsServer2D::AREA_BODY_REMOVED;
+ res[0] = E->value.state > 0 ? PS2DE::AREA_BODY_ADDED : PS2DE::AREA_BODY_REMOVED;
res[1] = E->key.rid;
res[2] = E->key.instance_id;
res[3] = E->key.body_shape;
diff --git a/modules/godot_physics_2d/godot_area_2d.h b/modules/godot_physics_2d/godot_area_2d.h
index b5040c58691..9d16139b19c 100644
--- a/modules/godot_physics_2d/godot_area_2d.h
+++ b/modules/godot_physics_2d/godot_area_2d.h
@@ -32,17 +32,18 @@
#include "godot_collision_object_2d.h"
+#include "core/templates/hash_set.h"
#include "core/templates/self_list.h"
-#include "servers/physics_2d/physics_server_2d.h"
+#include "core/variant/callable.h"
class GodotSpace2D;
class GodotBody2D;
class GodotConstraint2D;
class GodotArea2D : public GodotCollisionObject2D {
- PhysicsServer2D::AreaSpaceOverrideMode gravity_override_mode = PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED;
- PhysicsServer2D::AreaSpaceOverrideMode linear_damping_override_mode = PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED;
- PhysicsServer2D::AreaSpaceOverrideMode angular_damping_override_mode = PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED;
+ PS2DE::AreaSpaceOverrideMode gravity_override_mode = PS2DE::AREA_SPACE_OVERRIDE_DISABLED;
+ PS2DE::AreaSpaceOverrideMode linear_damping_override_mode = PS2DE::AREA_SPACE_OVERRIDE_DISABLED;
+ PS2DE::AreaSpaceOverrideMode angular_damping_override_mode = PS2DE::AREA_SPACE_OVERRIDE_DISABLED;
real_t gravity = 9.80665;
Vector2 gravity_vector = Vector2(0, -1);
@@ -96,7 +97,7 @@ class GodotArea2D : public GodotCollisionObject2D {
virtual void _shapes_changed() override;
void _queue_monitor_update();
- void _set_space_override_mode(PhysicsServer2D::AreaSpaceOverrideMode &r_mode, PhysicsServer2D::AreaSpaceOverrideMode p_new_mode);
+ void _set_space_override_mode(PS2DE::AreaSpaceOverrideMode &r_mode, PS2DE::AreaSpaceOverrideMode p_new_mode);
public:
void set_monitor_callback(const Callable &p_callback);
@@ -111,8 +112,8 @@ public:
_FORCE_INLINE_ void add_area_to_query(GodotArea2D *p_area, uint32_t p_area_shape, uint32_t p_self_shape);
_FORCE_INLINE_ void remove_area_from_query(GodotArea2D *p_area, uint32_t p_area_shape, uint32_t p_self_shape);
- void set_param(PhysicsServer2D::AreaParameter p_param, const Variant &p_value);
- Variant get_param(PhysicsServer2D::AreaParameter p_param) const;
+ void set_param(PS2DE::AreaParameter p_param, const Variant &p_value);
+ Variant get_param(PS2DE::AreaParameter p_param) const;
_FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity = p_gravity; }
_FORCE_INLINE_ real_t get_gravity() const { return gravity; }
diff --git a/modules/godot_physics_2d/godot_area_pair_2d.cpp b/modules/godot_physics_2d/godot_area_pair_2d.cpp
index d04842f79fd..eb7c5886bde 100644
--- a/modules/godot_physics_2d/godot_area_pair_2d.cpp
+++ b/modules/godot_physics_2d/godot_area_pair_2d.cpp
@@ -41,11 +41,11 @@ bool GodotAreaPair2D::setup(real_t p_step) {
process_collision = false;
has_space_override = false;
if (result != colliding) {
- if ((int)area->get_param(PhysicsServer2D::AREA_PARAM_GRAVITY_OVERRIDE_MODE) != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
+ if ((int)area->get_param(PS2DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE) != PS2DE::AREA_SPACE_OVERRIDE_DISABLED) {
has_space_override = true;
- } else if ((int)area->get_param(PhysicsServer2D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE) != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
+ } else if ((int)area->get_param(PS2DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE) != PS2DE::AREA_SPACE_OVERRIDE_DISABLED) {
has_space_override = true;
- } else if ((int)area->get_param(PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE) != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
+ } else if ((int)area->get_param(PS2DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE) != PS2DE::AREA_SPACE_OVERRIDE_DISABLED) {
has_space_override = true;
}
process_collision = has_space_override;
@@ -99,7 +99,7 @@ GodotAreaPair2D::GodotAreaPair2D(GodotBody2D *p_body, int p_body_shape, GodotAre
area_shape = p_area_shape;
body->add_constraint(this, 0);
area->add_constraint(this);
- if (p_body->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) { //need to be active to process pair
+ if (p_body->get_mode() == PS2DE::BODY_MODE_KINEMATIC) { //need to be active to process pair
p_body->set_active(true);
}
}
diff --git a/modules/godot_physics_2d/godot_body_2d.cpp b/modules/godot_physics_2d/godot_body_2d.cpp
index 65a5e1eebcf..2034954f1dd 100644
--- a/modules/godot_physics_2d/godot_body_2d.cpp
+++ b/modules/godot_physics_2d/godot_body_2d.cpp
@@ -45,7 +45,7 @@ void GodotBody2D::update_mass_properties() {
//update shapes and motions
switch (mode) {
- case PhysicsServer2D::BODY_MODE_RIGID: {
+ case PS2DE::BODY_MODE_RIGID: {
real_t total_area = 0;
for (int i = 0; i < get_shape_count(); i++) {
if (is_shape_disabled(i)) {
@@ -109,12 +109,12 @@ void GodotBody2D::update_mass_properties() {
}
} break;
- case PhysicsServer2D::BODY_MODE_KINEMATIC:
- case PhysicsServer2D::BODY_MODE_STATIC: {
+ case PS2DE::BODY_MODE_KINEMATIC:
+ case PS2DE::BODY_MODE_STATIC: {
_inv_inertia = 0;
_inv_mass = 0;
} break;
- case PhysicsServer2D::BODY_MODE_RIGID_LINEAR: {
+ case PS2DE::BODY_MODE_RIGID_LINEAR: {
_inv_inertia = 0;
_inv_mass = 1.0 / mass;
@@ -138,7 +138,7 @@ void GodotBody2D::set_active(bool p_active) {
active = p_active;
if (active) {
- if (mode == PhysicsServer2D::BODY_MODE_STATIC) {
+ if (mode == PS2DE::BODY_MODE_STATIC) {
// Static bodies can't be active.
active = false;
} else if (get_space()) {
@@ -149,60 +149,60 @@ void GodotBody2D::set_active(bool p_active) {
}
}
-void GodotBody2D::set_param(PhysicsServer2D::BodyParameter p_param, const Variant &p_value) {
+void GodotBody2D::set_param(PS2DE::BodyParameter p_param, const Variant &p_value) {
switch (p_param) {
- case PhysicsServer2D::BODY_PARAM_BOUNCE: {
+ case PS2DE::BODY_PARAM_BOUNCE: {
bounce = p_value;
} break;
- case PhysicsServer2D::BODY_PARAM_FRICTION: {
+ case PS2DE::BODY_PARAM_FRICTION: {
friction = p_value;
} break;
- case PhysicsServer2D::BODY_PARAM_MASS: {
+ case PS2DE::BODY_PARAM_MASS: {
real_t mass_value = p_value;
ERR_FAIL_COND(mass_value <= 0);
mass = mass_value;
- if (mode >= PhysicsServer2D::BODY_MODE_RIGID) {
+ if (mode >= PS2DE::BODY_MODE_RIGID) {
_mass_properties_changed();
}
} break;
- case PhysicsServer2D::BODY_PARAM_INERTIA: {
+ case PS2DE::BODY_PARAM_INERTIA: {
real_t inertia_value = p_value;
if (inertia_value <= 0.0) {
calculate_inertia = true;
- if (mode == PhysicsServer2D::BODY_MODE_RIGID) {
+ if (mode == PS2DE::BODY_MODE_RIGID) {
_mass_properties_changed();
}
} else {
calculate_inertia = false;
inertia = inertia_value;
- if (mode == PhysicsServer2D::BODY_MODE_RIGID) {
+ if (mode == PS2DE::BODY_MODE_RIGID) {
_inv_inertia = 1.0 / inertia;
}
}
} break;
- case PhysicsServer2D::BODY_PARAM_CENTER_OF_MASS: {
+ case PS2DE::BODY_PARAM_CENTER_OF_MASS: {
calculate_center_of_mass = false;
center_of_mass_local = p_value;
_update_transform_dependent();
} break;
- case PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE: {
+ case PS2DE::BODY_PARAM_GRAVITY_SCALE: {
if (Math::is_zero_approx(gravity_scale)) {
wakeup();
}
gravity_scale = p_value;
} break;
- case PhysicsServer2D::BODY_PARAM_LINEAR_DAMP_MODE: {
+ case PS2DE::BODY_PARAM_LINEAR_DAMP_MODE: {
int mode_value = p_value;
- linear_damp_mode = (PhysicsServer2D::BodyDampMode)mode_value;
+ linear_damp_mode = (PS2DE::BodyDampMode)mode_value;
} break;
- case PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP_MODE: {
+ case PS2DE::BODY_PARAM_ANGULAR_DAMP_MODE: {
int mode_value = p_value;
- angular_damp_mode = (PhysicsServer2D::BodyDampMode)mode_value;
+ angular_damp_mode = (PS2DE::BodyDampMode)mode_value;
} break;
- case PhysicsServer2D::BODY_PARAM_LINEAR_DAMP: {
+ case PS2DE::BODY_PARAM_LINEAR_DAMP: {
linear_damp = p_value;
} break;
- case PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP: {
+ case PS2DE::BODY_PARAM_ANGULAR_DAMP: {
angular_damp = p_value;
} break;
default: {
@@ -210,36 +210,36 @@ void GodotBody2D::set_param(PhysicsServer2D::BodyParameter p_param, const Varian
}
}
-Variant GodotBody2D::get_param(PhysicsServer2D::BodyParameter p_param) const {
+Variant GodotBody2D::get_param(PS2DE::BodyParameter p_param) const {
switch (p_param) {
- case PhysicsServer2D::BODY_PARAM_BOUNCE: {
+ case PS2DE::BODY_PARAM_BOUNCE: {
return bounce;
}
- case PhysicsServer2D::BODY_PARAM_FRICTION: {
+ case PS2DE::BODY_PARAM_FRICTION: {
return friction;
}
- case PhysicsServer2D::BODY_PARAM_MASS: {
+ case PS2DE::BODY_PARAM_MASS: {
return mass;
}
- case PhysicsServer2D::BODY_PARAM_INERTIA: {
+ case PS2DE::BODY_PARAM_INERTIA: {
return inertia;
}
- case PhysicsServer2D::BODY_PARAM_CENTER_OF_MASS: {
+ case PS2DE::BODY_PARAM_CENTER_OF_MASS: {
return center_of_mass_local;
}
- case PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE: {
+ case PS2DE::BODY_PARAM_GRAVITY_SCALE: {
return gravity_scale;
}
- case PhysicsServer2D::BODY_PARAM_LINEAR_DAMP_MODE: {
+ case PS2DE::BODY_PARAM_LINEAR_DAMP_MODE: {
return linear_damp_mode;
}
- case PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP_MODE: {
+ case PS2DE::BODY_PARAM_ANGULAR_DAMP_MODE: {
return angular_damp_mode;
}
- case PhysicsServer2D::BODY_PARAM_LINEAR_DAMP: {
+ case PS2DE::BODY_PARAM_LINEAR_DAMP: {
return linear_damp;
}
- case PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP: {
+ case PS2DE::BODY_PARAM_ANGULAR_DAMP: {
return angular_damp;
}
default: {
@@ -249,26 +249,26 @@ Variant GodotBody2D::get_param(PhysicsServer2D::BodyParameter p_param) const {
return 0;
}
-void GodotBody2D::set_mode(PhysicsServer2D::BodyMode p_mode) {
- PhysicsServer2D::BodyMode prev = mode;
+void GodotBody2D::set_mode(PS2DE::BodyMode p_mode) {
+ PS2DE::BodyMode prev = mode;
mode = p_mode;
switch (p_mode) {
//CLEAR UP EVERYTHING IN CASE IT NOT WORKS!
- case PhysicsServer2D::BODY_MODE_STATIC:
- case PhysicsServer2D::BODY_MODE_KINEMATIC: {
+ case PS2DE::BODY_MODE_STATIC:
+ case PS2DE::BODY_MODE_KINEMATIC: {
_set_inv_transform(get_transform().affine_inverse());
_inv_mass = 0;
_inv_inertia = 0;
- _set_static(p_mode == PhysicsServer2D::BODY_MODE_STATIC);
- set_active(p_mode == PhysicsServer2D::BODY_MODE_KINEMATIC && contacts.size());
+ _set_static(p_mode == PS2DE::BODY_MODE_STATIC);
+ set_active(p_mode == PS2DE::BODY_MODE_KINEMATIC && contacts.size());
linear_velocity = Vector2();
angular_velocity = 0;
- if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC && prev != mode) {
+ if (mode == PS2DE::BODY_MODE_KINEMATIC && prev != mode) {
first_time_kinematic = true;
}
} break;
- case PhysicsServer2D::BODY_MODE_RIGID: {
+ case PS2DE::BODY_MODE_RIGID: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
if (!calculate_inertia) {
_inv_inertia = 1.0 / inertia;
@@ -278,7 +278,7 @@ void GodotBody2D::set_mode(PhysicsServer2D::BodyMode p_mode) {
set_active(true);
} break;
- case PhysicsServer2D::BODY_MODE_RIGID_LINEAR: {
+ case PS2DE::BODY_MODE_RIGID_LINEAR: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_inv_inertia = 0;
angular_velocity = 0;
@@ -288,7 +288,7 @@ void GodotBody2D::set_mode(PhysicsServer2D::BodyMode p_mode) {
}
}
-PhysicsServer2D::BodyMode GodotBody2D::get_mode() const {
+PS2DE::BodyMode GodotBody2D::get_mode() const {
return mode;
}
@@ -298,10 +298,10 @@ void GodotBody2D::_shapes_changed() {
wakeup_neighbours();
}
-void GodotBody2D::set_state(PhysicsServer2D::BodyState p_state, const Variant &p_variant) {
+void GodotBody2D::set_state(PS2DE::BodyState p_state, const Variant &p_variant) {
switch (p_state) {
- case PhysicsServer2D::BODY_STATE_TRANSFORM: {
- if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
+ case PS2DE::BODY_STATE_TRANSFORM: {
+ if (mode == PS2DE::BODY_MODE_KINEMATIC) {
new_transform = p_variant;
//wakeup_neighbours();
set_active(true);
@@ -310,7 +310,7 @@ void GodotBody2D::set_state(PhysicsServer2D::BodyState p_state, const Variant &p
_set_inv_transform(get_transform().affine_inverse());
first_time_kinematic = false;
}
- } else if (mode == PhysicsServer2D::BODY_MODE_STATIC) {
+ } else if (mode == PS2DE::BODY_MODE_STATIC) {
_set_transform(p_variant);
_set_inv_transform(get_transform().affine_inverse());
wakeup_neighbours();
@@ -328,20 +328,20 @@ void GodotBody2D::set_state(PhysicsServer2D::BodyState p_state, const Variant &p
wakeup();
} break;
- case PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY: {
+ case PS2DE::BODY_STATE_LINEAR_VELOCITY: {
linear_velocity = p_variant;
constant_linear_velocity = linear_velocity;
wakeup();
} break;
- case PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY: {
+ case PS2DE::BODY_STATE_ANGULAR_VELOCITY: {
angular_velocity = p_variant;
constant_angular_velocity = angular_velocity;
wakeup();
} break;
- case PhysicsServer2D::BODY_STATE_SLEEPING: {
- if (mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
+ case PS2DE::BODY_STATE_SLEEPING: {
+ if (mode == PS2DE::BODY_MODE_STATIC || mode == PS2DE::BODY_MODE_KINEMATIC) {
break;
}
bool do_sleep = p_variant;
@@ -352,14 +352,14 @@ void GodotBody2D::set_state(PhysicsServer2D::BodyState p_state, const Variant &p
//biased_angular_velocity=Vector3();
set_active(false);
} else {
- if (mode != PhysicsServer2D::BODY_MODE_STATIC) {
+ if (mode != PS2DE::BODY_MODE_STATIC) {
set_active(true);
}
}
} break;
- case PhysicsServer2D::BODY_STATE_CAN_SLEEP: {
+ case PS2DE::BODY_STATE_CAN_SLEEP: {
can_sleep = p_variant;
- if (mode >= PhysicsServer2D::BODY_MODE_RIGID && !active && !can_sleep) {
+ if (mode >= PS2DE::BODY_MODE_RIGID && !active && !can_sleep) {
set_active(true);
}
@@ -367,21 +367,21 @@ void GodotBody2D::set_state(PhysicsServer2D::BodyState p_state, const Variant &p
}
}
-Variant GodotBody2D::get_state(PhysicsServer2D::BodyState p_state) const {
+Variant GodotBody2D::get_state(PS2DE::BodyState p_state) const {
switch (p_state) {
- case PhysicsServer2D::BODY_STATE_TRANSFORM: {
+ case PS2DE::BODY_STATE_TRANSFORM: {
return get_transform();
}
- case PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY: {
+ case PS2DE::BODY_STATE_LINEAR_VELOCITY: {
return linear_velocity;
}
- case PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY: {
+ case PS2DE::BODY_STATE_ANGULAR_VELOCITY: {
return angular_velocity;
}
- case PhysicsServer2D::BODY_STATE_SLEEPING: {
+ case PS2DE::BODY_STATE_SLEEPING: {
return !is_active();
}
- case PhysicsServer2D::BODY_STATE_CAN_SLEEP: {
+ case PS2DE::BODY_STATE_CAN_SLEEP: {
return can_sleep;
}
}
@@ -420,7 +420,7 @@ void GodotBody2D::_update_transform_dependent() {
}
void GodotBody2D::integrate_forces(real_t p_step) {
- if (mode == PhysicsServer2D::BODY_MODE_STATIC) {
+ if (mode == PS2DE::BODY_MODE_STATIC) {
return;
}
@@ -445,20 +445,20 @@ void GodotBody2D::integrate_forces(real_t p_step) {
const AreaCMP *aa = &areas[0];
for (int i = ac - 1; i >= 0 && !stopped; i--) {
if (!gravity_done) {
- PhysicsServer2D::AreaSpaceOverrideMode area_gravity_mode = (PhysicsServer2D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer2D::AREA_PARAM_GRAVITY_OVERRIDE_MODE);
- if (area_gravity_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
+ PS2DE::AreaSpaceOverrideMode area_gravity_mode = (PS2DE::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PS2DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE);
+ if (area_gravity_mode != PS2DE::AREA_SPACE_OVERRIDE_DISABLED) {
Vector2 area_gravity;
aa[i].area->compute_gravity(get_transform().get_origin(), area_gravity);
switch (area_gravity_mode) {
- case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE:
- case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
+ case PS2DE::AREA_SPACE_OVERRIDE_COMBINE:
+ case PS2DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
gravity += area_gravity;
- gravity_done = area_gravity_mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
+ gravity_done = area_gravity_mode == PS2DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
- case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE:
- case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
+ case PS2DE::AREA_SPACE_OVERRIDE_REPLACE:
+ case PS2DE::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
gravity = area_gravity;
- gravity_done = area_gravity_mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE;
+ gravity_done = area_gravity_mode == PS2DE::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
@@ -466,19 +466,19 @@ void GodotBody2D::integrate_forces(real_t p_step) {
}
}
if (!linear_damp_done) {
- PhysicsServer2D::AreaSpaceOverrideMode area_linear_damp_mode = (PhysicsServer2D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer2D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE);
- if (area_linear_damp_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
+ PS2DE::AreaSpaceOverrideMode area_linear_damp_mode = (PS2DE::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PS2DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE);
+ if (area_linear_damp_mode != PS2DE::AREA_SPACE_OVERRIDE_DISABLED) {
real_t area_linear_damp = aa[i].area->get_linear_damp();
switch (area_linear_damp_mode) {
- case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE:
- case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
+ case PS2DE::AREA_SPACE_OVERRIDE_COMBINE:
+ case PS2DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
total_linear_damp += area_linear_damp;
- linear_damp_done = area_linear_damp_mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
+ linear_damp_done = area_linear_damp_mode == PS2DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
- case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE:
- case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
+ case PS2DE::AREA_SPACE_OVERRIDE_REPLACE:
+ case PS2DE::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
total_linear_damp = area_linear_damp;
- linear_damp_done = area_linear_damp_mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE;
+ linear_damp_done = area_linear_damp_mode == PS2DE::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
@@ -486,19 +486,19 @@ void GodotBody2D::integrate_forces(real_t p_step) {
}
}
if (!angular_damp_done) {
- PhysicsServer2D::AreaSpaceOverrideMode area_angular_damp_mode = (PhysicsServer2D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE);
- if (area_angular_damp_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
+ PS2DE::AreaSpaceOverrideMode area_angular_damp_mode = (PS2DE::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PS2DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE);
+ if (area_angular_damp_mode != PS2DE::AREA_SPACE_OVERRIDE_DISABLED) {
real_t area_angular_damp = aa[i].area->get_angular_damp();
switch (area_angular_damp_mode) {
- case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE:
- case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
+ case PS2DE::AREA_SPACE_OVERRIDE_COMBINE:
+ case PS2DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
total_angular_damp += area_angular_damp;
- angular_damp_done = area_angular_damp_mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
+ angular_damp_done = area_angular_damp_mode == PS2DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
- case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE:
- case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
+ case PS2DE::AREA_SPACE_OVERRIDE_REPLACE:
+ case PS2DE::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
total_angular_damp = area_angular_damp;
- angular_damp_done = area_angular_damp_mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE;
+ angular_damp_done = area_angular_damp_mode == PS2DE::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
@@ -531,20 +531,20 @@ void GodotBody2D::integrate_forces(real_t p_step) {
// Override linear damping with body's value.
switch (linear_damp_mode) {
- case PhysicsServer2D::BODY_DAMP_MODE_COMBINE: {
+ case PS2DE::BODY_DAMP_MODE_COMBINE: {
total_linear_damp += linear_damp;
} break;
- case PhysicsServer2D::BODY_DAMP_MODE_REPLACE: {
+ case PS2DE::BODY_DAMP_MODE_REPLACE: {
total_linear_damp = linear_damp;
} break;
}
// Override angular damping with body's value.
switch (angular_damp_mode) {
- case PhysicsServer2D::BODY_DAMP_MODE_COMBINE: {
+ case PS2DE::BODY_DAMP_MODE_COMBINE: {
total_angular_damp += angular_damp;
} break;
- case PhysicsServer2D::BODY_DAMP_MODE_REPLACE: {
+ case PS2DE::BODY_DAMP_MODE_REPLACE: {
total_angular_damp = angular_damp;
} break;
}
@@ -557,7 +557,7 @@ void GodotBody2D::integrate_forces(real_t p_step) {
Vector2 motion;
bool do_motion = false;
- if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
+ if (mode == PS2DE::BODY_MODE_KINEMATIC) {
//compute motion, angular and etc. velocities from prev transform
motion = new_transform.get_origin() - get_transform().get_origin();
linear_velocity = constant_linear_velocity + motion / p_step;
@@ -593,7 +593,7 @@ void GodotBody2D::integrate_forces(real_t p_step) {
angular_velocity += _inv_inertia * torque * p_step;
}
- if (continuous_cd_mode != PhysicsServer2D::CCD_MODE_DISABLED) {
+ if (continuous_cd_mode != PS2DE::CCD_MODE_DISABLED) {
motion = linear_velocity * p_step;
do_motion = true;
}
@@ -613,7 +613,7 @@ void GodotBody2D::integrate_forces(real_t p_step) {
}
void GodotBody2D::integrate_velocities(real_t p_step) {
- if (mode == PhysicsServer2D::BODY_MODE_STATIC) {
+ if (mode == PS2DE::BODY_MODE_STATIC) {
return;
}
@@ -623,7 +623,7 @@ void GodotBody2D::integrate_velocities(real_t p_step) {
get_space()->body_add_to_state_query_list(&direct_state_query_list);
}
- if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
+ if (mode == PS2DE::BODY_MODE_KINEMATIC) {
_set_transform(new_transform, false);
_set_inv_transform(new_transform.affine_inverse());
if (contacts.is_empty() && linear_velocity == Vector2() && angular_velocity == 0) {
@@ -644,10 +644,10 @@ void GodotBody2D::integrate_velocities(real_t p_step) {
pos += center_of_mass - center_of_mass.rotated(angle_delta);
}
- _set_transform(Transform2D(angle, pos), continuous_cd_mode == PhysicsServer2D::CCD_MODE_DISABLED);
+ _set_transform(Transform2D(angle, pos), continuous_cd_mode == PS2DE::CCD_MODE_DISABLED);
_set_inv_transform(get_transform().inverse());
- if (continuous_cd_mode != PhysicsServer2D::CCD_MODE_DISABLED) {
+ if (continuous_cd_mode != PS2DE::CCD_MODE_DISABLED) {
new_transform = get_transform();
}
@@ -665,7 +665,7 @@ void GodotBody2D::wakeup_neighbours() {
continue;
}
GodotBody2D *b = n[i];
- if (b->mode < PhysicsServer2D::BODY_MODE_RIGID) {
+ if (b->mode < PS2DE::BODY_MODE_RIGID) {
continue;
}
@@ -702,7 +702,7 @@ void GodotBody2D::call_queries() {
}
bool GodotBody2D::sleep_test(real_t p_step) {
- if (mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
+ if (mode == PS2DE::BODY_MODE_STATIC || mode == PS2DE::BODY_MODE_KINEMATIC) {
return true;
} else if (!can_sleep) {
return false;
diff --git a/modules/godot_physics_2d/godot_body_2d.h b/modules/godot_physics_2d/godot_body_2d.h
index bcb55c6d323..2f328ad5412 100644
--- a/modules/godot_physics_2d/godot_body_2d.h
+++ b/modules/godot_physics_2d/godot_body_2d.h
@@ -36,12 +36,14 @@
#include "core/templates/list.h"
#include "core/templates/pair.h"
#include "core/templates/vset.h"
+#include "core/variant/variant.h"
+#include "servers/physics_2d/physics_server_2d_constants.h"
class GodotConstraint2D;
class GodotPhysicsDirectBodyState2D;
class GodotBody2D : public GodotCollisionObject2D {
- PhysicsServer2D::BodyMode mode = PhysicsServer2D::BODY_MODE_RIGID;
+ PS2DE::BodyMode mode = PS2DE::BODY_MODE_RIGID;
Vector2 biased_linear_velocity;
real_t biased_angular_velocity = 0.0;
@@ -55,8 +57,8 @@ class GodotBody2D : public GodotCollisionObject2D {
Vector2 constant_linear_velocity;
real_t constant_angular_velocity = 0.0;
- PhysicsServer2D::BodyDampMode linear_damp_mode = PhysicsServer2D::BODY_DAMP_MODE_COMBINE;
- PhysicsServer2D::BodyDampMode angular_damp_mode = PhysicsServer2D::BODY_DAMP_MODE_COMBINE;
+ PS2DE::BodyDampMode linear_damp_mode = PS2DE::BODY_DAMP_MODE_COMBINE;
+ PS2DE::BodyDampMode angular_damp_mode = PS2DE::BODY_DAMP_MODE_COMBINE;
real_t linear_damp = 0.0;
real_t angular_damp = 0.0;
@@ -96,7 +98,7 @@ class GodotBody2D : public GodotCollisionObject2D {
SelfList<GodotBody2D> direct_state_query_list;
VSet<RID> exceptions;
- PhysicsServer2D::CCDMode continuous_cd_mode = PhysicsServer2D::CCD_MODE_DISABLED;
+ PS2DE::CCDMode continuous_cd_mode = PS2DE::CCD_MODE_DISABLED;
bool omit_force_integration = false;
bool active = true;
bool can_sleep = true;
@@ -181,10 +183,10 @@ public:
}
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) {
- ERR_FAIL_INDEX(p_size, MAX_CONTACTS_REPORTED_2D_MAX);
+ ERR_FAIL_INDEX(p_size, PS2DC::MAX_CONTACTS_REPORTED_2D_MAX);
contacts.resize(p_size);
contact_count = 0;
- if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC && p_size) {
+ if (mode == PS2DE::BODY_MODE_KINEMATIC && p_size) {
set_active(true);
}
}
@@ -285,23 +287,23 @@ public:
_FORCE_INLINE_ bool is_active() const { return active; }
_FORCE_INLINE_ void wakeup() {
- if ((!get_space()) || mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
+ if ((!get_space()) || mode == PS2DE::BODY_MODE_STATIC || mode == PS2DE::BODY_MODE_KINEMATIC) {
return;
}
set_active(true);
}
- void set_param(PhysicsServer2D::BodyParameter p_param, const Variant &p_value);
- Variant get_param(PhysicsServer2D::BodyParameter p_param) const;
+ void set_param(PS2DE::BodyParameter p_param, const Variant &p_value);
+ Variant get_param(PS2DE::BodyParameter p_param) const;
- void set_mode(PhysicsServer2D::BodyMode p_mode);
- PhysicsServer2D::BodyMode get_mode() const;
+ void set_mode(PS2DE::BodyMode p_mode);
+ PS2DE::BodyMode get_mode() const;
- void set_state(PhysicsServer2D::BodyState p_state, const Variant &p_variant);
- Variant get_state(PhysicsServer2D::BodyState p_state) const;
+ void set_state(PS2DE::BodyState p_state, const Variant &p_variant);
+ Variant get_state(PS2DE::BodyState p_state) const;
- _FORCE_INLINE_ void set_continuous_collision_detection_mode(PhysicsServer2D::CCDMode p_mode) { continuous_cd_mode = p_mode; }
- _FORCE_INLINE_ PhysicsServer2D::CCDMode get_continuous_collision_detection_mode() const { return continuous_cd_mode; }
+ _FORCE_INLINE_ void set_continuous_collision_detection_mode(PS2DE::CCDMode p_mode) { continuous_cd_mode = p_mode; }
+ _FORCE_INLINE_ PS2DE::CCDMode get_continuous_collision_detection_mode() const { return continuous_cd_mode; }
void set_space(GodotSpace2D *p_space) override;
@@ -323,9 +325,9 @@ public:
}
_FORCE_INLINE_ Vector2 get_motion() const {
- if (mode > PhysicsServer2D::BODY_MODE_KINEMATIC) {
+ if (mode > PS2DE::BODY_MODE_KINEMATIC) {
return new_transform.get_origin() - get_transform().get_origin();
- } else if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
+ } else if (mode == PS2DE::BODY_MODE_KINEMATIC) {
return get_transform().get_origin() - new_transform.get_origin(); //kinematic simulates forward
}
return Vector2();
diff --git a/modules/godot_physics_2d/godot_body_direct_state_2d.cpp b/modules/godot_physics_2d/godot_body_direct_state_2d.cpp
index 3400229f76a..98ee57d688d 100644
--- a/modules/godot_physics_2d/godot_body_direct_state_2d.cpp
+++ b/modules/godot_physics_2d/godot_body_direct_state_2d.cpp
@@ -80,7 +80,7 @@ real_t GodotPhysicsDirectBodyState2D::get_angular_velocity() const {
}
void GodotPhysicsDirectBodyState2D::set_transform(const Transform2D &p_transform) {
- body->set_state(PhysicsServer2D::BODY_STATE_TRANSFORM, p_transform);
+ body->set_state(PS2DE::BODY_STATE_TRANSFORM, p_transform);
}
Transform2D GodotPhysicsDirectBodyState2D::get_transform() const {
diff --git a/modules/godot_physics_2d/godot_body_direct_state_2d.h b/modules/godot_physics_2d/godot_body_direct_state_2d.h
index 7afa6142881..38f4fc61a9e 100644
--- a/modules/godot_physics_2d/godot_body_direct_state_2d.h
+++ b/modules/godot_physics_2d/godot_body_direct_state_2d.h
@@ -30,7 +30,7 @@
#pragma once
-#include "servers/physics_2d/physics_server_2d.h"
+#include "servers/physics_2d/direct_states/physics_direct_body_state_2d.h"
class GodotBody2D;
diff --git a/modules/godot_physics_2d/godot_body_pair_2d.cpp b/modules/godot_physics_2d/godot_body_pair_2d.cpp
index c108b9fb067..bd2b4195bd6 100644
--- a/modules/godot_physics_2d/godot_body_pair_2d.cpp
+++ b/modules/godot_physics_2d/godot_body_pair_2d.cpp
@@ -256,8 +256,8 @@ bool GodotBodyPair2D::setup(real_t p_step) {
return false;
}
- collide_A = (A->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) && A->collides_with(B);
- collide_B = (B->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) && B->collides_with(A);
+ collide_A = (A->get_mode() > PS2DE::BODY_MODE_KINEMATIC) && A->collides_with(B);
+ collide_B = (B->get_mode() > PS2DE::BODY_MODE_KINEMATIC) && B->collides_with(A);
report_contacts_only = false;
if (!collide_A && !collide_B) {
@@ -287,10 +287,10 @@ bool GodotBodyPair2D::setup(real_t p_step) {
Vector2 motion_A, motion_B;
- if (A->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_SHAPE) {
+ if (A->get_continuous_collision_detection_mode() == PS2DE::CCD_MODE_CAST_SHAPE) {
motion_A = A->get_motion();
}
- if (B->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_SHAPE) {
+ if (B->get_continuous_collision_detection_mode() == PS2DE::CCD_MODE_CAST_SHAPE) {
motion_B = B->get_motion();
}
@@ -300,12 +300,12 @@ bool GodotBodyPair2D::setup(real_t p_step) {
if (!collided) {
oneway_disabled = false;
- if (A->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && collide_A) {
+ if (A->get_continuous_collision_detection_mode() == PS2DE::CCD_MODE_CAST_RAY && collide_A) {
check_ccd = true;
return true;
}
- if (B->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && collide_B) {
+ if (B->get_continuous_collision_detection_mode() == PS2DE::CCD_MODE_CAST_RAY && collide_B) {
check_ccd = true;
return true;
}
@@ -375,11 +375,11 @@ bool GodotBodyPair2D::pre_solve(real_t p_step) {
xform_Bu.columns[2] -= offset_A;
Transform2D xform_B = xform_Bu * B->get_shape_transform(shape_B);
- if (A->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && collide_A) {
+ if (A->get_continuous_collision_detection_mode() == PS2DE::CCD_MODE_CAST_RAY && collide_A) {
_test_ccd(p_step, A, shape_A, xform_A, B, shape_B, xform_B);
}
- if (B->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && collide_B) {
+ if (B->get_continuous_collision_detection_mode() == PS2DE::CCD_MODE_CAST_RAY && collide_B) {
_test_ccd(p_step, B, shape_B, xform_B, A, shape_A, xform_A);
}
}
diff --git a/modules/godot_physics_2d/godot_collision_object_2d.h b/modules/godot_physics_2d/godot_collision_object_2d.h
index d1de665bf9b..56f1b90f4be 100644
--- a/modules/godot_physics_2d/godot_collision_object_2d.h
+++ b/modules/godot_physics_2d/godot_collision_object_2d.h
@@ -33,6 +33,7 @@
#include "godot_broad_phase_2d.h"
#include "godot_shape_2d.h"
+#include "core/object/object_id.h"
#include "core/templates/self_list.h"
class GodotSpace2D;
diff --git a/modules/godot_physics_2d/godot_collision_solver_2d.cpp b/modules/godot_physics_2d/godot_collision_solver_2d.cpp
index 637a0679aef..a9f1e3fb00d 100644
--- a/modules/godot_physics_2d/godot_collision_solver_2d.cpp
+++ b/modules/godot_physics_2d/godot_collision_solver_2d.cpp
@@ -37,7 +37,7 @@
bool GodotCollisionSolver2D::solve_static_world_boundary(const GodotShape2D *p_shape_A, const Transform2D &p_transform_A, const GodotShape2D *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin) {
const GodotWorldBoundaryShape2D *world_boundary = static_cast<const GodotWorldBoundaryShape2D *>(p_shape_A);
- if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_WORLD_BOUNDARY) {
+ if (p_shape_B->get_type() == PS2DE::SHAPE_WORLD_BOUNDARY) {
return false;
}
@@ -78,7 +78,7 @@ bool GodotCollisionSolver2D::solve_static_world_boundary(const GodotShape2D *p_s
bool GodotCollisionSolver2D::solve_separation_ray(const GodotShape2D *p_shape_A, const Vector2 &p_motion_A, const Transform2D &p_transform_A, const GodotShape2D *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *r_sep_axis, real_t p_margin) {
const GodotSeparationRayShape2D *ray = static_cast<const GodotSeparationRayShape2D *>(p_shape_A);
- if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_SEPARATION_RAY) {
+ if (p_shape_B->get_type() == PS2DE::SHAPE_SEPARATION_RAY) {
return false;
}
@@ -218,8 +218,8 @@ bool GodotCollisionSolver2D::solve_concave(const GodotShape2D *p_shape_A, const
}
bool GodotCollisionSolver2D::solve(const GodotShape2D *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const GodotShape2D *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, Vector2 *r_sep_axis, real_t p_margin_A, real_t p_margin_B) {
- PhysicsServer2D::ShapeType type_A = p_shape_A->get_type();
- PhysicsServer2D::ShapeType type_B = p_shape_B->get_type();
+ PS2DE::ShapeType type_A = p_shape_A->get_type();
+ PS2DE::ShapeType type_B = p_shape_B->get_type();
bool concave_A = p_shape_A->is_concave();
bool concave_B = p_shape_B->is_concave();
real_t margin_A = p_margin_A, margin_B = p_margin_B;
@@ -233,8 +233,8 @@ bool GodotCollisionSolver2D::solve(const GodotShape2D *p_shape_A, const Transfor
swap = true;
}
- if (type_A == PhysicsServer2D::SHAPE_WORLD_BOUNDARY) {
- if (type_B == PhysicsServer2D::SHAPE_WORLD_BOUNDARY) {
+ if (type_A == PS2DE::SHAPE_WORLD_BOUNDARY) {
+ if (type_B == PS2DE::SHAPE_WORLD_BOUNDARY) {
WARN_PRINT_ONCE("Collisions between world boundaries are not supported.");
return false;
}
@@ -245,8 +245,8 @@ bool GodotCollisionSolver2D::solve(const GodotShape2D *p_shape_A, const Transfor
return solve_static_world_boundary(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_motion_B, p_result_callback, p_userdata, false, p_margin_B);
}
- } else if (type_A == PhysicsServer2D::SHAPE_SEPARATION_RAY) {
- if (type_B == PhysicsServer2D::SHAPE_SEPARATION_RAY) {
+ } else if (type_A == PS2DE::SHAPE_SEPARATION_RAY) {
+ if (type_B == PS2DE::SHAPE_SEPARATION_RAY) {
WARN_PRINT_ONCE("Collisions between two rays are not supported.");
return false; //no ray-ray
}
diff --git a/modules/godot_physics_2d/godot_collision_solver_2d_sat.cpp b/modules/godot_physics_2d/godot_collision_solver_2d_sat.cpp
index 96f0c2cee9d..cf049042db2 100644
--- a/modules/godot_physics_2d/godot_collision_solver_2d_sat.cpp
+++ b/modules/godot_physics_2d/godot_collision_solver_2d_sat.cpp
@@ -1104,16 +1104,16 @@ static void _collision_convex_polygon_convex_polygon(const GodotShape2D *p_a, co
////////
bool sat_2d_calculate_penetration(const GodotShape2D *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const GodotShape2D *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, GodotCollisionSolver2D::CallbackResult p_result_callback, void *p_userdata, bool p_swap, Vector2 *sep_axis, real_t p_margin_A, real_t p_margin_B) {
- PhysicsServer2D::ShapeType type_A = p_shape_A->get_type();
+ PS2DE::ShapeType type_A = p_shape_A->get_type();
- ERR_FAIL_COND_V(type_A == PhysicsServer2D::SHAPE_WORLD_BOUNDARY, false);
- ERR_FAIL_COND_V(type_A == PhysicsServer2D::SHAPE_SEPARATION_RAY, false);
+ ERR_FAIL_COND_V(type_A == PS2DE::SHAPE_WORLD_BOUNDARY, false);
+ ERR_FAIL_COND_V(type_A == PS2DE::SHAPE_SEPARATION_RAY, false);
ERR_FAIL_COND_V(p_shape_A->is_concave(), false);
- PhysicsServer2D::ShapeType type_B = p_shape_B->get_type();
+ PS2DE::ShapeType type_B = p_shape_B->get_type();
- ERR_FAIL_COND_V(type_B == PhysicsServer2D::SHAPE_WORLD_BOUNDARY, false);
- ERR_FAIL_COND_V(type_B == PhysicsServer2D::SHAPE_SEPARATION_RAY, false);
+ ERR_FAIL_COND_V(type_B == PS2DE::SHAPE_WORLD_BOUNDARY, false);
+ ERR_FAIL_COND_V(type_B == PS2DE::SHAPE_SEPARATION_RAY, false);
ERR_FAIL_COND_V(p_shape_B->is_concave(), false);
static const CollisionFunc collision_table[5][5] = {
diff --git a/modules/godot_physics_2d/godot_joints_2d.cpp b/modules/godot_physics_2d/godot_joints_2d.cpp
index 457d1cbc614..8083d326aab 100644
--- a/modules/godot_physics_2d/godot_joints_2d.cpp
+++ b/modules/godot_physics_2d/godot_joints_2d.cpp
@@ -97,8 +97,8 @@ normal_relative_velocity(GodotBody2D *a, GodotBody2D *b, Vector2 rA, Vector2 rB,
}
bool GodotPinJoint2D::setup(real_t p_step) {
- dynamic_A = (A->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC);
- dynamic_B = (B->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC);
+ dynamic_A = (A->get_mode() > PS2DE::BODY_MODE_KINEMATIC);
+ dynamic_B = (B->get_mode() > PS2DE::BODY_MODE_KINEMATIC);
if (!dynamic_A && !dynamic_B) {
return false;
@@ -256,58 +256,58 @@ void GodotPinJoint2D::solve(real_t p_step) {
P += impulse;
}
-void GodotPinJoint2D::set_param(PhysicsServer2D::PinJointParam p_param, real_t p_value) {
+void GodotPinJoint2D::set_param(PS2DE::PinJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer2D::PIN_JOINT_SOFTNESS: {
+ case PS2DE::PIN_JOINT_SOFTNESS: {
softness = p_value;
} break;
- case PhysicsServer2D::PIN_JOINT_LIMIT_UPPER: {
+ case PS2DE::PIN_JOINT_LIMIT_UPPER: {
angular_limit_upper = p_value;
} break;
- case PhysicsServer2D::PIN_JOINT_LIMIT_LOWER: {
+ case PS2DE::PIN_JOINT_LIMIT_LOWER: {
angular_limit_lower = p_value;
} break;
- case PhysicsServer2D::PIN_JOINT_MOTOR_TARGET_VELOCITY: {
+ case PS2DE::PIN_JOINT_MOTOR_TARGET_VELOCITY: {
motor_target_velocity = p_value;
} break;
}
}
-real_t GodotPinJoint2D::get_param(PhysicsServer2D::PinJointParam p_param) const {
+real_t GodotPinJoint2D::get_param(PS2DE::PinJointParam p_param) const {
switch (p_param) {
- case PhysicsServer2D::PIN_JOINT_SOFTNESS: {
+ case PS2DE::PIN_JOINT_SOFTNESS: {
return softness;
}
- case PhysicsServer2D::PIN_JOINT_LIMIT_UPPER: {
+ case PS2DE::PIN_JOINT_LIMIT_UPPER: {
return angular_limit_upper;
}
- case PhysicsServer2D::PIN_JOINT_LIMIT_LOWER: {
+ case PS2DE::PIN_JOINT_LIMIT_LOWER: {
return angular_limit_lower;
}
- case PhysicsServer2D::PIN_JOINT_MOTOR_TARGET_VELOCITY: {
+ case PS2DE::PIN_JOINT_MOTOR_TARGET_VELOCITY: {
return motor_target_velocity;
}
}
ERR_FAIL_V(0);
}
-void GodotPinJoint2D::set_flag(PhysicsServer2D::PinJointFlag p_flag, bool p_enabled) {
+void GodotPinJoint2D::set_flag(PS2DE::PinJointFlag p_flag, bool p_enabled) {
switch (p_flag) {
- case PhysicsServer2D::PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED: {
+ case PS2DE::PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED: {
angular_limit_enabled = p_enabled;
} break;
- case PhysicsServer2D::PIN_JOINT_FLAG_MOTOR_ENABLED: {
+ case PS2DE::PIN_JOINT_FLAG_MOTOR_ENABLED: {
motor_enabled = p_enabled;
} break;
}
}
-bool GodotPinJoint2D::get_flag(PhysicsServer2D::PinJointFlag p_flag) const {
+bool GodotPinJoint2D::get_flag(PS2DE::PinJointFlag p_flag) const {
switch (p_flag) {
- case PhysicsServer2D::PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED: {
+ case PS2DE::PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED: {
return angular_limit_enabled;
}
- case PhysicsServer2D::PIN_JOINT_FLAG_MOTOR_ENABLED: {
+ case PS2DE::PIN_JOINT_FLAG_MOTOR_ENABLED: {
return motor_enabled;
}
}
@@ -383,8 +383,8 @@ mult_k(const Vector2 &vr, const Vector2 &k1, const Vector2 &k2) {
}
bool GodotGrooveJoint2D::setup(real_t p_step) {
- dynamic_A = (A->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC);
- dynamic_B = (B->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC);
+ dynamic_A = (A->get_mode() > PS2DE::BODY_MODE_KINEMATIC);
+ dynamic_B = (B->get_mode() > PS2DE::BODY_MODE_KINEMATIC);
if (!dynamic_A && !dynamic_B) {
return false;
@@ -489,8 +489,8 @@ GodotGrooveJoint2D::GodotGrooveJoint2D(const Vector2 &p_a_groove1, const Vector2
//////////////////////////////////////////////
bool GodotDampedSpringJoint2D::setup(real_t p_step) {
- dynamic_A = (A->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC);
- dynamic_B = (B->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC);
+ dynamic_A = (A->get_mode() > PS2DE::BODY_MODE_KINEMATIC);
+ dynamic_B = (B->get_mode() > PS2DE::BODY_MODE_KINEMATIC);
if (!dynamic_A && !dynamic_B) {
return false;
@@ -551,29 +551,29 @@ void GodotDampedSpringJoint2D::solve(real_t p_step) {
}
}
-void GodotDampedSpringJoint2D::set_param(PhysicsServer2D::DampedSpringParam p_param, real_t p_value) {
+void GodotDampedSpringJoint2D::set_param(PS2DE::DampedSpringParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer2D::DAMPED_SPRING_REST_LENGTH: {
+ case PS2DE::DAMPED_SPRING_REST_LENGTH: {
rest_length = p_value;
} break;
- case PhysicsServer2D::DAMPED_SPRING_DAMPING: {
+ case PS2DE::DAMPED_SPRING_DAMPING: {
damping = p_value;
} break;
- case PhysicsServer2D::DAMPED_SPRING_STIFFNESS: {
+ case PS2DE::DAMPED_SPRING_STIFFNESS: {
stiffness = p_value;
} break;
}
}
-real_t GodotDampedSpringJoint2D::get_param(PhysicsServer2D::DampedSpringParam p_param) const {
+real_t GodotDampedSpringJoint2D::get_param(PS2DE::DampedSpringParam p_param) const {
switch (p_param) {
- case PhysicsServer2D::DAMPED_SPRING_REST_LENGTH: {
+ case PS2DE::DAMPED_SPRING_REST_LENGTH: {
return rest_length;
} break;
- case PhysicsServer2D::DAMPED_SPRING_DAMPING: {
+ case PS2DE::DAMPED_SPRING_DAMPING: {
return damping;
} break;
- case PhysicsServer2D::DAMPED_SPRING_STIFFNESS: {
+ case PS2DE::DAMPED_SPRING_STIFFNESS: {
return stiffness;
} break;
}
diff --git a/modules/godot_physics_2d/godot_joints_2d.h b/modules/godot_physics_2d/godot_joints_2d.h
index bb3cdd57c54..d255f84b35b 100644
--- a/modules/godot_physics_2d/godot_joints_2d.h
+++ b/modules/godot_physics_2d/godot_joints_2d.h
@@ -58,7 +58,7 @@ public:
void copy_settings_from(GodotJoint2D *p_joint);
- virtual PhysicsServer2D::JointType get_type() const { return PhysicsServer2D::JOINT_TYPE_MAX; }
+ virtual PS2DE::JointType get_type() const { return PS2DE::JOINT_TYPE_MAX; }
GodotJoint2D(GodotBody2D **p_body_ptr = nullptr, int p_body_count = 0) :
GodotConstraint2D(p_body_ptr, p_body_count) {}
@@ -102,17 +102,17 @@ class GodotPinJoint2D : public GodotJoint2D {
bool angular_limit_enabled = false;
public:
- virtual PhysicsServer2D::JointType get_type() const override { return PhysicsServer2D::JOINT_TYPE_PIN; }
+ virtual PS2DE::JointType get_type() const override { return PS2DE::JOINT_TYPE_PIN; }
virtual bool setup(real_t p_step) override;
virtual bool pre_solve(real_t p_step) override;
virtual void solve(real_t p_step) override;
- void set_param(PhysicsServer2D::PinJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer2D::PinJointParam p_param) const;
+ void set_param(PS2DE::PinJointParam p_param, real_t p_value);
+ real_t get_param(PS2DE::PinJointParam p_param) const;
- void set_flag(PhysicsServer2D::PinJointFlag p_flag, bool p_enabled);
- bool get_flag(PhysicsServer2D::PinJointFlag p_flag) const;
+ void set_flag(PS2DE::PinJointFlag p_flag, bool p_enabled);
+ bool get_flag(PS2DE::PinJointFlag p_flag) const;
GodotPinJoint2D(const Vector2 &p_pos, GodotBody2D *p_body_a, GodotBody2D *p_body_b = nullptr);
};
@@ -142,7 +142,7 @@ class GodotGrooveJoint2D : public GodotJoint2D {
bool correct = false;
public:
- virtual PhysicsServer2D::JointType get_type() const override { return PhysicsServer2D::JOINT_TYPE_GROOVE; }
+ virtual PS2DE::JointType get_type() const override { return PS2DE::JOINT_TYPE_GROOVE; }
virtual bool setup(real_t p_step) override;
virtual bool pre_solve(real_t p_step) override;
@@ -176,14 +176,14 @@ class GodotDampedSpringJoint2D : public GodotJoint2D {
real_t v_coef = 0.0;
public:
- virtual PhysicsServer2D::JointType get_type() const override { return PhysicsServer2D::JOINT_TYPE_DAMPED_SPRING; }
+ virtual PS2DE::JointType get_type() const override { return PS2DE::JOINT_TYPE_DAMPED_SPRING; }
virtual bool setup(real_t p_step) override;
virtual bool pre_solve(real_t p_step) override;
virtual void solve(real_t p_step) override;
- void set_param(PhysicsServer2D::DampedSpringParam p_param, real_t p_value);
- real_t get_param(PhysicsServer2D::DampedSpringParam p_param) const;
+ void set_param(PS2DE::DampedSpringParam p_param, real_t p_value);
+ real_t get_param(PS2DE::DampedSpringParam p_param) const;
GodotDampedSpringJoint2D(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, GodotBody2D *p_body_a, GodotBody2D *p_body_b);
};
diff --git a/modules/godot_physics_2d/godot_physics_server_2d.cpp b/modules/godot_physics_2d/godot_physics_server_2d.cpp
index ba4562280d6..9054f4746d3 100644
--- a/modules/godot_physics_2d/godot_physics_server_2d.cpp
+++ b/modules/godot_physics_2d/godot_physics_server_2d.cpp
@@ -40,34 +40,34 @@
#define FLUSH_QUERY_CHECK(m_object) \
ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.");
-RID GodotPhysicsServer2D::_shape_create(ShapeType p_shape) {
+RID GodotPhysicsServer2D::_shape_create(PS2DE::ShapeType p_shape) {
GodotShape2D *shape = nullptr;
switch (p_shape) {
- case SHAPE_WORLD_BOUNDARY: {
+ case PS2DE::SHAPE_WORLD_BOUNDARY: {
shape = memnew(GodotWorldBoundaryShape2D);
} break;
- case SHAPE_SEPARATION_RAY: {
+ case PS2DE::SHAPE_SEPARATION_RAY: {
shape = memnew(GodotSeparationRayShape2D);
} break;
- case SHAPE_SEGMENT: {
+ case PS2DE::SHAPE_SEGMENT: {
shape = memnew(GodotSegmentShape2D);
} break;
- case SHAPE_CIRCLE: {
+ case PS2DE::SHAPE_CIRCLE: {
shape = memnew(GodotCircleShape2D);
} break;
- case SHAPE_RECTANGLE: {
+ case PS2DE::SHAPE_RECTANGLE: {
shape = memnew(GodotRectangleShape2D);
} break;
- case SHAPE_CAPSULE: {
+ case PS2DE::SHAPE_CAPSULE: {
shape = memnew(GodotCapsuleShape2D);
} break;
- case SHAPE_CONVEX_POLYGON: {
+ case PS2DE::SHAPE_CONVEX_POLYGON: {
shape = memnew(GodotConvexPolygonShape2D);
} break;
- case SHAPE_CONCAVE_POLYGON: {
+ case PS2DE::SHAPE_CONCAVE_POLYGON: {
shape = memnew(GodotConcavePolygonShape2D);
} break;
- case SHAPE_CUSTOM: {
+ case PS2DE::SHAPE_CUSTOM: {
ERR_FAIL_V(RID());
} break;
@@ -80,35 +80,35 @@ RID GodotPhysicsServer2D::_shape_create(ShapeType p_shape) {
}
RID GodotPhysicsServer2D::world_boundary_shape_create() {
- return _shape_create(SHAPE_WORLD_BOUNDARY);
+ return _shape_create(PS2DE::SHAPE_WORLD_BOUNDARY);
}
RID GodotPhysicsServer2D::separation_ray_shape_create() {
- return _shape_create(SHAPE_SEPARATION_RAY);
+ return _shape_create(PS2DE::SHAPE_SEPARATION_RAY);
}
RID GodotPhysicsServer2D::segment_shape_create() {
- return _shape_create(SHAPE_SEGMENT);
+ return _shape_create(PS2DE::SHAPE_SEGMENT);
}
RID GodotPhysicsServer2D::circle_shape_create() {
- return _shape_create(SHAPE_CIRCLE);
+ return _shape_create(PS2DE::SHAPE_CIRCLE);
}
RID GodotPhysicsServer2D::rectangle_shape_create() {
- return _shape_create(SHAPE_RECTANGLE);
+ return _shape_create(PS2DE::SHAPE_RECTANGLE);
}
RID GodotPhysicsServer2D::capsule_shape_create() {
- return _shape_create(SHAPE_CAPSULE);
+ return _shape_create(PS2DE::SHAPE_CAPSULE);
}
RID GodotPhysicsServer2D::convex_polygon_shape_create() {
- return _shape_create(SHAPE_CONVEX_POLYGON);
+ return _shape_create(PS2DE::SHAPE_CONVEX_POLYGON);
}
RID GodotPhysicsServer2D::concave_polygon_shape_create() {
- return _shape_create(SHAPE_CONCAVE_POLYGON);
+ return _shape_create(PS2DE::SHAPE_CONCAVE_POLYGON);
}
void GodotPhysicsServer2D::shape_set_data(RID p_shape, const Variant &p_data) {
@@ -123,9 +123,9 @@ void GodotPhysicsServer2D::shape_set_custom_solver_bias(RID p_shape, real_t p_bi
shape->set_custom_bias(p_bias);
}
-PhysicsServer2D::ShapeType GodotPhysicsServer2D::shape_get_type(RID p_shape) const {
+PS2DE::ShapeType GodotPhysicsServer2D::shape_get_type(RID p_shape) const {
const GodotShape2D *shape = shape_owner.get_or_null(p_shape);
- ERR_FAIL_NULL_V(shape, SHAPE_CUSTOM);
+ ERR_FAIL_NULL_V(shape, PS2DE::SHAPE_CUSTOM);
return shape->get_type();
}
@@ -244,14 +244,14 @@ bool GodotPhysicsServer2D::space_is_active(RID p_space) const {
return active_spaces.has(space);
}
-void GodotPhysicsServer2D::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
+void GodotPhysicsServer2D::space_set_param(RID p_space, PS2DE::SpaceParameter p_param, real_t p_value) {
GodotSpace2D *space = space_owner.get_or_null(p_space);
ERR_FAIL_NULL(space);
space->set_param(p_param, p_value);
}
-real_t GodotPhysicsServer2D::space_get_param(RID p_space, SpaceParameter p_param) const {
+real_t GodotPhysicsServer2D::space_get_param(RID p_space, PS2DE::SpaceParameter p_param) const {
const GodotSpace2D *space = space_owner.get_or_null(p_space);
ERR_FAIL_NULL_V(space, 0);
return space->get_param(p_param);
@@ -436,7 +436,7 @@ ObjectID GodotPhysicsServer2D::area_get_canvas_instance_id(RID p_area) const {
return area->get_canvas_instance_id();
}
-void GodotPhysicsServer2D::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
+void GodotPhysicsServer2D::area_set_param(RID p_area, PS2DE::AreaParameter p_param, const Variant &p_value) {
if (space_owner.owns(p_area)) {
GodotSpace2D *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
@@ -452,7 +452,7 @@ void GodotPhysicsServer2D::area_set_transform(RID p_area, const Transform2D &p_t
area->set_transform(p_transform);
}
-Variant GodotPhysicsServer2D::area_get_param(RID p_area, AreaParameter p_param) const {
+Variant GodotPhysicsServer2D::area_get_param(RID p_area, PS2DE::AreaParameter p_param) const {
if (space_owner.owns(p_area)) {
GodotSpace2D *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
@@ -563,7 +563,7 @@ RID GodotPhysicsServer2D::body_get_space(RID p_body) const {
return space->get_self();
}
-void GodotPhysicsServer2D::body_set_mode(RID p_body, BodyMode p_mode) {
+void GodotPhysicsServer2D::body_set_mode(RID p_body, PS2DE::BodyMode p_mode) {
GodotBody2D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
FLUSH_QUERY_CHECK(body);
@@ -571,9 +571,9 @@ void GodotPhysicsServer2D::body_set_mode(RID p_body, BodyMode p_mode) {
body->set_mode(p_mode);
}
-PhysicsServer2D::BodyMode GodotPhysicsServer2D::body_get_mode(RID p_body) const {
+PS2DE::BodyMode GodotPhysicsServer2D::body_get_mode(RID p_body) const {
GodotBody2D *body = body_owner.get_or_null(p_body);
- ERR_FAIL_NULL_V(body, BODY_MODE_STATIC);
+ ERR_FAIL_NULL_V(body, PS2DE::BODY_MODE_STATIC);
return body->get_mode();
}
@@ -664,15 +664,15 @@ void GodotPhysicsServer2D::body_set_shape_as_one_way_collision(RID p_body, int p
body->set_shape_as_one_way_collision(p_shape_idx, p_enable, p_margin, p_direction);
}
-void GodotPhysicsServer2D::body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) {
+void GodotPhysicsServer2D::body_set_continuous_collision_detection_mode(RID p_body, PS2DE::CCDMode p_mode) {
GodotBody2D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
body->set_continuous_collision_detection_mode(p_mode);
}
-GodotPhysicsServer2D::CCDMode GodotPhysicsServer2D::body_get_continuous_collision_detection_mode(RID p_body) const {
+PS2DE::CCDMode GodotPhysicsServer2D::body_get_continuous_collision_detection_mode(RID p_body) const {
const GodotBody2D *body = body_owner.get_or_null(p_body);
- ERR_FAIL_NULL_V(body, CCD_MODE_DISABLED);
+ ERR_FAIL_NULL_V(body, PS2DE::CCD_MODE_DISABLED);
return body->get_continuous_collision_detection_mode();
}
@@ -745,14 +745,14 @@ real_t GodotPhysicsServer2D::body_get_collision_priority(RID p_body) const {
return body->get_collision_priority();
}
-void GodotPhysicsServer2D::body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) {
+void GodotPhysicsServer2D::body_set_param(RID p_body, PS2DE::BodyParameter p_param, const Variant &p_value) {
GodotBody2D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
body->set_param(p_param, p_value);
}
-Variant GodotPhysicsServer2D::body_get_param(RID p_body, BodyParameter p_param) const {
+Variant GodotPhysicsServer2D::body_get_param(RID p_body, PS2DE::BodyParameter p_param) const {
GodotBody2D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, 0);
@@ -766,14 +766,14 @@ void GodotPhysicsServer2D::body_reset_mass_properties(RID p_body) {
return body->reset_mass_properties();
}
-void GodotPhysicsServer2D::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
+void GodotPhysicsServer2D::body_set_state(RID p_body, PS2DE::BodyState p_state, const Variant &p_variant) {
GodotBody2D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
body->set_state(p_state, p_variant);
}
-Variant GodotPhysicsServer2D::body_get_state(RID p_body, BodyState p_state) const {
+Variant GodotPhysicsServer2D::body_get_state(RID p_body, PS2DE::BodyState p_state) const {
GodotBody2D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, Variant());
@@ -990,7 +990,7 @@ void GodotPhysicsServer2D::body_set_pickable(RID p_body, bool p_pickable) {
body->set_pickable(p_pickable);
}
-bool GodotPhysicsServer2D::body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result) {
+bool GodotPhysicsServer2D::body_test_motion(RID p_body, const PS2DT::MotionParameters &p_parameters, PS2DT::MotionResult *r_result) {
GodotBody2D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, false);
ERR_FAIL_NULL_V(body->get_space(), false);
@@ -1032,7 +1032,7 @@ RID GodotPhysicsServer2D::joint_create() {
void GodotPhysicsServer2D::joint_clear(RID p_joint) {
GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- if (joint->get_type() != JOINT_TYPE_MAX) {
+ if (joint->get_type() != PS2DE::JOINT_TYPE_MAX) {
GodotJoint2D *empty_joint = memnew(GodotJoint2D);
empty_joint->copy_settings_from(joint);
@@ -1041,35 +1041,35 @@ void GodotPhysicsServer2D::joint_clear(RID p_joint) {
}
}
-void GodotPhysicsServer2D::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) {
+void GodotPhysicsServer2D::joint_set_param(RID p_joint, PS2DE::JointParam p_param, real_t p_value) {
GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
switch (p_param) {
- case JOINT_PARAM_BIAS:
+ case PS2DE::JOINT_PARAM_BIAS:
joint->set_bias(p_value);
break;
- case JOINT_PARAM_MAX_BIAS:
+ case PS2DE::JOINT_PARAM_MAX_BIAS:
joint->set_max_bias(p_value);
break;
- case JOINT_PARAM_MAX_FORCE:
+ case PS2DE::JOINT_PARAM_MAX_FORCE:
joint->set_max_force(p_value);
break;
}
}
-real_t GodotPhysicsServer2D::joint_get_param(RID p_joint, JointParam p_param) const {
+real_t GodotPhysicsServer2D::joint_get_param(RID p_joint, PS2DE::JointParam p_param) const {
const GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, -1);
switch (p_param) {
- case JOINT_PARAM_BIAS:
+ case PS2DE::JOINT_PARAM_BIAS:
return joint->get_bias();
break;
- case JOINT_PARAM_MAX_BIAS:
+ case PS2DE::JOINT_PARAM_MAX_BIAS:
return joint->get_max_bias();
break;
- case JOINT_PARAM_MAX_FORCE:
+ case PS2DE::JOINT_PARAM_MAX_FORCE:
return joint->get_max_force();
break;
}
@@ -1157,63 +1157,63 @@ void GodotPhysicsServer2D::joint_make_damped_spring(RID p_joint, const Vector2 &
memdelete(prev_joint);
}
-void GodotPhysicsServer2D::pin_joint_set_flag(RID p_joint, PinJointFlag p_flag, bool p_enabled) {
+void GodotPhysicsServer2D::pin_joint_set_flag(RID p_joint, PS2DE::PinJointFlag p_flag, bool p_enabled) {
GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
+ ERR_FAIL_COND(joint->get_type() != PS2DE::JOINT_TYPE_PIN);
GodotPinJoint2D *pin_joint = static_cast<GodotPinJoint2D *>(joint);
pin_joint->set_flag(p_flag, p_enabled);
}
-bool GodotPhysicsServer2D::pin_joint_get_flag(RID p_joint, PinJointFlag p_flag) const {
+bool GodotPhysicsServer2D::pin_joint_get_flag(RID p_joint, PS2DE::PinJointFlag p_flag) const {
GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, false);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, false);
+ ERR_FAIL_COND_V(joint->get_type() != PS2DE::JOINT_TYPE_PIN, false);
GodotPinJoint2D *pin_joint = static_cast<GodotPinJoint2D *>(joint);
return pin_joint->get_flag(p_flag);
}
-void GodotPhysicsServer2D::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
+void GodotPhysicsServer2D::pin_joint_set_param(RID p_joint, PS2DE::PinJointParam p_param, real_t p_value) {
GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
+ ERR_FAIL_COND(joint->get_type() != PS2DE::JOINT_TYPE_PIN);
GodotPinJoint2D *pin_joint = static_cast<GodotPinJoint2D *>(joint);
pin_joint->set_param(p_param, p_value);
}
-real_t GodotPhysicsServer2D::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
+real_t GodotPhysicsServer2D::pin_joint_get_param(RID p_joint, PS2DE::PinJointParam p_param) const {
GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, 0);
+ ERR_FAIL_COND_V(joint->get_type() != PS2DE::JOINT_TYPE_PIN, 0);
GodotPinJoint2D *pin_joint = static_cast<GodotPinJoint2D *>(joint);
return pin_joint->get_param(p_param);
}
-void GodotPhysicsServer2D::damped_spring_joint_set_param(RID p_joint, DampedSpringParam p_param, real_t p_value) {
+void GodotPhysicsServer2D::damped_spring_joint_set_param(RID p_joint, PS2DE::DampedSpringParam p_param, real_t p_value) {
GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_DAMPED_SPRING);
+ ERR_FAIL_COND(joint->get_type() != PS2DE::JOINT_TYPE_DAMPED_SPRING);
GodotDampedSpringJoint2D *dsj = static_cast<GodotDampedSpringJoint2D *>(joint);
dsj->set_param(p_param, p_value);
}
-real_t GodotPhysicsServer2D::damped_spring_joint_get_param(RID p_joint, DampedSpringParam p_param) const {
+real_t GodotPhysicsServer2D::damped_spring_joint_get_param(RID p_joint, PS2DE::DampedSpringParam p_param) const {
GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_DAMPED_SPRING, 0);
+ ERR_FAIL_COND_V(joint->get_type() != PS2DE::JOINT_TYPE_DAMPED_SPRING, 0);
GodotDampedSpringJoint2D *dsj = static_cast<GodotDampedSpringJoint2D *>(joint);
return dsj->get_param(p_param);
}
-PhysicsServer2D::JointType GodotPhysicsServer2D::joint_get_type(RID p_joint) const {
+PS2DE::JointType GodotPhysicsServer2D::joint_get_type(RID p_joint) const {
GodotJoint2D *joint = joint_owner.get_or_null(p_joint);
- ERR_FAIL_NULL_V(joint, JOINT_TYPE_PIN);
+ ERR_FAIL_NULL_V(joint, PS2DE::JOINT_TYPE_PIN);
return joint->get_type();
}
@@ -1372,15 +1372,15 @@ void GodotPhysicsServer2D::_update_shapes() {
}
}
-int GodotPhysicsServer2D::get_process_info(ProcessInfo p_info) {
+int GodotPhysicsServer2D::get_process_info(PS2DE::ProcessInfo p_info) {
switch (p_info) {
- case INFO_ACTIVE_OBJECTS: {
+ case PS2DE::INFO_ACTIVE_OBJECTS: {
return active_objects;
} break;
- case INFO_COLLISION_PAIRS: {
+ case PS2DE::INFO_COLLISION_PAIRS: {
return collision_pairs;
} break;
- case INFO_ISLAND_COUNT: {
+ case PS2DE::INFO_ISLAND_COUNT: {
return island_count;
} break;
}
diff --git a/modules/godot_physics_2d/godot_physics_server_2d.h b/modules/godot_physics_2d/godot_physics_server_2d.h
index c9130c55e99..0e9b7979a17 100644
--- a/modules/godot_physics_2d/godot_physics_server_2d.h
+++ b/modules/godot_physics_2d/godot_physics_server_2d.h
@@ -69,7 +69,7 @@ class GodotPhysicsServer2D : public PhysicsServer2D {
SelfList<GodotCollisionObject2D>::List pending_shape_update_list;
void _update_shapes();
- RID _shape_create(ShapeType p_shape);
+ RID _shape_create(PS2DE::ShapeType p_shape);
public:
struct CollCbkData {
@@ -96,7 +96,7 @@ public:
virtual void shape_set_data(RID p_shape, const Variant &p_data) override;
virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias) override;
- virtual ShapeType shape_get_type(RID p_shape) const override;
+ virtual PS2DE::ShapeType shape_get_type(RID p_shape) const override;
virtual Variant shape_get_data(RID p_shape) const override;
virtual real_t shape_get_custom_solver_bias(RID p_shape) const override;
@@ -108,8 +108,8 @@ public:
virtual void space_set_active(RID p_space, bool p_active) override;
virtual bool space_is_active(RID p_space) const override;
- virtual void space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) override;
- virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const override;
+ virtual void space_set_param(RID p_space, PS2DE::SpaceParameter p_param, real_t p_value) override;
+ virtual real_t space_get_param(RID p_space, PS2DE::SpaceParameter p_param) const override;
virtual void space_set_debug_contacts(RID p_space, int p_max_contacts) override;
virtual Vector<Vector2> space_get_contacts(RID p_space) const override;
@@ -144,10 +144,10 @@ public:
virtual void area_attach_canvas_instance_id(RID p_area, ObjectID p_id) override;
virtual ObjectID area_get_canvas_instance_id(RID p_area) const override;
- virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) override;
+ virtual void area_set_param(RID p_area, PS2DE::AreaParameter p_param, const Variant &p_value) override;
virtual void area_set_transform(RID p_area, const Transform2D &p_transform) override;
- virtual Variant area_get_param(RID p_area, AreaParameter p_param) const override;
+ virtual Variant area_get_param(RID p_area, PS2DE::AreaParameter p_param) const override;
virtual Transform2D area_get_transform(RID p_area) const override;
virtual void area_set_monitorable(RID p_area, bool p_monitorable) override;
@@ -170,8 +170,8 @@ public:
virtual void body_set_space(RID p_body, RID p_space) override;
virtual RID body_get_space(RID p_body) const override;
- virtual void body_set_mode(RID p_body, BodyMode p_mode) override;
- virtual BodyMode body_get_mode(RID p_body) const override;
+ virtual void body_set_mode(RID p_body, PS2DE::BodyMode p_mode) override;
+ virtual PS2DE::BodyMode body_get_mode(RID p_body) const override;
virtual void body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false) override;
virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape) override;
@@ -193,8 +193,8 @@ public:
virtual void body_attach_canvas_instance_id(RID p_body, ObjectID p_id) override;
virtual ObjectID body_get_canvas_instance_id(RID p_body) const override;
- virtual void body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) override;
- virtual CCDMode body_get_continuous_collision_detection_mode(RID p_body) const override;
+ virtual void body_set_continuous_collision_detection_mode(RID p_body, PS2DE::CCDMode p_mode) override;
+ virtual PS2DE::CCDMode body_get_continuous_collision_detection_mode(RID p_body) const override;
virtual void body_set_collision_layer(RID p_body, uint32_t p_layer) override;
virtual uint32_t body_get_collision_layer(RID p_body) const override;
@@ -205,13 +205,13 @@ public:
virtual void body_set_collision_priority(RID p_body, real_t p_priority) override;
virtual real_t body_get_collision_priority(RID p_body) const override;
- virtual void body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) override;
- virtual Variant body_get_param(RID p_body, BodyParameter p_param) const override;
+ virtual void body_set_param(RID p_body, PS2DE::BodyParameter p_param, const Variant &p_value) override;
+ virtual Variant body_get_param(RID p_body, PS2DE::BodyParameter p_param) const override;
virtual void body_reset_mass_properties(RID p_body) override;
- virtual void body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) override;
- virtual Variant body_get_state(RID p_body, BodyState p_state) const override;
+ virtual void body_set_state(RID p_body, PS2DE::BodyState p_state, const Variant &p_variant) override;
+ virtual Variant body_get_state(RID p_body, PS2DE::BodyState p_state) const override;
virtual void body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) override;
virtual void body_apply_torque_impulse(RID p_body, real_t p_torque) override;
@@ -253,7 +253,7 @@ public:
virtual void body_set_pickable(RID p_body, bool p_pickable) override;
- virtual bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) override;
+ virtual bool body_test_motion(RID p_body, const PS2DT::MotionParameters &p_parameters, PS2DT::MotionResult *r_result = nullptr) override;
// this function only works on physics process, errors and returns null otherwise
virtual PhysicsDirectBodyState2D *body_get_direct_state(RID p_body) override;
@@ -264,8 +264,8 @@ public:
virtual void joint_clear(RID p_joint) override;
- virtual void joint_set_param(RID p_joint, JointParam p_param, real_t p_value) override;
- virtual real_t joint_get_param(RID p_joint, JointParam p_param) const override;
+ virtual void joint_set_param(RID p_joint, PS2DE::JointParam p_param, real_t p_value) override;
+ virtual real_t joint_get_param(RID p_joint, PS2DE::JointParam p_param) const override;
virtual void joint_disable_collisions_between_bodies(RID p_joint, const bool p_disabled) override;
virtual bool joint_is_disabled_collisions_between_bodies(RID p_joint) const override;
@@ -274,14 +274,14 @@ public:
virtual void joint_make_groove(RID p_joint, const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, RID p_body_a, RID p_body_b) override;
virtual void joint_make_damped_spring(RID p_joint, const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b = RID()) override;
- virtual void pin_joint_set_flag(RID p_joint, PinJointFlag p_flag, bool p_enabled) override;
- virtual bool pin_joint_get_flag(RID p_joint, PinJointFlag p_flag) const override;
- virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) override;
- virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const override;
- virtual void damped_spring_joint_set_param(RID p_joint, DampedSpringParam p_param, real_t p_value) override;
- virtual real_t damped_spring_joint_get_param(RID p_joint, DampedSpringParam p_param) const override;
+ virtual void pin_joint_set_flag(RID p_joint, PS2DE::PinJointFlag p_flag, bool p_enabled) override;
+ virtual bool pin_joint_get_flag(RID p_joint, PS2DE::PinJointFlag p_flag) const override;
+ virtual void pin_joint_set_param(RID p_joint, PS2DE::PinJointParam p_param, real_t p_value) override;
+ virtual real_t pin_joint_get_param(RID p_joint, PS2DE::PinJointParam p_param) const override;
+ virtual void damped_spring_joint_set_param(RID p_joint, PS2DE::DampedSpringParam p_param, real_t p_value) override;
+ virtual real_t damped_spring_joint_get_param(RID p_joint, PS2DE::DampedSpringParam p_param) const override;
- virtual JointType joint_get_type(RID p_joint) const override;
+ virtual PS2DE::JointType joint_get_type(RID p_joint) const override;
/* MISC */
@@ -297,7 +297,7 @@ public:
virtual bool is_flushing_queries() const override { return flushing_queries; }
- int get_process_info(ProcessInfo p_info) override;
+ int get_process_info(PS2DE::ProcessInfo p_info) override;
GodotPhysicsServer2D(bool p_using_threads = false);
~GodotPhysicsServer2D() {}
diff --git a/modules/godot_physics_2d/godot_shape_2d.cpp b/modules/godot_physics_2d/godot_shape_2d.cpp
index df32692da9d..c83685ced7a 100644
--- a/modules/godot_physics_2d/godot_shape_2d.cpp
+++ b/modules/godot_physics_2d/godot_shape_2d.cpp
@@ -32,6 +32,7 @@
#include "core/math/geometry_2d.h"
#include "core/templates/sort_array.h"
+#include "core/variant/variant.h"
void GodotShape2D::configure(const Rect2 &p_aabb) {
aabb = p_aabb;
diff --git a/modules/godot_physics_2d/godot_shape_2d.h b/modules/godot_physics_2d/godot_shape_2d.h
index 80ac63ebab9..e294878830d 100644
--- a/modules/godot_physics_2d/godot_shape_2d.h
+++ b/modules/godot_physics_2d/godot_shape_2d.h
@@ -30,7 +30,11 @@
#pragma once
-#include "servers/physics_2d/physics_server_2d.h"
+#include "core/math/rect2.h"
+#include "core/math/transform_2d.h"
+#include "core/templates/hash_map.h"
+#include "core/templates/rid.h"
+#include "servers/physics_2d/physics_server_2d_enums.h"
class GodotShape2D;
@@ -61,7 +65,7 @@ public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
_FORCE_INLINE_ RID get_self() const { return self; }
- virtual PhysicsServer2D::ShapeType get_type() const = 0;
+ virtual PS2DE::ShapeType get_type() const = 0;
_FORCE_INLINE_ Rect2 get_aabb() const { return aabb; }
_FORCE_INLINE_ bool is_configured() const { return configured; }
@@ -151,7 +155,7 @@ public:
_FORCE_INLINE_ Vector2 get_normal() const { return normal; }
_FORCE_INLINE_ real_t get_d() const { return d; }
- virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_WORLD_BOUNDARY; }
+ virtual PS2DE::ShapeType get_type() const override { return PS2DE::SHAPE_WORLD_BOUNDARY; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
@@ -188,7 +192,7 @@ public:
_FORCE_INLINE_ real_t get_length() const { return length; }
_FORCE_INLINE_ bool get_slide_on_slope() const { return slide_on_slope; }
- virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_SEPARATION_RAY; }
+ virtual PS2DE::ShapeType get_type() const override { return PS2DE::SHAPE_SEPARATION_RAY; }
virtual bool allows_one_way_collision() const override { return false; }
@@ -227,7 +231,7 @@ public:
_FORCE_INLINE_ const Vector2 &get_b() const { return b; }
_FORCE_INLINE_ const Vector2 &get_normal() const { return n; }
- virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_SEGMENT; }
+ virtual PS2DE::ShapeType get_type() const override { return PS2DE::SHAPE_SEGMENT; }
_FORCE_INLINE_ Vector2 get_xformed_normal(const Transform2D &p_xform) const {
return (p_xform.xform(b) - p_xform.xform(a)).normalized().orthogonal();
@@ -267,7 +271,7 @@ class GodotCircleShape2D : public GodotShape2D {
public:
_FORCE_INLINE_ const real_t &get_radius() const { return radius; }
- virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_CIRCLE; }
+ virtual PS2DE::ShapeType get_type() const override { return PS2DE::SHAPE_CIRCLE; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
@@ -300,7 +304,7 @@ class GodotRectangleShape2D : public GodotShape2D {
public:
_FORCE_INLINE_ const Vector2 &get_half_extents() const { return half_extents; }
- virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_RECTANGLE; }
+ virtual PS2DE::ShapeType get_type() const override { return PS2DE::SHAPE_RECTANGLE; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
@@ -374,7 +378,7 @@ public:
_FORCE_INLINE_ const real_t &get_radius() const { return radius; }
_FORCE_INLINE_ const real_t &get_height() const { return height; }
- virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_CAPSULE; }
+ virtual PS2DE::ShapeType get_type() const override { return PS2DE::SHAPE_CAPSULE; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
@@ -427,7 +431,7 @@ public:
return (p_xform.xform(b) - p_xform.xform(a)).normalized().orthogonal();
}
- virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_CONVEX_POLYGON; }
+ virtual PS2DE::ShapeType get_type() const override { return PS2DE::SHAPE_CONVEX_POLYGON; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
@@ -504,7 +508,7 @@ class GodotConcavePolygonShape2D : public GodotConcaveShape2D {
int _generate_bvh(BVH *p_bvh, int p_len, int p_depth);
public:
- virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_CONCAVE_POLYGON; }
+ virtual PS2DE::ShapeType get_type() const override { return PS2DE::SHAPE_CONCAVE_POLYGON; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override {
r_min = 0;
diff --git a/modules/godot_physics_2d/godot_space_2d.cpp b/modules/godot_physics_2d/godot_space_2d.cpp
index 1d7ce01cb09..4a3bd241cd9 100644
--- a/modules/godot_physics_2d/godot_space_2d.cpp
+++ b/modules/godot_physics_2d/godot_space_2d.cpp
@@ -56,7 +56,7 @@ _FORCE_INLINE_ static bool _can_collide_with(GodotCollisionObject2D *p_object, u
return true;
}
-int GodotPhysicsDirectSpaceState2D::intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) {
+int GodotPhysicsDirectSpaceState2D::intersect_point(const PS2DT::PointParameters &p_parameters, PS2DT::ShapeResult *r_results, int p_result_max) {
if (p_result_max <= 0) {
return 0;
}
@@ -115,7 +115,7 @@ int GodotPhysicsDirectSpaceState2D::intersect_point(const PointParameters &p_par
return cc;
}
-bool GodotPhysicsDirectSpaceState2D::intersect_ray(const RayParameters &p_parameters, RayResult &r_result) {
+bool GodotPhysicsDirectSpaceState2D::intersect_ray(const PS2DT::RayParameters &p_parameters, PS2DT::RayResult &r_result) {
ERR_FAIL_COND_V(space->locked, false);
Vector2 begin, end;
@@ -205,7 +205,7 @@ bool GodotPhysicsDirectSpaceState2D::intersect_ray(const RayParameters &p_parame
return true;
}
-int GodotPhysicsDirectSpaceState2D::intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) {
+int GodotPhysicsDirectSpaceState2D::intersect_shape(const PS2DT::ShapeParameters &p_parameters, PS2DT::ShapeResult *r_results, int p_result_max) {
if (p_result_max <= 0) {
return 0;
}
@@ -254,7 +254,7 @@ int GodotPhysicsDirectSpaceState2D::intersect_shape(const ShapeParameters &p_par
return cc;
}
-bool GodotPhysicsDirectSpaceState2D::cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) {
+bool GodotPhysicsDirectSpaceState2D::cast_motion(const PS2DT::ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) {
GodotShape2D *shape = GodotPhysicsServer2D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
ERR_FAIL_NULL_V(shape, false);
@@ -337,7 +337,7 @@ bool GodotPhysicsDirectSpaceState2D::cast_motion(const ShapeParameters &p_parame
return true;
}
-bool GodotPhysicsDirectSpaceState2D::collide_shape(const ShapeParameters &p_parameters, Vector2 *r_results, int p_result_max, int &r_result_count) {
+bool GodotPhysicsDirectSpaceState2D::collide_shape(const PS2DT::ShapeParameters &p_parameters, Vector2 *r_results, int p_result_max, int &r_result_count) {
if (p_result_max <= 0) {
return false;
}
@@ -438,7 +438,7 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B,
rd->best_local_shape = rd->local_shape;
}
-bool GodotPhysicsDirectSpaceState2D::rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) {
+bool GodotPhysicsDirectSpaceState2D::rest_info(const PS2DT::ShapeParameters &p_parameters, PS2DT::ShapeRestInfo *r_info) {
GodotShape2D *shape = GodotPhysicsServer2D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
ERR_FAIL_NULL_V(shape, false);
@@ -533,7 +533,7 @@ int GodotSpace2D::_cull_aabb_for_body(GodotBody2D *p_body, const Rect2 &p_aabb)
return amount;
}
-bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D::MotionParameters &p_parameters, PhysicsServer2D::MotionResult *r_result) {
+bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PS2DT::MotionParameters &p_parameters, PS2DT::MotionResult *r_result) {
//give me back regular physics engine logic
//this is madness
//and most people using this function will think
@@ -565,7 +565,7 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D::
if (!shapes_found) {
if (r_result) {
- *r_result = PhysicsServer2D::MotionResult();
+ *r_result = PS2DT::MotionResult();
r_result->travel = p_parameters.motion;
}
return false;
@@ -645,7 +645,7 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D::
if (col_obj->get_type() == GodotCollisionObject2D::TYPE_BODY) {
const GodotBody2D *b = static_cast<const GodotBody2D *>(col_obj);
- if (b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_RIGID) {
+ if (b->get_mode() == PS2DE::BODY_MODE_KINEMATIC || b->get_mode() == PS2DE::BODY_MODE_RIGID) {
//fix for moving platforms (kinematic and dynamic), margin is increased by how much it moved in the given direction
Vector2 lv = b->get_linear_velocity();
//compute displacement from linear velocity
@@ -754,7 +754,7 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D::
// Colliding separation rays allows to properly snap to the ground,
// otherwise it's not needed in regular motion.
- if (!p_parameters.collide_separation_ray && (body_shape->get_type() == PhysicsServer2D::SHAPE_SEPARATION_RAY)) {
+ if (!p_parameters.collide_separation_ray && (body_shape->get_type() == PS2DE::SHAPE_SEPARATION_RAY)) {
// When slide on slope is on, separation ray shape acts like a regular shape.
if (!static_cast<GodotSeparationRayShape2D *>(body_shape)->get_slide_on_slope()) {
continue;
@@ -950,7 +950,7 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D::
if (col_obj->get_type() == GodotCollisionObject2D::TYPE_BODY) {
const GodotBody2D *b = static_cast<const GodotBody2D *>(col_obj);
- if (b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_RIGID) {
+ if (b->get_mode() == PS2DE::BODY_MODE_KINEMATIC || b->get_mode() == PS2DE::BODY_MODE_RIGID) {
//fix for moving platforms (kinematic and dynamic), margin is increased by how much it moved in the given direction
Vector2 lv = b->get_linear_velocity();
//compute displacement from linear velocity
@@ -1144,57 +1144,57 @@ void GodotSpace2D::update() {
broadphase->update();
}
-void GodotSpace2D::set_param(PhysicsServer2D::SpaceParameter p_param, real_t p_value) {
+void GodotSpace2D::set_param(PS2DE::SpaceParameter p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer2D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
+ case PS2DE::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
contact_recycle_radius = p_value;
break;
- case PhysicsServer2D::SPACE_PARAM_CONTACT_MAX_SEPARATION:
+ case PS2DE::SPACE_PARAM_CONTACT_MAX_SEPARATION:
contact_max_separation = p_value;
break;
- case PhysicsServer2D::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION:
+ case PS2DE::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION:
contact_max_allowed_penetration = p_value;
break;
- case PhysicsServer2D::SPACE_PARAM_CONTACT_DEFAULT_BIAS:
+ case PS2DE::SPACE_PARAM_CONTACT_DEFAULT_BIAS:
contact_bias = p_value;
break;
- case PhysicsServer2D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
+ case PS2DE::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
body_linear_velocity_sleep_threshold = p_value;
break;
- case PhysicsServer2D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
+ case PS2DE::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
body_angular_velocity_sleep_threshold = p_value;
break;
- case PhysicsServer2D::SPACE_PARAM_BODY_TIME_TO_SLEEP:
+ case PS2DE::SPACE_PARAM_BODY_TIME_TO_SLEEP:
body_time_to_sleep = p_value;
break;
- case PhysicsServer2D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
+ case PS2DE::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
constraint_bias = p_value;
break;
- case PhysicsServer2D::SPACE_PARAM_SOLVER_ITERATIONS:
+ case PS2DE::SPACE_PARAM_SOLVER_ITERATIONS:
solver_iterations = p_value;
break;
}
}
-real_t GodotSpace2D::get_param(PhysicsServer2D::SpaceParameter p_param) const {
+real_t GodotSpace2D::get_param(PS2DE::SpaceParameter p_param) const {
switch (p_param) {
- case PhysicsServer2D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
+ case PS2DE::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
return contact_recycle_radius;
- case PhysicsServer2D::SPACE_PARAM_CONTACT_MAX_SEPARATION:
+ case PS2DE::SPACE_PARAM_CONTACT_MAX_SEPARATION:
return contact_max_separation;
- case PhysicsServer2D::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION:
+ case PS2DE::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION:
return contact_max_allowed_penetration;
- case PhysicsServer2D::SPACE_PARAM_CONTACT_DEFAULT_BIAS:
+ case PS2DE::SPACE_PARAM_CONTACT_DEFAULT_BIAS:
return contact_bias;
- case PhysicsServer2D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
+ case PS2DE::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
return body_linear_velocity_sleep_threshold;
- case PhysicsServer2D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
+ case PS2DE::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
return body_angular_velocity_sleep_threshold;
- case PhysicsServer2D::SPACE_PARAM_BODY_TIME_TO_SLEEP:
+ case PS2DE::SPACE_PARAM_BODY_TIME_TO_SLEEP:
return body_time_to_sleep;
- case PhysicsServer2D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
+ case PS2DE::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
return constraint_bias;
- case PhysicsServer2D::SPACE_PARAM_SOLVER_ITERATIONS:
+ case PS2DE::SPACE_PARAM_SOLVER_ITERATIONS:
return solver_iterations;
}
return 0;
diff --git a/modules/godot_physics_2d/godot_space_2d.h b/modules/godot_physics_2d/godot_space_2d.h
index c0b5a0d558a..fc7651c4cf9 100644
--- a/modules/godot_physics_2d/godot_space_2d.h
+++ b/modules/godot_physics_2d/godot_space_2d.h
@@ -36,6 +36,7 @@
#include "godot_collision_object_2d.h"
#include "core/typedefs.h"
+#include "servers/physics_2d/direct_states/physics_direct_space_state_2d.h"
class GodotPhysicsDirectSpaceState2D : public PhysicsDirectSpaceState2D {
GDCLASS(GodotPhysicsDirectSpaceState2D, PhysicsDirectSpaceState2D);
@@ -43,12 +44,12 @@ class GodotPhysicsDirectSpaceState2D : public PhysicsDirectSpaceState2D {
public:
GodotSpace2D *space = nullptr;
- virtual int intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) override;
- virtual bool intersect_ray(const RayParameters &p_parameters, RayResult &r_result) override;
- virtual int intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) override;
- virtual bool cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) override;
- virtual bool collide_shape(const ShapeParameters &p_parameters, Vector2 *r_results, int p_result_max, int &r_result_count) override;
- virtual bool rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) override;
+ virtual int intersect_point(const PS2DT::PointParameters &p_parameters, PS2DT::ShapeResult *r_results, int p_result_max) override;
+ virtual bool intersect_ray(const PS2DT::RayParameters &p_parameters, PS2DT::RayResult &r_result) override;
+ virtual int intersect_shape(const PS2DT::ShapeParameters &p_parameters, PS2DT::ShapeResult *r_results, int p_result_max) override;
+ virtual bool cast_motion(const PS2DT::ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) override;
+ virtual bool collide_shape(const PS2DT::ShapeParameters &p_parameters, Vector2 *r_results, int p_result_max, int &r_result_count) override;
+ virtual bool rest_info(const PS2DT::ShapeParameters &p_parameters, PS2DT::ShapeRestInfo *r_info) override;
GodotPhysicsDirectSpaceState2D() {}
};
@@ -174,8 +175,8 @@ public:
real_t get_last_step() const { return last_step; }
void set_last_step(real_t p_step) { last_step = p_step; }
- void set_param(PhysicsServer2D::SpaceParameter p_param, real_t p_value);
- real_t get_param(PhysicsServer2D::SpaceParameter p_param) const;
+ void set_param(PS2DE::SpaceParameter p_param, real_t p_value);
+ real_t get_param(PS2DE::SpaceParameter p_param) const;
void set_island_count(int p_island_count) { island_count = p_island_count; }
int get_island_count() const { return island_count; }
@@ -185,7 +186,7 @@ public:
int get_collision_pairs() const { return collision_pairs; }
- bool test_body_motion(GodotBody2D *p_body, const PhysicsServer2D::MotionParameters &p_parameters, PhysicsServer2D::MotionResult *r_result);
+ bool test_body_motion(GodotBody2D *p_body, const PS2DT::MotionParameters &p_parameters, PS2DT::MotionResult *r_result);
void set_debug_contacts(int p_amount) { contact_debug.resize(p_amount); }
_FORCE_INLINE_ bool is_debugging_contacts() const { return !contact_debug.is_empty(); }
diff --git a/modules/godot_physics_2d/godot_step_2d.cpp b/modules/godot_physics_2d/godot_step_2d.cpp
index d68f81a1a0b..698f92fa711 100644
--- a/modules/godot_physics_2d/godot_step_2d.cpp
+++ b/modules/godot_physics_2d/godot_step_2d.cpp
@@ -44,7 +44,7 @@
void GodotStep2D::_populate_island(GodotBody2D *p_body, LocalVector<GodotBody2D *> &p_body_island, LocalVector<GodotConstraint2D *> &p_constraint_island) {
p_body->set_island_step(_step);
- if (p_body->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) {
+ if (p_body->get_mode() > PS2DE::BODY_MODE_KINEMATIC) {
// Only rigid bodies are tested for activation.
p_body_island.push_back(p_body);
}
@@ -66,7 +66,7 @@ void GodotStep2D::_populate_island(GodotBody2D *p_body, LocalVector<GodotBody2D
if (other_body->get_island_step() == _step) {
continue; // Already processed.
}
- if (other_body->get_mode() == PhysicsServer2D::BODY_MODE_STATIC) {
+ if (other_body->get_mode() == PS2DE::BODY_MODE_STATIC) {
continue; // Static bodies don't connect islands.
}
_populate_island(other_body, p_body_island, p_constraint_island);
diff --git a/modules/godot_physics_3d/godot_area_3d.cpp b/modules/godot_physics_3d/godot_area_3d.cpp
index 424b6f258a0..5a4d30dbf5a 100644
--- a/modules/godot_physics_3d/godot_area_3d.cpp
+++ b/modules/godot_physics_3d/godot_area_3d.cpp
@@ -120,9 +120,9 @@ void GodotArea3D::set_area_monitor_callback(const Callable &p_callback) {
}
}
-void GodotArea3D::_set_space_override_mode(PhysicsServer3D::AreaSpaceOverrideMode &r_mode, PhysicsServer3D::AreaSpaceOverrideMode p_new_mode) {
- bool do_override = p_new_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
- if (do_override == (r_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED)) {
+void GodotArea3D::_set_space_override_mode(PS3DE::AreaSpaceOverrideMode &r_mode, PS3DE::AreaSpaceOverrideMode p_new_mode) {
+ bool do_override = p_new_mode != PS3DE::AREA_SPACE_OVERRIDE_DISABLED;
+ if (do_override == (r_mode != PS3DE::AREA_SPACE_OVERRIDE_DISABLED)) {
return;
}
_unregister_shapes();
@@ -130,84 +130,84 @@ void GodotArea3D::_set_space_override_mode(PhysicsServer3D::AreaSpaceOverrideMod
_shape_changed();
}
-void GodotArea3D::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) {
+void GodotArea3D::set_param(PS3DE::AreaParameter p_param, const Variant &p_value) {
switch (p_param) {
- case PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE:
- _set_space_override_mode(gravity_override_mode, (PhysicsServer3D::AreaSpaceOverrideMode)(int)p_value);
+ case PS3DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE:
+ _set_space_override_mode(gravity_override_mode, (PS3DE::AreaSpaceOverrideMode)(int)p_value);
break;
- case PhysicsServer3D::AREA_PARAM_GRAVITY:
+ case PS3DE::AREA_PARAM_GRAVITY:
gravity = p_value;
break;
- case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR:
+ case PS3DE::AREA_PARAM_GRAVITY_VECTOR:
gravity_vector = p_value;
break;
- case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT:
+ case PS3DE::AREA_PARAM_GRAVITY_IS_POINT:
gravity_is_point = p_value;
break;
- case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE:
+ case PS3DE::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE:
gravity_point_unit_distance = p_value;
break;
- case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
- _set_space_override_mode(linear_damping_override_mode, (PhysicsServer3D::AreaSpaceOverrideMode)(int)p_value);
+ case PS3DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
+ _set_space_override_mode(linear_damping_override_mode, (PS3DE::AreaSpaceOverrideMode)(int)p_value);
break;
- case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP:
+ case PS3DE::AREA_PARAM_LINEAR_DAMP:
linear_damp = p_value;
break;
- case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
- _set_space_override_mode(angular_damping_override_mode, (PhysicsServer3D::AreaSpaceOverrideMode)(int)p_value);
+ case PS3DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
+ _set_space_override_mode(angular_damping_override_mode, (PS3DE::AreaSpaceOverrideMode)(int)p_value);
break;
- case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP:
+ case PS3DE::AREA_PARAM_ANGULAR_DAMP:
angular_damp = p_value;
break;
- case PhysicsServer3D::AREA_PARAM_PRIORITY:
+ case PS3DE::AREA_PARAM_PRIORITY:
priority = p_value;
break;
- case PhysicsServer3D::AREA_PARAM_WIND_FORCE_MAGNITUDE:
+ case PS3DE::AREA_PARAM_WIND_FORCE_MAGNITUDE:
ERR_FAIL_COND_MSG(wind_force_magnitude < 0, "Wind force magnitude must be a non-negative real number, but a negative number was specified.");
wind_force_magnitude = p_value;
break;
- case PhysicsServer3D::AREA_PARAM_WIND_SOURCE:
+ case PS3DE::AREA_PARAM_WIND_SOURCE:
wind_source = p_value;
break;
- case PhysicsServer3D::AREA_PARAM_WIND_DIRECTION:
+ case PS3DE::AREA_PARAM_WIND_DIRECTION:
wind_direction = p_value;
break;
- case PhysicsServer3D::AREA_PARAM_WIND_ATTENUATION_FACTOR:
+ case PS3DE::AREA_PARAM_WIND_ATTENUATION_FACTOR:
ERR_FAIL_COND_MSG(wind_attenuation_factor < 0, "Wind attenuation factor must be a non-negative real number, but a negative number was specified.");
wind_attenuation_factor = p_value;
break;
}
}
-Variant GodotArea3D::get_param(PhysicsServer3D::AreaParameter p_param) const {
+Variant GodotArea3D::get_param(PS3DE::AreaParameter p_param) const {
switch (p_param) {
- case PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE:
+ case PS3DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE:
return gravity_override_mode;
- case PhysicsServer3D::AREA_PARAM_GRAVITY:
+ case PS3DE::AREA_PARAM_GRAVITY:
return gravity;
- case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR:
+ case PS3DE::AREA_PARAM_GRAVITY_VECTOR:
return gravity_vector;
- case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT:
+ case PS3DE::AREA_PARAM_GRAVITY_IS_POINT:
return gravity_is_point;
- case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE:
+ case PS3DE::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE:
return gravity_point_unit_distance;
- case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
+ case PS3DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
return linear_damping_override_mode;
- case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP:
+ case PS3DE::AREA_PARAM_LINEAR_DAMP:
return linear_damp;
- case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
+ case PS3DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
return angular_damping_override_mode;
- case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP:
+ case PS3DE::AREA_PARAM_ANGULAR_DAMP:
return angular_damp;
- case PhysicsServer3D::AREA_PARAM_PRIORITY:
+ case PS3DE::AREA_PARAM_PRIORITY:
return priority;
- case PhysicsServer3D::AREA_PARAM_WIND_FORCE_MAGNITUDE:
+ case PS3DE::AREA_PARAM_WIND_FORCE_MAGNITUDE:
return wind_force_magnitude;
- case PhysicsServer3D::AREA_PARAM_WIND_SOURCE:
+ case PS3DE::AREA_PARAM_WIND_SOURCE:
return wind_source;
- case PhysicsServer3D::AREA_PARAM_WIND_DIRECTION:
+ case PS3DE::AREA_PARAM_WIND_DIRECTION:
return wind_direction;
- case PhysicsServer3D::AREA_PARAM_WIND_ATTENUATION_FACTOR:
+ case PS3DE::AREA_PARAM_WIND_ATTENUATION_FACTOR:
return wind_attenuation_factor;
}
@@ -250,7 +250,7 @@ void GodotArea3D::call_queries() {
continue;
}
- res[0] = E->value.state > 0 ? PhysicsServer3D::AREA_BODY_ADDED : PhysicsServer3D::AREA_BODY_REMOVED;
+ res[0] = E->value.state > 0 ? PS3DE::AREA_BODY_ADDED : PS3DE::AREA_BODY_REMOVED;
res[1] = E->key.rid;
res[2] = E->key.instance_id;
res[3] = E->key.body_shape;
@@ -292,7 +292,7 @@ void GodotArea3D::call_queries() {
continue;
}
- res[0] = E->value.state > 0 ? PhysicsServer3D::AREA_BODY_ADDED : PhysicsServer3D::AREA_BODY_REMOVED;
+ res[0] = E->value.state > 0 ? PS3DE::AREA_BODY_ADDED : PS3DE::AREA_BODY_REMOVED;
res[1] = E->key.rid;
res[2] = E->key.instance_id;
res[3] = E->key.body_shape;
diff --git a/modules/godot_physics_3d/godot_area_3d.h b/modules/godot_physics_3d/godot_area_3d.h
index 3b6f091351b..dafbdf9fac1 100644
--- a/modules/godot_physics_3d/godot_area_3d.h
+++ b/modules/godot_physics_3d/godot_area_3d.h
@@ -32,8 +32,9 @@
#include "godot_collision_object_3d.h"
+#include "core/templates/hash_set.h"
#include "core/templates/self_list.h"
-#include "servers/physics_3d/physics_server_3d.h"
+#include "core/variant/callable.h"
class GodotSpace3D;
class GodotBody3D;
@@ -41,9 +42,9 @@ class GodotSoftBody3D;
class GodotConstraint3D;
class GodotArea3D : public GodotCollisionObject3D {
- PhysicsServer3D::AreaSpaceOverrideMode gravity_override_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
- PhysicsServer3D::AreaSpaceOverrideMode linear_damping_override_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
- PhysicsServer3D::AreaSpaceOverrideMode angular_damping_override_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
+ PS3DE::AreaSpaceOverrideMode gravity_override_mode = PS3DE::AREA_SPACE_OVERRIDE_DISABLED;
+ PS3DE::AreaSpaceOverrideMode linear_damping_override_mode = PS3DE::AREA_SPACE_OVERRIDE_DISABLED;
+ PS3DE::AreaSpaceOverrideMode angular_damping_override_mode = PS3DE::AREA_SPACE_OVERRIDE_DISABLED;
real_t gravity = 9.80665;
Vector3 gravity_vector = Vector3(0, -1, 0);
@@ -102,7 +103,7 @@ class GodotArea3D : public GodotCollisionObject3D {
virtual void _shapes_changed() override;
void _queue_monitor_update();
- void _set_space_override_mode(PhysicsServer3D::AreaSpaceOverrideMode &r_mode, PhysicsServer3D::AreaSpaceOverrideMode p_new_mode);
+ void _set_space_override_mode(PS3DE::AreaSpaceOverrideMode &r_mode, PS3DE::AreaSpaceOverrideMode p_new_mode);
public:
void set_monitor_callback(const Callable &p_callback);
@@ -120,8 +121,8 @@ public:
_FORCE_INLINE_ void add_area_to_query(GodotArea3D *p_area, uint32_t p_area_shape, uint32_t p_self_shape);
_FORCE_INLINE_ void remove_area_from_query(GodotArea3D *p_area, uint32_t p_area_shape, uint32_t p_self_shape);
- void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value);
- Variant get_param(PhysicsServer3D::AreaParameter p_param) const;
+ void set_param(PS3DE::AreaParameter p_param, const Variant &p_value);
+ Variant get_param(PS3DE::AreaParameter p_param) const;
_FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity = p_gravity; }
_FORCE_INLINE_ real_t get_gravity() const { return gravity; }
diff --git a/modules/godot_physics_3d/godot_area_pair_3d.cpp b/modules/godot_physics_3d/godot_area_pair_3d.cpp
index aaa96f5a289..d177375be45 100644
--- a/modules/godot_physics_3d/godot_area_pair_3d.cpp
+++ b/modules/godot_physics_3d/godot_area_pair_3d.cpp
@@ -41,11 +41,11 @@ bool GodotAreaPair3D::setup(real_t p_step) {
process_collision = false;
has_space_override = false;
if (result != colliding) {
- if ((int)area->get_param(PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE) != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
+ if ((int)area->get_param(PS3DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE) != PS3DE::AREA_SPACE_OVERRIDE_DISABLED) {
has_space_override = true;
- } else if ((int)area->get_param(PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE) != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
+ } else if ((int)area->get_param(PS3DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE) != PS3DE::AREA_SPACE_OVERRIDE_DISABLED) {
has_space_override = true;
- } else if ((int)area->get_param(PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE) != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
+ } else if ((int)area->get_param(PS3DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE) != PS3DE::AREA_SPACE_OVERRIDE_DISABLED) {
has_space_override = true;
}
process_collision = has_space_override;
@@ -99,7 +99,7 @@ GodotAreaPair3D::GodotAreaPair3D(GodotBody3D *p_body, int p_body_shape, GodotAre
area_shape = p_area_shape;
body->add_constraint(this, 0);
area->add_constraint(this);
- if (p_body->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC) {
+ if (p_body->get_mode() == PS3DE::BODY_MODE_KINEMATIC) {
p_body->set_active(true);
}
}
@@ -222,7 +222,7 @@ bool GodotAreaSoftBodyPair3D::setup(real_t p_step) {
process_collision = false;
has_space_override = false;
if (result != colliding) {
- if ((int)area->get_param(PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE) != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
+ if ((int)area->get_param(PS3DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE) != PS3DE::AREA_SPACE_OVERRIDE_DISABLED) {
has_space_override = true;
} else if (area->get_wind_force_magnitude() > CMP_EPSILON) {
has_space_override = true;
diff --git a/modules/godot_physics_3d/godot_body_3d.cpp b/modules/godot_physics_3d/godot_body_3d.cpp
index 397eb0d544b..ba099ff7128 100644
--- a/modules/godot_physics_3d/godot_body_3d.cpp
+++ b/modules/godot_physics_3d/godot_body_3d.cpp
@@ -57,7 +57,7 @@ void GodotBody3D::update_mass_properties() {
// Update shapes and motions.
switch (mode) {
- case PhysicsServer3D::BODY_MODE_RIGID: {
+ case PS3DE::BODY_MODE_RIGID: {
real_t total_area = 0;
for (int i = 0; i < get_shape_count(); i++) {
if (is_shape_disabled(i)) {
@@ -150,12 +150,12 @@ void GodotBody3D::update_mass_properties() {
}
} break;
- case PhysicsServer3D::BODY_MODE_KINEMATIC:
- case PhysicsServer3D::BODY_MODE_STATIC: {
+ case PS3DE::BODY_MODE_KINEMATIC:
+ case PS3DE::BODY_MODE_STATIC: {
_inv_inertia = Vector3();
_inv_mass = 0;
} break;
- case PhysicsServer3D::BODY_MODE_RIGID_LINEAR: {
+ case PS3DE::BODY_MODE_RIGID_LINEAR: {
_inv_inertia_tensor.set_zero();
_inv_mass = 1.0 / mass;
@@ -179,7 +179,7 @@ void GodotBody3D::set_active(bool p_active) {
active = p_active;
if (active) {
- if (mode == PhysicsServer3D::BODY_MODE_STATIC) {
+ if (mode == PS3DE::BODY_MODE_STATIC) {
// Static bodies can't be active.
active = false;
} else if (get_space()) {
@@ -190,61 +190,61 @@ void GodotBody3D::set_active(bool p_active) {
}
}
-void GodotBody3D::set_param(PhysicsServer3D::BodyParameter p_param, const Variant &p_value) {
+void GodotBody3D::set_param(PS3DE::BodyParameter p_param, const Variant &p_value) {
switch (p_param) {
- case PhysicsServer3D::BODY_PARAM_BOUNCE: {
+ case PS3DE::BODY_PARAM_BOUNCE: {
bounce = p_value;
} break;
- case PhysicsServer3D::BODY_PARAM_FRICTION: {
+ case PS3DE::BODY_PARAM_FRICTION: {
friction = p_value;
} break;
- case PhysicsServer3D::BODY_PARAM_MASS: {
+ case PS3DE::BODY_PARAM_MASS: {
real_t mass_value = p_value;
ERR_FAIL_COND(mass_value <= 0);
mass = mass_value;
- if (mode >= PhysicsServer3D::BODY_MODE_RIGID) {
+ if (mode >= PS3DE::BODY_MODE_RIGID) {
_mass_properties_changed();
}
} break;
- case PhysicsServer3D::BODY_PARAM_INERTIA: {
+ case PS3DE::BODY_PARAM_INERTIA: {
inertia = p_value;
if ((inertia.x <= 0.0) || (inertia.y <= 0.0) || (inertia.z <= 0.0)) {
calculate_inertia = true;
- if (mode == PhysicsServer3D::BODY_MODE_RIGID) {
+ if (mode == PS3DE::BODY_MODE_RIGID) {
_mass_properties_changed();
}
} else {
calculate_inertia = false;
- if (mode == PhysicsServer3D::BODY_MODE_RIGID) {
+ if (mode == PS3DE::BODY_MODE_RIGID) {
principal_inertia_axes_local = Basis();
_inv_inertia = inertia.inverse();
_update_transform_dependent();
}
}
} break;
- case PhysicsServer3D::BODY_PARAM_CENTER_OF_MASS: {
+ case PS3DE::BODY_PARAM_CENTER_OF_MASS: {
calculate_center_of_mass = false;
center_of_mass_local = p_value;
_update_transform_dependent();
} break;
- case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: {
+ case PS3DE::BODY_PARAM_GRAVITY_SCALE: {
if (Math::is_zero_approx(gravity_scale)) {
wakeup();
}
gravity_scale = p_value;
} break;
- case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP_MODE: {
+ case PS3DE::BODY_PARAM_LINEAR_DAMP_MODE: {
int mode_value = p_value;
- linear_damp_mode = (PhysicsServer3D::BodyDampMode)mode_value;
+ linear_damp_mode = (PS3DE::BodyDampMode)mode_value;
} break;
- case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP_MODE: {
+ case PS3DE::BODY_PARAM_ANGULAR_DAMP_MODE: {
int mode_value = p_value;
- angular_damp_mode = (PhysicsServer3D::BodyDampMode)mode_value;
+ angular_damp_mode = (PS3DE::BodyDampMode)mode_value;
} break;
- case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: {
+ case PS3DE::BODY_PARAM_LINEAR_DAMP: {
linear_damp = p_value;
} break;
- case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: {
+ case PS3DE::BODY_PARAM_ANGULAR_DAMP: {
angular_damp = p_value;
} break;
default: {
@@ -252,40 +252,40 @@ void GodotBody3D::set_param(PhysicsServer3D::BodyParameter p_param, const Varian
}
}
-Variant GodotBody3D::get_param(PhysicsServer3D::BodyParameter p_param) const {
+Variant GodotBody3D::get_param(PS3DE::BodyParameter p_param) const {
switch (p_param) {
- case PhysicsServer3D::BODY_PARAM_BOUNCE: {
+ case PS3DE::BODY_PARAM_BOUNCE: {
return bounce;
} break;
- case PhysicsServer3D::BODY_PARAM_FRICTION: {
+ case PS3DE::BODY_PARAM_FRICTION: {
return friction;
} break;
- case PhysicsServer3D::BODY_PARAM_MASS: {
+ case PS3DE::BODY_PARAM_MASS: {
return mass;
} break;
- case PhysicsServer3D::BODY_PARAM_INERTIA: {
- if (mode == PhysicsServer3D::BODY_MODE_RIGID) {
+ case PS3DE::BODY_PARAM_INERTIA: {
+ if (mode == PS3DE::BODY_MODE_RIGID) {
return _inv_inertia.inverse();
} else {
return Vector3();
}
} break;
- case PhysicsServer3D::BODY_PARAM_CENTER_OF_MASS: {
+ case PS3DE::BODY_PARAM_CENTER_OF_MASS: {
return center_of_mass_local;
} break;
- case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: {
+ case PS3DE::BODY_PARAM_GRAVITY_SCALE: {
return gravity_scale;
} break;
- case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP_MODE: {
+ case PS3DE::BODY_PARAM_LINEAR_DAMP_MODE: {
return linear_damp_mode;
}
- case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP_MODE: {
+ case PS3DE::BODY_PARAM_ANGULAR_DAMP_MODE: {
return angular_damp_mode;
}
- case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: {
+ case PS3DE::BODY_PARAM_LINEAR_DAMP: {
return linear_damp;
} break;
- case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: {
+ case PS3DE::BODY_PARAM_ANGULAR_DAMP: {
return angular_damp;
} break;
@@ -296,27 +296,27 @@ Variant GodotBody3D::get_param(PhysicsServer3D::BodyParameter p_param) const {
return 0;
}
-void GodotBody3D::set_mode(PhysicsServer3D::BodyMode p_mode) {
- PhysicsServer3D::BodyMode prev = mode;
+void GodotBody3D::set_mode(PS3DE::BodyMode p_mode) {
+ PS3DE::BodyMode prev = mode;
mode = p_mode;
switch (p_mode) {
- case PhysicsServer3D::BODY_MODE_STATIC:
- case PhysicsServer3D::BODY_MODE_KINEMATIC: {
+ case PS3DE::BODY_MODE_STATIC:
+ case PS3DE::BODY_MODE_KINEMATIC: {
_set_inv_transform(get_transform().affine_inverse());
_inv_mass = 0;
_inv_inertia = Vector3();
- _set_static(p_mode == PhysicsServer3D::BODY_MODE_STATIC);
- set_active(p_mode == PhysicsServer3D::BODY_MODE_KINEMATIC && contacts.size());
+ _set_static(p_mode == PS3DE::BODY_MODE_STATIC);
+ set_active(p_mode == PS3DE::BODY_MODE_KINEMATIC && contacts.size());
linear_velocity = Vector3();
angular_velocity = Vector3();
- if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC && prev != mode) {
+ if (mode == PS3DE::BODY_MODE_KINEMATIC && prev != mode) {
first_time_kinematic = true;
}
_update_transform_dependent();
} break;
- case PhysicsServer3D::BODY_MODE_RIGID: {
+ case PS3DE::BODY_MODE_RIGID: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
if (!calculate_inertia) {
principal_inertia_axes_local = Basis();
@@ -328,7 +328,7 @@ void GodotBody3D::set_mode(PhysicsServer3D::BodyMode p_mode) {
set_active(true);
} break;
- case PhysicsServer3D::BODY_MODE_RIGID_LINEAR: {
+ case PS3DE::BODY_MODE_RIGID_LINEAR: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_inv_inertia = Vector3();
angular_velocity = Vector3();
@@ -339,7 +339,7 @@ void GodotBody3D::set_mode(PhysicsServer3D::BodyMode p_mode) {
}
}
-PhysicsServer3D::BodyMode GodotBody3D::get_mode() const {
+PS3DE::BodyMode GodotBody3D::get_mode() const {
return mode;
}
@@ -349,10 +349,10 @@ void GodotBody3D::_shapes_changed() {
wakeup_neighbours();
}
-void GodotBody3D::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant) {
+void GodotBody3D::set_state(PS3DE::BodyState p_state, const Variant &p_variant) {
switch (p_state) {
- case PhysicsServer3D::BODY_STATE_TRANSFORM: {
- if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
+ case PS3DE::BODY_STATE_TRANSFORM: {
+ if (mode == PS3DE::BODY_MODE_KINEMATIC) {
new_transform = p_variant;
//wakeup_neighbours();
set_active(true);
@@ -362,7 +362,7 @@ void GodotBody3D::set_state(PhysicsServer3D::BodyState p_state, const Variant &p
first_time_kinematic = false;
}
- } else if (mode == PhysicsServer3D::BODY_MODE_STATIC) {
+ } else if (mode == PS3DE::BODY_MODE_STATIC) {
_set_transform(p_variant);
_set_inv_transform(get_transform().affine_inverse());
wakeup_neighbours();
@@ -380,19 +380,19 @@ void GodotBody3D::set_state(PhysicsServer3D::BodyState p_state, const Variant &p
wakeup();
} break;
- case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: {
+ case PS3DE::BODY_STATE_LINEAR_VELOCITY: {
linear_velocity = p_variant;
constant_linear_velocity = linear_velocity;
wakeup();
} break;
- case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: {
+ case PS3DE::BODY_STATE_ANGULAR_VELOCITY: {
angular_velocity = p_variant;
constant_angular_velocity = angular_velocity;
wakeup();
} break;
- case PhysicsServer3D::BODY_STATE_SLEEPING: {
- if (mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
+ case PS3DE::BODY_STATE_SLEEPING: {
+ if (mode == PS3DE::BODY_MODE_STATIC || mode == PS3DE::BODY_MODE_KINEMATIC) {
break;
}
bool do_sleep = p_variant;
@@ -406,9 +406,9 @@ void GodotBody3D::set_state(PhysicsServer3D::BodyState p_state, const Variant &p
set_active(true);
}
} break;
- case PhysicsServer3D::BODY_STATE_CAN_SLEEP: {
+ case PS3DE::BODY_STATE_CAN_SLEEP: {
can_sleep = p_variant;
- if (mode >= PhysicsServer3D::BODY_MODE_RIGID && !active && !can_sleep) {
+ if (mode >= PS3DE::BODY_MODE_RIGID && !active && !can_sleep) {
set_active(true);
}
@@ -416,21 +416,21 @@ void GodotBody3D::set_state(PhysicsServer3D::BodyState p_state, const Variant &p
}
}
-Variant GodotBody3D::get_state(PhysicsServer3D::BodyState p_state) const {
+Variant GodotBody3D::get_state(PS3DE::BodyState p_state) const {
switch (p_state) {
- case PhysicsServer3D::BODY_STATE_TRANSFORM: {
+ case PS3DE::BODY_STATE_TRANSFORM: {
return get_transform();
} break;
- case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: {
+ case PS3DE::BODY_STATE_LINEAR_VELOCITY: {
return linear_velocity;
} break;
- case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: {
+ case PS3DE::BODY_STATE_ANGULAR_VELOCITY: {
return angular_velocity;
} break;
- case PhysicsServer3D::BODY_STATE_SLEEPING: {
+ case PS3DE::BODY_STATE_SLEEPING: {
return !is_active();
} break;
- case PhysicsServer3D::BODY_STATE_CAN_SLEEP: {
+ case PS3DE::BODY_STATE_CAN_SLEEP: {
return can_sleep;
} break;
}
@@ -462,7 +462,7 @@ void GodotBody3D::set_space(GodotSpace3D *p_space) {
}
}
-void GodotBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock) {
+void GodotBody3D::set_axis_lock(PS3DE::BodyAxis p_axis, bool lock) {
if (lock) {
locked_axis |= p_axis;
} else {
@@ -470,12 +470,12 @@ void GodotBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock) {
}
}
-bool GodotBody3D::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const {
+bool GodotBody3D::is_axis_locked(PS3DE::BodyAxis p_axis) const {
return locked_axis & p_axis;
}
void GodotBody3D::integrate_forces(real_t p_step) {
- if (mode == PhysicsServer3D::BODY_MODE_STATIC) {
+ if (mode == PS3DE::BODY_MODE_STATIC) {
return;
}
@@ -500,20 +500,20 @@ void GodotBody3D::integrate_forces(real_t p_step) {
const AreaCMP *aa = &areas[0];
for (int i = ac - 1; i >= 0 && !stopped; i--) {
if (!gravity_done) {
- PhysicsServer3D::AreaSpaceOverrideMode area_gravity_mode = (PhysicsServer3D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE);
- if (area_gravity_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
+ PS3DE::AreaSpaceOverrideMode area_gravity_mode = (PS3DE::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PS3DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE);
+ if (area_gravity_mode != PS3DE::AREA_SPACE_OVERRIDE_DISABLED) {
Vector3 area_gravity;
aa[i].area->compute_gravity(get_transform().get_origin(), area_gravity);
switch (area_gravity_mode) {
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE:
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
+ case PS3DE::AREA_SPACE_OVERRIDE_COMBINE:
+ case PS3DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
gravity += area_gravity;
- gravity_done = area_gravity_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
+ gravity_done = area_gravity_mode == PS3DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE:
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
+ case PS3DE::AREA_SPACE_OVERRIDE_REPLACE:
+ case PS3DE::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
gravity = area_gravity;
- gravity_done = area_gravity_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE;
+ gravity_done = area_gravity_mode == PS3DE::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
@@ -521,19 +521,19 @@ void GodotBody3D::integrate_forces(real_t p_step) {
}
}
if (!linear_damp_done) {
- PhysicsServer3D::AreaSpaceOverrideMode area_linear_damp_mode = (PhysicsServer3D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE);
- if (area_linear_damp_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
+ PS3DE::AreaSpaceOverrideMode area_linear_damp_mode = (PS3DE::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PS3DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE);
+ if (area_linear_damp_mode != PS3DE::AREA_SPACE_OVERRIDE_DISABLED) {
real_t area_linear_damp = aa[i].area->get_linear_damp();
switch (area_linear_damp_mode) {
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE:
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
+ case PS3DE::AREA_SPACE_OVERRIDE_COMBINE:
+ case PS3DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
total_linear_damp += area_linear_damp;
- linear_damp_done = area_linear_damp_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
+ linear_damp_done = area_linear_damp_mode == PS3DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE:
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
+ case PS3DE::AREA_SPACE_OVERRIDE_REPLACE:
+ case PS3DE::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
total_linear_damp = area_linear_damp;
- linear_damp_done = area_linear_damp_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE;
+ linear_damp_done = area_linear_damp_mode == PS3DE::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
@@ -541,19 +541,19 @@ void GodotBody3D::integrate_forces(real_t p_step) {
}
}
if (!angular_damp_done) {
- PhysicsServer3D::AreaSpaceOverrideMode area_angular_damp_mode = (PhysicsServer3D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE);
- if (area_angular_damp_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
+ PS3DE::AreaSpaceOverrideMode area_angular_damp_mode = (PS3DE::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PS3DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE);
+ if (area_angular_damp_mode != PS3DE::AREA_SPACE_OVERRIDE_DISABLED) {
real_t area_angular_damp = aa[i].area->get_angular_damp();
switch (area_angular_damp_mode) {
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE:
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
+ case PS3DE::AREA_SPACE_OVERRIDE_COMBINE:
+ case PS3DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
total_angular_damp += area_angular_damp;
- angular_damp_done = area_angular_damp_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
+ angular_damp_done = area_angular_damp_mode == PS3DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE:
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
+ case PS3DE::AREA_SPACE_OVERRIDE_REPLACE:
+ case PS3DE::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
total_angular_damp = area_angular_damp;
- angular_damp_done = area_angular_damp_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE;
+ angular_damp_done = area_angular_damp_mode == PS3DE::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
@@ -586,20 +586,20 @@ void GodotBody3D::integrate_forces(real_t p_step) {
// Override linear damping with body's value.
switch (linear_damp_mode) {
- case PhysicsServer3D::BODY_DAMP_MODE_COMBINE: {
+ case PS3DE::BODY_DAMP_MODE_COMBINE: {
total_linear_damp += linear_damp;
} break;
- case PhysicsServer3D::BODY_DAMP_MODE_REPLACE: {
+ case PS3DE::BODY_DAMP_MODE_REPLACE: {
total_linear_damp = linear_damp;
} break;
}
// Override angular damping with body's value.
switch (angular_damp_mode) {
- case PhysicsServer3D::BODY_DAMP_MODE_COMBINE: {
+ case PS3DE::BODY_DAMP_MODE_COMBINE: {
total_angular_damp += angular_damp;
} break;
- case PhysicsServer3D::BODY_DAMP_MODE_REPLACE: {
+ case PS3DE::BODY_DAMP_MODE_REPLACE: {
total_angular_damp = angular_damp;
} break;
}
@@ -612,7 +612,7 @@ void GodotBody3D::integrate_forces(real_t p_step) {
Vector3 motion;
bool do_motion = false;
- if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
+ if (mode == PS3DE::BODY_MODE_KINEMATIC) {
//compute motion, angular and etc. velocities from prev transform
motion = new_transform.origin - get_transform().origin;
do_motion = true;
@@ -672,7 +672,7 @@ void GodotBody3D::integrate_forces(real_t p_step) {
}
void GodotBody3D::integrate_velocities(real_t p_step) {
- if (mode == PhysicsServer3D::BODY_MODE_STATIC) {
+ if (mode == PS3DE::BODY_MODE_STATIC) {
return;
}
@@ -684,7 +684,7 @@ void GodotBody3D::integrate_velocities(real_t p_step) {
//apply axis lock linear
for (int i = 0; i < 3; i++) {
- if (is_axis_locked((PhysicsServer3D::BodyAxis)(1 << i))) {
+ if (is_axis_locked((PS3DE::BodyAxis)(1 << i))) {
linear_velocity[i] = 0;
biased_linear_velocity[i] = 0;
new_transform.origin[i] = get_transform().origin[i];
@@ -692,13 +692,13 @@ void GodotBody3D::integrate_velocities(real_t p_step) {
}
//apply axis lock angular
for (int i = 0; i < 3; i++) {
- if (is_axis_locked((PhysicsServer3D::BodyAxis)(1 << (i + 3)))) {
+ if (is_axis_locked((PS3DE::BodyAxis)(1 << (i + 3)))) {
angular_velocity[i] = 0;
biased_angular_velocity[i] = 0;
}
}
- if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
+ if (mode == PS3DE::BODY_MODE_KINEMATIC) {
_set_transform(new_transform, false);
_set_inv_transform(new_transform.affine_inverse());
if (contacts.is_empty() && linear_velocity == Vector3() && angular_velocity == Vector3()) {
@@ -748,7 +748,7 @@ void GodotBody3D::wakeup_neighbours() {
continue;
}
GodotBody3D *b = n[i];
- if (b->mode < PhysicsServer3D::BODY_MODE_RIGID) {
+ if (b->mode < PS3DE::BODY_MODE_RIGID) {
continue;
}
@@ -781,7 +781,7 @@ void GodotBody3D::call_queries() {
}
bool GodotBody3D::sleep_test(real_t p_step) {
- if (mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
+ if (mode == PS3DE::BODY_MODE_STATIC || mode == PS3DE::BODY_MODE_KINEMATIC) {
return true;
} else if (!can_sleep) {
return false;
diff --git a/modules/godot_physics_3d/godot_body_3d.h b/modules/godot_physics_3d/godot_body_3d.h
index 7dcd17b1921..9bedf88a674 100644
--- a/modules/godot_physics_3d/godot_body_3d.h
+++ b/modules/godot_physics_3d/godot_body_3d.h
@@ -34,12 +34,13 @@
#include "godot_collision_object_3d.h"
#include "core/templates/vset.h"
+#include "servers/physics_3d/physics_server_3d_constants.h"
class GodotConstraint3D;
class GodotPhysicsDirectBodyState3D;
class GodotBody3D : public GodotCollisionObject3D {
- PhysicsServer3D::BodyMode mode = PhysicsServer3D::BODY_MODE_RIGID;
+ PS3DE::BodyMode mode = PS3DE::BODY_MODE_RIGID;
Vector3 linear_velocity;
Vector3 angular_velocity;
@@ -57,8 +58,8 @@ class GodotBody3D : public GodotCollisionObject3D {
real_t friction = 1.0;
Vector3 inertia;
- PhysicsServer3D::BodyDampMode linear_damp_mode = PhysicsServer3D::BODY_DAMP_MODE_COMBINE;
- PhysicsServer3D::BodyDampMode angular_damp_mode = PhysicsServer3D::BODY_DAMP_MODE_COMBINE;
+ PS3DE::BodyDampMode linear_damp_mode = PS3DE::BODY_DAMP_MODE_COMBINE;
+ PS3DE::BodyDampMode angular_damp_mode = PS3DE::BODY_DAMP_MODE_COMBINE;
real_t linear_damp = 0.0;
real_t angular_damp = 0.0;
@@ -175,10 +176,10 @@ public:
}
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) {
- ERR_FAIL_INDEX(p_size, MAX_CONTACTS_REPORTED_3D_MAX);
+ ERR_FAIL_INDEX(p_size, PS3DC::MAX_CONTACTS_REPORTED_3D_MAX);
contacts.resize(p_size);
contact_count = 0;
- if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC && p_size) {
+ if (mode == PS3DE::BODY_MODE_KINEMATIC && p_size) {
set_active(true);
}
}
@@ -284,20 +285,20 @@ public:
_FORCE_INLINE_ bool is_active() const { return active; }
_FORCE_INLINE_ void wakeup() {
- if ((!get_space()) || mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
+ if ((!get_space()) || mode == PS3DE::BODY_MODE_STATIC || mode == PS3DE::BODY_MODE_KINEMATIC) {
return;
}
set_active(true);
}
- void set_param(PhysicsServer3D::BodyParameter p_param, const Variant &p_value);
- Variant get_param(PhysicsServer3D::BodyParameter p_param) const;
+ void set_param(PS3DE::BodyParameter p_param, const Variant &p_value);
+ Variant get_param(PS3DE::BodyParameter p_param) const;
- void set_mode(PhysicsServer3D::BodyMode p_mode);
- PhysicsServer3D::BodyMode get_mode() const;
+ void set_mode(PS3DE::BodyMode p_mode);
+ PS3DE::BodyMode get_mode() const;
- void set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant);
- Variant get_state(PhysicsServer3D::BodyState p_state) const;
+ void set_state(PS3DE::BodyState p_state, const Variant &p_variant);
+ Variant get_state(PS3DE::BodyState p_state) const;
_FORCE_INLINE_ void set_continuous_collision_detection(bool p_enable) { continuous_cd = p_enable; }
_FORCE_INLINE_ bool is_continuous_collision_detection_enabled() const { return continuous_cd; }
@@ -313,8 +314,8 @@ public:
_FORCE_INLINE_ real_t get_friction() const { return friction; }
_FORCE_INLINE_ real_t get_bounce() const { return bounce; }
- void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock);
- bool is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const;
+ void set_axis_lock(PS3DE::BodyAxis p_axis, bool lock);
+ bool is_axis_locked(PS3DE::BodyAxis p_axis) const;
void integrate_forces(real_t p_step);
void integrate_velocities(real_t p_step);
diff --git a/modules/godot_physics_3d/godot_body_direct_state_3d.cpp b/modules/godot_physics_3d/godot_body_direct_state_3d.cpp
index a3529558570..83f0d4ae1e4 100644
--- a/modules/godot_physics_3d/godot_body_direct_state_3d.cpp
+++ b/modules/godot_physics_3d/godot_body_direct_state_3d.cpp
@@ -88,7 +88,7 @@ Vector3 GodotPhysicsDirectBodyState3D::get_angular_velocity() const {
}
void GodotPhysicsDirectBodyState3D::set_transform(const Transform3D &p_transform) {
- body->set_state(PhysicsServer3D::BODY_STATE_TRANSFORM, p_transform);
+ body->set_state(PS3DE::BODY_STATE_TRANSFORM, p_transform);
}
Transform3D GodotPhysicsDirectBodyState3D::get_transform() const {
diff --git a/modules/godot_physics_3d/godot_body_direct_state_3d.h b/modules/godot_physics_3d/godot_body_direct_state_3d.h
index 47970e3cc1c..2ab286706d0 100644
--- a/modules/godot_physics_3d/godot_body_direct_state_3d.h
+++ b/modules/godot_physics_3d/godot_body_direct_state_3d.h
@@ -30,7 +30,7 @@
#pragma once
-#include "servers/physics_3d/physics_server_3d.h"
+#include "servers/physics_3d/direct_states/physics_direct_body_state_3d.h"
class GodotBody3D;
diff --git a/modules/godot_physics_3d/godot_body_pair_3d.cpp b/modules/godot_physics_3d/godot_body_pair_3d.cpp
index 76440125a04..8a0481c0649 100644
--- a/modules/godot_physics_3d/godot_body_pair_3d.cpp
+++ b/modules/godot_physics_3d/godot_body_pair_3d.cpp
@@ -268,8 +268,8 @@ bool GodotBodyPair3D::setup(real_t p_step) {
return false;
}
- collide_A = (A->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC) && A->collides_with(B);
- collide_B = (B->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC) && B->collides_with(A);
+ collide_A = (A->get_mode() > PS3DE::BODY_MODE_KINEMATIC) && A->collides_with(B);
+ collide_B = (B->get_mode() > PS3DE::BODY_MODE_KINEMATIC) && B->collides_with(A);
report_contacts_only = false;
if (!collide_A && !collide_B) {
@@ -701,7 +701,7 @@ bool GodotBodySoftBodyPair3D::setup(real_t p_step) {
return false;
}
- body_collides = (body->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC) && body->collides_with(soft_body);
+ body_collides = (body->get_mode() > PS3DE::BODY_MODE_KINEMATIC) && body->collides_with(soft_body);
soft_body_collides = soft_body->collides_with(body);
if (!body_collides && !soft_body_collides) {
diff --git a/modules/godot_physics_3d/godot_collision_solver_3d.cpp b/modules/godot_physics_3d/godot_collision_solver_3d.cpp
index fd62f6188d3..92a092de80f 100644
--- a/modules/godot_physics_3d/godot_collision_solver_3d.cpp
+++ b/modules/godot_physics_3d/godot_collision_solver_3d.cpp
@@ -39,7 +39,7 @@
bool GodotCollisionSolver3D::solve_static_world_boundary(const GodotShape3D *p_shape_A, const Transform3D &p_transform_A, const GodotShape3D *p_shape_B, const Transform3D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin) {
const GodotWorldBoundaryShape3D *world_boundary = static_cast<const GodotWorldBoundaryShape3D *>(p_shape_A);
- if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_WORLD_BOUNDARY) {
+ if (p_shape_B->get_type() == PS3DE::SHAPE_WORLD_BOUNDARY) {
return false;
}
Plane p = p_transform_A.xform(world_boundary->get_plane());
@@ -358,8 +358,8 @@ bool GodotCollisionSolver3D::solve_concave(const GodotShape3D *p_shape_A, const
}
bool GodotCollisionSolver3D::solve_static(const GodotShape3D *p_shape_A, const Transform3D &p_transform_A, const GodotShape3D *p_shape_B, const Transform3D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis, real_t p_margin_A, real_t p_margin_B) {
- PhysicsServer3D::ShapeType type_A = p_shape_A->get_type();
- PhysicsServer3D::ShapeType type_B = p_shape_B->get_type();
+ PS3DE::ShapeType type_A = p_shape_A->get_type();
+ PS3DE::ShapeType type_B = p_shape_B->get_type();
bool concave_A = p_shape_A->is_concave();
bool concave_B = p_shape_B->is_concave();
@@ -371,16 +371,16 @@ bool GodotCollisionSolver3D::solve_static(const GodotShape3D *p_shape_A, const T
swap = true;
}
- if (type_A == PhysicsServer3D::SHAPE_WORLD_BOUNDARY) {
- if (type_B == PhysicsServer3D::SHAPE_WORLD_BOUNDARY) {
+ if (type_A == PS3DE::SHAPE_WORLD_BOUNDARY) {
+ if (type_B == PS3DE::SHAPE_WORLD_BOUNDARY) {
WARN_PRINT_ONCE("Collisions between world boundaries are not supported.");
return false;
}
- if (type_B == PhysicsServer3D::SHAPE_SEPARATION_RAY) {
+ if (type_B == PS3DE::SHAPE_SEPARATION_RAY) {
WARN_PRINT_ONCE("Collisions between world boundaries and rays are not supported.");
return false;
}
- if (type_B == PhysicsServer3D::SHAPE_SOFT_BODY) {
+ if (type_B == PS3DE::SHAPE_SOFT_BODY) {
WARN_PRINT_ONCE("Collisions between world boundaries and soft bodies are not supported.");
return false;
}
@@ -391,8 +391,8 @@ bool GodotCollisionSolver3D::solve_static(const GodotShape3D *p_shape_A, const T
return solve_static_world_boundary(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false, p_margin_B);
}
- } else if (type_A == PhysicsServer3D::SHAPE_SEPARATION_RAY) {
- if (type_B == PhysicsServer3D::SHAPE_SEPARATION_RAY) {
+ } else if (type_A == PS3DE::SHAPE_SEPARATION_RAY) {
+ if (type_B == PS3DE::SHAPE_SEPARATION_RAY) {
WARN_PRINT_ONCE("Collisions between rays are not supported.");
return false;
}
@@ -403,8 +403,8 @@ bool GodotCollisionSolver3D::solve_static(const GodotShape3D *p_shape_A, const T
return solve_separation_ray(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false, p_margin_A);
}
- } else if (type_B == PhysicsServer3D::SHAPE_SOFT_BODY) {
- if (type_A == PhysicsServer3D::SHAPE_SOFT_BODY) {
+ } else if (type_B == PS3DE::SHAPE_SOFT_BODY) {
+ if (type_A == PS3DE::SHAPE_SOFT_BODY) {
WARN_PRINT_ONCE("Collisions between soft bodies are not supported.");
return false;
}
@@ -456,7 +456,7 @@ bool GodotCollisionSolver3D::concave_distance_callback(void *p_userdata, GodotSh
bool GodotCollisionSolver3D::solve_distance_world_boundary(const GodotShape3D *p_shape_A, const Transform3D &p_transform_A, const GodotShape3D *p_shape_B, const Transform3D &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B) {
const GodotWorldBoundaryShape3D *world_boundary = static_cast<const GodotWorldBoundaryShape3D *>(p_shape_A);
- if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_WORLD_BOUNDARY) {
+ if (p_shape_B->get_type() == PS3DE::SHAPE_WORLD_BOUNDARY) {
return false;
}
Plane p = p_transform_A.xform(world_boundary->get_plane());
@@ -516,7 +516,7 @@ bool GodotCollisionSolver3D::solve_distance_world_boundary(const GodotShape3D *p
}
bool GodotCollisionSolver3D::solve_distance(const GodotShape3D *p_shape_A, const Transform3D &p_transform_A, const GodotShape3D *p_shape_B, const Transform3D &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis) {
- if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_WORLD_BOUNDARY) {
+ if (p_shape_B->get_type() == PS3DE::SHAPE_WORLD_BOUNDARY) {
Vector3 a, b;
bool col = solve_distance_world_boundary(p_shape_B, p_transform_B, p_shape_A, p_transform_A, a, b);
r_point_A = b;
diff --git a/modules/godot_physics_3d/godot_collision_solver_3d_sat.cpp b/modules/godot_physics_3d/godot_collision_solver_3d_sat.cpp
index 31431805e17..60b970cce52 100644
--- a/modules/godot_physics_3d/godot_collision_solver_3d_sat.cpp
+++ b/modules/godot_physics_3d/godot_collision_solver_3d_sat.cpp
@@ -2292,16 +2292,16 @@ static void _collision_convex_polygon_face(const GodotShape3D *p_a, const Transf
}
bool sat_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, Vector3 *r_prev_axis, real_t p_margin_a, real_t p_margin_b) {
- PhysicsServer3D::ShapeType type_A = p_shape_A->get_type();
+ PS3DE::ShapeType type_A = p_shape_A->get_type();
- ERR_FAIL_COND_V(type_A == PhysicsServer3D::SHAPE_WORLD_BOUNDARY, false);
- ERR_FAIL_COND_V(type_A == PhysicsServer3D::SHAPE_SEPARATION_RAY, false);
+ ERR_FAIL_COND_V(type_A == PS3DE::SHAPE_WORLD_BOUNDARY, false);
+ ERR_FAIL_COND_V(type_A == PS3DE::SHAPE_SEPARATION_RAY, false);
ERR_FAIL_COND_V(p_shape_A->is_concave(), false);
- PhysicsServer3D::ShapeType type_B = p_shape_B->get_type();
+ PS3DE::ShapeType type_B = p_shape_B->get_type();
- ERR_FAIL_COND_V(type_B == PhysicsServer3D::SHAPE_WORLD_BOUNDARY, false);
- ERR_FAIL_COND_V(type_B == PhysicsServer3D::SHAPE_SEPARATION_RAY, false);
+ ERR_FAIL_COND_V(type_B == PS3DE::SHAPE_WORLD_BOUNDARY, false);
+ ERR_FAIL_COND_V(type_B == PS3DE::SHAPE_SEPARATION_RAY, false);
ERR_FAIL_COND_V(p_shape_B->is_concave(), false);
static const CollisionFunc collision_table[6][6] = {
diff --git a/modules/godot_physics_3d/godot_joint_3d.h b/modules/godot_physics_3d/godot_joint_3d.h
index 2d885b8e32b..23e1c5423cc 100644
--- a/modules/godot_physics_3d/godot_joint_3d.h
+++ b/modules/godot_physics_3d/godot_joint_3d.h
@@ -82,7 +82,7 @@ public:
disable_collisions_between_bodies(p_joint->is_disabled_collisions_between_bodies());
}
- virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_TYPE_MAX; }
+ virtual PS3DE::JointType get_type() const { return PS3DE::JOINT_TYPE_MAX; }
_FORCE_INLINE_ GodotJoint3D(GodotBody3D **p_body_ptr = nullptr, int p_body_count = 0) :
GodotConstraint3D(p_body_ptr, p_body_count) {
}
diff --git a/modules/godot_physics_3d/godot_physics_server_3d.cpp b/modules/godot_physics_3d/godot_physics_server_3d.cpp
index 05e4813b77d..d02ce62b651 100644
--- a/modules/godot_physics_3d/godot_physics_server_3d.cpp
+++ b/modules/godot_physics_3d/godot_physics_server_3d.cpp
@@ -114,9 +114,9 @@ void GodotPhysicsServer3D::shape_set_custom_solver_bias(RID p_shape, real_t p_bi
shape->set_custom_bias(p_bias);
}
-PhysicsServer3D::ShapeType GodotPhysicsServer3D::shape_get_type(RID p_shape) const {
+PS3DE::ShapeType GodotPhysicsServer3D::shape_get_type(RID p_shape) const {
const GodotShape3D *shape = shape_owner.get_or_null(p_shape);
- ERR_FAIL_NULL_V(shape, SHAPE_CUSTOM);
+ ERR_FAIL_NULL_V(shape, PS3DE::SHAPE_CUSTOM);
return shape->get_type();
}
@@ -152,7 +152,7 @@ RID GodotPhysicsServer3D::space_create() {
area->set_priority(-1);
RID sgb = body_create();
body_set_space(sgb, id);
- body_set_mode(sgb, BODY_MODE_STATIC);
+ body_set_mode(sgb, PS3DE::BODY_MODE_STATIC);
space->set_static_global_body(sgb);
return id;
@@ -175,14 +175,14 @@ bool GodotPhysicsServer3D::space_is_active(RID p_space) const {
return active_spaces.has(space);
}
-void GodotPhysicsServer3D::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
+void GodotPhysicsServer3D::space_set_param(RID p_space, PS3DE::SpaceParameter p_param, real_t p_value) {
GodotSpace3D *space = space_owner.get_or_null(p_space);
ERR_FAIL_NULL(space);
space->set_param(p_param, p_value);
}
-real_t GodotPhysicsServer3D::space_get_param(RID p_space, SpaceParameter p_param) const {
+real_t GodotPhysicsServer3D::space_get_param(RID p_space, PS3DE::SpaceParameter p_param) const {
const GodotSpace3D *space = space_owner.get_or_null(p_space);
ERR_FAIL_NULL_V(space, 0);
return space->get_param(p_param);
@@ -346,7 +346,7 @@ ObjectID GodotPhysicsServer3D::area_get_object_instance_id(RID p_area) const {
return area->get_instance_id();
}
-void GodotPhysicsServer3D::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
+void GodotPhysicsServer3D::area_set_param(RID p_area, PS3DE::AreaParameter p_param, const Variant &p_value) {
if (space_owner.owns(p_area)) {
GodotSpace3D *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
@@ -362,7 +362,7 @@ void GodotPhysicsServer3D::area_set_transform(RID p_area, const Transform3D &p_t
area->set_transform(p_transform);
}
-Variant GodotPhysicsServer3D::area_get_param(RID p_area, AreaParameter p_param) const {
+Variant GodotPhysicsServer3D::area_get_param(RID p_area, PS3DE::AreaParameter p_param) const {
if (space_owner.owns(p_area)) {
GodotSpace3D *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
@@ -475,16 +475,16 @@ RID GodotPhysicsServer3D::body_get_space(RID p_body) const {
return space->get_self();
}
-void GodotPhysicsServer3D::body_set_mode(RID p_body, BodyMode p_mode) {
+void GodotPhysicsServer3D::body_set_mode(RID p_body, PS3DE::BodyMode p_mode) {
GodotBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
body->set_mode(p_mode);
}
-PhysicsServer3D::BodyMode GodotPhysicsServer3D::body_get_mode(RID p_body) const {
+PS3DE::BodyMode GodotPhysicsServer3D::body_get_mode(RID p_body) const {
GodotBody3D *body = body_owner.get_or_null(p_body);
- ERR_FAIL_NULL_V(body, BODY_MODE_STATIC);
+ ERR_FAIL_NULL_V(body, PS3DE::BODY_MODE_STATIC);
return body->get_mode();
}
@@ -656,14 +656,14 @@ uint32_t GodotPhysicsServer3D::body_get_user_flags(RID p_body) const {
return 0;
}
-void GodotPhysicsServer3D::body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) {
+void GodotPhysicsServer3D::body_set_param(RID p_body, PS3DE::BodyParameter p_param, const Variant &p_value) {
GodotBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
body->set_param(p_param, p_value);
}
-Variant GodotPhysicsServer3D::body_get_param(RID p_body, BodyParameter p_param) const {
+Variant GodotPhysicsServer3D::body_get_param(RID p_body, PS3DE::BodyParameter p_param) const {
GodotBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, 0);
@@ -677,14 +677,14 @@ void GodotPhysicsServer3D::body_reset_mass_properties(RID p_body) {
return body->reset_mass_properties();
}
-void GodotPhysicsServer3D::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
+void GodotPhysicsServer3D::body_set_state(RID p_body, PS3DE::BodyState p_state, const Variant &p_variant) {
GodotBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
body->set_state(p_state, p_variant);
}
-Variant GodotPhysicsServer3D::body_get_state(RID p_body, BodyState p_state) const {
+Variant GodotPhysicsServer3D::body_get_state(RID p_body, PS3DE::BodyState p_state) const {
GodotBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, Variant());
@@ -844,7 +844,7 @@ void GodotPhysicsServer3D::body_set_axis_velocity(RID p_body, const Vector3 &p_a
body->wakeup();
}
-void GodotPhysicsServer3D::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
+void GodotPhysicsServer3D::body_set_axis_lock(RID p_body, PS3DE::BodyAxis p_axis, bool p_lock) {
GodotBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
@@ -852,7 +852,7 @@ void GodotPhysicsServer3D::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool
body->wakeup();
}
-bool GodotPhysicsServer3D::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
+bool GodotPhysicsServer3D::body_is_axis_locked(RID p_body, PS3DE::BodyAxis p_axis) const {
const GodotBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, false);
return body->is_axis_locked(p_axis);
@@ -937,7 +937,7 @@ void GodotPhysicsServer3D::body_set_ray_pickable(RID p_body, bool p_enable) {
body->set_ray_pickable(p_enable);
}
-bool GodotPhysicsServer3D::body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result) {
+bool GodotPhysicsServer3D::body_test_motion(RID p_body, const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult *r_result) {
GodotBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, false);
ERR_FAIL_NULL_V(body->get_space(), false);
@@ -1063,14 +1063,14 @@ void GodotPhysicsServer3D::soft_body_get_collision_exceptions(RID p_body, List<R
}
}
-void GodotPhysicsServer3D::soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
+void GodotPhysicsServer3D::soft_body_set_state(RID p_body, PS3DE::BodyState p_state, const Variant &p_variant) {
GodotSoftBody3D *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_NULL(soft_body);
soft_body->set_state(p_state, p_variant);
}
-Variant GodotPhysicsServer3D::soft_body_get_state(RID p_body, BodyState p_state) const {
+Variant GodotPhysicsServer3D::soft_body_get_state(RID p_body, PS3DE::BodyState p_state) const {
GodotSoftBody3D *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(soft_body, Variant());
@@ -1081,7 +1081,7 @@ void GodotPhysicsServer3D::soft_body_set_transform(RID p_body, const Transform3D
GodotSoftBody3D *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_NULL(soft_body);
- soft_body->set_state(BODY_STATE_TRANSFORM, p_transform);
+ soft_body->set_state(PS3DE::BODY_STATE_TRANSFORM, p_transform);
}
void GodotPhysicsServer3D::soft_body_set_ray_pickable(RID p_body, bool p_enable) {
@@ -1254,7 +1254,7 @@ RID GodotPhysicsServer3D::joint_create() {
void GodotPhysicsServer3D::joint_clear(RID p_joint) {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- if (joint->get_type() != JOINT_TYPE_MAX) {
+ if (joint->get_type() != PS3DE::JOINT_TYPE_MAX) {
GodotJoint3D *empty_joint = memnew(GodotJoint3D);
empty_joint->copy_settings_from(joint);
@@ -1287,18 +1287,18 @@ void GodotPhysicsServer3D::joint_make_pin(RID p_joint, RID p_body_A, const Vecto
memdelete(prev_joint);
}
-void GodotPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
+void GodotPhysicsServer3D::pin_joint_set_param(RID p_joint, PS3DE::PinJointParam p_param, real_t p_value) {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_PIN);
GodotPinJoint3D *pin_joint = static_cast<GodotPinJoint3D *>(joint);
pin_joint->set_param(p_param, p_value);
}
-real_t GodotPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
+real_t GodotPhysicsServer3D::pin_joint_get_param(RID p_joint, PS3DE::PinJointParam p_param) const {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, 0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_PIN, 0);
GodotPinJoint3D *pin_joint = static_cast<GodotPinJoint3D *>(joint);
return pin_joint->get_param(p_param);
}
@@ -1306,7 +1306,7 @@ real_t GodotPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_pa
void GodotPhysicsServer3D::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_PIN);
GodotPinJoint3D *pin_joint = static_cast<GodotPinJoint3D *>(joint);
pin_joint->set_pos_a(p_A);
}
@@ -1314,7 +1314,7 @@ void GodotPhysicsServer3D::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A
Vector3 GodotPhysicsServer3D::pin_joint_get_local_a(RID p_joint) const {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, Vector3());
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, Vector3());
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_PIN, Vector3());
GodotPinJoint3D *pin_joint = static_cast<GodotPinJoint3D *>(joint);
return pin_joint->get_position_a();
}
@@ -1322,7 +1322,7 @@ Vector3 GodotPhysicsServer3D::pin_joint_get_local_a(RID p_joint) const {
void GodotPhysicsServer3D::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_PIN);
GodotPinJoint3D *pin_joint = static_cast<GodotPinJoint3D *>(joint);
pin_joint->set_pos_b(p_B);
}
@@ -1330,7 +1330,7 @@ void GodotPhysicsServer3D::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B
Vector3 GodotPhysicsServer3D::pin_joint_get_local_b(RID p_joint) const {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, Vector3());
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, Vector3());
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_PIN, Vector3());
GodotPinJoint3D *pin_joint = static_cast<GodotPinJoint3D *>(joint);
return pin_joint->get_position_b();
}
@@ -1383,34 +1383,34 @@ void GodotPhysicsServer3D::joint_make_hinge_simple(RID p_joint, RID p_body_A, co
memdelete(prev_joint);
}
-void GodotPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) {
+void GodotPhysicsServer3D::hinge_joint_set_param(RID p_joint, PS3DE::HingeJointParam p_param, real_t p_value) {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_HINGE);
GodotHingeJoint3D *hinge_joint = static_cast<GodotHingeJoint3D *>(joint);
hinge_joint->set_param(p_param, p_value);
}
-real_t GodotPhysicsServer3D::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
+real_t GodotPhysicsServer3D::hinge_joint_get_param(RID p_joint, PS3DE::HingeJointParam p_param) const {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, 0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_HINGE, 0);
GodotHingeJoint3D *hinge_joint = static_cast<GodotHingeJoint3D *>(joint);
return hinge_joint->get_param(p_param);
}
-void GodotPhysicsServer3D::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_enabled) {
+void GodotPhysicsServer3D::hinge_joint_set_flag(RID p_joint, PS3DE::HingeJointFlag p_flag, bool p_enabled) {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_HINGE);
GodotHingeJoint3D *hinge_joint = static_cast<GodotHingeJoint3D *>(joint);
hinge_joint->set_flag(p_flag, p_enabled);
}
-bool GodotPhysicsServer3D::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
+bool GodotPhysicsServer3D::hinge_joint_get_flag(RID p_joint, PS3DE::HingeJointFlag p_flag) const {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, false);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, false);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_HINGE, false);
GodotHingeJoint3D *hinge_joint = static_cast<GodotHingeJoint3D *>(joint);
return hinge_joint->get_flag(p_flag);
}
@@ -1454,9 +1454,9 @@ bool GodotPhysicsServer3D::joint_is_disabled_collisions_between_bodies(RID p_joi
return joint->is_disabled_collisions_between_bodies();
}
-GodotPhysicsServer3D::JointType GodotPhysicsServer3D::joint_get_type(RID p_joint) const {
+PS3DE::JointType GodotPhysicsServer3D::joint_get_type(RID p_joint) const {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
- ERR_FAIL_NULL_V(joint, JOINT_TYPE_PIN);
+ ERR_FAIL_NULL_V(joint, PS3DE::JOINT_TYPE_PIN);
return joint->get_type();
}
@@ -1484,18 +1484,18 @@ void GodotPhysicsServer3D::joint_make_slider(RID p_joint, RID p_body_A, const Tr
memdelete(prev_joint);
}
-void GodotPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) {
+void GodotPhysicsServer3D::slider_joint_set_param(RID p_joint, PS3DE::SliderJointParam p_param, real_t p_value) {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_SLIDER);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_SLIDER);
GodotSliderJoint3D *slider_joint = static_cast<GodotSliderJoint3D *>(joint);
slider_joint->set_param(p_param, p_value);
}
-real_t GodotPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
+real_t GodotPhysicsServer3D::slider_joint_get_param(RID p_joint, PS3DE::SliderJointParam p_param) const {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_CONE_TWIST, 0);
GodotSliderJoint3D *slider_joint = static_cast<GodotSliderJoint3D *>(joint);
return slider_joint->get_param(p_param);
}
@@ -1524,18 +1524,18 @@ void GodotPhysicsServer3D::joint_make_cone_twist(RID p_joint, RID p_body_A, cons
memdelete(prev_joint);
}
-void GodotPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) {
+void GodotPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, PS3DE::ConeTwistJointParam p_param, real_t p_value) {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_CONE_TWIST);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_CONE_TWIST);
GodotConeTwistJoint3D *cone_twist_joint = static_cast<GodotConeTwistJoint3D *>(joint);
cone_twist_joint->set_param(p_param, p_value);
}
-real_t GodotPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
+real_t GodotPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, PS3DE::ConeTwistJointParam p_param) const {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_CONE_TWIST, 0);
GodotConeTwistJoint3D *cone_twist_joint = static_cast<GodotConeTwistJoint3D *>(joint);
return cone_twist_joint->get_param(p_param);
}
@@ -1564,34 +1564,34 @@ void GodotPhysicsServer3D::joint_make_generic_6dof(RID p_joint, RID p_body_A, co
memdelete(prev_joint);
}
-void GodotPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) {
+void GodotPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, PS3DE::G6DOFJointAxisParam p_param, real_t p_value) {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_6DOF);
GodotGeneric6DOFJoint3D *generic_6dof_joint = static_cast<GodotGeneric6DOFJoint3D *>(joint);
generic_6dof_joint->set_param(p_axis, p_param, p_value);
}
-real_t GodotPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) const {
+real_t GodotPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, PS3DE::G6DOFJointAxisParam p_param) const {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, 0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_6DOF, 0);
GodotGeneric6DOFJoint3D *generic_6dof_joint = static_cast<GodotGeneric6DOFJoint3D *>(joint);
return generic_6dof_joint->get_param(p_axis, p_param);
}
-void GodotPhysicsServer3D::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
+void GodotPhysicsServer3D::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, PS3DE::G6DOFJointAxisFlag p_flag, bool p_enable) {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_6DOF);
GodotGeneric6DOFJoint3D *generic_6dof_joint = static_cast<GodotGeneric6DOFJoint3D *>(joint);
generic_6dof_joint->set_flag(p_axis, p_flag, p_enable);
}
-bool GodotPhysicsServer3D::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) const {
+bool GodotPhysicsServer3D::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, PS3DE::G6DOFJointAxisFlag p_flag) const {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, false);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, false);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_6DOF, false);
GodotGeneric6DOFJoint3D *generic_6dof_joint = static_cast<GodotGeneric6DOFJoint3D *>(joint);
return generic_6dof_joint->get_flag(p_axis, p_flag);
}
@@ -1601,14 +1601,14 @@ void GodotPhysicsServer3D::generic_6dof_joint_set_angular_target_rotation(RID p_
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_6DOF);
WARN_PRINT_ONCE("Quaternion angular target rotations for Generic6DOFJoint3D are only supported by Jolt Physics. This value will be ignored by GodotPhysics3D.");
}
Quaternion GodotPhysicsServer3D::generic_6dof_joint_get_angular_target_rotation(RID p_joint) const {
const GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, Quaternion());
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, Quaternion());
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_6DOF, Quaternion());
// GodotPhysics3D does not apply angular spring equilibrium points, so there is no body-space target to return.
WARN_PRINT_ONCE("Quaternion angular target rotations for Generic6DOFJoint3D are only supported by Jolt Physics. GodotPhysics3D returns the identity quaternion.");
@@ -1770,15 +1770,15 @@ void GodotPhysicsServer3D::finish() {
memdelete(stepper);
}
-int GodotPhysicsServer3D::get_process_info(ProcessInfo p_info) {
+int GodotPhysicsServer3D::get_process_info(PS3DE::ProcessInfo p_info) {
switch (p_info) {
- case INFO_ACTIVE_OBJECTS: {
+ case PS3DE::INFO_ACTIVE_OBJECTS: {
return active_objects;
} break;
- case INFO_COLLISION_PAIRS: {
+ case PS3DE::INFO_COLLISION_PAIRS: {
return collision_pairs;
} break;
- case INFO_ISLAND_COUNT: {
+ case PS3DE::INFO_ISLAND_COUNT: {
return island_count;
} break;
}
diff --git a/modules/godot_physics_3d/godot_physics_server_3d.h b/modules/godot_physics_3d/godot_physics_server_3d.h
index 052019f33c0..58410fb1f07 100644
--- a/modules/godot_physics_3d/godot_physics_server_3d.h
+++ b/modules/godot_physics_3d/godot_physics_server_3d.h
@@ -92,7 +92,7 @@ public:
virtual void shape_set_data(RID p_shape, const Variant &p_data) override;
virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias) override;
- virtual ShapeType shape_get_type(RID p_shape) const override;
+ virtual PS3DE::ShapeType shape_get_type(RID p_shape) const override;
virtual Variant shape_get_data(RID p_shape) const override;
virtual void shape_set_margin(RID p_shape, real_t p_margin) override;
@@ -106,8 +106,8 @@ public:
virtual void space_set_active(RID p_space, bool p_active) override;
virtual bool space_is_active(RID p_space) const override;
- virtual void space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) override;
- virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const override;
+ virtual void space_set_param(RID p_space, PS3DE::SpaceParameter p_param, real_t p_value) override;
+ virtual real_t space_get_param(RID p_space, PS3DE::SpaceParameter p_param) const override;
// this function only works on physics process, errors and returns null otherwise
virtual PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space) override;
@@ -139,10 +139,10 @@ public:
virtual void area_attach_object_instance_id(RID p_area, ObjectID p_id) override;
virtual ObjectID area_get_object_instance_id(RID p_area) const override;
- virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) override;
+ virtual void area_set_param(RID p_area, PS3DE::AreaParameter p_param, const Variant &p_value) override;
virtual void area_set_transform(RID p_area, const Transform3D &p_transform) override;
- virtual Variant area_get_param(RID p_area, AreaParameter p_param) const override;
+ virtual Variant area_get_param(RID p_area, PS3DE::AreaParameter p_param) const override;
virtual Transform3D area_get_transform(RID p_area) const override;
virtual void area_set_ray_pickable(RID p_area, bool p_enable) override;
@@ -166,8 +166,8 @@ public:
virtual void body_set_space(RID p_body, RID p_space) override;
virtual RID body_get_space(RID p_body) const override;
- virtual void body_set_mode(RID p_body, BodyMode p_mode) override;
- virtual BodyMode body_get_mode(RID p_body) const override;
+ virtual void body_set_mode(RID p_body, PS3DE::BodyMode p_mode) override;
+ virtual PS3DE::BodyMode body_get_mode(RID p_body) const override;
virtual void body_add_shape(RID p_body, RID p_shape, const Transform3D &p_transform = Transform3D(), bool p_disabled = false) override;
virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape) override;
@@ -200,13 +200,13 @@ public:
virtual void body_set_user_flags(RID p_body, uint32_t p_flags) override;
virtual uint32_t body_get_user_flags(RID p_body) const override;
- virtual void body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) override;
- virtual Variant body_get_param(RID p_body, BodyParameter p_param) const override;
+ virtual void body_set_param(RID p_body, PS3DE::BodyParameter p_param, const Variant &p_value) override;
+ virtual Variant body_get_param(RID p_body, PS3DE::BodyParameter p_param) const override;
virtual void body_reset_mass_properties(RID p_body) override;
- virtual void body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) override;
- virtual Variant body_get_state(RID p_body, BodyState p_state) const override;
+ virtual void body_set_state(RID p_body, PS3DE::BodyState p_state, const Variant &p_variant) override;
+ virtual Variant body_get_state(RID p_body, PS3DE::BodyState p_state) const override;
virtual void body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) override;
virtual void body_apply_impulse(RID p_body, const Vector3 &p_impulse, const Vector3 &p_position = Vector3()) override;
@@ -233,8 +233,8 @@ public:
virtual void body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) override;
- virtual void body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) override;
- virtual bool body_is_axis_locked(RID p_body, BodyAxis p_axis) const override;
+ virtual void body_set_axis_lock(RID p_body, PS3DE::BodyAxis p_axis, bool p_lock) override;
+ virtual bool body_is_axis_locked(RID p_body, PS3DE::BodyAxis p_axis) const override;
virtual void body_add_collision_exception(RID p_body, RID p_body_b) override;
virtual void body_remove_collision_exception(RID p_body, RID p_body_b) override;
@@ -254,7 +254,7 @@ public:
virtual void body_set_ray_pickable(RID p_body, bool p_enable) override;
- virtual bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) override;
+ virtual bool body_test_motion(RID p_body, const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult *r_result = nullptr) override;
// this function only works on physics process, errors and returns null otherwise
virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) override;
@@ -278,8 +278,8 @@ public:
virtual void soft_body_remove_collision_exception(RID p_body, RID p_body_b) override;
virtual void soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) override;
- virtual void soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) override;
- virtual Variant soft_body_get_state(RID p_body, BodyState p_state) const override;
+ virtual void soft_body_set_state(RID p_body, PS3DE::BodyState p_state, const Variant &p_variant) override;
+ virtual Variant soft_body_get_state(RID p_body, PS3DE::BodyState p_state) const override;
virtual void soft_body_set_transform(RID p_body, const Transform3D &p_transform) override;
@@ -325,8 +325,8 @@ public:
virtual void joint_make_pin(RID p_joint, RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) override;
- virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) override;
- virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const override;
+ virtual void pin_joint_set_param(RID p_joint, PS3DE::PinJointParam p_param, real_t p_value) override;
+ virtual real_t pin_joint_get_param(RID p_joint, PS3DE::PinJointParam p_param) const override;
virtual void pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) override;
virtual Vector3 pin_joint_get_local_a(RID p_joint) const override;
@@ -337,34 +337,34 @@ public:
virtual void joint_make_hinge(RID p_joint, RID p_body_A, const Transform3D &p_frame_A, RID p_body_B, const Transform3D &p_frame_B) override;
virtual void 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) override;
- virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) override;
- virtual real_t hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const override;
+ virtual void hinge_joint_set_param(RID p_joint, PS3DE::HingeJointParam p_param, real_t p_value) override;
+ virtual real_t hinge_joint_get_param(RID p_joint, PS3DE::HingeJointParam p_param) const override;
- virtual void hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) override;
- virtual bool hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const override;
+ virtual void hinge_joint_set_flag(RID p_joint, PS3DE::HingeJointFlag p_flag, bool p_value) override;
+ virtual bool hinge_joint_get_flag(RID p_joint, PS3DE::HingeJointFlag p_flag) const override;
virtual void joint_make_slider(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) override; //reference frame is A
- virtual void slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) override;
- virtual real_t slider_joint_get_param(RID p_joint, SliderJointParam p_param) const override;
+ virtual void slider_joint_set_param(RID p_joint, PS3DE::SliderJointParam p_param, real_t p_value) override;
+ virtual real_t slider_joint_get_param(RID p_joint, PS3DE::SliderJointParam p_param) const override;
virtual void joint_make_cone_twist(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) override; //reference frame is A
- virtual void cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) override;
- virtual real_t cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const override;
+ virtual void cone_twist_joint_set_param(RID p_joint, PS3DE::ConeTwistJointParam p_param, real_t p_value) override;
+ virtual real_t cone_twist_joint_get_param(RID p_joint, PS3DE::ConeTwistJointParam p_param) const override;
virtual void joint_make_generic_6dof(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) override; //reference frame is A
- virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param, real_t p_value) override;
- virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param) const override;
+ virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis, PS3DE::G6DOFJointAxisParam p_param, real_t p_value) override;
+ virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis, PS3DE::G6DOFJointAxisParam p_param) const override;
- virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag, bool p_enable) override;
- virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag) const override;
+ virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis, PS3DE::G6DOFJointAxisFlag p_flag, bool p_enable) override;
+ virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis, PS3DE::G6DOFJointAxisFlag p_flag) const override;
virtual void generic_6dof_joint_set_angular_target_rotation(RID p_joint, const Quaternion &p_target_rotation) override;
virtual Quaternion generic_6dof_joint_get_angular_target_rotation(RID p_joint) const override;
- virtual JointType joint_get_type(RID p_joint) const override;
+ virtual PS3DE::JointType joint_get_type(RID p_joint) const override;
virtual void joint_set_solver_priority(RID p_joint, int p_priority) override;
virtual int joint_get_solver_priority(RID p_joint) const override;
@@ -386,7 +386,7 @@ public:
virtual bool is_flushing_queries() const override { return flushing_queries; }
- int get_process_info(ProcessInfo p_info) override;
+ int get_process_info(PS3DE::ProcessInfo p_info) override;
GodotPhysicsServer3D(bool p_using_threads = false);
~GodotPhysicsServer3D() {}
diff --git a/modules/godot_physics_3d/godot_shape_3d.h b/modules/godot_physics_3d/godot_shape_3d.h
index 9a7b78e3e6a..2b8da7efef4 100644
--- a/modules/godot_physics_3d/godot_shape_3d.h
+++ b/modules/godot_physics_3d/godot_shape_3d.h
@@ -31,8 +31,11 @@
#pragma once
#include "core/math/geometry_3d.h"
+#include "core/templates/hash_map.h"
#include "core/templates/local_vector.h"
-#include "servers/physics_3d/physics_server_3d.h"
+#include "core/templates/rid.h"
+#include "core/variant/variant.h"
+#include "servers/physics_3d/physics_server_3d_enums.h"
class GodotShape3D;
@@ -68,7 +71,7 @@ public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
_FORCE_INLINE_ RID get_self() const { return self; }
- virtual PhysicsServer3D::ShapeType get_type() const = 0;
+ virtual PS3DE::ShapeType get_type() const = 0;
_FORCE_INLINE_ const AABB &get_aabb() const { return aabb; }
_FORCE_INLINE_ bool is_configured() const { return configured; }
@@ -120,7 +123,7 @@ public:
Plane get_plane() const;
virtual real_t get_volume() const override { return Math::INF; }
- virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_WORLD_BOUNDARY; }
+ virtual PS3DE::ShapeType get_type() const override { return PS3DE::SHAPE_WORLD_BOUNDARY; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const override;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const override { r_amount = 0; }
@@ -147,7 +150,7 @@ public:
bool get_slide_on_slope() const;
virtual real_t get_volume() const override { return 0.0; }
- virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_SEPARATION_RAY; }
+ virtual PS3DE::ShapeType get_type() const override { return PS3DE::SHAPE_SEPARATION_RAY; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const override;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const override;
@@ -174,7 +177,7 @@ public:
virtual real_t get_volume() const override { return 4.0 / 3.0 * Math::PI * radius * radius * radius; }
- virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_SPHERE; }
+ virtual PS3DE::ShapeType get_type() const override { return PS3DE::SHAPE_SPHERE; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const override;
@@ -199,7 +202,7 @@ public:
_FORCE_INLINE_ Vector3 get_half_extents() const { return half_extents; }
virtual real_t get_volume() const override { return 8 * half_extents.x * half_extents.y * half_extents.z; }
- virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_BOX; }
+ virtual PS3DE::ShapeType get_type() const override { return PS3DE::SHAPE_BOX; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const override;
@@ -228,7 +231,7 @@ public:
virtual real_t get_volume() const override { return 4.0 / 3.0 * Math::PI * radius * radius * radius + (height - radius * 2.0) * Math::PI * radius * radius; }
- virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CAPSULE; }
+ virtual PS3DE::ShapeType get_type() const override { return PS3DE::SHAPE_CAPSULE; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const override;
@@ -257,7 +260,7 @@ public:
virtual real_t get_volume() const override { return height * Math::PI * radius * radius; }
- virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CYLINDER; }
+ virtual PS3DE::ShapeType get_type() const override { return PS3DE::SHAPE_CYLINDER; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const override;
@@ -284,7 +287,7 @@ struct GodotConvexPolygonShape3D : public GodotShape3D {
public:
const Geometry3D::MeshData &get_mesh() const { return mesh; }
- virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; }
+ virtual PS3DE::ShapeType get_type() const override { return PS3DE::SHAPE_CONVEX_POLYGON; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const override;
@@ -363,7 +366,7 @@ struct GodotConcavePolygonShape3D : public GodotConcaveShape3D {
public:
Vector<Vector3> get_faces() const;
- virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CONCAVE_POLYGON; }
+ virtual PS3DE::ShapeType get_type() const override { return PS3DE::SHAPE_CONCAVE_POLYGON; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const override;
@@ -427,7 +430,7 @@ public:
int get_width() const;
int get_depth() const;
- virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_HEIGHTMAP; }
+ virtual PS3DE::ShapeType get_type() const override { return PS3DE::SHAPE_HEIGHTMAP; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
virtual Vector3 get_support(const Vector3 &p_normal) const override;
@@ -452,7 +455,7 @@ struct GodotFaceShape3D : public GodotShape3D {
bool backface_collision = false;
bool invert_backface_collision = false;
- virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CONCAVE_POLYGON; }
+ virtual PS3DE::ShapeType get_type() const override { return PS3DE::SHAPE_CONCAVE_POLYGON; }
const Vector3 &get_vertex(int p_idx) const { return vertex[p_idx]; }
@@ -475,7 +478,7 @@ struct GodotMotionShape3D : public GodotShape3D {
GodotShape3D *shape = nullptr;
Vector3 motion;
- virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; }
+ virtual PS3DE::ShapeType get_type() const override { return PS3DE::SHAPE_CONVEX_POLYGON; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override {
Vector3 cast = p_transform.basis.xform(motion);
diff --git a/modules/godot_physics_3d/godot_soft_body_3d.cpp b/modules/godot_physics_3d/godot_soft_body_3d.cpp
index 67b237e1e55..627fdfb08e0 100644
--- a/modules/godot_physics_3d/godot_soft_body_3d.cpp
+++ b/modules/godot_physics_3d/godot_soft_body_3d.cpp
@@ -33,6 +33,7 @@
#include "godot_space_3d.h"
#include "core/math/geometry_3d.h"
+#include "servers/physics_3d/physics_server_3d_rendering_server_handler.h"
#include "servers/rendering/rendering_server.h"
// Based on Bullet soft body.
@@ -62,46 +63,46 @@ GodotSoftBody3D::GodotSoftBody3D() :
void GodotSoftBody3D::_shapes_changed() {
}
-void GodotSoftBody3D::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant) {
+void GodotSoftBody3D::set_state(PS3DE::BodyState p_state, const Variant &p_variant) {
switch (p_state) {
- case PhysicsServer3D::BODY_STATE_TRANSFORM: {
+ case PS3DE::BODY_STATE_TRANSFORM: {
_set_transform(p_variant);
_set_inv_transform(get_transform().inverse());
apply_nodes_transform(get_transform());
} break;
- case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: {
+ case PS3DE::BODY_STATE_LINEAR_VELOCITY: {
// Not supported.
ERR_FAIL_MSG("Linear velocity is not supported for Soft bodies.");
} break;
- case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: {
+ case PS3DE::BODY_STATE_ANGULAR_VELOCITY: {
ERR_FAIL_MSG("Angular velocity is not supported for Soft bodies.");
} break;
- case PhysicsServer3D::BODY_STATE_SLEEPING: {
+ case PS3DE::BODY_STATE_SLEEPING: {
ERR_FAIL_MSG("Sleeping state is not supported for Soft bodies.");
} break;
- case PhysicsServer3D::BODY_STATE_CAN_SLEEP: {
+ case PS3DE::BODY_STATE_CAN_SLEEP: {
ERR_FAIL_MSG("Sleeping state is not supported for Soft bodies.");
} break;
}
}
-Variant GodotSoftBody3D::get_state(PhysicsServer3D::BodyState p_state) const {
+Variant GodotSoftBody3D::get_state(PS3DE::BodyState p_state) const {
switch (p_state) {
- case PhysicsServer3D::BODY_STATE_TRANSFORM: {
+ case PS3DE::BODY_STATE_TRANSFORM: {
return get_transform();
} break;
- case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: {
+ case PS3DE::BODY_STATE_LINEAR_VELOCITY: {
ERR_FAIL_V_MSG(Vector3(), "Linear velocity is not supported for Soft bodies.");
} break;
- case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: {
+ case PS3DE::BODY_STATE_ANGULAR_VELOCITY: {
ERR_FAIL_V_MSG(Vector3(), "Angular velocity is not supported for Soft bodies.");
} break;
- case PhysicsServer3D::BODY_STATE_SLEEPING: {
+ case PS3DE::BODY_STATE_SLEEPING: {
ERR_FAIL_V_MSG(false, "Sleeping state is not supported for Soft bodies.");
} break;
- case PhysicsServer3D::BODY_STATE_CAN_SLEEP: {
+ case PS3DE::BODY_STATE_CAN_SLEEP: {
ERR_FAIL_V_MSG(false, "Sleeping state is not supported for Soft bodies.");
} break;
}
@@ -1019,20 +1020,20 @@ void GodotSoftBody3D::predict_motion(real_t p_delta) {
const AreaCMP *aa = &areas[0];
for (int i = ac - 1; i >= 0; i--) {
if (!gravity_done) {
- PhysicsServer3D::AreaSpaceOverrideMode area_gravity_mode = (PhysicsServer3D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE);
- if (area_gravity_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
+ PS3DE::AreaSpaceOverrideMode area_gravity_mode = (PS3DE::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PS3DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE);
+ if (area_gravity_mode != PS3DE::AREA_SPACE_OVERRIDE_DISABLED) {
Vector3 area_gravity;
aa[i].area->compute_gravity(get_transform().get_origin(), area_gravity);
switch (area_gravity_mode) {
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE:
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
+ case PS3DE::AREA_SPACE_OVERRIDE_COMBINE:
+ case PS3DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
gravity += area_gravity;
- gravity_done = area_gravity_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
+ gravity_done = area_gravity_mode == PS3DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE:
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
+ case PS3DE::AREA_SPACE_OVERRIDE_REPLACE:
+ case PS3DE::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
gravity = area_gravity;
- gravity_done = area_gravity_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE;
+ gravity_done = area_gravity_mode == PS3DE::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
diff --git a/modules/godot_physics_3d/godot_soft_body_3d.h b/modules/godot_physics_3d/godot_soft_body_3d.h
index 7b5d345a84c..f92b8d76720 100644
--- a/modules/godot_physics_3d/godot_soft_body_3d.h
+++ b/modules/godot_physics_3d/godot_soft_body_3d.h
@@ -41,6 +41,7 @@
#include "core/templates/vset.h"
class GodotConstraint3D;
+class PhysicsServer3DRenderingServerHandler;
class GodotSoftBody3D : public GodotCollisionObject3D {
RID soft_mesh;
@@ -118,8 +119,8 @@ public:
const AABB &get_bounds() const { return bounds; }
- void set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant);
- Variant get_state(PhysicsServer3D::BodyState p_state) const;
+ void set_state(PS3DE::BodyState p_state, const Variant &p_variant);
+ Variant get_state(PS3DE::BodyState p_state) const;
_FORCE_INLINE_ void add_constraint(GodotConstraint3D *p_constraint) { constraints.insert(p_constraint); }
_FORCE_INLINE_ void remove_constraint(GodotConstraint3D *p_constraint) { constraints.erase(p_constraint); }
@@ -260,7 +261,7 @@ class GodotSoftBodyShape3D : public GodotShape3D {
public:
GodotSoftBody3D *get_soft_body() const { return soft_body; }
- virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_SOFT_BODY; }
+ virtual PS3DE::ShapeType get_type() const override { return PS3DE::SHAPE_SOFT_BODY; }
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override { r_min = r_max = 0.0; }
virtual Vector3 get_support(const Vector3 &p_normal) const override { return Vector3(); }
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const override { r_amount = 0; }
diff --git a/modules/godot_physics_3d/godot_space_3d.cpp b/modules/godot_physics_3d/godot_space_3d.cpp
index 04c27626cee..c0aef2a9cc1 100644
--- a/modules/godot_physics_3d/godot_space_3d.cpp
+++ b/modules/godot_physics_3d/godot_space_3d.cpp
@@ -60,7 +60,7 @@ _FORCE_INLINE_ static bool _can_collide_with(GodotCollisionObject3D *p_object, u
return true;
}
-int GodotPhysicsDirectSpaceState3D::intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) {
+int GodotPhysicsDirectSpaceState3D::intersect_point(const PS3DT::PointParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) {
ERR_FAIL_COND_V(space->locked, false);
int amount = space->broadphase->cull_point(p_parameters.position, space->intersection_query_results, GodotSpace3D::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
int cc = 0;
@@ -107,7 +107,7 @@ int GodotPhysicsDirectSpaceState3D::intersect_point(const PointParameters &p_par
return cc;
}
-bool GodotPhysicsDirectSpaceState3D::intersect_ray(const RayParameters &p_parameters, RayResult &r_result) {
+bool GodotPhysicsDirectSpaceState3D::intersect_ray(const PS3DT::RayParameters &p_parameters, PS3DT::RayResult &r_result) {
ERR_FAIL_COND_V(space->locked, false);
Vector3 begin, end;
@@ -207,7 +207,7 @@ bool GodotPhysicsDirectSpaceState3D::intersect_ray(const RayParameters &p_parame
return true;
}
-int GodotPhysicsDirectSpaceState3D::intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) {
+int GodotPhysicsDirectSpaceState3D::intersect_shape(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) {
if (p_result_max <= 0) {
return 0;
}
@@ -262,7 +262,7 @@ int GodotPhysicsDirectSpaceState3D::intersect_shape(const ShapeParameters &p_par
return cc;
}
-bool GodotPhysicsDirectSpaceState3D::cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, ShapeRestInfo *r_info) {
+bool GodotPhysicsDirectSpaceState3D::cast_motion(const PS3DT::ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, PS3DT::ShapeRestInfo *r_info) {
GodotShape3D *shape = GodotPhysicsServer3D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
ERR_FAIL_NULL_V(shape, false);
@@ -381,7 +381,7 @@ bool GodotPhysicsDirectSpaceState3D::cast_motion(const ShapeParameters &p_parame
return true;
}
-bool GodotPhysicsDirectSpaceState3D::collide_shape(const ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) {
+bool GodotPhysicsDirectSpaceState3D::collide_shape(const PS3DT::ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) {
if (p_result_max <= 0) {
return false;
}
@@ -511,7 +511,7 @@ static void _rest_cbk_result(const Vector3 &p_point_A, int p_index_A, const Vect
rd->best_result.local_shape = rd->local_shape;
}
-bool GodotPhysicsDirectSpaceState3D::rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) {
+bool GodotPhysicsDirectSpaceState3D::rest_info(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeRestInfo *r_info) {
GodotShape3D *shape = GodotPhysicsServer3D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid);
ERR_FAIL_NULL_V(shape, false);
@@ -649,7 +649,7 @@ int GodotSpace3D::_cull_aabb_for_body(GodotBody3D *p_body, const AABB &p_aabb) {
return amount;
}
-bool GodotSpace3D::test_body_motion(GodotBody3D *p_body, const PhysicsServer3D::MotionParameters &p_parameters, PhysicsServer3D::MotionResult *r_result) {
+bool GodotSpace3D::test_body_motion(GodotBody3D *p_body, const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult *r_result) {
//give me back regular physics engine logic
//this is madness
//and most people using this function will think
@@ -657,10 +657,10 @@ bool GodotSpace3D::test_body_motion(GodotBody3D *p_body, const PhysicsServer3D::
//this took about a week to get right..
//but is it right? who knows at this point..
- ERR_FAIL_COND_V(p_parameters.max_collisions < 0 || p_parameters.max_collisions > PhysicsServer3D::MotionResult::MAX_COLLISIONS, false);
+ ERR_FAIL_COND_V(p_parameters.max_collisions < 0 || p_parameters.max_collisions > PS3DT::MotionResult::MAX_COLLISIONS, false);
if (r_result) {
- *r_result = PhysicsServer3D::MotionResult();
+ *r_result = PS3DT::MotionResult();
}
AABB body_aabb;
@@ -817,7 +817,7 @@ bool GodotSpace3D::test_body_motion(GodotBody3D *p_body, const PhysicsServer3D::
// Colliding separation rays allows to properly snap to the ground,
// otherwise it's not needed in regular motion.
- if (!p_parameters.collide_separation_ray && (body_shape->get_type() == PhysicsServer3D::SHAPE_SEPARATION_RAY)) {
+ if (!p_parameters.collide_separation_ray && (body_shape->get_type() == PS3DE::SHAPE_SEPARATION_RAY)) {
// When slide on slope is on, separation ray shape acts like a regular shape.
if (!static_cast<GodotSeparationRayShape3D *>(body_shape)->get_slide_on_slope()) {
continue;
@@ -934,7 +934,7 @@ bool GodotSpace3D::test_body_motion(GodotBody3D *p_body, const PhysicsServer3D::
Transform3D ugt = body_transform;
ugt.origin += p_parameters.motion * unsafe;
- _RestResultData results[PhysicsServer3D::MotionResult::MAX_COLLISIONS];
+ _RestResultData results[PS3DT::MotionResult::MAX_COLLISIONS];
_RestCallbackData rcd;
if (p_parameters.max_collisions > 1) {
@@ -985,7 +985,7 @@ bool GodotSpace3D::test_body_motion(GodotBody3D *p_body, const PhysicsServer3D::
for (int collision_index = 0; collision_index < rcd.result_count; ++collision_index) {
const _RestResultData &result = (collision_index > 0) ? rcd.other_results[collision_index - 1] : rcd.best_result;
- PhysicsServer3D::MotionCollision &collision = r_result->collisions[collision_index];
+ PS3DT::MotionCollision &collision = r_result->collisions[collision_index];
collision.collider = result.object->get_self();
collision.collider_id = result.object->get_instance_id();
@@ -1189,52 +1189,52 @@ void GodotSpace3D::update() {
broadphase->update();
}
-void GodotSpace3D::set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value) {
+void GodotSpace3D::set_param(PS3DE::SpaceParameter p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
+ case PS3DE::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
contact_recycle_radius = p_value;
break;
- case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION:
+ case PS3DE::SPACE_PARAM_CONTACT_MAX_SEPARATION:
contact_max_separation = p_value;
break;
- case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION:
+ case PS3DE::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION:
contact_max_allowed_penetration = p_value;
break;
- case PhysicsServer3D::SPACE_PARAM_CONTACT_DEFAULT_BIAS:
+ case PS3DE::SPACE_PARAM_CONTACT_DEFAULT_BIAS:
contact_bias = p_value;
break;
- case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
+ case PS3DE::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
body_linear_velocity_sleep_threshold = p_value;
break;
- case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
+ case PS3DE::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
body_angular_velocity_sleep_threshold = p_value;
break;
- case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP:
+ case PS3DE::SPACE_PARAM_BODY_TIME_TO_SLEEP:
body_time_to_sleep = p_value;
break;
- case PhysicsServer3D::SPACE_PARAM_SOLVER_ITERATIONS:
+ case PS3DE::SPACE_PARAM_SOLVER_ITERATIONS:
solver_iterations = p_value;
break;
}
}
-real_t GodotSpace3D::get_param(PhysicsServer3D::SpaceParameter p_param) const {
+real_t GodotSpace3D::get_param(PS3DE::SpaceParameter p_param) const {
switch (p_param) {
- case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
+ case PS3DE::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
return contact_recycle_radius;
- case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION:
+ case PS3DE::SPACE_PARAM_CONTACT_MAX_SEPARATION:
return contact_max_separation;
- case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION:
+ case PS3DE::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION:
return contact_max_allowed_penetration;
- case PhysicsServer3D::SPACE_PARAM_CONTACT_DEFAULT_BIAS:
+ case PS3DE::SPACE_PARAM_CONTACT_DEFAULT_BIAS:
return contact_bias;
- case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
+ case PS3DE::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
return body_linear_velocity_sleep_threshold;
- case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
+ case PS3DE::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
return body_angular_velocity_sleep_threshold;
- case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP:
+ case PS3DE::SPACE_PARAM_BODY_TIME_TO_SLEEP:
return body_time_to_sleep;
- case PhysicsServer3D::SPACE_PARAM_SOLVER_ITERATIONS:
+ case PS3DE::SPACE_PARAM_SOLVER_ITERATIONS:
return solver_iterations;
}
return 0;
diff --git a/modules/godot_physics_3d/godot_space_3d.h b/modules/godot_physics_3d/godot_space_3d.h
index cc306fb1be5..d9db6a1f748 100644
--- a/modules/godot_physics_3d/godot_space_3d.h
+++ b/modules/godot_physics_3d/godot_space_3d.h
@@ -37,6 +37,7 @@
#include "godot_soft_body_3d.h"
#include "core/typedefs.h"
+#include "servers/physics_3d/direct_states/physics_direct_space_state_3d.h"
class GodotPhysicsDirectSpaceState3D : public PhysicsDirectSpaceState3D {
GDCLASS(GodotPhysicsDirectSpaceState3D, PhysicsDirectSpaceState3D);
@@ -44,12 +45,12 @@ class GodotPhysicsDirectSpaceState3D : public PhysicsDirectSpaceState3D {
public:
GodotSpace3D *space = nullptr;
- virtual int intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) override;
- virtual bool intersect_ray(const RayParameters &p_parameters, RayResult &r_result) override;
- virtual int intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) override;
- virtual bool cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, ShapeRestInfo *r_info = nullptr) override;
- virtual bool collide_shape(const ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) override;
- virtual bool rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) override;
+ virtual int intersect_point(const PS3DT::PointParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) override;
+ virtual bool intersect_ray(const PS3DT::RayParameters &p_parameters, PS3DT::RayResult &r_result) override;
+ virtual int intersect_shape(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) override;
+ virtual bool cast_motion(const PS3DT::ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, PS3DT::ShapeRestInfo *r_info = nullptr) override;
+ virtual bool collide_shape(const PS3DT::ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) override;
+ virtual bool rest_info(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeRestInfo *r_info) override;
virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const override;
GodotPhysicsDirectSpaceState3D();
@@ -175,8 +176,8 @@ public:
real_t get_last_step() const { return last_step; }
void set_last_step(real_t p_step) { last_step = p_step; }
- void set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value);
- real_t get_param(PhysicsServer3D::SpaceParameter p_param) const;
+ void set_param(PS3DE::SpaceParameter p_param, real_t p_value);
+ real_t get_param(PS3DE::SpaceParameter p_param) const;
void set_island_count(int p_island_count) { island_count = p_island_count; }
int get_island_count() const { return island_count; }
@@ -204,7 +205,7 @@ public:
void set_elapsed_time(ElapsedTime p_time, uint64_t p_msec) { elapsed_time[p_time] = p_msec; }
uint64_t get_elapsed_time(ElapsedTime p_time) const { return elapsed_time[p_time]; }
- bool test_body_motion(GodotBody3D *p_body, const PhysicsServer3D::MotionParameters &p_parameters, PhysicsServer3D::MotionResult *r_result);
+ bool test_body_motion(GodotBody3D *p_body, const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult *r_result);
GodotSpace3D();
~GodotSpace3D();
diff --git a/modules/godot_physics_3d/godot_step_3d.cpp b/modules/godot_physics_3d/godot_step_3d.cpp
index f8ddf5e082e..f270a185dba 100644
--- a/modules/godot_physics_3d/godot_step_3d.cpp
+++ b/modules/godot_physics_3d/godot_step_3d.cpp
@@ -44,7 +44,7 @@
void GodotStep3D::_populate_island(GodotBody3D *p_body, LocalVector<GodotBody3D *> &p_body_island, LocalVector<GodotConstraint3D *> &p_constraint_island) {
p_body->set_island_step(_step);
- if (p_body->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC) {
+ if (p_body->get_mode() > PS3DE::BODY_MODE_KINEMATIC) {
// Only rigid bodies are tested for activation.
p_body_island.push_back(p_body);
}
@@ -68,7 +68,7 @@ void GodotStep3D::_populate_island(GodotBody3D *p_body, LocalVector<GodotBody3D
if (other_body->get_island_step() == _step) {
continue; // Already processed.
}
- if (other_body->get_mode() == PhysicsServer3D::BODY_MODE_STATIC) {
+ if (other_body->get_mode() == PS3DE::BODY_MODE_STATIC) {
continue; // Static bodies don't connect islands.
}
_populate_island(other_body, p_body_island, p_constraint_island);
@@ -104,7 +104,7 @@ void GodotStep3D::_populate_island_soft_body(GodotSoftBody3D *p_soft_body, Local
if (body->get_island_step() == _step) {
continue; // Already processed.
}
- if (body->get_mode() == PhysicsServer3D::BODY_MODE_STATIC) {
+ if (body->get_mode() == PS3DE::BODY_MODE_STATIC) {
continue; // Static bodies don't connect islands.
}
_populate_island(body, p_body_island, p_constraint_island);
diff --git a/modules/godot_physics_3d/joints/godot_cone_twist_joint_3d.cpp b/modules/godot_physics_3d/joints/godot_cone_twist_joint_3d.cpp
index 7641ac6891d..c8a65946b06 100644
--- a/modules/godot_physics_3d/joints/godot_cone_twist_joint_3d.cpp
+++ b/modules/godot_physics_3d/joints/godot_cone_twist_joint_3d.cpp
@@ -64,8 +64,8 @@ GodotConeTwistJoint3D::GodotConeTwistJoint3D(GodotBody3D *rbA, GodotBody3D *rbB,
}
bool GodotConeTwistJoint3D::setup(real_t p_timestep) {
- dynamic_A = (A->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC);
- dynamic_B = (B->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC);
+ dynamic_A = (A->get_mode() > PS3DE::BODY_MODE_KINEMATIC);
+ dynamic_B = (B->get_mode() > PS3DE::BODY_MODE_KINEMATIC);
if (!dynamic_A && !dynamic_B) {
return false;
@@ -278,47 +278,47 @@ void GodotConeTwistJoint3D::solve(real_t p_timestep) {
}
}
-void GodotConeTwistJoint3D::set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value) {
+void GodotConeTwistJoint3D::set_param(PS3DE::ConeTwistJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: {
+ case PS3DE::CONE_TWIST_JOINT_SWING_SPAN: {
m_swingSpan1 = p_value;
m_swingSpan2 = p_value;
} break;
- case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: {
+ case PS3DE::CONE_TWIST_JOINT_TWIST_SPAN: {
m_twistSpan = p_value;
} break;
- case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: {
+ case PS3DE::CONE_TWIST_JOINT_BIAS: {
m_biasFactor = p_value;
} break;
- case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: {
+ case PS3DE::CONE_TWIST_JOINT_SOFTNESS: {
m_limitSoftness = p_value;
} break;
- case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: {
+ case PS3DE::CONE_TWIST_JOINT_RELAXATION: {
m_relaxationFactor = p_value;
} break;
- case PhysicsServer3D::CONE_TWIST_MAX:
+ case PS3DE::CONE_TWIST_MAX:
break; // Can't happen, but silences warning
}
}
-real_t GodotConeTwistJoint3D::get_param(PhysicsServer3D::ConeTwistJointParam p_param) const {
+real_t GodotConeTwistJoint3D::get_param(PS3DE::ConeTwistJointParam p_param) const {
switch (p_param) {
- case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: {
+ case PS3DE::CONE_TWIST_JOINT_SWING_SPAN: {
return m_swingSpan1;
} break;
- case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: {
+ case PS3DE::CONE_TWIST_JOINT_TWIST_SPAN: {
return m_twistSpan;
} break;
- case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: {
+ case PS3DE::CONE_TWIST_JOINT_BIAS: {
return m_biasFactor;
} break;
- case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: {
+ case PS3DE::CONE_TWIST_JOINT_SOFTNESS: {
return m_limitSoftness;
} break;
- case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: {
+ case PS3DE::CONE_TWIST_JOINT_RELAXATION: {
return m_relaxationFactor;
} break;
- case PhysicsServer3D::CONE_TWIST_MAX:
+ case PS3DE::CONE_TWIST_MAX:
break; // Can't happen, but silences warning
}
diff --git a/modules/godot_physics_3d/joints/godot_cone_twist_joint_3d.h b/modules/godot_physics_3d/joints/godot_cone_twist_joint_3d.h
index 1071080c8cb..2f93244c5ff 100644
--- a/modules/godot_physics_3d/joints/godot_cone_twist_joint_3d.h
+++ b/modules/godot_physics_3d/joints/godot_cone_twist_joint_3d.h
@@ -101,7 +101,7 @@ public:
bool m_solveSwingLimit = false;
public:
- virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_CONE_TWIST; }
+ virtual PS3DE::JointType get_type() const override { return PS3DE::JOINT_TYPE_CONE_TWIST; }
virtual bool setup(real_t p_step) override;
virtual void solve(real_t p_step) override;
@@ -134,6 +134,6 @@ public:
return m_twistLimitSign;
}
- void set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer3D::ConeTwistJointParam p_param) const;
+ void set_param(PS3DE::ConeTwistJointParam p_param, real_t p_value);
+ real_t get_param(PS3DE::ConeTwistJointParam p_param) const;
};
diff --git a/modules/godot_physics_3d/joints/godot_generic_6dof_joint_3d.cpp b/modules/godot_physics_3d/joints/godot_generic_6dof_joint_3d.cpp
index 1197e7cdfee..f44bb7af810 100644
--- a/modules/godot_physics_3d/joints/godot_generic_6dof_joint_3d.cpp
+++ b/modules/godot_physics_3d/joints/godot_generic_6dof_joint_3d.cpp
@@ -314,8 +314,8 @@ bool GodotGeneric6DOFJoint3D::testAngularLimitMotor(int axis_index) {
}
bool GodotGeneric6DOFJoint3D::setup(real_t p_timestep) {
- dynamic_A = (A->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC);
- dynamic_B = (B->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC);
+ dynamic_A = (A->get_mode() > PS3DE::BODY_MODE_KINEMATIC);
+ dynamic_B = (B->get_mode() > PS3DE::BODY_MODE_KINEMATIC);
if (!dynamic_A && !dynamic_B) {
return false;
@@ -444,242 +444,242 @@ void GodotGeneric6DOFJoint3D::calcAnchorPos() {
m_AnchorPos = pA * weight + pB * (real_t(1.0) - weight);
}
-void GodotGeneric6DOFJoint3D::set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value) {
+void GodotGeneric6DOFJoint3D::set_param(Vector3::Axis p_axis, PS3DE::G6DOFJointAxisParam p_param, real_t p_value) {
ERR_FAIL_INDEX(p_axis, 3);
switch (p_param) {
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
m_linearLimits.m_lowerLimit[p_axis] = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
m_linearLimits.m_upperLimit[p_axis] = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
+ case PS3DE::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
m_linearLimits.m_limitSoftness[p_axis] = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION: {
+ case PS3DE::G6DOF_JOINT_LINEAR_RESTITUTION: {
m_linearLimits.m_restitution[p_axis] = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING: {
+ case PS3DE::G6DOF_JOINT_LINEAR_DAMPING: {
m_linearLimits.m_damping[p_axis] = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
m_angularLimits[p_axis].m_loLimit = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
m_angularLimits[p_axis].m_hiLimit = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
m_angularLimits[p_axis].m_limitSoftness = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_DAMPING: {
m_angularLimits[p_axis].m_damping = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_RESTITUTION: {
m_angularLimits[p_axis].m_bounce = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
m_angularLimits[p_axis].m_maxLimitForce = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_ERP: {
m_angularLimits[p_axis].m_ERP = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
m_angularLimits[p_axis].m_targetVelocity = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
m_angularLimits[p_axis].m_maxLimitForce = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
+ case PS3DE::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: {
+ case PS3DE::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING: {
+ case PS3DE::G6DOF_JOINT_LINEAR_SPRING_DAMPING: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT: {
m_linearDriveForceLimit[p_axis] = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT: {
m_angularDriveTorqueLimit[p_axis] = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_MAX:
+ case PS3DE::G6DOF_JOINT_MAX:
break; // Can't happen, but silences warning
}
}
-real_t GodotGeneric6DOFJoint3D::get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const {
+real_t GodotGeneric6DOFJoint3D::get_param(Vector3::Axis p_axis, PS3DE::G6DOFJointAxisParam p_param) const {
ERR_FAIL_INDEX_V(p_axis, 3, 0);
switch (p_param) {
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
return m_linearLimits.m_lowerLimit[p_axis];
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
return m_linearLimits.m_upperLimit[p_axis];
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
+ case PS3DE::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
return m_linearLimits.m_limitSoftness[p_axis];
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION: {
+ case PS3DE::G6DOF_JOINT_LINEAR_RESTITUTION: {
return m_linearLimits.m_restitution[p_axis];
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING: {
+ case PS3DE::G6DOF_JOINT_LINEAR_DAMPING: {
return m_linearLimits.m_damping[p_axis];
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
return m_angularLimits[p_axis].m_loLimit;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
return m_angularLimits[p_axis].m_hiLimit;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
return m_angularLimits[p_axis].m_limitSoftness;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_DAMPING: {
return m_angularLimits[p_axis].m_damping;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_RESTITUTION: {
return m_angularLimits[p_axis].m_bounce;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
return m_angularLimits[p_axis].m_maxLimitForce;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_ERP: {
return m_angularLimits[p_axis].m_ERP;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
return m_angularLimits[p_axis].m_targetVelocity;
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
return m_angularLimits[p_axis].m_maxMotorForce;
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
+ case PS3DE::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: {
+ case PS3DE::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING: {
+ case PS3DE::G6DOF_JOINT_LINEAR_SPRING_DAMPING: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT: {
return m_linearDriveForceLimit[p_axis];
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT: {
return m_angularDriveTorqueLimit[p_axis];
} break;
- case PhysicsServer3D::G6DOF_JOINT_MAX:
+ case PS3DE::G6DOF_JOINT_MAX:
break; // Can't happen, but silences warning
}
return 0;
}
-void GodotGeneric6DOFJoint3D::set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value) {
+void GodotGeneric6DOFJoint3D::set_flag(Vector3::Axis p_axis, PS3DE::G6DOFJointAxisFlag p_flag, bool p_value) {
ERR_FAIL_INDEX(p_axis, 3);
switch (p_flag) {
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
m_linearLimits.enable_limit[p_axis] = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
m_angularLimits[p_axis].m_enableLimit = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
m_angularLimits[p_axis].m_enableMotor = p_value;
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_MAX:
+ case PS3DE::G6DOF_JOINT_FLAG_MAX:
break; // Can't happen, but silences warning
}
}
-bool GodotGeneric6DOFJoint3D::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const {
+bool GodotGeneric6DOFJoint3D::get_flag(Vector3::Axis p_axis, PS3DE::G6DOFJointAxisFlag p_flag) const {
ERR_FAIL_INDEX_V(p_axis, 3, false);
switch (p_flag) {
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
return m_linearLimits.enable_limit[p_axis];
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
return m_angularLimits[p_axis].m_enableLimit;
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
return m_angularLimits[p_axis].m_enableMotor;
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: {
// Not implemented in GodotPhysics3D backend
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_MAX:
+ case PS3DE::G6DOF_JOINT_FLAG_MAX:
break; // Can't happen, but silences warning
}
diff --git a/modules/godot_physics_3d/joints/godot_generic_6dof_joint_3d.h b/modules/godot_physics_3d/joints/godot_generic_6dof_joint_3d.h
index ddebfb1019a..ef603ae49bc 100644
--- a/modules/godot_physics_3d/joints/godot_generic_6dof_joint_3d.h
+++ b/modules/godot_physics_3d/joints/godot_generic_6dof_joint_3d.h
@@ -205,7 +205,7 @@ protected:
public:
GodotGeneric6DOFJoint3D(GodotBody3D *rbA, GodotBody3D *rbB, const Transform3D &frameInA, const Transform3D &frameInB, bool useLinearReferenceFrameA);
- virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_6DOF; }
+ virtual PS3DE::JointType get_type() const override { return PS3DE::JOINT_TYPE_6DOF; }
virtual bool setup(real_t p_step) override;
virtual void solve(real_t p_step) override;
@@ -315,9 +315,9 @@ public:
virtual void calcAnchorPos(); // overridable
- void set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value);
- real_t get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const;
+ void set_param(Vector3::Axis p_axis, PS3DE::G6DOFJointAxisParam p_param, real_t p_value);
+ real_t get_param(Vector3::Axis p_axis, PS3DE::G6DOFJointAxisParam p_param) const;
- void set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value);
- bool get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const;
+ void set_flag(Vector3::Axis p_axis, PS3DE::G6DOFJointAxisFlag p_flag, bool p_value);
+ bool get_flag(Vector3::Axis p_axis, PS3DE::G6DOFJointAxisFlag p_flag) const;
};
diff --git a/modules/godot_physics_3d/joints/godot_hinge_joint_3d.cpp b/modules/godot_physics_3d/joints/godot_hinge_joint_3d.cpp
index 3d423f70e20..22f41f75f1f 100644
--- a/modules/godot_physics_3d/joints/godot_hinge_joint_3d.cpp
+++ b/modules/godot_physics_3d/joints/godot_hinge_joint_3d.cpp
@@ -107,8 +107,8 @@ GodotHingeJoint3D::GodotHingeJoint3D(GodotBody3D *rbA, GodotBody3D *rbB, const V
}
bool GodotHingeJoint3D::setup(real_t p_step) {
- dynamic_A = (A->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC);
- dynamic_B = (B->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC);
+ dynamic_A = (A->get_mode() > PS3DE::BODY_MODE_KINEMATIC);
+ dynamic_B = (B->get_mode() > PS3DE::BODY_MODE_KINEMATIC);
if (!dynamic_A && !dynamic_B) {
return false;
@@ -358,82 +358,82 @@ real_t GodotHingeJoint3D::get_hinge_angle() {
return atan2fast(swingAxis.dot(refAxis0), swingAxis.dot(refAxis1));
}
-void GodotHingeJoint3D::set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value) {
+void GodotHingeJoint3D::set_param(PS3DE::HingeJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer3D::HINGE_JOINT_BIAS:
+ case PS3DE::HINGE_JOINT_BIAS:
tau = p_value;
break;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER:
+ case PS3DE::HINGE_JOINT_LIMIT_UPPER:
m_upperLimit = p_value;
break;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER:
+ case PS3DE::HINGE_JOINT_LIMIT_LOWER:
m_lowerLimit = p_value;
break;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS:
+ case PS3DE::HINGE_JOINT_LIMIT_BIAS:
m_biasFactor = p_value;
break;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS:
+ case PS3DE::HINGE_JOINT_LIMIT_SOFTNESS:
m_limitSoftness = p_value;
break;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION:
+ case PS3DE::HINGE_JOINT_LIMIT_RELAXATION:
m_relaxationFactor = p_value;
break;
- case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY:
+ case PS3DE::HINGE_JOINT_MOTOR_TARGET_VELOCITY:
m_motorTargetVelocity = p_value;
break;
- case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE:
+ case PS3DE::HINGE_JOINT_MOTOR_MAX_IMPULSE:
m_maxMotorImpulse = p_value;
break;
- case PhysicsServer3D::HINGE_JOINT_MAX:
+ case PS3DE::HINGE_JOINT_MAX:
break; // Can't happen, but silences warning
}
}
-real_t GodotHingeJoint3D::get_param(PhysicsServer3D::HingeJointParam p_param) const {
+real_t GodotHingeJoint3D::get_param(PS3DE::HingeJointParam p_param) const {
switch (p_param) {
- case PhysicsServer3D::HINGE_JOINT_BIAS:
+ case PS3DE::HINGE_JOINT_BIAS:
return tau;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER:
+ case PS3DE::HINGE_JOINT_LIMIT_UPPER:
return m_upperLimit;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER:
+ case PS3DE::HINGE_JOINT_LIMIT_LOWER:
return m_lowerLimit;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS:
+ case PS3DE::HINGE_JOINT_LIMIT_BIAS:
return m_biasFactor;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS:
+ case PS3DE::HINGE_JOINT_LIMIT_SOFTNESS:
return m_limitSoftness;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION:
+ case PS3DE::HINGE_JOINT_LIMIT_RELAXATION:
return m_relaxationFactor;
- case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY:
+ case PS3DE::HINGE_JOINT_MOTOR_TARGET_VELOCITY:
return m_motorTargetVelocity;
- case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE:
+ case PS3DE::HINGE_JOINT_MOTOR_MAX_IMPULSE:
return m_maxMotorImpulse;
- case PhysicsServer3D::HINGE_JOINT_MAX:
+ case PS3DE::HINGE_JOINT_MAX:
break; // Can't happen, but silences warning
}
return 0;
}
-void GodotHingeJoint3D::set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value) {
+void GodotHingeJoint3D::set_flag(PS3DE::HingeJointFlag p_flag, bool p_value) {
switch (p_flag) {
- case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT:
+ case PS3DE::HINGE_JOINT_FLAG_USE_LIMIT:
m_useLimit = p_value;
break;
- case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR:
+ case PS3DE::HINGE_JOINT_FLAG_ENABLE_MOTOR:
m_enableAngularMotor = p_value;
break;
- case PhysicsServer3D::HINGE_JOINT_FLAG_MAX:
+ case PS3DE::HINGE_JOINT_FLAG_MAX:
break; // Can't happen, but silences warning
}
}
-bool GodotHingeJoint3D::get_flag(PhysicsServer3D::HingeJointFlag p_flag) const {
+bool GodotHingeJoint3D::get_flag(PS3DE::HingeJointFlag p_flag) const {
switch (p_flag) {
- case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT:
+ case PS3DE::HINGE_JOINT_FLAG_USE_LIMIT:
return m_useLimit;
- case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR:
+ case PS3DE::HINGE_JOINT_FLAG_ENABLE_MOTOR:
return m_enableAngularMotor;
- case PhysicsServer3D::HINGE_JOINT_FLAG_MAX:
+ case PS3DE::HINGE_JOINT_FLAG_MAX:
break; // Can't happen, but silences warning
}
diff --git a/modules/godot_physics_3d/joints/godot_hinge_joint_3d.h b/modules/godot_physics_3d/joints/godot_hinge_joint_3d.h
index 0eb0689c330..56e72d754eb 100644
--- a/modules/godot_physics_3d/joints/godot_hinge_joint_3d.h
+++ b/modules/godot_physics_3d/joints/godot_hinge_joint_3d.h
@@ -95,18 +95,18 @@ class GodotHingeJoint3D : public GodotJoint3D {
real_t m_appliedImpulse = 0.0;
public:
- virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_HINGE; }
+ virtual PS3DE::JointType get_type() const override { return PS3DE::JOINT_TYPE_HINGE; }
virtual bool setup(real_t p_step) override;
virtual void solve(real_t p_step) override;
real_t get_hinge_angle();
- void set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer3D::HingeJointParam p_param) const;
+ void set_param(PS3DE::HingeJointParam p_param, real_t p_value);
+ real_t get_param(PS3DE::HingeJointParam p_param) const;
- void set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value);
- bool get_flag(PhysicsServer3D::HingeJointFlag p_flag) const;
+ void set_flag(PS3DE::HingeJointFlag p_flag, bool p_value);
+ bool get_flag(PS3DE::HingeJointFlag p_flag) const;
GodotHingeJoint3D(GodotBody3D *rbA, GodotBody3D *rbB, const Transform3D &frameA, const Transform3D &frameB);
GodotHingeJoint3D(GodotBody3D *rbA, GodotBody3D *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB);
diff --git a/modules/godot_physics_3d/joints/godot_pin_joint_3d.cpp b/modules/godot_physics_3d/joints/godot_pin_joint_3d.cpp
index 304c05f59d5..e8e568ef051 100644
--- a/modules/godot_physics_3d/joints/godot_pin_joint_3d.cpp
+++ b/modules/godot_physics_3d/joints/godot_pin_joint_3d.cpp
@@ -50,8 +50,8 @@ subject to the following restrictions:
#include "godot_pin_joint_3d.h"
bool GodotPinJoint3D::setup(real_t p_step) {
- dynamic_A = (A->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC);
- dynamic_B = (B->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC);
+ dynamic_A = (A->get_mode() > PS3DE::BODY_MODE_KINEMATIC);
+ dynamic_B = (B->get_mode() > PS3DE::BODY_MODE_KINEMATIC);
if (!dynamic_A && !dynamic_B) {
return false;
@@ -139,27 +139,27 @@ void GodotPinJoint3D::solve(real_t p_step) {
}
}
-void GodotPinJoint3D::set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value) {
+void GodotPinJoint3D::set_param(PS3DE::PinJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer3D::PIN_JOINT_BIAS:
+ case PS3DE::PIN_JOINT_BIAS:
m_tau = p_value;
break;
- case PhysicsServer3D::PIN_JOINT_DAMPING:
+ case PS3DE::PIN_JOINT_DAMPING:
m_damping = p_value;
break;
- case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP:
+ case PS3DE::PIN_JOINT_IMPULSE_CLAMP:
m_impulseClamp = p_value;
break;
}
}
-real_t GodotPinJoint3D::get_param(PhysicsServer3D::PinJointParam p_param) const {
+real_t GodotPinJoint3D::get_param(PS3DE::PinJointParam p_param) const {
switch (p_param) {
- case PhysicsServer3D::PIN_JOINT_BIAS:
+ case PS3DE::PIN_JOINT_BIAS:
return m_tau;
- case PhysicsServer3D::PIN_JOINT_DAMPING:
+ case PS3DE::PIN_JOINT_DAMPING:
return m_damping;
- case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP:
+ case PS3DE::PIN_JOINT_IMPULSE_CLAMP:
return m_impulseClamp;
}
diff --git a/modules/godot_physics_3d/joints/godot_pin_joint_3d.h b/modules/godot_physics_3d/joints/godot_pin_joint_3d.h
index 69ce6138803..7f322427cd5 100644
--- a/modules/godot_physics_3d/joints/godot_pin_joint_3d.h
+++ b/modules/godot_physics_3d/joints/godot_pin_joint_3d.h
@@ -73,13 +73,13 @@ class GodotPinJoint3D : public GodotJoint3D {
Vector3 m_pivotInB;
public:
- virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_PIN; }
+ virtual PS3DE::JointType get_type() const override { return PS3DE::JOINT_TYPE_PIN; }
virtual bool setup(real_t p_step) override;
virtual void solve(real_t p_step) override;
- void set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer3D::PinJointParam p_param) const;
+ void set_param(PS3DE::PinJointParam p_param, real_t p_value);
+ real_t get_param(PS3DE::PinJointParam p_param) const;
void set_pos_a(const Vector3 &p_pos) { m_pivotInA = p_pos; }
void set_pos_b(const Vector3 &p_pos) { m_pivotInB = p_pos; }
diff --git a/modules/godot_physics_3d/joints/godot_slider_joint_3d.cpp b/modules/godot_physics_3d/joints/godot_slider_joint_3d.cpp
index b9dca94b377..1638de93ff5 100644
--- a/modules/godot_physics_3d/joints/godot_slider_joint_3d.cpp
+++ b/modules/godot_physics_3d/joints/godot_slider_joint_3d.cpp
@@ -71,8 +71,8 @@ GodotSliderJoint3D::GodotSliderJoint3D(GodotBody3D *rbA, GodotBody3D *rbB, const
//-----------------------------------------------------------------------------
bool GodotSliderJoint3D::setup(real_t p_step) {
- dynamic_A = (A->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC);
- dynamic_B = (B->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC);
+ dynamic_A = (A->get_mode() > PS3DE::BODY_MODE_KINEMATIC);
+ dynamic_B = (B->get_mode() > PS3DE::BODY_MODE_KINEMATIC);
if (!dynamic_A && !dynamic_B) {
return false;
@@ -347,130 +347,130 @@ Vector3 GodotSliderJoint3D::getAncorInB() {
return ancorInB;
}
-void GodotSliderJoint3D::set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value) {
+void GodotSliderJoint3D::set_param(PS3DE::SliderJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER:
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_UPPER:
m_upperLinLimit = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER:
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_LOWER:
m_lowerLinLimit = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS:
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS:
m_softnessLimLin = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION:
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION:
m_restitutionLimLin = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING:
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_DAMPING:
m_dampingLimLin = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS:
+ case PS3DE::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS:
m_softnessDirLin = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION:
+ case PS3DE::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION:
m_restitutionDirLin = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING:
+ case PS3DE::SLIDER_JOINT_LINEAR_MOTION_DAMPING:
m_dampingDirLin = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS:
+ case PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS:
m_softnessOrthoLin = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION:
+ case PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION:
m_restitutionOrthoLin = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING:
+ case PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING:
m_dampingOrthoLin = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER:
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_UPPER:
m_upperAngLimit = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER:
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_LOWER:
m_lowerAngLimit = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS:
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS:
m_softnessLimAng = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION:
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION:
m_restitutionLimAng = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING:
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING:
m_dampingLimAng = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS:
+ case PS3DE::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS:
m_softnessDirAng = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION:
+ case PS3DE::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION:
m_restitutionDirAng = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING:
+ case PS3DE::SLIDER_JOINT_ANGULAR_MOTION_DAMPING:
m_dampingDirAng = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS:
+ case PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS:
m_softnessOrthoAng = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION:
+ case PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION:
m_restitutionOrthoAng = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING:
+ case PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING:
m_dampingOrthoAng = p_value;
break;
- case PhysicsServer3D::SLIDER_JOINT_MAX:
+ case PS3DE::SLIDER_JOINT_MAX:
break; // Can't happen, but silences warning
}
}
-real_t GodotSliderJoint3D::get_param(PhysicsServer3D::SliderJointParam p_param) const {
+real_t GodotSliderJoint3D::get_param(PS3DE::SliderJointParam p_param) const {
switch (p_param) {
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER:
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_UPPER:
return m_upperLinLimit;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER:
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_LOWER:
return m_lowerLinLimit;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS:
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS:
return m_softnessLimLin;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION:
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION:
return m_restitutionLimLin;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING:
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_DAMPING:
return m_dampingLimLin;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS:
+ case PS3DE::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS:
return m_softnessDirLin;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION:
+ case PS3DE::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION:
return m_restitutionDirLin;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING:
+ case PS3DE::SLIDER_JOINT_LINEAR_MOTION_DAMPING:
return m_dampingDirLin;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS:
+ case PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS:
return m_softnessOrthoLin;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION:
+ case PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION:
return m_restitutionOrthoLin;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING:
+ case PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING:
return m_dampingOrthoLin;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER:
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_UPPER:
return m_upperAngLimit;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER:
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_LOWER:
return m_lowerAngLimit;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS:
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS:
return m_softnessLimAng;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION:
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION:
return m_restitutionLimAng;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING:
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING:
return m_dampingLimAng;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS:
+ case PS3DE::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS:
return m_softnessDirAng;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION:
+ case PS3DE::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION:
return m_restitutionDirAng;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING:
+ case PS3DE::SLIDER_JOINT_ANGULAR_MOTION_DAMPING:
return m_dampingDirAng;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS:
+ case PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS:
return m_softnessOrthoAng;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION:
+ case PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION:
return m_restitutionOrthoAng;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING:
+ case PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING:
return m_dampingOrthoAng;
- case PhysicsServer3D::SLIDER_JOINT_MAX:
+ case PS3DE::SLIDER_JOINT_MAX:
break; // Can't happen, but silences warning
}
diff --git a/modules/godot_physics_3d/joints/godot_slider_joint_3d.h b/modules/godot_physics_3d/joints/godot_slider_joint_3d.h
index d7ec86a8f75..24f3a6aa7b2 100644
--- a/modules/godot_physics_3d/joints/godot_slider_joint_3d.h
+++ b/modules/godot_physics_3d/joints/godot_slider_joint_3d.h
@@ -233,11 +233,11 @@ public:
Vector3 getAncorInA();
Vector3 getAncorInB();
- void set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer3D::SliderJointParam p_param) const;
+ void set_param(PS3DE::SliderJointParam p_param, real_t p_value);
+ real_t get_param(PS3DE::SliderJointParam p_param) const;
virtual bool setup(real_t p_step) override;
virtual void solve(real_t p_step) override;
- virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_SLIDER; }
+ virtual PS3DE::JointType get_type() const override { return PS3DE::JOINT_TYPE_SLIDER; }
};
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index c4ad64dce2d..9c2a07497e5 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -251,7 +251,7 @@ Array GridMap::get_collision_shapes() const {
for (const KeyValue<OctantKey, Octant *> &E : octant_map) {
Octant *g = E.value;
RID body = g->static_body;
- Transform3D body_xform = PhysicsServer3D::get_singleton()->body_get_state(body, PhysicsServer3D::BODY_STATE_TRANSFORM);
+ Transform3D body_xform = PhysicsServer3D::get_singleton()->body_get_state(body, PS3DE::BODY_STATE_TRANSFORM);
int nshapes = PhysicsServer3D::get_singleton()->body_get_shape_count(body);
for (int i = 0; i < nshapes; i++) {
RID shape = PhysicsServer3D::get_singleton()->body_get_shape(body, i);
@@ -549,14 +549,14 @@ void GridMap::set_cell_item(const Vector3i &p_position, int p_item, int p_rot) {
g->dirty = true;
#ifndef PHYSICS_3D_DISABLED
g->static_body = PhysicsServer3D::get_singleton()->body_create();
- PhysicsServer3D::get_singleton()->body_set_mode(g->static_body, PhysicsServer3D::BODY_MODE_STATIC);
+ PhysicsServer3D::get_singleton()->body_set_mode(g->static_body, PS3DE::BODY_MODE_STATIC);
PhysicsServer3D::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id());
PhysicsServer3D::get_singleton()->body_set_collision_layer(g->static_body, collision_layer);
PhysicsServer3D::get_singleton()->body_set_collision_mask(g->static_body, collision_mask);
PhysicsServer3D::get_singleton()->body_set_collision_priority(g->static_body, collision_priority);
if (physics_material.is_valid()) {
- PhysicsServer3D::get_singleton()->body_set_param(g->static_body, PhysicsServer3D::BODY_PARAM_FRICTION, physics_material->computed_friction());
- PhysicsServer3D::get_singleton()->body_set_param(g->static_body, PhysicsServer3D::BODY_PARAM_BOUNCE, physics_material->computed_bounce());
+ PhysicsServer3D::get_singleton()->body_set_param(g->static_body, PS3DE::BODY_PARAM_FRICTION, physics_material->computed_friction());
+ PhysicsServer3D::get_singleton()->body_set_param(g->static_body, PS3DE::BODY_PARAM_BOUNCE, physics_material->computed_bounce());
}
#endif // PHYSICS_3D_DISABLED
bool debug_collisions = false;
@@ -743,7 +743,7 @@ void GridMap::_octant_transform(const OctantKey &p_key) {
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
#ifndef PHYSICS_3D_DISABLED
- PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PS3DE::BODY_STATE_TRANSFORM, get_global_transform());
if (g.collision_debug_instance.is_valid()) {
RS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
@@ -1022,8 +1022,8 @@ void GridMap::_update_physics_bodies_characteristics() {
bounce = physics_material->computed_bounce();
}
for (const KeyValue<OctantKey, Octant *> &E : octant_map) {
- PhysicsServer3D::get_singleton()->body_set_param(E.value->static_body, PhysicsServer3D::BODY_PARAM_FRICTION, friction);
- PhysicsServer3D::get_singleton()->body_set_param(E.value->static_body, PhysicsServer3D::BODY_PARAM_BOUNCE, bounce);
+ PhysicsServer3D::get_singleton()->body_set_param(E.value->static_body, PS3DE::BODY_PARAM_FRICTION, friction);
+ PhysicsServer3D::get_singleton()->body_set_param(E.value->static_body, PS3DE::BODY_PARAM_BOUNCE, bounce);
}
}
#endif // PHYSICS_3D_DISABLED
@@ -1035,7 +1035,7 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
const RID scenario = get_world_3d()->get_scenario();
#ifndef PHYSICS_3D_DISABLED
- PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PS3DE::BODY_STATE_TRANSFORM, get_global_transform());
PhysicsServer3D::get_singleton()->body_set_space(g.static_body, get_world_3d()->get_space());
if (g.collision_debug_instance.is_valid()) {
@@ -1102,7 +1102,7 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
Octant &g = *octant_map[p_key];
#ifndef PHYSICS_3D_DISABLED
- PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PS3DE::BODY_STATE_TRANSFORM, get_global_transform());
PhysicsServer3D::get_singleton()->body_set_space(g.static_body, RID());
if (g.collision_debug_instance.is_valid()) {
@@ -1961,7 +1961,7 @@ void GridMap::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigat
if (body.is_null()) {
continue;
}
- const Transform3D body_xform = PhysicsServer3D::get_singleton()->body_get_state(body, PhysicsServer3D::BODY_STATE_TRANSFORM);
+ const Transform3D body_xform = PhysicsServer3D::get_singleton()->body_get_state(body, PS3DE::BODY_STATE_TRANSFORM);
int nshapes = PhysicsServer3D::get_singleton()->body_get_shape_count(body);
for (int i = 0; i < nshapes; i++) {
RID shape = PhysicsServer3D::get_singleton()->body_get_shape(body, i);
@@ -1977,25 +1977,25 @@ void GridMap::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigat
for (int i = 0; i < shapes.size(); i += 2) {
RID shape = shapes[i + 1];
- PhysicsServer3D::ShapeType type = PhysicsServer3D::get_singleton()->shape_get_type(shape);
+ PS3DE::ShapeType type = PhysicsServer3D::get_singleton()->shape_get_type(shape);
Variant data = PhysicsServer3D::get_singleton()->shape_get_data(shape);
switch (type) {
- case PhysicsServer3D::SHAPE_SPHERE: {
+ case PS3DE::SHAPE_SPHERE: {
real_t radius = data;
Array arr;
arr.resize(RSE::ARRAY_MAX);
SphereMesh::create_mesh_array(arr, radius, radius * 2.0);
p_source_geometry_data->add_mesh_array(arr, shapes[i]);
} break;
- case PhysicsServer3D::SHAPE_BOX: {
+ case PS3DE::SHAPE_BOX: {
Vector3 extents = data;
Array arr;
arr.resize(RSE::ARRAY_MAX);
BoxMesh::create_mesh_array(arr, extents * 2.0);
p_source_geometry_data->add_mesh_array(arr, shapes[i]);
} break;
- case PhysicsServer3D::SHAPE_CAPSULE: {
+ case PS3DE::SHAPE_CAPSULE: {
Dictionary dict = data;
real_t radius = dict["radius"];
real_t height = dict["height"];
@@ -2004,7 +2004,7 @@ void GridMap::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigat
CapsuleMesh::create_mesh_array(arr, radius, height);
p_source_geometry_data->add_mesh_array(arr, shapes[i]);
} break;
- case PhysicsServer3D::SHAPE_CYLINDER: {
+ case PS3DE::SHAPE_CYLINDER: {
Dictionary dict = data;
real_t radius = dict["radius"];
real_t height = dict["height"];
@@ -2013,7 +2013,7 @@ void GridMap::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigat
CylinderMesh::create_mesh_array(arr, radius, radius, height);
p_source_geometry_data->add_mesh_array(arr, shapes[i]);
} break;
- case PhysicsServer3D::SHAPE_CONVEX_POLYGON: {
+ case PS3DE::SHAPE_CONVEX_POLYGON: {
PackedVector3Array vertices = data;
Geometry3D::MeshData md;
@@ -2033,12 +2033,12 @@ void GridMap::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigat
p_source_geometry_data->add_faces(faces, shapes[i]);
}
} break;
- case PhysicsServer3D::SHAPE_CONCAVE_POLYGON: {
+ case PS3DE::SHAPE_CONCAVE_POLYGON: {
Dictionary dict = data;
PackedVector3Array faces = Variant(dict["faces"]);
p_source_geometry_data->add_faces(faces, shapes[i]);
} break;
- case PhysicsServer3D::SHAPE_HEIGHTMAP: {
+ case PS3DE::SHAPE_HEIGHTMAP: {
Dictionary dict = data;
///< dict( int:"width", int:"depth",float:"cell_size", float_array:"heights"
int heightmap_depth = dict["depth"];
diff --git a/modules/jolt_physics/joints/jolt_cone_twist_joint_3d.cpp b/modules/jolt_physics/joints/jolt_cone_twist_joint_3d.cpp
index eb4fc2b8fb2..be603fdb97d 100644
--- a/modules/jolt_physics/joints/jolt_cone_twist_joint_3d.cpp
+++ b/modules/jolt_physics/joints/jolt_cone_twist_joint_3d.cpp
@@ -158,21 +158,21 @@ JoltConeTwistJoint3D::JoltConeTwistJoint3D(const JoltJoint3D &p_old_joint, JoltB
rebuild();
}
-double JoltConeTwistJoint3D::get_param(PhysicsServer3D::ConeTwistJointParam p_param) const {
+double JoltConeTwistJoint3D::get_param(PS3DE::ConeTwistJointParam p_param) const {
switch (p_param) {
- case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: {
+ case PS3DE::CONE_TWIST_JOINT_SWING_SPAN: {
return swing_limit_span;
}
- case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: {
+ case PS3DE::CONE_TWIST_JOINT_TWIST_SPAN: {
return twist_limit_span;
}
- case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: {
+ case PS3DE::CONE_TWIST_JOINT_BIAS: {
return CONE_TWIST_DEFAULT_BIAS;
}
- case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: {
+ case PS3DE::CONE_TWIST_JOINT_SOFTNESS: {
return CONE_TWIST_DEFAULT_SOFTNESS;
}
- case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: {
+ case PS3DE::CONE_TWIST_JOINT_RELAXATION: {
return CONE_TWIST_DEFAULT_RELAXATION;
}
default: {
@@ -181,27 +181,27 @@ double JoltConeTwistJoint3D::get_param(PhysicsServer3D::ConeTwistJointParam p_pa
}
}
-void JoltConeTwistJoint3D::set_param(PhysicsServer3D::ConeTwistJointParam p_param, double p_value) {
+void JoltConeTwistJoint3D::set_param(PS3DE::ConeTwistJointParam p_param, double p_value) {
switch (p_param) {
- case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: {
+ case PS3DE::CONE_TWIST_JOINT_SWING_SPAN: {
swing_limit_span = p_value;
_limits_changed();
} break;
- case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: {
+ case PS3DE::CONE_TWIST_JOINT_TWIST_SPAN: {
twist_limit_span = p_value;
_limits_changed();
} break;
- case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: {
+ case PS3DE::CONE_TWIST_JOINT_BIAS: {
if (!Math::is_equal_approx(p_value, CONE_TWIST_DEFAULT_BIAS)) {
WARN_PRINT(vformat("Cone twist joint bias is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: {
+ case PS3DE::CONE_TWIST_JOINT_SOFTNESS: {
if (!Math::is_equal_approx(p_value, CONE_TWIST_DEFAULT_SOFTNESS)) {
WARN_PRINT(vformat("Cone twist joint softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: {
+ case PS3DE::CONE_TWIST_JOINT_RELAXATION: {
if (!Math::is_equal_approx(p_value, CONE_TWIST_DEFAULT_RELAXATION)) {
WARN_PRINT(vformat("Cone twist joint relaxation is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
diff --git a/modules/jolt_physics/joints/jolt_cone_twist_joint_3d.h b/modules/jolt_physics/joints/jolt_cone_twist_joint_3d.h
index df25f5f1fe2..127e3f6546a 100644
--- a/modules/jolt_physics/joints/jolt_cone_twist_joint_3d.h
+++ b/modules/jolt_physics/joints/jolt_cone_twist_joint_3d.h
@@ -38,7 +38,7 @@
#include <Jolt/Physics/Body/Body.h>
class JoltConeTwistJoint3D final : public JoltJoint3D {
- typedef PhysicsServer3D::ConeTwistJointParam Parameter;
+ typedef PS3DE::ConeTwistJointParam Parameter;
typedef JoltPhysicsServer3D::ConeTwistJointParamJolt JoltParameter;
typedef JoltPhysicsServer3D::ConeTwistJointFlagJolt JoltFlag;
@@ -76,10 +76,10 @@ class JoltConeTwistJoint3D final : public JoltJoint3D {
public:
JoltConeTwistJoint3D(const JoltJoint3D &p_old_joint, JoltBody3D *p_body_a, JoltBody3D *p_body_b, const Transform3D &p_local_ref_a, const Transform3D &p_local_ref_b);
- virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_CONE_TWIST; }
+ virtual PS3DE::JointType get_type() const override { return PS3DE::JOINT_TYPE_CONE_TWIST; }
- double get_param(PhysicsServer3D::ConeTwistJointParam p_param) const;
- void set_param(PhysicsServer3D::ConeTwistJointParam p_param, double p_value);
+ double get_param(PS3DE::ConeTwistJointParam p_param) const;
+ void set_param(PS3DE::ConeTwistJointParam p_param, double p_value);
double get_jolt_param(JoltParameter p_param) const;
void set_jolt_param(JoltParameter p_param, double p_value);
diff --git a/modules/jolt_physics/joints/jolt_generic_6dof_joint_3d.cpp b/modules/jolt_physics/joints/jolt_generic_6dof_joint_3d.cpp
index 755c65ea739..a89a595948c 100644
--- a/modules/jolt_physics/joints/jolt_generic_6dof_joint_3d.cpp
+++ b/modules/jolt_physics/joints/jolt_generic_6dof_joint_3d.cpp
@@ -279,76 +279,76 @@ double JoltGeneric6DOFJoint3D::get_param(Axis p_axis, Param p_param) const {
const int axis_ang = AXES_ANGULAR + (int)p_axis;
switch ((int)p_param) {
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
return limit_lower[axis_lin];
}
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
return limit_upper[axis_lin];
}
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
+ case PS3DE::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
return G6DOF_DEFAULT_LINEAR_LIMIT_SOFTNESS;
}
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION: {
+ case PS3DE::G6DOF_JOINT_LINEAR_RESTITUTION: {
return G6DOF_DEFAULT_LINEAR_RESTITUTION;
}
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING: {
+ case PS3DE::G6DOF_JOINT_LINEAR_DAMPING: {
return G6DOF_DEFAULT_LINEAR_DAMPING;
}
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
+ case PS3DE::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
return motor_speed[axis_lin];
}
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: {
return motor_limit[axis_lin];
}
- case JoltPhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: {
+ case PS3DE::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: { // JoltPhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS
return spring_stiffness[axis_lin];
}
- case JoltPhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING: {
+ case PS3DE::G6DOF_JOINT_LINEAR_SPRING_DAMPING: { // G6DOF_JOINT_LINEAR_SPRING_DAMPING::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS
return spring_damping[axis_lin];
}
- case JoltPhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: { // JoltPhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT
return spring_equilibrium[axis_lin];
}
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT: {
return drive_limit[axis_lin];
}
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
return limit_lower[axis_ang];
}
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
return limit_upper[axis_ang];
}
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
return G6DOF_DEFAULT_ANGULAR_LIMIT_SOFTNESS;
}
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_DAMPING: {
return G6DOF_DEFAULT_ANGULAR_DAMPING;
}
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_RESTITUTION: {
return G6DOF_DEFAULT_ANGULAR_RESTITUTION;
}
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
return G6DOF_DEFAULT_ANGULAR_FORCE_LIMIT;
}
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_ERP: {
return G6DOF_DEFAULT_ANGULAR_ERP;
}
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
return motor_speed[axis_ang];
}
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
return motor_limit[axis_ang];
}
- case JoltPhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: { // JoltPhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS
return spring_stiffness[axis_ang];
}
- case JoltPhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: { // JoltPhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING
return spring_damping[axis_ang];
}
- case JoltPhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: { // JoltPhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT
return spring_equilibrium[axis_ang];
}
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT: {
return drive_limit[axis_ang];
}
default: {
@@ -362,109 +362,109 @@ void JoltGeneric6DOFJoint3D::set_param(Axis p_axis, Param p_param, double p_valu
const int axis_ang = AXES_ANGULAR + (int)p_axis;
switch ((int)p_param) {
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
limit_lower[axis_lin] = p_value;
_limits_changed();
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
limit_upper[axis_lin] = p_value;
_limits_changed();
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
+ case PS3DE::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
if (!Math::is_equal_approx(p_value, G6DOF_DEFAULT_LINEAR_LIMIT_SOFTNESS)) {
WARN_PRINT(vformat("6DOF joint linear limit softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION: {
+ case PS3DE::G6DOF_JOINT_LINEAR_RESTITUTION: {
if (!Math::is_equal_approx(p_value, G6DOF_DEFAULT_LINEAR_RESTITUTION)) {
WARN_PRINT(vformat("6DOF joint linear restitution is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING: {
+ case PS3DE::G6DOF_JOINT_LINEAR_DAMPING: {
if (!Math::is_equal_approx(p_value, G6DOF_DEFAULT_LINEAR_DAMPING)) {
WARN_PRINT(vformat("6DOF joint linear damping is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
+ case PS3DE::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
motor_speed[axis_lin] = p_value;
_motor_speed_changed(axis_lin);
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: {
motor_limit[axis_lin] = p_value;
_motor_limit_changed(axis_lin);
} break;
- case JoltPhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: {
+ case PS3DE::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: { // JoltPhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS
spring_stiffness[axis_lin] = p_value;
_spring_parameters_changed(axis_lin);
} break;
- case JoltPhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING: {
+ case PS3DE::G6DOF_JOINT_LINEAR_SPRING_DAMPING: { // JoltPhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING
spring_damping[axis_lin] = p_value;
_spring_parameters_changed(axis_lin);
} break;
- case JoltPhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: { // JoltPhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT
spring_equilibrium[axis_lin] = p_value;
_spring_equilibrium_changed(axis_lin);
} break;
- case PhysicsServer3D::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT: {
drive_limit[axis_lin] = p_value;
drive_limit_set[axis_lin] = true;
_drive_limit_changed(axis_lin);
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
limit_lower[axis_ang] = p_value;
_limits_changed();
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
limit_upper[axis_ang] = p_value;
_limits_changed();
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
if (!Math::is_equal_approx(p_value, G6DOF_DEFAULT_ANGULAR_LIMIT_SOFTNESS)) {
WARN_PRINT(vformat("6DOF joint angular limit softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_DAMPING: {
if (!Math::is_equal_approx(p_value, G6DOF_DEFAULT_ANGULAR_DAMPING)) {
WARN_PRINT(vformat("6DOF joint angular damping is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_RESTITUTION: {
if (!Math::is_equal_approx(p_value, G6DOF_DEFAULT_ANGULAR_RESTITUTION)) {
WARN_PRINT(vformat("6DOF joint angular restitution is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
if (!Math::is_equal_approx(p_value, G6DOF_DEFAULT_ANGULAR_FORCE_LIMIT)) {
WARN_PRINT(vformat("6DOF joint angular force limit is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_ERP: {
if (!Math::is_equal_approx(p_value, G6DOF_DEFAULT_ANGULAR_ERP)) {
WARN_PRINT(vformat("6DOF joint angular ERP is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
motor_speed[axis_ang] = p_value;
_motor_speed_changed(axis_ang);
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
motor_limit[axis_ang] = p_value;
_motor_limit_changed(axis_ang);
} break;
- case JoltPhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: { // JoltPhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS
spring_stiffness[axis_ang] = p_value;
_spring_parameters_changed(axis_ang);
} break;
- case JoltPhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: { // JoltPhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING
spring_damping[axis_ang] = p_value;
_spring_parameters_changed(axis_ang);
} break;
- case JoltPhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: { // JoltPhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT
spring_equilibrium[axis_ang] = p_value;
has_angular_target_rotation = false;
_spring_equilibrium_changed(axis_ang);
} break;
- case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT: {
+ case PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT: {
drive_limit[axis_ang] = p_value;
drive_limit_set[axis_ang] = true;
_drive_limit_changed(axis_ang);
@@ -480,22 +480,22 @@ bool JoltGeneric6DOFJoint3D::get_flag(Axis p_axis, Flag p_flag) const {
const int axis_ang = AXES_ANGULAR + (int)p_axis;
switch ((int)p_flag) {
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
return limit_enabled[axis_lin];
}
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
return limit_enabled[axis_ang];
}
- case JoltPhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: { // JoltPhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING
return spring_enabled[axis_ang];
}
- case JoltPhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: { // JoltPhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING
return spring_enabled[axis_lin];
}
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
return motor_enabled[axis_ang];
}
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
return motor_enabled[axis_lin];
}
default: {
@@ -509,27 +509,27 @@ void JoltGeneric6DOFJoint3D::set_flag(Axis p_axis, Flag p_flag, bool p_enabled)
const int axis_ang = AXES_ANGULAR + (int)p_axis;
switch ((int)p_flag) {
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
limit_enabled[axis_lin] = p_enabled;
_limits_changed();
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
limit_enabled[axis_ang] = p_enabled;
_limits_changed();
} break;
- case JoltPhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: { // JoltPhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING
spring_enabled[axis_ang] = p_enabled;
_spring_state_changed(axis_ang);
} break;
- case JoltPhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: { // JoltPhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING
spring_enabled[axis_lin] = p_enabled;
_spring_state_changed(axis_lin);
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
motor_enabled[axis_ang] = p_enabled;
_motor_state_changed(axis_ang);
} break;
- case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
+ case PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
motor_enabled[axis_lin] = p_enabled;
_motor_state_changed(axis_lin);
} break;
diff --git a/modules/jolt_physics/joints/jolt_generic_6dof_joint_3d.h b/modules/jolt_physics/joints/jolt_generic_6dof_joint_3d.h
index 7c3194dec41..652162fc8a5 100644
--- a/modules/jolt_physics/joints/jolt_generic_6dof_joint_3d.h
+++ b/modules/jolt_physics/joints/jolt_generic_6dof_joint_3d.h
@@ -40,9 +40,9 @@
class JoltGeneric6DOFJoint3D final : public JoltJoint3D {
typedef Vector3::Axis Axis;
typedef JPH::SixDOFConstraintSettings::EAxis JoltAxis;
- typedef PhysicsServer3D::G6DOFJointAxisParam Param;
+ typedef PS3DE::G6DOFJointAxisParam Param;
typedef JoltPhysicsServer3D::G6DOFJointAxisParamJolt JoltParam;
- typedef PhysicsServer3D::G6DOFJointAxisFlag Flag;
+ typedef PS3DE::G6DOFJointAxisFlag Flag;
typedef JoltPhysicsServer3D::G6DOFJointAxisFlagJolt JoltFlag;
enum {
@@ -108,7 +108,7 @@ class JoltGeneric6DOFJoint3D final : public JoltJoint3D {
public:
JoltGeneric6DOFJoint3D(const JoltJoint3D &p_old_joint, JoltBody3D *p_body_a, JoltBody3D *p_body_b, const Transform3D &p_local_ref_a, const Transform3D &p_local_ref_b);
- virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_6DOF; }
+ virtual PS3DE::JointType get_type() const override { return PS3DE::JOINT_TYPE_6DOF; }
double get_param(Axis p_axis, Param p_param) const;
void set_param(Axis p_axis, Param p_param, double p_value);
diff --git a/modules/jolt_physics/joints/jolt_hinge_joint_3d.cpp b/modules/jolt_physics/joints/jolt_hinge_joint_3d.cpp
index 5ee7a2d44e4..eb14477e075 100644
--- a/modules/jolt_physics/joints/jolt_hinge_joint_3d.cpp
+++ b/modules/jolt_physics/joints/jolt_hinge_joint_3d.cpp
@@ -170,28 +170,28 @@ JoltHingeJoint3D::JoltHingeJoint3D(const JoltJoint3D &p_old_joint, JoltBody3D *p
double JoltHingeJoint3D::get_param(Parameter p_param) const {
switch (p_param) {
- case PhysicsServer3D::HINGE_JOINT_BIAS: {
+ case PS3DE::HINGE_JOINT_BIAS: {
return HINGE_DEFAULT_BIAS;
}
- case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER: {
+ case PS3DE::HINGE_JOINT_LIMIT_UPPER: {
return limit_upper;
}
- case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER: {
+ case PS3DE::HINGE_JOINT_LIMIT_LOWER: {
return limit_lower;
}
- case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS: {
+ case PS3DE::HINGE_JOINT_LIMIT_BIAS: {
return HINGE_DEFAULT_LIMIT_BIAS;
}
- case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS: {
+ case PS3DE::HINGE_JOINT_LIMIT_SOFTNESS: {
return HINGE_DEFAULT_SOFTNESS;
}
- case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION: {
+ case PS3DE::HINGE_JOINT_LIMIT_RELAXATION: {
return HINGE_DEFAULT_RELAXATION;
}
- case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY: {
+ case PS3DE::HINGE_JOINT_MOTOR_TARGET_VELOCITY: {
return motor_target_speed;
}
- case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE: {
+ case PS3DE::HINGE_JOINT_MOTOR_MAX_IMPULSE: {
// With Godot using max impulse instead of max torque we don't have much choice but to calculate this and hope the timestep doesn't change.
return motor_max_torque * estimate_physics_step();
}
@@ -203,39 +203,39 @@ double JoltHingeJoint3D::get_param(Parameter p_param) const {
void JoltHingeJoint3D::set_param(Parameter p_param, double p_value) {
switch (p_param) {
- case PhysicsServer3D::HINGE_JOINT_BIAS: {
+ case PS3DE::HINGE_JOINT_BIAS: {
if (!Math::is_equal_approx(p_value, HINGE_DEFAULT_BIAS)) {
WARN_PRINT(vformat("Hinge joint bias is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER: {
+ case PS3DE::HINGE_JOINT_LIMIT_UPPER: {
limit_upper = p_value;
_limits_changed();
} break;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER: {
+ case PS3DE::HINGE_JOINT_LIMIT_LOWER: {
limit_lower = p_value;
_limits_changed();
} break;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS: {
+ case PS3DE::HINGE_JOINT_LIMIT_BIAS: {
if (!Math::is_equal_approx(p_value, HINGE_DEFAULT_LIMIT_BIAS)) {
WARN_PRINT(vformat("Hinge joint bias limit is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS: {
+ case PS3DE::HINGE_JOINT_LIMIT_SOFTNESS: {
if (!Math::is_equal_approx(p_value, HINGE_DEFAULT_SOFTNESS)) {
WARN_PRINT(vformat("Hinge joint softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION: {
+ case PS3DE::HINGE_JOINT_LIMIT_RELAXATION: {
if (!Math::is_equal_approx(p_value, HINGE_DEFAULT_RELAXATION)) {
WARN_PRINT(vformat("Hinge joint relaxation is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY: {
+ case PS3DE::HINGE_JOINT_MOTOR_TARGET_VELOCITY: {
motor_target_speed = p_value;
_motor_speed_changed();
} break;
- case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE: {
+ case PS3DE::HINGE_JOINT_MOTOR_MAX_IMPULSE: {
// With Godot using max impulse instead of max torque we don't have much choice but to calculate this and hope the timestep doesn't change.
motor_max_torque = p_value / estimate_physics_step();
_motor_limit_changed();
@@ -285,10 +285,10 @@ void JoltHingeJoint3D::set_jolt_param(JoltParameter p_param, double p_value) {
bool JoltHingeJoint3D::get_flag(Flag p_flag) const {
switch (p_flag) {
- case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT: {
+ case PS3DE::HINGE_JOINT_FLAG_USE_LIMIT: {
return limits_enabled;
}
- case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR: {
+ case PS3DE::HINGE_JOINT_FLAG_ENABLE_MOTOR: {
return motor_enabled;
}
default: {
@@ -299,11 +299,11 @@ bool JoltHingeJoint3D::get_flag(Flag p_flag) const {
void JoltHingeJoint3D::set_flag(Flag p_flag, bool p_enabled) {
switch (p_flag) {
- case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT: {
+ case PS3DE::HINGE_JOINT_FLAG_USE_LIMIT: {
limits_enabled = p_enabled;
_limits_changed();
} break;
- case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR: {
+ case PS3DE::HINGE_JOINT_FLAG_ENABLE_MOTOR: {
motor_enabled = p_enabled;
_motor_state_changed();
} break;
diff --git a/modules/jolt_physics/joints/jolt_hinge_joint_3d.h b/modules/jolt_physics/joints/jolt_hinge_joint_3d.h
index cb8635bc932..9b58b4629a7 100644
--- a/modules/jolt_physics/joints/jolt_hinge_joint_3d.h
+++ b/modules/jolt_physics/joints/jolt_hinge_joint_3d.h
@@ -38,9 +38,9 @@
#include <Jolt/Physics/Constraints/SliderConstraint.h>
class JoltHingeJoint3D final : public JoltJoint3D {
- typedef PhysicsServer3D::HingeJointParam Parameter;
+ typedef PS3DE::HingeJointParam Parameter;
typedef JoltPhysicsServer3D::HingeJointParamJolt JoltParameter;
- typedef PhysicsServer3D::HingeJointFlag Flag;
+ typedef PS3DE::HingeJointFlag Flag;
typedef JoltPhysicsServer3D::HingeJointFlagJolt JoltFlag;
double limit_lower = 0.0;
@@ -76,7 +76,7 @@ class JoltHingeJoint3D final : public JoltJoint3D {
public:
JoltHingeJoint3D(const JoltJoint3D &p_old_joint, JoltBody3D *p_body_a, JoltBody3D *p_body_b, const Transform3D &p_local_ref_a, const Transform3D &p_local_ref_b);
- virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_HINGE; }
+ virtual PS3DE::JointType get_type() const override { return PS3DE::JOINT_TYPE_HINGE; }
double get_param(Parameter p_param) const;
void set_param(Parameter p_param, double p_value);
diff --git a/modules/jolt_physics/joints/jolt_joint_3d.h b/modules/jolt_physics/joints/jolt_joint_3d.h
index 6901edac19d..df801bc79eb 100644
--- a/modules/jolt_physics/joints/jolt_joint_3d.h
+++ b/modules/jolt_physics/joints/jolt_joint_3d.h
@@ -30,7 +30,9 @@
#pragma once
-#include "servers/physics_3d/physics_server_3d.h"
+#include "core/math/transform_3d.h"
+#include "core/templates/rid.h"
+#include "servers/physics_3d/physics_server_3d_enums.h"
#include <Jolt/Jolt.h>
@@ -78,7 +80,7 @@ public:
JoltJoint3D(const JoltJoint3D &p_old_joint, JoltBody3D *p_body_a, JoltBody3D *p_body_b, const Transform3D &p_local_ref_a, const Transform3D &p_local_ref_b);
virtual ~JoltJoint3D();
- virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_TYPE_MAX; }
+ virtual PS3DE::JointType get_type() const { return PS3DE::JOINT_TYPE_MAX; }
RID get_rid() const { return rid; }
void set_rid(const RID &p_rid) { rid = p_rid; }
diff --git a/modules/jolt_physics/joints/jolt_pin_joint_3d.cpp b/modules/jolt_physics/joints/jolt_pin_joint_3d.cpp
index 56a64f7645b..6f19495c361 100644
--- a/modules/jolt_physics/joints/jolt_pin_joint_3d.cpp
+++ b/modules/jolt_physics/joints/jolt_pin_joint_3d.cpp
@@ -79,15 +79,15 @@ void JoltPinJoint3D::set_local_b(const Vector3 &p_local_b) {
_points_changed();
}
-double JoltPinJoint3D::get_param(PhysicsServer3D::PinJointParam p_param) const {
+double JoltPinJoint3D::get_param(PS3DE::PinJointParam p_param) const {
switch (p_param) {
- case PhysicsServer3D::PIN_JOINT_BIAS: {
+ case PS3DE::PIN_JOINT_BIAS: {
return PIN_DEFAULT_BIAS;
}
- case PhysicsServer3D::PIN_JOINT_DAMPING: {
+ case PS3DE::PIN_JOINT_DAMPING: {
return PIN_DEFAULT_DAMPING;
}
- case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP: {
+ case PS3DE::PIN_JOINT_IMPULSE_CLAMP: {
return PIN_DEFAULT_IMPULSE_CLAMP;
}
default: {
@@ -96,19 +96,19 @@ double JoltPinJoint3D::get_param(PhysicsServer3D::PinJointParam p_param) const {
}
}
-void JoltPinJoint3D::set_param(PhysicsServer3D::PinJointParam p_param, double p_value) {
+void JoltPinJoint3D::set_param(PS3DE::PinJointParam p_param, double p_value) {
switch (p_param) {
- case PhysicsServer3D::PIN_JOINT_BIAS: {
+ case PS3DE::PIN_JOINT_BIAS: {
if (!Math::is_equal_approx(p_value, PIN_DEFAULT_BIAS)) {
WARN_PRINT(vformat("Pin joint bias is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::PIN_JOINT_DAMPING: {
+ case PS3DE::PIN_JOINT_DAMPING: {
if (!Math::is_equal_approx(p_value, PIN_DEFAULT_DAMPING)) {
WARN_PRINT(vformat("Pin joint damping is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP: {
+ case PS3DE::PIN_JOINT_IMPULSE_CLAMP: {
if (!Math::is_equal_approx(p_value, PIN_DEFAULT_IMPULSE_CLAMP)) {
WARN_PRINT(vformat("Pin joint impulse clamp is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
diff --git a/modules/jolt_physics/joints/jolt_pin_joint_3d.h b/modules/jolt_physics/joints/jolt_pin_joint_3d.h
index d81957fc864..23e88985d14 100644
--- a/modules/jolt_physics/joints/jolt_pin_joint_3d.h
+++ b/modules/jolt_physics/joints/jolt_pin_joint_3d.h
@@ -44,7 +44,7 @@ class JoltPinJoint3D final : public JoltJoint3D {
public:
JoltPinJoint3D(const JoltJoint3D &p_old_joint, JoltBody3D *p_body_a, JoltBody3D *p_body_b, const Vector3 &p_local_a, const Vector3 &p_local_b);
- virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_PIN; }
+ virtual PS3DE::JointType get_type() const override { return PS3DE::JOINT_TYPE_PIN; }
Vector3 get_local_a() const { return local_ref_a.origin; }
void set_local_a(const Vector3 &p_local_a);
@@ -52,8 +52,8 @@ public:
Vector3 get_local_b() const { return local_ref_b.origin; }
void set_local_b(const Vector3 &p_local_b);
- double get_param(PhysicsServer3D::PinJointParam p_param) const;
- void set_param(PhysicsServer3D::PinJointParam p_param, double p_value);
+ double get_param(PS3DE::PinJointParam p_param) const;
+ void set_param(PS3DE::PinJointParam p_param, double p_value);
float get_applied_force() const;
diff --git a/modules/jolt_physics/joints/jolt_slider_joint_3d.cpp b/modules/jolt_physics/joints/jolt_slider_joint_3d.cpp
index c535559593c..88aec7ca4aa 100644
--- a/modules/jolt_physics/joints/jolt_slider_joint_3d.cpp
+++ b/modules/jolt_physics/joints/jolt_slider_joint_3d.cpp
@@ -178,72 +178,72 @@ JoltSliderJoint3D::JoltSliderJoint3D(const JoltJoint3D &p_old_joint, JoltBody3D
rebuild();
}
-double JoltSliderJoint3D::get_param(PhysicsServer3D::SliderJointParam p_param) const {
+double JoltSliderJoint3D::get_param(PS3DE::SliderJointParam p_param) const {
switch (p_param) {
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER: {
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_UPPER: {
return limit_upper;
}
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER: {
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_LOWER: {
return limit_lower;
}
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: {
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: {
return SLIDER_DEFAULT_LINEAR_LIMIT_SOFTNESS;
}
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: {
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: {
return SLIDER_DEFAULT_LINEAR_LIMIT_RESTITUTION;
}
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: {
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: {
return SLIDER_DEFAULT_LINEAR_LIMIT_DAMPING;
}
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: {
+ case PS3DE::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: {
return SLIDER_DEFAULT_LINEAR_MOTION_SOFTNESS;
}
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: {
+ case PS3DE::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: {
return SLIDER_DEFAULT_LINEAR_MOTION_RESTITUTION;
}
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING: {
+ case PS3DE::SLIDER_JOINT_LINEAR_MOTION_DAMPING: {
return SLIDER_DEFAULT_LINEAR_MOTION_DAMPING;
}
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: {
+ case PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: {
return SLIDER_DEFAULT_LINEAR_ORTHO_SOFTNESS;
}
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: {
+ case PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: {
return SLIDER_DEFAULT_LINEAR_ORTHO_RESTITUTION;
}
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: {
+ case PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: {
return SLIDER_DEFAULT_LINEAR_ORTHO_DAMPING;
}
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: {
return SLIDER_DEFAULT_ANGULAR_LIMIT_UPPER;
}
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: {
return SLIDER_DEFAULT_ANGULAR_LIMIT_LOWER;
}
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: {
return SLIDER_DEFAULT_ANGULAR_LIMIT_SOFTNESS;
}
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: {
return SLIDER_DEFAULT_ANGULAR_LIMIT_RESTITUTION;
}
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: {
return SLIDER_DEFAULT_ANGULAR_LIMIT_DAMPING;
}
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: {
return SLIDER_DEFAULT_ANGULAR_MOTION_SOFTNESS;
}
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: {
return SLIDER_DEFAULT_ANGULAR_MOTION_RESTITUTION;
}
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: {
return SLIDER_DEFAULT_ANGULAR_MOTION_DAMPING;
}
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: {
return SLIDER_DEFAULT_ANGULAR_ORTHO_SOFTNESS;
}
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: {
return SLIDER_DEFAULT_ANGULAR_ORTHO_RESTITUTION;
}
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: {
return SLIDER_DEFAULT_ANGULAR_ORTHO_DAMPING;
}
default: {
@@ -252,112 +252,112 @@ double JoltSliderJoint3D::get_param(PhysicsServer3D::SliderJointParam p_param) c
}
}
-void JoltSliderJoint3D::set_param(PhysicsServer3D::SliderJointParam p_param, double p_value) {
+void JoltSliderJoint3D::set_param(PS3DE::SliderJointParam p_param, double p_value) {
switch (p_param) {
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER: {
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_UPPER: {
limit_upper = p_value;
_limits_changed();
} break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER: {
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_LOWER: {
limit_lower = p_value;
_limits_changed();
} break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: {
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_LINEAR_LIMIT_SOFTNESS)) {
WARN_PRINT(vformat("Slider joint linear limit softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: {
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_LINEAR_LIMIT_RESTITUTION)) {
WARN_PRINT(vformat("Slider joint linear limit restitution is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: {
+ case PS3DE::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_LINEAR_LIMIT_DAMPING)) {
WARN_PRINT(vformat("Slider joint linear limit damping is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: {
+ case PS3DE::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_LINEAR_MOTION_SOFTNESS)) {
WARN_PRINT(vformat("Slider joint linear motion softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: {
+ case PS3DE::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_LINEAR_MOTION_RESTITUTION)) {
WARN_PRINT(vformat("Slider joint linear motion restitution is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING: {
+ case PS3DE::SLIDER_JOINT_LINEAR_MOTION_DAMPING: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_LINEAR_MOTION_DAMPING)) {
WARN_PRINT(vformat("Slider joint linear motion damping is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: {
+ case PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_LINEAR_ORTHO_SOFTNESS)) {
WARN_PRINT(vformat("Slider joint linear ortho softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: {
+ case PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_LINEAR_ORTHO_RESTITUTION)) {
WARN_PRINT(vformat("Slider joint linear ortho restitution is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: {
+ case PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_LINEAR_ORTHO_DAMPING)) {
WARN_PRINT(vformat("Slider joint linear ortho damping is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_ANGULAR_LIMIT_UPPER)) {
WARN_PRINT(vformat("Slider joint angular limits are not supported when using Jolt Physics. Any such value will be ignored. Try using Generic6DOFJoint3D instead. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_ANGULAR_LIMIT_LOWER)) {
WARN_PRINT(vformat("Slider joint angular limits are not supported when using Jolt Physics. Any such value will be ignored. Try using Generic6DOFJoint3D instead. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_ANGULAR_LIMIT_SOFTNESS)) {
WARN_PRINT(vformat("Slider joint angular limit softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_ANGULAR_LIMIT_RESTITUTION)) {
WARN_PRINT(vformat("Slider joint angular limit restitution is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_ANGULAR_LIMIT_DAMPING)) {
WARN_PRINT(vformat("Slider joint angular limit damping is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_ANGULAR_MOTION_SOFTNESS)) {
WARN_PRINT(vformat("Slider joint angular motion softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_ANGULAR_MOTION_RESTITUTION)) {
WARN_PRINT(vformat("Slider joint angular motion restitution is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_ANGULAR_MOTION_DAMPING)) {
WARN_PRINT(vformat("Slider joint angular motion damping is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_ANGULAR_ORTHO_SOFTNESS)) {
WARN_PRINT(vformat("Slider joint angular ortho softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_ANGULAR_ORTHO_RESTITUTION)) {
WARN_PRINT(vformat("Slider joint angular ortho restitution is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
} break;
- case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: {
+ case PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: {
if (!Math::is_equal_approx(p_value, SLIDER_DEFAULT_ANGULAR_ORTHO_DAMPING)) {
WARN_PRINT(vformat("Slider joint angular ortho damping is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
}
diff --git a/modules/jolt_physics/joints/jolt_slider_joint_3d.h b/modules/jolt_physics/joints/jolt_slider_joint_3d.h
index 43e76f37d36..c11cfb5d651 100644
--- a/modules/jolt_physics/joints/jolt_slider_joint_3d.h
+++ b/modules/jolt_physics/joints/jolt_slider_joint_3d.h
@@ -38,7 +38,7 @@
#include <Jolt/Physics/Constraints/SliderConstraint.h>
class JoltSliderJoint3D final : public JoltJoint3D {
- typedef PhysicsServer3D::SliderJointParam Parameter;
+ typedef PS3DE::SliderJointParam Parameter;
typedef JoltPhysicsServer3D::SliderJointParamJolt JoltParameter;
typedef JoltPhysicsServer3D::SliderJointFlagJolt JoltFlag;
@@ -75,10 +75,10 @@ class JoltSliderJoint3D final : public JoltJoint3D {
public:
JoltSliderJoint3D(const JoltJoint3D &p_old_joint, JoltBody3D *p_body_a, JoltBody3D *p_body_b, const Transform3D &p_local_ref_a, const Transform3D &p_local_ref_b);
- virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_SLIDER; }
+ virtual PS3DE::JointType get_type() const override { return PS3DE::JOINT_TYPE_SLIDER; }
- double get_param(PhysicsServer3D::SliderJointParam p_param) const;
- void set_param(PhysicsServer3D::SliderJointParam p_param, double p_value);
+ double get_param(PS3DE::SliderJointParam p_param) const;
+ void set_param(PS3DE::SliderJointParam p_param, double p_value);
double get_jolt_param(JoltParameter p_param) const;
void set_jolt_param(JoltParameter p_param, double p_value);
diff --git a/modules/jolt_physics/jolt_physics_server_3d.cpp b/modules/jolt_physics/jolt_physics_server_3d.cpp
index c2460dc4f18..af097beb773 100644
--- a/modules/jolt_physics/jolt_physics_server_3d.cpp
+++ b/modules/jolt_physics/jolt_physics_server_3d.cpp
@@ -152,9 +152,9 @@ void JoltPhysicsServer3D::shape_set_custom_solver_bias(RID p_shape, real_t p_bia
shape->set_solver_bias((float)p_bias);
}
-PhysicsServer3D::ShapeType JoltPhysicsServer3D::shape_get_type(RID p_shape) const {
+PS3DE::ShapeType JoltPhysicsServer3D::shape_get_type(RID p_shape) const {
const JoltShape3D *shape = shape_owner.get_or_null(p_shape);
- ERR_FAIL_NULL_V(shape, SHAPE_CUSTOM);
+ ERR_FAIL_NULL_V(shape, PS3DE::SHAPE_CUSTOM);
return shape->get_type();
}
@@ -214,14 +214,14 @@ bool JoltPhysicsServer3D::space_is_active(RID p_space) const {
return active_spaces.has(space);
}
-void JoltPhysicsServer3D::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
+void JoltPhysicsServer3D::space_set_param(RID p_space, PS3DE::SpaceParameter p_param, real_t p_value) {
JoltSpace3D *space = space_owner.get_or_null(p_space);
ERR_FAIL_NULL(space);
space->set_param(p_param, (double)p_value);
}
-real_t JoltPhysicsServer3D::space_get_param(RID p_space, SpaceParameter p_param) const {
+real_t JoltPhysicsServer3D::space_get_param(RID p_space, PS3DE::SpaceParameter p_param) const {
const JoltSpace3D *space = space_owner.get_or_null(p_space);
ERR_FAIL_NULL_V(space, 0.0);
@@ -429,7 +429,7 @@ ObjectID JoltPhysicsServer3D::area_get_object_instance_id(RID p_area) const {
return area->get_instance_id();
}
-void JoltPhysicsServer3D::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
+void JoltPhysicsServer3D::area_set_param(RID p_area, PS3DE::AreaParameter p_param, const Variant &p_value) {
RID area_rid = p_area;
if (space_owner.owns(area_rid)) {
@@ -443,7 +443,7 @@ void JoltPhysicsServer3D::area_set_param(RID p_area, AreaParameter p_param, cons
area->set_param(p_param, p_value);
}
-Variant JoltPhysicsServer3D::area_get_param(RID p_area, AreaParameter p_param) const {
+Variant JoltPhysicsServer3D::area_get_param(RID p_area, PS3DE::AreaParameter p_param) const {
RID area_rid = p_area;
if (space_owner.owns(area_rid)) {
@@ -561,16 +561,16 @@ RID JoltPhysicsServer3D::body_get_space(RID p_body) const {
return space->get_rid();
}
-void JoltPhysicsServer3D::body_set_mode(RID p_body, BodyMode p_mode) {
+void JoltPhysicsServer3D::body_set_mode(RID p_body, PS3DE::BodyMode p_mode) {
JoltBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
body->set_mode(p_mode);
}
-PhysicsServer3D::BodyMode JoltPhysicsServer3D::body_get_mode(RID p_body) const {
+PS3DE::BodyMode JoltPhysicsServer3D::body_get_mode(RID p_body) const {
const JoltBody3D *body = body_owner.get_or_null(p_body);
- ERR_FAIL_NULL_V(body, BODY_MODE_STATIC);
+ ERR_FAIL_NULL_V(body, PS3DE::BODY_MODE_STATIC);
return body->get_mode();
}
@@ -728,14 +728,14 @@ uint32_t JoltPhysicsServer3D::body_get_user_flags(RID p_body) const {
return 0;
}
-void JoltPhysicsServer3D::body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) {
+void JoltPhysicsServer3D::body_set_param(RID p_body, PS3DE::BodyParameter p_param, const Variant &p_value) {
JoltBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
body->set_param(p_param, p_value);
}
-Variant JoltPhysicsServer3D::body_get_param(RID p_body, BodyParameter p_param) const {
+Variant JoltPhysicsServer3D::body_get_param(RID p_body, PS3DE::BodyParameter p_param) const {
const JoltBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, Variant());
@@ -749,14 +749,14 @@ void JoltPhysicsServer3D::body_reset_mass_properties(RID p_body) {
body->reset_mass_properties();
}
-void JoltPhysicsServer3D::body_set_state(RID p_body, BodyState p_state, const Variant &p_value) {
+void JoltPhysicsServer3D::body_set_state(RID p_body, PS3DE::BodyState p_state, const Variant &p_value) {
JoltBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
body->set_state(p_state, p_value);
}
-Variant JoltPhysicsServer3D::body_get_state(RID p_body, BodyState p_state) const {
+Variant JoltPhysicsServer3D::body_get_state(RID p_body, PS3DE::BodyState p_state) const {
JoltBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, Variant());
@@ -861,14 +861,14 @@ void JoltPhysicsServer3D::body_set_axis_velocity(RID p_body, const Vector3 &p_ax
body->set_axis_velocity(p_axis_velocity);
}
-void JoltPhysicsServer3D::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
+void JoltPhysicsServer3D::body_set_axis_lock(RID p_body, PS3DE::BodyAxis p_axis, bool p_lock) {
JoltBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
body->set_axis_lock(p_axis, p_lock);
}
-bool JoltPhysicsServer3D::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
+bool JoltPhysicsServer3D::body_is_axis_locked(RID p_body, PS3DE::BodyAxis p_axis) const {
const JoltBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, false);
@@ -955,7 +955,7 @@ void JoltPhysicsServer3D::body_set_ray_pickable(RID p_body, bool p_enable) {
body->set_pickable(p_enable);
}
-bool JoltPhysicsServer3D::body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result) {
+bool JoltPhysicsServer3D::body_test_motion(RID p_body, const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult *r_result) {
JoltBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, false);
@@ -1085,14 +1085,14 @@ void JoltPhysicsServer3D::soft_body_get_collision_exceptions(RID p_body, List<RI
}
}
-void JoltPhysicsServer3D::soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_value) {
+void JoltPhysicsServer3D::soft_body_set_state(RID p_body, PS3DE::BodyState p_state, const Variant &p_value) {
JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_NULL(body);
body->set_state(p_state, p_value);
}
-Variant JoltPhysicsServer3D::soft_body_get_state(RID p_body, BodyState p_state) const {
+Variant JoltPhysicsServer3D::soft_body_get_state(RID p_body, PS3DE::BodyState p_state) const {
JoltSoftBody3D *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, Variant());
@@ -1261,7 +1261,7 @@ void JoltPhysicsServer3D::joint_clear(RID p_joint) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- if (joint->get_type() != JOINT_TYPE_MAX) {
+ if (joint->get_type() != PS3DE::JOINT_TYPE_MAX) {
JoltJoint3D *empty_joint = memnew(JoltJoint3D);
empty_joint->set_rid(joint->get_rid());
@@ -1290,21 +1290,21 @@ void JoltPhysicsServer3D::joint_make_pin(RID p_joint, RID p_body_a, const Vector
joint_owner.replace(p_joint, new_joint);
}
-void JoltPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
+void JoltPhysicsServer3D::pin_joint_set_param(RID p_joint, PS3DE::PinJointParam p_param, real_t p_value) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_PIN);
JoltPinJoint3D *pin_joint = static_cast<JoltPinJoint3D *>(joint);
pin_joint->set_param(p_param, (double)p_value);
}
-real_t JoltPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
+real_t JoltPhysicsServer3D::pin_joint_get_param(RID p_joint, PS3DE::PinJointParam p_param) const {
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, 0.0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_PIN, 0.0);
const JoltPinJoint3D *pin_joint = static_cast<const JoltPinJoint3D *>(joint);
return (real_t)pin_joint->get_param(p_param);
@@ -1314,7 +1314,7 @@ void JoltPhysicsServer3D::pin_joint_set_local_a(RID p_joint, const Vector3 &p_lo
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_PIN);
JoltPinJoint3D *pin_joint = static_cast<JoltPinJoint3D *>(joint);
pin_joint->set_local_a(p_local_a);
@@ -1324,7 +1324,7 @@ Vector3 JoltPhysicsServer3D::pin_joint_get_local_a(RID p_joint) const {
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, Vector3());
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, Vector3());
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_PIN, Vector3());
const JoltPinJoint3D *pin_joint = static_cast<const JoltPinJoint3D *>(joint);
return pin_joint->get_local_a();
@@ -1334,7 +1334,7 @@ void JoltPhysicsServer3D::pin_joint_set_local_b(RID p_joint, const Vector3 &p_lo
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_PIN);
JoltPinJoint3D *pin_joint = static_cast<JoltPinJoint3D *>(joint);
pin_joint->set_local_b(p_local_b);
@@ -1344,7 +1344,7 @@ Vector3 JoltPhysicsServer3D::pin_joint_get_local_b(RID p_joint) const {
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, Vector3());
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, Vector3());
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_PIN, Vector3());
const JoltPinJoint3D *pin_joint = static_cast<const JoltPinJoint3D *>(joint);
return pin_joint->get_local_b();
@@ -1372,41 +1372,41 @@ void JoltPhysicsServer3D::joint_make_hinge_simple(RID p_joint, RID p_body_a, con
ERR_FAIL_MSG("Simple hinge joints are not supported when using Jolt Physics.");
}
-void JoltPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) {
+void JoltPhysicsServer3D::hinge_joint_set_param(RID p_joint, PS3DE::HingeJointParam p_param, real_t p_value) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_HINGE);
JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);
return hinge_joint->set_param(p_param, (double)p_value);
}
-real_t JoltPhysicsServer3D::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
+real_t JoltPhysicsServer3D::hinge_joint_get_param(RID p_joint, PS3DE::HingeJointParam p_param) const {
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, 0.0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_HINGE, 0.0);
const JoltHingeJoint3D *hinge_joint = static_cast<const JoltHingeJoint3D *>(joint);
return (real_t)hinge_joint->get_param(p_param);
}
-void JoltPhysicsServer3D::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_enabled) {
+void JoltPhysicsServer3D::hinge_joint_set_flag(RID p_joint, PS3DE::HingeJointFlag p_flag, bool p_enabled) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_HINGE);
JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);
return hinge_joint->set_flag(p_flag, p_enabled);
}
-bool JoltPhysicsServer3D::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
+bool JoltPhysicsServer3D::hinge_joint_get_flag(RID p_joint, PS3DE::HingeJointFlag p_flag) const {
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, false);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, false);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_HINGE, false);
const JoltHingeJoint3D *hinge_joint = static_cast<const JoltHingeJoint3D *>(joint);
return hinge_joint->get_flag(p_flag);
@@ -1430,21 +1430,21 @@ void JoltPhysicsServer3D::joint_make_slider(RID p_joint, RID p_body_a, const Tra
joint_owner.replace(p_joint, new_joint);
}
-void JoltPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) {
+void JoltPhysicsServer3D::slider_joint_set_param(RID p_joint, PS3DE::SliderJointParam p_param, real_t p_value) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_SLIDER);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_SLIDER);
JoltSliderJoint3D *slider_joint = static_cast<JoltSliderJoint3D *>(joint);
return slider_joint->set_param(p_param, (real_t)p_value);
}
-real_t JoltPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
+real_t JoltPhysicsServer3D::slider_joint_get_param(RID p_joint, PS3DE::SliderJointParam p_param) const {
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_SLIDER, 0.0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_SLIDER, 0.0);
const JoltSliderJoint3D *slider_joint = static_cast<const JoltSliderJoint3D *>(joint);
return slider_joint->get_param(p_param);
@@ -1468,21 +1468,21 @@ void JoltPhysicsServer3D::joint_make_cone_twist(RID p_joint, RID p_body_a, const
joint_owner.replace(p_joint, new_joint);
}
-void JoltPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) {
+void JoltPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, PS3DE::ConeTwistJointParam p_param, real_t p_value) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_CONE_TWIST);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_CONE_TWIST);
JoltConeTwistJoint3D *cone_twist_joint = static_cast<JoltConeTwistJoint3D *>(joint);
return cone_twist_joint->set_param(p_param, (double)p_value);
}
-real_t JoltPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
+real_t JoltPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, PS3DE::ConeTwistJointParam p_param) const {
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0.0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_CONE_TWIST, 0.0);
const JoltConeTwistJoint3D *cone_twist_joint = static_cast<const JoltConeTwistJoint3D *>(joint);
return (real_t)cone_twist_joint->get_param(p_param);
@@ -1506,41 +1506,41 @@ void JoltPhysicsServer3D::joint_make_generic_6dof(RID p_joint, RID p_body_a, con
joint_owner.replace(p_joint, new_joint);
}
-void JoltPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value) {
+void JoltPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, PS3DE::G6DOFJointAxisParam p_param, real_t p_value) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_6DOF);
JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);
return g6dof_joint->set_param(p_axis, p_param, (double)p_value);
}
-real_t JoltPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const {
+real_t JoltPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, PS3DE::G6DOFJointAxisParam p_param) const {
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, 0.0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_6DOF, 0.0);
const JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<const JoltGeneric6DOFJoint3D *>(joint);
return (real_t)g6dof_joint->get_param(p_axis, p_param);
}
-void JoltPhysicsServer3D::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_enable) {
+void JoltPhysicsServer3D::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, PS3DE::G6DOFJointAxisFlag p_flag, bool p_enable) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_6DOF);
JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);
return g6dof_joint->set_flag(p_axis, p_flag, p_enable);
}
-bool JoltPhysicsServer3D::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const {
+bool JoltPhysicsServer3D::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, PS3DE::G6DOFJointAxisFlag p_flag) const {
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, false);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, false);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_6DOF, false);
const JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<const JoltGeneric6DOFJoint3D *>(joint);
return g6dof_joint->get_flag(p_axis, p_flag);
@@ -1550,7 +1550,7 @@ void JoltPhysicsServer3D::generic_6dof_joint_set_angular_target_rotation(RID p_j
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_6DOF);
JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);
g6dof_joint->set_angular_target_rotation(p_target_rotation);
@@ -1560,15 +1560,15 @@ Quaternion JoltPhysicsServer3D::generic_6dof_joint_get_angular_target_rotation(R
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, Quaternion());
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, Quaternion());
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_6DOF, Quaternion());
const JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<const JoltGeneric6DOFJoint3D *>(joint);
return g6dof_joint->get_angular_target_rotation();
}
-PhysicsServer3D::JointType JoltPhysicsServer3D::joint_get_type(RID p_joint) const {
+PS3DE::JointType JoltPhysicsServer3D::joint_get_type(RID p_joint) const {
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
- ERR_FAIL_NULL_V(joint, JOINT_TYPE_PIN);
+ ERR_FAIL_NULL_V(joint, PS3DE::JOINT_TYPE_PIN);
return joint->get_type();
}
@@ -1684,7 +1684,7 @@ bool JoltPhysicsServer3D::is_flushing_queries() const {
return flushing_queries;
}
-int JoltPhysicsServer3D::get_process_info(ProcessInfo p_process_info) {
+int JoltPhysicsServer3D::get_process_info(PS3DE::ProcessInfo p_process_info) {
return 0;
}
@@ -1799,7 +1799,7 @@ float JoltPhysicsServer3D::pin_joint_get_applied_force(RID p_joint) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0f);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, 0.0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_PIN, 0.0);
JoltPinJoint3D *pin_joint = static_cast<JoltPinJoint3D *>(joint);
return pin_joint->get_applied_force();
@@ -1809,7 +1809,7 @@ double JoltPhysicsServer3D::hinge_joint_get_jolt_param(RID p_joint, HingeJointPa
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, 0.0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_HINGE, 0.0);
JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);
return hinge_joint->get_jolt_param(p_param);
@@ -1819,7 +1819,7 @@ void JoltPhysicsServer3D::hinge_joint_set_jolt_param(RID p_joint, HingeJointPara
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_HINGE);
JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);
return hinge_joint->set_jolt_param(p_param, p_value);
@@ -1829,7 +1829,7 @@ bool JoltPhysicsServer3D::hinge_joint_get_jolt_flag(RID p_joint, HingeJointFlagJ
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, false);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, false);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_HINGE, false);
const JoltHingeJoint3D *hinge_joint = static_cast<const JoltHingeJoint3D *>(joint);
return hinge_joint->get_jolt_flag(p_flag);
@@ -1839,7 +1839,7 @@ void JoltPhysicsServer3D::hinge_joint_set_jolt_flag(RID p_joint, HingeJointFlagJ
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_HINGE);
JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);
return hinge_joint->set_jolt_flag(p_flag, p_enabled);
@@ -1849,7 +1849,7 @@ float JoltPhysicsServer3D::hinge_joint_get_applied_force(RID p_joint) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0f);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, 0.0f);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_HINGE, 0.0f);
JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);
return hinge_joint->get_applied_force();
@@ -1859,7 +1859,7 @@ float JoltPhysicsServer3D::hinge_joint_get_applied_torque(RID p_joint) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0f);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, 0.0f);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_HINGE, 0.0f);
JoltHingeJoint3D *hinge_joint = static_cast<JoltHingeJoint3D *>(joint);
return hinge_joint->get_applied_torque();
@@ -1869,7 +1869,7 @@ double JoltPhysicsServer3D::slider_joint_get_jolt_param(RID p_joint, SliderJoint
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_SLIDER, 0.0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_SLIDER, 0.0);
JoltSliderJoint3D *slider_joint = static_cast<JoltSliderJoint3D *>(joint);
return slider_joint->get_jolt_param(p_param);
@@ -1879,7 +1879,7 @@ void JoltPhysicsServer3D::slider_joint_set_jolt_param(RID p_joint, SliderJointPa
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_SLIDER);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_SLIDER);
JoltSliderJoint3D *slider_joint = static_cast<JoltSliderJoint3D *>(joint);
return slider_joint->set_jolt_param(p_param, p_value);
@@ -1889,7 +1889,7 @@ bool JoltPhysicsServer3D::slider_joint_get_jolt_flag(RID p_joint, SliderJointFla
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, false);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_SLIDER, false);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_SLIDER, false);
const JoltSliderJoint3D *slider_joint = static_cast<const JoltSliderJoint3D *>(joint);
return slider_joint->get_jolt_flag(p_flag);
@@ -1899,7 +1899,7 @@ void JoltPhysicsServer3D::slider_joint_set_jolt_flag(RID p_joint, SliderJointFla
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_SLIDER);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_SLIDER);
JoltSliderJoint3D *slider_joint = static_cast<JoltSliderJoint3D *>(joint);
return slider_joint->set_jolt_flag(p_flag, p_enabled);
@@ -1909,7 +1909,7 @@ float JoltPhysicsServer3D::slider_joint_get_applied_force(RID p_joint) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0f);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_SLIDER, 0.0f);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_SLIDER, 0.0f);
JoltSliderJoint3D *slider_joint = static_cast<JoltSliderJoint3D *>(joint);
return slider_joint->get_applied_force();
@@ -1919,7 +1919,7 @@ float JoltPhysicsServer3D::slider_joint_get_applied_torque(RID p_joint) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0f);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_SLIDER, 0.0f);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_SLIDER, 0.0f);
JoltSliderJoint3D *slider_joint = static_cast<JoltSliderJoint3D *>(joint);
return slider_joint->get_applied_torque();
@@ -1929,7 +1929,7 @@ double JoltPhysicsServer3D::cone_twist_joint_get_jolt_param(RID p_joint, ConeTwi
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0.0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_CONE_TWIST, 0.0);
JoltConeTwistJoint3D *cone_twist_joint = static_cast<JoltConeTwistJoint3D *>(joint);
return cone_twist_joint->get_jolt_param(p_param);
@@ -1939,7 +1939,7 @@ void JoltPhysicsServer3D::cone_twist_joint_set_jolt_param(RID p_joint, ConeTwist
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_CONE_TWIST);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_CONE_TWIST);
JoltConeTwistJoint3D *cone_twist_joint = static_cast<JoltConeTwistJoint3D *>(joint);
return cone_twist_joint->set_jolt_param(p_param, p_value);
@@ -1949,7 +1949,7 @@ bool JoltPhysicsServer3D::cone_twist_joint_get_jolt_flag(RID p_joint, ConeTwistJ
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, false);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, false);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_CONE_TWIST, false);
const JoltConeTwistJoint3D *cone_twist_joint = static_cast<const JoltConeTwistJoint3D *>(joint);
return cone_twist_joint->get_jolt_flag(p_flag);
@@ -1959,7 +1959,7 @@ void JoltPhysicsServer3D::cone_twist_joint_set_jolt_flag(RID p_joint, ConeTwistJ
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_CONE_TWIST);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_CONE_TWIST);
JoltConeTwistJoint3D *cone_twist_joint = static_cast<JoltConeTwistJoint3D *>(joint);
return cone_twist_joint->set_jolt_flag(p_flag, p_enabled);
@@ -1969,7 +1969,7 @@ float JoltPhysicsServer3D::cone_twist_joint_get_applied_force(RID p_joint) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0f);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0.0f);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_CONE_TWIST, 0.0f);
JoltConeTwistJoint3D *cone_twist_joint = static_cast<JoltConeTwistJoint3D *>(joint);
return cone_twist_joint->get_applied_force();
@@ -1979,7 +1979,7 @@ float JoltPhysicsServer3D::cone_twist_joint_get_applied_torque(RID p_joint) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0f);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0.0f);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_CONE_TWIST, 0.0f);
JoltConeTwistJoint3D *cone_twist_joint = static_cast<JoltConeTwistJoint3D *>(joint);
return cone_twist_joint->get_applied_torque();
@@ -1989,7 +1989,7 @@ double JoltPhysicsServer3D::generic_6dof_joint_get_jolt_param(RID p_joint, Vecto
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, 0.0);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_6DOF, 0.0);
JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);
return g6dof_joint->get_jolt_param(p_axis, p_param);
@@ -1999,7 +1999,7 @@ void JoltPhysicsServer3D::generic_6dof_joint_set_jolt_param(RID p_joint, Vector3
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_6DOF);
JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);
return g6dof_joint->set_jolt_param(p_axis, p_param, p_value);
@@ -2009,7 +2009,7 @@ bool JoltPhysicsServer3D::generic_6dof_joint_get_jolt_flag(RID p_joint, Vector3:
const JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, false);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, false);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_6DOF, false);
const JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<const JoltGeneric6DOFJoint3D *>(joint);
return g6dof_joint->get_jolt_flag(p_axis, p_flag);
@@ -2019,7 +2019,7 @@ void JoltPhysicsServer3D::generic_6dof_joint_set_jolt_flag(RID p_joint, Vector3:
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
+ ERR_FAIL_COND(joint->get_type() != PS3DE::JOINT_TYPE_6DOF);
JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);
return g6dof_joint->set_jolt_flag(p_axis, p_flag, p_enabled);
@@ -2029,7 +2029,7 @@ float JoltPhysicsServer3D::generic_6dof_joint_get_applied_force(RID p_joint) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0f);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, 0.0f);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_6DOF, 0.0f);
JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);
return g6dof_joint->get_applied_force();
@@ -2039,7 +2039,7 @@ float JoltPhysicsServer3D::generic_6dof_joint_get_applied_torque(RID p_joint) {
JoltJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0.0f);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, 0.0f);
+ ERR_FAIL_COND_V(joint->get_type() != PS3DE::JOINT_TYPE_6DOF, 0.0f);
JoltGeneric6DOFJoint3D *g6dof_joint = static_cast<JoltGeneric6DOFJoint3D *>(joint);
return g6dof_joint->get_applied_torque();
diff --git a/modules/jolt_physics/jolt_physics_server_3d.h b/modules/jolt_physics/jolt_physics_server_3d.h
index 6aca5d68b5d..244de204d4d 100644
--- a/modules/jolt_physics/jolt_physics_server_3d.h
+++ b/modules/jolt_physics/jolt_physics_server_3d.h
@@ -144,7 +144,7 @@ public:
virtual void shape_set_margin(RID p_shape, real_t p_margin) override;
virtual real_t shape_get_margin(RID p_shape) const override;
- virtual PhysicsServer3D::ShapeType shape_get_type(RID p_shape) const override;
+ virtual PS3DE::ShapeType shape_get_type(RID p_shape) const override;
virtual real_t shape_get_custom_solver_bias(RID p_shape) const override;
@@ -153,8 +153,8 @@ public:
virtual void space_set_active(RID p_space, bool p_active) override;
virtual bool space_is_active(RID p_space) const override;
- virtual void space_set_param(RID p_space, PhysicsServer3D::SpaceParameter p_param, real_t p_value) override;
- virtual real_t space_get_param(RID p_space, PhysicsServer3D::SpaceParameter p_param) const override;
+ virtual void space_set_param(RID p_space, PS3DE::SpaceParameter p_param, real_t p_value) override;
+ virtual real_t space_get_param(RID p_space, PS3DE::SpaceParameter p_param) const override;
virtual PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space) override;
@@ -185,8 +185,8 @@ public:
virtual void area_attach_object_instance_id(RID p_area, ObjectID p_id) override;
virtual ObjectID area_get_object_instance_id(RID p_area) const override;
- virtual void area_set_param(RID p_area, PhysicsServer3D::AreaParameter p_param, const Variant &p_value) override;
- virtual Variant area_get_param(RID p_area, PhysicsServer3D::AreaParameter p_param) const override;
+ virtual void area_set_param(RID p_area, PS3DE::AreaParameter p_param, const Variant &p_value) override;
+ virtual Variant area_get_param(RID p_area, PS3DE::AreaParameter p_param) const override;
virtual void area_set_transform(RID p_area, const Transform3D &p_transform) override;
virtual Transform3D area_get_transform(RID p_area) const override;
@@ -209,8 +209,8 @@ public:
virtual void body_set_space(RID p_body, RID p_space) override;
virtual RID body_get_space(RID p_body) const override;
- virtual void body_set_mode(RID p_body, PhysicsServer3D::BodyMode p_mode) override;
- virtual PhysicsServer3D::BodyMode body_get_mode(RID p_body) const override;
+ virtual void body_set_mode(RID p_body, PS3DE::BodyMode p_mode) override;
+ virtual PS3DE::BodyMode body_get_mode(RID p_body) const override;
virtual void body_add_shape(RID p_body, RID p_shape, const Transform3D &p_transform, bool p_disabled) override;
@@ -245,13 +245,13 @@ public:
virtual void body_set_user_flags(RID p_body, uint32_t p_flags) override;
virtual uint32_t body_get_user_flags(RID p_body) const override;
- virtual void body_set_param(RID p_body, PhysicsServer3D::BodyParameter p_param, const Variant &p_value) override;
- virtual Variant body_get_param(RID p_body, PhysicsServer3D::BodyParameter p_param) const override;
+ virtual void body_set_param(RID p_body, PS3DE::BodyParameter p_param, const Variant &p_value) override;
+ virtual Variant body_get_param(RID p_body, PS3DE::BodyParameter p_param) const override;
virtual void body_reset_mass_properties(RID p_body) override;
- virtual void body_set_state(RID p_body, PhysicsServer3D::BodyState p_state, const Variant &p_value) override;
- virtual Variant body_get_state(RID p_body, PhysicsServer3D::BodyState p_state) const override;
+ virtual void body_set_state(RID p_body, PS3DE::BodyState p_state, const Variant &p_value) override;
+ virtual Variant body_get_state(RID p_body, PS3DE::BodyState p_state) const override;
virtual void body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) override;
virtual void body_apply_impulse(RID p_body, const Vector3 &p_impulse, const Vector3 &p_position) override;
@@ -273,8 +273,8 @@ public:
virtual void body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) override;
- virtual void body_set_axis_lock(RID p_body, PhysicsServer3D::BodyAxis p_axis, bool p_lock) override;
- virtual bool body_is_axis_locked(RID p_body, PhysicsServer3D::BodyAxis p_axis) const override;
+ virtual void body_set_axis_lock(RID p_body, PS3DE::BodyAxis p_axis, bool p_lock) override;
+ virtual bool body_is_axis_locked(RID p_body, PS3DE::BodyAxis p_axis) const override;
virtual void body_add_collision_exception(RID p_body, RID p_excepted_body) override;
virtual void body_remove_collision_exception(RID p_body, RID p_excepted_body) override;
@@ -294,7 +294,7 @@ public:
virtual void body_set_ray_pickable(RID p_body, bool p_enable) override;
- virtual bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result) override;
+ virtual bool body_test_motion(RID p_body, const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult *r_result) override;
virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) override;
@@ -317,8 +317,8 @@ public:
virtual void soft_body_remove_collision_exception(RID p_body, RID p_excepted_body) override;
virtual void soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) override;
- virtual void soft_body_set_state(RID p_body, PhysicsServer3D::BodyState p_state, const Variant &p_value) override;
- virtual Variant soft_body_get_state(RID p_body, PhysicsServer3D::BodyState p_state) const override;
+ virtual void soft_body_set_state(RID p_body, PS3DE::BodyState p_state, const Variant &p_value) override;
+ virtual Variant soft_body_get_state(RID p_body, PS3DE::BodyState p_state) const override;
virtual void soft_body_set_transform(RID p_body, const Transform3D &p_transform) override;
@@ -366,8 +366,8 @@ public:
virtual void joint_make_pin(RID p_joint, RID p_body_a, const Vector3 &p_local_a, RID p_body_b, const Vector3 &p_local_b) override;
- virtual void pin_joint_set_param(RID p_joint, PhysicsServer3D::PinJointParam p_param, real_t p_value) override;
- virtual real_t pin_joint_get_param(RID p_joint, PhysicsServer3D::PinJointParam p_param) const override;
+ virtual void pin_joint_set_param(RID p_joint, PS3DE::PinJointParam p_param, real_t p_value) override;
+ virtual real_t pin_joint_get_param(RID p_joint, PS3DE::PinJointParam p_param) const override;
virtual void pin_joint_set_local_a(RID p_joint, const Vector3 &p_local_a) override;
virtual Vector3 pin_joint_get_local_a(RID p_joint) const override;
@@ -379,34 +379,34 @@ public:
virtual void 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) override;
- virtual void hinge_joint_set_param(RID p_joint, PhysicsServer3D::HingeJointParam p_param, real_t p_value) override;
- virtual real_t hinge_joint_get_param(RID p_joint, PhysicsServer3D::HingeJointParam p_param) const override;
+ virtual void hinge_joint_set_param(RID p_joint, PS3DE::HingeJointParam p_param, real_t p_value) override;
+ virtual real_t hinge_joint_get_param(RID p_joint, PS3DE::HingeJointParam p_param) const override;
- virtual void hinge_joint_set_flag(RID p_joint, PhysicsServer3D::HingeJointFlag p_flag, bool p_enabled) override;
- virtual bool hinge_joint_get_flag(RID p_joint, PhysicsServer3D::HingeJointFlag p_flag) const override;
+ virtual void hinge_joint_set_flag(RID p_joint, PS3DE::HingeJointFlag p_flag, bool p_enabled) override;
+ virtual bool hinge_joint_get_flag(RID p_joint, PS3DE::HingeJointFlag p_flag) const override;
virtual void 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) override;
- virtual void slider_joint_set_param(RID p_joint, PhysicsServer3D::SliderJointParam p_param, real_t p_value) override;
- virtual real_t slider_joint_get_param(RID p_joint, PhysicsServer3D::SliderJointParam p_param) const override;
+ virtual void slider_joint_set_param(RID p_joint, PS3DE::SliderJointParam p_param, real_t p_value) override;
+ virtual real_t slider_joint_get_param(RID p_joint, PS3DE::SliderJointParam p_param) const override;
virtual void 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) override;
- virtual void cone_twist_joint_set_param(RID p_joint, PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value) override;
- virtual real_t cone_twist_joint_get_param(RID p_joint, PhysicsServer3D::ConeTwistJointParam p_param) const override;
+ virtual void cone_twist_joint_set_param(RID p_joint, PS3DE::ConeTwistJointParam p_param, real_t p_value) override;
+ virtual real_t cone_twist_joint_get_param(RID p_joint, PS3DE::ConeTwistJointParam p_param) const override;
virtual void 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) override;
- virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value) override;
- virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const override;
+ virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, PS3DE::G6DOFJointAxisParam p_param, real_t p_value) override;
+ virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, PS3DE::G6DOFJointAxisParam p_param) const override;
- virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_enable) override;
- virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const override;
+ virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, PS3DE::G6DOFJointAxisFlag p_flag, bool p_enable) override;
+ virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, PS3DE::G6DOFJointAxisFlag p_flag) const override;
virtual void generic_6dof_joint_set_angular_target_rotation(RID p_joint, const Quaternion &p_target_rotation) override;
virtual Quaternion generic_6dof_joint_get_angular_target_rotation(RID p_joint) const override;
- virtual PhysicsServer3D::JointType joint_get_type(RID p_joint) const override;
+ virtual PS3DE::JointType joint_get_type(RID p_joint) const override;
virtual void joint_set_solver_priority(RID p_joint, int p_priority) override;
virtual int joint_get_solver_priority(RID p_joint) const override;
@@ -429,7 +429,7 @@ public:
virtual void flush_queries() override;
virtual bool is_flushing_queries() const override;
- virtual int get_process_info(PhysicsServer3D::ProcessInfo p_process_info) override;
+ virtual int get_process_info(PS3DE::ProcessInfo p_process_info) override;
bool is_on_separate_thread() const { return on_separate_thread; }
bool is_active() const { return active; }
diff --git a/modules/jolt_physics/objects/jolt_area_3d.cpp b/modules/jolt_physics/objects/jolt_area_3d.cpp
index 558ba0c4e0b..9136a0cb7ec 100644
--- a/modules/jolt_physics/objects/jolt_area_3d.cpp
+++ b/modules/jolt_physics/objects/jolt_area_3d.cpp
@@ -142,7 +142,7 @@ void JoltArea3D::_flush_events(OverlapsById &p_objects, const Callable &p_callba
for (const ShapeIndexPair &shape_indices : overlap.pending_added) {
int &ref_count = overlap.ref_counts[shape_indices];
if (ref_count++ == 0) {
- _report_event(p_callback, PhysicsServer3D::AREA_BODY_ADDED, overlap.rid, overlap.instance_id, shape_indices.other, shape_indices.self);
+ _report_event(p_callback, PS3DE::AREA_BODY_ADDED, overlap.rid, overlap.instance_id, shape_indices.other, shape_indices.self);
}
}
@@ -150,7 +150,7 @@ void JoltArea3D::_flush_events(OverlapsById &p_objects, const Callable &p_callba
int &ref_count = overlap.ref_counts[shape_indices];
ERR_CONTINUE(ref_count <= 0);
if (--ref_count == 0) {
- _report_event(p_callback, PhysicsServer3D::AREA_BODY_REMOVED, overlap.rid, overlap.instance_id, shape_indices.other, shape_indices.self);
+ _report_event(p_callback, PS3DE::AREA_BODY_REMOVED, overlap.rid, overlap.instance_id, shape_indices.other, shape_indices.self);
overlap.ref_counts.erase(shape_indices);
}
}
@@ -170,7 +170,7 @@ void JoltArea3D::_flush_events(OverlapsById &p_objects, const Callable &p_callba
}
}
-void JoltArea3D::_report_event(const Callable &p_callback, PhysicsServer3D::AreaBodyStatus p_status, const RID &p_other_rid, ObjectID p_other_instance_id, int p_other_shape_index, int p_self_shape_index) const {
+void JoltArea3D::_report_event(const Callable &p_callback, PS3DE::AreaBodyStatus p_status, const RID &p_other_rid, ObjectID p_other_instance_id, int p_other_shape_index, int p_self_shape_index) const {
ERR_FAIL_COND(!p_callback.is_valid());
const Variant arg1 = p_status;
@@ -300,49 +300,49 @@ void JoltArea3D::set_transform(Transform3D p_transform) {
}
}
-Variant JoltArea3D::get_param(PhysicsServer3D::AreaParameter p_param) const {
+Variant JoltArea3D::get_param(PS3DE::AreaParameter p_param) const {
switch (p_param) {
- case PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE: {
+ case PS3DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE: {
return get_gravity_mode();
}
- case PhysicsServer3D::AREA_PARAM_GRAVITY: {
+ case PS3DE::AREA_PARAM_GRAVITY: {
return get_gravity();
}
- case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: {
+ case PS3DE::AREA_PARAM_GRAVITY_VECTOR: {
return get_gravity_vector();
}
- case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: {
+ case PS3DE::AREA_PARAM_GRAVITY_IS_POINT: {
return is_point_gravity();
}
- case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE: {
+ case PS3DE::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE: {
return get_point_gravity_distance();
}
- case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE: {
+ case PS3DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE: {
return get_linear_damp_mode();
}
- case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: {
+ case PS3DE::AREA_PARAM_LINEAR_DAMP: {
return get_linear_damp();
}
- case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE: {
+ case PS3DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE: {
return get_angular_damp_mode();
}
- case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: {
+ case PS3DE::AREA_PARAM_ANGULAR_DAMP: {
return get_angular_damp();
}
- case PhysicsServer3D::AREA_PARAM_PRIORITY: {
+ case PS3DE::AREA_PARAM_PRIORITY: {
return get_priority();
}
- case PhysicsServer3D::AREA_PARAM_WIND_FORCE_MAGNITUDE: {
+ case PS3DE::AREA_PARAM_WIND_FORCE_MAGNITUDE: {
// This parameter is named incorrectly. It's actually a pressure.
return get_wind_pressure();
}
- case PhysicsServer3D::AREA_PARAM_WIND_SOURCE: {
+ case PS3DE::AREA_PARAM_WIND_SOURCE: {
return get_wind_source();
}
- case PhysicsServer3D::AREA_PARAM_WIND_DIRECTION: {
+ case PS3DE::AREA_PARAM_WIND_DIRECTION: {
return get_wind_direction();
}
- case PhysicsServer3D::AREA_PARAM_WIND_ATTENUATION_FACTOR: {
+ case PS3DE::AREA_PARAM_WIND_ATTENUATION_FACTOR: {
return get_wind_attenuation_factor();
}
default: {
@@ -351,49 +351,49 @@ Variant JoltArea3D::get_param(PhysicsServer3D::AreaParameter p_param) const {
}
}
-void JoltArea3D::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) {
+void JoltArea3D::set_param(PS3DE::AreaParameter p_param, const Variant &p_value) {
switch (p_param) {
- case PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE: {
+ case PS3DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE: {
set_gravity_mode((OverrideMode)(int)p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_GRAVITY: {
+ case PS3DE::AREA_PARAM_GRAVITY: {
set_gravity(p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: {
+ case PS3DE::AREA_PARAM_GRAVITY_VECTOR: {
set_gravity_vector(p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: {
+ case PS3DE::AREA_PARAM_GRAVITY_IS_POINT: {
set_point_gravity(p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE: {
+ case PS3DE::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE: {
set_point_gravity_distance(p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE: {
+ case PS3DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE: {
set_linear_damp_mode((OverrideMode)(int)p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: {
+ case PS3DE::AREA_PARAM_LINEAR_DAMP: {
set_linear_damp(p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE: {
+ case PS3DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE: {
set_angular_damp_mode((OverrideMode)(int)p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: {
+ case PS3DE::AREA_PARAM_ANGULAR_DAMP: {
set_angular_damp(p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_PRIORITY: {
+ case PS3DE::AREA_PARAM_PRIORITY: {
set_priority(p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_WIND_FORCE_MAGNITUDE: {
+ case PS3DE::AREA_PARAM_WIND_FORCE_MAGNITUDE: {
// This parameter is named incorrectly. It's actually a pressure.
set_wind_pressure(p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_WIND_SOURCE: {
+ case PS3DE::AREA_PARAM_WIND_SOURCE: {
set_wind_source(p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_WIND_DIRECTION: {
+ case PS3DE::AREA_PARAM_WIND_DIRECTION: {
set_wind_direction(p_value);
} break;
- case PhysicsServer3D::AREA_PARAM_WIND_ATTENUATION_FACTOR: {
+ case PS3DE::AREA_PARAM_WIND_ATTENUATION_FACTOR: {
set_wind_attenuation_factor(p_value);
} break;
default: {
diff --git a/modules/jolt_physics/objects/jolt_area_3d.h b/modules/jolt_physics/objects/jolt_area_3d.h
index 7ffb5410647..acef0381722 100644
--- a/modules/jolt_physics/objects/jolt_area_3d.h
+++ b/modules/jolt_physics/objects/jolt_area_3d.h
@@ -32,14 +32,14 @@
#include "jolt_shaped_object_3d.h"
-#include "servers/physics_3d/physics_server_3d.h"
+#include "servers/physics_3d/physics_server_3d_enums.h"
class JoltBody3D;
class JoltSoftBody3D;
class JoltArea3D final : public JoltShapedObject3D {
public:
- typedef PhysicsServer3D::AreaSpaceOverrideMode OverrideMode;
+ typedef PS3DE::AreaSpaceOverrideMode OverrideMode;
private:
struct BodyIDHasher {
@@ -115,9 +115,9 @@ private:
float wind_pressure = 0.0f;
float wind_attenuation_factor = 0.0f;
- OverrideMode gravity_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
- OverrideMode linear_damp_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
- OverrideMode angular_damp_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
+ OverrideMode gravity_mode = PS3DE::AREA_SPACE_OVERRIDE_DISABLED;
+ OverrideMode linear_damp_mode = PS3DE::AREA_SPACE_OVERRIDE_DISABLED;
+ OverrideMode angular_damp_mode = PS3DE::AREA_SPACE_OVERRIDE_DISABLED;
bool monitorable = false;
bool point_gravity = false;
@@ -139,7 +139,7 @@ private:
void _flush_events(OverlapsById &p_objects, const Callable &p_callback);
- void _report_event(const Callable &p_callback, PhysicsServer3D::AreaBodyStatus p_status, const RID &p_other_rid, ObjectID p_other_instance_id, int p_other_shape_index, int p_self_shape_index) const;
+ void _report_event(const Callable &p_callback, PS3DE::AreaBodyStatus p_status, const RID &p_other_rid, ObjectID p_other_instance_id, int p_other_shape_index, int p_self_shape_index) const;
void _notify_body_entered(const JPH::BodyID &p_body_id);
void _notify_body_exited(const JPH::BodyID &p_body_id);
@@ -162,8 +162,8 @@ public:
void set_transform(Transform3D p_transform);
- Variant get_param(PhysicsServer3D::AreaParameter p_param) const;
- void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value);
+ Variant get_param(PS3DE::AreaParameter p_param) const;
+ void set_param(PS3DE::AreaParameter p_param, const Variant &p_value);
bool has_body_monitor_callback() const { return body_monitor_callback.is_valid(); }
void set_body_monitor_callback(const Callable &p_callback);
@@ -250,28 +250,28 @@ public:
// Incorporates the value provided by `p_getter` into `p_value` according to the override mode `p_mode`.
// Returns true if further calls to this function should stop (i.e. value has been replaced entirely).
template <typename TValue, typename TGetter>
- static bool apply_override(TValue &p_value, PhysicsServer3D::AreaSpaceOverrideMode p_mode, TGetter &&p_getter);
+ static bool apply_override(TValue &p_value, PS3DE::AreaSpaceOverrideMode p_mode, TGetter &&p_getter);
};
template <typename TValue, typename TGetter>
-inline bool JoltArea3D::apply_override(TValue &p_value, PhysicsServer3D::AreaSpaceOverrideMode p_mode, TGetter &&p_getter) {
+inline bool JoltArea3D::apply_override(TValue &p_value, PS3DE::AreaSpaceOverrideMode p_mode, TGetter &&p_getter) {
switch (p_mode) {
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED: {
+ case PS3DE::AREA_SPACE_OVERRIDE_DISABLED: {
return false;
}
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE: {
+ case PS3DE::AREA_SPACE_OVERRIDE_COMBINE: {
p_value += p_getter();
return false;
}
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
+ case PS3DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
p_value += p_getter();
return true;
}
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE: {
+ case PS3DE::AREA_SPACE_OVERRIDE_REPLACE: {
p_value = p_getter();
return true;
}
- case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
+ case PS3DE::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
p_value = p_getter();
return false;
}
diff --git a/modules/jolt_physics/objects/jolt_body_3d.cpp b/modules/jolt_physics/objects/jolt_body_3d.cpp
index 1b563c74fc3..31511f3c19c 100644
--- a/modules/jolt_physics/objects/jolt_body_3d.cpp
+++ b/modules/jolt_physics/objects/jolt_body_3d.cpp
@@ -42,14 +42,16 @@
#include "jolt_physics_direct_body_state_3d.h"
#include "jolt_soft_body_3d.h"
+#include "servers/physics_3d/physics_server_3d_constants.h"
+
JPH::BroadPhaseLayer JoltBody3D::_get_broad_phase_layer() const {
switch (mode) {
- case PhysicsServer3D::BODY_MODE_STATIC: {
+ case PS3DE::BODY_MODE_STATIC: {
return _is_big() ? JoltBroadPhaseLayer::BODY_STATIC_BIG : JoltBroadPhaseLayer::BODY_STATIC;
}
- case PhysicsServer3D::BODY_MODE_KINEMATIC:
- case PhysicsServer3D::BODY_MODE_RIGID:
- case PhysicsServer3D::BODY_MODE_RIGID_LINEAR: {
+ case PS3DE::BODY_MODE_KINEMATIC:
+ case PS3DE::BODY_MODE_RIGID:
+ case PS3DE::BODY_MODE_RIGID_LINEAR: {
return JoltBroadPhaseLayer::BODY_DYNAMIC;
}
default: {
@@ -71,14 +73,14 @@ JPH::ObjectLayer JoltBody3D::_get_object_layer() const {
JPH::EMotionType JoltBody3D::_get_motion_type() const {
switch (mode) {
- case PhysicsServer3D::BODY_MODE_STATIC: {
+ case PS3DE::BODY_MODE_STATIC: {
return JPH::EMotionType::Static;
}
- case PhysicsServer3D::BODY_MODE_KINEMATIC: {
+ case PS3DE::BODY_MODE_KINEMATIC: {
return JPH::EMotionType::Kinematic;
}
- case PhysicsServer3D::BODY_MODE_RIGID:
- case PhysicsServer3D::BODY_MODE_RIGID_LINEAR: {
+ case PS3DE::BODY_MODE_RIGID:
+ case PS3DE::BODY_MODE_RIGID_LINEAR: {
return JPH::EMotionType::Dynamic;
}
default: {
@@ -189,27 +191,27 @@ JPH::EAllowedDOFs JoltBody3D::_calculate_allowed_dofs() const {
JPH::EAllowedDOFs allowed_dofs = JPH::EAllowedDOFs::All;
- if (is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)) {
+ if (is_axis_locked(PS3DE::BODY_AXIS_LINEAR_X)) {
allowed_dofs &= ~JPH::EAllowedDOFs::TranslationX;
}
- if (is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)) {
+ if (is_axis_locked(PS3DE::BODY_AXIS_LINEAR_Y)) {
allowed_dofs &= ~JPH::EAllowedDOFs::TranslationY;
}
- if (is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z)) {
+ if (is_axis_locked(PS3DE::BODY_AXIS_LINEAR_Z)) {
allowed_dofs &= ~JPH::EAllowedDOFs::TranslationZ;
}
- if (is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_X) || is_rigid_linear()) {
+ if (is_axis_locked(PS3DE::BODY_AXIS_ANGULAR_X) || is_rigid_linear()) {
allowed_dofs &= ~JPH::EAllowedDOFs::RotationX;
}
- if (is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Y) || is_rigid_linear()) {
+ if (is_axis_locked(PS3DE::BODY_AXIS_ANGULAR_Y) || is_rigid_linear()) {
allowed_dofs &= ~JPH::EAllowedDOFs::RotationY;
}
- if (is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Z) || is_rigid_linear()) {
+ if (is_axis_locked(PS3DE::BODY_AXIS_ANGULAR_Z) || is_rigid_linear()) {
allowed_dofs &= ~JPH::EAllowedDOFs::RotationZ;
}
@@ -299,8 +301,8 @@ void JoltBody3D::_update_environmental_properties() {
const Vector3 position = to_godot(jolt_body->GetPosition());
bool gravity_done = false;
- bool linear_damp_done = linear_damp_mode == PhysicsServer3D::BODY_DAMP_MODE_REPLACE;
- bool angular_damp_done = angular_damp_mode == PhysicsServer3D::BODY_DAMP_MODE_REPLACE;
+ bool linear_damp_done = linear_damp_mode == PS3DE::BODY_DAMP_MODE_REPLACE;
+ bool angular_damp_done = angular_damp_mode == PS3DE::BODY_DAMP_MODE_REPLACE;
for (const JoltArea3D *area : areas) {
if (!gravity_done) {
@@ -341,19 +343,19 @@ void JoltBody3D::_update_environmental_properties() {
total_gravity *= jolt_body->GetMotionPropertiesUnchecked()->GetGravityFactor();
switch (linear_damp_mode) {
- case PhysicsServer3D::BODY_DAMP_MODE_COMBINE: {
+ case PS3DE::BODY_DAMP_MODE_COMBINE: {
total_linear_damp += linear_damp;
} break;
- case PhysicsServer3D::BODY_DAMP_MODE_REPLACE: {
+ case PS3DE::BODY_DAMP_MODE_REPLACE: {
total_linear_damp = linear_damp;
} break;
}
switch (angular_damp_mode) {
- case PhysicsServer3D::BODY_DAMP_MODE_COMBINE: {
+ case PS3DE::BODY_DAMP_MODE_COMBINE: {
total_angular_damp += angular_damp;
} break;
- case PhysicsServer3D::BODY_DAMP_MODE_REPLACE: {
+ case PS3DE::BODY_DAMP_MODE_REPLACE: {
total_angular_damp = angular_damp;
} break;
}
@@ -539,21 +541,21 @@ void JoltBody3D::set_transform(Transform3D p_transform) {
_transform_changed();
}
-Variant JoltBody3D::get_state(PhysicsServer3D::BodyState p_state) const {
+Variant JoltBody3D::get_state(PS3DE::BodyState p_state) const {
switch (p_state) {
- case PhysicsServer3D::BODY_STATE_TRANSFORM: {
+ case PS3DE::BODY_STATE_TRANSFORM: {
return get_transform_scaled();
}
- case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: {
+ case PS3DE::BODY_STATE_LINEAR_VELOCITY: {
return get_linear_velocity();
}
- case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: {
+ case PS3DE::BODY_STATE_ANGULAR_VELOCITY: {
return get_angular_velocity();
}
- case PhysicsServer3D::BODY_STATE_SLEEPING: {
+ case PS3DE::BODY_STATE_SLEEPING: {
return is_sleeping();
}
- case PhysicsServer3D::BODY_STATE_CAN_SLEEP: {
+ case PS3DE::BODY_STATE_CAN_SLEEP: {
return is_sleep_allowed();
}
default: {
@@ -562,21 +564,21 @@ Variant JoltBody3D::get_state(PhysicsServer3D::BodyState p_state) const {
}
}
-void JoltBody3D::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_value) {
+void JoltBody3D::set_state(PS3DE::BodyState p_state, const Variant &p_value) {
switch (p_state) {
- case PhysicsServer3D::BODY_STATE_TRANSFORM: {
+ case PS3DE::BODY_STATE_TRANSFORM: {
set_transform(p_value);
} break;
- case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: {
+ case PS3DE::BODY_STATE_LINEAR_VELOCITY: {
set_linear_velocity(p_value);
} break;
- case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: {
+ case PS3DE::BODY_STATE_ANGULAR_VELOCITY: {
set_angular_velocity(p_value);
} break;
- case PhysicsServer3D::BODY_STATE_SLEEPING: {
+ case PS3DE::BODY_STATE_SLEEPING: {
set_is_sleeping(p_value);
} break;
- case PhysicsServer3D::BODY_STATE_CAN_SLEEP: {
+ case PS3DE::BODY_STATE_CAN_SLEEP: {
set_is_sleep_allowed(p_value);
} break;
default: {
@@ -585,36 +587,36 @@ void JoltBody3D::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_
}
}
-Variant JoltBody3D::get_param(PhysicsServer3D::BodyParameter p_param) const {
+Variant JoltBody3D::get_param(PS3DE::BodyParameter p_param) const {
switch (p_param) {
- case PhysicsServer3D::BODY_PARAM_BOUNCE: {
+ case PS3DE::BODY_PARAM_BOUNCE: {
return get_bounce();
}
- case PhysicsServer3D::BODY_PARAM_FRICTION: {
+ case PS3DE::BODY_PARAM_FRICTION: {
return get_friction();
}
- case PhysicsServer3D::BODY_PARAM_MASS: {
+ case PS3DE::BODY_PARAM_MASS: {
return get_mass();
}
- case PhysicsServer3D::BODY_PARAM_INERTIA: {
+ case PS3DE::BODY_PARAM_INERTIA: {
return get_inertia();
}
- case PhysicsServer3D::BODY_PARAM_CENTER_OF_MASS: {
+ case PS3DE::BODY_PARAM_CENTER_OF_MASS: {
return get_center_of_mass_custom();
}
- case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: {
+ case PS3DE::BODY_PARAM_GRAVITY_SCALE: {
return get_gravity_scale();
}
- case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP_MODE: {
+ case PS3DE::BODY_PARAM_LINEAR_DAMP_MODE: {
return get_linear_damp_mode();
}
- case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP_MODE: {
+ case PS3DE::BODY_PARAM_ANGULAR_DAMP_MODE: {
return get_angular_damp_mode();
}
- case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: {
+ case PS3DE::BODY_PARAM_LINEAR_DAMP: {
return get_linear_damp();
}
- case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: {
+ case PS3DE::BODY_PARAM_ANGULAR_DAMP: {
return get_angular_damp();
}
default: {
@@ -623,36 +625,36 @@ Variant JoltBody3D::get_param(PhysicsServer3D::BodyParameter p_param) const {
}
}
-void JoltBody3D::set_param(PhysicsServer3D::BodyParameter p_param, const Variant &p_value) {
+void JoltBody3D::set_param(PS3DE::BodyParameter p_param, const Variant &p_value) {
switch (p_param) {
- case PhysicsServer3D::BODY_PARAM_BOUNCE: {
+ case PS3DE::BODY_PARAM_BOUNCE: {
set_bounce(p_value);
} break;
- case PhysicsServer3D::BODY_PARAM_FRICTION: {
+ case PS3DE::BODY_PARAM_FRICTION: {
set_friction(p_value);
} break;
- case PhysicsServer3D::BODY_PARAM_MASS: {
+ case PS3DE::BODY_PARAM_MASS: {
set_mass(p_value);
} break;
- case PhysicsServer3D::BODY_PARAM_INERTIA: {
+ case PS3DE::BODY_PARAM_INERTIA: {
set_inertia(p_value);
} break;
- case PhysicsServer3D::BODY_PARAM_CENTER_OF_MASS: {
+ case PS3DE::BODY_PARAM_CENTER_OF_MASS: {
set_center_of_mass_custom(p_value);
} break;
- case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: {
+ case PS3DE::BODY_PARAM_GRAVITY_SCALE: {
set_gravity_scale(p_value);
} break;
- case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP_MODE: {
+ case PS3DE::BODY_PARAM_LINEAR_DAMP_MODE: {
set_linear_damp_mode((DampMode)(int)p_value);
} break;
- case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP_MODE: {
+ case PS3DE::BODY_PARAM_ANGULAR_DAMP_MODE: {
set_angular_damp_mode((DampMode)(int)p_value);
} break;
- case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: {
+ case PS3DE::BODY_PARAM_LINEAR_DAMP: {
set_linear_damp(p_value);
} break;
- case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: {
+ case PS3DE::BODY_PARAM_ANGULAR_DAMP: {
set_angular_damp(p_value);
} break;
default: {
@@ -807,7 +809,7 @@ void JoltBody3D::set_center_of_mass_custom(const Vector3 &p_center_of_mass) {
}
void JoltBody3D::set_max_contacts_reported(int p_count) {
- ERR_FAIL_INDEX(p_count, MAX_CONTACTS_REPORTED_3D_MAX);
+ ERR_FAIL_INDEX(p_count, PS3DC::MAX_CONTACTS_REPORTED_3D_MAX);
if (unlikely((int)contacts.size() == p_count)) {
return;
@@ -1104,18 +1106,19 @@ void JoltBody3D::pre_step(float p_step) {
JoltObject3D::pre_step(p_step);
switch (mode) {
- case PhysicsServer3D::BODY_MODE_STATIC: {
+ case PS3DE::BODY_MODE_STATIC: {
// Will never happen.
} break;
- case PhysicsServer3D::BODY_MODE_RIGID:
- case PhysicsServer3D::BODY_MODE_RIGID_LINEAR: {
+ case PS3DE::BODY_MODE_RIGID:
+ case PS3DE::BODY_MODE_RIGID_LINEAR: {
if (_needs_update_environmental_properties()) {
_update_environmental_properties();
}
_integrate_forces(p_step);
} break;
- case PhysicsServer3D::BODY_MODE_KINEMATIC: {
+
+ case PS3DE::BODY_MODE_KINEMATIC: {
if (_needs_update_environmental_properties()) {
_update_environmental_properties();
}
@@ -1139,7 +1142,7 @@ JoltPhysicsDirectBodyState3D *JoltBody3D::get_direct_state() {
return direct_state;
}
-void JoltBody3D::set_mode(PhysicsServer3D::BodyMode p_mode) {
+void JoltBody3D::set_mode(PS3DE::BodyMode p_mode) {
if (p_mode == mode) {
return;
}
@@ -1299,11 +1302,11 @@ void JoltBody3D::set_angular_damp_mode(DampMode p_mode) {
_update_environmental_properties();
}
-bool JoltBody3D::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const {
+bool JoltBody3D::is_axis_locked(PS3DE::BodyAxis p_axis) const {
return (locked_axes & (uint32_t)p_axis) != 0;
}
-void JoltBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_enabled) {
+void JoltBody3D::set_axis_lock(PS3DE::BodyAxis p_axis, bool p_enabled) {
const uint32_t previous_locked_axes = locked_axes;
if (p_enabled) {
diff --git a/modules/jolt_physics/objects/jolt_body_3d.h b/modules/jolt_physics/objects/jolt_body_3d.h
index cb67b433ba4..fad4196a5c6 100644
--- a/modules/jolt_physics/objects/jolt_body_3d.h
+++ b/modules/jolt_physics/objects/jolt_body_3d.h
@@ -39,7 +39,7 @@ class JoltSoftBody3D;
class JoltBody3D final : public JoltShapedObject3D {
public:
- typedef PhysicsServer3D::BodyDampMode DampMode;
+ typedef PS3DE::BodyDampMode DampMode;
struct Contact {
Vector3 normal;
@@ -82,10 +82,10 @@ private:
JoltPhysicsDirectBodyState3D *direct_state = nullptr;
- PhysicsServer3D::BodyMode mode = PhysicsServer3D::BODY_MODE_RIGID;
+ PS3DE::BodyMode mode = PS3DE::BODY_MODE_RIGID;
- DampMode linear_damp_mode = PhysicsServer3D::BODY_DAMP_MODE_COMBINE;
- DampMode angular_damp_mode = PhysicsServer3D::BODY_DAMP_MODE_COMBINE;
+ DampMode linear_damp_mode = PS3DE::BODY_DAMP_MODE_COMBINE;
+ DampMode angular_damp_mode = PS3DE::BODY_DAMP_MODE_COMBINE;
float mass = 1.0f;
float linear_damp = 0.0f;
@@ -159,11 +159,11 @@ public:
void set_transform(Transform3D p_transform);
- Variant get_state(PhysicsServer3D::BodyState p_state) const;
- void set_state(PhysicsServer3D::BodyState p_state, const Variant &p_value);
+ Variant get_state(PS3DE::BodyState p_state) const;
+ void set_state(PS3DE::BodyState p_state, const Variant &p_value);
- Variant get_param(PhysicsServer3D::BodyParameter p_param) const;
- void set_param(PhysicsServer3D::BodyParameter p_param, const Variant &p_value);
+ Variant get_param(PS3DE::BodyParameter p_param) const;
+ void set_param(PS3DE::BodyParameter p_param, const Variant &p_value);
bool has_state_sync_callback() const { return state_sync_callback.is_valid(); }
void set_state_sync_callback(const Callable &p_callback) { state_sync_callback = p_callback; }
@@ -254,14 +254,14 @@ public:
JoltPhysicsDirectBodyState3D *get_direct_state();
- PhysicsServer3D::BodyMode get_mode() const { return mode; }
+ PS3DE::BodyMode get_mode() const { return mode; }
- void set_mode(PhysicsServer3D::BodyMode p_mode);
+ void set_mode(PS3DE::BodyMode p_mode);
- bool is_static() const { return mode == PhysicsServer3D::BODY_MODE_STATIC; }
- bool is_kinematic() const { return mode == PhysicsServer3D::BODY_MODE_KINEMATIC; }
- bool is_rigid_free() const { return mode == PhysicsServer3D::BODY_MODE_RIGID; }
- bool is_rigid_linear() const { return mode == PhysicsServer3D::BODY_MODE_RIGID_LINEAR; }
+ bool is_static() const { return mode == PS3DE::BODY_MODE_STATIC; }
+ bool is_kinematic() const { return mode == PS3DE::BODY_MODE_KINEMATIC; }
+ bool is_rigid_free() const { return mode == PS3DE::BODY_MODE_RIGID; }
+ bool is_rigid_linear() const { return mode == PS3DE::BODY_MODE_RIGID_LINEAR; }
bool is_rigid() const { return is_rigid_free() || is_rigid_linear(); }
bool is_ccd_enabled() const;
@@ -302,8 +302,8 @@ public:
DampMode get_angular_damp_mode() const { return angular_damp_mode; }
void set_angular_damp_mode(DampMode p_mode);
- bool is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const;
- void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_enabled);
+ bool is_axis_locked(PS3DE::BodyAxis p_axis) const;
+ void set_axis_lock(PS3DE::BodyAxis p_axis, bool p_enabled);
bool are_axes_locked() const { return locked_axes != 0; }
virtual bool can_interact_with(const JoltBody3D &p_other) const override;
diff --git a/modules/jolt_physics/objects/jolt_soft_body_3d.cpp b/modules/jolt_physics/objects/jolt_soft_body_3d.cpp
index b949b9c06d8..e00d1dea450 100644
--- a/modules/jolt_physics/objects/jolt_soft_body_3d.cpp
+++ b/modules/jolt_physics/objects/jolt_soft_body_3d.cpp
@@ -39,6 +39,7 @@
#include "jolt_group_filter.h"
#include "core/config/engine.h"
+#include "servers/physics_3d/physics_server_3d_rendering_server_handler.h"
#include "servers/rendering/rendering_server.h"
#include <Jolt/Physics/SoftBody/SoftBodyMotionProperties.h>
@@ -648,21 +649,21 @@ void JoltSoftBody3D::set_drag(float p_drag) {
// Drag is not a thing in Jolt, and not supported by Godot Physics either.
}
-Variant JoltSoftBody3D::get_state(PhysicsServer3D::BodyState p_state) const {
+Variant JoltSoftBody3D::get_state(PS3DE::BodyState p_state) const {
switch (p_state) {
- case PhysicsServer3D::BODY_STATE_TRANSFORM: {
+ case PS3DE::BODY_STATE_TRANSFORM: {
return get_transform();
}
- case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: {
+ case PS3DE::BODY_STATE_LINEAR_VELOCITY: {
ERR_FAIL_V_MSG(Variant(), "Linear velocity is not supported for soft bodies.");
}
- case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: {
+ case PS3DE::BODY_STATE_ANGULAR_VELOCITY: {
ERR_FAIL_V_MSG(Variant(), "Angular velocity is not supported for soft bodies.");
}
- case PhysicsServer3D::BODY_STATE_SLEEPING: {
+ case PS3DE::BODY_STATE_SLEEPING: {
return is_sleeping();
}
- case PhysicsServer3D::BODY_STATE_CAN_SLEEP: {
+ case PS3DE::BODY_STATE_CAN_SLEEP: {
return is_sleep_allowed();
}
default: {
@@ -671,21 +672,21 @@ Variant JoltSoftBody3D::get_state(PhysicsServer3D::BodyState p_state) const {
}
}
-void JoltSoftBody3D::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_value) {
+void JoltSoftBody3D::set_state(PS3DE::BodyState p_state, const Variant &p_value) {
switch (p_state) {
- case PhysicsServer3D::BODY_STATE_TRANSFORM: {
+ case PS3DE::BODY_STATE_TRANSFORM: {
set_transform(p_value);
} break;
- case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: {
+ case PS3DE::BODY_STATE_LINEAR_VELOCITY: {
ERR_FAIL_MSG("Linear velocity is not supported for soft bodies.");
} break;
- case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: {
+ case PS3DE::BODY_STATE_ANGULAR_VELOCITY: {
ERR_FAIL_MSG("Angular velocity is not supported for soft bodies.");
} break;
- case PhysicsServer3D::BODY_STATE_SLEEPING: {
+ case PS3DE::BODY_STATE_SLEEPING: {
set_is_sleeping(p_value);
} break;
- case PhysicsServer3D::BODY_STATE_CAN_SLEEP: {
+ case PS3DE::BODY_STATE_CAN_SLEEP: {
set_is_sleep_allowed(p_value);
} break;
default: {
diff --git a/modules/jolt_physics/objects/jolt_soft_body_3d.h b/modules/jolt_physics/objects/jolt_soft_body_3d.h
index d0db56453a7..3e91e651d12 100644
--- a/modules/jolt_physics/objects/jolt_soft_body_3d.h
+++ b/modules/jolt_physics/objects/jolt_soft_body_3d.h
@@ -32,7 +32,7 @@
#include "jolt_object_3d.h"
-#include "servers/physics_3d/physics_server_3d.h"
+#include "servers/physics_3d/physics_server_3d_enums.h"
#include <Jolt/Jolt.h>
@@ -41,6 +41,7 @@
class JoltArea3D;
class JoltSpace3D;
+class PhysicsServer3DRenderingServerHandler;
class JoltSoftBody3D final : public JoltObject3D {
HashSet<int> pinned_vertices;
@@ -152,8 +153,8 @@ public:
float get_drag() const;
void set_drag(float p_drag);
- Variant get_state(PhysicsServer3D::BodyState p_state) const;
- void set_state(PhysicsServer3D::BodyState p_state, const Variant &p_value);
+ Variant get_state(PS3DE::BodyState p_state) const;
+ void set_state(PS3DE::BodyState p_state, const Variant &p_value);
Transform3D get_transform() const;
void set_transform(const Transform3D &p_transform);
diff --git a/modules/jolt_physics/shapes/jolt_shape_3d.h b/modules/jolt_physics/shapes/jolt_shape_3d.h
index fd22748424c..8a6d9fb5606 100644
--- a/modules/jolt_physics/shapes/jolt_shape_3d.h
+++ b/modules/jolt_physics/shapes/jolt_shape_3d.h
@@ -30,7 +30,12 @@
#pragma once
-#include "servers/physics_3d/physics_server_3d.h"
+#include "core/math/aabb.h"
+#include "core/os/mutex.h"
+#include "core/templates/hash_map.h"
+#include "core/templates/rid.h"
+#include "core/variant/variant.h"
+#include "servers/physics_3d/physics_server_3d_enums.h"
#include <Jolt/Jolt.h>
@@ -50,7 +55,7 @@ protected:
String _owners_to_string() const;
public:
- typedef PhysicsServer3D::ShapeType ShapeType;
+ typedef PS3DE::ShapeType ShapeType;
virtual ~JoltShape3D() = 0;
diff --git a/modules/jolt_physics/spaces/jolt_physics_direct_space_state_3d.cpp b/modules/jolt_physics/spaces/jolt_physics_direct_space_state_3d.cpp
index fadfdb7b970..1da4772ea58 100644
--- a/modules/jolt_physics/spaces/jolt_physics_direct_space_state_3d.cpp
+++ b/modules/jolt_physics/spaces/jolt_physics_direct_space_state_3d.cpp
@@ -299,7 +299,7 @@ bool JoltPhysicsDirectSpaceState3D::_body_motion_cast(const JoltBody3D &p_body,
return collided;
}
-bool JoltPhysicsDirectSpaceState3D::_body_motion_collide(const JoltBody3D &p_body, const Transform3D &p_transform, const Vector3 &p_motion, float p_margin, int p_max_collisions, const HashSet<RID> &p_excluded_bodies, const HashSet<ObjectID> &p_excluded_objects, PhysicsServer3D::MotionResult *p_result) const {
+bool JoltPhysicsDirectSpaceState3D::_body_motion_collide(const JoltBody3D &p_body, const Transform3D &p_transform, const Vector3 &p_motion, float p_margin, int p_max_collisions, const HashSet<RID> &p_excluded_bodies, const HashSet<ObjectID> &p_excluded_objects, PS3DT::MotionResult *p_result) const {
if (p_max_collisions == 0) {
return false;
}
@@ -352,7 +352,7 @@ bool JoltPhysicsDirectSpaceState3D::_body_motion_collide(const JoltBody3D &p_bod
for (JPH::Vec3 contact_point : contact_points2) {
const Vector3 position = base_offset + to_godot(contact_point);
- PhysicsServer3D::MotionCollision &collision = p_result->collisions[count++];
+ PS3DT::MotionCollision &collision = p_result->collisions[count++];
collision.position = position;
collision.normal = normal;
@@ -448,7 +448,7 @@ JoltPhysicsDirectSpaceState3D::JoltPhysicsDirectSpaceState3D(JoltSpace3D *p_spac
space(p_space) {
}
-bool JoltPhysicsDirectSpaceState3D::intersect_ray(const RayParameters &p_parameters, RayResult &r_result) {
+bool JoltPhysicsDirectSpaceState3D::intersect_ray(const PS3DT::RayParameters &p_parameters, PS3DT::RayResult &r_result) {
ERR_FAIL_COND_V_MSG(space->is_stepping(), false, "intersect_ray must not be called while the physics space is being stepped.");
space->flush_pending_objects();
@@ -511,7 +511,7 @@ bool JoltPhysicsDirectSpaceState3D::intersect_ray(const RayParameters &p_paramet
return true;
}
-int JoltPhysicsDirectSpaceState3D::intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) {
+int JoltPhysicsDirectSpaceState3D::intersect_point(const PS3DT::PointParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) {
ERR_FAIL_COND_V_MSG(space->is_stepping(), false, "intersect_point must not be called while the physics space is being stepped.");
if (p_result_max == 0) {
@@ -531,7 +531,7 @@ int JoltPhysicsDirectSpaceState3D::intersect_point(const PointParameters &p_para
const JoltObject3D *object = space->try_get_object(hit.mBodyID);
ERR_FAIL_NULL_V(object, 0);
- ShapeResult &result = *r_results++;
+ PS3DT::ShapeResult &result = *r_results++;
result.shape = 0;
@@ -549,7 +549,7 @@ int JoltPhysicsDirectSpaceState3D::intersect_point(const PointParameters &p_para
return hit_count;
}
-int JoltPhysicsDirectSpaceState3D::intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) {
+int JoltPhysicsDirectSpaceState3D::intersect_shape(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) {
ERR_FAIL_COND_V_MSG(space->is_stepping(), false, "intersect_shape must not be called while the physics space is being stepped.");
if (p_result_max == 0) {
@@ -588,7 +588,7 @@ int JoltPhysicsDirectSpaceState3D::intersect_shape(const ShapeParameters &p_para
const JoltObject3D *object = space->try_get_object(hit.mBodyID2);
ERR_FAIL_NULL_V(object, 0);
- ShapeResult &result = *r_results++;
+ PS3DT::ShapeResult &result = *r_results++;
result.shape = 0;
@@ -606,7 +606,7 @@ int JoltPhysicsDirectSpaceState3D::intersect_shape(const ShapeParameters &p_para
return hit_count;
}
-bool JoltPhysicsDirectSpaceState3D::cast_motion(const ShapeParameters &p_parameters, real_t &r_closest_safe, real_t &r_closest_unsafe, ShapeRestInfo *r_info) {
+bool JoltPhysicsDirectSpaceState3D::cast_motion(const PS3DT::ShapeParameters &p_parameters, real_t &r_closest_safe, real_t &r_closest_unsafe, PS3DT::ShapeRestInfo *r_info) {
ERR_FAIL_COND_V_MSG(space->is_stepping(), false, "cast_motion must not be called while the physics space is being stepped.");
ERR_FAIL_COND_V_MSG(r_info != nullptr, false, "Providing rest info as part of cast_motion is not supported when using Jolt Physics.");
@@ -637,7 +637,7 @@ bool JoltPhysicsDirectSpaceState3D::cast_motion(const ShapeParameters &p_paramet
return true;
}
-bool JoltPhysicsDirectSpaceState3D::collide_shape(const ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) {
+bool JoltPhysicsDirectSpaceState3D::collide_shape(const PS3DT::ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) {
r_result_count = 0;
ERR_FAIL_COND_V_MSG(space->is_stepping(), false, "collide_shape must not be called while the physics space is being stepped.");
@@ -712,7 +712,7 @@ bool JoltPhysicsDirectSpaceState3D::collide_shape(const ShapeParameters &p_param
return true;
}
-bool JoltPhysicsDirectSpaceState3D::rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) {
+bool JoltPhysicsDirectSpaceState3D::rest_info(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeRestInfo *r_info) {
ERR_FAIL_COND_V_MSG(space->is_stepping(), false, "get_rest_info must not be called while the physics space is being stepped.");
space->flush_pending_objects();
@@ -845,7 +845,7 @@ Vector3 JoltPhysicsDirectSpaceState3D::get_closest_point_to_object_volume(RID p_
}
}
-bool JoltPhysicsDirectSpaceState3D::body_test_motion(const JoltBody3D &p_body, const PhysicsServer3D::MotionParameters &p_parameters, PhysicsServer3D::MotionResult *r_result) const {
+bool JoltPhysicsDirectSpaceState3D::body_test_motion(const JoltBody3D &p_body, const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult *r_result) const {
ERR_FAIL_COND_V_MSG(space->is_stepping(), false, "body_test_motion (maybe from move_and_slide?) must not be called while the physics space is being stepped.");
if (!p_body.in_space()) {
@@ -884,7 +884,7 @@ bool JoltPhysicsDirectSpaceState3D::body_test_motion(const JoltBody3D &p_body, c
}
if (collided) {
- const PhysicsServer3D::MotionCollision &deepest = r_result->collisions[0];
+ const PS3DT::MotionCollision &deepest = r_result->collisions[0];
r_result->travel = recovery + p_parameters.motion * safe_fraction;
r_result->remainder = p_parameters.motion - p_parameters.motion * safe_fraction;
diff --git a/modules/jolt_physics/spaces/jolt_physics_direct_space_state_3d.h b/modules/jolt_physics/spaces/jolt_physics_direct_space_state_3d.h
index f8738abaffd..bad81b83e4e 100644
--- a/modules/jolt_physics/spaces/jolt_physics_direct_space_state_3d.h
+++ b/modules/jolt_physics/spaces/jolt_physics_direct_space_state_3d.h
@@ -57,7 +57,7 @@ class JoltPhysicsDirectSpaceState3D final : public PhysicsDirectSpaceState3D {
bool _body_motion_recover(const JoltBody3D &p_body, const Transform3D &p_transform, float p_margin, const HashSet<RID> &p_excluded_bodies, const HashSet<ObjectID> &p_excluded_objects, Vector3 &r_recovery) const;
bool _body_motion_cast(const JoltBody3D &p_body, const Transform3D &p_transform, const Vector3 &p_scale, const Vector3 &p_motion, bool p_collide_separation_ray, const HashSet<RID> &p_excluded_bodies, const HashSet<ObjectID> &p_excluded_objects, real_t &r_safe_fraction, real_t &r_unsafe_fraction) const;
- bool _body_motion_collide(const JoltBody3D &p_body, const Transform3D &p_transform, const Vector3 &p_motion, float p_margin, int p_max_collisions, const HashSet<RID> &p_excluded_bodies, const HashSet<ObjectID> &p_excluded_objects, PhysicsServer3D::MotionResult *r_result) const;
+ bool _body_motion_collide(const JoltBody3D &p_body, const Transform3D &p_transform, const Vector3 &p_motion, float p_margin, int p_max_collisions, const HashSet<RID> &p_excluded_bodies, const HashSet<ObjectID> &p_excluded_objects, PS3DT::MotionResult *r_result) const;
int _try_get_face_index(const JPH::Body &p_body, const JPH::SubShapeID &p_sub_shape_id);
@@ -70,15 +70,15 @@ public:
JoltPhysicsDirectSpaceState3D() = default;
explicit JoltPhysicsDirectSpaceState3D(JoltSpace3D *p_space);
- virtual bool intersect_ray(const RayParameters &p_parameters, RayResult &r_result) override;
- virtual int intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) override;
- virtual int intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) override;
- virtual bool cast_motion(const ShapeParameters &p_parameters, real_t &r_closest_safe, real_t &r_closest_unsafe, ShapeRestInfo *r_info = nullptr) override;
- virtual bool collide_shape(const ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) override;
- virtual bool rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) override;
+ virtual bool intersect_ray(const PS3DT::RayParameters &p_parameters, PS3DT::RayResult &r_result) override;
+ virtual int intersect_point(const PS3DT::PointParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) override;
+ virtual int intersect_shape(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) override;
+ virtual bool cast_motion(const PS3DT::ShapeParameters &p_parameters, real_t &r_closest_safe, real_t &r_closest_unsafe, PS3DT::ShapeRestInfo *r_info = nullptr) override;
+ virtual bool collide_shape(const PS3DT::ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) override;
+ virtual bool rest_info(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeRestInfo *r_info) override;
virtual Vector3 get_closest_point_to_object_volume(RID p_object, Vector3 p_point) const override;
- bool body_test_motion(const JoltBody3D &p_body, const PhysicsServer3D::MotionParameters &p_parameters, PhysicsServer3D::MotionResult *r_result) const;
+ bool body_test_motion(const JoltBody3D &p_body, const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult *r_result) const;
JoltSpace3D &get_space() const { return *space; }
};
diff --git a/modules/jolt_physics/spaces/jolt_space_3d.cpp b/modules/jolt_physics/spaces/jolt_space_3d.cpp
index 88980589950..4242161bf9d 100644
--- a/modules/jolt_physics/spaces/jolt_space_3d.cpp
+++ b/modules/jolt_physics/spaces/jolt_space_3d.cpp
@@ -235,30 +235,30 @@ void JoltSpace3D::call_queries() {
}
}
-double JoltSpace3D::get_param(PhysicsServer3D::SpaceParameter p_param) const {
+double JoltSpace3D::get_param(PS3DE::SpaceParameter p_param) const {
switch (p_param) {
- case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: {
+ case PS3DE::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: {
return SPACE_DEFAULT_CONTACT_RECYCLE_RADIUS;
}
- case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION: {
+ case PS3DE::SPACE_PARAM_CONTACT_MAX_SEPARATION: {
return SPACE_DEFAULT_CONTACT_MAX_SEPARATION;
}
- case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION: {
+ case PS3DE::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION: {
return SPACE_DEFAULT_CONTACT_MAX_ALLOWED_PENETRATION;
}
- case PhysicsServer3D::SPACE_PARAM_CONTACT_DEFAULT_BIAS: {
+ case PS3DE::SPACE_PARAM_CONTACT_DEFAULT_BIAS: {
return SPACE_DEFAULT_CONTACT_DEFAULT_BIAS;
}
- case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: {
+ case PS3DE::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: {
return SPACE_DEFAULT_SLEEP_THRESHOLD_LINEAR;
}
- case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: {
+ case PS3DE::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: {
return SPACE_DEFAULT_SLEEP_THRESHOLD_ANGULAR;
}
- case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP: {
+ case PS3DE::SPACE_PARAM_BODY_TIME_TO_SLEEP: {
return JoltProjectSettings::sleep_time_threshold;
}
- case PhysicsServer3D::SPACE_PARAM_SOLVER_ITERATIONS: {
+ case PS3DE::SPACE_PARAM_SOLVER_ITERATIONS: {
return SPACE_DEFAULT_SOLVER_ITERATIONS;
}
default: {
@@ -267,30 +267,30 @@ double JoltSpace3D::get_param(PhysicsServer3D::SpaceParameter p_param) const {
}
}
-void JoltSpace3D::set_param(PhysicsServer3D::SpaceParameter p_param, double p_value) {
+void JoltSpace3D::set_param(PS3DE::SpaceParameter p_param, double p_value) {
switch (p_param) {
- case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: {
+ case PS3DE::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: {
WARN_PRINT("Space-specific contact recycle radius is not supported when using Jolt Physics. Any such value will be ignored.");
} break;
- case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION: {
+ case PS3DE::SPACE_PARAM_CONTACT_MAX_SEPARATION: {
WARN_PRINT("Space-specific contact max separation is not supported when using Jolt Physics. Any such value will be ignored.");
} break;
- case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION: {
+ case PS3DE::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION: {
WARN_PRINT("Space-specific contact max allowed penetration is not supported when using Jolt Physics. Any such value will be ignored.");
} break;
- case PhysicsServer3D::SPACE_PARAM_CONTACT_DEFAULT_BIAS: {
+ case PS3DE::SPACE_PARAM_CONTACT_DEFAULT_BIAS: {
WARN_PRINT("Space-specific contact default bias is not supported when using Jolt Physics. Any such value will be ignored.");
} break;
- case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: {
+ case PS3DE::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: {
WARN_PRINT("Space-specific linear velocity sleep threshold is not supported when using Jolt Physics. Any such value will be ignored.");
} break;
- case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: {
+ case PS3DE::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: {
WARN_PRINT("Space-specific angular velocity sleep threshold is not supported when using Jolt Physics. Any such value will be ignored.");
} break;
- case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP: {
+ case PS3DE::SPACE_PARAM_BODY_TIME_TO_SLEEP: {
WARN_PRINT("Space-specific body sleep time is not supported when using Jolt Physics. Any such value will be ignored.");
} break;
- case PhysicsServer3D::SPACE_PARAM_SOLVER_ITERATIONS: {
+ case PS3DE::SPACE_PARAM_SOLVER_ITERATIONS: {
WARN_PRINT("Space-specific solver iterations is not supported when using Jolt Physics. Any such value will be ignored.");
} break;
default: {
diff --git a/modules/jolt_physics/spaces/jolt_space_3d.h b/modules/jolt_physics/spaces/jolt_space_3d.h
index 7746c9f1001..1fa188e1074 100644
--- a/modules/jolt_physics/spaces/jolt_space_3d.h
+++ b/modules/jolt_physics/spaces/jolt_space_3d.h
@@ -30,7 +30,12 @@
#pragma once
-#include "servers/physics_3d/physics_server_3d.h"
+#include "core/os/mutex.h"
+#include "core/templates/local_vector.h"
+#include "core/templates/rid.h"
+#include "core/templates/self_list.h"
+#include "core/variant/variant.h"
+#include "servers/physics_3d/physics_server_3d_enums.h"
#include <Jolt/Jolt.h>
@@ -102,8 +107,8 @@ public:
bool is_stepping() const { return stepping; }
- double get_param(PhysicsServer3D::SpaceParameter p_param) const;
- void set_param(PhysicsServer3D::SpaceParameter p_param, double p_value);
+ double get_param(PS3DE::SpaceParameter p_param) const;
+ void set_param(PS3DE::SpaceParameter p_param, double p_value);
JPH::PhysicsSystem &get_physics_system() const { return *physics_system; }
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index 4a46caeb85a..28368b8e85f 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -40,6 +40,7 @@
#include "scene/resources/world_2d.h"
#include "servers/audio/audio_server.h"
#include "servers/audio/audio_stream.h"
+#include "servers/physics_2d/direct_states/physics_direct_space_state_2d.h"
#ifndef PHYSICS_2D_DISABLED
#include "scene/2d/physics/area_2d.h"
@@ -94,9 +95,9 @@ StringName AudioStreamPlayer2D::_get_actual_bus() {
PhysicsDirectSpaceState2D *space_state = PhysicsServer2D::get_singleton()->space_get_direct_state(world_2d->get_space());
ERR_FAIL_NULL_V(space_state, SceneStringName(Master));
- PhysicsDirectSpaceState2D::ShapeResult sr[MAX_INTERSECT_AREAS];
+ PS2DT::ShapeResult sr[MAX_INTERSECT_AREAS];
- PhysicsDirectSpaceState2D::PointParameters point_params;
+ PS2DT::PointParameters point_params;
point_params.position = global_pos;
point_params.collision_mask = area_mask;
point_params.collide_with_bodies = false;
diff --git a/scene/2d/physics/animatable_body_2d.cpp b/scene/2d/physics/animatable_body_2d.cpp
index ecbc5528e23..4395837f21e 100644
--- a/scene/2d/physics/animatable_body_2d.cpp
+++ b/scene/2d/physics/animatable_body_2d.cpp
@@ -33,6 +33,8 @@
#include "core/config/engine.h"
#include "core/object/callable_mp.h"
#include "core/object/class_db.h"
+#include "servers/physics_2d/direct_states/physics_direct_body_state_2d.h"
+#include "servers/physics_2d/physics_server_2d.h"
void AnimatableBody2D::set_sync_to_physics(bool p_enable) {
if (sync_to_physics == p_enable) {
@@ -93,7 +95,7 @@ void AnimatableBody2D::_notification(int p_what) {
// Used by sync to physics, send the new transform to the physics...
Transform2D new_transform = get_global_transform();
- PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_TRANSFORM, new_transform);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PS2DE::BODY_STATE_TRANSFORM, new_transform);
// ... but then revert changes.
set_notify_local_transform(false);
@@ -111,5 +113,5 @@ void AnimatableBody2D::_bind_methods() {
}
AnimatableBody2D::AnimatableBody2D() :
- StaticBody2D(PhysicsServer2D::BODY_MODE_KINEMATIC) {
+ StaticBody2D(PS2DE::BODY_MODE_KINEMATIC) {
}
diff --git a/scene/2d/physics/animatable_body_2d.h b/scene/2d/physics/animatable_body_2d.h
index 14e3d29a5a8..284c7f40ec1 100644
--- a/scene/2d/physics/animatable_body_2d.h
+++ b/scene/2d/physics/animatable_body_2d.h
@@ -32,6 +32,8 @@
#include "scene/2d/physics/static_body_2d.h"
+class PhysicsDirectBodyState2D;
+
class AnimatableBody2D : public StaticBody2D {
GDCLASS(AnimatableBody2D, StaticBody2D);
diff --git a/scene/2d/physics/area_2d.cpp b/scene/2d/physics/area_2d.cpp
index 9b514413731..d96ce29753d 100644
--- a/scene/2d/physics/area_2d.cpp
+++ b/scene/2d/physics/area_2d.cpp
@@ -34,10 +34,11 @@
#include "core/object/callable_mp.h"
#include "core/object/class_db.h"
#include "servers/audio/audio_server.h"
+#include "servers/physics_2d/physics_server_2d.h"
void Area2D::set_gravity_space_override_mode(SpaceOverride p_mode) {
gravity_space_override = p_mode;
- PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_OVERRIDE_MODE, p_mode);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PS2DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE, p_mode);
}
Area2D::SpaceOverride Area2D::get_gravity_space_override_mode() const {
@@ -46,7 +47,7 @@ Area2D::SpaceOverride Area2D::get_gravity_space_override_mode() const {
void Area2D::set_gravity_is_point(bool p_enabled) {
gravity_is_point = p_enabled;
- PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PS2DE::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
}
bool Area2D::is_gravity_a_point() const {
@@ -55,7 +56,7 @@ bool Area2D::is_gravity_a_point() const {
void Area2D::set_gravity_point_unit_distance(real_t p_scale) {
gravity_point_unit_distance = p_scale;
- PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE, p_scale);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PS2DE::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE, p_scale);
}
real_t Area2D::get_gravity_point_unit_distance() const {
@@ -64,7 +65,7 @@ real_t Area2D::get_gravity_point_unit_distance() const {
void Area2D::set_gravity_point_center(const Vector2 &p_center) {
gravity_vec = p_center;
- PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, p_center);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PS2DE::AREA_PARAM_GRAVITY_VECTOR, p_center);
}
const Vector2 &Area2D::get_gravity_point_center() const {
@@ -73,7 +74,7 @@ const Vector2 &Area2D::get_gravity_point_center() const {
void Area2D::set_gravity_direction(const Vector2 &p_direction) {
gravity_vec = p_direction;
- PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, p_direction);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PS2DE::AREA_PARAM_GRAVITY_VECTOR, p_direction);
}
const Vector2 &Area2D::get_gravity_direction() const {
@@ -82,7 +83,7 @@ const Vector2 &Area2D::get_gravity_direction() const {
void Area2D::set_gravity(real_t p_gravity) {
gravity = p_gravity;
- PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY, p_gravity);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PS2DE::AREA_PARAM_GRAVITY, p_gravity);
}
real_t Area2D::get_gravity() const {
@@ -91,7 +92,7 @@ real_t Area2D::get_gravity() const {
void Area2D::set_linear_damp_space_override_mode(SpaceOverride p_mode) {
linear_damp_space_override = p_mode;
- PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE, p_mode);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PS2DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE, p_mode);
}
Area2D::SpaceOverride Area2D::get_linear_damp_space_override_mode() const {
@@ -100,7 +101,7 @@ Area2D::SpaceOverride Area2D::get_linear_damp_space_override_mode() const {
void Area2D::set_angular_damp_space_override_mode(SpaceOverride p_mode) {
angular_damp_space_override = p_mode;
- PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE, p_mode);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PS2DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE, p_mode);
}
Area2D::SpaceOverride Area2D::get_angular_damp_space_override_mode() const {
@@ -109,7 +110,7 @@ Area2D::SpaceOverride Area2D::get_angular_damp_space_override_mode() const {
void Area2D::set_linear_damp(real_t p_linear_damp) {
linear_damp = p_linear_damp;
- PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PS2DE::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
}
real_t Area2D::get_linear_damp() const {
@@ -118,7 +119,7 @@ real_t Area2D::get_linear_damp() const {
void Area2D::set_angular_damp(real_t p_angular_damp) {
angular_damp = p_angular_damp;
- PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PS2DE::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
}
real_t Area2D::get_angular_damp() const {
@@ -127,7 +128,7 @@ real_t Area2D::get_angular_damp() const {
void Area2D::set_priority(int p_priority) {
priority = p_priority;
- PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_PRIORITY, p_priority);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PS2DE::AREA_PARAM_PRIORITY, p_priority);
}
int Area2D::get_priority() const {
@@ -165,7 +166,7 @@ void Area2D::_body_exit_tree(ObjectID p_id) {
}
void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape) {
- bool body_in = p_status == PhysicsServer2D::AREA_BODY_ADDED;
+ bool body_in = p_status == PS2DE::AREA_BODY_ADDED;
ObjectID objid = p_instance;
// Exit early if instance is invalid.
@@ -276,7 +277,7 @@ void Area2D::_area_exit_tree(ObjectID p_id) {
}
void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int p_area_shape, int p_self_shape) {
- bool area_in = p_status == PhysicsServer2D::AREA_BODY_ADDED;
+ bool area_in = p_status == PS2DE::AREA_BODY_ADDED;
ObjectID objid = p_instance;
// Exit early if instance is invalid.
diff --git a/scene/2d/physics/character_body_2d.cpp b/scene/2d/physics/character_body_2d.cpp
index c70acc5a60f..f99c3f3b225 100644
--- a/scene/2d/physics/character_body_2d.cpp
+++ b/scene/2d/physics/character_body_2d.cpp
@@ -32,6 +32,7 @@
#include "core/config/engine.h"
#include "core/object/class_db.h"
+#include "servers/physics_2d/direct_states/physics_direct_body_state_2d.h"
#ifndef DISABLE_DEPRECATED
#include "servers/physics_2d/physics_server_2d_extension.h"
@@ -80,14 +81,14 @@ bool CharacterBody2D::move_and_slide() {
on_wall = false;
if (!current_platform_velocity.is_zero_approx()) {
- PhysicsServer2D::MotionParameters parameters(get_global_transform(), current_platform_velocity * delta, margin);
+ PS2DT::MotionParameters parameters(get_global_transform(), current_platform_velocity * delta, margin);
parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
parameters.exclude_bodies.insert(platform_rid);
if (platform_object_id.is_valid()) {
parameters.exclude_objects.insert(platform_object_id);
}
- PhysicsServer2D::MotionResult floor_result;
+ PS2DT::MotionResult floor_result;
if (move_and_collide(parameters, floor_result, false, false)) {
motion_results.push_back(floor_result);
_set_collision_direction(floor_result);
@@ -139,12 +140,12 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
Vector2 last_travel;
for (int iteration = 0; iteration < max_slides; ++iteration) {
- PhysicsServer2D::MotionParameters parameters(get_global_transform(), motion, margin);
+ PS2DT::MotionParameters parameters(get_global_transform(), motion, margin);
parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
Vector2 prev_position = parameters.from.columns[2];
- PhysicsServer2D::MotionResult result;
+ PS2DT::MotionResult result;
bool collided = move_and_collide(parameters, result, false, !sliding_enabled);
last_motion = result.travel;
@@ -296,10 +297,10 @@ void CharacterBody2D::_move_and_slide_floating(double p_delta) {
bool first_slide = true;
for (int iteration = 0; iteration < max_slides; ++iteration) {
- PhysicsServer2D::MotionParameters parameters(get_global_transform(), motion, margin);
+ PS2DT::MotionParameters parameters(get_global_transform(), motion, margin);
parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
- PhysicsServer2D::MotionResult result;
+ PS2DT::MotionResult result;
bool collided = move_and_collide(parameters, result, false, false);
last_motion = result.travel;
@@ -347,11 +348,11 @@ void CharacterBody2D::_apply_floor_snap(bool p_wall_as_floor) {
// Snap by at least collision margin to keep floor state consistent.
real_t length = MAX(floor_snap_length, margin);
- PhysicsServer2D::MotionParameters parameters(get_global_transform(), -up_direction * length, margin);
+ PS2DT::MotionParameters parameters(get_global_transform(), -up_direction * length, margin);
parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
parameters.collide_separation_ray = true;
- PhysicsServer2D::MotionResult result;
+ PS2DT::MotionResult result;
if (move_and_collide(parameters, result, true, false)) {
if ((result.get_angle(up_direction) <= floor_max_angle + FLOOR_ANGLE_THRESHOLD) ||
(p_wall_as_floor && result.get_angle(-up_direction) > floor_max_angle + FLOOR_ANGLE_THRESHOLD)) {
@@ -391,11 +392,11 @@ bool CharacterBody2D::_on_floor_if_snapped(bool p_was_on_floor, bool p_vel_dir_f
// Snap by at least collision margin to keep floor state consistent.
real_t length = MAX(floor_snap_length, margin);
- PhysicsServer2D::MotionParameters parameters(get_global_transform(), -up_direction * length, margin);
+ PS2DT::MotionParameters parameters(get_global_transform(), -up_direction * length, margin);
parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
parameters.collide_separation_ray = true;
- PhysicsServer2D::MotionResult result;
+ PS2DT::MotionResult result;
if (move_and_collide(parameters, result, true, false)) {
if (result.get_angle(up_direction) <= floor_max_angle + FLOOR_ANGLE_THRESHOLD) {
return true;
@@ -405,7 +406,7 @@ bool CharacterBody2D::_on_floor_if_snapped(bool p_was_on_floor, bool p_vel_dir_f
return false;
}
-void CharacterBody2D::_set_collision_direction(const PhysicsServer2D::MotionResult &p_result) {
+void CharacterBody2D::_set_collision_direction(const PS2DT::MotionResult &p_result) {
if (motion_mode == MOTION_MODE_GROUNDED && p_result.get_angle(up_direction) <= floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //floor
on_floor = true;
floor_normal = p_result.collision_normal;
@@ -422,7 +423,7 @@ void CharacterBody2D::_set_collision_direction(const PhysicsServer2D::MotionResu
}
}
-void CharacterBody2D::_set_platform_data(const PhysicsServer2D::MotionResult &p_result) {
+void CharacterBody2D::_set_platform_data(const PS2DT::MotionResult &p_result) {
PhysicsDirectBodyState2D *bs = PhysicsServer2D::get_singleton()->body_get_direct_state(p_result.collider);
if (bs == nullptr) {
return;
@@ -509,8 +510,8 @@ int CharacterBody2D::get_slide_collision_count() const {
return motion_results.size();
}
-PhysicsServer2D::MotionResult CharacterBody2D::get_slide_collision(int p_bounce) const {
- ERR_FAIL_INDEX_V(p_bounce, motion_results.size(), PhysicsServer2D::MotionResult());
+PS2DT::MotionResult CharacterBody2D::get_slide_collision(int p_bounce) const {
+ ERR_FAIL_INDEX_V(p_bounce, motion_results.size(), PS2DT::MotionResult());
return motion_results[p_bounce];
}
@@ -768,5 +769,5 @@ void CharacterBody2D::_bind_methods() {
}
CharacterBody2D::CharacterBody2D() :
- PhysicsBody2D(PhysicsServer2D::BODY_MODE_KINEMATIC) {
+ PhysicsBody2D(PS2DE::BODY_MODE_KINEMATIC) {
}
diff --git a/scene/2d/physics/character_body_2d.h b/scene/2d/physics/character_body_2d.h
index 5c7f44b7118..671de914792 100644
--- a/scene/2d/physics/character_body_2d.h
+++ b/scene/2d/physics/character_body_2d.h
@@ -68,7 +68,7 @@ public:
const Vector2 &get_platform_velocity() const;
int get_slide_collision_count() const;
- PhysicsServer2D::MotionResult get_slide_collision(int p_bounce) const;
+ PS2DT::MotionResult get_slide_collision(int p_bounce) const;
void set_safe_margin(real_t p_margin);
real_t get_safe_margin() const;
@@ -143,7 +143,7 @@ private:
bool on_ceiling = false;
bool on_wall = false;
- Vector<PhysicsServer2D::MotionResult> motion_results;
+ Vector<PS2DT::MotionResult> motion_results;
Vector<Ref<KinematicCollision2D>> slide_colliders;
void _move_and_slide_floating(double p_delta);
@@ -154,8 +154,8 @@ private:
const Vector2 &get_up_direction() const;
bool _on_floor_if_snapped(bool p_was_on_floor, bool p_vel_dir_facing_up);
void set_up_direction(const Vector2 &p_up_direction);
- void _set_collision_direction(const PhysicsServer2D::MotionResult &p_result);
- void _set_platform_data(const PhysicsServer2D::MotionResult &p_result);
+ void _set_collision_direction(const PS2DT::MotionResult &p_result);
+ void _set_platform_data(const PS2DT::MotionResult &p_result);
void _apply_floor_snap(bool p_wall_as_floor = false);
void _snap_on_floor(bool p_was_on_floor, bool p_vel_dir_facing_up, bool p_wall_as_floor = false);
diff --git a/scene/2d/physics/collision_object_2d.cpp b/scene/2d/physics/collision_object_2d.cpp
index 9ca3df08a96..3eb98a82a77 100644
--- a/scene/2d/physics/collision_object_2d.cpp
+++ b/scene/2d/physics/collision_object_2d.cpp
@@ -41,7 +41,7 @@ void CollisionObject2D::_notification(int p_what) {
if (area) {
PhysicsServer2D::get_singleton()->area_set_transform(rid, gl_transform);
} else {
- PhysicsServer2D::get_singleton()->body_set_state(rid, PhysicsServer2D::BODY_STATE_TRANSFORM, gl_transform);
+ PhysicsServer2D::get_singleton()->body_set_state(rid, PS2DE::BODY_STATE_TRANSFORM, gl_transform);
}
bool disabled = !is_enabled();
@@ -87,7 +87,7 @@ void CollisionObject2D::_notification(int p_what) {
if (area) {
PhysicsServer2D::get_singleton()->area_set_transform(rid, gl_transform);
} else {
- PhysicsServer2D::get_singleton()->body_set_state(rid, PhysicsServer2D::BODY_STATE_TRANSFORM, gl_transform);
+ PhysicsServer2D::get_singleton()->body_set_state(rid, PS2DE::BODY_STATE_TRANSFORM, gl_transform);
}
} break;
@@ -255,8 +255,8 @@ void CollisionObject2D::_apply_disabled() {
} break;
case DISABLE_MODE_MAKE_STATIC: {
- if (!area && (body_mode != PhysicsServer2D::BODY_MODE_STATIC)) {
- PhysicsServer2D::get_singleton()->body_set_mode(rid, PhysicsServer2D::BODY_MODE_STATIC);
+ if (!area && (body_mode != PS2DE::BODY_MODE_STATIC)) {
+ PhysicsServer2D::get_singleton()->body_set_mode(rid, PS2DE::BODY_MODE_STATIC);
}
} break;
@@ -281,7 +281,7 @@ void CollisionObject2D::_apply_enabled() {
} break;
case DISABLE_MODE_MAKE_STATIC: {
- if (!area && (body_mode != PhysicsServer2D::BODY_MODE_STATIC)) {
+ if (!area && (body_mode != PS2DE::BODY_MODE_STATIC)) {
PhysicsServer2D::get_singleton()->body_set_mode(rid, body_mode);
}
} break;
@@ -570,7 +570,7 @@ bool CollisionObject2D::is_only_update_transform_changes_enabled() const {
return only_update_transform_changes;
}
-void CollisionObject2D::set_body_mode(PhysicsServer2D::BodyMode p_mode) {
+void CollisionObject2D::set_body_mode(PS2DE::BodyMode p_mode) {
ERR_FAIL_COND(area);
if (body_mode == p_mode) {
diff --git a/scene/2d/physics/collision_object_2d.h b/scene/2d/physics/collision_object_2d.h
index b2dbbe904ff..62f15ea0dd7 100644
--- a/scene/2d/physics/collision_object_2d.h
+++ b/scene/2d/physics/collision_object_2d.h
@@ -34,7 +34,7 @@
#include "scene/2d/node_2d.h"
#include "scene/main/viewport.h"
#include "scene/resources/2d/shape_2d.h"
-#include "servers/physics_2d/physics_server_2d.h"
+#include "servers/physics_2d/physics_server_2d_enums.h"
class CollisionObject2D : public Node2D {
GDCLASS(CollisionObject2D, Node2D);
@@ -60,7 +60,7 @@ private:
DisableMode disable_mode = DISABLE_MODE_REMOVE;
- PhysicsServer2D::BodyMode body_mode = PhysicsServer2D::BODY_MODE_STATIC;
+ PS2DE::BodyMode body_mode = PS2DE::BODY_MODE_STATIC;
struct ShapeData {
ObjectID owner_id;
@@ -110,7 +110,7 @@ protected:
void set_only_update_transform_changes(bool p_enable);
bool is_only_update_transform_changes_enabled() const;
- void set_body_mode(PhysicsServer2D::BodyMode p_mode);
+ void set_body_mode(PS2DE::BodyMode p_mode);
virtual void _space_changed(const RID &p_new_space);
diff --git a/scene/2d/physics/joints/damped_spring_joint_2d.cpp b/scene/2d/physics/joints/damped_spring_joint_2d.cpp
index 9af1ff85ce8..7381df7381e 100644
--- a/scene/2d/physics/joints/damped_spring_joint_2d.cpp
+++ b/scene/2d/physics/joints/damped_spring_joint_2d.cpp
@@ -34,6 +34,7 @@
#include "core/object/class_db.h"
#include "scene/2d/physics/physics_body_2d.h"
#include "scene/main/scene_tree.h"
+#include "servers/physics_2d/physics_server_2d.h"
void DampedSpringJoint2D::_notification(int p_what) {
switch (p_what) {
@@ -60,10 +61,10 @@ void DampedSpringJoint2D::_configure_joint(RID p_joint, PhysicsBody2D *body_a, P
PhysicsServer2D::get_singleton()->joint_make_damped_spring(p_joint, anchor_A, anchor_B, body_a->get_rid(), body_b->get_rid());
if (rest_length) {
- PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(p_joint, PhysicsServer2D::DAMPED_SPRING_REST_LENGTH, rest_length);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(p_joint, PS2DE::DAMPED_SPRING_REST_LENGTH, rest_length);
}
- PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(p_joint, PhysicsServer2D::DAMPED_SPRING_STIFFNESS, stiffness);
- PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(p_joint, PhysicsServer2D::DAMPED_SPRING_DAMPING, damping);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(p_joint, PS2DE::DAMPED_SPRING_STIFFNESS, stiffness);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(p_joint, PS2DE::DAMPED_SPRING_DAMPING, damping);
}
void DampedSpringJoint2D::set_length(real_t p_length) {
@@ -79,7 +80,7 @@ void DampedSpringJoint2D::set_rest_length(real_t p_rest_length) {
rest_length = p_rest_length;
queue_redraw();
if (is_configured()) {
- PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_rid(), PhysicsServer2D::DAMPED_SPRING_REST_LENGTH, p_rest_length ? p_rest_length : length);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_rid(), PS2DE::DAMPED_SPRING_REST_LENGTH, p_rest_length ? p_rest_length : length);
}
}
@@ -91,7 +92,7 @@ void DampedSpringJoint2D::set_stiffness(real_t p_stiffness) {
stiffness = p_stiffness;
queue_redraw();
if (is_configured()) {
- PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_rid(), PhysicsServer2D::DAMPED_SPRING_STIFFNESS, p_stiffness);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_rid(), PS2DE::DAMPED_SPRING_STIFFNESS, p_stiffness);
}
}
@@ -103,7 +104,7 @@ void DampedSpringJoint2D::set_damping(real_t p_damping) {
damping = p_damping;
queue_redraw();
if (is_configured()) {
- PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_rid(), PhysicsServer2D::DAMPED_SPRING_DAMPING, p_damping);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_rid(), PS2DE::DAMPED_SPRING_DAMPING, p_damping);
}
}
diff --git a/scene/2d/physics/joints/groove_joint_2d.cpp b/scene/2d/physics/joints/groove_joint_2d.cpp
index f2e7a06ff7d..5787b08ec02 100644
--- a/scene/2d/physics/joints/groove_joint_2d.cpp
+++ b/scene/2d/physics/joints/groove_joint_2d.cpp
@@ -34,6 +34,7 @@
#include "core/object/class_db.h"
#include "scene/2d/physics/physics_body_2d.h"
#include "scene/main/scene_tree.h"
+#include "servers/physics_2d/physics_server_2d.h"
void GrooveJoint2D::_notification(int p_what) {
switch (p_what) {
diff --git a/scene/2d/physics/joints/joint_2d.cpp b/scene/2d/physics/joints/joint_2d.cpp
index 46eaedded1c..2769d8dc53b 100644
--- a/scene/2d/physics/joints/joint_2d.cpp
+++ b/scene/2d/physics/joints/joint_2d.cpp
@@ -34,6 +34,7 @@
#include "core/object/callable_mp.h"
#include "core/object/class_db.h"
#include "scene/2d/physics/physics_body_2d.h"
+#include "servers/physics_2d/physics_server_2d.h"
void Joint2D::_disconnect_signals() {
Node *node_a = get_node_or_null(a);
@@ -114,7 +115,7 @@ void Joint2D::_update_joint(bool p_only_free) {
ERR_FAIL_COND_MSG(!joint.is_valid(), "Failed to configure the joint.");
- PhysicsServer2D::get_singleton()->joint_set_param(joint, PhysicsServer2D::JOINT_PARAM_BIAS, bias);
+ PhysicsServer2D::get_singleton()->joint_set_param(joint, PS2DE::JOINT_PARAM_BIAS, bias);
ba = body_a->get_rid();
bb = body_b->get_rid();
@@ -194,7 +195,7 @@ void Joint2D::_notification(int p_what) {
void Joint2D::set_bias(real_t p_bias) {
bias = p_bias;
if (joint.is_valid()) {
- PhysicsServer2D::get_singleton()->joint_set_param(joint, PhysicsServer2D::JOINT_PARAM_BIAS, bias);
+ PhysicsServer2D::get_singleton()->joint_set_param(joint, PS2DE::JOINT_PARAM_BIAS, bias);
}
}
diff --git a/scene/2d/physics/joints/pin_joint_2d.cpp b/scene/2d/physics/joints/pin_joint_2d.cpp
index 400a9da2eaa..d95a9a1a4ce 100644
--- a/scene/2d/physics/joints/pin_joint_2d.cpp
+++ b/scene/2d/physics/joints/pin_joint_2d.cpp
@@ -34,6 +34,7 @@
#include "core/object/class_db.h"
#include "scene/2d/physics/physics_body_2d.h"
#include "scene/main/scene_tree.h"
+#include "servers/physics_2d/physics_server_2d.h"
void PinJoint2D::_notification(int p_what) {
switch (p_what) {
@@ -54,12 +55,12 @@ void PinJoint2D::_notification(int p_what) {
void PinJoint2D::_configure_joint(RID p_joint, PhysicsBody2D *body_a, PhysicsBody2D *body_b) {
PhysicsServer2D::get_singleton()->joint_make_pin(p_joint, get_global_position(), body_a->get_rid(), body_b ? body_b->get_rid() : RID());
- PhysicsServer2D::get_singleton()->pin_joint_set_param(p_joint, PhysicsServer2D::PIN_JOINT_SOFTNESS, softness);
- PhysicsServer2D::get_singleton()->pin_joint_set_param(p_joint, PhysicsServer2D::PIN_JOINT_LIMIT_UPPER, angular_limit_upper);
- PhysicsServer2D::get_singleton()->pin_joint_set_param(p_joint, PhysicsServer2D::PIN_JOINT_LIMIT_LOWER, angular_limit_lower);
- PhysicsServer2D::get_singleton()->pin_joint_set_param(p_joint, PhysicsServer2D::PIN_JOINT_MOTOR_TARGET_VELOCITY, motor_target_velocity);
- PhysicsServer2D::get_singleton()->pin_joint_set_flag(p_joint, PhysicsServer2D::PIN_JOINT_FLAG_MOTOR_ENABLED, motor_enabled);
- PhysicsServer2D::get_singleton()->pin_joint_set_flag(p_joint, PhysicsServer2D::PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED, angular_limit_enabled);
+ PhysicsServer2D::get_singleton()->pin_joint_set_param(p_joint, PS2DE::PIN_JOINT_SOFTNESS, softness);
+ PhysicsServer2D::get_singleton()->pin_joint_set_param(p_joint, PS2DE::PIN_JOINT_LIMIT_UPPER, angular_limit_upper);
+ PhysicsServer2D::get_singleton()->pin_joint_set_param(p_joint, PS2DE::PIN_JOINT_LIMIT_LOWER, angular_limit_lower);
+ PhysicsServer2D::get_singleton()->pin_joint_set_param(p_joint, PS2DE::PIN_JOINT_MOTOR_TARGET_VELOCITY, motor_target_velocity);
+ PhysicsServer2D::get_singleton()->pin_joint_set_flag(p_joint, PS2DE::PIN_JOINT_FLAG_MOTOR_ENABLED, motor_enabled);
+ PhysicsServer2D::get_singleton()->pin_joint_set_flag(p_joint, PS2DE::PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED, angular_limit_enabled);
}
void PinJoint2D::set_softness(real_t p_softness) {
@@ -69,7 +70,7 @@ void PinJoint2D::set_softness(real_t p_softness) {
softness = p_softness;
queue_redraw();
if (is_configured()) {
- PhysicsServer2D::get_singleton()->pin_joint_set_param(get_rid(), PhysicsServer2D::PIN_JOINT_SOFTNESS, p_softness);
+ PhysicsServer2D::get_singleton()->pin_joint_set_param(get_rid(), PS2DE::PIN_JOINT_SOFTNESS, p_softness);
}
}
@@ -84,7 +85,7 @@ void PinJoint2D::set_angular_limit_lower(real_t p_angular_limit_lower) {
angular_limit_lower = p_angular_limit_lower;
queue_redraw();
if (is_configured()) {
- PhysicsServer2D::get_singleton()->pin_joint_set_param(get_rid(), PhysicsServer2D::PIN_JOINT_LIMIT_LOWER, p_angular_limit_lower);
+ PhysicsServer2D::get_singleton()->pin_joint_set_param(get_rid(), PS2DE::PIN_JOINT_LIMIT_LOWER, p_angular_limit_lower);
}
}
@@ -99,7 +100,7 @@ void PinJoint2D::set_angular_limit_upper(real_t p_angular_limit_upper) {
angular_limit_upper = p_angular_limit_upper;
queue_redraw();
if (is_configured()) {
- PhysicsServer2D::get_singleton()->pin_joint_set_param(get_rid(), PhysicsServer2D::PIN_JOINT_LIMIT_UPPER, p_angular_limit_upper);
+ PhysicsServer2D::get_singleton()->pin_joint_set_param(get_rid(), PS2DE::PIN_JOINT_LIMIT_UPPER, p_angular_limit_upper);
}
}
@@ -114,7 +115,7 @@ void PinJoint2D::set_motor_target_velocity(real_t p_motor_target_velocity) {
motor_target_velocity = p_motor_target_velocity;
queue_redraw();
if (is_configured()) {
- PhysicsServer2D::get_singleton()->pin_joint_set_param(get_rid(), PhysicsServer2D::PIN_JOINT_MOTOR_TARGET_VELOCITY, motor_target_velocity);
+ PhysicsServer2D::get_singleton()->pin_joint_set_param(get_rid(), PS2DE::PIN_JOINT_MOTOR_TARGET_VELOCITY, motor_target_velocity);
}
}
@@ -129,7 +130,7 @@ void PinJoint2D::set_motor_enabled(bool p_motor_enabled) {
motor_enabled = p_motor_enabled;
queue_redraw();
if (is_configured()) {
- PhysicsServer2D::get_singleton()->pin_joint_set_flag(get_rid(), PhysicsServer2D::PIN_JOINT_FLAG_MOTOR_ENABLED, motor_enabled);
+ PhysicsServer2D::get_singleton()->pin_joint_set_flag(get_rid(), PS2DE::PIN_JOINT_FLAG_MOTOR_ENABLED, motor_enabled);
}
}
@@ -144,7 +145,7 @@ void PinJoint2D::set_angular_limit_enabled(bool p_angular_limit_enabled) {
angular_limit_enabled = p_angular_limit_enabled;
queue_redraw();
if (is_configured()) {
- PhysicsServer2D::get_singleton()->pin_joint_set_flag(get_rid(), PhysicsServer2D::PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED, angular_limit_enabled);
+ PhysicsServer2D::get_singleton()->pin_joint_set_flag(get_rid(), PS2DE::PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED, angular_limit_enabled);
}
}
diff --git a/scene/2d/physics/kinematic_collision_2d.h b/scene/2d/physics/kinematic_collision_2d.h
index 610834052c7..877909185bc 100644
--- a/scene/2d/physics/kinematic_collision_2d.h
+++ b/scene/2d/physics/kinematic_collision_2d.h
@@ -31,7 +31,7 @@
#pragma once
#include "core/object/ref_counted.h"
-#include "servers/physics_2d/physics_server_2d.h"
+#include "servers/physics_2d/physics_server_2d_types.h"
class CharacterBody2D;
class PhysicsBody2D;
@@ -42,7 +42,7 @@ class KinematicCollision2D : public RefCounted {
ObjectID owner_id;
friend class PhysicsBody2D;
friend class CharacterBody2D;
- PhysicsServer2D::MotionResult result;
+ PS2DT::MotionResult result;
protected:
static void _bind_methods();
diff --git a/scene/2d/physics/physical_bone_2d.cpp b/scene/2d/physics/physical_bone_2d.cpp
index 5102937d719..843c09ae6be 100644
--- a/scene/2d/physics/physical_bone_2d.cpp
+++ b/scene/2d/physics/physical_bone_2d.cpp
@@ -32,6 +32,7 @@
#include "core/object/class_db.h"
#include "scene/2d/physics/joints/joint_2d.h"
+#include "servers/physics_2d/physics_server_2d.h"
void PhysicalBone2D::_notification(int p_what) {
switch (p_what) {
@@ -179,7 +180,7 @@ void PhysicalBone2D::_stop_physics_simulation() {
PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), 0);
PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), 0);
PhysicsServer2D::get_singleton()->body_set_collision_priority(get_rid(), 1.0);
- PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BodyMode::BODY_MODE_STATIC);
+ PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PS2DE::BodyMode::BODY_MODE_STATIC);
}
}
@@ -291,7 +292,7 @@ PhysicalBone2D::PhysicalBone2D() {
// Stop the RigidBody from executing its force integration.
PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), 0);
PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), 0);
- PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BodyMode::BODY_MODE_STATIC);
+ PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PS2DE::BodyMode::BODY_MODE_STATIC);
child_joint = nullptr;
}
diff --git a/scene/2d/physics/physics_body_2d.cpp b/scene/2d/physics/physics_body_2d.cpp
index 4cec467fe0a..cc3a6d5e619 100644
--- a/scene/2d/physics/physics_body_2d.cpp
+++ b/scene/2d/physics/physics_body_2d.cpp
@@ -32,6 +32,8 @@
#include "core/object/class_db.h"
#include "scene/main/scene_tree.h"
+#include "servers/physics_2d/direct_states/physics_direct_body_state_2d.h"
+#include "servers/physics_2d/physics_server_2d.h"
void PhysicsBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_and_collide", "motion", "test_only", "safe_margin", "recovery_as_collision"), &PhysicsBody2D::_move, DEFVAL(false), DEFVAL(0.08), DEFVAL(false));
@@ -43,17 +45,17 @@ void PhysicsBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_collision_exception_with", "body"), &PhysicsBody2D::remove_collision_exception_with);
}
-PhysicsBody2D::PhysicsBody2D(PhysicsServer2D::BodyMode p_mode) :
+PhysicsBody2D::PhysicsBody2D(PS2DE::BodyMode p_mode) :
CollisionObject2D(PhysicsServer2D::get_singleton()->body_create(), false) {
set_body_mode(p_mode);
set_pickable(false);
}
Ref<KinematicCollision2D> PhysicsBody2D::_move(const Vector2 &p_motion, bool p_test_only, real_t p_margin, bool p_recovery_as_collision) {
- PhysicsServer2D::MotionParameters parameters(get_global_transform(), p_motion, p_margin);
+ PS2DT::MotionParameters parameters(get_global_transform(), p_motion, p_margin);
parameters.recovery_as_collision = p_recovery_as_collision;
- PhysicsServer2D::MotionResult result;
+ PS2DT::MotionResult result;
if (move_and_collide(parameters, result, p_test_only)) {
// Create a new instance when the cached reference is invalid or still in use in script.
@@ -69,7 +71,7 @@ Ref<KinematicCollision2D> PhysicsBody2D::_move(const Vector2 &p_motion, bool p_t
return Ref<KinematicCollision2D>();
}
-bool PhysicsBody2D::move_and_collide(const PhysicsServer2D::MotionParameters &p_parameters, PhysicsServer2D::MotionResult &r_result, bool p_test_only, bool p_cancel_sliding) {
+bool PhysicsBody2D::move_and_collide(const PS2DT::MotionParameters &p_parameters, PS2DT::MotionResult &r_result, bool p_test_only, bool p_cancel_sliding) {
if (is_only_update_transform_changes_enabled()) {
ERR_PRINT("Move functions do not work together with 'sync to physics' option. See the documentation for details.");
}
@@ -126,15 +128,15 @@ bool PhysicsBody2D::move_and_collide(const PhysicsServer2D::MotionParameters &p_
bool PhysicsBody2D::test_move(const Transform2D &p_from, const Vector2 &p_motion, const Ref<KinematicCollision2D> &r_collision, real_t p_margin, bool p_recovery_as_collision) {
ERR_FAIL_COND_V(!is_inside_tree(), false);
- PhysicsServer2D::MotionResult *r = nullptr;
- PhysicsServer2D::MotionResult temp_result;
+ PS2DT::MotionResult *r = nullptr;
+ PS2DT::MotionResult temp_result;
if (r_collision.is_valid()) {
r = &r_collision->result;
} else {
r = &temp_result;
}
- PhysicsServer2D::MotionParameters parameters(p_from, p_motion, p_margin);
+ PS2DT::MotionParameters parameters(p_from, p_motion, p_margin);
parameters.recovery_as_collision = p_recovery_as_collision;
return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), parameters, r);
diff --git a/scene/2d/physics/physics_body_2d.h b/scene/2d/physics/physics_body_2d.h
index e3e4bfa5eb5..ed36fab4dd1 100644
--- a/scene/2d/physics/physics_body_2d.h
+++ b/scene/2d/physics/physics_body_2d.h
@@ -32,14 +32,13 @@
#include "scene/2d/physics/collision_object_2d.h"
#include "scene/2d/physics/kinematic_collision_2d.h"
-#include "servers/physics_2d/physics_server_2d.h"
class PhysicsBody2D : public CollisionObject2D {
GDCLASS(PhysicsBody2D, CollisionObject2D);
protected:
static void _bind_methods();
- PhysicsBody2D(PhysicsServer2D::BodyMode p_mode);
+ PhysicsBody2D(PS2DE::BodyMode p_mode);
Ref<KinematicCollision2D> motion_cache;
@@ -48,7 +47,7 @@ protected:
public:
PackedStringArray get_configuration_warnings() const override;
- bool move_and_collide(const PhysicsServer2D::MotionParameters &p_parameters, PhysicsServer2D::MotionResult &r_result, bool p_test_only = false, bool p_cancel_sliding = true);
+ bool move_and_collide(const PS2DT::MotionParameters &p_parameters, PS2DT::MotionResult &r_result, bool p_test_only = false, bool p_cancel_sliding = true);
bool test_move(const Transform2D &p_from, const Vector2 &p_motion, const Ref<KinematicCollision2D> &r_collision = Ref<KinematicCollision2D>(), real_t p_margin = 0.08, bool p_recovery_as_collision = false);
Vector2 get_gravity() const;
diff --git a/scene/2d/physics/ray_cast_2d.cpp b/scene/2d/physics/ray_cast_2d.cpp
index abfd3147643..d14caa523c9 100644
--- a/scene/2d/physics/ray_cast_2d.cpp
+++ b/scene/2d/physics/ray_cast_2d.cpp
@@ -35,6 +35,7 @@
#include "scene/2d/physics/collision_object_2d.h"
#include "scene/main/scene_tree.h"
#include "scene/resources/world_2d.h"
+#include "servers/physics_2d/direct_states/physics_direct_space_state_2d.h"
void RayCast2D::set_target_position(const Vector2 &p_point) {
target_position = p_point;
@@ -195,10 +196,10 @@ void RayCast2D::_update_raycast_state() {
to = Vector2(0, 0.01);
}
- PhysicsDirectSpaceState2D::RayResult rr;
+ PS2DT::RayResult rr;
bool prev_collision_state = collided;
- PhysicsDirectSpaceState2D::RayParameters ray_params;
+ PS2DT::RayParameters ray_params;
ray_params.from = gt.get_origin();
ray_params.to = gt.xform(to);
ray_params.exclude = exclude;
diff --git a/scene/2d/physics/rigid_body_2d.cpp b/scene/2d/physics/rigid_body_2d.cpp
index 86fb8a3489d..f9dd4514b26 100644
--- a/scene/2d/physics/rigid_body_2d.cpp
+++ b/scene/2d/physics/rigid_body_2d.cpp
@@ -34,6 +34,8 @@
#include "core/object/callable_mp.h"
#include "core/object/class_db.h"
#include "scene/resources/physics_material.h"
+#include "servers/physics_2d/physics_server_2d.h"
+#include "servers/physics_2d/physics_server_2d_constants.h"
void RigidBody2D::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
@@ -178,7 +180,7 @@ void RigidBody2D::_body_state_changed(PhysicsDirectBodyState2D *p_state) {
if (new_transform != old_transform) {
// Update the physics server with the new transform, to prevent it from being overwritten at the sync below.
- PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_TRANSFORM, new_transform);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PS2DE::BODY_STATE_TRANSFORM, new_transform);
}
}
@@ -268,16 +270,16 @@ void RigidBody2D::_apply_body_mode() {
if (freeze) {
switch (freeze_mode) {
case FREEZE_MODE_STATIC: {
- set_body_mode(PhysicsServer2D::BODY_MODE_STATIC);
+ set_body_mode(PS2DE::BODY_MODE_STATIC);
} break;
case FREEZE_MODE_KINEMATIC: {
- set_body_mode(PhysicsServer2D::BODY_MODE_KINEMATIC);
+ set_body_mode(PS2DE::BODY_MODE_KINEMATIC);
} break;
}
} else if (lock_rotation) {
- set_body_mode(PhysicsServer2D::BODY_MODE_RIGID_LINEAR);
+ set_body_mode(PS2DE::BODY_MODE_RIGID_LINEAR);
} else {
- set_body_mode(PhysicsServer2D::BODY_MODE_RIGID);
+ set_body_mode(PS2DE::BODY_MODE_RIGID);
}
}
@@ -323,7 +325,7 @@ RigidBody2D::FreezeMode RigidBody2D::get_freeze_mode() const {
void RigidBody2D::set_mass(real_t p_mass) {
ERR_FAIL_COND(p_mass <= 0);
mass = p_mass;
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_MASS, mass);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_MASS, mass);
}
real_t RigidBody2D::get_mass() const {
@@ -333,7 +335,7 @@ real_t RigidBody2D::get_mass() const {
void RigidBody2D::set_inertia(real_t p_inertia) {
ERR_FAIL_COND(p_inertia < 0);
inertia = p_inertia;
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_INERTIA, inertia);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_INERTIA, inertia);
}
real_t RigidBody2D::get_inertia() const {
@@ -352,12 +354,12 @@ void RigidBody2D::set_center_of_mass_mode(CenterOfMassMode p_mode) {
center_of_mass = Vector2();
PhysicsServer2D::get_singleton()->body_reset_mass_properties(get_rid());
if (inertia != 0.0) {
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_INERTIA, inertia);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_INERTIA, inertia);
}
} break;
case CENTER_OF_MASS_MODE_CUSTOM: {
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_CENTER_OF_MASS, center_of_mass);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_CENTER_OF_MASS, center_of_mass);
} break;
}
@@ -376,7 +378,7 @@ void RigidBody2D::set_center_of_mass(const Vector2 &p_center_of_mass) {
ERR_FAIL_COND(center_of_mass_mode != CENTER_OF_MASS_MODE_CUSTOM);
center_of_mass = p_center_of_mass;
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_CENTER_OF_MASS, center_of_mass);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_CENTER_OF_MASS, center_of_mass);
}
const Vector2 &RigidBody2D::get_center_of_mass() const {
@@ -402,7 +404,7 @@ Ref<PhysicsMaterial> RigidBody2D::get_physics_material_override() const {
void RigidBody2D::set_gravity_scale(real_t p_gravity_scale) {
gravity_scale = p_gravity_scale;
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
}
real_t RigidBody2D::get_gravity_scale() const {
@@ -411,7 +413,7 @@ real_t RigidBody2D::get_gravity_scale() const {
void RigidBody2D::set_linear_damp_mode(DampMode p_mode) {
linear_damp_mode = p_mode;
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_LINEAR_DAMP_MODE, linear_damp_mode);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_LINEAR_DAMP_MODE, linear_damp_mode);
}
RigidBody2D::DampMode RigidBody2D::get_linear_damp_mode() const {
@@ -420,7 +422,7 @@ RigidBody2D::DampMode RigidBody2D::get_linear_damp_mode() const {
void RigidBody2D::set_angular_damp_mode(DampMode p_mode) {
angular_damp_mode = p_mode;
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP_MODE, angular_damp_mode);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_ANGULAR_DAMP_MODE, angular_damp_mode);
}
RigidBody2D::DampMode RigidBody2D::get_angular_damp_mode() const {
@@ -430,7 +432,7 @@ RigidBody2D::DampMode RigidBody2D::get_angular_damp_mode() const {
void RigidBody2D::set_linear_damp(real_t p_linear_damp) {
ERR_FAIL_COND(p_linear_damp < -1);
linear_damp = p_linear_damp;
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_LINEAR_DAMP, linear_damp);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_LINEAR_DAMP, linear_damp);
}
real_t RigidBody2D::get_linear_damp() const {
@@ -440,7 +442,7 @@ real_t RigidBody2D::get_linear_damp() const {
void RigidBody2D::set_angular_damp(real_t p_angular_damp) {
ERR_FAIL_COND(p_angular_damp < -1);
angular_damp = p_angular_damp;
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP, angular_damp);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_ANGULAR_DAMP, angular_damp);
}
real_t RigidBody2D::get_angular_damp() const {
@@ -451,12 +453,12 @@ void RigidBody2D::set_axis_velocity(const Vector2 &p_axis) {
Vector2 axis = p_axis.normalized();
linear_velocity -= axis * axis.dot(linear_velocity);
linear_velocity += p_axis;
- PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PS2DE::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
}
void RigidBody2D::set_linear_velocity(const Vector2 &p_velocity) {
linear_velocity = p_velocity;
- PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PS2DE::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
}
Vector2 RigidBody2D::get_linear_velocity() const {
@@ -465,7 +467,7 @@ Vector2 RigidBody2D::get_linear_velocity() const {
void RigidBody2D::set_angular_velocity(real_t p_velocity) {
angular_velocity = p_velocity;
- PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PS2DE::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
}
real_t RigidBody2D::get_angular_velocity() const {
@@ -487,12 +489,12 @@ bool RigidBody2D::is_using_custom_integrator() {
void RigidBody2D::set_sleeping(bool p_sleeping) {
sleeping = p_sleeping;
- PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_SLEEPING, sleeping);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PS2DE::BODY_STATE_SLEEPING, sleeping);
}
void RigidBody2D::set_can_sleep(bool p_active) {
can_sleep = p_active;
- PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_CAN_SLEEP, p_active);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PS2DE::BODY_STATE_CAN_SLEEP, p_active);
}
bool RigidBody2D::is_able_to_sleep() const {
@@ -504,7 +506,7 @@ bool RigidBody2D::is_sleeping() const {
}
void RigidBody2D::set_max_contacts_reported(int p_amount) {
- ERR_FAIL_INDEX_MSG(p_amount, MAX_CONTACTS_REPORTED_2D_MAX, "Max contacts reported allocates memory (about 100 bytes each), and therefore must not be set too high.");
+ ERR_FAIL_INDEX_MSG(p_amount, PS2DC::MAX_CONTACTS_REPORTED_2D_MAX, "Max contacts reported allocates memory (about 100 bytes each), and therefore must not be set too high.");
max_contacts_reported = p_amount;
PhysicsServer2D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
}
@@ -571,7 +573,7 @@ real_t RigidBody2D::get_constant_torque() const {
void RigidBody2D::set_continuous_collision_detection_mode(CCDMode p_mode) {
ccd_mode = p_mode;
- PhysicsServer2D::get_singleton()->body_set_continuous_collision_detection_mode(get_rid(), PhysicsServer2D::CCDMode(p_mode));
+ PhysicsServer2D::get_singleton()->body_set_continuous_collision_detection_mode(get_rid(), PS2DE::CCDMode(p_mode));
}
RigidBody2D::CCDMode RigidBody2D::get_continuous_collision_detection_mode() const {
@@ -807,7 +809,7 @@ void RigidBody2D::_validate_property(PropertyInfo &p_property) const {
}
RigidBody2D::RigidBody2D() :
- PhysicsBody2D(PhysicsServer2D::BODY_MODE_RIGID) {
+ PhysicsBody2D(PS2DE::BODY_MODE_RIGID) {
PhysicsServer2D::get_singleton()->body_set_state_sync_callback(get_rid(), callable_mp(this, &RigidBody2D::_body_state_changed));
}
@@ -819,10 +821,10 @@ RigidBody2D::~RigidBody2D() {
void RigidBody2D::_reload_physics_characteristics() {
if (physics_material_override.is_null()) {
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, 0);
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, 1);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_BOUNCE, 0);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_FRICTION, 1);
} else {
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
}
}
diff --git a/scene/2d/physics/rigid_body_2d.h b/scene/2d/physics/rigid_body_2d.h
index f3b0708d5d9..c9c21b7e703 100644
--- a/scene/2d/physics/rigid_body_2d.h
+++ b/scene/2d/physics/rigid_body_2d.h
@@ -32,6 +32,7 @@
#include "core/templates/vset.h"
#include "scene/2d/physics/physics_body_2d.h"
+#include "servers/physics_2d/direct_states/physics_direct_body_state_2d.h"
class PhysicsMaterial;
diff --git a/scene/2d/physics/shape_cast_2d.cpp b/scene/2d/physics/shape_cast_2d.cpp
index 2d1dba73369..04bfc80c28b 100644
--- a/scene/2d/physics/shape_cast_2d.cpp
+++ b/scene/2d/physics/shape_cast_2d.cpp
@@ -36,6 +36,7 @@
#include "scene/2d/physics/collision_object_2d.h"
#include "scene/main/scene_tree.h"
#include "scene/resources/world_2d.h"
+#include "servers/physics_2d/direct_states/physics_direct_space_state_2d.h"
#include "servers/physics_2d/physics_server_2d.h"
void ShapeCast2D::set_target_position(const Vector2 &p_point) {
@@ -298,7 +299,7 @@ void ShapeCast2D::_update_shapecast_state() {
Transform2D gt = get_global_transform();
- PhysicsDirectSpaceState2D::ShapeParameters params;
+ PS2DT::ShapeParameters params;
params.shape_rid = shape_rid;
params.transform = gt;
params.motion = gt.basis_xform(target_position);
@@ -328,7 +329,7 @@ void ShapeCast2D::_update_shapecast_state() {
bool intersected = true;
while (intersected && result.size() < max_results) {
- PhysicsDirectSpaceState2D::ShapeRestInfo info;
+ PS2DT::ShapeRestInfo info;
intersected = dss->rest_info(params, &info);
if (intersected) {
result.push_back(info);
@@ -388,7 +389,7 @@ Array ShapeCast2D::get_collision_result() const {
Array ret;
for (int i = 0; i < result.size(); ++i) {
- const PhysicsDirectSpaceState2D::ShapeRestInfo &sri = result[i];
+ const PS2DT::ShapeRestInfo &sri = result[i];
Dictionary col;
col["point"] = sri.point;
diff --git a/scene/2d/physics/shape_cast_2d.h b/scene/2d/physics/shape_cast_2d.h
index d0d1b9513a0..ccdec6d8b49 100644
--- a/scene/2d/physics/shape_cast_2d.h
+++ b/scene/2d/physics/shape_cast_2d.h
@@ -32,7 +32,7 @@
#include "scene/2d/node_2d.h"
#include "scene/resources/2d/shape_2d.h"
-#include "servers/physics_2d/physics_server_2d.h"
+#include "servers/physics_2d/physics_server_2d_types.h"
class CollisionObject2D;
@@ -54,7 +54,7 @@ class ShapeCast2D : public Node2D {
// Result
int max_results = 32;
- Vector<PhysicsDirectSpaceState2D::ShapeRestInfo> result;
+ Vector<PS2DT::ShapeRestInfo> result;
bool collided = false;
real_t collision_safe_fraction = 1.0;
real_t collision_unsafe_fraction = 1.0;
diff --git a/scene/2d/physics/static_body_2d.cpp b/scene/2d/physics/static_body_2d.cpp
index 1972c98269b..b8de31f1115 100644
--- a/scene/2d/physics/static_body_2d.cpp
+++ b/scene/2d/physics/static_body_2d.cpp
@@ -33,6 +33,7 @@
#include "core/object/callable_mp.h"
#include "core/object/class_db.h"
#include "scene/resources/physics_material.h"
+#include "servers/physics_2d/physics_server_2d.h"
#ifndef NAVIGATION_2D_DISABLED
#include "scene/resources/2d/capsule_shape_2d.h"
@@ -51,13 +52,13 @@ RID StaticBody2D::_navmesh_source_geometry_parser;
void StaticBody2D::set_constant_linear_velocity(const Vector2 &p_vel) {
constant_linear_velocity = p_vel;
- PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PS2DE::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity);
}
void StaticBody2D::set_constant_angular_velocity(real_t p_vel) {
constant_angular_velocity = p_vel;
- PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PS2DE::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity);
}
Vector2 StaticBody2D::get_constant_linear_velocity() const {
@@ -87,11 +88,11 @@ Ref<PhysicsMaterial> StaticBody2D::get_physics_material_override() const {
void StaticBody2D::_reload_physics_characteristics() {
if (physics_material_override.is_null()) {
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, 0);
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, 1);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_BOUNCE, 0);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_FRICTION, 1);
} else {
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
- PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PS2DE::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
}
}
@@ -236,6 +237,6 @@ void StaticBody2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "constant_angular_velocity", PROPERTY_HINT_NONE, U"radians_as_degrees,suffix:\u00B0/s"), "set_constant_angular_velocity", "get_constant_angular_velocity");
}
-StaticBody2D::StaticBody2D(PhysicsServer2D::BodyMode p_mode) :
+StaticBody2D::StaticBody2D(PS2DE::BodyMode p_mode) :
PhysicsBody2D(p_mode) {
}
diff --git a/scene/2d/physics/static_body_2d.h b/scene/2d/physics/static_body_2d.h
index 19729fc1390..52752ff2686 100644
--- a/scene/2d/physics/static_body_2d.h
+++ b/scene/2d/physics/static_body_2d.h
@@ -61,7 +61,7 @@ public:
Vector2 get_constant_linear_velocity() const;
real_t get_constant_angular_velocity() const;
- StaticBody2D(PhysicsServer2D::BodyMode p_mode = PhysicsServer2D::BODY_MODE_STATIC);
+ StaticBody2D(PS2DE::BodyMode p_mode = PS2DE::BODY_MODE_STATIC);
private:
static Callable _navmesh_source_geometry_parsing_callback;
diff --git a/scene/2d/tile_map_layer.cpp b/scene/2d/tile_map_layer.cpp
index 86e8aa1ace4..e288f0749bc 100644
--- a/scene/2d/tile_map_layer.cpp
+++ b/scene/2d/tile_map_layer.cpp
@@ -890,27 +890,27 @@ void TileMapLayer::_physics_update(bool p_force_cleanup) {
bodies_coords[body] = physics_quadrant->quadrant_coords;
// Create or update the body.
- ps->body_set_mode(body, use_kinematic_bodies ? PhysicsServer2D::BODY_MODE_KINEMATIC : PhysicsServer2D::BODY_MODE_STATIC);
+ ps->body_set_mode(body, use_kinematic_bodies ? PS2DE::BODY_MODE_KINEMATIC : PS2DE::BODY_MODE_STATIC);
ps->body_set_space(body, space);
Transform2D xform;
xform.set_origin(quadrant_origin);
xform = gl_transform * xform;
- ps->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform);
+ ps->body_set_state(body, PS2DE::BODY_STATE_TRANSFORM, xform);
ps->body_attach_object_instance_id(body, tile_map_node ? tile_map_node->get_instance_id() : get_instance_id());
ps->body_set_collision_layer(body, physics_layer);
ps->body_set_collision_mask(body, physics_mask);
ps->body_set_pickable(body, false);
- ps->body_set_state(body, PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
- ps->body_set_state(body, PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
+ ps->body_set_state(body, PS2DE::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
+ ps->body_set_state(body, PS2DE::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
if (!physics_material.is_valid()) {
- ps->body_set_param(body, PhysicsServer2D::BODY_PARAM_BOUNCE, 0);
- ps->body_set_param(body, PhysicsServer2D::BODY_PARAM_FRICTION, 1);
+ ps->body_set_param(body, PS2DE::BODY_PARAM_BOUNCE, 0);
+ ps->body_set_param(body, PS2DE::BODY_PARAM_FRICTION, 1);
} else {
- ps->body_set_param(body, PhysicsServer2D::BODY_PARAM_BOUNCE, physics_material->computed_bounce());
- ps->body_set_param(body, PhysicsServer2D::BODY_PARAM_FRICTION, physics_material->computed_friction());
+ ps->body_set_param(body, PS2DE::BODY_PARAM_BOUNCE, physics_material->computed_bounce());
+ ps->body_set_param(body, PS2DE::BODY_PARAM_FRICTION, physics_material->computed_friction());
}
}
@@ -972,7 +972,7 @@ void TileMapLayer::_physics_update(bool p_force_cleanup) {
for (KeyValue<Vector2i, Ref<PhysicsQuadrant>> &kv : physics_quadrant_map) {
Ref<PhysicsQuadrant> &physics_quadrant = kv.value;
for (const KeyValue<PhysicsQuadrant::PhysicsBodyKey, PhysicsQuadrant::PhysicsBodyValue> &kvbody : physics_quadrant->bodies) {
- ps->body_set_mode(kvbody.value.body, use_kinematic_bodies ? PhysicsServer2D::BODY_MODE_KINEMATIC : PhysicsServer2D::BODY_MODE_STATIC);
+ ps->body_set_mode(kvbody.value.body, use_kinematic_bodies ? PS2DE::BODY_MODE_KINEMATIC : PS2DE::BODY_MODE_STATIC);
}
}
}
@@ -1062,7 +1062,7 @@ void TileMapLayer::_physics_notification(int p_what) {
const RID &body = kvbody.value.body;
Transform2D xform(0, tile_set->map_to_local(kv.key));
xform = gl_transform * xform;
- ps->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform);
+ ps->body_set_state(body, PS2DE::BODY_STATE_TRANSFORM, xform);
}
}
}
@@ -1165,7 +1165,7 @@ void TileMapLayer::_physics_draw_quadrant_debug(const RID &p_canvas_item, DebugQ
if (shape_count == 0) {
continue;
}
- const Transform2D body_to_quadrant = global_to_debug_quadrant * Transform2D(ps->body_get_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM));
+ const Transform2D body_to_quadrant = global_to_debug_quadrant * Transform2D(ps->body_get_state(body, PS2DE::BODY_STATE_TRANSFORM));
Color face_random_variation_color;
face_random_variation_color.set_hsv(
@@ -1178,9 +1178,9 @@ void TileMapLayer::_physics_draw_quadrant_debug(const RID &p_canvas_item, DebugQ
for (int shape_index = 0; shape_index < shape_count; shape_index++) {
const RID &shape = ps->body_get_shape(body, shape_index);
const Transform2D &shape_xform = ps->body_get_shape_transform(body, shape_index);
- const PhysicsServer2D::ShapeType &type = ps->shape_get_type(shape);
+ const PS2DE::ShapeType &type = ps->shape_get_type(shape);
- if (type == PhysicsServer2D::SHAPE_CONVEX_POLYGON) {
+ if (type == PS2DE::SHAPE_CONVEX_POLYGON) {
PackedVector2Array outline = ps->shape_get_data(shape);
const int outline_size = outline.size();
if (outline_size < 3) {
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index 0c051eae306..2eec5d22750 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -318,9 +318,9 @@ Area3D *AudioStreamPlayer3D::_get_overriding_area() {
PhysicsDirectSpaceState3D *space_state = PhysicsServer3D::get_singleton()->space_get_direct_state(world_3d->get_space());
- PhysicsDirectSpaceState3D::ShapeResult sr[MAX_INTERSECT_AREAS];
+ PS3DT::ShapeResult sr[MAX_INTERSECT_AREAS];
- PhysicsDirectSpaceState3D::PointParameters point_params;
+ PS3DT::PointParameters point_params;
point_params.position = global_pos;
point_params.collision_mask = area_mask;
point_params.collide_with_bodies = false;
diff --git a/scene/3d/physics/animatable_body_3d.cpp b/scene/3d/physics/animatable_body_3d.cpp
index b8fc4e47b5a..6e0021e3d43 100644
--- a/scene/3d/physics/animatable_body_3d.cpp
+++ b/scene/3d/physics/animatable_body_3d.cpp
@@ -108,7 +108,7 @@ void AnimatableBody3D::_notification(int p_what) {
// Used by sync to physics, send the new transform to the physics...
Transform3D new_transform = get_global_transform();
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_TRANSFORM, new_transform);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_TRANSFORM, new_transform);
// ... but then revert changes.
set_notify_local_transform(false);
@@ -127,6 +127,6 @@ void AnimatableBody3D::_bind_methods() {
}
AnimatableBody3D::AnimatableBody3D() :
- StaticBody3D(PhysicsServer3D::BODY_MODE_KINEMATIC) {
+ StaticBody3D(PS3DE::BODY_MODE_KINEMATIC) {
PhysicsServer3D::get_singleton()->body_set_state_sync_callback(get_rid(), callable_mp(this, &AnimatableBody3D::_body_state_changed));
}
diff --git a/scene/3d/physics/area_3d.cpp b/scene/3d/physics/area_3d.cpp
index e904ee26636..5deca0025f1 100644
--- a/scene/3d/physics/area_3d.cpp
+++ b/scene/3d/physics/area_3d.cpp
@@ -37,7 +37,7 @@
void Area3D::set_gravity_space_override_mode(SpaceOverride p_mode) {
gravity_space_override = p_mode;
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE, p_mode);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE, p_mode);
}
Area3D::SpaceOverride Area3D::get_gravity_space_override_mode() const {
@@ -46,7 +46,7 @@ Area3D::SpaceOverride Area3D::get_gravity_space_override_mode() const {
void Area3D::set_gravity_is_point(bool p_enabled) {
gravity_is_point = p_enabled;
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
}
bool Area3D::is_gravity_a_point() const {
@@ -55,7 +55,7 @@ bool Area3D::is_gravity_a_point() const {
void Area3D::set_gravity_point_unit_distance(real_t p_scale) {
gravity_point_unit_distance = p_scale;
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE, p_scale);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE, p_scale);
}
real_t Area3D::get_gravity_point_unit_distance() const {
@@ -64,7 +64,7 @@ real_t Area3D::get_gravity_point_unit_distance() const {
void Area3D::set_gravity_point_center(const Vector3 &p_center) {
gravity_vec = p_center;
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, p_center);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_GRAVITY_VECTOR, p_center);
}
const Vector3 &Area3D::get_gravity_point_center() const {
@@ -73,7 +73,7 @@ const Vector3 &Area3D::get_gravity_point_center() const {
void Area3D::set_gravity_direction(const Vector3 &p_direction) {
gravity_vec = p_direction;
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, p_direction);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_GRAVITY_VECTOR, p_direction);
}
const Vector3 &Area3D::get_gravity_direction() const {
@@ -82,7 +82,7 @@ const Vector3 &Area3D::get_gravity_direction() const {
void Area3D::set_gravity(real_t p_gravity) {
gravity = p_gravity;
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY, p_gravity);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_GRAVITY, p_gravity);
}
real_t Area3D::get_gravity() const {
@@ -91,7 +91,7 @@ real_t Area3D::get_gravity() const {
void Area3D::set_linear_damp_space_override_mode(SpaceOverride p_mode) {
linear_damp_space_override = p_mode;
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE, p_mode);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE, p_mode);
}
Area3D::SpaceOverride Area3D::get_linear_damp_space_override_mode() const {
@@ -100,7 +100,7 @@ Area3D::SpaceOverride Area3D::get_linear_damp_space_override_mode() const {
void Area3D::set_angular_damp_space_override_mode(SpaceOverride p_mode) {
angular_damp_space_override = p_mode;
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE, p_mode);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE, p_mode);
}
Area3D::SpaceOverride Area3D::get_angular_damp_space_override_mode() const {
@@ -109,7 +109,7 @@ Area3D::SpaceOverride Area3D::get_angular_damp_space_override_mode() const {
void Area3D::set_linear_damp(real_t p_linear_damp) {
linear_damp = p_linear_damp;
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
}
real_t Area3D::get_linear_damp() const {
@@ -118,7 +118,7 @@ real_t Area3D::get_linear_damp() const {
void Area3D::set_angular_damp(real_t p_angular_damp) {
angular_damp = p_angular_damp;
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
}
real_t Area3D::get_angular_damp() const {
@@ -127,7 +127,7 @@ real_t Area3D::get_angular_damp() const {
void Area3D::set_priority(int p_priority) {
priority = p_priority;
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_PRIORITY, p_priority);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_PRIORITY, p_priority);
}
int Area3D::get_priority() const {
@@ -185,10 +185,10 @@ void Area3D::_initialize_wind() {
}
// Set force, source and direction in the physics server.
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_WIND_ATTENUATION_FACTOR, wind_attenuation_factor);
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_WIND_SOURCE, wind_source);
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_WIND_DIRECTION, wind_direction);
- PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_WIND_FORCE_MAGNITUDE, temp_magnitude);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_WIND_ATTENUATION_FACTOR, wind_attenuation_factor);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_WIND_SOURCE, wind_source);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_WIND_DIRECTION, wind_direction);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PS3DE::AREA_PARAM_WIND_FORCE_MAGNITUDE, temp_magnitude);
}
void Area3D::_body_enter_tree(ObjectID p_id) {
@@ -222,7 +222,7 @@ void Area3D::_body_exit_tree(ObjectID p_id) {
}
void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape) {
- bool body_in = p_status == PhysicsServer3D::AREA_BODY_ADDED;
+ bool body_in = p_status == PS3DE::AREA_BODY_ADDED;
ObjectID objid = p_instance;
// Exit early if instance is invalid.
@@ -428,7 +428,7 @@ void Area3D::_area_exit_tree(ObjectID p_id) {
}
void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int p_area_shape, int p_self_shape) {
- bool area_in = p_status == PhysicsServer3D::AREA_BODY_ADDED;
+ bool area_in = p_status == PS3DE::AREA_BODY_ADDED;
ObjectID objid = p_instance;
// Exit if instance is invalid.
diff --git a/scene/3d/physics/character_body_3d.cpp b/scene/3d/physics/character_body_3d.cpp
index 71f86af35da..15e71efcbe3 100644
--- a/scene/3d/physics/character_body_3d.cpp
+++ b/scene/3d/physics/character_body_3d.cpp
@@ -98,7 +98,7 @@ bool CharacterBody3D::move_and_slide() {
last_motion = Vector3();
if (!current_platform_velocity.is_zero_approx()) {
- PhysicsServer3D::MotionParameters parameters(get_global_transform(), current_platform_velocity * delta, margin);
+ PS3DT::MotionParameters parameters(get_global_transform(), current_platform_velocity * delta, margin);
parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
parameters.exclude_bodies.insert(platform_rid);
@@ -106,7 +106,7 @@ bool CharacterBody3D::move_and_slide() {
parameters.exclude_objects.insert(platform_object_id);
}
- PhysicsServer3D::MotionResult floor_result;
+ PS3DT::MotionResult floor_result;
if (move_and_collide(parameters, floor_result, false, false)) {
motion_results.push_back(floor_result);
@@ -163,11 +163,11 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
Vector3 total_travel;
for (int iteration = 0; iteration < max_slides; ++iteration) {
- PhysicsServer3D::MotionParameters parameters(get_global_transform(), motion, margin);
+ PS3DT::MotionParameters parameters(get_global_transform(), motion, margin);
parameters.max_collisions = 6; // There can be 4 collisions between 2 walls + 2 more for the floor.
parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
- PhysicsServer3D::MotionResult result;
+ PS3DT::MotionResult result;
bool collided = move_and_collide(parameters, result, false, !sliding_enabled);
last_motion = result.travel;
@@ -315,7 +315,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
if (apply_default_sliding) {
// Regular sliding, the last part of the test handle the case when you don't want to slide on the ceiling.
if ((sliding_enabled || !collision_state.floor) && (!collision_state.ceiling || slide_on_ceiling || !vel_dir_facing_up) && !apply_ceiling_velocity) {
- const PhysicsServer3D::MotionCollision &collision = result.collisions[0];
+ const PS3DT::MotionCollision &collision = result.collisions[0];
Vector3 slide_motion = result.remainder.slide(collision.normal);
if (collision_state.floor && !collision_state.wall && !motion_slide_up.is_zero_approx()) {
@@ -410,10 +410,10 @@ void CharacterBody3D::_move_and_slide_floating(double p_delta) {
bool first_slide = true;
for (int iteration = 0; iteration < max_slides; ++iteration) {
- PhysicsServer3D::MotionParameters parameters(get_global_transform(), motion, margin);
+ PS3DT::MotionParameters parameters(get_global_transform(), motion, margin);
parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
- PhysicsServer3D::MotionResult result;
+ PS3DT::MotionResult result;
bool collided = move_and_collide(parameters, result, false, false);
last_motion = result.travel;
@@ -464,12 +464,12 @@ void CharacterBody3D::apply_floor_snap() {
// Snap by at least collision margin to keep floor state consistent.
real_t length = MAX(floor_snap_length, margin);
- PhysicsServer3D::MotionParameters parameters(get_global_transform(), -up_direction * length, margin);
+ PS3DT::MotionParameters parameters(get_global_transform(), -up_direction * length, margin);
parameters.max_collisions = 4;
parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
parameters.collide_separation_ray = true;
- PhysicsServer3D::MotionResult result;
+ PS3DT::MotionResult result;
if (move_and_collide(parameters, result, true, false)) {
CollisionState result_state;
// Apply direction for floor only.
@@ -508,12 +508,12 @@ bool CharacterBody3D::_on_floor_if_snapped(bool p_was_on_floor, bool p_vel_dir_f
// Snap by at least collision margin to keep floor state consistent.
real_t length = MAX(floor_snap_length, margin);
- PhysicsServer3D::MotionParameters parameters(get_global_transform(), -up_direction * length, margin);
+ PS3DT::MotionParameters parameters(get_global_transform(), -up_direction * length, margin);
parameters.max_collisions = 4;
parameters.recovery_as_collision = true; // Also report collisions generated only from recovery.
parameters.collide_separation_ray = true;
- PhysicsServer3D::MotionResult result;
+ PS3DT::MotionResult result;
if (move_and_collide(parameters, result, true, false)) {
CollisionState result_state;
// Don't apply direction for any type.
@@ -525,7 +525,7 @@ bool CharacterBody3D::_on_floor_if_snapped(bool p_was_on_floor, bool p_vel_dir_f
return false;
}
-void CharacterBody3D::_set_collision_direction(const PhysicsServer3D::MotionResult &p_result, CollisionState &r_state, CollisionState p_apply_state) {
+void CharacterBody3D::_set_collision_direction(const PS3DT::MotionResult &p_result, CollisionState &r_state, CollisionState p_apply_state) {
r_state.state = 0;
real_t wall_depth = -1.0;
@@ -538,7 +538,7 @@ void CharacterBody3D::_set_collision_direction(const PhysicsServer3D::MotionResu
Vector3 tmp_wall_col; // Avoid duplicate on average calculation.
for (int i = p_result.collision_count - 1; i >= 0; i--) {
- const PhysicsServer3D::MotionCollision &collision = p_result.collisions[i];
+ const PS3DT::MotionCollision &collision = p_result.collisions[i];
if (motion_mode == MOTION_MODE_GROUNDED) {
// Check if any collision is floor.
@@ -613,7 +613,7 @@ void CharacterBody3D::_set_collision_direction(const PhysicsServer3D::MotionResu
}
}
-void CharacterBody3D::_set_platform_data(const PhysicsServer3D::MotionCollision &p_collision) {
+void CharacterBody3D::_set_platform_data(const PS3DT::MotionCollision &p_collision) {
PhysicsDirectBodyState3D *bs = PhysicsServer3D::get_singleton()->body_get_direct_state(p_collision.collider);
if (bs == nullptr) {
return;
@@ -717,8 +717,8 @@ int CharacterBody3D::get_slide_collision_count() const {
return motion_results.size();
}
-PhysicsServer3D::MotionResult CharacterBody3D::get_slide_collision(int p_bounce) const {
- ERR_FAIL_INDEX_V(p_bounce, motion_results.size(), PhysicsServer3D::MotionResult());
+PS3DT::MotionResult CharacterBody3D::get_slide_collision(int p_bounce) const {
+ ERR_FAIL_INDEX_V(p_bounce, motion_results.size(), PS3DT::MotionResult());
return motion_results[p_bounce];
}
@@ -964,5 +964,5 @@ void CharacterBody3D::_validate_property(PropertyInfo &p_property) const {
}
CharacterBody3D::CharacterBody3D() :
- PhysicsBody3D(PhysicsServer3D::BODY_MODE_KINEMATIC) {
+ PhysicsBody3D(PS3DE::BODY_MODE_KINEMATIC) {
}
diff --git a/scene/3d/physics/character_body_3d.h b/scene/3d/physics/character_body_3d.h
index 34c70d648e7..17bec2a1e08 100644
--- a/scene/3d/physics/character_body_3d.h
+++ b/scene/3d/physics/character_body_3d.h
@@ -70,7 +70,7 @@ public:
virtual Vector3 get_linear_velocity() const override;
int get_slide_collision_count() const;
- PhysicsServer3D::MotionResult get_slide_collision(int p_bounce) const;
+ PS3DT::MotionResult get_slide_collision(int p_bounce) const;
void set_safe_margin(real_t p_margin);
real_t get_safe_margin() const;
@@ -161,7 +161,7 @@ private:
Vector3 previous_position;
Vector3 real_velocity;
- Vector<PhysicsServer3D::MotionResult> motion_results;
+ Vector<PS3DT::MotionResult> motion_results;
Vector<Ref<KinematicCollision3D>> slide_colliders;
void _move_and_slide_floating(double p_delta);
@@ -172,8 +172,8 @@ private:
const Vector3 &get_up_direction() const;
bool _on_floor_if_snapped(bool p_was_on_floor, bool p_vel_dir_facing_up);
void set_up_direction(const Vector3 &p_up_direction);
- void _set_collision_direction(const PhysicsServer3D::MotionResult &p_result, CollisionState &r_state, CollisionState p_apply_state = CollisionState(true, true, true));
- void _set_platform_data(const PhysicsServer3D::MotionCollision &p_collision);
+ void _set_collision_direction(const PS3DT::MotionResult &p_result, CollisionState &r_state, CollisionState p_apply_state = CollisionState(true, true, true));
+ void _set_platform_data(const PS3DT::MotionCollision &p_collision);
void _snap_on_floor(bool p_was_on_floor, bool p_vel_dir_facing_up);
protected:
diff --git a/scene/3d/physics/collision_object_3d.cpp b/scene/3d/physics/collision_object_3d.cpp
index 88cf223fad2..9481a54daac 100644
--- a/scene/3d/physics/collision_object_3d.cpp
+++ b/scene/3d/physics/collision_object_3d.cpp
@@ -65,7 +65,7 @@ void CollisionObject3D::_notification(int p_what) {
if (area) {
PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform());
} else {
- PhysicsServer3D::get_singleton()->body_set_state(rid, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_state(rid, PS3DE::BODY_STATE_TRANSFORM, get_global_transform());
}
bool disabled = !is_enabled();
@@ -101,7 +101,7 @@ void CollisionObject3D::_notification(int p_what) {
if (area) {
PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform());
} else {
- PhysicsServer3D::get_singleton()->body_set_state(rid, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_state(rid, PS3DE::BODY_STATE_TRANSFORM, get_global_transform());
}
_on_transform_changed();
@@ -257,8 +257,8 @@ void CollisionObject3D::_apply_disabled() {
} break;
case DISABLE_MODE_MAKE_STATIC: {
- if (!area && (body_mode != PhysicsServer3D::BODY_MODE_STATIC)) {
- PhysicsServer3D::get_singleton()->body_set_mode(rid, PhysicsServer3D::BODY_MODE_STATIC);
+ if (!area && (body_mode != PS3DE::BODY_MODE_STATIC)) {
+ PhysicsServer3D::get_singleton()->body_set_mode(rid, PS3DE::BODY_MODE_STATIC);
}
} break;
@@ -283,7 +283,7 @@ void CollisionObject3D::_apply_enabled() {
} break;
case DISABLE_MODE_MAKE_STATIC: {
- if (!area && (body_mode != PhysicsServer3D::BODY_MODE_STATIC)) {
+ if (!area && (body_mode != PS3DE::BODY_MODE_STATIC)) {
PhysicsServer3D::get_singleton()->body_set_mode(rid, body_mode);
}
} break;
@@ -309,7 +309,7 @@ void CollisionObject3D::_mouse_exit() {
emit_signal(SceneStringName(mouse_exited));
}
-void CollisionObject3D::set_body_mode(PhysicsServer3D::BodyMode p_mode) {
+void CollisionObject3D::set_body_mode(PS3DE::BodyMode p_mode) {
ERR_FAIL_COND(area);
if (body_mode == p_mode) {
diff --git a/scene/3d/physics/collision_object_3d.h b/scene/3d/physics/collision_object_3d.h
index c39a4cb342c..fb9e9bb7a1f 100644
--- a/scene/3d/physics/collision_object_3d.h
+++ b/scene/3d/physics/collision_object_3d.h
@@ -59,7 +59,7 @@ private:
DisableMode disable_mode = DISABLE_MODE_REMOVE;
- PhysicsServer3D::BodyMode body_mode = PhysicsServer3D::BODY_MODE_STATIC;
+ PS3DE::BodyMode body_mode = PS3DE::BODY_MODE_STATIC;
struct ShapeData {
ObjectID owner_id;
@@ -117,7 +117,7 @@ protected:
virtual void _mouse_enter();
virtual void _mouse_exit();
- void set_body_mode(PhysicsServer3D::BodyMode p_mode);
+ void set_body_mode(PS3DE::BodyMode p_mode);
virtual void _space_changed(const RID &p_new_space);
diff --git a/scene/3d/physics/joints/cone_twist_joint_3d.cpp b/scene/3d/physics/joints/cone_twist_joint_3d.cpp
index fe2bdd52215..a8e2091445c 100644
--- a/scene/3d/physics/joints/cone_twist_joint_3d.cpp
+++ b/scene/3d/physics/joints/cone_twist_joint_3d.cpp
@@ -55,7 +55,7 @@ void ConeTwistJoint3D::set_param(Param p_param, real_t p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
if (is_configured()) {
- PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(get_rid(), PhysicsServer3D::ConeTwistJointParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(get_rid(), PS3DE::ConeTwistJointParam(p_param), p_value);
}
update_gizmos();
@@ -84,7 +84,7 @@ void ConeTwistJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, Phys
PhysicsServer3D::get_singleton()->joint_make_cone_twist(p_joint, body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
for (int i = 0; i < PARAM_MAX; i++) {
- PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(p_joint, PhysicsServer3D::ConeTwistJointParam(i), params[i]);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(p_joint, PS3DE::ConeTwistJointParam(i), params[i]);
}
}
diff --git a/scene/3d/physics/joints/generic_6dof_joint_3d.cpp b/scene/3d/physics/joints/generic_6dof_joint_3d.cpp
index 386b70f7236..e5f1f51b4f1 100644
--- a/scene/3d/physics/joints/generic_6dof_joint_3d.cpp
+++ b/scene/3d/physics/joints/generic_6dof_joint_3d.cpp
@@ -230,7 +230,7 @@ void Generic6DOFJoint3D::set_param_x(Param p_param, real_t p_value) {
_warn_if_deprecated_param(p_param);
}
if (is_configured()) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_X, PS3DE::G6DOFJointAxisParam(p_param), p_value);
}
update_gizmos();
@@ -252,7 +252,7 @@ void Generic6DOFJoint3D::set_param_y(Param p_param, real_t p_value) {
_warn_if_deprecated_param(p_param);
}
if (is_configured()) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_Y, PS3DE::G6DOFJointAxisParam(p_param), p_value);
}
update_gizmos();
}
@@ -273,7 +273,7 @@ void Generic6DOFJoint3D::set_param_z(Param p_param, real_t p_value) {
_warn_if_deprecated_param(p_param);
}
if (is_configured()) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_Z, PS3DE::G6DOFJointAxisParam(p_param), p_value);
}
update_gizmos();
}
@@ -312,7 +312,7 @@ void Generic6DOFJoint3D::set_flag_x(Flag p_flag, bool p_enabled) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags_x[p_flag] = p_enabled;
if (is_configured()) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_rid(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_rid(), Vector3::AXIS_X, PS3DE::G6DOFJointAxisFlag(p_flag), p_enabled);
}
update_gizmos();
}
@@ -326,7 +326,7 @@ void Generic6DOFJoint3D::set_flag_y(Flag p_flag, bool p_enabled) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags_y[p_flag] = p_enabled;
if (is_configured()) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_rid(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_rid(), Vector3::AXIS_Y, PS3DE::G6DOFJointAxisFlag(p_flag), p_enabled);
}
update_gizmos();
}
@@ -340,7 +340,7 @@ void Generic6DOFJoint3D::set_flag_z(Flag p_flag, bool p_enabled) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags_z[p_flag] = p_enabled;
if (is_configured()) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_rid(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_rid(), Vector3::AXIS_Z, PS3DE::G6DOFJointAxisFlag(p_flag), p_enabled);
}
update_gizmos();
}
@@ -397,9 +397,9 @@ void Generic6DOFJoint3D::clear_angular_target_rotation() {
}
PhysicsServer3D *server = PhysicsServer3D::get_singleton();
- server->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_X, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, params_x[PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT]);
- server->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_Y, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, params_y[PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT]);
- server->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_Z, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, params_z[PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT]);
+ server->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_X, PS3DE::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, params_x[PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT]);
+ server->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_Y, PS3DE::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, params_y[PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT]);
+ server->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_Z, PS3DE::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, params_z[PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT]);
}
void Generic6DOFJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
@@ -424,19 +424,19 @@ void Generic6DOFJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, Ph
for (int i = 0; i < PARAM_MAX; i++) {
const Param param = static_cast<Param>(i);
if (_should_replay_param(Vector3::AXIS_X, param)) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(p_joint, Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(i), params_x[i]);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(p_joint, Vector3::AXIS_X, PS3DE::G6DOFJointAxisParam(i), params_x[i]);
}
if (_should_replay_param(Vector3::AXIS_Y, param)) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(p_joint, Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(i), params_y[i]);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(p_joint, Vector3::AXIS_Y, PS3DE::G6DOFJointAxisParam(i), params_y[i]);
}
if (_should_replay_param(Vector3::AXIS_Z, param)) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(p_joint, Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(i), params_z[i]);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(p_joint, Vector3::AXIS_Z, PS3DE::G6DOFJointAxisParam(i), params_z[i]);
}
}
for (int i = 0; i < FLAG_MAX; i++) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(p_joint, Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(i), flags_x[i]);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(p_joint, Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(i), flags_y[i]);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(p_joint, Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(i), flags_z[i]);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(p_joint, Vector3::AXIS_X, PS3DE::G6DOFJointAxisFlag(i), flags_x[i]);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(p_joint, Vector3::AXIS_Y, PS3DE::G6DOFJointAxisFlag(i), flags_y[i]);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(p_joint, Vector3::AXIS_Z, PS3DE::G6DOFJointAxisFlag(i), flags_z[i]);
}
if (has_angular_target_rotation) {
diff --git a/scene/3d/physics/joints/generic_6dof_joint_3d.h b/scene/3d/physics/joints/generic_6dof_joint_3d.h
index 04feb06b7f1..0e0ebc3286d 100644
--- a/scene/3d/physics/joints/generic_6dof_joint_3d.h
+++ b/scene/3d/physics/joints/generic_6dof_joint_3d.h
@@ -37,41 +37,41 @@ class Generic6DOFJoint3D : public Joint3D {
public:
enum Param {
- PARAM_LINEAR_LOWER_LIMIT = PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT,
- PARAM_LINEAR_UPPER_LIMIT = PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT,
- PARAM_LINEAR_LIMIT_SOFTNESS = PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS,
- PARAM_LINEAR_RESTITUTION = PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION,
- PARAM_LINEAR_DAMPING = PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING,
- PARAM_LINEAR_MOTOR_TARGET_VELOCITY = PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY,
- PARAM_LINEAR_MOTOR_FORCE_LIMIT = PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT,
- PARAM_LINEAR_SPRING_STIFFNESS = PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS,
- PARAM_LINEAR_SPRING_DAMPING = PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING,
- PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT = PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT,
- PARAM_ANGULAR_LOWER_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT,
- PARAM_ANGULAR_UPPER_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT,
- PARAM_ANGULAR_LIMIT_SOFTNESS = PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS,
- PARAM_ANGULAR_DAMPING = PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING,
- PARAM_ANGULAR_RESTITUTION = PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION,
- PARAM_ANGULAR_FORCE_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT,
- PARAM_ANGULAR_ERP = PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP,
- PARAM_ANGULAR_MOTOR_TARGET_VELOCITY = PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY,
- PARAM_ANGULAR_MOTOR_FORCE_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT,
- PARAM_ANGULAR_SPRING_STIFFNESS = PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS,
- PARAM_ANGULAR_SPRING_DAMPING = PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING,
- PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT,
- PARAM_LINEAR_DRIVE_FORCE_LIMIT = PhysicsServer3D::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT,
- PARAM_ANGULAR_DRIVE_TORQUE_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT,
- PARAM_MAX = PhysicsServer3D::G6DOF_JOINT_MAX,
+ PARAM_LINEAR_LOWER_LIMIT = PS3DE::G6DOF_JOINT_LINEAR_LOWER_LIMIT,
+ PARAM_LINEAR_UPPER_LIMIT = PS3DE::G6DOF_JOINT_LINEAR_UPPER_LIMIT,
+ PARAM_LINEAR_LIMIT_SOFTNESS = PS3DE::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS,
+ PARAM_LINEAR_RESTITUTION = PS3DE::G6DOF_JOINT_LINEAR_RESTITUTION,
+ PARAM_LINEAR_DAMPING = PS3DE::G6DOF_JOINT_LINEAR_DAMPING,
+ PARAM_LINEAR_MOTOR_TARGET_VELOCITY = PS3DE::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY,
+ PARAM_LINEAR_MOTOR_FORCE_LIMIT = PS3DE::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT,
+ PARAM_LINEAR_SPRING_STIFFNESS = PS3DE::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS,
+ PARAM_LINEAR_SPRING_DAMPING = PS3DE::G6DOF_JOINT_LINEAR_SPRING_DAMPING,
+ PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT = PS3DE::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT,
+ PARAM_ANGULAR_LOWER_LIMIT = PS3DE::G6DOF_JOINT_ANGULAR_LOWER_LIMIT,
+ PARAM_ANGULAR_UPPER_LIMIT = PS3DE::G6DOF_JOINT_ANGULAR_UPPER_LIMIT,
+ PARAM_ANGULAR_LIMIT_SOFTNESS = PS3DE::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS,
+ PARAM_ANGULAR_DAMPING = PS3DE::G6DOF_JOINT_ANGULAR_DAMPING,
+ PARAM_ANGULAR_RESTITUTION = PS3DE::G6DOF_JOINT_ANGULAR_RESTITUTION,
+ PARAM_ANGULAR_FORCE_LIMIT = PS3DE::G6DOF_JOINT_ANGULAR_FORCE_LIMIT,
+ PARAM_ANGULAR_ERP = PS3DE::G6DOF_JOINT_ANGULAR_ERP,
+ PARAM_ANGULAR_MOTOR_TARGET_VELOCITY = PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY,
+ PARAM_ANGULAR_MOTOR_FORCE_LIMIT = PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT,
+ PARAM_ANGULAR_SPRING_STIFFNESS = PS3DE::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS,
+ PARAM_ANGULAR_SPRING_DAMPING = PS3DE::G6DOF_JOINT_ANGULAR_SPRING_DAMPING,
+ PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT = PS3DE::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT,
+ PARAM_LINEAR_DRIVE_FORCE_LIMIT = PS3DE::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT,
+ PARAM_ANGULAR_DRIVE_TORQUE_LIMIT = PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT,
+ PARAM_MAX = PS3DE::G6DOF_JOINT_MAX,
};
enum Flag {
- FLAG_ENABLE_LINEAR_LIMIT = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT,
- FLAG_ENABLE_ANGULAR_LIMIT = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT,
- FLAG_ENABLE_LINEAR_SPRING = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING,
- FLAG_ENABLE_ANGULAR_SPRING = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING,
- FLAG_ENABLE_MOTOR = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR,
- FLAG_ENABLE_LINEAR_MOTOR = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR,
- FLAG_MAX = PhysicsServer3D::G6DOF_JOINT_FLAG_MAX
+ FLAG_ENABLE_LINEAR_LIMIT = PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT,
+ FLAG_ENABLE_ANGULAR_LIMIT = PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT,
+ FLAG_ENABLE_LINEAR_SPRING = PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING,
+ FLAG_ENABLE_ANGULAR_SPRING = PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING,
+ FLAG_ENABLE_MOTOR = PS3DE::G6DOF_JOINT_FLAG_ENABLE_MOTOR,
+ FLAG_ENABLE_LINEAR_MOTOR = PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR,
+ FLAG_MAX = PS3DE::G6DOF_JOINT_FLAG_MAX
};
protected:
diff --git a/scene/3d/physics/joints/hinge_joint_3d.cpp b/scene/3d/physics/joints/hinge_joint_3d.cpp
index d66cfc8026a..63ab74f5e98 100644
--- a/scene/3d/physics/joints/hinge_joint_3d.cpp
+++ b/scene/3d/physics/joints/hinge_joint_3d.cpp
@@ -71,7 +71,7 @@ void HingeJoint3D::set_param(Param p_param, real_t p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
if (is_configured()) {
- PhysicsServer3D::get_singleton()->hinge_joint_set_param(get_rid(), PhysicsServer3D::HingeJointParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(get_rid(), PS3DE::HingeJointParam(p_param), p_value);
}
update_gizmos();
@@ -86,7 +86,7 @@ void HingeJoint3D::set_flag(Flag p_flag, bool p_value) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags[p_flag] = p_value;
if (is_configured()) {
- PhysicsServer3D::get_singleton()->hinge_joint_set_flag(get_rid(), PhysicsServer3D::HingeJointFlag(p_flag), p_value);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_flag(get_rid(), PS3DE::HingeJointFlag(p_flag), p_value);
}
update_gizmos();
@@ -114,11 +114,11 @@ void HingeJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, PhysicsB
PhysicsServer3D::get_singleton()->joint_make_hinge(p_joint, body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
for (int i = 0; i < PARAM_MAX; i++) {
- PhysicsServer3D::get_singleton()->hinge_joint_set_param(p_joint, PhysicsServer3D::HingeJointParam(i), params[i]);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(p_joint, PS3DE::HingeJointParam(i), params[i]);
}
for (int i = 0; i < FLAG_MAX; i++) {
set_flag(Flag(i), flags[i]);
- PhysicsServer3D::get_singleton()->hinge_joint_set_flag(p_joint, PhysicsServer3D::HingeJointFlag(i), flags[i]);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_flag(p_joint, PS3DE::HingeJointFlag(i), flags[i]);
}
}
diff --git a/scene/3d/physics/joints/hinge_joint_3d.h b/scene/3d/physics/joints/hinge_joint_3d.h
index 84a5ca3e730..aad88278326 100644
--- a/scene/3d/physics/joints/hinge_joint_3d.h
+++ b/scene/3d/physics/joints/hinge_joint_3d.h
@@ -37,21 +37,21 @@ class HingeJoint3D : public Joint3D {
public:
enum Param {
- PARAM_BIAS = PhysicsServer3D::HINGE_JOINT_BIAS,
- PARAM_LIMIT_UPPER = PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER,
- PARAM_LIMIT_LOWER = PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER,
- PARAM_LIMIT_BIAS = PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS,
- PARAM_LIMIT_SOFTNESS = PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS,
- PARAM_LIMIT_RELAXATION = PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION,
- PARAM_MOTOR_TARGET_VELOCITY = PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY,
- PARAM_MOTOR_MAX_IMPULSE = PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE,
- PARAM_MAX = PhysicsServer3D::HINGE_JOINT_MAX
+ PARAM_BIAS = PS3DE::HINGE_JOINT_BIAS,
+ PARAM_LIMIT_UPPER = PS3DE::HINGE_JOINT_LIMIT_UPPER,
+ PARAM_LIMIT_LOWER = PS3DE::HINGE_JOINT_LIMIT_LOWER,
+ PARAM_LIMIT_BIAS = PS3DE::HINGE_JOINT_LIMIT_BIAS,
+ PARAM_LIMIT_SOFTNESS = PS3DE::HINGE_JOINT_LIMIT_SOFTNESS,
+ PARAM_LIMIT_RELAXATION = PS3DE::HINGE_JOINT_LIMIT_RELAXATION,
+ PARAM_MOTOR_TARGET_VELOCITY = PS3DE::HINGE_JOINT_MOTOR_TARGET_VELOCITY,
+ PARAM_MOTOR_MAX_IMPULSE = PS3DE::HINGE_JOINT_MOTOR_MAX_IMPULSE,
+ PARAM_MAX = PS3DE::HINGE_JOINT_MAX
};
enum Flag {
- FLAG_USE_LIMIT = PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT,
- FLAG_ENABLE_MOTOR = PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR,
- FLAG_MAX = PhysicsServer3D::HINGE_JOINT_FLAG_MAX
+ FLAG_USE_LIMIT = PS3DE::HINGE_JOINT_FLAG_USE_LIMIT,
+ FLAG_ENABLE_MOTOR = PS3DE::HINGE_JOINT_FLAG_ENABLE_MOTOR,
+ FLAG_MAX = PS3DE::HINGE_JOINT_FLAG_MAX
};
protected:
diff --git a/scene/3d/physics/joints/pin_joint_3d.cpp b/scene/3d/physics/joints/pin_joint_3d.cpp
index c9311cfabf3..90288411725 100644
--- a/scene/3d/physics/joints/pin_joint_3d.cpp
+++ b/scene/3d/physics/joints/pin_joint_3d.cpp
@@ -49,7 +49,7 @@ void PinJoint3D::set_param(Param p_param, real_t p_value) {
ERR_FAIL_INDEX(p_param, 3);
params[p_param] = p_value;
if (is_configured()) {
- PhysicsServer3D::get_singleton()->pin_joint_set_param(get_rid(), PhysicsServer3D::PinJointParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(get_rid(), PS3DE::PinJointParam(p_param), p_value);
}
}
@@ -71,7 +71,7 @@ void PinJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, PhysicsBod
PhysicsServer3D::get_singleton()->joint_make_pin(p_joint, body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
for (int i = 0; i < 3; i++) {
- PhysicsServer3D::get_singleton()->pin_joint_set_param(p_joint, PhysicsServer3D::PinJointParam(i), params[i]);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(p_joint, PS3DE::PinJointParam(i), params[i]);
}
}
diff --git a/scene/3d/physics/joints/pin_joint_3d.h b/scene/3d/physics/joints/pin_joint_3d.h
index fad22a25475..ad65abd7d6e 100644
--- a/scene/3d/physics/joints/pin_joint_3d.h
+++ b/scene/3d/physics/joints/pin_joint_3d.h
@@ -37,9 +37,9 @@ class PinJoint3D : public Joint3D {
public:
enum Param {
- PARAM_BIAS = PhysicsServer3D::PIN_JOINT_BIAS,
- PARAM_DAMPING = PhysicsServer3D::PIN_JOINT_DAMPING,
- PARAM_IMPULSE_CLAMP = PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP
+ PARAM_BIAS = PS3DE::PIN_JOINT_BIAS,
+ PARAM_DAMPING = PS3DE::PIN_JOINT_DAMPING,
+ PARAM_IMPULSE_CLAMP = PS3DE::PIN_JOINT_IMPULSE_CLAMP
};
protected:
diff --git a/scene/3d/physics/joints/slider_joint_3d.cpp b/scene/3d/physics/joints/slider_joint_3d.cpp
index 450776522af..ca25d7f8112 100644
--- a/scene/3d/physics/joints/slider_joint_3d.cpp
+++ b/scene/3d/physics/joints/slider_joint_3d.cpp
@@ -91,7 +91,7 @@ void SliderJoint3D::set_param(Param p_param, real_t p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
if (is_configured()) {
- PhysicsServer3D::get_singleton()->slider_joint_set_param(get_rid(), PhysicsServer3D::SliderJointParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(get_rid(), PS3DE::SliderJointParam(p_param), p_value);
}
update_gizmos();
}
@@ -118,7 +118,7 @@ void SliderJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, Physics
PhysicsServer3D::get_singleton()->joint_make_slider(p_joint, body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
for (int i = 0; i < PARAM_MAX; i++) {
- PhysicsServer3D::get_singleton()->slider_joint_set_param(p_joint, PhysicsServer3D::SliderJointParam(i), params[i]);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(p_joint, PS3DE::SliderJointParam(i), params[i]);
}
}
diff --git a/scene/3d/physics/joints/slider_joint_3d.h b/scene/3d/physics/joints/slider_joint_3d.h
index 5d4c767ecd9..db64fc6e3ec 100644
--- a/scene/3d/physics/joints/slider_joint_3d.h
+++ b/scene/3d/physics/joints/slider_joint_3d.h
@@ -37,30 +37,30 @@ class SliderJoint3D : public Joint3D {
public:
enum Param {
- PARAM_LINEAR_LIMIT_UPPER = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER,
- PARAM_LINEAR_LIMIT_LOWER = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER,
- PARAM_LINEAR_LIMIT_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS,
- PARAM_LINEAR_LIMIT_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION,
- PARAM_LINEAR_LIMIT_DAMPING = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING,
- PARAM_LINEAR_MOTION_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS,
- PARAM_LINEAR_MOTION_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION,
- PARAM_LINEAR_MOTION_DAMPING = PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING,
- PARAM_LINEAR_ORTHOGONAL_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS,
- PARAM_LINEAR_ORTHOGONAL_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION,
- PARAM_LINEAR_ORTHOGONAL_DAMPING = PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING,
+ PARAM_LINEAR_LIMIT_UPPER = PS3DE::SLIDER_JOINT_LINEAR_LIMIT_UPPER,
+ PARAM_LINEAR_LIMIT_LOWER = PS3DE::SLIDER_JOINT_LINEAR_LIMIT_LOWER,
+ PARAM_LINEAR_LIMIT_SOFTNESS = PS3DE::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS,
+ PARAM_LINEAR_LIMIT_RESTITUTION = PS3DE::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION,
+ PARAM_LINEAR_LIMIT_DAMPING = PS3DE::SLIDER_JOINT_LINEAR_LIMIT_DAMPING,
+ PARAM_LINEAR_MOTION_SOFTNESS = PS3DE::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS,
+ PARAM_LINEAR_MOTION_RESTITUTION = PS3DE::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION,
+ PARAM_LINEAR_MOTION_DAMPING = PS3DE::SLIDER_JOINT_LINEAR_MOTION_DAMPING,
+ PARAM_LINEAR_ORTHOGONAL_SOFTNESS = PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS,
+ PARAM_LINEAR_ORTHOGONAL_RESTITUTION = PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION,
+ PARAM_LINEAR_ORTHOGONAL_DAMPING = PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING,
- PARAM_ANGULAR_LIMIT_UPPER = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER,
- PARAM_ANGULAR_LIMIT_LOWER = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER,
- PARAM_ANGULAR_LIMIT_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS,
- PARAM_ANGULAR_LIMIT_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION,
- PARAM_ANGULAR_LIMIT_DAMPING = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING,
- PARAM_ANGULAR_MOTION_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS,
- PARAM_ANGULAR_MOTION_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION,
- PARAM_ANGULAR_MOTION_DAMPING = PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING,
- PARAM_ANGULAR_ORTHOGONAL_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS,
- PARAM_ANGULAR_ORTHOGONAL_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION,
- PARAM_ANGULAR_ORTHOGONAL_DAMPING = PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING,
- PARAM_MAX = PhysicsServer3D::SLIDER_JOINT_MAX
+ PARAM_ANGULAR_LIMIT_UPPER = PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_UPPER,
+ PARAM_ANGULAR_LIMIT_LOWER = PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_LOWER,
+ PARAM_ANGULAR_LIMIT_SOFTNESS = PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS,
+ PARAM_ANGULAR_LIMIT_RESTITUTION = PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION,
+ PARAM_ANGULAR_LIMIT_DAMPING = PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING,
+ PARAM_ANGULAR_MOTION_SOFTNESS = PS3DE::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS,
+ PARAM_ANGULAR_MOTION_RESTITUTION = PS3DE::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION,
+ PARAM_ANGULAR_MOTION_DAMPING = PS3DE::SLIDER_JOINT_ANGULAR_MOTION_DAMPING,
+ PARAM_ANGULAR_ORTHOGONAL_SOFTNESS = PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS,
+ PARAM_ANGULAR_ORTHOGONAL_RESTITUTION = PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION,
+ PARAM_ANGULAR_ORTHOGONAL_DAMPING = PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING,
+ PARAM_MAX = PS3DE::SLIDER_JOINT_MAX
};
diff --git a/scene/3d/physics/kinematic_collision_3d.h b/scene/3d/physics/kinematic_collision_3d.h
index 1216f42a12e..53248be3641 100644
--- a/scene/3d/physics/kinematic_collision_3d.h
+++ b/scene/3d/physics/kinematic_collision_3d.h
@@ -31,7 +31,7 @@
#pragma once
#include "core/object/ref_counted.h"
-#include "servers/physics_3d/physics_server_3d.h"
+#include "servers/physics_3d/physics_server_3d_types.h"
class KinematicCollision3D : public RefCounted {
GDCLASS(KinematicCollision3D, RefCounted);
@@ -39,7 +39,7 @@ class KinematicCollision3D : public RefCounted {
ObjectID owner_id;
friend class PhysicsBody3D;
friend class CharacterBody3D;
- PhysicsServer3D::MotionResult result;
+ PS3DT::MotionResult result;
protected:
static void _bind_methods();
diff --git a/scene/3d/physics/physical_bone_3d.cpp b/scene/3d/physics/physical_bone_3d.cpp
index 6a5ef65034a..ef348d97caf 100644
--- a/scene/3d/physics/physical_bone_3d.cpp
+++ b/scene/3d/physics/physical_bone_3d.cpp
@@ -60,7 +60,7 @@ void PhysicalBone3D::apply_impulse(const Vector3 &p_impulse, const Vector3 &p_po
void PhysicalBone3D::set_linear_velocity(const Vector3 &p_velocity) {
linear_velocity = p_velocity;
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
}
Vector3 PhysicalBone3D::get_linear_velocity() const {
@@ -69,7 +69,7 @@ Vector3 PhysicalBone3D::get_linear_velocity() const {
void PhysicalBone3D::set_angular_velocity(const Vector3 &p_velocity) {
angular_velocity = p_velocity;
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
}
Vector3 PhysicalBone3D::get_angular_velocity() const {
@@ -114,23 +114,23 @@ bool PhysicalBone3D::PinJointData::_set(const StringName &p_name, const Variant
return true;
}
- bool is_valid_pin = j.is_valid() && PhysicsServer3D::get_singleton()->joint_get_type(j) == PhysicsServer3D::JOINT_TYPE_PIN;
+ bool is_valid_pin = j.is_valid() && PhysicsServer3D::get_singleton()->joint_get_type(j) == PS3DE::JOINT_TYPE_PIN;
if ("joint_constraints/bias" == p_name) {
bias = p_value;
if (is_valid_pin) {
- PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_BIAS, bias);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PS3DE::PIN_JOINT_BIAS, bias);
}
} else if ("joint_constraints/damping" == p_name) {
damping = p_value;
if (is_valid_pin) {
- PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_DAMPING, damping);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PS3DE::PIN_JOINT_DAMPING, damping);
}
} else if ("joint_constraints/impulse_clamp" == p_name) {
impulse_clamp = p_value;
if (is_valid_pin) {
- PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP, impulse_clamp);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PS3DE::PIN_JOINT_IMPULSE_CLAMP, impulse_clamp);
}
} else {
@@ -171,35 +171,35 @@ bool PhysicalBone3D::ConeJointData::_set(const StringName &p_name, const Variant
return true;
}
- bool is_valid_cone = j.is_valid() && PhysicsServer3D::get_singleton()->joint_get_type(j) == PhysicsServer3D::JOINT_TYPE_CONE_TWIST;
+ bool is_valid_cone = j.is_valid() && PhysicsServer3D::get_singleton()->joint_get_type(j) == PS3DE::JOINT_TYPE_CONE_TWIST;
if ("joint_constraints/swing_span" == p_name) {
swing_span = Math::deg_to_rad(real_t(p_value));
if (is_valid_cone) {
- PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN, swing_span);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PS3DE::CONE_TWIST_JOINT_SWING_SPAN, swing_span);
}
} else if ("joint_constraints/twist_span" == p_name) {
twist_span = Math::deg_to_rad(real_t(p_value));
if (is_valid_cone) {
- PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN, twist_span);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PS3DE::CONE_TWIST_JOINT_TWIST_SPAN, twist_span);
}
} else if ("joint_constraints/bias" == p_name) {
bias = p_value;
if (is_valid_cone) {
- PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_BIAS, bias);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PS3DE::CONE_TWIST_JOINT_BIAS, bias);
}
} else if ("joint_constraints/softness" == p_name) {
softness = p_value;
if (is_valid_cone) {
- PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS, softness);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PS3DE::CONE_TWIST_JOINT_SOFTNESS, softness);
}
} else if ("joint_constraints/relaxation" == p_name) {
relaxation = p_value;
if (is_valid_cone) {
- PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION, relaxation);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PS3DE::CONE_TWIST_JOINT_RELAXATION, relaxation);
}
} else {
@@ -246,41 +246,41 @@ bool PhysicalBone3D::HingeJointData::_set(const StringName &p_name, const Varian
return true;
}
- bool is_valid_hinge = j.is_valid() && PhysicsServer3D::get_singleton()->joint_get_type(j) == PhysicsServer3D::JOINT_TYPE_HINGE;
+ bool is_valid_hinge = j.is_valid() && PhysicsServer3D::get_singleton()->joint_get_type(j) == PS3DE::JOINT_TYPE_HINGE;
if ("joint_constraints/angular_limit_enabled" == p_name) {
angular_limit_enabled = p_value;
if (is_valid_hinge) {
- PhysicsServer3D::get_singleton()->hinge_joint_set_flag(j, PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT, angular_limit_enabled);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_flag(j, PS3DE::HINGE_JOINT_FLAG_USE_LIMIT, angular_limit_enabled);
}
} else if ("joint_constraints/angular_limit_upper" == p_name) {
angular_limit_upper = Math::deg_to_rad(real_t(p_value));
if (is_valid_hinge) {
- PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER, angular_limit_upper);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PS3DE::HINGE_JOINT_LIMIT_UPPER, angular_limit_upper);
}
} else if ("joint_constraints/angular_limit_lower" == p_name) {
angular_limit_lower = Math::deg_to_rad(real_t(p_value));
if (is_valid_hinge) {
- PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER, angular_limit_lower);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PS3DE::HINGE_JOINT_LIMIT_LOWER, angular_limit_lower);
}
} else if ("joint_constraints/angular_limit_bias" == p_name) {
angular_limit_bias = p_value;
if (is_valid_hinge) {
- PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS, angular_limit_bias);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PS3DE::HINGE_JOINT_LIMIT_BIAS, angular_limit_bias);
}
} else if ("joint_constraints/angular_limit_softness" == p_name) {
angular_limit_softness = p_value;
if (is_valid_hinge) {
- PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS, angular_limit_softness);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PS3DE::HINGE_JOINT_LIMIT_SOFTNESS, angular_limit_softness);
}
} else if ("joint_constraints/angular_limit_relaxation" == p_name) {
angular_limit_relaxation = p_value;
if (is_valid_hinge) {
- PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION, angular_limit_relaxation);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PS3DE::HINGE_JOINT_LIMIT_RELAXATION, angular_limit_relaxation);
}
} else {
@@ -330,65 +330,65 @@ bool PhysicalBone3D::SliderJointData::_set(const StringName &p_name, const Varia
return true;
}
- bool is_valid_slider = j.is_valid() && PhysicsServer3D::get_singleton()->joint_get_type(j) == PhysicsServer3D::JOINT_TYPE_SLIDER;
+ bool is_valid_slider = j.is_valid() && PhysicsServer3D::get_singleton()->joint_get_type(j) == PS3DE::JOINT_TYPE_SLIDER;
if ("joint_constraints/linear_limit_upper" == p_name) {
linear_limit_upper = p_value;
if (is_valid_slider) {
- PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER, linear_limit_upper);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PS3DE::SLIDER_JOINT_LINEAR_LIMIT_UPPER, linear_limit_upper);
}
} else if ("joint_constraints/linear_limit_lower" == p_name) {
linear_limit_lower = p_value;
if (is_valid_slider) {
- PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER, linear_limit_lower);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PS3DE::SLIDER_JOINT_LINEAR_LIMIT_LOWER, linear_limit_lower);
}
} else if ("joint_constraints/linear_limit_softness" == p_name) {
linear_limit_softness = p_value;
if (is_valid_slider) {
- PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, linear_limit_softness);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PS3DE::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, linear_limit_softness);
}
} else if ("joint_constraints/linear_limit_restitution" == p_name) {
linear_limit_restitution = p_value;
if (is_valid_slider) {
- PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, linear_limit_restitution);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PS3DE::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, linear_limit_restitution);
}
} else if ("joint_constraints/linear_limit_damping" == p_name) {
linear_limit_damping = p_value;
if (is_valid_slider) {
- PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, linear_limit_restitution);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PS3DE::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, linear_limit_restitution);
}
} else if ("joint_constraints/angular_limit_upper" == p_name) {
angular_limit_upper = Math::deg_to_rad(real_t(p_value));
if (is_valid_slider) {
- PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, angular_limit_upper);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, angular_limit_upper);
}
} else if ("joint_constraints/angular_limit_lower" == p_name) {
angular_limit_lower = Math::deg_to_rad(real_t(p_value));
if (is_valid_slider) {
- PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, angular_limit_lower);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, angular_limit_lower);
}
} else if ("joint_constraints/angular_limit_softness" == p_name) {
angular_limit_softness = p_value;
if (is_valid_slider) {
- PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
}
} else if ("joint_constraints/angular_limit_restitution" == p_name) {
angular_limit_restitution = p_value;
if (is_valid_slider) {
- PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
}
} else if ("joint_constraints/angular_limit_damping" == p_name) {
angular_limit_damping = p_value;
if (is_valid_slider) {
- PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, angular_limit_damping);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, angular_limit_damping);
}
} else {
@@ -472,131 +472,131 @@ bool PhysicalBone3D::SixDOFJointData::_set(const StringName &p_name, const Varia
}
String var_name = path.get_slicec('/', 2);
- bool is_valid_6dof = j.is_valid() && PhysicsServer3D::get_singleton()->joint_get_type(j) == PhysicsServer3D::JOINT_TYPE_6DOF;
+ bool is_valid_6dof = j.is_valid() && PhysicsServer3D::get_singleton()->joint_get_type(j) == PS3DE::JOINT_TYPE_6DOF;
if ("linear_limit_enabled" == var_name) {
axis_data[axis].linear_limit_enabled = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, axis_data[axis].linear_limit_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, axis_data[axis].linear_limit_enabled);
}
} else if ("linear_limit_upper" == var_name) {
axis_data[axis].linear_limit_upper = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT, axis_data[axis].linear_limit_upper);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_LINEAR_UPPER_LIMIT, axis_data[axis].linear_limit_upper);
}
} else if ("linear_limit_lower" == var_name) {
axis_data[axis].linear_limit_lower = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT, axis_data[axis].linear_limit_lower);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_LINEAR_LOWER_LIMIT, axis_data[axis].linear_limit_lower);
}
} else if ("linear_limit_softness" == var_name) {
axis_data[axis].linear_limit_softness = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, axis_data[axis].linear_limit_softness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, axis_data[axis].linear_limit_softness);
}
} else if ("linear_spring_enabled" == var_name) {
axis_data[axis].linear_spring_enabled = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, axis_data[axis].linear_spring_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, axis_data[axis].linear_spring_enabled);
}
} else if ("linear_spring_stiffness" == var_name) {
axis_data[axis].linear_spring_stiffness = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, axis_data[axis].linear_spring_stiffness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, axis_data[axis].linear_spring_stiffness);
}
} else if ("linear_spring_damping" == var_name) {
axis_data[axis].linear_spring_damping = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING, axis_data[axis].linear_spring_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_LINEAR_SPRING_DAMPING, axis_data[axis].linear_spring_damping);
}
} else if ("linear_equilibrium_point" == var_name) {
axis_data[axis].linear_equilibrium_point = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].linear_equilibrium_point);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].linear_equilibrium_point);
}
} else if ("linear_restitution" == var_name) {
axis_data[axis].linear_restitution = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION, axis_data[axis].linear_restitution);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_LINEAR_RESTITUTION, axis_data[axis].linear_restitution);
}
} else if ("linear_damping" == var_name) {
axis_data[axis].linear_damping = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING, axis_data[axis].linear_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_LINEAR_DAMPING, axis_data[axis].linear_damping);
}
} else if ("angular_limit_enabled" == var_name) {
axis_data[axis].angular_limit_enabled = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, axis_data[axis].angular_limit_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, axis_data[axis].angular_limit_enabled);
}
} else if ("angular_limit_upper" == var_name) {
axis_data[axis].angular_limit_upper = Math::deg_to_rad(real_t(p_value));
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, axis_data[axis].angular_limit_upper);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, axis_data[axis].angular_limit_upper);
}
} else if ("angular_limit_lower" == var_name) {
axis_data[axis].angular_limit_lower = Math::deg_to_rad(real_t(p_value));
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, axis_data[axis].angular_limit_lower);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, axis_data[axis].angular_limit_lower);
}
} else if ("angular_limit_softness" == var_name) {
axis_data[axis].angular_limit_softness = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, axis_data[axis].angular_limit_softness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, axis_data[axis].angular_limit_softness);
}
} else if ("angular_restitution" == var_name) {
axis_data[axis].angular_restitution = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION, axis_data[axis].angular_restitution);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_ANGULAR_RESTITUTION, axis_data[axis].angular_restitution);
}
} else if ("angular_damping" == var_name) {
axis_data[axis].angular_damping = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING, axis_data[axis].angular_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_ANGULAR_DAMPING, axis_data[axis].angular_damping);
}
} else if ("erp" == var_name) {
axis_data[axis].erp = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP, axis_data[axis].erp);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_ANGULAR_ERP, axis_data[axis].erp);
}
} else if ("angular_spring_enabled" == var_name) {
axis_data[axis].angular_spring_enabled = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, axis_data[axis].angular_spring_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, axis_data[axis].angular_spring_enabled);
}
} else if ("angular_spring_stiffness" == var_name) {
axis_data[axis].angular_spring_stiffness = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, axis_data[axis].angular_spring_stiffness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, axis_data[axis].angular_spring_stiffness);
}
} else if ("angular_spring_damping" == var_name) {
axis_data[axis].angular_spring_damping = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, axis_data[axis].angular_spring_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, axis_data[axis].angular_spring_damping);
}
} else if ("angular_equilibrium_point" == var_name) {
axis_data[axis].angular_equilibrium_point = p_value;
if (is_valid_6dof) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].angular_equilibrium_point);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PS3DE::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].angular_equilibrium_point);
}
} else {
@@ -816,7 +816,7 @@ void PhysicalBone3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) {
if (new_transform != old_transform) {
// Update the physics server with the new transform, to prevent it from being overwritten at the sync below.
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_TRANSFORM, new_transform);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_TRANSFORM, new_transform);
}
}
@@ -968,72 +968,72 @@ void PhysicalBone3D::_reload_joint() {
case JOINT_TYPE_PIN: {
PhysicsServer3D::get_singleton()->joint_make_pin(joint, body_a->get_rid(), local_a.origin, get_rid(), joint_offset.origin);
const PinJointData *pjd(static_cast<const PinJointData *>(joint_data));
- PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PhysicsServer3D::PIN_JOINT_BIAS, pjd->bias);
- PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PhysicsServer3D::PIN_JOINT_DAMPING, pjd->damping);
- PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP, pjd->impulse_clamp);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PS3DE::PIN_JOINT_BIAS, pjd->bias);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PS3DE::PIN_JOINT_DAMPING, pjd->damping);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PS3DE::PIN_JOINT_IMPULSE_CLAMP, pjd->impulse_clamp);
} break;
case JOINT_TYPE_CONE: {
PhysicsServer3D::get_singleton()->joint_make_cone_twist(joint, body_a->get_rid(), local_a, get_rid(), joint_offset);
const ConeJointData *cjd(static_cast<const ConeJointData *>(joint_data));
- PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN, cjd->swing_span);
- PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN, cjd->twist_span);
- PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_BIAS, cjd->bias);
- PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS, cjd->softness);
- PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION, cjd->relaxation);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PS3DE::CONE_TWIST_JOINT_SWING_SPAN, cjd->swing_span);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PS3DE::CONE_TWIST_JOINT_TWIST_SPAN, cjd->twist_span);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PS3DE::CONE_TWIST_JOINT_BIAS, cjd->bias);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PS3DE::CONE_TWIST_JOINT_SOFTNESS, cjd->softness);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PS3DE::CONE_TWIST_JOINT_RELAXATION, cjd->relaxation);
} break;
case JOINT_TYPE_HINGE: {
PhysicsServer3D::get_singleton()->joint_make_hinge(joint, body_a->get_rid(), local_a, get_rid(), joint_offset);
const HingeJointData *hjd(static_cast<const HingeJointData *>(joint_data));
- PhysicsServer3D::get_singleton()->hinge_joint_set_flag(joint, PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT, hjd->angular_limit_enabled);
- PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER, hjd->angular_limit_upper);
- PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER, hjd->angular_limit_lower);
- PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS, hjd->angular_limit_bias);
- PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS, hjd->angular_limit_softness);
- PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION, hjd->angular_limit_relaxation);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_flag(joint, PS3DE::HINGE_JOINT_FLAG_USE_LIMIT, hjd->angular_limit_enabled);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PS3DE::HINGE_JOINT_LIMIT_UPPER, hjd->angular_limit_upper);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PS3DE::HINGE_JOINT_LIMIT_LOWER, hjd->angular_limit_lower);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PS3DE::HINGE_JOINT_LIMIT_BIAS, hjd->angular_limit_bias);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PS3DE::HINGE_JOINT_LIMIT_SOFTNESS, hjd->angular_limit_softness);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PS3DE::HINGE_JOINT_LIMIT_RELAXATION, hjd->angular_limit_relaxation);
} break;
case JOINT_TYPE_SLIDER: {
PhysicsServer3D::get_singleton()->joint_make_slider(joint, body_a->get_rid(), local_a, get_rid(), joint_offset);
const SliderJointData *sjd(static_cast<const SliderJointData *>(joint_data));
- PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER, sjd->linear_limit_upper);
- PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER, sjd->linear_limit_lower);
- PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, sjd->linear_limit_softness);
- PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, sjd->linear_limit_restitution);
- PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, sjd->linear_limit_restitution);
- PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, sjd->angular_limit_upper);
- PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, sjd->angular_limit_lower);
- PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, sjd->angular_limit_softness);
- PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, sjd->angular_limit_softness);
- PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, sjd->angular_limit_damping);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PS3DE::SLIDER_JOINT_LINEAR_LIMIT_UPPER, sjd->linear_limit_upper);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PS3DE::SLIDER_JOINT_LINEAR_LIMIT_LOWER, sjd->linear_limit_lower);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PS3DE::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, sjd->linear_limit_softness);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PS3DE::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, sjd->linear_limit_restitution);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PS3DE::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, sjd->linear_limit_restitution);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, sjd->angular_limit_upper);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, sjd->angular_limit_lower);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, sjd->angular_limit_softness);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, sjd->angular_limit_softness);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, sjd->angular_limit_damping);
} break;
case JOINT_TYPE_6DOF: {
PhysicsServer3D::get_singleton()->joint_make_generic_6dof(joint, body_a->get_rid(), local_a, get_rid(), joint_offset);
const SixDOFJointData *g6dofjd(static_cast<const SixDOFJointData *>(joint_data));
for (int axis = 0; axis < 3; ++axis) {
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, g6dofjd->axis_data[axis].linear_limit_enabled);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT, g6dofjd->axis_data[axis].linear_limit_upper);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT, g6dofjd->axis_data[axis].linear_limit_lower);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, g6dofjd->axis_data[axis].linear_limit_softness);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, g6dofjd->axis_data[axis].linear_spring_enabled);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, g6dofjd->axis_data[axis].linear_spring_stiffness);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING, g6dofjd->axis_data[axis].linear_spring_damping);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, g6dofjd->axis_data[axis].linear_equilibrium_point);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION, g6dofjd->axis_data[axis].linear_restitution);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING, g6dofjd->axis_data[axis].linear_damping);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, g6dofjd->axis_data[axis].angular_limit_enabled);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, g6dofjd->axis_data[axis].angular_limit_upper);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, g6dofjd->axis_data[axis].angular_limit_lower);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, g6dofjd->axis_data[axis].angular_limit_softness);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION, g6dofjd->axis_data[axis].angular_restitution);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING, g6dofjd->axis_data[axis].angular_damping);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP, g6dofjd->axis_data[axis].erp);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, g6dofjd->axis_data[axis].angular_spring_enabled);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, g6dofjd->axis_data[axis].angular_spring_stiffness);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, g6dofjd->axis_data[axis].angular_spring_damping);
- PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, g6dofjd->axis_data[axis].angular_equilibrium_point);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, g6dofjd->axis_data[axis].linear_limit_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_LINEAR_UPPER_LIMIT, g6dofjd->axis_data[axis].linear_limit_upper);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_LINEAR_LOWER_LIMIT, g6dofjd->axis_data[axis].linear_limit_lower);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, g6dofjd->axis_data[axis].linear_limit_softness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, g6dofjd->axis_data[axis].linear_spring_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, g6dofjd->axis_data[axis].linear_spring_stiffness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_LINEAR_SPRING_DAMPING, g6dofjd->axis_data[axis].linear_spring_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, g6dofjd->axis_data[axis].linear_equilibrium_point);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_LINEAR_RESTITUTION, g6dofjd->axis_data[axis].linear_restitution);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_LINEAR_DAMPING, g6dofjd->axis_data[axis].linear_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, g6dofjd->axis_data[axis].angular_limit_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, g6dofjd->axis_data[axis].angular_limit_upper);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, g6dofjd->axis_data[axis].angular_limit_lower);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, g6dofjd->axis_data[axis].angular_limit_softness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_ANGULAR_RESTITUTION, g6dofjd->axis_data[axis].angular_restitution);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_ANGULAR_DAMPING, g6dofjd->axis_data[axis].angular_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_ANGULAR_ERP, g6dofjd->axis_data[axis].erp);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, g6dofjd->axis_data[axis].angular_spring_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, g6dofjd->axis_data[axis].angular_spring_stiffness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, g6dofjd->axis_data[axis].angular_spring_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PS3DE::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, g6dofjd->axis_data[axis].angular_equilibrium_point);
}
} break;
@@ -1198,7 +1198,7 @@ const String &PhysicalBone3D::get_bone_name() const {
void PhysicalBone3D::set_mass(real_t p_mass) {
ERR_FAIL_COND(p_mass <= 0);
mass = p_mass;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_MASS, mass);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_MASS, mass);
}
real_t PhysicalBone3D::get_mass() const {
@@ -1209,7 +1209,7 @@ void PhysicalBone3D::set_friction(real_t p_friction) {
ERR_FAIL_COND(p_friction < 0 || p_friction > 1);
friction = p_friction;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, friction);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_FRICTION, friction);
}
real_t PhysicalBone3D::get_friction() const {
@@ -1220,7 +1220,7 @@ void PhysicalBone3D::set_bounce(real_t p_bounce) {
ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1);
bounce = p_bounce;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, bounce);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_BOUNCE, bounce);
}
real_t PhysicalBone3D::get_bounce() const {
@@ -1229,7 +1229,7 @@ real_t PhysicalBone3D::get_bounce() const {
void PhysicalBone3D::set_gravity_scale(real_t p_gravity_scale) {
gravity_scale = p_gravity_scale;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
}
real_t PhysicalBone3D::get_gravity_scale() const {
@@ -1238,7 +1238,7 @@ real_t PhysicalBone3D::get_gravity_scale() const {
void PhysicalBone3D::set_linear_damp_mode(DampMode p_mode) {
linear_damp_mode = p_mode;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_LINEAR_DAMP_MODE, linear_damp_mode);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_LINEAR_DAMP_MODE, linear_damp_mode);
}
PhysicalBone3D::DampMode PhysicalBone3D::get_linear_damp_mode() const {
@@ -1247,7 +1247,7 @@ PhysicalBone3D::DampMode PhysicalBone3D::get_linear_damp_mode() const {
void PhysicalBone3D::set_angular_damp_mode(DampMode p_mode) {
angular_damp_mode = p_mode;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP_MODE, angular_damp_mode);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_ANGULAR_DAMP_MODE, angular_damp_mode);
}
PhysicalBone3D::DampMode PhysicalBone3D::get_angular_damp_mode() const {
@@ -1258,7 +1258,7 @@ void PhysicalBone3D::set_linear_damp(real_t p_linear_damp) {
ERR_FAIL_COND(p_linear_damp < 0);
linear_damp = p_linear_damp;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_LINEAR_DAMP, linear_damp);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_LINEAR_DAMP, linear_damp);
}
real_t PhysicalBone3D::get_linear_damp() const {
@@ -1269,7 +1269,7 @@ void PhysicalBone3D::set_angular_damp(real_t p_angular_damp) {
ERR_FAIL_COND(p_angular_damp < 0);
angular_damp = p_angular_damp;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP, angular_damp);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_ANGULAR_DAMP, angular_damp);
}
real_t PhysicalBone3D::get_angular_damp() const {
@@ -1278,7 +1278,7 @@ real_t PhysicalBone3D::get_angular_damp() const {
void PhysicalBone3D::set_can_sleep(bool p_active) {
can_sleep = p_active;
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_CAN_SLEEP, p_active);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_CAN_SLEEP, p_active);
}
bool PhysicalBone3D::is_able_to_sleep() const {
@@ -1286,7 +1286,7 @@ bool PhysicalBone3D::is_able_to_sleep() const {
}
PhysicalBone3D::PhysicalBone3D() :
- PhysicsBody3D(PhysicsServer3D::BODY_MODE_STATIC) {
+ PhysicsBody3D(PS3DE::BODY_MODE_STATIC) {
joint = PhysicsServer3D::get_singleton()->joint_create();
reset_physics_simulation_state();
}
@@ -1347,7 +1347,7 @@ void PhysicalBone3D::_start_physics_simulation() {
return;
}
reset_to_rest_position();
- set_body_mode(PhysicsServer3D::BODY_MODE_RIGID);
+ set_body_mode(PS3DE::BODY_MODE_RIGID);
PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer());
PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask());
PhysicsServer3D::get_singleton()->body_set_collision_priority(get_rid(), get_collision_priority());
@@ -1360,12 +1360,12 @@ void PhysicalBone3D::_stop_physics_simulation() {
PhysicalBoneSimulator3D *simulator = get_simulator();
if (simulator) {
if (simulator->is_active() && bone_id != -1) {
- set_body_mode(PhysicsServer3D::BODY_MODE_KINEMATIC);
+ set_body_mode(PS3DE::BODY_MODE_KINEMATIC);
PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer());
PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask());
PhysicsServer3D::get_singleton()->body_set_collision_priority(get_rid(), get_collision_priority());
} else {
- set_body_mode(PhysicsServer3D::BODY_MODE_STATIC);
+ set_body_mode(PS3DE::BODY_MODE_STATIC);
PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), 0);
PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), 0);
PhysicsServer3D::get_singleton()->body_set_collision_priority(get_rid(), 1.0);
diff --git a/scene/3d/physics/physics_body_3d.cpp b/scene/3d/physics/physics_body_3d.cpp
index 6b5206325c8..2822d2d76b4 100644
--- a/scene/3d/physics/physics_body_3d.cpp
+++ b/scene/3d/physics/physics_body_3d.cpp
@@ -46,15 +46,15 @@ void PhysicsBody3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_collision_exception_with", "body"), &PhysicsBody3D::remove_collision_exception_with);
ADD_GROUP("Axis Lock", "axis_lock_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_x"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_X);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_y"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Y);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_z"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Z);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_x"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_ANGULAR_X);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_y"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_ANGULAR_Y);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_z"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_ANGULAR_Z);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_x"), "set_axis_lock", "get_axis_lock", PS3DE::BODY_AXIS_LINEAR_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_y"), "set_axis_lock", "get_axis_lock", PS3DE::BODY_AXIS_LINEAR_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_z"), "set_axis_lock", "get_axis_lock", PS3DE::BODY_AXIS_LINEAR_Z);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_x"), "set_axis_lock", "get_axis_lock", PS3DE::BODY_AXIS_ANGULAR_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_y"), "set_axis_lock", "get_axis_lock", PS3DE::BODY_AXIS_ANGULAR_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_z"), "set_axis_lock", "get_axis_lock", PS3DE::BODY_AXIS_ANGULAR_Z);
}
-PhysicsBody3D::PhysicsBody3D(PhysicsServer3D::BodyMode p_mode) :
+PhysicsBody3D::PhysicsBody3D(PS3DE::BodyMode p_mode) :
CollisionObject3D(PhysicsServer3D::get_singleton()->body_create(), false) {
_define_ancestry(AncestralClass::PHYSICS_BODY_3D);
set_body_mode(p_mode);
@@ -88,11 +88,11 @@ void PhysicsBody3D::remove_collision_exception_with(RequiredParam<Node> rp_node)
}
Ref<KinematicCollision3D> PhysicsBody3D::_move(const Vector3 &p_motion, bool p_test_only, real_t p_margin, bool p_recovery_as_collision, int p_max_collisions) {
- PhysicsServer3D::MotionParameters parameters(get_global_transform(), p_motion, p_margin);
+ PS3DT::MotionParameters parameters(get_global_transform(), p_motion, p_margin);
parameters.max_collisions = p_max_collisions;
parameters.recovery_as_collision = p_recovery_as_collision;
- PhysicsServer3D::MotionResult result;
+ PS3DT::MotionResult result;
if (move_and_collide(parameters, result, p_test_only)) {
// Create a new instance when the cached reference is invalid or still in use in script.
@@ -109,7 +109,7 @@ Ref<KinematicCollision3D> PhysicsBody3D::_move(const Vector3 &p_motion, bool p_t
return Ref<KinematicCollision3D>();
}
-bool PhysicsBody3D::move_and_collide(const PhysicsServer3D::MotionParameters &p_parameters, PhysicsServer3D::MotionResult &r_result, bool p_test_only, bool p_cancel_sliding) {
+bool PhysicsBody3D::move_and_collide(const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult &r_result, bool p_test_only, bool p_cancel_sliding) {
bool colliding = PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), p_parameters, &r_result);
// Restore direction of motion to be along original motion,
@@ -168,15 +168,15 @@ bool PhysicsBody3D::move_and_collide(const PhysicsServer3D::MotionParameters &p_
bool PhysicsBody3D::test_move(const Transform3D &p_from, const Vector3 &p_motion, const Ref<KinematicCollision3D> &r_collision, real_t p_margin, bool p_recovery_as_collision, int p_max_collisions) {
ERR_FAIL_COND_V(!is_inside_tree(), false);
- PhysicsServer3D::MotionResult *r = nullptr;
- PhysicsServer3D::MotionResult temp_result;
+ PS3DT::MotionResult *r = nullptr;
+ PS3DT::MotionResult temp_result;
if (r_collision.is_valid()) {
r = &r_collision->result;
} else {
r = &temp_result;
}
- PhysicsServer3D::MotionParameters parameters(p_from, p_motion, p_margin);
+ PS3DT::MotionParameters parameters(p_from, p_motion, p_margin);
parameters.recovery_as_collision = p_recovery_as_collision;
parameters.max_collisions = p_max_collisions;
@@ -189,7 +189,7 @@ Vector3 PhysicsBody3D::get_gravity() const {
return state->get_total_gravity();
}
-void PhysicsBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock) {
+void PhysicsBody3D::set_axis_lock(PS3DE::BodyAxis p_axis, bool p_lock) {
if (p_lock) {
locked_axis |= p_axis;
} else {
@@ -198,7 +198,7 @@ void PhysicsBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock)
PhysicsServer3D::get_singleton()->body_set_axis_lock(get_rid(), p_axis, p_lock);
}
-bool PhysicsBody3D::get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const {
+bool PhysicsBody3D::get_axis_lock(PS3DE::BodyAxis p_axis) const {
return (locked_axis & p_axis);
}
diff --git a/scene/3d/physics/physics_body_3d.h b/scene/3d/physics/physics_body_3d.h
index 249844dd9ed..16ee7b65ad7 100644
--- a/scene/3d/physics/physics_body_3d.h
+++ b/scene/3d/physics/physics_body_3d.h
@@ -39,7 +39,7 @@ class PhysicsBody3D : public CollisionObject3D {
protected:
static void _bind_methods();
- PhysicsBody3D(PhysicsServer3D::BodyMode p_mode);
+ PhysicsBody3D(PS3DE::BodyMode p_mode);
Ref<KinematicCollision3D> motion_cache;
@@ -52,12 +52,12 @@ public:
PackedStringArray get_configuration_warnings() const override;
- bool move_and_collide(const PhysicsServer3D::MotionParameters &p_parameters, PhysicsServer3D::MotionResult &r_result, bool p_test_only = false, bool p_cancel_sliding = true);
+ bool move_and_collide(const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult &r_result, bool p_test_only = false, bool p_cancel_sliding = true);
bool test_move(const Transform3D &p_from, const Vector3 &p_motion, const Ref<KinematicCollision3D> &r_collision = Ref<KinematicCollision3D>(), real_t p_margin = 0.001, bool p_recovery_as_collision = false, int p_max_collisions = 1);
Vector3 get_gravity() const;
- void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock);
- bool get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const;
+ void set_axis_lock(PS3DE::BodyAxis p_axis, bool p_lock);
+ bool get_axis_lock(PS3DE::BodyAxis p_axis) const;
virtual Vector3 get_linear_velocity() const;
virtual Vector3 get_angular_velocity() const;
diff --git a/scene/3d/physics/ray_cast_3d.cpp b/scene/3d/physics/ray_cast_3d.cpp
index 51d1d7c5253..7fbfb6e2330 100644
--- a/scene/3d/physics/ray_cast_3d.cpp
+++ b/scene/3d/physics/ray_cast_3d.cpp
@@ -234,7 +234,7 @@ void RayCast3D::_update_raycast_state() {
to = Vector3(0, 0.01, 0);
}
- PhysicsDirectSpaceState3D::RayParameters ray_params;
+ PS3DT::RayParameters ray_params;
ray_params.from = gt.get_origin();
ray_params.to = gt.xform(to);
ray_params.exclude = exclude;
@@ -244,7 +244,7 @@ void RayCast3D::_update_raycast_state() {
ray_params.hit_from_inside = hit_from_inside;
ray_params.hit_back_faces = hit_back_faces;
- PhysicsDirectSpaceState3D::RayResult rr;
+ PS3DT::RayResult rr;
if (dss->intersect_ray(ray_params, rr)) {
collided = true;
against = rr.collider_id;
diff --git a/scene/3d/physics/rigid_body_3d.cpp b/scene/3d/physics/rigid_body_3d.cpp
index 39c042fc6e4..c169cc0f9d2 100644
--- a/scene/3d/physics/rigid_body_3d.cpp
+++ b/scene/3d/physics/rigid_body_3d.cpp
@@ -34,6 +34,7 @@
#include "core/object/callable_mp.h"
#include "core/object/class_db.h"
#include "scene/resources/physics_material.h"
+#include "servers/physics_3d/physics_server_3d_constants.h"
void RigidBody3D::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
@@ -179,7 +180,7 @@ void RigidBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) {
if (new_transform != old_transform) {
// Update the physics server with the new transform, to prevent it from being overwritten at the sync below.
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_TRANSFORM, new_transform);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_TRANSFORM, new_transform);
}
}
@@ -286,16 +287,16 @@ void RigidBody3D::_apply_body_mode() {
if (freeze) {
switch (freeze_mode) {
case FREEZE_MODE_STATIC: {
- set_body_mode(PhysicsServer3D::BODY_MODE_STATIC);
+ set_body_mode(PS3DE::BODY_MODE_STATIC);
} break;
case FREEZE_MODE_KINEMATIC: {
- set_body_mode(PhysicsServer3D::BODY_MODE_KINEMATIC);
+ set_body_mode(PS3DE::BODY_MODE_KINEMATIC);
} break;
}
} else if (lock_rotation) {
- set_body_mode(PhysicsServer3D::BODY_MODE_RIGID_LINEAR);
+ set_body_mode(PS3DE::BODY_MODE_RIGID_LINEAR);
} else {
- set_body_mode(PhysicsServer3D::BODY_MODE_RIGID);
+ set_body_mode(PS3DE::BODY_MODE_RIGID);
}
}
@@ -341,7 +342,7 @@ RigidBody3D::FreezeMode RigidBody3D::get_freeze_mode() const {
void RigidBody3D::set_mass(real_t p_mass) {
ERR_FAIL_COND(p_mass <= 0);
mass = p_mass;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_MASS, mass);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_MASS, mass);
}
real_t RigidBody3D::get_mass() const {
@@ -354,7 +355,7 @@ void RigidBody3D::set_inertia(const Vector3 &p_inertia) {
ERR_FAIL_COND(p_inertia.z < 0);
inertia = p_inertia;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_INERTIA, inertia);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_INERTIA, inertia);
}
const Vector3 &RigidBody3D::get_inertia() const {
@@ -373,12 +374,12 @@ void RigidBody3D::set_center_of_mass_mode(CenterOfMassMode p_mode) {
center_of_mass = Vector3();
PhysicsServer3D::get_singleton()->body_reset_mass_properties(get_rid());
if (inertia != Vector3()) {
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_INERTIA, inertia);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_INERTIA, inertia);
}
} break;
case CENTER_OF_MASS_MODE_CUSTOM: {
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_CENTER_OF_MASS, center_of_mass);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_CENTER_OF_MASS, center_of_mass);
} break;
}
@@ -397,7 +398,7 @@ void RigidBody3D::set_center_of_mass(const Vector3 &p_center_of_mass) {
ERR_FAIL_COND(center_of_mass_mode != CENTER_OF_MASS_MODE_CUSTOM);
center_of_mass = p_center_of_mass;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_CENTER_OF_MASS, center_of_mass);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_CENTER_OF_MASS, center_of_mass);
}
const Vector3 &RigidBody3D::get_center_of_mass() const {
@@ -423,7 +424,7 @@ Ref<PhysicsMaterial> RigidBody3D::get_physics_material_override() const {
void RigidBody3D::set_gravity_scale(real_t p_gravity_scale) {
gravity_scale = p_gravity_scale;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
}
real_t RigidBody3D::get_gravity_scale() const {
@@ -432,7 +433,7 @@ real_t RigidBody3D::get_gravity_scale() const {
void RigidBody3D::set_linear_damp_mode(DampMode p_mode) {
linear_damp_mode = p_mode;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_LINEAR_DAMP_MODE, linear_damp_mode);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_LINEAR_DAMP_MODE, linear_damp_mode);
}
RigidBody3D::DampMode RigidBody3D::get_linear_damp_mode() const {
@@ -441,7 +442,7 @@ RigidBody3D::DampMode RigidBody3D::get_linear_damp_mode() const {
void RigidBody3D::set_angular_damp_mode(DampMode p_mode) {
angular_damp_mode = p_mode;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP_MODE, angular_damp_mode);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_ANGULAR_DAMP_MODE, angular_damp_mode);
}
RigidBody3D::DampMode RigidBody3D::get_angular_damp_mode() const {
@@ -451,7 +452,7 @@ RigidBody3D::DampMode RigidBody3D::get_angular_damp_mode() const {
void RigidBody3D::set_linear_damp(real_t p_linear_damp) {
ERR_FAIL_COND(p_linear_damp < 0.0);
linear_damp = p_linear_damp;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_LINEAR_DAMP, linear_damp);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_LINEAR_DAMP, linear_damp);
}
real_t RigidBody3D::get_linear_damp() const {
@@ -461,7 +462,7 @@ real_t RigidBody3D::get_linear_damp() const {
void RigidBody3D::set_angular_damp(real_t p_angular_damp) {
ERR_FAIL_COND(p_angular_damp < 0.0);
angular_damp = p_angular_damp;
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP, angular_damp);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_ANGULAR_DAMP, angular_damp);
}
real_t RigidBody3D::get_angular_damp() const {
@@ -472,12 +473,12 @@ void RigidBody3D::set_axis_velocity(const Vector3 &p_axis) {
Vector3 axis = p_axis.normalized();
linear_velocity -= axis * axis.dot(linear_velocity);
linear_velocity += p_axis;
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
}
void RigidBody3D::set_linear_velocity(const Vector3 &p_velocity) {
linear_velocity = p_velocity;
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
}
Vector3 RigidBody3D::get_linear_velocity() const {
@@ -486,7 +487,7 @@ Vector3 RigidBody3D::get_linear_velocity() const {
void RigidBody3D::set_angular_velocity(const Vector3 &p_velocity) {
angular_velocity = p_velocity;
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
}
Vector3 RigidBody3D::get_angular_velocity() const {
@@ -512,12 +513,12 @@ bool RigidBody3D::is_using_custom_integrator() {
void RigidBody3D::set_sleeping(bool p_sleeping) {
sleeping = p_sleeping;
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_SLEEPING, sleeping);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_SLEEPING, sleeping);
}
void RigidBody3D::set_can_sleep(bool p_active) {
can_sleep = p_active;
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_CAN_SLEEP, p_active);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_CAN_SLEEP, p_active);
}
bool RigidBody3D::is_able_to_sleep() const {
@@ -529,7 +530,7 @@ bool RigidBody3D::is_sleeping() const {
}
void RigidBody3D::set_max_contacts_reported(int p_amount) {
- ERR_FAIL_INDEX_MSG(p_amount, MAX_CONTACTS_REPORTED_3D_MAX, "Max contacts reported allocates memory (about 80 bytes each), and therefore must not be set too high.");
+ ERR_FAIL_INDEX_MSG(p_amount, PS3DC::MAX_CONTACTS_REPORTED_3D_MAX, "Max contacts reported allocates memory (about 80 bytes each), and therefore must not be set too high.");
max_contacts_reported = p_amount;
PhysicsServer3D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
}
@@ -659,11 +660,11 @@ TypedArray<Node3D> RigidBody3D::get_colliding_bodies() const {
void RigidBody3D::_reload_physics_characteristics() {
if (physics_material_override.is_null()) {
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, 0);
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, 1);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_BOUNCE, 0);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_FRICTION, 1);
} else {
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
}
}
@@ -827,7 +828,7 @@ void RigidBody3D::_validate_property(PropertyInfo &p_property) const {
}
RigidBody3D::RigidBody3D() :
- PhysicsBody3D(PhysicsServer3D::BODY_MODE_RIGID) {
+ PhysicsBody3D(PS3DE::BODY_MODE_RIGID) {
PhysicsServer3D::get_singleton()->body_set_state_sync_callback(get_rid(), callable_mp(this, &RigidBody3D::_body_state_changed));
}
diff --git a/scene/3d/physics/shape_cast_3d.cpp b/scene/3d/physics/shape_cast_3d.cpp
index e2cedb40b06..f5c60b47f14 100644
--- a/scene/3d/physics/shape_cast_3d.cpp
+++ b/scene/3d/physics/shape_cast_3d.cpp
@@ -400,7 +400,7 @@ void ShapeCast3D::_update_shapecast_state() {
Transform3D gt = get_global_transform();
- PhysicsDirectSpaceState3D::ShapeParameters params;
+ PS3DT::ShapeParameters params;
params.shape_rid = shape_rid;
params.transform = gt;
params.motion = gt.basis.xform(target_position);
@@ -428,7 +428,7 @@ void ShapeCast3D::_update_shapecast_state() {
bool intersected = true;
while (intersected && result.size() < max_results) {
- PhysicsDirectSpaceState3D::ShapeRestInfo info;
+ PS3DT::ShapeRestInfo info;
intersected = dss->rest_info(params, &info);
if (intersected) {
result.push_back(info);
@@ -484,7 +484,7 @@ Array ShapeCast3D::get_collision_result() const {
Array ret;
for (int i = 0; i < result.size(); ++i) {
- const PhysicsDirectSpaceState3D::ShapeRestInfo &sri = result[i];
+ const PS3DT::ShapeRestInfo &sri = result[i];
Dictionary col;
col["point"] = sri.point;
diff --git a/scene/3d/physics/shape_cast_3d.h b/scene/3d/physics/shape_cast_3d.h
index 6cf6474d741..6360183c07e 100644
--- a/scene/3d/physics/shape_cast_3d.h
+++ b/scene/3d/physics/shape_cast_3d.h
@@ -68,7 +68,7 @@ class ShapeCast3D : public Node3D {
// Result
int max_results = 32;
- Vector<PhysicsDirectSpaceState3D::ShapeRestInfo> result;
+ Vector<PS3DT::ShapeRestInfo> result;
bool collided = false;
real_t collision_safe_fraction = 1.0;
real_t collision_unsafe_fraction = 1.0;
diff --git a/scene/3d/physics/spring_arm_3d.cpp b/scene/3d/physics/spring_arm_3d.cpp
index 878fddec7f2..33c3180079f 100644
--- a/scene/3d/physics/spring_arm_3d.cpp
+++ b/scene/3d/physics/spring_arm_3d.cpp
@@ -157,7 +157,7 @@ void SpringArm3D::process_spring() {
Transform3D base_transform = camera->get_global_transform();
base_transform.origin = get_global_transform().origin;
- PhysicsDirectSpaceState3D::ShapeParameters shape_params;
+ PS3DT::ShapeParameters shape_params;
shape_params.shape_rid = camera->get_pyramid_shape_rid();
shape_params.transform = base_transform;
shape_params.motion = motion;
@@ -166,13 +166,13 @@ void SpringArm3D::process_spring() {
get_world_3d()->get_direct_space_state()->cast_motion(shape_params, motion_delta, motion_delta_unsafe);
} else {
- PhysicsDirectSpaceState3D::RayParameters ray_params;
+ PS3DT::RayParameters ray_params;
ray_params.from = get_global_transform().origin;
ray_params.to = get_global_transform().origin + motion;
ray_params.exclude = excluded_objects;
ray_params.collision_mask = mask;
- PhysicsDirectSpaceState3D::RayResult r;
+ PS3DT::RayResult r;
bool intersected = get_world_3d()->get_direct_space_state()->intersect_ray(ray_params, r);
if (intersected) {
real_t dist = get_global_transform().origin.distance_to(r.position);
@@ -181,7 +181,7 @@ void SpringArm3D::process_spring() {
}
}
} else {
- PhysicsDirectSpaceState3D::ShapeParameters shape_params;
+ PS3DT::ShapeParameters shape_params;
shape_params.shape_rid = shape->get_rid();
shape_params.transform = get_global_transform();
shape_params.motion = motion;
diff --git a/scene/3d/physics/static_body_3d.cpp b/scene/3d/physics/static_body_3d.cpp
index 4de0f241626..cfa8d5c2b1e 100644
--- a/scene/3d/physics/static_body_3d.cpp
+++ b/scene/3d/physics/static_body_3d.cpp
@@ -73,13 +73,13 @@ Ref<PhysicsMaterial> StaticBody3D::get_physics_material_override() const {
void StaticBody3D::set_constant_linear_velocity(const Vector3 &p_vel) {
constant_linear_velocity = p_vel;
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity);
}
void StaticBody3D::set_constant_angular_velocity(const Vector3 &p_vel) {
constant_angular_velocity = p_vel;
- PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PS3DE::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity);
}
Vector3 StaticBody3D::get_constant_linear_velocity() const {
@@ -92,11 +92,11 @@ Vector3 StaticBody3D::get_constant_angular_velocity() const {
void StaticBody3D::_reload_physics_characteristics() {
if (physics_material_override.is_null()) {
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, 0);
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, 1);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_BOUNCE, 0);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_FRICTION, 1);
} else {
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
- PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PS3DE::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
}
}
@@ -248,6 +248,6 @@ void StaticBody3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_angular_velocity", PROPERTY_HINT_NONE, U"radians_as_degrees,suffix:\u00B0/s"), "set_constant_angular_velocity", "get_constant_angular_velocity");
}
-StaticBody3D::StaticBody3D(PhysicsServer3D::BodyMode p_mode) :
+StaticBody3D::StaticBody3D(PS3DE::BodyMode p_mode) :
PhysicsBody3D(p_mode) {
}
diff --git a/scene/3d/physics/static_body_3d.h b/scene/3d/physics/static_body_3d.h
index 04ae6b77672..7d1291b2d90 100644
--- a/scene/3d/physics/static_body_3d.h
+++ b/scene/3d/physics/static_body_3d.h
@@ -61,7 +61,7 @@ public:
Vector3 get_constant_linear_velocity() const;
Vector3 get_constant_angular_velocity() const;
- StaticBody3D(PhysicsServer3D::BodyMode p_mode = PhysicsServer3D::BODY_MODE_STATIC);
+ StaticBody3D(PS3DE::BodyMode p_mode = PS3DE::BODY_MODE_STATIC);
private:
void _reload_physics_characteristics();
diff --git a/scene/3d/physics/vehicle_body_3d.cpp b/scene/3d/physics/vehicle_body_3d.cpp
index 1e5083a90c1..cff2e3848fb 100644
--- a/scene/3d/physics/vehicle_body_3d.cpp
+++ b/scene/3d/physics/vehicle_body_3d.cpp
@@ -471,11 +471,11 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) {
real_t param = real_t(0.);
- PhysicsDirectSpaceState3D::RayResult rr;
+ PS3DT::RayResult rr;
PhysicsDirectSpaceState3D *ss = s->get_space_state();
- PhysicsDirectSpaceState3D::RayParameters ray_params;
+ PS3DT::RayParameters ray_params;
ray_params.from = source;
ray_params.to = target;
ray_params.exclude = exclude;
diff --git a/scene/debugger/runtime_node_select.cpp b/scene/debugger/runtime_node_select.cpp
index ac723788829..163add12097 100644
--- a/scene/debugger/runtime_node_select.cpp
+++ b/scene/debugger/runtime_node_select.cpp
@@ -1230,9 +1230,9 @@ void RuntimeNodeSelect::_find_3d_items_at_pos(const Point2 &p_pos, Vector<Select
#ifndef PHYSICS_3D_DISABLED
// Start with physical objects.
PhysicsDirectSpaceState3D *ss = root->get_world_3d()->get_direct_space_state();
- PhysicsDirectSpaceState3D::RayResult result;
+ PS3DT::RayResult result;
HashSet<RID> excluded;
- PhysicsDirectSpaceState3D::RayParameters ray_params;
+ PS3DT::RayParameters ray_params;
ray_params.from = pos;
ray_params.to = to;
ray_params.collide_with_areas = true;
@@ -1356,13 +1356,13 @@ void RuntimeNodeSelect::_find_3d_items_at_rect(const Rect2 &p_rect, Vector<Selec
// Start with physical objects.
PhysicsDirectSpaceState3D *ss = root->get_world_3d()->get_direct_space_state();
- PhysicsDirectSpaceState3D::ShapeResult results[32];
- PhysicsDirectSpaceState3D::ShapeParameters shape_params;
+ PS3DT::ShapeResult results[32];
+ PS3DT::ShapeParameters shape_params;
shape_params.shape_rid = shape->get_rid();
shape_params.collide_with_areas = true;
const int num_hits = ss->intersect_shape(shape_params, results, 32);
for (int i = 0; i < num_hits; i++) {
- const PhysicsDirectSpaceState3D::ShapeResult &result = results[i];
+ const PS3DT::ShapeResult &result = results[i];
if (!result.collider) {
continue;
}
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 1a9d863f985..38ff65b1c7c 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -71,6 +71,7 @@ STATIC_ASSERT_INCOMPLETE_TYPE(class, RenderingServer);
#ifndef PHYSICS_2D_DISABLED
#include "scene/2d/physics/collision_object_2d.h"
+#include "servers/physics_2d/direct_states/physics_direct_space_state_2d.h"
#endif // PHYSICS_2D_DISABLED
#ifndef PHYSICS_3D_DISABLED
@@ -812,7 +813,7 @@ void Viewport::_process_picking() {
Vector2 last_pos(1e20, 1e20);
CollisionObject3D *last_object = nullptr;
ObjectID last_id;
- PhysicsDirectSpaceState3D::RayResult result;
+ PS3DT::RayResult result;
#endif // PHYSICS_3D_DISABLED
#ifndef PHYSICS_2D_DISABLED
@@ -903,7 +904,7 @@ void Viewport::_process_picking() {
uint64_t frame = get_tree()->get_frame();
- PhysicsDirectSpaceState2D::ShapeResult res[64];
+ PS2DT::ShapeResult res[64];
for (const CanvasLayer *E : canvas_layers) {
Transform2D canvas_layer_transform;
ObjectID canvas_layer_id;
@@ -919,7 +920,7 @@ void Viewport::_process_picking() {
Vector2 point = canvas_layer_transform.affine_inverse().xform(pos);
- PhysicsDirectSpaceState2D::PointParameters point_params;
+ PS2DT::PointParameters point_params;
point_params.position = point;
point_params.canvas_instance_id = canvas_layer_id;
point_params.collide_with_areas = true;
@@ -928,7 +929,7 @@ void Viewport::_process_picking() {
int rc = ss2d->intersect_point(point_params, res, 64);
if (physics_object_picking_sort) {
struct ComparatorCollisionObjects {
- bool operator()(const PhysicsDirectSpaceState2D::ShapeResult &p_a, const PhysicsDirectSpaceState2D::ShapeResult &p_b) const {
+ bool operator()(const PS2DT::ShapeResult &p_a, const PS2DT::ShapeResult &p_b) const {
CollisionObject2D *a = Object::cast_to<CollisionObject2D>(p_a.collider);
CollisionObject2D *b = Object::cast_to<CollisionObject2D>(p_b.collider);
if (!a || !b) {
@@ -942,7 +943,7 @@ void Viewport::_process_picking() {
return a->is_greater_than(b);
}
};
- SortArray<PhysicsDirectSpaceState2D::ShapeResult, ComparatorCollisionObjects> sorter;
+ SortArray<PS2DT::ShapeResult, ComparatorCollisionObjects> sorter;
sorter.sort(res, rc);
}
for (int i = 0; i < rc; i++) {
@@ -1029,7 +1030,7 @@ void Viewport::_process_picking() {
PhysicsDirectSpaceState3D *space = PhysicsServer3D::get_singleton()->space_get_direct_state(find_world_3d()->get_space());
if (space) {
- PhysicsDirectSpaceState3D::RayParameters ray_params;
+ PS3DT::RayParameters ray_params;
ray_params.from = from;
ray_params.to = from + dir * depth_far;
ray_params.collide_with_areas = true;
diff --git a/scene/resources/2d/skeleton/skeleton_modification_2d_jiggle.cpp b/scene/resources/2d/skeleton/skeleton_modification_2d_jiggle.cpp
index 3643801efe1..b26d1eeb0db 100644
--- a/scene/resources/2d/skeleton/skeleton_modification_2d_jiggle.cpp
+++ b/scene/resources/2d/skeleton/skeleton_modification_2d_jiggle.cpp
@@ -197,9 +197,9 @@ void SkeletonModification2DJiggle::_execute_jiggle_joint(int p_joint_idx, Node2D
Ref<World2D> world_2d = stack->skeleton->get_world_2d();
ERR_FAIL_COND(world_2d.is_null());
PhysicsDirectSpaceState2D *space_state = PhysicsServer2D::get_singleton()->space_get_direct_state(world_2d->get_space());
- PhysicsDirectSpaceState2D::RayResult ray_result;
+ PS2DT::RayResult ray_result;
- PhysicsDirectSpaceState2D::RayParameters ray_params;
+ PS2DT::RayParameters ray_params;
ray_params.from = operation_bone_trans.get_origin();
ray_params.to = jiggle_data_chain[p_joint_idx].dynamic_position;
ray_params.collision_mask = collision_mask;
diff --git a/scene/resources/3d/box_shape_3d.cpp b/scene/resources/3d/box_shape_3d.cpp
index e08345c78a5..e67189389bf 100644
--- a/scene/resources/3d/box_shape_3d.cpp
+++ b/scene/resources/3d/box_shape_3d.cpp
@@ -116,6 +116,6 @@ void BoxShape3D::_bind_methods() {
}
BoxShape3D::BoxShape3D() :
- Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_BOX)) {
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PS3DE::SHAPE_BOX)) {
set_size(Vector3(1, 1, 1));
}
diff --git a/scene/resources/3d/capsule_shape_3d.cpp b/scene/resources/3d/capsule_shape_3d.cpp
index d92a1b90f47..c9a0f0f761e 100644
--- a/scene/resources/3d/capsule_shape_3d.cpp
+++ b/scene/resources/3d/capsule_shape_3d.cpp
@@ -154,6 +154,6 @@ void CapsuleShape3D::_bind_methods() {
}
CapsuleShape3D::CapsuleShape3D() :
- Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CAPSULE)) {
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PS3DE::SHAPE_CAPSULE)) {
_update_shape();
}
diff --git a/scene/resources/3d/concave_polygon_shape_3d.cpp b/scene/resources/3d/concave_polygon_shape_3d.cpp
index afce253a8e7..bf3ebedcf39 100644
--- a/scene/resources/3d/concave_polygon_shape_3d.cpp
+++ b/scene/resources/3d/concave_polygon_shape_3d.cpp
@@ -132,6 +132,6 @@ void ConcavePolygonShape3D::_bind_methods() {
}
ConcavePolygonShape3D::ConcavePolygonShape3D() :
- Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CONCAVE_POLYGON)) {
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PS3DE::SHAPE_CONCAVE_POLYGON)) {
//set_planes(Vector3(1,1,1));
}
diff --git a/scene/resources/3d/convex_polygon_shape_3d.cpp b/scene/resources/3d/convex_polygon_shape_3d.cpp
index 4fcc9bbd9d0..7c129343ff1 100644
--- a/scene/resources/3d/convex_polygon_shape_3d.cpp
+++ b/scene/resources/3d/convex_polygon_shape_3d.cpp
@@ -127,5 +127,5 @@ void ConvexPolygonShape3D::_bind_methods() {
}
ConvexPolygonShape3D::ConvexPolygonShape3D() :
- Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CONVEX_POLYGON)) {
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PS3DE::SHAPE_CONVEX_POLYGON)) {
}
diff --git a/scene/resources/3d/cylinder_shape_3d.cpp b/scene/resources/3d/cylinder_shape_3d.cpp
index 60704b5cf5c..6c8181a2ed8 100644
--- a/scene/resources/3d/cylinder_shape_3d.cpp
+++ b/scene/resources/3d/cylinder_shape_3d.cpp
@@ -125,6 +125,6 @@ void CylinderShape3D::_bind_methods() {
}
CylinderShape3D::CylinderShape3D() :
- Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CYLINDER)) {
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PS3DE::SHAPE_CYLINDER)) {
_update_shape();
}
diff --git a/scene/resources/3d/height_map_shape_3d.cpp b/scene/resources/3d/height_map_shape_3d.cpp
index e7a82bd31ba..0278af73dfb 100644
--- a/scene/resources/3d/height_map_shape_3d.cpp
+++ b/scene/resources/3d/height_map_shape_3d.cpp
@@ -362,7 +362,7 @@ void HeightMapShape3D::_bind_methods() {
}
HeightMapShape3D::HeightMapShape3D() :
- Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_HEIGHTMAP)) {
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PS3DE::SHAPE_HEIGHTMAP)) {
map_data.resize(map_width * map_depth);
real_t *w = map_data.ptrw();
w[0] = 0.0;
diff --git a/scene/resources/3d/separation_ray_shape_3d.cpp b/scene/resources/3d/separation_ray_shape_3d.cpp
index 9a4fa95999e..185995fd0c9 100644
--- a/scene/resources/3d/separation_ray_shape_3d.cpp
+++ b/scene/resources/3d/separation_ray_shape_3d.cpp
@@ -91,7 +91,7 @@ void SeparationRayShape3D::_bind_methods() {
}
SeparationRayShape3D::SeparationRayShape3D() :
- Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_SEPARATION_RAY)) {
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PS3DE::SHAPE_SEPARATION_RAY)) {
/* Code copied from setters to prevent the use of uninitialized variables */
_update_shape();
emit_changed();
diff --git a/scene/resources/3d/sphere_shape_3d.cpp b/scene/resources/3d/sphere_shape_3d.cpp
index e5e05a24c0c..3b913c7dd3d 100644
--- a/scene/resources/3d/sphere_shape_3d.cpp
+++ b/scene/resources/3d/sphere_shape_3d.cpp
@@ -102,6 +102,6 @@ void SphereShape3D::_bind_methods() {
}
SphereShape3D::SphereShape3D() :
- Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_SPHERE)) {
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PS3DE::SHAPE_SPHERE)) {
set_radius(0.5);
}
diff --git a/scene/resources/3d/world_3d.cpp b/scene/resources/3d/world_3d.cpp
index 106059d096b..18af289e8ac 100644
--- a/scene/resources/3d/world_3d.cpp
+++ b/scene/resources/3d/world_3d.cpp
@@ -54,10 +54,10 @@ RID World3D::get_space() const {
if (space.is_null()) {
space = PhysicsServer3D::get_singleton()->space_create();
PhysicsServer3D::get_singleton()->space_set_active(space, true);
- PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_GRAVITY, GLOBAL_GET("physics/3d/default_gravity"));
- PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_GET("physics/3d/default_gravity_vector"));
- PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_LINEAR_DAMP, GLOBAL_GET("physics/3d/default_linear_damp"));
- PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP, GLOBAL_GET("physics/3d/default_angular_damp"));
+ PhysicsServer3D::get_singleton()->area_set_param(space, PS3DE::AREA_PARAM_GRAVITY, GLOBAL_GET("physics/3d/default_gravity"));
+ PhysicsServer3D::get_singleton()->area_set_param(space, PS3DE::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_GET("physics/3d/default_gravity_vector"));
+ PhysicsServer3D::get_singleton()->area_set_param(space, PS3DE::AREA_PARAM_LINEAR_DAMP, GLOBAL_GET("physics/3d/default_linear_damp"));
+ PhysicsServer3D::get_singleton()->area_set_param(space, PS3DE::AREA_PARAM_ANGULAR_DAMP, GLOBAL_GET("physics/3d/default_angular_damp"));
}
#endif // PHYSICS_3D_DISABLED
return space;
diff --git a/scene/resources/3d/world_boundary_shape_3d.cpp b/scene/resources/3d/world_boundary_shape_3d.cpp
index cd06bd042cb..705774c9715 100644
--- a/scene/resources/3d/world_boundary_shape_3d.cpp
+++ b/scene/resources/3d/world_boundary_shape_3d.cpp
@@ -133,6 +133,6 @@ void WorldBoundaryShape3D::_bind_methods() {
}
WorldBoundaryShape3D::WorldBoundaryShape3D() :
- Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_WORLD_BOUNDARY)) {
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PS3DE::SHAPE_WORLD_BOUNDARY)) {
set_plane(Plane(0, 1, 0, 0));
}
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index c2749aadd84..1d31092ffa5 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -63,10 +63,10 @@ RID World2D::get_space() const {
if (space.is_null()) {
space = PhysicsServer2D::get_singleton()->space_create();
PhysicsServer2D::get_singleton()->space_set_active(space, true);
- PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY, GLOBAL_GET("physics/2d/default_gravity"));
- PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_GET("physics/2d/default_gravity_vector"));
- PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_LINEAR_DAMP, GLOBAL_GET("physics/2d/default_linear_damp"));
- PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP, GLOBAL_GET("physics/2d/default_angular_damp"));
+ PhysicsServer2D::get_singleton()->area_set_param(space, PS2DE::AREA_PARAM_GRAVITY, GLOBAL_GET("physics/2d/default_gravity"));
+ PhysicsServer2D::get_singleton()->area_set_param(space, PS2DE::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_GET("physics/2d/default_gravity_vector"));
+ PhysicsServer2D::get_singleton()->area_set_param(space, PS2DE::AREA_PARAM_LINEAR_DAMP, GLOBAL_GET("physics/2d/default_linear_damp"));
+ PhysicsServer2D::get_singleton()->area_set_param(space, PS2DE::AREA_PARAM_ANGULAR_DAMP, GLOBAL_GET("physics/2d/default_angular_damp"));
}
return space;
}
diff --git a/servers/physics_2d/SCsub b/servers/physics_2d/SCsub
index 96d81ed1484..3beeed07bbb 100644
--- a/servers/physics_2d/SCsub
+++ b/servers/physics_2d/SCsub
@@ -5,3 +5,6 @@ Import("env")
if not env["disable_physics_2d"]:
env.add_source_files(env.servers_sources, "*.cpp")
+
+ SConscript("direct_states/SCsub")
+ SConscript("queries/SCsub")
diff --git a/servers/physics_2d/direct_states/SCsub b/servers/physics_2d/direct_states/SCsub
new file mode 100644
index 00000000000..96d81ed1484
--- /dev/null
+++ b/servers/physics_2d/direct_states/SCsub
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+from misc.utility.scons_hints import *
+
+Import("env")
+
+if not env["disable_physics_2d"]:
+ env.add_source_files(env.servers_sources, "*.cpp")
diff --git a/servers/physics_2d/direct_states/physics_direct_body_state_2d.cpp b/servers/physics_2d/direct_states/physics_direct_body_state_2d.cpp
new file mode 100644
index 00000000000..73e5b013d4f
--- /dev/null
+++ b/servers/physics_2d/direct_states/physics_direct_body_state_2d.cpp
@@ -0,0 +1,149 @@
+/**************************************************************************/
+/* physics_direct_body_state_2d.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 "physics_direct_body_state_2d.h"
+
+#include "core/object/class_db.h"
+
+void PhysicsDirectBodyState2D::integrate_forces() {
+ real_t step = get_step();
+ Vector2 lv = get_linear_velocity();
+ lv += get_total_gravity() * step;
+
+ real_t av = get_angular_velocity();
+
+ real_t damp = 1.0 - step * get_total_linear_damp();
+
+ if (damp < 0) { // reached zero in the given time
+ damp = 0;
+ }
+
+ lv *= damp;
+
+ damp = 1.0 - step * get_total_angular_damp();
+
+ if (damp < 0) { // reached zero in the given time
+ damp = 0;
+ }
+
+ av *= damp;
+
+ set_linear_velocity(lv);
+ set_angular_velocity(av);
+}
+
+Object *PhysicsDirectBodyState2D::get_contact_collider_object(int p_contact_idx) const {
+ ObjectID objid = get_contact_collider_id(p_contact_idx);
+ Object *obj = ObjectDB::get_instance(objid);
+ return obj;
+}
+
+void PhysicsDirectBodyState2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState2D::get_total_gravity);
+ ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState2D::get_total_linear_damp);
+ ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState2D::get_total_angular_damp);
+
+ ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState2D::get_center_of_mass);
+ ClassDB::bind_method(D_METHOD("get_center_of_mass_local"), &PhysicsDirectBodyState2D::get_center_of_mass_local);
+ ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState2D::get_inverse_mass);
+ ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState2D::get_inverse_inertia);
+
+ ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &PhysicsDirectBodyState2D::set_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_linear_velocity"), &PhysicsDirectBodyState2D::get_linear_velocity);
+
+ ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &PhysicsDirectBodyState2D::set_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_angular_velocity"), &PhysicsDirectBodyState2D::get_angular_velocity);
+
+ ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsDirectBodyState2D::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsDirectBodyState2D::get_transform);
+
+ ClassDB::bind_method(D_METHOD("get_velocity_at_local_position", "local_position"), &PhysicsDirectBodyState2D::get_velocity_at_local_position);
+
+ ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &PhysicsDirectBodyState2D::apply_central_impulse);
+ ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &PhysicsDirectBodyState2D::apply_torque_impulse);
+ ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &PhysicsDirectBodyState2D::apply_impulse, Vector2());
+
+ ClassDB::bind_method(D_METHOD("apply_central_force", "force"), &PhysicsDirectBodyState2D::apply_central_force, Vector2());
+ ClassDB::bind_method(D_METHOD("apply_force", "force", "position"), &PhysicsDirectBodyState2D::apply_force, Vector2());
+ ClassDB::bind_method(D_METHOD("apply_torque", "torque"), &PhysicsDirectBodyState2D::apply_torque);
+
+ ClassDB::bind_method(D_METHOD("add_constant_central_force", "force"), &PhysicsDirectBodyState2D::add_constant_central_force, Vector2());
+ ClassDB::bind_method(D_METHOD("add_constant_force", "force", "position"), &PhysicsDirectBodyState2D::add_constant_force, Vector2());
+ ClassDB::bind_method(D_METHOD("add_constant_torque", "torque"), &PhysicsDirectBodyState2D::add_constant_torque);
+
+ ClassDB::bind_method(D_METHOD("set_constant_force", "force"), &PhysicsDirectBodyState2D::set_constant_force);
+ ClassDB::bind_method(D_METHOD("get_constant_force"), &PhysicsDirectBodyState2D::get_constant_force);
+
+ ClassDB::bind_method(D_METHOD("set_constant_torque", "torque"), &PhysicsDirectBodyState2D::set_constant_torque);
+ ClassDB::bind_method(D_METHOD("get_constant_torque"), &PhysicsDirectBodyState2D::get_constant_torque);
+
+ ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &PhysicsDirectBodyState2D::set_sleep_state);
+ ClassDB::bind_method(D_METHOD("is_sleeping"), &PhysicsDirectBodyState2D::is_sleeping);
+
+ ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PhysicsDirectBodyState2D::set_collision_layer);
+ ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsDirectBodyState2D::get_collision_layer);
+
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &PhysicsDirectBodyState2D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsDirectBodyState2D::get_collision_mask);
+
+ ClassDB::bind_method(D_METHOD("get_contact_count"), &PhysicsDirectBodyState2D::get_contact_count);
+
+ ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_position);
+ ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_normal);
+ ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_shape);
+ ClassDB::bind_method(D_METHOD("get_contact_local_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_velocity_at_position);
+ ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_position);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_id);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_object);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_velocity_at_position);
+ ClassDB::bind_method(D_METHOD("get_contact_impulse", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_impulse);
+ ClassDB::bind_method(D_METHOD("get_step"), &PhysicsDirectBodyState2D::get_step);
+ ClassDB::bind_method(D_METHOD("integrate_forces"), &PhysicsDirectBodyState2D::integrate_forces);
+ ClassDB::bind_method(D_METHOD("get_space_state"), &PhysicsDirectBodyState2D::get_space_state);
+
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "step"), "", "get_step");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inverse_mass"), "", "get_inverse_mass");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inverse_inertia"), "", "get_inverse_inertia");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "total_angular_damp"), "", "get_total_angular_damp");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "total_linear_damp"), "", "get_total_linear_damp");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "total_gravity"), "", "get_total_gravity");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center_of_mass"), "", "get_center_of_mass");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center_of_mass_local"), "", "get_center_of_mass_local");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "linear_velocity"), "set_linear_velocity", "get_linear_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sleeping"), "set_sleep_state", "is_sleeping");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer"), "set_collision_layer", "get_collision_layer");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask"), "set_collision_mask", "get_collision_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform");
+}
+
+PhysicsDirectBodyState2D::PhysicsDirectBodyState2D() {}
diff --git a/servers/physics_2d/direct_states/physics_direct_body_state_2d.h b/servers/physics_2d/direct_states/physics_direct_body_state_2d.h
new file mode 100644
index 00000000000..d300593de4a
--- /dev/null
+++ b/servers/physics_2d/direct_states/physics_direct_body_state_2d.h
@@ -0,0 +1,111 @@
+/**************************************************************************/
+/* physics_direct_body_state_2d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/variant/type_info.h"
+#include "servers/physics_2d/direct_states/physics_direct_space_state_2d.h"
+
+class PhysicsDirectBodyState2D : public Object {
+ GDCLASS(PhysicsDirectBodyState2D, Object);
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual Vector2 get_total_gravity() const = 0; // get gravity vector working on this body space/area
+ virtual real_t get_total_linear_damp() const = 0; // get density of this body space/area
+ virtual real_t get_total_angular_damp() const = 0; // get density of this body space/area
+
+ virtual Vector2 get_center_of_mass() const = 0;
+ virtual Vector2 get_center_of_mass_local() const = 0;
+ virtual real_t get_inverse_mass() const = 0; // get the mass
+ virtual real_t get_inverse_inertia() const = 0; // get density of this body space
+
+ virtual void set_linear_velocity(const Vector2 &p_velocity) = 0;
+ virtual Vector2 get_linear_velocity() const = 0;
+
+ virtual void set_angular_velocity(real_t p_velocity) = 0;
+ virtual real_t get_angular_velocity() const = 0;
+
+ virtual void set_transform(const Transform2D &p_transform) = 0;
+ virtual Transform2D get_transform() const = 0;
+
+ virtual Vector2 get_velocity_at_local_position(const Vector2 &p_position) const = 0;
+
+ virtual void apply_central_impulse(const Vector2 &p_impulse) = 0;
+ virtual void apply_torque_impulse(real_t p_torque) = 0;
+ virtual void apply_impulse(const Vector2 &p_impulse, const Vector2 &p_position = Vector2()) = 0;
+
+ virtual void apply_central_force(const Vector2 &p_force) = 0;
+ virtual void apply_force(const Vector2 &p_force, const Vector2 &p_position = Vector2()) = 0;
+ virtual void apply_torque(real_t p_torque) = 0;
+
+ virtual void add_constant_central_force(const Vector2 &p_force) = 0;
+ virtual void add_constant_force(const Vector2 &p_force, const Vector2 &p_position = Vector2()) = 0;
+ virtual void add_constant_torque(real_t p_torque) = 0;
+
+ virtual void set_constant_force(const Vector2 &p_force) = 0;
+ virtual Vector2 get_constant_force() const = 0;
+
+ virtual void set_constant_torque(real_t p_torque) = 0;
+ virtual real_t get_constant_torque() const = 0;
+
+ virtual void set_sleep_state(bool p_enable) = 0;
+ virtual bool is_sleeping() const = 0;
+
+ virtual void set_collision_layer(uint32_t p_layer) = 0;
+ virtual uint32_t get_collision_layer() const = 0;
+
+ virtual void set_collision_mask(uint32_t p_mask) = 0;
+ virtual uint32_t get_collision_mask() const = 0;
+
+ virtual int get_contact_count() const = 0;
+
+ virtual Vector2 get_contact_local_position(int p_contact_idx) const = 0;
+ virtual Vector2 get_contact_local_normal(int p_contact_idx) const = 0;
+ virtual int get_contact_local_shape(int p_contact_idx) const = 0;
+ virtual Vector2 get_contact_local_velocity_at_position(int p_contact_idx) const = 0;
+
+ virtual RID get_contact_collider(int p_contact_idx) const = 0;
+ virtual Vector2 get_contact_collider_position(int p_contact_idx) const = 0;
+ virtual ObjectID get_contact_collider_id(int p_contact_idx) const = 0;
+ virtual Object *get_contact_collider_object(int p_contact_idx) const;
+ virtual int get_contact_collider_shape(int p_contact_idx) const = 0;
+ virtual Vector2 get_contact_collider_velocity_at_position(int p_contact_idx) const = 0;
+ virtual Vector2 get_contact_impulse(int p_contact_idx) const = 0;
+
+ virtual real_t get_step() const = 0;
+ virtual void integrate_forces();
+
+ virtual RequiredResult<PhysicsDirectSpaceState2D> get_space_state() = 0;
+
+ PhysicsDirectBodyState2D();
+};
diff --git a/servers/physics_2d/direct_states/physics_direct_space_state_2d.cpp b/servers/physics_2d/direct_states/physics_direct_space_state_2d.cpp
new file mode 100644
index 00000000000..ac0daffd88f
--- /dev/null
+++ b/servers/physics_2d/direct_states/physics_direct_space_state_2d.cpp
@@ -0,0 +1,166 @@
+/**************************************************************************/
+/* physics_direct_space_state_2d.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 "physics_direct_space_state_2d.h"
+
+#include "core/object/class_db.h"
+#include "core/variant/typed_array.h"
+
+Dictionary PhysicsDirectSpaceState2D::_intersect_ray(RequiredParam<PhysicsRayQueryParameters2D> rp_ray_query) {
+ EXTRACT_PARAM_OR_FAIL_V(p_ray_query, rp_ray_query, Dictionary());
+
+ PS2DT::RayResult result;
+ bool res = intersect_ray(p_ray_query->get_parameters(), result);
+
+ if (!res) {
+ return Dictionary();
+ }
+
+ Dictionary d;
+ d["position"] = result.position;
+ d["normal"] = result.normal;
+ d["collider_id"] = result.collider_id;
+ d["collider"] = result.collider;
+ d["shape"] = result.shape;
+ d["rid"] = result.rid;
+
+ return d;
+}
+
+TypedArray<Dictionary> PhysicsDirectSpaceState2D::_intersect_point(RequiredParam<PhysicsPointQueryParameters2D> rp_point_query, int p_max_results) {
+ EXTRACT_PARAM_OR_FAIL_V(p_point_query, rp_point_query, TypedArray<Dictionary>());
+
+ Vector<PS2DT::ShapeResult> ret;
+ ret.resize(p_max_results);
+
+ int rc = intersect_point(p_point_query->get_parameters(), ret.ptrw(), ret.size());
+
+ if (rc == 0) {
+ return TypedArray<Dictionary>();
+ }
+
+ TypedArray<Dictionary> r;
+ r.resize(rc);
+ for (int i = 0; i < rc; i++) {
+ Dictionary d;
+ d["rid"] = ret[i].rid;
+ d["collider_id"] = ret[i].collider_id;
+ d["collider"] = ret[i].collider;
+ d["shape"] = ret[i].shape;
+ r[i] = d;
+ }
+ return r;
+}
+
+TypedArray<Dictionary> PhysicsDirectSpaceState2D::_intersect_shape(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query, int p_max_results) {
+ EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, TypedArray<Dictionary>());
+
+ Vector<PS2DT::ShapeResult> sr;
+ sr.resize(p_max_results);
+ int rc = intersect_shape(p_shape_query->get_parameters(), sr.ptrw(), sr.size());
+ TypedArray<Dictionary> ret;
+ ret.resize(rc);
+ for (int i = 0; i < rc; i++) {
+ Dictionary d;
+ d["rid"] = sr[i].rid;
+ d["collider_id"] = sr[i].collider_id;
+ d["collider"] = sr[i].collider;
+ d["shape"] = sr[i].shape;
+ ret[i] = d;
+ }
+
+ return ret;
+}
+
+Vector<real_t> PhysicsDirectSpaceState2D::_cast_motion(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query) {
+ EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, Vector<real_t>());
+
+ real_t closest_safe, closest_unsafe;
+ bool res = cast_motion(p_shape_query->get_parameters(), closest_safe, closest_unsafe);
+ if (!res) {
+ return Vector<real_t>();
+ }
+ Vector<real_t> ret;
+ ret.resize(2);
+ ret.write[0] = closest_safe;
+ ret.write[1] = closest_unsafe;
+ return ret;
+}
+
+TypedArray<Vector2> PhysicsDirectSpaceState2D::_collide_shape(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query, int p_max_results) {
+ EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, TypedArray<Vector2>());
+
+ Vector<Vector2> ret;
+ ret.resize(p_max_results * 2);
+ int rc = 0;
+ bool res = collide_shape(p_shape_query->get_parameters(), ret.ptrw(), p_max_results, rc);
+ if (!res) {
+ return TypedArray<Vector2>();
+ }
+ TypedArray<Vector2> r;
+ r.resize(rc * 2);
+ for (int i = 0; i < rc * 2; i++) {
+ r[i] = ret[i];
+ }
+ return r;
+}
+
+Dictionary PhysicsDirectSpaceState2D::_get_rest_info(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query) {
+ EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, Dictionary());
+
+ PS2DT::ShapeRestInfo sri;
+
+ bool res = rest_info(p_shape_query->get_parameters(), &sri);
+ Dictionary r;
+ if (!res) {
+ return r;
+ }
+
+ r["point"] = sri.point;
+ r["normal"] = sri.normal;
+ r["rid"] = sri.rid;
+ r["collider_id"] = sri.collider_id;
+ r["shape"] = sri.shape;
+ r["linear_velocity"] = sri.linear_velocity;
+
+ return r;
+}
+
+PhysicsDirectSpaceState2D::PhysicsDirectSpaceState2D() {
+}
+
+void PhysicsDirectSpaceState2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("intersect_point", "parameters", "max_results"), &PhysicsDirectSpaceState2D::_intersect_point, DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("intersect_ray", "parameters"), &PhysicsDirectSpaceState2D::_intersect_ray);
+ ClassDB::bind_method(D_METHOD("intersect_shape", "parameters", "max_results"), &PhysicsDirectSpaceState2D::_intersect_shape, DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("cast_motion", "parameters"), &PhysicsDirectSpaceState2D::_cast_motion);
+ ClassDB::bind_method(D_METHOD("collide_shape", "parameters", "max_results"), &PhysicsDirectSpaceState2D::_collide_shape, DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("get_rest_info", "parameters"), &PhysicsDirectSpaceState2D::_get_rest_info);
+}
diff --git a/servers/physics_2d/direct_states/physics_direct_space_state_2d.h b/servers/physics_2d/direct_states/physics_direct_space_state_2d.h
new file mode 100644
index 00000000000..aab6151732e
--- /dev/null
+++ b/servers/physics_2d/direct_states/physics_direct_space_state_2d.h
@@ -0,0 +1,63 @@
+/**************************************************************************/
+/* physics_direct_space_state_2d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/variant/type_info.h"
+#include "servers/physics_2d/physics_server_2d_types.h"
+#include "servers/physics_2d/queries/physics_point_query_parameters_2d.h"
+#include "servers/physics_2d/queries/physics_ray_query_parameters_2d.h"
+#include "servers/physics_2d/queries/physics_shape_query_parameters_2d.h"
+
+class PhysicsDirectSpaceState2D : public Object {
+ GDCLASS(PhysicsDirectSpaceState2D, Object);
+
+ Dictionary _intersect_ray(RequiredParam<PhysicsRayQueryParameters2D> rp_ray_query);
+ TypedArray<Dictionary> _intersect_point(RequiredParam<PhysicsPointQueryParameters2D> rp_point_query, int p_max_results = 32);
+ TypedArray<Dictionary> _intersect_shape(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query, int p_max_results = 32);
+ Vector<real_t> _cast_motion(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query);
+ TypedArray<Vector2> _collide_shape(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query, int p_max_results = 32);
+ Dictionary _get_rest_info(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query);
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual bool intersect_ray(const PS2DT::RayParameters &p_parameters, PS2DT::RayResult &r_result) = 0;
+
+ virtual int intersect_point(const PS2DT::PointParameters &p_parameters, PS2DT::ShapeResult *r_results, int p_result_max) = 0;
+
+ virtual int intersect_shape(const PS2DT::ShapeParameters &p_parameters, PS2DT::ShapeResult *r_results, int p_result_max) = 0;
+ virtual bool cast_motion(const PS2DT::ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) = 0;
+ virtual bool collide_shape(const PS2DT::ShapeParameters &p_parameters, Vector2 *r_results, int p_result_max, int &r_result_count) = 0;
+ virtual bool rest_info(const PS2DT::ShapeParameters &p_parameters, PS2DT::ShapeRestInfo *r_info) = 0;
+
+ PhysicsDirectSpaceState2D();
+};
diff --git a/servers/physics_2d/physics_server_2d.cpp b/servers/physics_2d/physics_server_2d.cpp
index 56cd195fb69..7084efb141d 100644
--- a/servers/physics_2d/physics_server_2d.cpp
+++ b/servers/physics_2d/physics_server_2d.cpp
@@ -33,592 +33,17 @@
#include "core/config/project_settings.h"
#include "core/object/class_db.h"
-#include "core/variant/typed_array.h"
PhysicsServer2D *PhysicsServer2D::singleton = nullptr;
-void PhysicsDirectBodyState2D::integrate_forces() {
- real_t step = get_step();
- Vector2 lv = get_linear_velocity();
- lv += get_total_gravity() * step;
-
- real_t av = get_angular_velocity();
-
- real_t damp = 1.0 - step * get_total_linear_damp();
-
- if (damp < 0) { // reached zero in the given time
- damp = 0;
- }
-
- lv *= damp;
-
- damp = 1.0 - step * get_total_angular_damp();
-
- if (damp < 0) { // reached zero in the given time
- damp = 0;
- }
-
- av *= damp;
-
- set_linear_velocity(lv);
- set_angular_velocity(av);
-}
-
-Object *PhysicsDirectBodyState2D::get_contact_collider_object(int p_contact_idx) const {
- ObjectID objid = get_contact_collider_id(p_contact_idx);
- Object *obj = ObjectDB::get_instance(objid);
- return obj;
-}
-
PhysicsServer2D *PhysicsServer2D::get_singleton() {
return singleton;
}
-void PhysicsDirectBodyState2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState2D::get_total_gravity);
- ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState2D::get_total_linear_damp);
- ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState2D::get_total_angular_damp);
-
- ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState2D::get_center_of_mass);
- ClassDB::bind_method(D_METHOD("get_center_of_mass_local"), &PhysicsDirectBodyState2D::get_center_of_mass_local);
- ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState2D::get_inverse_mass);
- ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState2D::get_inverse_inertia);
-
- ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &PhysicsDirectBodyState2D::set_linear_velocity);
- ClassDB::bind_method(D_METHOD("get_linear_velocity"), &PhysicsDirectBodyState2D::get_linear_velocity);
-
- ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &PhysicsDirectBodyState2D::set_angular_velocity);
- ClassDB::bind_method(D_METHOD("get_angular_velocity"), &PhysicsDirectBodyState2D::get_angular_velocity);
-
- ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsDirectBodyState2D::set_transform);
- ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsDirectBodyState2D::get_transform);
-
- ClassDB::bind_method(D_METHOD("get_velocity_at_local_position", "local_position"), &PhysicsDirectBodyState2D::get_velocity_at_local_position);
-
- ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &PhysicsDirectBodyState2D::apply_central_impulse);
- ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &PhysicsDirectBodyState2D::apply_torque_impulse);
- ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &PhysicsDirectBodyState2D::apply_impulse, Vector2());
-
- ClassDB::bind_method(D_METHOD("apply_central_force", "force"), &PhysicsDirectBodyState2D::apply_central_force, Vector2());
- ClassDB::bind_method(D_METHOD("apply_force", "force", "position"), &PhysicsDirectBodyState2D::apply_force, Vector2());
- ClassDB::bind_method(D_METHOD("apply_torque", "torque"), &PhysicsDirectBodyState2D::apply_torque);
-
- ClassDB::bind_method(D_METHOD("add_constant_central_force", "force"), &PhysicsDirectBodyState2D::add_constant_central_force, Vector2());
- ClassDB::bind_method(D_METHOD("add_constant_force", "force", "position"), &PhysicsDirectBodyState2D::add_constant_force, Vector2());
- ClassDB::bind_method(D_METHOD("add_constant_torque", "torque"), &PhysicsDirectBodyState2D::add_constant_torque);
-
- ClassDB::bind_method(D_METHOD("set_constant_force", "force"), &PhysicsDirectBodyState2D::set_constant_force);
- ClassDB::bind_method(D_METHOD("get_constant_force"), &PhysicsDirectBodyState2D::get_constant_force);
-
- ClassDB::bind_method(D_METHOD("set_constant_torque", "torque"), &PhysicsDirectBodyState2D::set_constant_torque);
- ClassDB::bind_method(D_METHOD("get_constant_torque"), &PhysicsDirectBodyState2D::get_constant_torque);
-
- ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &PhysicsDirectBodyState2D::set_sleep_state);
- ClassDB::bind_method(D_METHOD("is_sleeping"), &PhysicsDirectBodyState2D::is_sleeping);
-
- ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PhysicsDirectBodyState2D::set_collision_layer);
- ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsDirectBodyState2D::get_collision_layer);
-
- ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &PhysicsDirectBodyState2D::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsDirectBodyState2D::get_collision_mask);
-
- ClassDB::bind_method(D_METHOD("get_contact_count"), &PhysicsDirectBodyState2D::get_contact_count);
-
- ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_position);
- ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_normal);
- ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_shape);
- ClassDB::bind_method(D_METHOD("get_contact_local_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_velocity_at_position);
- ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider);
- ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_position);
- ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_id);
- ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_object);
- ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_shape);
- ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_velocity_at_position);
- ClassDB::bind_method(D_METHOD("get_contact_impulse", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_impulse);
- ClassDB::bind_method(D_METHOD("get_step"), &PhysicsDirectBodyState2D::get_step);
- ClassDB::bind_method(D_METHOD("integrate_forces"), &PhysicsDirectBodyState2D::integrate_forces);
- ClassDB::bind_method(D_METHOD("get_space_state"), &PhysicsDirectBodyState2D::get_space_state);
-
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "step"), "", "get_step");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inverse_mass"), "", "get_inverse_mass");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inverse_inertia"), "", "get_inverse_inertia");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "total_angular_damp"), "", "get_total_angular_damp");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "total_linear_damp"), "", "get_total_linear_damp");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "total_gravity"), "", "get_total_gravity");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center_of_mass"), "", "get_center_of_mass");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center_of_mass_local"), "", "get_center_of_mass_local");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "linear_velocity"), "set_linear_velocity", "get_linear_velocity");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sleeping"), "set_sleep_state", "is_sleeping");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer"), "set_collision_layer", "get_collision_layer");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask"), "set_collision_mask", "get_collision_mask");
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform");
-}
-
-PhysicsDirectBodyState2D::PhysicsDirectBodyState2D() {}
-
-///////////////////////////////////////////////////////
-
-Ref<PhysicsRayQueryParameters2D> PhysicsRayQueryParameters2D::create(Vector2 p_from, Vector2 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude) {
- Ref<PhysicsRayQueryParameters2D> params;
- params.instantiate();
- params->set_from(p_from);
- params->set_to(p_to);
- params->set_collision_mask(p_mask);
- params->set_exclude(p_exclude);
- return params;
-}
-
-void PhysicsRayQueryParameters2D::set_exclude(const TypedArray<RID> &p_exclude) {
- parameters.exclude.clear();
- for (int i = 0; i < p_exclude.size(); i++) {
- parameters.exclude.insert(p_exclude[i]);
- }
-}
-
-TypedArray<RID> PhysicsRayQueryParameters2D::get_exclude() const {
- TypedArray<RID> ret;
- ret.resize(parameters.exclude.size());
- int idx = 0;
- for (const RID &E : parameters.exclude) {
- ret[idx++] = E;
- }
- return ret;
-}
-
-void PhysicsRayQueryParameters2D::_bind_methods() {
- ClassDB::bind_static_method("PhysicsRayQueryParameters2D", D_METHOD("create", "from", "to", "collision_mask", "exclude"), &PhysicsRayQueryParameters2D::create, DEFVAL(UINT32_MAX), DEFVAL(TypedArray<RID>()));
-
- ClassDB::bind_method(D_METHOD("set_from", "from"), &PhysicsRayQueryParameters2D::set_from);
- ClassDB::bind_method(D_METHOD("get_from"), &PhysicsRayQueryParameters2D::get_from);
-
- ClassDB::bind_method(D_METHOD("set_to", "to"), &PhysicsRayQueryParameters2D::set_to);
- ClassDB::bind_method(D_METHOD("get_to"), &PhysicsRayQueryParameters2D::get_to);
-
- ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsRayQueryParameters2D::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsRayQueryParameters2D::get_collision_mask);
-
- ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsRayQueryParameters2D::set_exclude);
- ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsRayQueryParameters2D::get_exclude);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsRayQueryParameters2D::set_collide_with_bodies);
- ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsRayQueryParameters2D::is_collide_with_bodies_enabled);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsRayQueryParameters2D::set_collide_with_areas);
- ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsRayQueryParameters2D::is_collide_with_areas_enabled);
-
- ClassDB::bind_method(D_METHOD("set_hit_from_inside", "enable"), &PhysicsRayQueryParameters2D::set_hit_from_inside);
- ClassDB::bind_method(D_METHOD("is_hit_from_inside_enabled"), &PhysicsRayQueryParameters2D::is_hit_from_inside_enabled);
-
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "from"), "set_from", "get_from");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "to"), "set_to", "get_to");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude", "get_exclude");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hit_from_inside"), "set_hit_from_inside", "is_hit_from_inside_enabled");
-}
-
-///////////////////////////////////////////////////////
-
-void PhysicsPointQueryParameters2D::set_exclude(const TypedArray<RID> &p_exclude) {
- parameters.exclude.clear();
- for (int i = 0; i < p_exclude.size(); i++) {
- parameters.exclude.insert(p_exclude[i]);
- }
-}
-
-TypedArray<RID> PhysicsPointQueryParameters2D::get_exclude() const {
- TypedArray<RID> ret;
- ret.resize(parameters.exclude.size());
- int idx = 0;
- for (const RID &E : parameters.exclude) {
- ret[idx++] = E;
- }
- return ret;
-}
-
-void PhysicsPointQueryParameters2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_position", "position"), &PhysicsPointQueryParameters2D::set_position);
- ClassDB::bind_method(D_METHOD("get_position"), &PhysicsPointQueryParameters2D::get_position);
-
- ClassDB::bind_method(D_METHOD("set_canvas_instance_id", "canvas_instance_id"), &PhysicsPointQueryParameters2D::set_canvas_instance_id);
- ClassDB::bind_method(D_METHOD("get_canvas_instance_id"), &PhysicsPointQueryParameters2D::get_canvas_instance_id);
-
- ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsPointQueryParameters2D::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsPointQueryParameters2D::get_collision_mask);
-
- ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsPointQueryParameters2D::set_exclude);
- ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsPointQueryParameters2D::get_exclude);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsPointQueryParameters2D::set_collide_with_bodies);
- ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsPointQueryParameters2D::is_collide_with_bodies_enabled);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsPointQueryParameters2D::set_collide_with_areas);
- ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsPointQueryParameters2D::is_collide_with_areas_enabled);
-
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "canvas_instance_id", PROPERTY_HINT_OBJECT_ID), "set_canvas_instance_id", "get_canvas_instance_id");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude", "get_exclude");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
-}
-
-///////////////////////////////////////////////////////
-
-void PhysicsShapeQueryParameters2D::set_shape(const Ref<Resource> &p_shape_ref) {
- ERR_FAIL_COND(p_shape_ref.is_null());
- shape_ref = p_shape_ref;
- parameters.shape_rid = p_shape_ref->get_rid();
-}
-
-void PhysicsShapeQueryParameters2D::set_shape_rid(const RID &p_shape) {
- if (parameters.shape_rid != p_shape) {
- shape_ref = Ref<Resource>();
- parameters.shape_rid = p_shape;
- }
-}
-
-void PhysicsShapeQueryParameters2D::set_exclude(const TypedArray<RID> &p_exclude) {
- parameters.exclude.clear();
- for (int i = 0; i < p_exclude.size(); i++) {
- parameters.exclude.insert(p_exclude[i]);
- }
-}
-
-TypedArray<RID> PhysicsShapeQueryParameters2D::get_exclude() const {
- TypedArray<RID> ret;
- ret.resize(parameters.exclude.size());
- int idx = 0;
- for (const RID &E : parameters.exclude) {
- ret[idx++] = E;
- }
- return ret;
-}
-
-void PhysicsShapeQueryParameters2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters2D::set_shape);
- ClassDB::bind_method(D_METHOD("get_shape"), &PhysicsShapeQueryParameters2D::get_shape);
-
- ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters2D::set_shape_rid);
- ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters2D::get_shape_rid);
-
- ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsShapeQueryParameters2D::set_transform);
- ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsShapeQueryParameters2D::get_transform);
-
- ClassDB::bind_method(D_METHOD("set_motion", "motion"), &PhysicsShapeQueryParameters2D::set_motion);
- ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsShapeQueryParameters2D::get_motion);
-
- ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsShapeQueryParameters2D::set_margin);
- ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsShapeQueryParameters2D::get_margin);
-
- ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsShapeQueryParameters2D::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsShapeQueryParameters2D::get_collision_mask);
-
- ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsShapeQueryParameters2D::set_exclude);
- ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsShapeQueryParameters2D::get_exclude);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsShapeQueryParameters2D::set_collide_with_bodies);
- ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsShapeQueryParameters2D::is_collide_with_bodies_enabled);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsShapeQueryParameters2D::set_collide_with_areas);
- ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsShapeQueryParameters2D::is_collide_with_areas_enabled);
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude", "get_exclude");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin", PROPERTY_HINT_RANGE, "0,100,0.01"), "set_margin", "get_margin");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion"), "set_motion", "get_motion");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape2D"), "set_shape", "get_shape");
- ADD_PROPERTY(PropertyInfo(Variant::RID, "shape_rid"), "set_shape_rid", "get_shape_rid");
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
-}
-
-///////////////////////////////////////////////////////
-
-Dictionary PhysicsDirectSpaceState2D::_intersect_ray(RequiredParam<PhysicsRayQueryParameters2D> rp_ray_query) {
- EXTRACT_PARAM_OR_FAIL_V(p_ray_query, rp_ray_query, Dictionary());
-
- RayResult result;
- bool res = intersect_ray(p_ray_query->get_parameters(), result);
-
- if (!res) {
- return Dictionary();
- }
-
- Dictionary d;
- d["position"] = result.position;
- d["normal"] = result.normal;
- d["collider_id"] = result.collider_id;
- d["collider"] = result.collider;
- d["shape"] = result.shape;
- d["rid"] = result.rid;
-
- return d;
-}
-
-TypedArray<Dictionary> PhysicsDirectSpaceState2D::_intersect_point(RequiredParam<PhysicsPointQueryParameters2D> rp_point_query, int p_max_results) {
- EXTRACT_PARAM_OR_FAIL_V(p_point_query, rp_point_query, TypedArray<Dictionary>());
-
- Vector<ShapeResult> ret;
- ret.resize(p_max_results);
-
- int rc = intersect_point(p_point_query->get_parameters(), ret.ptrw(), ret.size());
-
- if (rc == 0) {
- return TypedArray<Dictionary>();
- }
-
- TypedArray<Dictionary> r;
- r.resize(rc);
- for (int i = 0; i < rc; i++) {
- Dictionary d;
- d["rid"] = ret[i].rid;
- d["collider_id"] = ret[i].collider_id;
- d["collider"] = ret[i].collider;
- d["shape"] = ret[i].shape;
- r[i] = d;
- }
- return r;
-}
-
-TypedArray<Dictionary> PhysicsDirectSpaceState2D::_intersect_shape(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query, int p_max_results) {
- EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, TypedArray<Dictionary>());
-
- Vector<ShapeResult> sr;
- sr.resize(p_max_results);
- int rc = intersect_shape(p_shape_query->get_parameters(), sr.ptrw(), sr.size());
- TypedArray<Dictionary> ret;
- ret.resize(rc);
- for (int i = 0; i < rc; i++) {
- Dictionary d;
- d["rid"] = sr[i].rid;
- d["collider_id"] = sr[i].collider_id;
- d["collider"] = sr[i].collider;
- d["shape"] = sr[i].shape;
- ret[i] = d;
- }
-
- return ret;
-}
-
-Vector<real_t> PhysicsDirectSpaceState2D::_cast_motion(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query) {
- EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, Vector<real_t>());
-
- real_t closest_safe, closest_unsafe;
- bool res = cast_motion(p_shape_query->get_parameters(), closest_safe, closest_unsafe);
- if (!res) {
- return Vector<real_t>();
- }
- Vector<real_t> ret;
- ret.resize(2);
- ret.write[0] = closest_safe;
- ret.write[1] = closest_unsafe;
- return ret;
-}
-
-TypedArray<Vector2> PhysicsDirectSpaceState2D::_collide_shape(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query, int p_max_results) {
- EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, TypedArray<Vector2>());
-
- Vector<Vector2> ret;
- ret.resize(p_max_results * 2);
- int rc = 0;
- bool res = collide_shape(p_shape_query->get_parameters(), ret.ptrw(), p_max_results, rc);
- if (!res) {
- return TypedArray<Vector2>();
- }
- TypedArray<Vector2> r;
- r.resize(rc * 2);
- for (int i = 0; i < rc * 2; i++) {
- r[i] = ret[i];
- }
- return r;
-}
-
-Dictionary PhysicsDirectSpaceState2D::_get_rest_info(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query) {
- EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, Dictionary());
-
- ShapeRestInfo sri;
-
- bool res = rest_info(p_shape_query->get_parameters(), &sri);
- Dictionary r;
- if (!res) {
- return r;
- }
-
- r["point"] = sri.point;
- r["normal"] = sri.normal;
- r["rid"] = sri.rid;
- r["collider_id"] = sri.collider_id;
- r["shape"] = sri.shape;
- r["linear_velocity"] = sri.linear_velocity;
-
- return r;
-}
-
-PhysicsDirectSpaceState2D::PhysicsDirectSpaceState2D() {
-}
-
-void PhysicsDirectSpaceState2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("intersect_point", "parameters", "max_results"), &PhysicsDirectSpaceState2D::_intersect_point, DEFVAL(32));
- ClassDB::bind_method(D_METHOD("intersect_ray", "parameters"), &PhysicsDirectSpaceState2D::_intersect_ray);
- ClassDB::bind_method(D_METHOD("intersect_shape", "parameters", "max_results"), &PhysicsDirectSpaceState2D::_intersect_shape, DEFVAL(32));
- ClassDB::bind_method(D_METHOD("cast_motion", "parameters"), &PhysicsDirectSpaceState2D::_cast_motion);
- ClassDB::bind_method(D_METHOD("collide_shape", "parameters", "max_results"), &PhysicsDirectSpaceState2D::_collide_shape, DEFVAL(32));
- ClassDB::bind_method(D_METHOD("get_rest_info", "parameters"), &PhysicsDirectSpaceState2D::_get_rest_info);
-}
-
-///////////////////////////////
-
-TypedArray<RID> PhysicsTestMotionParameters2D::get_exclude_bodies() const {
- TypedArray<RID> exclude;
- exclude.resize(parameters.exclude_bodies.size());
-
- int body_index = 0;
- for (RID body : parameters.exclude_bodies) {
- exclude[body_index++] = body;
- }
-
- return exclude;
-}
-
-void PhysicsTestMotionParameters2D::set_exclude_bodies(const TypedArray<RID> &p_exclude) {
- parameters.exclude_bodies.clear();
- for (int i = 0; i < p_exclude.size(); i++) {
- parameters.exclude_bodies.insert(p_exclude[i]);
- }
-}
-
-TypedArray<uint64_t> PhysicsTestMotionParameters2D::get_exclude_objects() const {
- TypedArray<uint64_t> exclude;
- exclude.resize(parameters.exclude_objects.size());
-
- int object_index = 0;
- for (ObjectID object_id : parameters.exclude_objects) {
- exclude[object_index++] = object_id;
- }
-
- return exclude;
-}
-
-void PhysicsTestMotionParameters2D::set_exclude_objects(const TypedArray<uint64_t> &p_exclude) {
- parameters.exclude_objects.clear();
- for (int i = 0; i < p_exclude.size(); ++i) {
- ObjectID object_id = p_exclude[i];
- ERR_CONTINUE(object_id.is_null());
- parameters.exclude_objects.insert(object_id);
- }
-}
-
-void PhysicsTestMotionParameters2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_from"), &PhysicsTestMotionParameters2D::get_from);
- ClassDB::bind_method(D_METHOD("set_from", "from"), &PhysicsTestMotionParameters2D::set_from);
-
- ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsTestMotionParameters2D::get_motion);
- ClassDB::bind_method(D_METHOD("set_motion", "motion"), &PhysicsTestMotionParameters2D::set_motion);
-
- ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsTestMotionParameters2D::get_margin);
- ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsTestMotionParameters2D::set_margin);
-
- ClassDB::bind_method(D_METHOD("is_collide_separation_ray_enabled"), &PhysicsTestMotionParameters2D::is_collide_separation_ray_enabled);
- ClassDB::bind_method(D_METHOD("set_collide_separation_ray_enabled", "enabled"), &PhysicsTestMotionParameters2D::set_collide_separation_ray_enabled);
-
- ClassDB::bind_method(D_METHOD("get_exclude_bodies"), &PhysicsTestMotionParameters2D::get_exclude_bodies);
- ClassDB::bind_method(D_METHOD("set_exclude_bodies", "exclude_list"), &PhysicsTestMotionParameters2D::set_exclude_bodies);
-
- ClassDB::bind_method(D_METHOD("get_exclude_objects"), &PhysicsTestMotionParameters2D::get_exclude_objects);
- ClassDB::bind_method(D_METHOD("set_exclude_objects", "exclude_list"), &PhysicsTestMotionParameters2D::set_exclude_objects);
-
- ClassDB::bind_method(D_METHOD("is_recovery_as_collision_enabled"), &PhysicsTestMotionParameters2D::is_recovery_as_collision_enabled);
- ClassDB::bind_method(D_METHOD("set_recovery_as_collision_enabled", "enabled"), &PhysicsTestMotionParameters2D::set_recovery_as_collision_enabled);
-
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "from"), "set_from", "get_from");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion"), "set_motion", "get_motion");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin"), "set_margin", "get_margin");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_separation_ray"), "set_collide_separation_ray_enabled", "is_collide_separation_ray_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude_bodies", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude_bodies", "get_exclude_bodies");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude_objects"), "set_exclude_objects", "get_exclude_objects");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "recovery_as_collision"), "set_recovery_as_collision_enabled", "is_recovery_as_collision_enabled");
-}
-
-///////////////////////////////
-
-Vector2 PhysicsTestMotionResult2D::get_travel() const {
- return result.travel;
-}
-
-Vector2 PhysicsTestMotionResult2D::get_remainder() const {
- return result.remainder;
-}
-
-Vector2 PhysicsTestMotionResult2D::get_collision_point() const {
- return result.collision_point;
-}
-
-Vector2 PhysicsTestMotionResult2D::get_collision_normal() const {
- return result.collision_normal;
-}
-
-Vector2 PhysicsTestMotionResult2D::get_collider_velocity() const {
- return result.collider_velocity;
-}
-
-ObjectID PhysicsTestMotionResult2D::get_collider_id() const {
- return result.collider_id;
-}
-
-RID PhysicsTestMotionResult2D::get_collider_rid() const {
- return result.collider;
-}
-
-Object *PhysicsTestMotionResult2D::get_collider() const {
- return ObjectDB::get_instance(result.collider_id);
-}
-
-int PhysicsTestMotionResult2D::get_collider_shape() const {
- return result.collider_shape;
-}
-
-int PhysicsTestMotionResult2D::get_collision_local_shape() const {
- return result.collision_local_shape;
-}
-
-real_t PhysicsTestMotionResult2D::get_collision_depth() const {
- return result.collision_depth;
-}
-
-real_t PhysicsTestMotionResult2D::get_collision_safe_fraction() const {
- return result.collision_safe_fraction;
-}
-
-real_t PhysicsTestMotionResult2D::get_collision_unsafe_fraction() const {
- return result.collision_unsafe_fraction;
-}
-
-void PhysicsTestMotionResult2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_travel"), &PhysicsTestMotionResult2D::get_travel);
- ClassDB::bind_method(D_METHOD("get_remainder"), &PhysicsTestMotionResult2D::get_remainder);
- ClassDB::bind_method(D_METHOD("get_collision_point"), &PhysicsTestMotionResult2D::get_collision_point);
- ClassDB::bind_method(D_METHOD("get_collision_normal"), &PhysicsTestMotionResult2D::get_collision_normal);
- ClassDB::bind_method(D_METHOD("get_collider_velocity"), &PhysicsTestMotionResult2D::get_collider_velocity);
- ClassDB::bind_method(D_METHOD("get_collider_id"), &PhysicsTestMotionResult2D::get_collider_id);
- ClassDB::bind_method(D_METHOD("get_collider_rid"), &PhysicsTestMotionResult2D::get_collider_rid);
- ClassDB::bind_method(D_METHOD("get_collider"), &PhysicsTestMotionResult2D::get_collider);
- ClassDB::bind_method(D_METHOD("get_collider_shape"), &PhysicsTestMotionResult2D::get_collider_shape);
- ClassDB::bind_method(D_METHOD("get_collision_local_shape"), &PhysicsTestMotionResult2D::get_collision_local_shape);
- ClassDB::bind_method(D_METHOD("get_collision_depth"), &PhysicsTestMotionResult2D::get_collision_depth);
- ClassDB::bind_method(D_METHOD("get_collision_safe_fraction"), &PhysicsTestMotionResult2D::get_collision_safe_fraction);
- ClassDB::bind_method(D_METHOD("get_collision_unsafe_fraction"), &PhysicsTestMotionResult2D::get_collision_unsafe_fraction);
-}
-
-///////////////////////////////////////
-
bool PhysicsServer2D::_body_test_motion(RID p_body, RequiredParam<PhysicsTestMotionParameters2D> rp_parameters, const Ref<PhysicsTestMotionResult2D> &p_result) {
EXTRACT_PARAM_OR_FAIL_V(p_parameters, rp_parameters, false);
- MotionResult *result_ptr = nullptr;
+ PS2DT::MotionResult *result_ptr = nullptr;
if (p_result.is_valid()) {
result_ptr = p_result->get_result_ptr();
}
@@ -804,100 +229,100 @@ void PhysicsServer2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer2D::get_process_info);
- BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS);
- BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_MAX_SEPARATION);
- BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION);
- BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_DEFAULT_BIAS);
- BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD);
- BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD);
- BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_TIME_TO_SLEEP);
- BIND_ENUM_CONSTANT(SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS);
- BIND_ENUM_CONSTANT(SPACE_PARAM_SOLVER_ITERATIONS);
-
- BIND_ENUM_CONSTANT(SHAPE_WORLD_BOUNDARY);
- BIND_ENUM_CONSTANT(SHAPE_SEPARATION_RAY);
- BIND_ENUM_CONSTANT(SHAPE_SEGMENT);
- BIND_ENUM_CONSTANT(SHAPE_CIRCLE);
- BIND_ENUM_CONSTANT(SHAPE_RECTANGLE);
- BIND_ENUM_CONSTANT(SHAPE_CAPSULE);
- BIND_ENUM_CONSTANT(SHAPE_CONVEX_POLYGON);
- BIND_ENUM_CONSTANT(SHAPE_CONCAVE_POLYGON);
- BIND_ENUM_CONSTANT(SHAPE_CUSTOM);
-
- BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_OVERRIDE_MODE);
- BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY);
- BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_VECTOR);
- BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_IS_POINT);
- BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE);
- BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE);
- BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP);
- BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE);
- BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP);
- BIND_ENUM_CONSTANT(AREA_PARAM_PRIORITY);
-
- BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_DISABLED);
- BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE);
- BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE_REPLACE);
- BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE);
- BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE_COMBINE);
-
- BIND_ENUM_CONSTANT(BODY_MODE_STATIC);
- BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC);
- BIND_ENUM_CONSTANT(BODY_MODE_RIGID);
- BIND_ENUM_CONSTANT(BODY_MODE_RIGID_LINEAR);
-
- BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE);
- BIND_ENUM_CONSTANT(BODY_PARAM_FRICTION);
- BIND_ENUM_CONSTANT(BODY_PARAM_MASS);
- BIND_ENUM_CONSTANT(BODY_PARAM_INERTIA);
- BIND_ENUM_CONSTANT(BODY_PARAM_CENTER_OF_MASS);
- BIND_ENUM_CONSTANT(BODY_PARAM_GRAVITY_SCALE);
- BIND_ENUM_CONSTANT(BODY_PARAM_LINEAR_DAMP_MODE);
- BIND_ENUM_CONSTANT(BODY_PARAM_ANGULAR_DAMP_MODE);
- BIND_ENUM_CONSTANT(BODY_PARAM_LINEAR_DAMP);
- BIND_ENUM_CONSTANT(BODY_PARAM_ANGULAR_DAMP);
- BIND_ENUM_CONSTANT(BODY_PARAM_MAX);
-
- BIND_ENUM_CONSTANT(BODY_DAMP_MODE_COMBINE);
- BIND_ENUM_CONSTANT(BODY_DAMP_MODE_REPLACE);
-
- BIND_ENUM_CONSTANT(BODY_STATE_TRANSFORM);
- BIND_ENUM_CONSTANT(BODY_STATE_LINEAR_VELOCITY);
- BIND_ENUM_CONSTANT(BODY_STATE_ANGULAR_VELOCITY);
- BIND_ENUM_CONSTANT(BODY_STATE_SLEEPING);
- BIND_ENUM_CONSTANT(BODY_STATE_CAN_SLEEP);
-
- BIND_ENUM_CONSTANT(JOINT_TYPE_PIN);
- BIND_ENUM_CONSTANT(JOINT_TYPE_GROOVE);
- BIND_ENUM_CONSTANT(JOINT_TYPE_DAMPED_SPRING);
- BIND_ENUM_CONSTANT(JOINT_TYPE_MAX);
-
- BIND_ENUM_CONSTANT(JOINT_PARAM_BIAS);
- BIND_ENUM_CONSTANT(JOINT_PARAM_MAX_BIAS);
- BIND_ENUM_CONSTANT(JOINT_PARAM_MAX_FORCE);
-
- BIND_ENUM_CONSTANT(PIN_JOINT_SOFTNESS);
- BIND_ENUM_CONSTANT(PIN_JOINT_LIMIT_UPPER);
- BIND_ENUM_CONSTANT(PIN_JOINT_LIMIT_LOWER);
- BIND_ENUM_CONSTANT(PIN_JOINT_MOTOR_TARGET_VELOCITY);
-
- BIND_ENUM_CONSTANT(PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED);
- BIND_ENUM_CONSTANT(PIN_JOINT_FLAG_MOTOR_ENABLED);
-
- BIND_ENUM_CONSTANT(DAMPED_SPRING_REST_LENGTH);
- BIND_ENUM_CONSTANT(DAMPED_SPRING_STIFFNESS);
- BIND_ENUM_CONSTANT(DAMPED_SPRING_DAMPING);
-
- BIND_ENUM_CONSTANT(CCD_MODE_DISABLED);
- BIND_ENUM_CONSTANT(CCD_MODE_CAST_RAY);
- BIND_ENUM_CONSTANT(CCD_MODE_CAST_SHAPE);
-
- BIND_ENUM_CONSTANT(AREA_BODY_ADDED);
- BIND_ENUM_CONSTANT(AREA_BODY_REMOVED);
-
- BIND_ENUM_CONSTANT(INFO_ACTIVE_OBJECTS);
- BIND_ENUM_CONSTANT(INFO_COLLISION_PAIRS);
- BIND_ENUM_CONSTANT(INFO_ISLAND_COUNT);
+ BIND_ENUM_CONSTANT(PS2DE::SPACE_PARAM_CONTACT_RECYCLE_RADIUS);
+ BIND_ENUM_CONSTANT(PS2DE::SPACE_PARAM_CONTACT_MAX_SEPARATION);
+ BIND_ENUM_CONSTANT(PS2DE::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION);
+ BIND_ENUM_CONSTANT(PS2DE::SPACE_PARAM_CONTACT_DEFAULT_BIAS);
+ BIND_ENUM_CONSTANT(PS2DE::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD);
+ BIND_ENUM_CONSTANT(PS2DE::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD);
+ BIND_ENUM_CONSTANT(PS2DE::SPACE_PARAM_BODY_TIME_TO_SLEEP);
+ BIND_ENUM_CONSTANT(PS2DE::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS);
+ BIND_ENUM_CONSTANT(PS2DE::SPACE_PARAM_SOLVER_ITERATIONS);
+
+ BIND_ENUM_CONSTANT(PS2DE::SHAPE_WORLD_BOUNDARY);
+ BIND_ENUM_CONSTANT(PS2DE::SHAPE_SEPARATION_RAY);
+ BIND_ENUM_CONSTANT(PS2DE::SHAPE_SEGMENT);
+ BIND_ENUM_CONSTANT(PS2DE::SHAPE_CIRCLE);
+ BIND_ENUM_CONSTANT(PS2DE::SHAPE_RECTANGLE);
+ BIND_ENUM_CONSTANT(PS2DE::SHAPE_CAPSULE);
+ BIND_ENUM_CONSTANT(PS2DE::SHAPE_CONVEX_POLYGON);
+ BIND_ENUM_CONSTANT(PS2DE::SHAPE_CONCAVE_POLYGON);
+ BIND_ENUM_CONSTANT(PS2DE::SHAPE_CUSTOM);
+
+ BIND_ENUM_CONSTANT(PS2DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_PARAM_GRAVITY);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_PARAM_GRAVITY_VECTOR);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_PARAM_GRAVITY_IS_POINT);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_PARAM_LINEAR_DAMP);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_PARAM_ANGULAR_DAMP);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_PARAM_PRIORITY);
+
+ BIND_ENUM_CONSTANT(PS2DE::AREA_SPACE_OVERRIDE_DISABLED);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_SPACE_OVERRIDE_COMBINE);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_SPACE_OVERRIDE_REPLACE);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_SPACE_OVERRIDE_REPLACE_COMBINE);
+
+ BIND_ENUM_CONSTANT(PS2DE::BODY_MODE_STATIC);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_MODE_KINEMATIC);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_MODE_RIGID);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_MODE_RIGID_LINEAR);
+
+ BIND_ENUM_CONSTANT(PS2DE::BODY_PARAM_BOUNCE);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_PARAM_FRICTION);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_PARAM_MASS);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_PARAM_INERTIA);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_PARAM_CENTER_OF_MASS);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_PARAM_GRAVITY_SCALE);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_PARAM_LINEAR_DAMP_MODE);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_PARAM_ANGULAR_DAMP_MODE);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_PARAM_LINEAR_DAMP);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_PARAM_ANGULAR_DAMP);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_PARAM_MAX);
+
+ BIND_ENUM_CONSTANT(PS2DE::BODY_DAMP_MODE_COMBINE);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_DAMP_MODE_REPLACE);
+
+ BIND_ENUM_CONSTANT(PS2DE::BODY_STATE_TRANSFORM);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_STATE_LINEAR_VELOCITY);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_STATE_ANGULAR_VELOCITY);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_STATE_SLEEPING);
+ BIND_ENUM_CONSTANT(PS2DE::BODY_STATE_CAN_SLEEP);
+
+ BIND_ENUM_CONSTANT(PS2DE::JOINT_TYPE_PIN);
+ BIND_ENUM_CONSTANT(PS2DE::JOINT_TYPE_GROOVE);
+ BIND_ENUM_CONSTANT(PS2DE::JOINT_TYPE_DAMPED_SPRING);
+ BIND_ENUM_CONSTANT(PS2DE::JOINT_TYPE_MAX);
+
+ BIND_ENUM_CONSTANT(PS2DE::JOINT_PARAM_BIAS);
+ BIND_ENUM_CONSTANT(PS2DE::JOINT_PARAM_MAX_BIAS);
+ BIND_ENUM_CONSTANT(PS2DE::JOINT_PARAM_MAX_FORCE);
+
+ BIND_ENUM_CONSTANT(PS2DE::PIN_JOINT_SOFTNESS);
+ BIND_ENUM_CONSTANT(PS2DE::PIN_JOINT_LIMIT_UPPER);
+ BIND_ENUM_CONSTANT(PS2DE::PIN_JOINT_LIMIT_LOWER);
+ BIND_ENUM_CONSTANT(PS2DE::PIN_JOINT_MOTOR_TARGET_VELOCITY);
+
+ BIND_ENUM_CONSTANT(PS2DE::PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED);
+ BIND_ENUM_CONSTANT(PS2DE::PIN_JOINT_FLAG_MOTOR_ENABLED);
+
+ BIND_ENUM_CONSTANT(PS2DE::DAMPED_SPRING_REST_LENGTH);
+ BIND_ENUM_CONSTANT(PS2DE::DAMPED_SPRING_STIFFNESS);
+ BIND_ENUM_CONSTANT(PS2DE::DAMPED_SPRING_DAMPING);
+
+ BIND_ENUM_CONSTANT(PS2DE::CCD_MODE_DISABLED);
+ BIND_ENUM_CONSTANT(PS2DE::CCD_MODE_CAST_RAY);
+ BIND_ENUM_CONSTANT(PS2DE::CCD_MODE_CAST_SHAPE);
+
+ BIND_ENUM_CONSTANT(PS2DE::AREA_BODY_ADDED);
+ BIND_ENUM_CONSTANT(PS2DE::AREA_BODY_REMOVED);
+
+ BIND_ENUM_CONSTANT(PS2DE::INFO_ACTIVE_OBJECTS);
+ BIND_ENUM_CONSTANT(PS2DE::INFO_COLLISION_PAIRS);
+ BIND_ENUM_CONSTANT(PS2DE::INFO_ISLAND_COUNT);
}
PhysicsServer2D::PhysicsServer2D() {
diff --git a/servers/physics_2d/physics_server_2d.h b/servers/physics_2d/physics_server_2d.h
index d185fcd2026..7870e09959c 100644
--- a/servers/physics_2d/physics_server_2d.h
+++ b/servers/physics_2d/physics_server_2d.h
@@ -30,185 +30,14 @@
#pragma once
-#include "core/io/resource.h"
#include "core/object/ref_counted.h"
-
-constexpr int MAX_CONTACTS_REPORTED_2D_MAX = 4096;
-
-class PhysicsDirectSpaceState2D;
-template <typename T>
-class TypedArray;
-
-class PhysicsDirectBodyState2D : public Object {
- GDCLASS(PhysicsDirectBodyState2D, Object);
-
-protected:
- static void _bind_methods();
-
-public:
- virtual Vector2 get_total_gravity() const = 0; // get gravity vector working on this body space/area
- virtual real_t get_total_linear_damp() const = 0; // get density of this body space/area
- virtual real_t get_total_angular_damp() const = 0; // get density of this body space/area
-
- virtual Vector2 get_center_of_mass() const = 0;
- virtual Vector2 get_center_of_mass_local() const = 0;
- virtual real_t get_inverse_mass() const = 0; // get the mass
- virtual real_t get_inverse_inertia() const = 0; // get density of this body space
-
- virtual void set_linear_velocity(const Vector2 &p_velocity) = 0;
- virtual Vector2 get_linear_velocity() const = 0;
-
- virtual void set_angular_velocity(real_t p_velocity) = 0;
- virtual real_t get_angular_velocity() const = 0;
-
- virtual void set_transform(const Transform2D &p_transform) = 0;
- virtual Transform2D get_transform() const = 0;
-
- virtual Vector2 get_velocity_at_local_position(const Vector2 &p_position) const = 0;
-
- virtual void apply_central_impulse(const Vector2 &p_impulse) = 0;
- virtual void apply_torque_impulse(real_t p_torque) = 0;
- virtual void apply_impulse(const Vector2 &p_impulse, const Vector2 &p_position = Vector2()) = 0;
-
- virtual void apply_central_force(const Vector2 &p_force) = 0;
- virtual void apply_force(const Vector2 &p_force, const Vector2 &p_position = Vector2()) = 0;
- virtual void apply_torque(real_t p_torque) = 0;
-
- virtual void add_constant_central_force(const Vector2 &p_force) = 0;
- virtual void add_constant_force(const Vector2 &p_force, const Vector2 &p_position = Vector2()) = 0;
- virtual void add_constant_torque(real_t p_torque) = 0;
-
- virtual void set_constant_force(const Vector2 &p_force) = 0;
- virtual Vector2 get_constant_force() const = 0;
-
- virtual void set_constant_torque(real_t p_torque) = 0;
- virtual real_t get_constant_torque() const = 0;
-
- virtual void set_sleep_state(bool p_enable) = 0;
- virtual bool is_sleeping() const = 0;
-
- virtual void set_collision_layer(uint32_t p_layer) = 0;
- virtual uint32_t get_collision_layer() const = 0;
-
- virtual void set_collision_mask(uint32_t p_mask) = 0;
- virtual uint32_t get_collision_mask() const = 0;
-
- virtual int get_contact_count() const = 0;
-
- virtual Vector2 get_contact_local_position(int p_contact_idx) const = 0;
- virtual Vector2 get_contact_local_normal(int p_contact_idx) const = 0;
- virtual int get_contact_local_shape(int p_contact_idx) const = 0;
- virtual Vector2 get_contact_local_velocity_at_position(int p_contact_idx) const = 0;
-
- virtual RID get_contact_collider(int p_contact_idx) const = 0;
- virtual Vector2 get_contact_collider_position(int p_contact_idx) const = 0;
- virtual ObjectID get_contact_collider_id(int p_contact_idx) const = 0;
- virtual Object *get_contact_collider_object(int p_contact_idx) const;
- virtual int get_contact_collider_shape(int p_contact_idx) const = 0;
- virtual Vector2 get_contact_collider_velocity_at_position(int p_contact_idx) const = 0;
- virtual Vector2 get_contact_impulse(int p_contact_idx) const = 0;
-
- virtual real_t get_step() const = 0;
- virtual void integrate_forces();
-
- virtual RequiredResult<PhysicsDirectSpaceState2D> get_space_state() = 0;
-
- PhysicsDirectBodyState2D();
-};
-
-class PhysicsRayQueryParameters2D;
-class PhysicsPointQueryParameters2D;
-class PhysicsShapeQueryParameters2D;
-
-class PhysicsDirectSpaceState2D : public Object {
- GDCLASS(PhysicsDirectSpaceState2D, Object);
-
- Dictionary _intersect_ray(RequiredParam<PhysicsRayQueryParameters2D> rp_ray_query);
- TypedArray<Dictionary> _intersect_point(RequiredParam<PhysicsPointQueryParameters2D> rp_point_query, int p_max_results = 32);
- TypedArray<Dictionary> _intersect_shape(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query, int p_max_results = 32);
- Vector<real_t> _cast_motion(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query);
- TypedArray<Vector2> _collide_shape(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query, int p_max_results = 32);
- Dictionary _get_rest_info(RequiredParam<PhysicsShapeQueryParameters2D> rp_shape_query);
-
-protected:
- static void _bind_methods();
-
-public:
- struct RayParameters {
- Vector2 from;
- Vector2 to;
- HashSet<RID> exclude;
- uint32_t collision_mask = UINT32_MAX;
-
- bool collide_with_bodies = true;
- bool collide_with_areas = false;
-
- bool hit_from_inside = false;
- };
-
- struct RayResult {
- Vector2 position;
- Vector2 normal;
- RID rid;
- ObjectID collider_id;
- Object *collider = nullptr;
- int shape = 0;
- };
-
- virtual bool intersect_ray(const RayParameters &p_parameters, RayResult &r_result) = 0;
-
- struct ShapeResult {
- RID rid;
- ObjectID collider_id;
- Object *collider = nullptr;
- int shape = 0;
- };
-
- struct PointParameters {
- Vector2 position;
- ObjectID canvas_instance_id;
- HashSet<RID> exclude;
- uint32_t collision_mask = UINT32_MAX;
-
- bool collide_with_bodies = true;
- bool collide_with_areas = false;
-
- bool pick_point = false;
- };
-
- virtual int intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) = 0;
-
- struct ShapeParameters {
- RID shape_rid;
- Transform2D transform;
- Vector2 motion;
- real_t margin = 0.0;
- HashSet<RID> exclude;
- uint32_t collision_mask = UINT32_MAX;
-
- bool collide_with_bodies = true;
- bool collide_with_areas = false;
- };
-
- struct ShapeRestInfo {
- Vector2 point;
- Vector2 normal;
- RID rid;
- ObjectID collider_id;
- int shape = 0;
- Vector2 linear_velocity; // Velocity at contact point.
- };
-
- virtual int intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) = 0;
- virtual bool cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) = 0;
- virtual bool collide_shape(const ShapeParameters &p_parameters, Vector2 *r_results, int p_result_max, int &r_result_count) = 0;
- virtual bool rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) = 0;
-
- PhysicsDirectSpaceState2D();
-};
-
-class PhysicsTestMotionParameters2D;
-class PhysicsTestMotionResult2D;
+#include "servers/physics_2d/direct_states/physics_direct_body_state_2d.h"
+#include "servers/physics_2d/direct_states/physics_direct_space_state_2d.h"
+#include "servers/physics_2d/physics_server_2d_enums.h"
+#include "servers/physics_2d/physics_server_2d_types.h"
+#include "servers/physics_2d/queries/physics_shape_query_parameters_2d.h"
+#include "servers/physics_2d/queries/physics_testmotion_query_parameters_2d.h"
+#include "servers/physics_2d/queries/physics_testmotion_query_result_2d.h"
class PhysicsServer2D : public Object {
GDCLASS(PhysicsServer2D, Object);
@@ -228,18 +57,6 @@ protected:
public:
static PhysicsServer2D *get_singleton();
- enum ShapeType {
- SHAPE_WORLD_BOUNDARY, ///< plane:"plane"
- SHAPE_SEPARATION_RAY, ///< float:"length"
- SHAPE_SEGMENT, ///< float:"length"
- SHAPE_CIRCLE, ///< float:"radius"
- SHAPE_RECTANGLE, ///< vec3:"extents"
- SHAPE_CAPSULE,
- SHAPE_CONVEX_POLYGON, ///< array of planes:"planes"
- SHAPE_CONCAVE_POLYGON, ///< Vector2 array:"triangles" , or Dictionary with "indices" (int array) and "triangles" (Vector2 array)
- SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error
- };
-
virtual RID world_boundary_shape_create() = 0;
virtual RID separation_ray_shape_create() = 0;
virtual RID segment_shape_create() = 0;
@@ -252,7 +69,7 @@ public:
virtual void shape_set_data(RID p_shape, const Variant &p_data) = 0;
virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias) = 0;
- virtual ShapeType shape_get_type(RID p_shape) const = 0;
+ virtual PS2DE::ShapeType shape_get_type(RID p_shape) const = 0;
virtual Variant shape_get_data(RID p_shape) const = 0;
virtual real_t shape_get_custom_solver_bias(RID p_shape) const = 0;
@@ -265,20 +82,8 @@ public:
virtual void space_set_active(RID p_space, bool p_active) = 0;
virtual bool space_is_active(RID p_space) const = 0;
- enum SpaceParameter {
- SPACE_PARAM_CONTACT_RECYCLE_RADIUS,
- SPACE_PARAM_CONTACT_MAX_SEPARATION,
- SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION,
- SPACE_PARAM_CONTACT_DEFAULT_BIAS,
- SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD,
- SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD,
- SPACE_PARAM_BODY_TIME_TO_SLEEP,
- SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS,
- SPACE_PARAM_SOLVER_ITERATIONS,
- };
-
- virtual void space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) = 0;
- virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const = 0;
+ virtual void space_set_param(RID p_space, PS2DE::SpaceParameter p_param, real_t p_value) = 0;
+ virtual real_t space_get_param(RID p_space, PS2DE::SpaceParameter p_param) const = 0;
// this function only works on physics process, errors and returns null otherwise
virtual PhysicsDirectSpaceState2D *space_get_direct_state(RID p_space) = 0;
@@ -293,32 +98,11 @@ public:
//missing attenuation? missing better override?
- enum AreaParameter {
- AREA_PARAM_GRAVITY_OVERRIDE_MODE,
- AREA_PARAM_GRAVITY,
- AREA_PARAM_GRAVITY_VECTOR,
- AREA_PARAM_GRAVITY_IS_POINT,
- AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE,
- AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE,
- AREA_PARAM_LINEAR_DAMP,
- AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE,
- AREA_PARAM_ANGULAR_DAMP,
- AREA_PARAM_PRIORITY
- };
-
virtual RID area_create() = 0;
virtual void area_set_space(RID p_area, RID p_space) = 0;
virtual RID area_get_space(RID p_area) const = 0;
- enum AreaSpaceOverrideMode {
- AREA_SPACE_OVERRIDE_DISABLED,
- AREA_SPACE_OVERRIDE_COMBINE,
- AREA_SPACE_OVERRIDE_COMBINE_REPLACE, // Combines, then discards all subsequent calculations
- AREA_SPACE_OVERRIDE_REPLACE,
- AREA_SPACE_OVERRIDE_REPLACE_COMBINE // Discards all previous calculations, then keeps combining
- };
-
virtual void area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false) = 0;
virtual void area_set_shape(RID p_area, int p_shape_idx, RID p_shape) = 0;
virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) = 0;
@@ -338,10 +122,10 @@ public:
virtual void area_attach_canvas_instance_id(RID p_area, ObjectID p_id) = 0;
virtual ObjectID area_get_canvas_instance_id(RID p_area) const = 0;
- virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) = 0;
+ virtual void area_set_param(RID p_area, PS2DE::AreaParameter p_param, const Variant &p_value) = 0;
virtual void area_set_transform(RID p_area, const Transform2D &p_transform) = 0;
- virtual Variant area_get_param(RID p_parea, AreaParameter p_param) const = 0;
+ virtual Variant area_get_param(RID p_parea, PS2DE::AreaParameter p_param) const = 0;
virtual Transform2D area_get_transform(RID p_area) const = 0;
virtual void area_set_collision_layer(RID p_area, uint32_t p_layer) = 0;
@@ -360,20 +144,13 @@ public:
//missing ccd?
- enum BodyMode {
- BODY_MODE_STATIC,
- BODY_MODE_KINEMATIC,
- BODY_MODE_RIGID,
- BODY_MODE_RIGID_LINEAR,
- };
-
virtual RID body_create() = 0;
virtual void body_set_space(RID p_body, RID p_space) = 0;
virtual RID body_get_space(RID p_body) const = 0;
- virtual void body_set_mode(RID p_body, BodyMode p_mode) = 0;
- virtual BodyMode body_get_mode(RID p_body) const = 0;
+ virtual void body_set_mode(RID p_body, PS2DE::BodyMode p_mode) = 0;
+ virtual PS2DE::BodyMode body_get_mode(RID p_body) const = 0;
virtual void body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false) = 0;
virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape) = 0;
@@ -395,14 +172,8 @@ public:
virtual void body_attach_canvas_instance_id(RID p_body, ObjectID p_id) = 0;
virtual ObjectID body_get_canvas_instance_id(RID p_body) const = 0;
- enum CCDMode {
- CCD_MODE_DISABLED,
- CCD_MODE_CAST_RAY,
- CCD_MODE_CAST_SHAPE,
- };
-
- virtual void body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) = 0;
- virtual CCDMode body_get_continuous_collision_detection_mode(RID p_body) const = 0;
+ virtual void body_set_continuous_collision_detection_mode(RID p_body, PS2DE::CCDMode p_mode) = 0;
+ virtual PS2DE::CCDMode body_get_continuous_collision_detection_mode(RID p_body) const = 0;
virtual void body_set_collision_layer(RID p_body, uint32_t p_layer) = 0;
virtual uint32_t body_get_collision_layer(RID p_body) const = 0;
@@ -413,42 +184,15 @@ public:
virtual void body_set_collision_priority(RID p_body, real_t p_priority) = 0;
virtual real_t body_get_collision_priority(RID p_body) const = 0;
- // common body variables
- enum BodyParameter {
- BODY_PARAM_BOUNCE,
- BODY_PARAM_FRICTION,
- BODY_PARAM_MASS, ///< unused for static, always infinite
- BODY_PARAM_INERTIA,
- BODY_PARAM_CENTER_OF_MASS,
- BODY_PARAM_GRAVITY_SCALE,
- BODY_PARAM_LINEAR_DAMP_MODE,
- BODY_PARAM_ANGULAR_DAMP_MODE,
- BODY_PARAM_LINEAR_DAMP,
- BODY_PARAM_ANGULAR_DAMP,
- BODY_PARAM_MAX,
- };
-
- enum BodyDampMode {
- BODY_DAMP_MODE_COMBINE,
- BODY_DAMP_MODE_REPLACE,
- };
-
- virtual void body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) = 0;
- virtual Variant body_get_param(RID p_body, BodyParameter p_param) const = 0;
+ virtual void body_set_param(RID p_body, PS2DE::BodyParameter p_param, const Variant &p_value) = 0;
+ virtual Variant body_get_param(RID p_body, PS2DE::BodyParameter p_param) const = 0;
virtual void body_reset_mass_properties(RID p_body) = 0;
//state
- enum BodyState {
- BODY_STATE_TRANSFORM,
- BODY_STATE_LINEAR_VELOCITY,
- BODY_STATE_ANGULAR_VELOCITY,
- BODY_STATE_SLEEPING,
- BODY_STATE_CAN_SLEEP,
- };
- virtual void body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) = 0;
- virtual Variant body_get_state(RID p_body, BodyState p_state) const = 0;
+ virtual void body_set_state(RID p_body, PS2DE::BodyState p_state, const Variant &p_variant) = 0;
+ virtual Variant body_get_state(RID p_body, PS2DE::BodyState p_state) const = 0;
virtual void body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) = 0;
virtual void body_apply_torque_impulse(RID p_body, real_t p_torque) = 0;
@@ -495,44 +239,7 @@ public:
// this function only works on physics process, errors and returns null otherwise
virtual PhysicsDirectBodyState2D *body_get_direct_state(RID p_body) = 0;
- struct MotionParameters {
- Transform2D from;
- Vector2 motion;
- real_t margin = 0.08;
- bool collide_separation_ray = false;
- HashSet<RID> exclude_bodies;
- HashSet<ObjectID> exclude_objects;
- bool recovery_as_collision = false;
-
- MotionParameters() {}
-
- MotionParameters(const Transform2D &p_from, const Vector2 &p_motion, real_t p_margin = 0.08) :
- from(p_from),
- motion(p_motion),
- margin(p_margin) {}
- };
-
- struct MotionResult {
- Vector2 travel;
- Vector2 remainder;
-
- Vector2 collision_point;
- Vector2 collision_normal;
- Vector2 collider_velocity;
- real_t collision_depth = 0.0;
- real_t collision_safe_fraction = 0.0;
- real_t collision_unsafe_fraction = 0.0;
- int collision_local_shape = 0;
- ObjectID collider_id;
- RID collider;
- int collider_shape = 0;
-
- real_t get_angle(Vector2 p_up_direction) const {
- return Math::acos(collision_normal.dot(p_up_direction));
- }
- };
-
- virtual bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) = 0;
+ virtual bool body_test_motion(RID p_body, const PS2DT::MotionParameters &p_parameters, PS2DT::MotionResult *r_result = nullptr) = 0;
/* JOINT API */
@@ -540,21 +247,8 @@ public:
virtual void joint_clear(RID p_joint) = 0;
- enum JointType {
- JOINT_TYPE_PIN,
- JOINT_TYPE_GROOVE,
- JOINT_TYPE_DAMPED_SPRING,
- JOINT_TYPE_MAX
- };
-
- enum JointParam {
- JOINT_PARAM_BIAS,
- JOINT_PARAM_MAX_BIAS,
- JOINT_PARAM_MAX_FORCE,
- };
-
- virtual void joint_set_param(RID p_joint, JointParam p_param, real_t p_value) = 0;
- virtual real_t joint_get_param(RID p_joint, JointParam p_param) const = 0;
+ virtual void joint_set_param(RID p_joint, PS2DE::JointParam p_param, real_t p_value) = 0;
+ virtual real_t joint_get_param(RID p_joint, PS2DE::JointParam p_param) const = 0;
virtual void joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) = 0;
virtual bool joint_is_disabled_collisions_between_bodies(RID p_joint) const = 0;
@@ -563,40 +257,16 @@ public:
virtual void joint_make_groove(RID p_joint, const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, RID p_body_a, RID p_body_b) = 0;
virtual void joint_make_damped_spring(RID p_joint, const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b = RID()) = 0;
- enum PinJointParam {
- PIN_JOINT_SOFTNESS,
- PIN_JOINT_LIMIT_UPPER,
- PIN_JOINT_LIMIT_LOWER,
- PIN_JOINT_MOTOR_TARGET_VELOCITY
- };
-
- virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) = 0;
- virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const = 0;
+ virtual void pin_joint_set_param(RID p_joint, PS2DE::PinJointParam p_param, real_t p_value) = 0;
+ virtual real_t pin_joint_get_param(RID p_joint, PS2DE::PinJointParam p_param) const = 0;
- enum PinJointFlag {
- PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED,
- PIN_JOINT_FLAG_MOTOR_ENABLED
- };
+ virtual void pin_joint_set_flag(RID p_joint, PS2DE::PinJointFlag p_flag, bool p_enabled) = 0;
+ virtual bool pin_joint_get_flag(RID p_joint, PS2DE::PinJointFlag p_flag) const = 0;
- virtual void pin_joint_set_flag(RID p_joint, PinJointFlag p_flag, bool p_enabled) = 0;
- virtual bool pin_joint_get_flag(RID p_joint, PinJointFlag p_flag) const = 0;
+ virtual void damped_spring_joint_set_param(RID p_joint, PS2DE::DampedSpringParam p_param, real_t p_value) = 0;
+ virtual real_t damped_spring_joint_get_param(RID p_joint, PS2DE::DampedSpringParam p_param) const = 0;
- enum DampedSpringParam {
- DAMPED_SPRING_REST_LENGTH,
- DAMPED_SPRING_STIFFNESS,
- DAMPED_SPRING_DAMPING
- };
- virtual void damped_spring_joint_set_param(RID p_joint, DampedSpringParam p_param, real_t p_value) = 0;
- virtual real_t damped_spring_joint_get_param(RID p_joint, DampedSpringParam p_param) const = 0;
-
- virtual JointType joint_get_type(RID p_joint) const = 0;
-
- /* QUERY API */
-
- enum AreaBodyStatus {
- AREA_BODY_ADDED,
- AREA_BODY_REMOVED
- };
+ virtual PS2DE::JointType joint_get_type(RID p_joint) const = 0;
/* MISC */
@@ -617,183 +287,12 @@ public:
virtual bool is_flushing_queries() const = 0;
- enum ProcessInfo {
- INFO_ACTIVE_OBJECTS,
- INFO_COLLISION_PAIRS,
- INFO_ISLAND_COUNT
- };
-
- virtual int get_process_info(ProcessInfo p_info) = 0;
+ virtual int get_process_info(PS2DE::ProcessInfo p_info) = 0;
PhysicsServer2D();
~PhysicsServer2D();
};
-class PhysicsRayQueryParameters2D : public RefCounted {
- GDCLASS(PhysicsRayQueryParameters2D, RefCounted);
-
- PhysicsDirectSpaceState2D::RayParameters parameters;
-
-protected:
- static void _bind_methods();
-
-public:
- static Ref<PhysicsRayQueryParameters2D> create(Vector2 p_from, Vector2 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude);
- const PhysicsDirectSpaceState2D::RayParameters &get_parameters() const { return parameters; }
-
- void set_from(const Vector2 &p_from) { parameters.from = p_from; }
- const Vector2 &get_from() const { return parameters.from; }
-
- void set_to(const Vector2 &p_to) { parameters.to = p_to; }
- const Vector2 &get_to() const { return parameters.to; }
-
- void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
- uint32_t get_collision_mask() const { return parameters.collision_mask; }
-
- void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
- bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
-
- void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
- bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
-
- void set_hit_from_inside(bool p_enable) { parameters.hit_from_inside = p_enable; }
- bool is_hit_from_inside_enabled() const { return parameters.hit_from_inside; }
-
- void set_exclude(const TypedArray<RID> &p_exclude);
- TypedArray<RID> get_exclude() const;
-};
-
-class PhysicsPointQueryParameters2D : public RefCounted {
- GDCLASS(PhysicsPointQueryParameters2D, RefCounted);
-
- PhysicsDirectSpaceState2D::PointParameters parameters;
-
-protected:
- static void _bind_methods();
-
-public:
- const PhysicsDirectSpaceState2D::PointParameters &get_parameters() const { return parameters; }
-
- void set_position(const Vector2 &p_position) { parameters.position = p_position; }
- const Vector2 &get_position() const { return parameters.position; }
-
- void set_canvas_instance_id(ObjectID p_canvas_instance_id) { parameters.canvas_instance_id = p_canvas_instance_id; }
- ObjectID get_canvas_instance_id() const { return parameters.canvas_instance_id; }
-
- void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
- uint32_t get_collision_mask() const { return parameters.collision_mask; }
-
- void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
- bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
-
- void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
- bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
-
- void set_exclude(const TypedArray<RID> &p_exclude);
- TypedArray<RID> get_exclude() const;
-};
-
-class PhysicsShapeQueryParameters2D : public RefCounted {
- GDCLASS(PhysicsShapeQueryParameters2D, RefCounted);
-
- PhysicsDirectSpaceState2D::ShapeParameters parameters;
-
- Ref<Resource> shape_ref;
-
-protected:
- static void _bind_methods();
-
-public:
- const PhysicsDirectSpaceState2D::ShapeParameters &get_parameters() const { return parameters; }
-
- void set_shape(const Ref<Resource> &p_shape_ref);
- Ref<Resource> get_shape() const { return shape_ref; }
-
- void set_shape_rid(const RID &p_shape);
- RID get_shape_rid() const { return parameters.shape_rid; }
-
- void set_transform(const Transform2D &p_transform) { parameters.transform = p_transform; }
- const Transform2D &get_transform() const { return parameters.transform; }
-
- void set_motion(const Vector2 &p_motion) { parameters.motion = p_motion; }
- const Vector2 &get_motion() const { return parameters.motion; }
-
- void set_margin(real_t p_margin) { parameters.margin = p_margin; }
- real_t get_margin() const { return parameters.margin; }
-
- void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
- uint32_t get_collision_mask() const { return parameters.collision_mask; }
-
- void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
- bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
-
- void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
- bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
-
- void set_exclude(const TypedArray<RID> &p_exclude);
- TypedArray<RID> get_exclude() const;
-};
-
-class PhysicsTestMotionParameters2D : public RefCounted {
- GDCLASS(PhysicsTestMotionParameters2D, RefCounted);
-
- PhysicsServer2D::MotionParameters parameters;
-
-protected:
- static void _bind_methods();
-
-public:
- const PhysicsServer2D::MotionParameters &get_parameters() const { return parameters; }
-
- const Transform2D &get_from() const { return parameters.from; }
- void set_from(const Transform2D &p_from) { parameters.from = p_from; }
-
- const Vector2 &get_motion() const { return parameters.motion; }
- void set_motion(const Vector2 &p_motion) { parameters.motion = p_motion; }
-
- real_t get_margin() const { return parameters.margin; }
- void set_margin(real_t p_margin) { parameters.margin = p_margin; }
-
- bool is_collide_separation_ray_enabled() const { return parameters.collide_separation_ray; }
- void set_collide_separation_ray_enabled(bool p_enabled) { parameters.collide_separation_ray = p_enabled; }
-
- TypedArray<RID> get_exclude_bodies() const;
- void set_exclude_bodies(const TypedArray<RID> &p_exclude);
-
- TypedArray<uint64_t> get_exclude_objects() const;
- void set_exclude_objects(const TypedArray<uint64_t> &p_exclude);
-
- bool is_recovery_as_collision_enabled() const { return parameters.recovery_as_collision; }
- void set_recovery_as_collision_enabled(bool p_enabled) { parameters.recovery_as_collision = p_enabled; }
-};
-
-class PhysicsTestMotionResult2D : public RefCounted {
- GDCLASS(PhysicsTestMotionResult2D, RefCounted);
-
- PhysicsServer2D::MotionResult result;
-
-protected:
- static void _bind_methods();
-
-public:
- PhysicsServer2D::MotionResult *get_result_ptr() { return &result; }
-
- Vector2 get_travel() const;
- Vector2 get_remainder() const;
-
- Vector2 get_collision_point() const;
- Vector2 get_collision_normal() const;
- Vector2 get_collider_velocity() const;
- ObjectID get_collider_id() const;
- RID get_collider_rid() const;
- Object *get_collider() const;
- int get_collider_shape() const;
- int get_collision_local_shape() const;
- real_t get_collision_depth() const;
- real_t get_collision_safe_fraction() const;
- real_t get_collision_unsafe_fraction() const;
-};
-
class PhysicsServer2DManager : public Object {
GDCLASS(PhysicsServer2DManager, Object);
@@ -845,19 +344,19 @@ public:
~PhysicsServer2DManager();
};
-VARIANT_ENUM_CAST(PhysicsServer2D::ShapeType);
-VARIANT_ENUM_CAST(PhysicsServer2D::SpaceParameter);
-VARIANT_ENUM_CAST(PhysicsServer2D::AreaParameter);
-VARIANT_ENUM_CAST(PhysicsServer2D::AreaSpaceOverrideMode);
-VARIANT_ENUM_CAST(PhysicsServer2D::BodyMode);
-VARIANT_ENUM_CAST(PhysicsServer2D::BodyParameter);
-VARIANT_ENUM_CAST(PhysicsServer2D::BodyDampMode);
-VARIANT_ENUM_CAST(PhysicsServer2D::BodyState);
-VARIANT_ENUM_CAST(PhysicsServer2D::CCDMode);
-VARIANT_ENUM_CAST(PhysicsServer2D::JointParam);
-VARIANT_ENUM_CAST(PhysicsServer2D::JointType);
-VARIANT_ENUM_CAST(PhysicsServer2D::PinJointParam);
-VARIANT_ENUM_CAST(PhysicsServer2D::PinJointFlag);
-VARIANT_ENUM_CAST(PhysicsServer2D::DampedSpringParam);
-VARIANT_ENUM_CAST(PhysicsServer2D::AreaBodyStatus);
-VARIANT_ENUM_CAST(PhysicsServer2D::ProcessInfo);
+VARIANT_ENUM_CAST_EXT(PS2DE::ShapeType, PhysicsServer2D::ShapeType);
+VARIANT_ENUM_CAST_EXT(PS2DE::SpaceParameter, PhysicsServer2D::SpaceParameter);
+VARIANT_ENUM_CAST_EXT(PS2DE::AreaParameter, PhysicsServer2D::AreaParameter);
+VARIANT_ENUM_CAST_EXT(PS2DE::AreaSpaceOverrideMode, PhysicsServer2D::AreaSpaceOverrideMode);
+VARIANT_ENUM_CAST_EXT(PS2DE::BodyMode, PhysicsServer2D::BodyMode);
+VARIANT_ENUM_CAST_EXT(PS2DE::BodyParameter, PhysicsServer2D::BodyParameter);
+VARIANT_ENUM_CAST_EXT(PS2DE::BodyDampMode, PhysicsServer2D::BodyDampMode);
+VARIANT_ENUM_CAST_EXT(PS2DE::BodyState, PhysicsServer2D::BodyState);
+VARIANT_ENUM_CAST_EXT(PS2DE::CCDMode, PhysicsServer2D::CCDMode);
+VARIANT_ENUM_CAST_EXT(PS2DE::JointParam, PhysicsServer2D::JointParam);
+VARIANT_ENUM_CAST_EXT(PS2DE::JointType, PhysicsServer2D::JointType);
+VARIANT_ENUM_CAST_EXT(PS2DE::PinJointParam, PhysicsServer2D::PinJointParam);
+VARIANT_ENUM_CAST_EXT(PS2DE::PinJointFlag, PhysicsServer2D::PinJointFlag);
+VARIANT_ENUM_CAST_EXT(PS2DE::DampedSpringParam, PhysicsServer2D::DampedSpringParam);
+VARIANT_ENUM_CAST_EXT(PS2DE::AreaBodyStatus, PhysicsServer2D::AreaBodyStatus);
+VARIANT_ENUM_CAST_EXT(PS2DE::ProcessInfo, PhysicsServer2D::ProcessInfo);
diff --git a/servers/physics_2d/physics_server_2d_constants.h b/servers/physics_2d/physics_server_2d_constants.h
new file mode 100644
index 00000000000..94aad09dd65
--- /dev/null
+++ b/servers/physics_2d/physics_server_2d_constants.h
@@ -0,0 +1,40 @@
+/**************************************************************************/
+/* physics_server_2d_constants.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+namespace PhysicsServer2DConstants {
+
+constexpr int MAX_CONTACTS_REPORTED_2D_MAX = 4096;
+
+} // namespace PhysicsServer2DConstants
+
+// Alias to make it easier to use.
+#define PS2DC PhysicsServer2DConstants
diff --git a/servers/physics_2d/physics_server_2d_dummy.h b/servers/physics_2d/physics_server_2d_dummy.h
index 340e10df842..f7739e5246f 100644
--- a/servers/physics_2d/physics_server_2d_dummy.h
+++ b/servers/physics_2d/physics_server_2d_dummy.h
@@ -30,6 +30,8 @@
#pragma once
+#include "servers/physics_2d/direct_states/physics_direct_body_state_2d.h"
+#include "servers/physics_2d/direct_states/physics_direct_space_state_2d.h"
#include "servers/physics_2d/physics_server_2d.h"
class PhysicsDirectBodyState2DDummy : public PhysicsDirectBodyState2D {
@@ -114,14 +116,14 @@ class PhysicsDirectSpaceState2DDummy : public PhysicsDirectSpaceState2D {
GDCLASS(PhysicsDirectSpaceState2DDummy, PhysicsDirectSpaceState2D);
public:
- virtual bool intersect_ray(const RayParameters &p_parameters, RayResult &r_result) override { return false; }
+ virtual bool intersect_ray(const PS2DT::RayParameters &p_parameters, PS2DT::RayResult &r_result) override { return false; }
- virtual int intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) override { return 0; }
+ virtual int intersect_point(const PS2DT::PointParameters &p_parameters, PS2DT::ShapeResult *r_results, int p_result_max) override { return 0; }
- virtual int intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) override { return 0; }
- virtual bool cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) override { return false; }
- virtual bool collide_shape(const ShapeParameters &p_parameters, Vector2 *r_results, int p_result_max, int &r_result_count) override { return false; }
- virtual bool rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) override { return false; }
+ virtual int intersect_shape(const PS2DT::ShapeParameters &p_parameters, PS2DT::ShapeResult *r_results, int p_result_max) override { return 0; }
+ virtual bool cast_motion(const PS2DT::ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) override { return false; }
+ virtual bool collide_shape(const PS2DT::ShapeParameters &p_parameters, Vector2 *r_results, int p_result_max, int &r_result_count) override { return false; }
+ virtual bool rest_info(const PS2DT::ShapeParameters &p_parameters, PS2DT::ShapeRestInfo *r_info) override { return false; }
};
class PhysicsServer2DDummy : public PhysicsServer2D {
@@ -143,7 +145,7 @@ public:
virtual void shape_set_data(RID p_shape, const Variant &p_data) override {}
virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias) override {}
- virtual ShapeType shape_get_type(RID p_shape) const override { return ShapeType::SHAPE_CIRCLE; }
+ virtual PS2DE::ShapeType shape_get_type(RID p_shape) const override { return PS2DE::ShapeType::SHAPE_CIRCLE; }
virtual Variant shape_get_data(RID p_shape) const override { return Variant(); }
virtual real_t shape_get_custom_solver_bias(RID p_shape) const override { return 0; }
@@ -155,8 +157,8 @@ public:
virtual void space_set_active(RID p_space, bool p_active) override {}
virtual bool space_is_active(RID p_space) const override { return false; }
- virtual void space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) override {}
- virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const override { return 0; }
+ virtual void space_set_param(RID p_space, PS2DE::SpaceParameter p_param, real_t p_value) override {}
+ virtual real_t space_get_param(RID p_space, PS2DE::SpaceParameter p_param) const override { return 0; }
virtual PhysicsDirectSpaceState2D *space_get_direct_state(RID p_space) override { return space_state_dummy; }
@@ -190,10 +192,10 @@ public:
virtual void area_attach_canvas_instance_id(RID p_area, ObjectID p_id) override {}
virtual ObjectID area_get_canvas_instance_id(RID p_area) const override { return ObjectID(); }
- virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) override {}
+ virtual void area_set_param(RID p_area, PS2DE::AreaParameter p_param, const Variant &p_value) override {}
virtual void area_set_transform(RID p_area, const Transform2D &p_transform) override {}
- virtual Variant area_get_param(RID p_parea, AreaParameter p_param) const override { return Variant(); }
+ virtual Variant area_get_param(RID p_parea, PS2DE::AreaParameter p_param) const override { return Variant(); }
virtual Transform2D area_get_transform(RID p_area) const override { return Transform2D(); }
virtual void area_set_collision_layer(RID p_area, uint32_t p_layer) override {}
@@ -215,8 +217,8 @@ public:
virtual void body_set_space(RID p_body, RID p_space) override {}
virtual RID body_get_space(RID p_body) const override { return RID(); }
- virtual void body_set_mode(RID p_body, BodyMode p_mode) override {}
- virtual BodyMode body_get_mode(RID p_body) const override { return BodyMode::BODY_MODE_STATIC; }
+ virtual void body_set_mode(RID p_body, PS2DE::BodyMode p_mode) override {}
+ virtual PS2DE::BodyMode body_get_mode(RID p_body) const override { return PS2DE::BodyMode::BODY_MODE_STATIC; }
virtual void body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false) override {}
virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape) override {}
@@ -238,8 +240,8 @@ public:
virtual void body_attach_canvas_instance_id(RID p_body, ObjectID p_id) override {}
virtual ObjectID body_get_canvas_instance_id(RID p_body) const override { return ObjectID(); }
- virtual void body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) override {}
- virtual CCDMode body_get_continuous_collision_detection_mode(RID p_body) const override { return CCDMode::CCD_MODE_DISABLED; }
+ virtual void body_set_continuous_collision_detection_mode(RID p_body, PS2DE::CCDMode p_mode) override {}
+ virtual PS2DE::CCDMode body_get_continuous_collision_detection_mode(RID p_body) const override { return PS2DE::CCDMode::CCD_MODE_DISABLED; }
virtual void body_set_collision_layer(RID p_body, uint32_t p_layer) override {}
virtual uint32_t body_get_collision_layer(RID p_body) const override { return 0; }
@@ -250,13 +252,13 @@ public:
virtual void body_set_collision_priority(RID p_body, real_t p_priority) override {}
virtual real_t body_get_collision_priority(RID p_body) const override { return 0; }
- virtual void body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) override {}
- virtual Variant body_get_param(RID p_body, BodyParameter p_param) const override { return Variant(); }
+ virtual void body_set_param(RID p_body, PS2DE::BodyParameter p_param, const Variant &p_value) override {}
+ virtual Variant body_get_param(RID p_body, PS2DE::BodyParameter p_param) const override { return Variant(); }
virtual void body_reset_mass_properties(RID p_body) override {}
- virtual void body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) override {}
- virtual Variant body_get_state(RID p_body, BodyState p_state) const override { return Variant(); }
+ virtual void body_set_state(RID p_body, PS2DE::BodyState p_state, const Variant &p_variant) override {}
+ virtual Variant body_get_state(RID p_body, PS2DE::BodyState p_state) const override { return Variant(); }
virtual void body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) override {}
virtual void body_apply_torque_impulse(RID p_body, real_t p_torque) override {}
@@ -300,7 +302,7 @@ public:
virtual PhysicsDirectBodyState2D *body_get_direct_state(RID p_body) override { return body_state_dummy; }
- virtual bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) override { return false; }
+ virtual bool body_test_motion(RID p_body, const PS2DT::MotionParameters &p_parameters, PS2DT::MotionResult *r_result = nullptr) override { return false; }
/* JOINT API */
@@ -308,8 +310,8 @@ public:
virtual void joint_clear(RID p_joint) override {}
- virtual void joint_set_param(RID p_joint, JointParam p_param, real_t p_value) override {}
- virtual real_t joint_get_param(RID p_joint, JointParam p_param) const override { return 0; }
+ virtual void joint_set_param(RID p_joint, PS2DE::JointParam p_param, real_t p_value) override {}
+ virtual real_t joint_get_param(RID p_joint, PS2DE::JointParam p_param) const override { return 0; }
virtual void joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) override {}
virtual bool joint_is_disabled_collisions_between_bodies(RID p_joint) const override { return false; }
@@ -318,16 +320,16 @@ public:
virtual void joint_make_groove(RID p_joint, const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, RID p_body_a, RID p_body_b) override {}
virtual void joint_make_damped_spring(RID p_joint, const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b = RID()) override {}
- virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) override {}
- virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const override { return 0; }
+ virtual void pin_joint_set_param(RID p_joint, PS2DE::PinJointParam p_param, real_t p_value) override {}
+ virtual real_t pin_joint_get_param(RID p_joint, PS2DE::PinJointParam p_param) const override { return 0; }
- virtual void pin_joint_set_flag(RID p_joint, PinJointFlag p_flag, bool p_enabled) override {}
- virtual bool pin_joint_get_flag(RID p_joint, PinJointFlag p_flag) const override { return false; }
+ virtual void pin_joint_set_flag(RID p_joint, PS2DE::PinJointFlag p_flag, bool p_enabled) override {}
+ virtual bool pin_joint_get_flag(RID p_joint, PS2DE::PinJointFlag p_flag) const override { return false; }
- virtual void damped_spring_joint_set_param(RID p_joint, DampedSpringParam p_param, real_t p_value) override {}
- virtual real_t damped_spring_joint_get_param(RID p_joint, DampedSpringParam p_param) const override { return 0; }
+ virtual void damped_spring_joint_set_param(RID p_joint, PS2DE::DampedSpringParam p_param, real_t p_value) override {}
+ virtual real_t damped_spring_joint_get_param(RID p_joint, PS2DE::DampedSpringParam p_param) const override { return 0; }
- virtual JointType joint_get_type(RID p_joint) const override { return JointType::JOINT_TYPE_PIN; }
+ virtual PS2DE::JointType joint_get_type(RID p_joint) const override { return PS2DE::JointType::JOINT_TYPE_PIN; }
/* MISC */
@@ -349,5 +351,5 @@ public:
virtual bool is_flushing_queries() const override { return false; }
- virtual int get_process_info(ProcessInfo p_info) override { return 0; }
+ virtual int get_process_info(PS2DE::ProcessInfo p_info) override { return 0; }
};
diff --git a/servers/physics_2d/physics_server_2d_enums.h b/servers/physics_2d/physics_server_2d_enums.h
new file mode 100644
index 00000000000..de514c972b1
--- /dev/null
+++ b/servers/physics_2d/physics_server_2d_enums.h
@@ -0,0 +1,182 @@
+/**************************************************************************/
+/* physics_server_2d_enums.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+namespace PhysicsServer2DEnums {
+
+/* SHAPE API */
+
+enum ShapeType {
+ SHAPE_WORLD_BOUNDARY, ///< plane:"plane"
+ SHAPE_SEPARATION_RAY, ///< float:"length"
+ SHAPE_SEGMENT, ///< float:"length"
+ SHAPE_CIRCLE, ///< float:"radius"
+ SHAPE_RECTANGLE, ///< vec3:"extents"
+ SHAPE_CAPSULE,
+ SHAPE_CONVEX_POLYGON, ///< array of planes:"planes"
+ SHAPE_CONCAVE_POLYGON, ///< Vector2 array:"triangles" , or Dictionary with "indices" (int array) and "triangles" (Vector2 array)
+ SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error
+};
+
+/* SPACE API */
+
+enum SpaceParameter {
+ SPACE_PARAM_CONTACT_RECYCLE_RADIUS,
+ SPACE_PARAM_CONTACT_MAX_SEPARATION,
+ SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION,
+ SPACE_PARAM_CONTACT_DEFAULT_BIAS,
+ SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD,
+ SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD,
+ SPACE_PARAM_BODY_TIME_TO_SLEEP,
+ SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS,
+ SPACE_PARAM_SOLVER_ITERATIONS,
+};
+
+/* AREA API */
+
+enum AreaParameter {
+ AREA_PARAM_GRAVITY_OVERRIDE_MODE,
+ AREA_PARAM_GRAVITY,
+ AREA_PARAM_GRAVITY_VECTOR,
+ AREA_PARAM_GRAVITY_IS_POINT,
+ AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE,
+ AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE,
+ AREA_PARAM_LINEAR_DAMP,
+ AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE,
+ AREA_PARAM_ANGULAR_DAMP,
+ AREA_PARAM_PRIORITY
+};
+
+enum AreaSpaceOverrideMode {
+ AREA_SPACE_OVERRIDE_DISABLED,
+ AREA_SPACE_OVERRIDE_COMBINE,
+ AREA_SPACE_OVERRIDE_COMBINE_REPLACE, // Combines, then discards all subsequent calculations
+ AREA_SPACE_OVERRIDE_REPLACE,
+ AREA_SPACE_OVERRIDE_REPLACE_COMBINE // Discards all previous calculations, then keeps combining
+};
+
+/* BODY API */
+
+enum BodyMode {
+ BODY_MODE_STATIC,
+ BODY_MODE_KINEMATIC,
+ BODY_MODE_RIGID,
+ BODY_MODE_RIGID_LINEAR,
+};
+
+enum BodyDampMode {
+ BODY_DAMP_MODE_COMBINE,
+ BODY_DAMP_MODE_REPLACE,
+};
+
+// common body variables
+enum BodyParameter {
+ BODY_PARAM_BOUNCE,
+ BODY_PARAM_FRICTION,
+ BODY_PARAM_MASS, ///< unused for static, always infinite
+ BODY_PARAM_INERTIA,
+ BODY_PARAM_CENTER_OF_MASS,
+ BODY_PARAM_GRAVITY_SCALE,
+ BODY_PARAM_LINEAR_DAMP_MODE,
+ BODY_PARAM_ANGULAR_DAMP_MODE,
+ BODY_PARAM_LINEAR_DAMP,
+ BODY_PARAM_ANGULAR_DAMP,
+ BODY_PARAM_MAX,
+};
+
+enum BodyState {
+ BODY_STATE_TRANSFORM,
+ BODY_STATE_LINEAR_VELOCITY,
+ BODY_STATE_ANGULAR_VELOCITY,
+ BODY_STATE_SLEEPING,
+ BODY_STATE_CAN_SLEEP,
+};
+
+enum CCDMode {
+ CCD_MODE_DISABLED,
+ CCD_MODE_CAST_RAY,
+ CCD_MODE_CAST_SHAPE,
+};
+
+/* JOINT API */
+
+enum JointType {
+ JOINT_TYPE_PIN,
+ JOINT_TYPE_GROOVE,
+ JOINT_TYPE_DAMPED_SPRING,
+ JOINT_TYPE_MAX
+};
+
+enum JointParam {
+ JOINT_PARAM_BIAS,
+ JOINT_PARAM_MAX_BIAS,
+ JOINT_PARAM_MAX_FORCE,
+};
+
+enum PinJointParam {
+ PIN_JOINT_SOFTNESS,
+ PIN_JOINT_LIMIT_UPPER,
+ PIN_JOINT_LIMIT_LOWER,
+ PIN_JOINT_MOTOR_TARGET_VELOCITY
+};
+
+enum PinJointFlag {
+ PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED,
+ PIN_JOINT_FLAG_MOTOR_ENABLED
+};
+
+enum DampedSpringParam {
+ DAMPED_SPRING_REST_LENGTH,
+ DAMPED_SPRING_STIFFNESS,
+ DAMPED_SPRING_DAMPING
+};
+
+/* QUERY API */
+
+enum AreaBodyStatus {
+ AREA_BODY_ADDED,
+ AREA_BODY_REMOVED
+};
+
+enum ProcessInfo {
+ INFO_ACTIVE_OBJECTS,
+ INFO_COLLISION_PAIRS,
+ INFO_ISLAND_COUNT
+};
+
+#ifndef DISABLE_DEPRECATED
+// Graveyard.
+#endif
+
+} // namespace PhysicsServer2DEnums
+
+// Alias to make it easier to use.
+#define PS2DE PhysicsServer2DEnums
diff --git a/servers/physics_2d/physics_server_2d_extension.h b/servers/physics_2d/physics_server_2d_extension.h
index 788b3160b38..23f435a88ee 100644
--- a/servers/physics_2d/physics_server_2d_extension.h
+++ b/servers/physics_2d/physics_server_2d_extension.h
@@ -114,9 +114,9 @@ public:
PhysicsDirectBodyState2DExtension();
};
-typedef PhysicsDirectSpaceState2D::RayResult PhysicsServer2DExtensionRayResult;
-typedef PhysicsDirectSpaceState2D::ShapeResult PhysicsServer2DExtensionShapeResult;
-typedef PhysicsDirectSpaceState2D::ShapeRestInfo PhysicsServer2DExtensionShapeRestInfo;
+typedef PS2DT::RayResult PhysicsServer2DExtensionRayResult;
+typedef PS2DT::ShapeResult PhysicsServer2DExtensionShapeResult;
+typedef PS2DT::ShapeRestInfo PhysicsServer2DExtensionShapeRestInfo;
GDVIRTUAL_NATIVE_PTR(PhysicsServer2DExtensionRayResult)
GDVIRTUAL_NATIVE_PTR(PhysicsServer2DExtensionShapeResult)
@@ -139,42 +139,42 @@ protected:
GDVIRTUAL8R_REQUIRED(bool, _rest_info, RID, const Transform2D &, const Vector2 &, real_t, uint32_t, bool, bool, GDExtensionPtr<PhysicsServer2DExtensionShapeRestInfo>)
public:
- virtual bool intersect_ray(const RayParameters &p_parameters, RayResult &r_result) override {
+ virtual bool intersect_ray(const PS2DT::RayParameters &p_parameters, PS2DT::RayResult &r_result) override {
exclude = &p_parameters.exclude;
bool ret = false;
GDVIRTUAL_CALL(_intersect_ray, p_parameters.from, p_parameters.to, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, p_parameters.hit_from_inside, &r_result, ret);
exclude = nullptr;
return ret;
}
- virtual int intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) override {
+ virtual int intersect_point(const PS2DT::PointParameters &p_parameters, PS2DT::ShapeResult *r_results, int p_result_max) override {
exclude = &p_parameters.exclude;
int ret = false;
GDVIRTUAL_CALL(_intersect_point, p_parameters.position, p_parameters.canvas_instance_id, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_results, p_result_max, ret);
exclude = nullptr;
return ret;
}
- virtual int intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) override {
+ virtual int intersect_shape(const PS2DT::ShapeParameters &p_parameters, PS2DT::ShapeResult *r_results, int p_result_max) override {
exclude = &p_parameters.exclude;
int ret = 0;
GDVIRTUAL_CALL(_intersect_shape, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_results, p_result_max, ret);
exclude = nullptr;
return ret;
}
- virtual bool cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) override {
+ virtual bool cast_motion(const PS2DT::ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) override {
exclude = &p_parameters.exclude;
bool ret = false;
GDVIRTUAL_CALL(_cast_motion, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, &p_closest_safe, &p_closest_unsafe, ret);
exclude = nullptr;
return ret;
}
- virtual bool collide_shape(const ShapeParameters &p_parameters, Vector2 *r_results, int p_result_max, int &r_result_count) override {
+ virtual bool collide_shape(const PS2DT::ShapeParameters &p_parameters, Vector2 *r_results, int p_result_max, int &r_result_count) override {
exclude = &p_parameters.exclude;
bool ret = false;
GDVIRTUAL_CALL(_collide_shape, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_results, p_result_max, &r_result_count, ret);
exclude = nullptr;
return ret;
}
- virtual bool rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) override {
+ virtual bool rest_info(const PS2DT::ShapeParameters &p_parameters, PS2DT::ShapeRestInfo *r_info) override {
exclude = &p_parameters.exclude;
bool ret = false;
GDVIRTUAL_CALL(_rest_info, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_info, ret);
@@ -185,7 +185,7 @@ public:
PhysicsDirectSpaceState2DExtension();
};
-typedef PhysicsServer2D::MotionResult PhysicsServer2DExtensionMotionResult;
+typedef PS2DT::MotionResult PhysicsServer2DExtensionMotionResult;
GDVIRTUAL_NATIVE_PTR(PhysicsServer2DExtensionMotionResult)
@@ -220,7 +220,7 @@ public:
EXBIND2(shape_set_data, RID, const Variant &)
EXBIND2(shape_set_custom_solver_bias, RID, real_t)
- EXBIND1RC(ShapeType, shape_get_type, RID)
+ EXBIND1RC(PS2DE::ShapeType, shape_get_type, RID)
EXBIND1RC(Variant, shape_get_data, RID)
EXBIND1RC(real_t, shape_get_custom_solver_bias, RID)
@@ -236,8 +236,8 @@ public:
EXBIND2(space_set_active, RID, bool)
EXBIND1RC(bool, space_is_active, RID)
- EXBIND3(space_set_param, RID, SpaceParameter, real_t)
- EXBIND2RC(real_t, space_get_param, RID, SpaceParameter)
+ EXBIND3(space_set_param, RID, PS2DE::SpaceParameter, real_t)
+ EXBIND2RC(real_t, space_get_param, RID, PS2DE::SpaceParameter)
EXBIND1R(PhysicsDirectSpaceState2D *, space_get_direct_state, RID)
@@ -271,10 +271,10 @@ public:
EXBIND2(area_attach_canvas_instance_id, RID, ObjectID)
EXBIND1RC(ObjectID, area_get_canvas_instance_id, RID)
- EXBIND3(area_set_param, RID, AreaParameter, const Variant &)
+ EXBIND3(area_set_param, RID, PS2DE::AreaParameter, const Variant &)
EXBIND2(area_set_transform, RID, const Transform2D &)
- EXBIND2RC(Variant, area_get_param, RID, AreaParameter)
+ EXBIND2RC(Variant, area_get_param, RID, PS2DE::AreaParameter)
EXBIND1RC(Transform2D, area_get_transform, RID)
EXBIND2(area_set_collision_layer, RID, uint32_t)
@@ -297,8 +297,8 @@ public:
EXBIND2(body_set_space, RID, RID)
EXBIND1RC(RID, body_get_space, RID)
- EXBIND2(body_set_mode, RID, BodyMode)
- EXBIND1RC(BodyMode, body_get_mode, RID)
+ EXBIND2(body_set_mode, RID, PS2DE::BodyMode)
+ EXBIND1RC(PS2DE::BodyMode, body_get_mode, RID)
EXBIND4(body_add_shape, RID, RID, const Transform2D &, bool)
EXBIND3(body_set_shape, RID, int, RID)
@@ -320,8 +320,8 @@ public:
EXBIND2(body_attach_canvas_instance_id, RID, ObjectID)
EXBIND1RC(ObjectID, body_get_canvas_instance_id, RID)
- EXBIND2(body_set_continuous_collision_detection_mode, RID, CCDMode)
- EXBIND1RC(CCDMode, body_get_continuous_collision_detection_mode, RID)
+ EXBIND2(body_set_continuous_collision_detection_mode, RID, PS2DE::CCDMode)
+ EXBIND1RC(PS2DE::CCDMode, body_get_continuous_collision_detection_mode, RID)
EXBIND2(body_set_collision_layer, RID, uint32_t)
EXBIND1RC(uint32_t, body_get_collision_layer, RID)
@@ -332,13 +332,13 @@ public:
EXBIND2(body_set_collision_priority, RID, real_t)
EXBIND1RC(real_t, body_get_collision_priority, RID)
- EXBIND3(body_set_param, RID, BodyParameter, const Variant &)
- EXBIND2RC(Variant, body_get_param, RID, BodyParameter)
+ EXBIND3(body_set_param, RID, PS2DE::BodyParameter, const Variant &)
+ EXBIND2RC(Variant, body_get_param, RID, PS2DE::BodyParameter)
EXBIND1(body_reset_mass_properties, RID)
- EXBIND3(body_set_state, RID, BodyState, const Variant &)
- EXBIND2RC(Variant, body_get_state, RID, BodyState)
+ EXBIND3(body_set_state, RID, PS2DE::BodyState, const Variant &)
+ EXBIND2RC(Variant, body_get_state, RID, PS2DE::BodyState)
EXBIND2(body_apply_central_impulse, RID, const Vector2 &)
EXBIND2(body_apply_torque_impulse, RID, real_t)
@@ -402,7 +402,7 @@ public:
bool body_test_motion_is_excluding_body(RID p_body) const;
bool body_test_motion_is_excluding_object(ObjectID p_object) const;
- bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) override {
+ bool body_test_motion(RID p_body, const PS2DT::MotionParameters &p_parameters, PS2DT::MotionResult *r_result = nullptr) override {
bool ret = false;
exclude_bodies = &p_parameters.exclude_bodies;
exclude_objects = &p_parameters.exclude_objects;
@@ -417,8 +417,8 @@ public:
EXBIND0R(RID, joint_create)
EXBIND1(joint_clear, RID)
- EXBIND3(joint_set_param, RID, JointParam, real_t)
- EXBIND2RC(real_t, joint_get_param, RID, JointParam)
+ EXBIND3(joint_set_param, RID, PS2DE::JointParam, real_t)
+ EXBIND2RC(real_t, joint_get_param, RID, PS2DE::JointParam)
EXBIND2(joint_disable_collisions_between_bodies, RID, bool)
EXBIND1RC(bool, joint_is_disabled_collisions_between_bodies, RID)
@@ -427,16 +427,16 @@ public:
EXBIND6(joint_make_groove, RID, const Vector2 &, const Vector2 &, const Vector2 &, RID, RID)
EXBIND5(joint_make_damped_spring, RID, const Vector2 &, const Vector2 &, RID, RID)
- EXBIND3(pin_joint_set_flag, RID, PinJointFlag, bool)
- EXBIND2RC(bool, pin_joint_get_flag, RID, PinJointFlag)
+ EXBIND3(pin_joint_set_flag, RID, PS2DE::PinJointFlag, bool)
+ EXBIND2RC(bool, pin_joint_get_flag, RID, PS2DE::PinJointFlag)
- EXBIND3(pin_joint_set_param, RID, PinJointParam, real_t)
- EXBIND2RC(real_t, pin_joint_get_param, RID, PinJointParam)
+ EXBIND3(pin_joint_set_param, RID, PS2DE::PinJointParam, real_t)
+ EXBIND2RC(real_t, pin_joint_get_param, RID, PS2DE::PinJointParam)
- EXBIND3(damped_spring_joint_set_param, RID, DampedSpringParam, real_t)
- EXBIND2RC(real_t, damped_spring_joint_get_param, RID, DampedSpringParam)
+ EXBIND3(damped_spring_joint_set_param, RID, PS2DE::DampedSpringParam, real_t)
+ EXBIND2RC(real_t, damped_spring_joint_get_param, RID, PS2DE::DampedSpringParam)
- EXBIND1RC(JointType, joint_get_type, RID)
+ EXBIND1RC(PS2DE::JointType, joint_get_type, RID)
/* MISC */
@@ -455,7 +455,7 @@ public:
EXBIND0(finish)
EXBIND0RC(bool, is_flushing_queries)
- EXBIND1R(int, get_process_info, ProcessInfo)
+ EXBIND1R(int, get_process_info, PS2DE::ProcessInfo)
PhysicsServer2DExtension();
~PhysicsServer2DExtension();
diff --git a/servers/physics_2d/physics_server_2d_types.h b/servers/physics_2d/physics_server_2d_types.h
new file mode 100644
index 00000000000..37427421c41
--- /dev/null
+++ b/servers/physics_2d/physics_server_2d_types.h
@@ -0,0 +1,145 @@
+/**************************************************************************/
+/* physics_server_2d_types.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/math/vector2.h"
+#include "core/object/object.h"
+#include "core/templates/hash_set.h"
+#include "core/templates/rid.h"
+
+namespace PhysicsServer2DTypes {
+
+struct RayParameters {
+ Vector2 from;
+ Vector2 to;
+ HashSet<RID> exclude;
+ uint32_t collision_mask = UINT32_MAX;
+
+ bool collide_with_bodies = true;
+ bool collide_with_areas = false;
+
+ bool hit_from_inside = false;
+};
+
+struct RayResult {
+ Vector2 position;
+ Vector2 normal;
+ RID rid;
+ ObjectID collider_id;
+ Object *collider = nullptr;
+ int shape = 0;
+};
+
+struct ShapeResult {
+ RID rid;
+ ObjectID collider_id;
+ Object *collider = nullptr;
+ int shape = 0;
+};
+
+struct PointParameters {
+ Vector2 position;
+ ObjectID canvas_instance_id;
+ HashSet<RID> exclude;
+ uint32_t collision_mask = UINT32_MAX;
+
+ bool collide_with_bodies = true;
+ bool collide_with_areas = false;
+
+ bool pick_point = false;
+};
+
+struct ShapeParameters {
+ RID shape_rid;
+ Transform2D transform;
+ Vector2 motion;
+ real_t margin = 0.0;
+ HashSet<RID> exclude;
+ uint32_t collision_mask = UINT32_MAX;
+
+ bool collide_with_bodies = true;
+ bool collide_with_areas = false;
+};
+
+struct ShapeRestInfo {
+ Vector2 point;
+ Vector2 normal;
+ RID rid;
+ ObjectID collider_id;
+ int shape = 0;
+ Vector2 linear_velocity; // Velocity at contact point.
+};
+
+struct MotionParameters {
+ Transform2D from;
+ Vector2 motion;
+ real_t margin = 0.08;
+ bool collide_separation_ray = false;
+ HashSet<RID> exclude_bodies;
+ HashSet<ObjectID> exclude_objects;
+ bool recovery_as_collision = false;
+
+ MotionParameters() {}
+
+ MotionParameters(const Transform2D &p_from, const Vector2 &p_motion, real_t p_margin = 0.08) :
+ from(p_from),
+ motion(p_motion),
+ margin(p_margin) {}
+};
+
+struct MotionResult {
+ Vector2 travel;
+ Vector2 remainder;
+
+ Vector2 collision_point;
+ Vector2 collision_normal;
+ Vector2 collider_velocity;
+ real_t collision_depth = 0.0;
+ real_t collision_safe_fraction = 0.0;
+ real_t collision_unsafe_fraction = 0.0;
+ int collision_local_shape = 0;
+ ObjectID collider_id;
+ RID collider;
+ int collider_shape = 0;
+
+ real_t get_angle(Vector2 p_up_direction) const {
+ return Math::acos(collision_normal.dot(p_up_direction));
+ }
+};
+
+#ifndef DISABLE_DEPRECATED
+// Graveyard.
+#endif
+
+} // namespace PhysicsServer2DTypes
+
+// Alias to make it easier to use.
+#define PS2DT PhysicsServer2DTypes
diff --git a/servers/physics_2d/physics_server_2d_wrap_mt.h b/servers/physics_2d/physics_server_2d_wrap_mt.h
index 6d60a25e6a2..dd6afb9333c 100644
--- a/servers/physics_2d/physics_server_2d_wrap_mt.h
+++ b/servers/physics_2d/physics_server_2d_wrap_mt.h
@@ -92,7 +92,7 @@ public:
FUNC2(shape_set_data, RID, const Variant &);
FUNC2(shape_set_custom_solver_bias, RID, real_t);
- FUNC1RC(ShapeType, shape_get_type, RID);
+ FUNC1RC(PS2DE::ShapeType, shape_get_type, RID);
FUNC1RC(Variant, shape_get_data, RID);
FUNC1RC(real_t, shape_get_custom_solver_bias, RID);
@@ -108,8 +108,8 @@ public:
FUNC2(space_set_active, RID, bool);
FUNC1RC(bool, space_is_active, RID);
- FUNC3(space_set_param, RID, SpaceParameter, real_t);
- FUNC2RC(real_t, space_get_param, RID, SpaceParameter);
+ FUNC3(space_set_param, RID, PS2DE::SpaceParameter, real_t);
+ FUNC2RC(real_t, space_get_param, RID, PS2DE::SpaceParameter);
// this function only works on physics process, errors and returns null otherwise
PhysicsDirectSpaceState2D *space_get_direct_state(RID p_space) override {
@@ -153,10 +153,10 @@ public:
FUNC2(area_attach_canvas_instance_id, RID, ObjectID);
FUNC1RC(ObjectID, area_get_canvas_instance_id, RID);
- FUNC3(area_set_param, RID, AreaParameter, const Variant &);
+ FUNC3(area_set_param, RID, PS2DE::AreaParameter, const Variant &);
FUNC2(area_set_transform, RID, const Transform2D &);
- FUNC2RC(Variant, area_get_param, RID, AreaParameter);
+ FUNC2RC(Variant, area_get_param, RID, PS2DE::AreaParameter);
FUNC1RC(Transform2D, area_get_transform, RID);
FUNC2(area_set_collision_layer, RID, uint32_t);
@@ -179,8 +179,8 @@ public:
FUNC2(body_set_space, RID, RID);
FUNC1RC(RID, body_get_space, RID);
- FUNC2(body_set_mode, RID, BodyMode);
- FUNC1RC(BodyMode, body_get_mode, RID);
+ FUNC2(body_set_mode, RID, PS2DE::BodyMode);
+ FUNC1RC(PS2DE::BodyMode, body_get_mode, RID);
FUNC4(body_add_shape, RID, RID, const Transform2D &, bool);
FUNC3(body_set_shape, RID, int, RID);
@@ -202,8 +202,8 @@ public:
FUNC2(body_attach_canvas_instance_id, RID, ObjectID);
FUNC1RC(ObjectID, body_get_canvas_instance_id, RID);
- FUNC2(body_set_continuous_collision_detection_mode, RID, CCDMode);
- FUNC1RC(CCDMode, body_get_continuous_collision_detection_mode, RID);
+ FUNC2(body_set_continuous_collision_detection_mode, RID, PS2DE::CCDMode);
+ FUNC1RC(PS2DE::CCDMode, body_get_continuous_collision_detection_mode, RID);
FUNC2(body_set_collision_layer, RID, uint32_t);
FUNC1RC(uint32_t, body_get_collision_layer, RID);
@@ -214,13 +214,13 @@ public:
FUNC2(body_set_collision_priority, RID, real_t);
FUNC1RC(real_t, body_get_collision_priority, RID);
- FUNC3(body_set_param, RID, BodyParameter, const Variant &);
- FUNC2RC(Variant, body_get_param, RID, BodyParameter);
+ FUNC3(body_set_param, RID, PS2DE::BodyParameter, const Variant &);
+ FUNC2RC(Variant, body_get_param, RID, PS2DE::BodyParameter);
FUNC1(body_reset_mass_properties, RID);
- FUNC3(body_set_state, RID, BodyState, const Variant &);
- FUNC2RC(Variant, body_get_state, RID, BodyState);
+ FUNC3(body_set_state, RID, PS2DE::BodyState, const Variant &);
+ FUNC2RC(Variant, body_get_state, RID, PS2DE::BodyState);
FUNC2(body_apply_central_impulse, RID, const Vector2 &);
FUNC2(body_apply_torque_impulse, RID, real_t);
@@ -264,7 +264,7 @@ public:
FUNC2(body_set_pickable, RID, bool);
- bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) override {
+ bool body_test_motion(RID p_body, const PS2DT::MotionParameters &p_parameters, PS2DT::MotionResult *r_result = nullptr) override {
ERR_FAIL_COND_V(!Thread::is_main_thread(), false);
return physics_server_2d->body_test_motion(p_body, p_parameters, r_result);
}
@@ -281,8 +281,8 @@ public:
FUNC1(joint_clear, RID)
- FUNC3(joint_set_param, RID, JointParam, real_t);
- FUNC2RC(real_t, joint_get_param, RID, JointParam);
+ FUNC3(joint_set_param, RID, PS2DE::JointParam, real_t);
+ FUNC2RC(real_t, joint_get_param, RID, PS2DE::JointParam);
FUNC2(joint_disable_collisions_between_bodies, RID, const bool);
FUNC1RC(bool, joint_is_disabled_collisions_between_bodies, RID);
@@ -297,16 +297,16 @@ public:
FUNC6(joint_make_groove, RID, const Vector2 &, const Vector2 &, const Vector2 &, RID, RID);
FUNC5(joint_make_damped_spring, RID, const Vector2 &, const Vector2 &, RID, RID);
- FUNC3(pin_joint_set_param, RID, PinJointParam, real_t);
- FUNC2RC(real_t, pin_joint_get_param, RID, PinJointParam);
+ FUNC3(pin_joint_set_param, RID, PS2DE::PinJointParam, real_t);
+ FUNC2RC(real_t, pin_joint_get_param, RID, PS2DE::PinJointParam);
- FUNC3(pin_joint_set_flag, RID, PinJointFlag, bool);
- FUNC2RC(bool, pin_joint_get_flag, RID, PinJointFlag);
+ FUNC3(pin_joint_set_flag, RID, PS2DE::PinJointFlag, bool);
+ FUNC2RC(bool, pin_joint_get_flag, RID, PS2DE::PinJointFlag);
- FUNC3(damped_spring_joint_set_param, RID, DampedSpringParam, real_t);
- FUNC2RC(real_t, damped_spring_joint_get_param, RID, DampedSpringParam);
+ FUNC3(damped_spring_joint_set_param, RID, PS2DE::DampedSpringParam, real_t);
+ FUNC2RC(real_t, damped_spring_joint_get_param, RID, PS2DE::DampedSpringParam);
- FUNC1RC(JointType, joint_get_type, RID);
+ FUNC1RC(PS2DE::JointType, joint_get_type, RID);
/* MISC */
@@ -324,7 +324,7 @@ public:
return physics_server_2d->is_flushing_queries();
}
- int get_process_info(ProcessInfo p_info) override {
+ int get_process_info(PS2DE::ProcessInfo p_info) override {
return physics_server_2d->get_process_info(p_info);
}
diff --git a/servers/physics_2d/queries/SCsub b/servers/physics_2d/queries/SCsub
new file mode 100644
index 00000000000..96d81ed1484
--- /dev/null
+++ b/servers/physics_2d/queries/SCsub
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+from misc.utility.scons_hints import *
+
+Import("env")
+
+if not env["disable_physics_2d"]:
+ env.add_source_files(env.servers_sources, "*.cpp")
diff --git a/servers/physics_2d/queries/physics_point_query_parameters_2d.cpp b/servers/physics_2d/queries/physics_point_query_parameters_2d.cpp
new file mode 100644
index 00000000000..c69178e2062
--- /dev/null
+++ b/servers/physics_2d/queries/physics_point_query_parameters_2d.cpp
@@ -0,0 +1,78 @@
+/**************************************************************************/
+/* physics_point_query_parameters_2d.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 "physics_point_query_parameters_2d.h"
+
+#include "core/object/class_db.h"
+#include "core/variant/typed_array.h"
+
+void PhysicsPointQueryParameters2D::set_exclude(const TypedArray<RID> &p_exclude) {
+ parameters.exclude.clear();
+ for (int i = 0; i < p_exclude.size(); i++) {
+ parameters.exclude.insert(p_exclude[i]);
+ }
+}
+
+TypedArray<RID> PhysicsPointQueryParameters2D::get_exclude() const {
+ TypedArray<RID> ret;
+ ret.resize(parameters.exclude.size());
+ int idx = 0;
+ for (const RID &E : parameters.exclude) {
+ ret[idx++] = E;
+ }
+ return ret;
+}
+
+void PhysicsPointQueryParameters2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_position", "position"), &PhysicsPointQueryParameters2D::set_position);
+ ClassDB::bind_method(D_METHOD("get_position"), &PhysicsPointQueryParameters2D::get_position);
+
+ ClassDB::bind_method(D_METHOD("set_canvas_instance_id", "canvas_instance_id"), &PhysicsPointQueryParameters2D::set_canvas_instance_id);
+ ClassDB::bind_method(D_METHOD("get_canvas_instance_id"), &PhysicsPointQueryParameters2D::get_canvas_instance_id);
+
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsPointQueryParameters2D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsPointQueryParameters2D::get_collision_mask);
+
+ ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsPointQueryParameters2D::set_exclude);
+ ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsPointQueryParameters2D::get_exclude);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsPointQueryParameters2D::set_collide_with_bodies);
+ ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsPointQueryParameters2D::is_collide_with_bodies_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsPointQueryParameters2D::set_collide_with_areas);
+ ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsPointQueryParameters2D::is_collide_with_areas_enabled);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "canvas_instance_id", PROPERTY_HINT_OBJECT_ID), "set_canvas_instance_id", "get_canvas_instance_id");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude", "get_exclude");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
+}
diff --git a/servers/physics_2d/queries/physics_point_query_parameters_2d.h b/servers/physics_2d/queries/physics_point_query_parameters_2d.h
new file mode 100644
index 00000000000..0cb1966b31d
--- /dev/null
+++ b/servers/physics_2d/queries/physics_point_query_parameters_2d.h
@@ -0,0 +1,64 @@
+/**************************************************************************/
+/* physics_point_query_parameters_2d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/object/ref_counted.h"
+#include "servers/physics_2d/physics_server_2d_types.h"
+
+class PhysicsPointQueryParameters2D : public RefCounted {
+ GDCLASS(PhysicsPointQueryParameters2D, RefCounted);
+
+ PS2DT::PointParameters parameters;
+
+protected:
+ static void _bind_methods();
+
+public:
+ const PS2DT::PointParameters &get_parameters() const { return parameters; }
+
+ void set_position(const Vector2 &p_position) { parameters.position = p_position; }
+ const Vector2 &get_position() const { return parameters.position; }
+
+ void set_canvas_instance_id(ObjectID p_canvas_instance_id) { parameters.canvas_instance_id = p_canvas_instance_id; }
+ ObjectID get_canvas_instance_id() const { return parameters.canvas_instance_id; }
+
+ void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
+ uint32_t get_collision_mask() const { return parameters.collision_mask; }
+
+ void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
+ bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
+
+ void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
+ bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
+
+ void set_exclude(const TypedArray<RID> &p_exclude);
+ TypedArray<RID> get_exclude() const;
+};
diff --git a/servers/physics_2d/queries/physics_ray_query_parameters_2d.cpp b/servers/physics_2d/queries/physics_ray_query_parameters_2d.cpp
new file mode 100644
index 00000000000..8a528584fe3
--- /dev/null
+++ b/servers/physics_2d/queries/physics_ray_query_parameters_2d.cpp
@@ -0,0 +1,94 @@
+/**************************************************************************/
+/* physics_ray_query_parameters_2d.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 "physics_ray_query_parameters_2d.h"
+
+#include "core/object/class_db.h"
+#include "core/variant/typed_array.h"
+
+Ref<PhysicsRayQueryParameters2D> PhysicsRayQueryParameters2D::create(Vector2 p_from, Vector2 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude) {
+ Ref<PhysicsRayQueryParameters2D> params;
+ params.instantiate();
+ params->set_from(p_from);
+ params->set_to(p_to);
+ params->set_collision_mask(p_mask);
+ params->set_exclude(p_exclude);
+ return params;
+}
+
+void PhysicsRayQueryParameters2D::set_exclude(const TypedArray<RID> &p_exclude) {
+ parameters.exclude.clear();
+ for (int i = 0; i < p_exclude.size(); i++) {
+ parameters.exclude.insert(p_exclude[i]);
+ }
+}
+
+TypedArray<RID> PhysicsRayQueryParameters2D::get_exclude() const {
+ TypedArray<RID> ret;
+ ret.resize(parameters.exclude.size());
+ int idx = 0;
+ for (const RID &E : parameters.exclude) {
+ ret[idx++] = E;
+ }
+ return ret;
+}
+
+void PhysicsRayQueryParameters2D::_bind_methods() {
+ ClassDB::bind_static_method("PhysicsRayQueryParameters2D", D_METHOD("create", "from", "to", "collision_mask", "exclude"), &PhysicsRayQueryParameters2D::create, DEFVAL(UINT32_MAX), DEFVAL(TypedArray<RID>()));
+
+ ClassDB::bind_method(D_METHOD("set_from", "from"), &PhysicsRayQueryParameters2D::set_from);
+ ClassDB::bind_method(D_METHOD("get_from"), &PhysicsRayQueryParameters2D::get_from);
+
+ ClassDB::bind_method(D_METHOD("set_to", "to"), &PhysicsRayQueryParameters2D::set_to);
+ ClassDB::bind_method(D_METHOD("get_to"), &PhysicsRayQueryParameters2D::get_to);
+
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsRayQueryParameters2D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsRayQueryParameters2D::get_collision_mask);
+
+ ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsRayQueryParameters2D::set_exclude);
+ ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsRayQueryParameters2D::get_exclude);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsRayQueryParameters2D::set_collide_with_bodies);
+ ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsRayQueryParameters2D::is_collide_with_bodies_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsRayQueryParameters2D::set_collide_with_areas);
+ ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsRayQueryParameters2D::is_collide_with_areas_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_hit_from_inside", "enable"), &PhysicsRayQueryParameters2D::set_hit_from_inside);
+ ClassDB::bind_method(D_METHOD("is_hit_from_inside_enabled"), &PhysicsRayQueryParameters2D::is_hit_from_inside_enabled);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "from"), "set_from", "get_from");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "to"), "set_to", "get_to");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude", "get_exclude");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hit_from_inside"), "set_hit_from_inside", "is_hit_from_inside_enabled");
+}
diff --git a/servers/physics_2d/queries/physics_ray_query_parameters_2d.h b/servers/physics_2d/queries/physics_ray_query_parameters_2d.h
new file mode 100644
index 00000000000..b00b821ce63
--- /dev/null
+++ b/servers/physics_2d/queries/physics_ray_query_parameters_2d.h
@@ -0,0 +1,71 @@
+/**************************************************************************/
+/* physics_ray_query_parameters_2d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/object/ref_counted.h"
+#include "servers/physics_2d/physics_server_2d_types.h"
+
+template <typename T>
+class TypedArray;
+
+class PhysicsRayQueryParameters2D : public RefCounted {
+ GDCLASS(PhysicsRayQueryParameters2D, RefCounted);
+
+ PS2DT::RayParameters parameters;
+
+protected:
+ static void _bind_methods();
+
+public:
+ static Ref<PhysicsRayQueryParameters2D> create(Vector2 p_from, Vector2 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude);
+ const PS2DT::RayParameters &get_parameters() const { return parameters; }
+
+ void set_from(const Vector2 &p_from) { parameters.from = p_from; }
+ const Vector2 &get_from() const { return parameters.from; }
+
+ void set_to(const Vector2 &p_to) { parameters.to = p_to; }
+ const Vector2 &get_to() const { return parameters.to; }
+
+ void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
+ uint32_t get_collision_mask() const { return parameters.collision_mask; }
+
+ void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
+ bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
+
+ void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
+ bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
+
+ void set_hit_from_inside(bool p_enable) { parameters.hit_from_inside = p_enable; }
+ bool is_hit_from_inside_enabled() const { return parameters.hit_from_inside; }
+
+ void set_exclude(const TypedArray<RID> &p_exclude);
+ TypedArray<RID> get_exclude() const;
+};
diff --git a/servers/physics_2d/queries/physics_shape_query_parameters_2d.cpp b/servers/physics_2d/queries/physics_shape_query_parameters_2d.cpp
new file mode 100644
index 00000000000..f86728643d6
--- /dev/null
+++ b/servers/physics_2d/queries/physics_shape_query_parameters_2d.cpp
@@ -0,0 +1,108 @@
+/**************************************************************************/
+/* physics_shape_query_parameters_2d.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 "physics_shape_query_parameters_2d.h"
+
+#include "core/io/resource.h"
+#include "core/object/class_db.h"
+#include "core/variant/typed_array.h"
+
+Ref<Resource> PhysicsShapeQueryParameters2D::get_shape() const {
+ return shape_ref;
+}
+
+void PhysicsShapeQueryParameters2D::set_shape(const Ref<Resource> &p_shape_ref) {
+ ERR_FAIL_COND(p_shape_ref.is_null());
+ shape_ref = p_shape_ref;
+ parameters.shape_rid = p_shape_ref->get_rid();
+}
+
+void PhysicsShapeQueryParameters2D::set_shape_rid(const RID &p_shape) {
+ if (parameters.shape_rid != p_shape) {
+ shape_ref = Ref<Resource>();
+ parameters.shape_rid = p_shape;
+ }
+}
+
+void PhysicsShapeQueryParameters2D::set_exclude(const TypedArray<RID> &p_exclude) {
+ parameters.exclude.clear();
+ for (int i = 0; i < p_exclude.size(); i++) {
+ parameters.exclude.insert(p_exclude[i]);
+ }
+}
+
+TypedArray<RID> PhysicsShapeQueryParameters2D::get_exclude() const {
+ TypedArray<RID> ret;
+ ret.resize(parameters.exclude.size());
+ int idx = 0;
+ for (const RID &E : parameters.exclude) {
+ ret[idx++] = E;
+ }
+ return ret;
+}
+
+void PhysicsShapeQueryParameters2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters2D::set_shape);
+ ClassDB::bind_method(D_METHOD("get_shape"), &PhysicsShapeQueryParameters2D::get_shape);
+
+ ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters2D::set_shape_rid);
+ ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters2D::get_shape_rid);
+
+ ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsShapeQueryParameters2D::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsShapeQueryParameters2D::get_transform);
+
+ ClassDB::bind_method(D_METHOD("set_motion", "motion"), &PhysicsShapeQueryParameters2D::set_motion);
+ ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsShapeQueryParameters2D::get_motion);
+
+ ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsShapeQueryParameters2D::set_margin);
+ ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsShapeQueryParameters2D::get_margin);
+
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsShapeQueryParameters2D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsShapeQueryParameters2D::get_collision_mask);
+
+ ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsShapeQueryParameters2D::set_exclude);
+ ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsShapeQueryParameters2D::get_exclude);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsShapeQueryParameters2D::set_collide_with_bodies);
+ ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsShapeQueryParameters2D::is_collide_with_bodies_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsShapeQueryParameters2D::set_collide_with_areas);
+ ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsShapeQueryParameters2D::is_collide_with_areas_enabled);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude", "get_exclude");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin", PROPERTY_HINT_RANGE, "0,100,0.01"), "set_margin", "get_margin");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion"), "set_motion", "get_motion");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape2D"), "set_shape", "get_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::RID, "shape_rid"), "set_shape_rid", "get_shape_rid");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
+}
diff --git a/servers/physics_2d/queries/physics_shape_query_parameters_2d.h b/servers/physics_2d/queries/physics_shape_query_parameters_2d.h
new file mode 100644
index 00000000000..049cfc730ee
--- /dev/null
+++ b/servers/physics_2d/queries/physics_shape_query_parameters_2d.h
@@ -0,0 +1,79 @@
+/**************************************************************************/
+/* physics_shape_query_parameters_2d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/object/ref_counted.h"
+#include "servers/physics_2d/physics_server_2d_types.h"
+
+class Resource;
+template <typename T>
+class Ref;
+
+class PhysicsShapeQueryParameters2D : public RefCounted {
+ GDCLASS(PhysicsShapeQueryParameters2D, RefCounted);
+
+ PS2DT::ShapeParameters parameters;
+
+ Ref<Resource> shape_ref;
+
+protected:
+ static void _bind_methods();
+
+public:
+ const PS2DT::ShapeParameters &get_parameters() const { return parameters; }
+
+ void set_shape(const Ref<Resource> &p_shape_ref);
+ Ref<Resource> get_shape() const;
+
+ void set_shape_rid(const RID &p_shape);
+ RID get_shape_rid() const { return parameters.shape_rid; }
+
+ void set_transform(const Transform2D &p_transform) { parameters.transform = p_transform; }
+ const Transform2D &get_transform() const { return parameters.transform; }
+
+ void set_motion(const Vector2 &p_motion) { parameters.motion = p_motion; }
+ const Vector2 &get_motion() const { return parameters.motion; }
+
+ void set_margin(real_t p_margin) { parameters.margin = p_margin; }
+ real_t get_margin() const { return parameters.margin; }
+
+ void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
+ uint32_t get_collision_mask() const { return parameters.collision_mask; }
+
+ void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
+ bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
+
+ void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
+ bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
+
+ void set_exclude(const TypedArray<RID> &p_exclude);
+ TypedArray<RID> get_exclude() const;
+};
diff --git a/servers/physics_2d/queries/physics_testmotion_query_parameters_2d.cpp b/servers/physics_2d/queries/physics_testmotion_query_parameters_2d.cpp
new file mode 100644
index 00000000000..869e9dfa958
--- /dev/null
+++ b/servers/physics_2d/queries/physics_testmotion_query_parameters_2d.cpp
@@ -0,0 +1,105 @@
+/**************************************************************************/
+/* physics_testmotion_query_parameters_2d.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 "physics_testmotion_query_parameters_2d.h"
+
+#include "core/object/class_db.h"
+#include "core/variant/typed_array.h"
+
+TypedArray<RID> PhysicsTestMotionParameters2D::get_exclude_bodies() const {
+ TypedArray<RID> exclude;
+ exclude.resize(parameters.exclude_bodies.size());
+
+ int body_index = 0;
+ for (RID body : parameters.exclude_bodies) {
+ exclude[body_index++] = body;
+ }
+
+ return exclude;
+}
+
+void PhysicsTestMotionParameters2D::set_exclude_bodies(const TypedArray<RID> &p_exclude) {
+ parameters.exclude_bodies.clear();
+ for (int i = 0; i < p_exclude.size(); i++) {
+ parameters.exclude_bodies.insert(p_exclude[i]);
+ }
+}
+
+TypedArray<uint64_t> PhysicsTestMotionParameters2D::get_exclude_objects() const {
+ TypedArray<uint64_t> exclude;
+ exclude.resize(parameters.exclude_objects.size());
+
+ int object_index = 0;
+ for (ObjectID object_id : parameters.exclude_objects) {
+ exclude[object_index++] = object_id;
+ }
+
+ return exclude;
+}
+
+void PhysicsTestMotionParameters2D::set_exclude_objects(const TypedArray<uint64_t> &p_exclude) {
+ parameters.exclude_objects.clear();
+ for (int i = 0; i < p_exclude.size(); ++i) {
+ ObjectID object_id = p_exclude[i];
+ ERR_CONTINUE(object_id.is_null());
+ parameters.exclude_objects.insert(object_id);
+ }
+}
+
+void PhysicsTestMotionParameters2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_from"), &PhysicsTestMotionParameters2D::get_from);
+ ClassDB::bind_method(D_METHOD("set_from", "from"), &PhysicsTestMotionParameters2D::set_from);
+
+ ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsTestMotionParameters2D::get_motion);
+ ClassDB::bind_method(D_METHOD("set_motion", "motion"), &PhysicsTestMotionParameters2D::set_motion);
+
+ ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsTestMotionParameters2D::get_margin);
+ ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsTestMotionParameters2D::set_margin);
+
+ ClassDB::bind_method(D_METHOD("is_collide_separation_ray_enabled"), &PhysicsTestMotionParameters2D::is_collide_separation_ray_enabled);
+ ClassDB::bind_method(D_METHOD("set_collide_separation_ray_enabled", "enabled"), &PhysicsTestMotionParameters2D::set_collide_separation_ray_enabled);
+
+ ClassDB::bind_method(D_METHOD("get_exclude_bodies"), &PhysicsTestMotionParameters2D::get_exclude_bodies);
+ ClassDB::bind_method(D_METHOD("set_exclude_bodies", "exclude_list"), &PhysicsTestMotionParameters2D::set_exclude_bodies);
+
+ ClassDB::bind_method(D_METHOD("get_exclude_objects"), &PhysicsTestMotionParameters2D::get_exclude_objects);
+ ClassDB::bind_method(D_METHOD("set_exclude_objects", "exclude_list"), &PhysicsTestMotionParameters2D::set_exclude_objects);
+
+ ClassDB::bind_method(D_METHOD("is_recovery_as_collision_enabled"), &PhysicsTestMotionParameters2D::is_recovery_as_collision_enabled);
+ ClassDB::bind_method(D_METHOD("set_recovery_as_collision_enabled", "enabled"), &PhysicsTestMotionParameters2D::set_recovery_as_collision_enabled);
+
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "from"), "set_from", "get_from");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion"), "set_motion", "get_motion");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin"), "set_margin", "get_margin");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_separation_ray"), "set_collide_separation_ray_enabled", "is_collide_separation_ray_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude_bodies", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude_bodies", "get_exclude_bodies");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude_objects"), "set_exclude_objects", "get_exclude_objects");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "recovery_as_collision"), "set_recovery_as_collision_enabled", "is_recovery_as_collision_enabled");
+}
diff --git a/servers/physics_2d/queries/physics_testmotion_query_parameters_2d.h b/servers/physics_2d/queries/physics_testmotion_query_parameters_2d.h
new file mode 100644
index 00000000000..dc1b9c08c28
--- /dev/null
+++ b/servers/physics_2d/queries/physics_testmotion_query_parameters_2d.h
@@ -0,0 +1,67 @@
+/**************************************************************************/
+/* physics_testmotion_query_parameters_2d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/object/ref_counted.h"
+#include "servers/physics_2d/physics_server_2d_types.h"
+
+class PhysicsTestMotionParameters2D : public RefCounted {
+ GDCLASS(PhysicsTestMotionParameters2D, RefCounted);
+
+ PS2DT::MotionParameters parameters;
+
+protected:
+ static void _bind_methods();
+
+public:
+ const PS2DT::MotionParameters &get_parameters() const { return parameters; }
+
+ const Transform2D &get_from() const { return parameters.from; }
+ void set_from(const Transform2D &p_from) { parameters.from = p_from; }
+
+ const Vector2 &get_motion() const { return parameters.motion; }
+ void set_motion(const Vector2 &p_motion) { parameters.motion = p_motion; }
+
+ real_t get_margin() const { return parameters.margin; }
+ void set_margin(real_t p_margin) { parameters.margin = p_margin; }
+
+ bool is_collide_separation_ray_enabled() const { return parameters.collide_separation_ray; }
+ void set_collide_separation_ray_enabled(bool p_enabled) { parameters.collide_separation_ray = p_enabled; }
+
+ TypedArray<RID> get_exclude_bodies() const;
+ void set_exclude_bodies(const TypedArray<RID> &p_exclude);
+
+ TypedArray<uint64_t> get_exclude_objects() const;
+ void set_exclude_objects(const TypedArray<uint64_t> &p_exclude);
+
+ bool is_recovery_as_collision_enabled() const { return parameters.recovery_as_collision; }
+ void set_recovery_as_collision_enabled(bool p_enabled) { parameters.recovery_as_collision = p_enabled; }
+};
diff --git a/servers/physics_2d/queries/physics_testmotion_query_result_2d.cpp b/servers/physics_2d/queries/physics_testmotion_query_result_2d.cpp
new file mode 100644
index 00000000000..6b486c36a3b
--- /dev/null
+++ b/servers/physics_2d/queries/physics_testmotion_query_result_2d.cpp
@@ -0,0 +1,101 @@
+/**************************************************************************/
+/* physics_testmotion_query_result_2d.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 "physics_testmotion_query_result_2d.h"
+
+#include "core/object/class_db.h"
+
+Vector2 PhysicsTestMotionResult2D::get_travel() const {
+ return result.travel;
+}
+
+Vector2 PhysicsTestMotionResult2D::get_remainder() const {
+ return result.remainder;
+}
+
+Vector2 PhysicsTestMotionResult2D::get_collision_point() const {
+ return result.collision_point;
+}
+
+Vector2 PhysicsTestMotionResult2D::get_collision_normal() const {
+ return result.collision_normal;
+}
+
+Vector2 PhysicsTestMotionResult2D::get_collider_velocity() const {
+ return result.collider_velocity;
+}
+
+ObjectID PhysicsTestMotionResult2D::get_collider_id() const {
+ return result.collider_id;
+}
+
+RID PhysicsTestMotionResult2D::get_collider_rid() const {
+ return result.collider;
+}
+
+Object *PhysicsTestMotionResult2D::get_collider() const {
+ return ObjectDB::get_instance(result.collider_id);
+}
+
+int PhysicsTestMotionResult2D::get_collider_shape() const {
+ return result.collider_shape;
+}
+
+int PhysicsTestMotionResult2D::get_collision_local_shape() const {
+ return result.collision_local_shape;
+}
+
+real_t PhysicsTestMotionResult2D::get_collision_depth() const {
+ return result.collision_depth;
+}
+
+real_t PhysicsTestMotionResult2D::get_collision_safe_fraction() const {
+ return result.collision_safe_fraction;
+}
+
+real_t PhysicsTestMotionResult2D::get_collision_unsafe_fraction() const {
+ return result.collision_unsafe_fraction;
+}
+
+void PhysicsTestMotionResult2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_travel"), &PhysicsTestMotionResult2D::get_travel);
+ ClassDB::bind_method(D_METHOD("get_remainder"), &PhysicsTestMotionResult2D::get_remainder);
+ ClassDB::bind_method(D_METHOD("get_collision_point"), &PhysicsTestMotionResult2D::get_collision_point);
+ ClassDB::bind_method(D_METHOD("get_collision_normal"), &PhysicsTestMotionResult2D::get_collision_normal);
+ ClassDB::bind_method(D_METHOD("get_collider_velocity"), &PhysicsTestMotionResult2D::get_collider_velocity);
+ ClassDB::bind_method(D_METHOD("get_collider_id"), &PhysicsTestMotionResult2D::get_collider_id);
+ ClassDB::bind_method(D_METHOD("get_collider_rid"), &PhysicsTestMotionResult2D::get_collider_rid);
+ ClassDB::bind_method(D_METHOD("get_collider"), &PhysicsTestMotionResult2D::get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_shape"), &PhysicsTestMotionResult2D::get_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_collision_local_shape"), &PhysicsTestMotionResult2D::get_collision_local_shape);
+ ClassDB::bind_method(D_METHOD("get_collision_depth"), &PhysicsTestMotionResult2D::get_collision_depth);
+ ClassDB::bind_method(D_METHOD("get_collision_safe_fraction"), &PhysicsTestMotionResult2D::get_collision_safe_fraction);
+ ClassDB::bind_method(D_METHOD("get_collision_unsafe_fraction"), &PhysicsTestMotionResult2D::get_collision_unsafe_fraction);
+}
diff --git a/servers/physics_2d/queries/physics_testmotion_query_result_2d.h b/servers/physics_2d/queries/physics_testmotion_query_result_2d.h
new file mode 100644
index 00000000000..b3954a0a32a
--- /dev/null
+++ b/servers/physics_2d/queries/physics_testmotion_query_result_2d.h
@@ -0,0 +1,61 @@
+/**************************************************************************/
+/* physics_testmotion_query_result_2d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/object/ref_counted.h"
+#include "servers/physics_2d/physics_server_2d_types.h"
+
+class PhysicsTestMotionResult2D : public RefCounted {
+ GDCLASS(PhysicsTestMotionResult2D, RefCounted);
+
+ PS2DT::MotionResult result;
+
+protected:
+ static void _bind_methods();
+
+public:
+ PS2DT::MotionResult *get_result_ptr() { return &result; }
+
+ Vector2 get_travel() const;
+ Vector2 get_remainder() const;
+
+ Vector2 get_collision_point() const;
+ Vector2 get_collision_normal() const;
+ Vector2 get_collider_velocity() const;
+ ObjectID get_collider_id() const;
+ RID get_collider_rid() const;
+ Object *get_collider() const;
+ int get_collider_shape() const;
+ int get_collision_local_shape() const;
+ real_t get_collision_depth() const;
+ real_t get_collision_safe_fraction() const;
+ real_t get_collision_unsafe_fraction() const;
+};
diff --git a/servers/physics_3d/SCsub b/servers/physics_3d/SCsub
index 87926c3a3d4..26c3c4ff4b8 100644
--- a/servers/physics_3d/SCsub
+++ b/servers/physics_3d/SCsub
@@ -5,3 +5,6 @@ Import("env")
if not env["disable_physics_3d"]:
env.add_source_files(env.servers_sources, "*.cpp")
+
+ SConscript("direct_states/SCsub")
+ SConscript("queries/SCsub")
diff --git a/servers/physics_3d/direct_states/SCsub b/servers/physics_3d/direct_states/SCsub
new file mode 100644
index 00000000000..87926c3a3d4
--- /dev/null
+++ b/servers/physics_3d/direct_states/SCsub
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+from misc.utility.scons_hints import *
+
+Import("env")
+
+if not env["disable_physics_3d"]:
+ env.add_source_files(env.servers_sources, "*.cpp")
diff --git a/servers/physics_3d/direct_states/physics_direct_body_state_3d.cpp b/servers/physics_3d/direct_states/physics_direct_body_state_3d.cpp
new file mode 100644
index 00000000000..49f54115f28
--- /dev/null
+++ b/servers/physics_3d/direct_states/physics_direct_body_state_3d.cpp
@@ -0,0 +1,153 @@
+/**************************************************************************/
+/* physics_direct_body_state_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 "physics_direct_body_state_3d.h"
+
+#include "core/object/class_db.h"
+
+void PhysicsDirectBodyState3D::integrate_forces() {
+ real_t step = get_step();
+ Vector3 lv = get_linear_velocity();
+ lv += get_total_gravity() * step;
+
+ Vector3 av = get_angular_velocity();
+
+ real_t linear_damp = 1.0 - step * get_total_linear_damp();
+
+ if (linear_damp < 0) { // reached zero in the given time
+ linear_damp = 0;
+ }
+
+ real_t angular_damp = 1.0 - step * get_total_angular_damp();
+
+ if (angular_damp < 0) { // reached zero in the given time
+ angular_damp = 0;
+ }
+
+ lv *= linear_damp;
+ av *= angular_damp;
+
+ set_linear_velocity(lv);
+ set_angular_velocity(av);
+}
+
+Object *PhysicsDirectBodyState3D::get_contact_collider_object(int p_contact_idx) const {
+ ObjectID objid = get_contact_collider_id(p_contact_idx);
+ Object *obj = ObjectDB::get_instance(objid);
+ return obj;
+}
+
+void PhysicsDirectBodyState3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState3D::get_total_gravity);
+ ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState3D::get_total_linear_damp);
+ ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState3D::get_total_angular_damp);
+
+ ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState3D::get_center_of_mass);
+ ClassDB::bind_method(D_METHOD("get_center_of_mass_local"), &PhysicsDirectBodyState3D::get_center_of_mass_local);
+ ClassDB::bind_method(D_METHOD("get_principal_inertia_axes"), &PhysicsDirectBodyState3D::get_principal_inertia_axes);
+
+ ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState3D::get_inverse_mass);
+ ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState3D::get_inverse_inertia);
+ ClassDB::bind_method(D_METHOD("get_inverse_inertia_tensor"), &PhysicsDirectBodyState3D::get_inverse_inertia_tensor);
+
+ ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &PhysicsDirectBodyState3D::set_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_linear_velocity"), &PhysicsDirectBodyState3D::get_linear_velocity);
+
+ ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &PhysicsDirectBodyState3D::set_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_angular_velocity"), &PhysicsDirectBodyState3D::get_angular_velocity);
+
+ ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsDirectBodyState3D::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsDirectBodyState3D::get_transform);
+
+ ClassDB::bind_method(D_METHOD("get_velocity_at_local_position", "local_position"), &PhysicsDirectBodyState3D::get_velocity_at_local_position);
+
+ ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &PhysicsDirectBodyState3D::apply_central_impulse, Vector3());
+ ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &PhysicsDirectBodyState3D::apply_impulse, Vector3());
+ ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &PhysicsDirectBodyState3D::apply_torque_impulse);
+
+ ClassDB::bind_method(D_METHOD("apply_central_force", "force"), &PhysicsDirectBodyState3D::apply_central_force, Vector3());
+ ClassDB::bind_method(D_METHOD("apply_force", "force", "position"), &PhysicsDirectBodyState3D::apply_force, Vector3());
+ ClassDB::bind_method(D_METHOD("apply_torque", "torque"), &PhysicsDirectBodyState3D::apply_torque);
+
+ ClassDB::bind_method(D_METHOD("add_constant_central_force", "force"), &PhysicsDirectBodyState3D::add_constant_central_force, Vector3());
+ ClassDB::bind_method(D_METHOD("add_constant_force", "force", "position"), &PhysicsDirectBodyState3D::add_constant_force, Vector3());
+ ClassDB::bind_method(D_METHOD("add_constant_torque", "torque"), &PhysicsDirectBodyState3D::add_constant_torque);
+
+ ClassDB::bind_method(D_METHOD("set_constant_force", "force"), &PhysicsDirectBodyState3D::set_constant_force);
+ ClassDB::bind_method(D_METHOD("get_constant_force"), &PhysicsDirectBodyState3D::get_constant_force);
+
+ ClassDB::bind_method(D_METHOD("set_constant_torque", "torque"), &PhysicsDirectBodyState3D::set_constant_torque);
+ ClassDB::bind_method(D_METHOD("get_constant_torque"), &PhysicsDirectBodyState3D::get_constant_torque);
+
+ ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &PhysicsDirectBodyState3D::set_sleep_state);
+ ClassDB::bind_method(D_METHOD("is_sleeping"), &PhysicsDirectBodyState3D::is_sleeping);
+
+ ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PhysicsDirectBodyState3D::set_collision_layer);
+ ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsDirectBodyState3D::get_collision_layer);
+
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &PhysicsDirectBodyState3D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsDirectBodyState3D::get_collision_mask);
+
+ ClassDB::bind_method(D_METHOD("get_contact_count"), &PhysicsDirectBodyState3D::get_contact_count);
+
+ ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_position);
+ ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_normal);
+ ClassDB::bind_method(D_METHOD("get_contact_impulse", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_impulse);
+ ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_shape);
+ ClassDB::bind_method(D_METHOD("get_contact_local_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_velocity_at_position);
+ ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_position);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_id);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_object);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_velocity_at_position);
+ ClassDB::bind_method(D_METHOD("get_step"), &PhysicsDirectBodyState3D::get_step);
+ ClassDB::bind_method(D_METHOD("integrate_forces"), &PhysicsDirectBodyState3D::integrate_forces);
+ ClassDB::bind_method(D_METHOD("get_space_state"), &PhysicsDirectBodyState3D::get_space_state);
+
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "step"), "", "get_step");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inverse_mass"), "", "get_inverse_mass");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "total_angular_damp"), "", "get_total_angular_damp");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "total_linear_damp"), "", "get_total_linear_damp");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "inverse_inertia"), "", "get_inverse_inertia");
+ ADD_PROPERTY(PropertyInfo(Variant::BASIS, "inverse_inertia_tensor"), "", "get_inverse_inertia_tensor");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "total_gravity"), "", "get_total_gravity");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "center_of_mass"), "", "get_center_of_mass");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "center_of_mass_local"), "", "get_center_of_mass_local");
+ ADD_PROPERTY(PropertyInfo(Variant::BASIS, "principal_inertia_axes"), "", "get_principal_inertia_axes");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity"), "set_linear_velocity", "get_linear_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sleeping"), "set_sleep_state", "is_sleeping");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer"), "set_collision_layer", "get_collision_layer");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask"), "set_collision_mask", "get_collision_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "transform"), "set_transform", "get_transform");
+}
+
+PhysicsDirectBodyState3D::PhysicsDirectBodyState3D() {}
diff --git a/servers/physics_3d/direct_states/physics_direct_body_state_3d.h b/servers/physics_3d/direct_states/physics_direct_body_state_3d.h
new file mode 100644
index 00000000000..f0f6b9194a1
--- /dev/null
+++ b/servers/physics_3d/direct_states/physics_direct_body_state_3d.h
@@ -0,0 +1,113 @@
+/**************************************************************************/
+/* physics_direct_body_state_3d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/variant/type_info.h"
+#include "servers/physics_3d/direct_states/physics_direct_space_state_3d.h"
+
+class PhysicsDirectBodyState3D : public Object {
+ GDCLASS(PhysicsDirectBodyState3D, Object);
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual Vector3 get_total_gravity() const = 0;
+ virtual real_t get_total_angular_damp() const = 0;
+ virtual real_t get_total_linear_damp() const = 0;
+
+ virtual Vector3 get_center_of_mass() const = 0;
+ virtual Vector3 get_center_of_mass_local() const = 0;
+ virtual Basis get_principal_inertia_axes() const = 0;
+ virtual real_t get_inverse_mass() const = 0; // get the mass
+ virtual Vector3 get_inverse_inertia() const = 0; // get density of this body space
+ virtual Basis get_inverse_inertia_tensor() const = 0; // get density of this body space
+
+ virtual void set_linear_velocity(const Vector3 &p_velocity) = 0;
+ virtual Vector3 get_linear_velocity() const = 0;
+
+ virtual void set_angular_velocity(const Vector3 &p_velocity) = 0;
+ virtual Vector3 get_angular_velocity() const = 0;
+
+ virtual void set_transform(const Transform3D &p_transform) = 0;
+ virtual Transform3D get_transform() const = 0;
+
+ virtual Vector3 get_velocity_at_local_position(const Vector3 &p_position) const = 0;
+
+ virtual void apply_central_impulse(const Vector3 &p_impulse) = 0;
+ virtual void apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position = Vector3()) = 0;
+ virtual void apply_torque_impulse(const Vector3 &p_impulse) = 0;
+
+ virtual void apply_central_force(const Vector3 &p_force) = 0;
+ virtual void apply_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0;
+ virtual void apply_torque(const Vector3 &p_torque) = 0;
+
+ virtual void add_constant_central_force(const Vector3 &p_force) = 0;
+ virtual void add_constant_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0;
+ virtual void add_constant_torque(const Vector3 &p_torque) = 0;
+
+ virtual void set_constant_force(const Vector3 &p_force) = 0;
+ virtual Vector3 get_constant_force() const = 0;
+
+ virtual void set_constant_torque(const Vector3 &p_torque) = 0;
+ virtual Vector3 get_constant_torque() const = 0;
+
+ virtual void set_sleep_state(bool p_sleep) = 0;
+ virtual bool is_sleeping() const = 0;
+
+ virtual void set_collision_layer(uint32_t p_layer) = 0;
+ virtual uint32_t get_collision_layer() const = 0;
+
+ virtual void set_collision_mask(uint32_t p_mask) = 0;
+ virtual uint32_t get_collision_mask() const = 0;
+
+ virtual int get_contact_count() const = 0;
+
+ virtual Vector3 get_contact_local_position(int p_contact_idx) const = 0;
+ virtual Vector3 get_contact_local_normal(int p_contact_idx) const = 0;
+ virtual Vector3 get_contact_impulse(int p_contact_idx) const = 0;
+ virtual int get_contact_local_shape(int p_contact_idx) const = 0;
+ virtual Vector3 get_contact_local_velocity_at_position(int p_contact_idx) const = 0;
+
+ virtual RID get_contact_collider(int p_contact_idx) const = 0;
+ virtual Vector3 get_contact_collider_position(int p_contact_idx) const = 0;
+ virtual ObjectID get_contact_collider_id(int p_contact_idx) const = 0;
+ virtual Object *get_contact_collider_object(int p_contact_idx) const;
+ virtual int get_contact_collider_shape(int p_contact_idx) const = 0;
+ virtual Vector3 get_contact_collider_velocity_at_position(int p_contact_idx) const = 0;
+
+ virtual real_t get_step() const = 0;
+ virtual void integrate_forces();
+
+ virtual RequiredResult<PhysicsDirectSpaceState3D> get_space_state() = 0;
+
+ PhysicsDirectBodyState3D();
+};
diff --git a/servers/physics_3d/direct_states/physics_direct_space_state_3d.cpp b/servers/physics_3d/direct_states/physics_direct_space_state_3d.cpp
new file mode 100644
index 00000000000..dafefd5d191
--- /dev/null
+++ b/servers/physics_3d/direct_states/physics_direct_space_state_3d.cpp
@@ -0,0 +1,167 @@
+/**************************************************************************/
+/* physics_direct_space_state_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 "physics_direct_space_state_3d.h"
+
+#include "core/object/class_db.h"
+#include "core/variant/typed_array.h"
+
+Dictionary PhysicsDirectSpaceState3D::_intersect_ray(RequiredParam<PhysicsRayQueryParameters3D> rp_ray_query) {
+ EXTRACT_PARAM_OR_FAIL_V(p_ray_query, rp_ray_query, Dictionary());
+
+ PS3DT::RayResult result;
+ bool res = intersect_ray(p_ray_query->get_parameters(), result);
+
+ if (!res) {
+ return Dictionary();
+ }
+
+ Dictionary d;
+ d["position"] = result.position;
+ d["normal"] = result.normal;
+ d["face_index"] = result.face_index;
+ d["collider_id"] = result.collider_id;
+ d["collider"] = result.collider;
+ d["shape"] = result.shape;
+ d["rid"] = result.rid;
+
+ return d;
+}
+
+TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_point(RequiredParam<PhysicsPointQueryParameters3D> rp_point_query, int p_max_results) {
+ EXTRACT_PARAM_OR_FAIL_V(p_point_query, rp_point_query, TypedArray<Dictionary>());
+
+ Vector<PS3DT::ShapeResult> ret;
+ ret.resize(p_max_results);
+
+ int rc = intersect_point(p_point_query->get_parameters(), ret.ptrw(), ret.size());
+
+ if (rc == 0) {
+ return TypedArray<Dictionary>();
+ }
+
+ TypedArray<Dictionary> r;
+ r.resize(rc);
+ for (int i = 0; i < rc; i++) {
+ Dictionary d;
+ d["rid"] = ret[i].rid;
+ d["collider_id"] = ret[i].collider_id;
+ d["collider"] = ret[i].collider;
+ d["shape"] = ret[i].shape;
+ r[i] = d;
+ }
+ return r;
+}
+
+TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_shape(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query, int p_max_results) {
+ EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, TypedArray<Dictionary>());
+
+ Vector<PS3DT::ShapeResult> sr;
+ sr.resize(p_max_results);
+ int rc = intersect_shape(p_shape_query->get_parameters(), sr.ptrw(), sr.size());
+ TypedArray<Dictionary> ret;
+ ret.resize(rc);
+ for (int i = 0; i < rc; i++) {
+ Dictionary d;
+ d["rid"] = sr[i].rid;
+ d["collider_id"] = sr[i].collider_id;
+ d["collider"] = sr[i].collider;
+ d["shape"] = sr[i].shape;
+ ret[i] = d;
+ }
+
+ return ret;
+}
+
+Vector<real_t> PhysicsDirectSpaceState3D::_cast_motion(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query) {
+ EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, Vector<real_t>());
+
+ real_t closest_safe = 1.0f, closest_unsafe = 1.0f;
+ bool res = cast_motion(p_shape_query->get_parameters(), closest_safe, closest_unsafe);
+ if (!res) {
+ return Vector<real_t>();
+ }
+ Vector<real_t> ret;
+ ret.resize(2);
+ ret.write[0] = closest_safe;
+ ret.write[1] = closest_unsafe;
+ return ret;
+}
+
+TypedArray<Vector3> PhysicsDirectSpaceState3D::_collide_shape(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query, int p_max_results) {
+ EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, TypedArray<Vector3>());
+
+ Vector<Vector3> ret;
+ ret.resize(p_max_results * 2);
+ int rc = 0;
+ bool res = collide_shape(p_shape_query->get_parameters(), ret.ptrw(), p_max_results, rc);
+ if (!res) {
+ return TypedArray<Vector3>();
+ }
+ TypedArray<Vector3> r;
+ r.resize(rc * 2);
+ for (int i = 0; i < rc * 2; i++) {
+ r[i] = ret[i];
+ }
+ return r;
+}
+
+Dictionary PhysicsDirectSpaceState3D::_get_rest_info(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query) {
+ EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, Dictionary());
+
+ PS3DT::ShapeRestInfo sri;
+
+ bool res = rest_info(p_shape_query->get_parameters(), &sri);
+ Dictionary r;
+ if (!res) {
+ return r;
+ }
+
+ r["point"] = sri.point;
+ r["normal"] = sri.normal;
+ r["rid"] = sri.rid;
+ r["collider_id"] = sri.collider_id;
+ r["shape"] = sri.shape;
+ r["linear_velocity"] = sri.linear_velocity;
+
+ return r;
+}
+
+PhysicsDirectSpaceState3D::PhysicsDirectSpaceState3D() {
+}
+
+void PhysicsDirectSpaceState3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("intersect_point", "parameters", "max_results"), &PhysicsDirectSpaceState3D::_intersect_point, DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("intersect_ray", "parameters"), &PhysicsDirectSpaceState3D::_intersect_ray);
+ ClassDB::bind_method(D_METHOD("intersect_shape", "parameters", "max_results"), &PhysicsDirectSpaceState3D::_intersect_shape, DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("cast_motion", "parameters"), &PhysicsDirectSpaceState3D::_cast_motion);
+ ClassDB::bind_method(D_METHOD("collide_shape", "parameters", "max_results"), &PhysicsDirectSpaceState3D::_collide_shape, DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("get_rest_info", "parameters"), &PhysicsDirectSpaceState3D::_get_rest_info);
+}
diff --git a/servers/physics_3d/direct_states/physics_direct_space_state_3d.h b/servers/physics_3d/direct_states/physics_direct_space_state_3d.h
new file mode 100644
index 00000000000..1edc5467d89
--- /dev/null
+++ b/servers/physics_3d/direct_states/physics_direct_space_state_3d.h
@@ -0,0 +1,66 @@
+/**************************************************************************/
+/* physics_direct_space_state_3d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/variant/type_info.h"
+#include "servers/physics_3d/physics_server_3d_types.h"
+#include "servers/physics_3d/queries/physics_point_query_parameters_3d.h"
+#include "servers/physics_3d/queries/physics_ray_query_parameters_3d.h"
+#include "servers/physics_3d/queries/physics_shape_query_parameters_3d.h"
+
+class PhysicsDirectSpaceState3D : public Object {
+ GDCLASS(PhysicsDirectSpaceState3D, Object);
+
+private:
+ Dictionary _intersect_ray(RequiredParam<PhysicsRayQueryParameters3D> rp_ray_query);
+ TypedArray<Dictionary> _intersect_point(RequiredParam<PhysicsPointQueryParameters3D> rp_point_query, int p_max_results = 32);
+ TypedArray<Dictionary> _intersect_shape(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query, int p_max_results = 32);
+ Vector<real_t> _cast_motion(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query);
+ TypedArray<Vector3> _collide_shape(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query, int p_max_results = 32);
+ Dictionary _get_rest_info(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query);
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual bool intersect_ray(const PS3DT::RayParameters &p_parameters, PS3DT::RayResult &r_result) = 0;
+
+ virtual int intersect_point(const PS3DT::PointParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) = 0;
+
+ virtual int intersect_shape(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) = 0;
+ virtual bool cast_motion(const PS3DT::ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, PS3DT::ShapeRestInfo *r_info = nullptr) = 0;
+ virtual bool collide_shape(const PS3DT::ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) = 0;
+ virtual bool rest_info(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeRestInfo *r_info) = 0;
+
+ virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const = 0;
+
+ PhysicsDirectSpaceState3D();
+};
diff --git a/servers/physics_3d/physics_server_3d.cpp b/servers/physics_3d/physics_server_3d.cpp
index 13cbf6d207b..ccd61e630f5 100644
--- a/servers/physics_3d/physics_server_3d.cpp
+++ b/servers/physics_3d/physics_server_3d.cpp
@@ -32,635 +32,18 @@
#include "core/config/project_settings.h"
#include "core/object/class_db.h"
-#include "core/variant/typed_array.h"
-
-void PhysicsServer3DRenderingServerHandler::set_vertex(int p_vertex_id, const Vector3 &p_vertex) {
- GDVIRTUAL_CALL(_set_vertex, p_vertex_id, p_vertex);
-}
-void PhysicsServer3DRenderingServerHandler::set_normal(int p_vertex_id, const Vector3 &p_normal) {
- GDVIRTUAL_CALL(_set_normal, p_vertex_id, p_normal);
-}
-void PhysicsServer3DRenderingServerHandler::set_aabb(const AABB &p_aabb) {
- GDVIRTUAL_CALL(_set_aabb, p_aabb);
-}
-
-void PhysicsServer3DRenderingServerHandler::_bind_methods() {
- GDVIRTUAL_BIND(_set_vertex, "vertex_id", "vertex");
- GDVIRTUAL_BIND(_set_normal, "vertex_id", "normal");
- GDVIRTUAL_BIND(_set_aabb, "aabb");
-
- ClassDB::bind_method(D_METHOD("set_vertex", "vertex_id", "vertex"), &PhysicsServer3DRenderingServerHandler::set_vertex);
- ClassDB::bind_method(D_METHOD("set_normal", "vertex_id", "normal"), &PhysicsServer3DRenderingServerHandler::set_normal);
- ClassDB::bind_method(D_METHOD("set_aabb", "aabb"), &PhysicsServer3DRenderingServerHandler::set_aabb);
-}
+#include "core/object/ref_counted.h"
PhysicsServer3D *PhysicsServer3D::singleton = nullptr;
-void PhysicsDirectBodyState3D::integrate_forces() {
- real_t step = get_step();
- Vector3 lv = get_linear_velocity();
- lv += get_total_gravity() * step;
-
- Vector3 av = get_angular_velocity();
-
- real_t linear_damp = 1.0 - step * get_total_linear_damp();
-
- if (linear_damp < 0) { // reached zero in the given time
- linear_damp = 0;
- }
-
- real_t angular_damp = 1.0 - step * get_total_angular_damp();
-
- if (angular_damp < 0) { // reached zero in the given time
- angular_damp = 0;
- }
-
- lv *= linear_damp;
- av *= angular_damp;
-
- set_linear_velocity(lv);
- set_angular_velocity(av);
-}
-
-Object *PhysicsDirectBodyState3D::get_contact_collider_object(int p_contact_idx) const {
- ObjectID objid = get_contact_collider_id(p_contact_idx);
- Object *obj = ObjectDB::get_instance(objid);
- return obj;
-}
-
PhysicsServer3D *PhysicsServer3D::get_singleton() {
return singleton;
}
-void PhysicsDirectBodyState3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState3D::get_total_gravity);
- ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState3D::get_total_linear_damp);
- ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState3D::get_total_angular_damp);
-
- ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState3D::get_center_of_mass);
- ClassDB::bind_method(D_METHOD("get_center_of_mass_local"), &PhysicsDirectBodyState3D::get_center_of_mass_local);
- ClassDB::bind_method(D_METHOD("get_principal_inertia_axes"), &PhysicsDirectBodyState3D::get_principal_inertia_axes);
-
- ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState3D::get_inverse_mass);
- ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState3D::get_inverse_inertia);
- ClassDB::bind_method(D_METHOD("get_inverse_inertia_tensor"), &PhysicsDirectBodyState3D::get_inverse_inertia_tensor);
-
- ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &PhysicsDirectBodyState3D::set_linear_velocity);
- ClassDB::bind_method(D_METHOD("get_linear_velocity"), &PhysicsDirectBodyState3D::get_linear_velocity);
-
- ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &PhysicsDirectBodyState3D::set_angular_velocity);
- ClassDB::bind_method(D_METHOD("get_angular_velocity"), &PhysicsDirectBodyState3D::get_angular_velocity);
-
- ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsDirectBodyState3D::set_transform);
- ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsDirectBodyState3D::get_transform);
-
- ClassDB::bind_method(D_METHOD("get_velocity_at_local_position", "local_position"), &PhysicsDirectBodyState3D::get_velocity_at_local_position);
-
- ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &PhysicsDirectBodyState3D::apply_central_impulse, Vector3());
- ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &PhysicsDirectBodyState3D::apply_impulse, Vector3());
- ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &PhysicsDirectBodyState3D::apply_torque_impulse);
-
- ClassDB::bind_method(D_METHOD("apply_central_force", "force"), &PhysicsDirectBodyState3D::apply_central_force, Vector3());
- ClassDB::bind_method(D_METHOD("apply_force", "force", "position"), &PhysicsDirectBodyState3D::apply_force, Vector3());
- ClassDB::bind_method(D_METHOD("apply_torque", "torque"), &PhysicsDirectBodyState3D::apply_torque);
-
- ClassDB::bind_method(D_METHOD("add_constant_central_force", "force"), &PhysicsDirectBodyState3D::add_constant_central_force, Vector3());
- ClassDB::bind_method(D_METHOD("add_constant_force", "force", "position"), &PhysicsDirectBodyState3D::add_constant_force, Vector3());
- ClassDB::bind_method(D_METHOD("add_constant_torque", "torque"), &PhysicsDirectBodyState3D::add_constant_torque);
-
- ClassDB::bind_method(D_METHOD("set_constant_force", "force"), &PhysicsDirectBodyState3D::set_constant_force);
- ClassDB::bind_method(D_METHOD("get_constant_force"), &PhysicsDirectBodyState3D::get_constant_force);
-
- ClassDB::bind_method(D_METHOD("set_constant_torque", "torque"), &PhysicsDirectBodyState3D::set_constant_torque);
- ClassDB::bind_method(D_METHOD("get_constant_torque"), &PhysicsDirectBodyState3D::get_constant_torque);
-
- ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &PhysicsDirectBodyState3D::set_sleep_state);
- ClassDB::bind_method(D_METHOD("is_sleeping"), &PhysicsDirectBodyState3D::is_sleeping);
-
- ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PhysicsDirectBodyState3D::set_collision_layer);
- ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsDirectBodyState3D::get_collision_layer);
-
- ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &PhysicsDirectBodyState3D::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsDirectBodyState3D::get_collision_mask);
-
- ClassDB::bind_method(D_METHOD("get_contact_count"), &PhysicsDirectBodyState3D::get_contact_count);
-
- ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_position);
- ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_normal);
- ClassDB::bind_method(D_METHOD("get_contact_impulse", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_impulse);
- ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_shape);
- ClassDB::bind_method(D_METHOD("get_contact_local_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_velocity_at_position);
- ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider);
- ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_position);
- ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_id);
- ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_object);
- ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_shape);
- ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_velocity_at_position);
- ClassDB::bind_method(D_METHOD("get_step"), &PhysicsDirectBodyState3D::get_step);
- ClassDB::bind_method(D_METHOD("integrate_forces"), &PhysicsDirectBodyState3D::integrate_forces);
- ClassDB::bind_method(D_METHOD("get_space_state"), &PhysicsDirectBodyState3D::get_space_state);
-
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "step"), "", "get_step");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inverse_mass"), "", "get_inverse_mass");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "total_angular_damp"), "", "get_total_angular_damp");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "total_linear_damp"), "", "get_total_linear_damp");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "inverse_inertia"), "", "get_inverse_inertia");
- ADD_PROPERTY(PropertyInfo(Variant::BASIS, "inverse_inertia_tensor"), "", "get_inverse_inertia_tensor");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "total_gravity"), "", "get_total_gravity");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "center_of_mass"), "", "get_center_of_mass");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "center_of_mass_local"), "", "get_center_of_mass_local");
- ADD_PROPERTY(PropertyInfo(Variant::BASIS, "principal_inertia_axes"), "", "get_principal_inertia_axes");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity"), "set_linear_velocity", "get_linear_velocity");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sleeping"), "set_sleep_state", "is_sleeping");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer"), "set_collision_layer", "get_collision_layer");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask"), "set_collision_mask", "get_collision_mask");
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "transform"), "set_transform", "get_transform");
-}
-
-PhysicsDirectBodyState3D::PhysicsDirectBodyState3D() {}
-
-///////////////////////////////////////////////////////
-
-void PhysicsRayQueryParameters3D::set_exclude(const TypedArray<RID> &p_exclude) {
- parameters.exclude.clear();
- for (int i = 0; i < p_exclude.size(); i++) {
- parameters.exclude.insert(p_exclude[i]);
- }
-}
-
-TypedArray<RID> PhysicsRayQueryParameters3D::get_exclude() const {
- TypedArray<RID> ret;
- ret.resize(parameters.exclude.size());
- int idx = 0;
- for (const RID &E : parameters.exclude) {
- ret[idx++] = E;
- }
- return ret;
-}
-
-void PhysicsRayQueryParameters3D::_bind_methods() {
- ClassDB::bind_static_method("PhysicsRayQueryParameters3D", D_METHOD("create", "from", "to", "collision_mask", "exclude"), &PhysicsRayQueryParameters3D::create, DEFVAL(UINT32_MAX), DEFVAL(TypedArray<RID>()));
-
- ClassDB::bind_method(D_METHOD("set_from", "from"), &PhysicsRayQueryParameters3D::set_from);
- ClassDB::bind_method(D_METHOD("get_from"), &PhysicsRayQueryParameters3D::get_from);
-
- ClassDB::bind_method(D_METHOD("set_to", "to"), &PhysicsRayQueryParameters3D::set_to);
- ClassDB::bind_method(D_METHOD("get_to"), &PhysicsRayQueryParameters3D::get_to);
-
- ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsRayQueryParameters3D::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsRayQueryParameters3D::get_collision_mask);
-
- ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsRayQueryParameters3D::set_exclude);
- ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsRayQueryParameters3D::get_exclude);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsRayQueryParameters3D::set_collide_with_bodies);
- ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsRayQueryParameters3D::is_collide_with_bodies_enabled);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsRayQueryParameters3D::set_collide_with_areas);
- ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsRayQueryParameters3D::is_collide_with_areas_enabled);
-
- ClassDB::bind_method(D_METHOD("set_hit_from_inside", "enable"), &PhysicsRayQueryParameters3D::set_hit_from_inside);
- ClassDB::bind_method(D_METHOD("is_hit_from_inside_enabled"), &PhysicsRayQueryParameters3D::is_hit_from_inside_enabled);
-
- ClassDB::bind_method(D_METHOD("set_hit_back_faces", "enable"), &PhysicsRayQueryParameters3D::set_hit_back_faces);
- ClassDB::bind_method(D_METHOD("is_hit_back_faces_enabled"), &PhysicsRayQueryParameters3D::is_hit_back_faces_enabled);
-
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "from"), "set_from", "get_from");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "to"), "set_to", "get_to");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude", "get_exclude");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hit_from_inside"), "set_hit_from_inside", "is_hit_from_inside_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hit_back_faces"), "set_hit_back_faces", "is_hit_back_faces_enabled");
-}
-
-///////////////////////////////////////////////////////
-
-Ref<PhysicsRayQueryParameters3D> PhysicsRayQueryParameters3D::create(Vector3 p_from, Vector3 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude) {
- Ref<PhysicsRayQueryParameters3D> params;
- params.instantiate();
- params->set_from(p_from);
- params->set_to(p_to);
- params->set_collision_mask(p_mask);
- params->set_exclude(p_exclude);
- return params;
-}
-
-void PhysicsPointQueryParameters3D::set_exclude(const TypedArray<RID> &p_exclude) {
- parameters.exclude.clear();
- for (int i = 0; i < p_exclude.size(); i++) {
- parameters.exclude.insert(p_exclude[i]);
- }
-}
-
-TypedArray<RID> PhysicsPointQueryParameters3D::get_exclude() const {
- TypedArray<RID> ret;
- ret.resize(parameters.exclude.size());
- int idx = 0;
- for (const RID &E : parameters.exclude) {
- ret[idx++] = E;
- }
- return ret;
-}
-
-void PhysicsPointQueryParameters3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_position", "position"), &PhysicsPointQueryParameters3D::set_position);
- ClassDB::bind_method(D_METHOD("get_position"), &PhysicsPointQueryParameters3D::get_position);
-
- ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsPointQueryParameters3D::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsPointQueryParameters3D::get_collision_mask);
-
- ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsPointQueryParameters3D::set_exclude);
- ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsPointQueryParameters3D::get_exclude);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsPointQueryParameters3D::set_collide_with_bodies);
- ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsPointQueryParameters3D::is_collide_with_bodies_enabled);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsPointQueryParameters3D::set_collide_with_areas);
- ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsPointQueryParameters3D::is_collide_with_areas_enabled);
-
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "set_position", "get_position");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude", "get_exclude");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
-}
-
-///////////////////////////////////////////////////////
-
-void PhysicsShapeQueryParameters3D::set_shape(const Ref<Resource> &p_shape_ref) {
- ERR_FAIL_COND(p_shape_ref.is_null());
- shape_ref = p_shape_ref;
- parameters.shape_rid = p_shape_ref->get_rid();
-}
-
-void PhysicsShapeQueryParameters3D::set_shape_rid(const RID &p_shape) {
- if (parameters.shape_rid != p_shape) {
- shape_ref = Ref<Resource>();
- parameters.shape_rid = p_shape;
- }
-}
-
-void PhysicsShapeQueryParameters3D::set_exclude(const TypedArray<RID> &p_exclude) {
- parameters.exclude.clear();
- for (int i = 0; i < p_exclude.size(); i++) {
- parameters.exclude.insert(p_exclude[i]);
- }
-}
-
-TypedArray<RID> PhysicsShapeQueryParameters3D::get_exclude() const {
- TypedArray<RID> ret;
- ret.resize(parameters.exclude.size());
- int idx = 0;
- for (const RID &E : parameters.exclude) {
- ret[idx++] = E;
- }
- return ret;
-}
-
-void PhysicsShapeQueryParameters3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters3D::set_shape);
- ClassDB::bind_method(D_METHOD("get_shape"), &PhysicsShapeQueryParameters3D::get_shape);
-
- ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters3D::set_shape_rid);
- ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters3D::get_shape_rid);
-
- ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsShapeQueryParameters3D::set_transform);
- ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsShapeQueryParameters3D::get_transform);
-
- ClassDB::bind_method(D_METHOD("set_motion", "motion"), &PhysicsShapeQueryParameters3D::set_motion);
- ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsShapeQueryParameters3D::get_motion);
-
- ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsShapeQueryParameters3D::set_margin);
- ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsShapeQueryParameters3D::get_margin);
-
- ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsShapeQueryParameters3D::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsShapeQueryParameters3D::get_collision_mask);
-
- ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsShapeQueryParameters3D::set_exclude);
- ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsShapeQueryParameters3D::get_exclude);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsShapeQueryParameters3D::set_collide_with_bodies);
- ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsShapeQueryParameters3D::is_collide_with_bodies_enabled);
-
- ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsShapeQueryParameters3D::set_collide_with_areas);
- ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsShapeQueryParameters3D::is_collide_with_areas_enabled);
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude", "get_exclude");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin", PROPERTY_HINT_RANGE, "0,100,0.01"), "set_margin", "get_margin");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "motion"), "set_motion", "get_motion");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape3D"), "set_shape", "get_shape");
- ADD_PROPERTY(PropertyInfo(Variant::RID, "shape_rid"), "set_shape_rid", "get_shape_rid");
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "transform"), "set_transform", "get_transform");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
-}
-
-/////////////////////////////////////
-
-Dictionary PhysicsDirectSpaceState3D::_intersect_ray(RequiredParam<PhysicsRayQueryParameters3D> rp_ray_query) {
- EXTRACT_PARAM_OR_FAIL_V(p_ray_query, rp_ray_query, Dictionary());
-
- RayResult result;
- bool res = intersect_ray(p_ray_query->get_parameters(), result);
-
- if (!res) {
- return Dictionary();
- }
-
- Dictionary d;
- d["position"] = result.position;
- d["normal"] = result.normal;
- d["face_index"] = result.face_index;
- d["collider_id"] = result.collider_id;
- d["collider"] = result.collider;
- d["shape"] = result.shape;
- d["rid"] = result.rid;
-
- return d;
-}
-
-TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_point(RequiredParam<PhysicsPointQueryParameters3D> rp_point_query, int p_max_results) {
- EXTRACT_PARAM_OR_FAIL_V(p_point_query, rp_point_query, TypedArray<Dictionary>());
-
- Vector<ShapeResult> ret;
- ret.resize(p_max_results);
-
- int rc = intersect_point(p_point_query->get_parameters(), ret.ptrw(), ret.size());
-
- if (rc == 0) {
- return TypedArray<Dictionary>();
- }
-
- TypedArray<Dictionary> r;
- r.resize(rc);
- for (int i = 0; i < rc; i++) {
- Dictionary d;
- d["rid"] = ret[i].rid;
- d["collider_id"] = ret[i].collider_id;
- d["collider"] = ret[i].collider;
- d["shape"] = ret[i].shape;
- r[i] = d;
- }
- return r;
-}
-
-TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_shape(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query, int p_max_results) {
- EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, TypedArray<Dictionary>());
-
- Vector<ShapeResult> sr;
- sr.resize(p_max_results);
- int rc = intersect_shape(p_shape_query->get_parameters(), sr.ptrw(), sr.size());
- TypedArray<Dictionary> ret;
- ret.resize(rc);
- for (int i = 0; i < rc; i++) {
- Dictionary d;
- d["rid"] = sr[i].rid;
- d["collider_id"] = sr[i].collider_id;
- d["collider"] = sr[i].collider;
- d["shape"] = sr[i].shape;
- ret[i] = d;
- }
-
- return ret;
-}
-
-Vector<real_t> PhysicsDirectSpaceState3D::_cast_motion(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query) {
- EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, Vector<real_t>());
-
- real_t closest_safe = 1.0f, closest_unsafe = 1.0f;
- bool res = cast_motion(p_shape_query->get_parameters(), closest_safe, closest_unsafe);
- if (!res) {
- return Vector<real_t>();
- }
- Vector<real_t> ret;
- ret.resize(2);
- ret.write[0] = closest_safe;
- ret.write[1] = closest_unsafe;
- return ret;
-}
-
-TypedArray<Vector3> PhysicsDirectSpaceState3D::_collide_shape(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query, int p_max_results) {
- EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, TypedArray<Vector3>());
-
- Vector<Vector3> ret;
- ret.resize(p_max_results * 2);
- int rc = 0;
- bool res = collide_shape(p_shape_query->get_parameters(), ret.ptrw(), p_max_results, rc);
- if (!res) {
- return TypedArray<Vector3>();
- }
- TypedArray<Vector3> r;
- r.resize(rc * 2);
- for (int i = 0; i < rc * 2; i++) {
- r[i] = ret[i];
- }
- return r;
-}
-
-Dictionary PhysicsDirectSpaceState3D::_get_rest_info(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query) {
- EXTRACT_PARAM_OR_FAIL_V(p_shape_query, rp_shape_query, Dictionary());
-
- ShapeRestInfo sri;
-
- bool res = rest_info(p_shape_query->get_parameters(), &sri);
- Dictionary r;
- if (!res) {
- return r;
- }
-
- r["point"] = sri.point;
- r["normal"] = sri.normal;
- r["rid"] = sri.rid;
- r["collider_id"] = sri.collider_id;
- r["shape"] = sri.shape;
- r["linear_velocity"] = sri.linear_velocity;
-
- return r;
-}
-
-PhysicsDirectSpaceState3D::PhysicsDirectSpaceState3D() {
-}
-
-void PhysicsDirectSpaceState3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("intersect_point", "parameters", "max_results"), &PhysicsDirectSpaceState3D::_intersect_point, DEFVAL(32));
- ClassDB::bind_method(D_METHOD("intersect_ray", "parameters"), &PhysicsDirectSpaceState3D::_intersect_ray);
- ClassDB::bind_method(D_METHOD("intersect_shape", "parameters", "max_results"), &PhysicsDirectSpaceState3D::_intersect_shape, DEFVAL(32));
- ClassDB::bind_method(D_METHOD("cast_motion", "parameters"), &PhysicsDirectSpaceState3D::_cast_motion);
- ClassDB::bind_method(D_METHOD("collide_shape", "parameters", "max_results"), &PhysicsDirectSpaceState3D::_collide_shape, DEFVAL(32));
- ClassDB::bind_method(D_METHOD("get_rest_info", "parameters"), &PhysicsDirectSpaceState3D::_get_rest_info);
-}
-
-///////////////////////////////
-
-TypedArray<RID> PhysicsTestMotionParameters3D::get_exclude_bodies() const {
- TypedArray<RID> exclude;
- exclude.resize(parameters.exclude_bodies.size());
-
- int body_index = 0;
- for (const RID &body : parameters.exclude_bodies) {
- exclude[body_index++] = body;
- }
-
- return exclude;
-}
-
-void PhysicsTestMotionParameters3D::set_exclude_bodies(const TypedArray<RID> &p_exclude) {
- parameters.exclude_bodies.clear();
- for (int i = 0; i < p_exclude.size(); i++) {
- parameters.exclude_bodies.insert(p_exclude[i]);
- }
-}
-
-TypedArray<uint64_t> PhysicsTestMotionParameters3D::get_exclude_objects() const {
- TypedArray<uint64_t> exclude;
- exclude.resize(parameters.exclude_objects.size());
-
- int object_index = 0;
- for (const ObjectID &object_id : parameters.exclude_objects) {
- exclude[object_index++] = object_id;
- }
-
- return exclude;
-}
-
-void PhysicsTestMotionParameters3D::set_exclude_objects(const TypedArray<uint64_t> &p_exclude) {
- parameters.exclude_objects.clear();
- for (int i = 0; i < p_exclude.size(); ++i) {
- ObjectID object_id = p_exclude[i];
- ERR_CONTINUE(object_id.is_null());
- parameters.exclude_objects.insert(object_id);
- }
-}
-
-void PhysicsTestMotionParameters3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_from"), &PhysicsTestMotionParameters3D::get_from);
- ClassDB::bind_method(D_METHOD("set_from", "from"), &PhysicsTestMotionParameters3D::set_from);
-
- ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsTestMotionParameters3D::get_motion);
- ClassDB::bind_method(D_METHOD("set_motion", "motion"), &PhysicsTestMotionParameters3D::set_motion);
-
- ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsTestMotionParameters3D::get_margin);
- ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsTestMotionParameters3D::set_margin);
-
- ClassDB::bind_method(D_METHOD("get_max_collisions"), &PhysicsTestMotionParameters3D::get_max_collisions);
- ClassDB::bind_method(D_METHOD("set_max_collisions", "max_collisions"), &PhysicsTestMotionParameters3D::set_max_collisions);
-
- ClassDB::bind_method(D_METHOD("is_collide_separation_ray_enabled"), &PhysicsTestMotionParameters3D::is_collide_separation_ray_enabled);
- ClassDB::bind_method(D_METHOD("set_collide_separation_ray_enabled", "enabled"), &PhysicsTestMotionParameters3D::set_collide_separation_ray_enabled);
-
- ClassDB::bind_method(D_METHOD("get_exclude_bodies"), &PhysicsTestMotionParameters3D::get_exclude_bodies);
- ClassDB::bind_method(D_METHOD("set_exclude_bodies", "exclude_list"), &PhysicsTestMotionParameters3D::set_exclude_bodies);
-
- ClassDB::bind_method(D_METHOD("get_exclude_objects"), &PhysicsTestMotionParameters3D::get_exclude_objects);
- ClassDB::bind_method(D_METHOD("set_exclude_objects", "exclude_list"), &PhysicsTestMotionParameters3D::set_exclude_objects);
-
- ClassDB::bind_method(D_METHOD("is_recovery_as_collision_enabled"), &PhysicsTestMotionParameters3D::is_recovery_as_collision_enabled);
- ClassDB::bind_method(D_METHOD("set_recovery_as_collision_enabled", "enabled"), &PhysicsTestMotionParameters3D::set_recovery_as_collision_enabled);
-
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "from"), "set_from", "get_from");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "motion"), "set_motion", "get_motion");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin"), "set_margin", "get_margin");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "max_collisions"), "set_max_collisions", "get_max_collisions");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_separation_ray"), "set_collide_separation_ray_enabled", "is_collide_separation_ray_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude_bodies", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude_bodies", "get_exclude_bodies");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude_objects"), "set_exclude_objects", "get_exclude_objects");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "recovery_as_collision"), "set_recovery_as_collision_enabled", "is_recovery_as_collision_enabled");
-}
-
-///////////////////////////////
-
-Vector3 PhysicsTestMotionResult3D::get_travel() const {
- return result.travel;
-}
-
-Vector3 PhysicsTestMotionResult3D::get_remainder() const {
- return result.remainder;
-}
-
-real_t PhysicsTestMotionResult3D::get_collision_safe_fraction() const {
- return result.collision_safe_fraction;
-}
-
-real_t PhysicsTestMotionResult3D::get_collision_unsafe_fraction() const {
- return result.collision_unsafe_fraction;
-}
-
-int PhysicsTestMotionResult3D::get_collision_count() const {
- return result.collision_count;
-}
-
-Vector3 PhysicsTestMotionResult3D::get_collision_point(int p_collision_index) const {
- ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, Vector3());
- return result.collisions[p_collision_index].position;
-}
-
-Vector3 PhysicsTestMotionResult3D::get_collision_normal(int p_collision_index) const {
- ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, Vector3());
- return result.collisions[p_collision_index].normal;
-}
-
-Vector3 PhysicsTestMotionResult3D::get_collider_velocity(int p_collision_index) const {
- ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, Vector3());
- return result.collisions[p_collision_index].collider_velocity;
-}
-
-ObjectID PhysicsTestMotionResult3D::get_collider_id(int p_collision_index) const {
- ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, ObjectID());
- return result.collisions[p_collision_index].collider_id;
-}
-
-RID PhysicsTestMotionResult3D::get_collider_rid(int p_collision_index) const {
- ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, RID());
- return result.collisions[p_collision_index].collider;
-}
-
-Object *PhysicsTestMotionResult3D::get_collider(int p_collision_index) const {
- ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, nullptr);
- return ObjectDB::get_instance(result.collisions[p_collision_index].collider_id);
-}
-
-int PhysicsTestMotionResult3D::get_collider_shape(int p_collision_index) const {
- ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, 0);
- return result.collisions[p_collision_index].collider_shape;
-}
-
-int PhysicsTestMotionResult3D::get_collision_local_shape(int p_collision_index) const {
- ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, 0);
- return result.collisions[p_collision_index].local_shape;
-}
-
-real_t PhysicsTestMotionResult3D::get_collision_depth(int p_collision_index) const {
- ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, 0.0);
- return result.collisions[p_collision_index].depth;
-}
-
-void PhysicsTestMotionResult3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_travel"), &PhysicsTestMotionResult3D::get_travel);
- ClassDB::bind_method(D_METHOD("get_remainder"), &PhysicsTestMotionResult3D::get_remainder);
- ClassDB::bind_method(D_METHOD("get_collision_safe_fraction"), &PhysicsTestMotionResult3D::get_collision_safe_fraction);
- ClassDB::bind_method(D_METHOD("get_collision_unsafe_fraction"), &PhysicsTestMotionResult3D::get_collision_unsafe_fraction);
- ClassDB::bind_method(D_METHOD("get_collision_count"), &PhysicsTestMotionResult3D::get_collision_count);
- ClassDB::bind_method(D_METHOD("get_collision_point", "collision_index"), &PhysicsTestMotionResult3D::get_collision_point, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_collision_normal", "collision_index"), &PhysicsTestMotionResult3D::get_collision_normal, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_collider_velocity", "collision_index"), &PhysicsTestMotionResult3D::get_collider_velocity, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_collider_id", "collision_index"), &PhysicsTestMotionResult3D::get_collider_id, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_collider_rid", "collision_index"), &PhysicsTestMotionResult3D::get_collider_rid, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_collider", "collision_index"), &PhysicsTestMotionResult3D::get_collider, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_collider_shape", "collision_index"), &PhysicsTestMotionResult3D::get_collider_shape, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_collision_local_shape", "collision_index"), &PhysicsTestMotionResult3D::get_collision_local_shape, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_collision_depth", "collision_index"), &PhysicsTestMotionResult3D::get_collision_depth, DEFVAL(0));
-}
-
-///////////////////////////////////////
-
bool PhysicsServer3D::_body_test_motion(RID p_body, RequiredParam<PhysicsTestMotionParameters3D> rp_parameters, const Ref<PhysicsTestMotionResult3D> &p_result) {
EXTRACT_PARAM_OR_FAIL_V(p_parameters, rp_parameters, false);
- MotionResult *result_ptr = nullptr;
+ PS3DT::MotionResult *result_ptr = nullptr;
if (p_result.is_valid()) {
result_ptr = p_result->get_result_ptr();
}
@@ -668,27 +51,27 @@ bool PhysicsServer3D::_body_test_motion(RID p_body, RequiredParam<PhysicsTestMot
return body_test_motion(p_body, p_parameters->get_parameters(), result_ptr);
}
-RID PhysicsServer3D::shape_create(ShapeType p_shape) {
+RID PhysicsServer3D::shape_create(PS3DE::ShapeType p_shape) {
switch (p_shape) {
- case SHAPE_WORLD_BOUNDARY:
+ case PS3DE::SHAPE_WORLD_BOUNDARY:
return world_boundary_shape_create();
- case SHAPE_SEPARATION_RAY:
+ case PS3DE::SHAPE_SEPARATION_RAY:
return separation_ray_shape_create();
- case SHAPE_SPHERE:
+ case PS3DE::SHAPE_SPHERE:
return sphere_shape_create();
- case SHAPE_BOX:
+ case PS3DE::SHAPE_BOX:
return box_shape_create();
- case SHAPE_CAPSULE:
+ case PS3DE::SHAPE_CAPSULE:
return capsule_shape_create();
- case SHAPE_CYLINDER:
+ case PS3DE::SHAPE_CYLINDER:
return cylinder_shape_create();
- case SHAPE_CONVEX_POLYGON:
+ case PS3DE::SHAPE_CONVEX_POLYGON:
return convex_polygon_shape_create();
- case SHAPE_CONCAVE_POLYGON:
+ case PS3DE::SHAPE_CONCAVE_POLYGON:
return concave_polygon_shape_create();
- case SHAPE_HEIGHTMAP:
+ case PS3DE::SHAPE_HEIGHTMAP:
return heightmap_shape_create();
- case SHAPE_CUSTOM:
+ case PS3DE::SHAPE_CUSTOM:
return custom_shape_create();
default:
return RID();
@@ -914,12 +297,12 @@ void PhysicsServer3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("joint_create"), &PhysicsServer3D::joint_create);
ClassDB::bind_method(D_METHOD("joint_clear", "joint"), &PhysicsServer3D::joint_clear);
- BIND_ENUM_CONSTANT(JOINT_TYPE_PIN);
- BIND_ENUM_CONSTANT(JOINT_TYPE_HINGE);
- BIND_ENUM_CONSTANT(JOINT_TYPE_SLIDER);
- BIND_ENUM_CONSTANT(JOINT_TYPE_CONE_TWIST);
- BIND_ENUM_CONSTANT(JOINT_TYPE_6DOF);
- BIND_ENUM_CONSTANT(JOINT_TYPE_MAX);
+ BIND_ENUM_CONSTANT(PS3DE::JOINT_TYPE_PIN);
+ BIND_ENUM_CONSTANT(PS3DE::JOINT_TYPE_HINGE);
+ BIND_ENUM_CONSTANT(PS3DE::JOINT_TYPE_SLIDER);
+ BIND_ENUM_CONSTANT(PS3DE::JOINT_TYPE_CONE_TWIST);
+ BIND_ENUM_CONSTANT(PS3DE::JOINT_TYPE_6DOF);
+ BIND_ENUM_CONSTANT(PS3DE::JOINT_TYPE_MAX);
ClassDB::bind_method(D_METHOD("joint_make_pin", "joint", "body_A", "local_A", "body_B", "local_B"), &PhysicsServer3D::joint_make_pin);
ClassDB::bind_method(D_METHOD("pin_joint_set_param", "joint", "param", "value"), &PhysicsServer3D::pin_joint_set_param);
@@ -931,21 +314,21 @@ void PhysicsServer3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("pin_joint_set_local_b", "joint", "local_B"), &PhysicsServer3D::pin_joint_set_local_b);
ClassDB::bind_method(D_METHOD("pin_joint_get_local_b", "joint"), &PhysicsServer3D::pin_joint_get_local_b);
- BIND_ENUM_CONSTANT(PIN_JOINT_BIAS);
- BIND_ENUM_CONSTANT(PIN_JOINT_DAMPING);
- BIND_ENUM_CONSTANT(PIN_JOINT_IMPULSE_CLAMP);
+ BIND_ENUM_CONSTANT(PS3DE::PIN_JOINT_BIAS);
+ BIND_ENUM_CONSTANT(PS3DE::PIN_JOINT_DAMPING);
+ BIND_ENUM_CONSTANT(PS3DE::PIN_JOINT_IMPULSE_CLAMP);
- BIND_ENUM_CONSTANT(HINGE_JOINT_BIAS);
- BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_UPPER);
- BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_LOWER);
- BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_BIAS);
- BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_SOFTNESS);
- BIND_ENUM_CONSTANT(HINGE_JOINT_LIMIT_RELAXATION);
- BIND_ENUM_CONSTANT(HINGE_JOINT_MOTOR_TARGET_VELOCITY);
- BIND_ENUM_CONSTANT(HINGE_JOINT_MOTOR_MAX_IMPULSE);
+ BIND_ENUM_CONSTANT(PS3DE::HINGE_JOINT_BIAS);
+ BIND_ENUM_CONSTANT(PS3DE::HINGE_JOINT_LIMIT_UPPER);
+ BIND_ENUM_CONSTANT(PS3DE::HINGE_JOINT_LIMIT_LOWER);
+ BIND_ENUM_CONSTANT(PS3DE::HINGE_JOINT_LIMIT_BIAS);
+ BIND_ENUM_CONSTANT(PS3DE::HINGE_JOINT_LIMIT_SOFTNESS);
+ BIND_ENUM_CONSTANT(PS3DE::HINGE_JOINT_LIMIT_RELAXATION);
+ BIND_ENUM_CONSTANT(PS3DE::HINGE_JOINT_MOTOR_TARGET_VELOCITY);
+ BIND_ENUM_CONSTANT(PS3DE::HINGE_JOINT_MOTOR_MAX_IMPULSE);
- BIND_ENUM_CONSTANT(HINGE_JOINT_FLAG_USE_LIMIT);
- BIND_ENUM_CONSTANT(HINGE_JOINT_FLAG_ENABLE_MOTOR);
+ BIND_ENUM_CONSTANT(PS3DE::HINGE_JOINT_FLAG_USE_LIMIT);
+ BIND_ENUM_CONSTANT(PS3DE::HINGE_JOINT_FLAG_ENABLE_MOTOR);
ClassDB::bind_method(D_METHOD("joint_make_hinge", "joint", "body_A", "hinge_A", "body_B", "hinge_B"), &PhysicsServer3D::joint_make_hinge);
@@ -960,75 +343,75 @@ void PhysicsServer3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("slider_joint_set_param", "joint", "param", "value"), &PhysicsServer3D::slider_joint_set_param);
ClassDB::bind_method(D_METHOD("slider_joint_get_param", "joint", "param"), &PhysicsServer3D::slider_joint_get_param);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_UPPER);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_LOWER);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_DAMPING);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_MOTION_SOFTNESS);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_MOTION_RESTITUTION);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_MOTION_DAMPING);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING);
-
- BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_UPPER);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_LOWER);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_LIMIT_DAMPING);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_MOTION_DAMPING);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING);
- BIND_ENUM_CONSTANT(SLIDER_JOINT_MAX);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_LINEAR_LIMIT_UPPER);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_LINEAR_LIMIT_LOWER);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_LINEAR_LIMIT_DAMPING);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_LINEAR_MOTION_DAMPING);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING);
+
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_UPPER);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_LOWER);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_ANGULAR_MOTION_DAMPING);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING);
+ BIND_ENUM_CONSTANT(PS3DE::SLIDER_JOINT_MAX);
ClassDB::bind_method(D_METHOD("joint_make_cone_twist", "joint", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer3D::joint_make_cone_twist);
ClassDB::bind_method(D_METHOD("cone_twist_joint_set_param", "joint", "param", "value"), &PhysicsServer3D::cone_twist_joint_set_param);
ClassDB::bind_method(D_METHOD("cone_twist_joint_get_param", "joint", "param"), &PhysicsServer3D::cone_twist_joint_get_param);
- BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_SWING_SPAN);
- BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_TWIST_SPAN);
- BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_BIAS);
- BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_SOFTNESS);
- BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_RELAXATION);
-
- BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_LOWER_LIMIT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_UPPER_LIMIT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_RESTITUTION);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_DAMPING);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_SPRING_STIFFNESS);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_SPRING_DAMPING);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_LOWER_LIMIT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_UPPER_LIMIT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_DAMPING);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_RESTITUTION);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_FORCE_LIMIT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_ERP);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_SPRING_DAMPING);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_MAX);
-
- BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_MOTOR);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR);
- BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_MAX);
+ BIND_ENUM_CONSTANT(PS3DE::CONE_TWIST_JOINT_SWING_SPAN);
+ BIND_ENUM_CONSTANT(PS3DE::CONE_TWIST_JOINT_TWIST_SPAN);
+ BIND_ENUM_CONSTANT(PS3DE::CONE_TWIST_JOINT_BIAS);
+ BIND_ENUM_CONSTANT(PS3DE::CONE_TWIST_JOINT_SOFTNESS);
+ BIND_ENUM_CONSTANT(PS3DE::CONE_TWIST_JOINT_RELAXATION);
+
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_LINEAR_LOWER_LIMIT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_LINEAR_UPPER_LIMIT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_LINEAR_RESTITUTION);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_LINEAR_DAMPING);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_LINEAR_SPRING_DAMPING);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_LOWER_LIMIT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_UPPER_LIMIT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_DAMPING);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_RESTITUTION);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_FORCE_LIMIT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_ERP);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_SPRING_DAMPING);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_MAX);
+
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_FLAG_ENABLE_MOTOR);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR);
+ BIND_ENUM_CONSTANT(PS3DE::G6DOF_JOINT_FLAG_MAX);
ClassDB::bind_method(D_METHOD("joint_get_type", "joint"), &PhysicsServer3D::joint_get_type);
@@ -1055,87 +438,87 @@ void PhysicsServer3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer3D::get_process_info);
- BIND_ENUM_CONSTANT(SHAPE_WORLD_BOUNDARY);
- BIND_ENUM_CONSTANT(SHAPE_SEPARATION_RAY);
- BIND_ENUM_CONSTANT(SHAPE_SPHERE);
- BIND_ENUM_CONSTANT(SHAPE_BOX);
- BIND_ENUM_CONSTANT(SHAPE_CAPSULE);
- BIND_ENUM_CONSTANT(SHAPE_CYLINDER);
- BIND_ENUM_CONSTANT(SHAPE_CONVEX_POLYGON);
- BIND_ENUM_CONSTANT(SHAPE_CONCAVE_POLYGON);
- BIND_ENUM_CONSTANT(SHAPE_HEIGHTMAP);
- BIND_ENUM_CONSTANT(SHAPE_SOFT_BODY);
- BIND_ENUM_CONSTANT(SHAPE_CUSTOM);
-
- BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_OVERRIDE_MODE);
- BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY);
- BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_VECTOR);
- BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_IS_POINT);
- BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE);
- BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE);
- BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP);
- BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE);
- BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP);
- BIND_ENUM_CONSTANT(AREA_PARAM_PRIORITY);
- BIND_ENUM_CONSTANT(AREA_PARAM_WIND_FORCE_MAGNITUDE);
- BIND_ENUM_CONSTANT(AREA_PARAM_WIND_SOURCE);
- BIND_ENUM_CONSTANT(AREA_PARAM_WIND_DIRECTION);
- BIND_ENUM_CONSTANT(AREA_PARAM_WIND_ATTENUATION_FACTOR);
-
- BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_DISABLED);
- BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE);
- BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_COMBINE_REPLACE);
- BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE);
- BIND_ENUM_CONSTANT(AREA_SPACE_OVERRIDE_REPLACE_COMBINE);
-
- BIND_ENUM_CONSTANT(BODY_MODE_STATIC);
- BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC);
- BIND_ENUM_CONSTANT(BODY_MODE_RIGID);
- BIND_ENUM_CONSTANT(BODY_MODE_RIGID_LINEAR);
-
- BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE);
- BIND_ENUM_CONSTANT(BODY_PARAM_FRICTION);
- BIND_ENUM_CONSTANT(BODY_PARAM_MASS);
- BIND_ENUM_CONSTANT(BODY_PARAM_INERTIA);
- BIND_ENUM_CONSTANT(BODY_PARAM_CENTER_OF_MASS);
- BIND_ENUM_CONSTANT(BODY_PARAM_GRAVITY_SCALE);
- BIND_ENUM_CONSTANT(BODY_PARAM_LINEAR_DAMP_MODE);
- BIND_ENUM_CONSTANT(BODY_PARAM_ANGULAR_DAMP_MODE);
- BIND_ENUM_CONSTANT(BODY_PARAM_LINEAR_DAMP);
- BIND_ENUM_CONSTANT(BODY_PARAM_ANGULAR_DAMP);
- BIND_ENUM_CONSTANT(BODY_PARAM_MAX);
-
- BIND_ENUM_CONSTANT(BODY_DAMP_MODE_COMBINE);
- BIND_ENUM_CONSTANT(BODY_DAMP_MODE_REPLACE);
-
- BIND_ENUM_CONSTANT(BODY_STATE_TRANSFORM);
- BIND_ENUM_CONSTANT(BODY_STATE_LINEAR_VELOCITY);
- BIND_ENUM_CONSTANT(BODY_STATE_ANGULAR_VELOCITY);
- BIND_ENUM_CONSTANT(BODY_STATE_SLEEPING);
- BIND_ENUM_CONSTANT(BODY_STATE_CAN_SLEEP);
-
- BIND_ENUM_CONSTANT(AREA_BODY_ADDED);
- BIND_ENUM_CONSTANT(AREA_BODY_REMOVED);
-
- BIND_ENUM_CONSTANT(INFO_ACTIVE_OBJECTS);
- BIND_ENUM_CONSTANT(INFO_COLLISION_PAIRS);
- BIND_ENUM_CONSTANT(INFO_ISLAND_COUNT);
-
- BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS);
- BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_MAX_SEPARATION);
- BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION);
- BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_DEFAULT_BIAS);
- BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD);
- BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD);
- BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_TIME_TO_SLEEP);
- BIND_ENUM_CONSTANT(SPACE_PARAM_SOLVER_ITERATIONS);
-
- BIND_ENUM_CONSTANT(BODY_AXIS_LINEAR_X);
- BIND_ENUM_CONSTANT(BODY_AXIS_LINEAR_Y);
- BIND_ENUM_CONSTANT(BODY_AXIS_LINEAR_Z);
- BIND_ENUM_CONSTANT(BODY_AXIS_ANGULAR_X);
- BIND_ENUM_CONSTANT(BODY_AXIS_ANGULAR_Y);
- BIND_ENUM_CONSTANT(BODY_AXIS_ANGULAR_Z);
+ BIND_ENUM_CONSTANT(PS3DE::SHAPE_WORLD_BOUNDARY);
+ BIND_ENUM_CONSTANT(PS3DE::SHAPE_SEPARATION_RAY);
+ BIND_ENUM_CONSTANT(PS3DE::SHAPE_SPHERE);
+ BIND_ENUM_CONSTANT(PS3DE::SHAPE_BOX);
+ BIND_ENUM_CONSTANT(PS3DE::SHAPE_CAPSULE);
+ BIND_ENUM_CONSTANT(PS3DE::SHAPE_CYLINDER);
+ BIND_ENUM_CONSTANT(PS3DE::SHAPE_CONVEX_POLYGON);
+ BIND_ENUM_CONSTANT(PS3DE::SHAPE_CONCAVE_POLYGON);
+ BIND_ENUM_CONSTANT(PS3DE::SHAPE_HEIGHTMAP);
+ BIND_ENUM_CONSTANT(PS3DE::SHAPE_SOFT_BODY);
+ BIND_ENUM_CONSTANT(PS3DE::SHAPE_CUSTOM);
+
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_GRAVITY_OVERRIDE_MODE);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_GRAVITY);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_GRAVITY_VECTOR);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_GRAVITY_IS_POINT);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_LINEAR_DAMP);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_ANGULAR_DAMP);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_PRIORITY);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_WIND_FORCE_MAGNITUDE);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_WIND_SOURCE);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_WIND_DIRECTION);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_PARAM_WIND_ATTENUATION_FACTOR);
+
+ BIND_ENUM_CONSTANT(PS3DE::AREA_SPACE_OVERRIDE_DISABLED);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_SPACE_OVERRIDE_COMBINE);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_SPACE_OVERRIDE_COMBINE_REPLACE);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_SPACE_OVERRIDE_REPLACE);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_SPACE_OVERRIDE_REPLACE_COMBINE);
+
+ BIND_ENUM_CONSTANT(PS3DE::BODY_MODE_STATIC);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_MODE_KINEMATIC);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_MODE_RIGID);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_MODE_RIGID_LINEAR);
+
+ BIND_ENUM_CONSTANT(PS3DE::BODY_PARAM_BOUNCE);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_PARAM_FRICTION);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_PARAM_MASS);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_PARAM_INERTIA);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_PARAM_CENTER_OF_MASS);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_PARAM_GRAVITY_SCALE);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_PARAM_LINEAR_DAMP_MODE);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_PARAM_ANGULAR_DAMP_MODE);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_PARAM_LINEAR_DAMP);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_PARAM_ANGULAR_DAMP);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_PARAM_MAX);
+
+ BIND_ENUM_CONSTANT(PS3DE::BODY_DAMP_MODE_COMBINE);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_DAMP_MODE_REPLACE);
+
+ BIND_ENUM_CONSTANT(PS3DE::BODY_STATE_TRANSFORM);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_STATE_LINEAR_VELOCITY);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_STATE_ANGULAR_VELOCITY);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_STATE_SLEEPING);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_STATE_CAN_SLEEP);
+
+ BIND_ENUM_CONSTANT(PS3DE::AREA_BODY_ADDED);
+ BIND_ENUM_CONSTANT(PS3DE::AREA_BODY_REMOVED);
+
+ BIND_ENUM_CONSTANT(PS3DE::INFO_ACTIVE_OBJECTS);
+ BIND_ENUM_CONSTANT(PS3DE::INFO_COLLISION_PAIRS);
+ BIND_ENUM_CONSTANT(PS3DE::INFO_ISLAND_COUNT);
+
+ BIND_ENUM_CONSTANT(PS3DE::SPACE_PARAM_CONTACT_RECYCLE_RADIUS);
+ BIND_ENUM_CONSTANT(PS3DE::SPACE_PARAM_CONTACT_MAX_SEPARATION);
+ BIND_ENUM_CONSTANT(PS3DE::SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION);
+ BIND_ENUM_CONSTANT(PS3DE::SPACE_PARAM_CONTACT_DEFAULT_BIAS);
+ BIND_ENUM_CONSTANT(PS3DE::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD);
+ BIND_ENUM_CONSTANT(PS3DE::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD);
+ BIND_ENUM_CONSTANT(PS3DE::SPACE_PARAM_BODY_TIME_TO_SLEEP);
+ BIND_ENUM_CONSTANT(PS3DE::SPACE_PARAM_SOLVER_ITERATIONS);
+
+ BIND_ENUM_CONSTANT(PS3DE::BODY_AXIS_LINEAR_X);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_AXIS_LINEAR_Y);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_AXIS_LINEAR_Z);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_AXIS_ANGULAR_X);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_AXIS_ANGULAR_Y);
+ BIND_ENUM_CONSTANT(PS3DE::BODY_AXIS_ANGULAR_Z);
#endif
}
diff --git a/servers/physics_3d/physics_server_3d.h b/servers/physics_3d/physics_server_3d.h
index 89cafbb8d7a..430764bd2e0 100644
--- a/servers/physics_3d/physics_server_3d.h
+++ b/servers/physics_3d/physics_server_3d.h
@@ -30,205 +30,20 @@
#pragma once
-#include "core/io/resource.h"
-#include "core/object/gdvirtual.gen.h"
-
-constexpr int MAX_CONTACTS_REPORTED_3D_MAX = 4096;
+#include "servers/physics_3d/direct_states/physics_direct_body_state_3d.h"
+#include "servers/physics_3d/direct_states/physics_direct_space_state_3d.h"
+#include "servers/physics_3d/physics_server_3d_enums.h"
+#include "servers/physics_3d/physics_server_3d_rendering_server_handler.h"
+#include "servers/physics_3d/physics_server_3d_types.h"
+#include "servers/physics_3d/queries/physics_testmotion_query_parameters_3d.h"
+#include "servers/physics_3d/queries/physics_testmotion_query_result_3d.h"
class PhysicsDirectSpaceState3D;
template <typename T>
class TypedArray;
-class PhysicsDirectBodyState3D : public Object {
- GDCLASS(PhysicsDirectBodyState3D, Object);
-
-protected:
- static void _bind_methods();
-
-public:
- virtual Vector3 get_total_gravity() const = 0;
- virtual real_t get_total_angular_damp() const = 0;
- virtual real_t get_total_linear_damp() const = 0;
-
- virtual Vector3 get_center_of_mass() const = 0;
- virtual Vector3 get_center_of_mass_local() const = 0;
- virtual Basis get_principal_inertia_axes() const = 0;
- virtual real_t get_inverse_mass() const = 0; // get the mass
- virtual Vector3 get_inverse_inertia() const = 0; // get density of this body space
- virtual Basis get_inverse_inertia_tensor() const = 0; // get density of this body space
-
- virtual void set_linear_velocity(const Vector3 &p_velocity) = 0;
- virtual Vector3 get_linear_velocity() const = 0;
-
- virtual void set_angular_velocity(const Vector3 &p_velocity) = 0;
- virtual Vector3 get_angular_velocity() const = 0;
-
- virtual void set_transform(const Transform3D &p_transform) = 0;
- virtual Transform3D get_transform() const = 0;
-
- virtual Vector3 get_velocity_at_local_position(const Vector3 &p_position) const = 0;
-
- virtual void apply_central_impulse(const Vector3 &p_impulse) = 0;
- virtual void apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position = Vector3()) = 0;
- virtual void apply_torque_impulse(const Vector3 &p_impulse) = 0;
-
- virtual void apply_central_force(const Vector3 &p_force) = 0;
- virtual void apply_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0;
- virtual void apply_torque(const Vector3 &p_torque) = 0;
-
- virtual void add_constant_central_force(const Vector3 &p_force) = 0;
- virtual void add_constant_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0;
- virtual void add_constant_torque(const Vector3 &p_torque) = 0;
-
- virtual void set_constant_force(const Vector3 &p_force) = 0;
- virtual Vector3 get_constant_force() const = 0;
-
- virtual void set_constant_torque(const Vector3 &p_torque) = 0;
- virtual Vector3 get_constant_torque() const = 0;
-
- virtual void set_sleep_state(bool p_sleep) = 0;
- virtual bool is_sleeping() const = 0;
-
- virtual void set_collision_layer(uint32_t p_layer) = 0;
- virtual uint32_t get_collision_layer() const = 0;
-
- virtual void set_collision_mask(uint32_t p_mask) = 0;
- virtual uint32_t get_collision_mask() const = 0;
-
- virtual int get_contact_count() const = 0;
-
- virtual Vector3 get_contact_local_position(int p_contact_idx) const = 0;
- virtual Vector3 get_contact_local_normal(int p_contact_idx) const = 0;
- virtual Vector3 get_contact_impulse(int p_contact_idx) const = 0;
- virtual int get_contact_local_shape(int p_contact_idx) const = 0;
- virtual Vector3 get_contact_local_velocity_at_position(int p_contact_idx) const = 0;
-
- virtual RID get_contact_collider(int p_contact_idx) const = 0;
- virtual Vector3 get_contact_collider_position(int p_contact_idx) const = 0;
- virtual ObjectID get_contact_collider_id(int p_contact_idx) const = 0;
- virtual Object *get_contact_collider_object(int p_contact_idx) const;
- virtual int get_contact_collider_shape(int p_contact_idx) const = 0;
- virtual Vector3 get_contact_collider_velocity_at_position(int p_contact_idx) const = 0;
-
- virtual real_t get_step() const = 0;
- virtual void integrate_forces();
-
- virtual RequiredResult<PhysicsDirectSpaceState3D> get_space_state() = 0;
-
- PhysicsDirectBodyState3D();
-};
-
-class PhysicsRayQueryParameters3D;
-class PhysicsPointQueryParameters3D;
-class PhysicsShapeQueryParameters3D;
-
-class PhysicsDirectSpaceState3D : public Object {
- GDCLASS(PhysicsDirectSpaceState3D, Object);
-
-private:
- Dictionary _intersect_ray(RequiredParam<PhysicsRayQueryParameters3D> rp_ray_query);
- TypedArray<Dictionary> _intersect_point(RequiredParam<PhysicsPointQueryParameters3D> rp_point_query, int p_max_results = 32);
- TypedArray<Dictionary> _intersect_shape(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query, int p_max_results = 32);
- Vector<real_t> _cast_motion(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query);
- TypedArray<Vector3> _collide_shape(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query, int p_max_results = 32);
- Dictionary _get_rest_info(RequiredParam<PhysicsShapeQueryParameters3D> rp_shape_query);
-
-protected:
- static void _bind_methods();
-
-public:
- struct RayParameters {
- Vector3 from;
- Vector3 to;
- HashSet<RID> exclude;
- uint32_t collision_mask = UINT32_MAX;
-
- bool collide_with_bodies = true;
- bool collide_with_areas = false;
-
- bool hit_from_inside = false;
- bool hit_back_faces = true;
-
- bool pick_ray = false;
- };
-
- struct RayResult {
- Vector3 position;
- Vector3 normal;
- RID rid;
- ObjectID collider_id;
- Object *collider = nullptr;
- int shape = 0;
- int face_index = -1;
- };
-
- virtual bool intersect_ray(const RayParameters &p_parameters, RayResult &r_result) = 0;
-
- struct ShapeResult {
- RID rid;
- ObjectID collider_id;
- Object *collider = nullptr;
- int shape = 0;
- };
-
- struct PointParameters {
- Vector3 position;
- HashSet<RID> exclude;
- uint32_t collision_mask = UINT32_MAX;
-
- bool collide_with_bodies = true;
- bool collide_with_areas = false;
- };
-
- virtual int intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) = 0;
-
- struct ShapeParameters {
- RID shape_rid;
- Transform3D transform;
- Vector3 motion;
- real_t margin = 0.0;
- HashSet<RID> exclude;
- uint32_t collision_mask = UINT32_MAX;
-
- bool collide_with_bodies = true;
- bool collide_with_areas = false;
- };
-
- struct ShapeRestInfo {
- Vector3 point;
- Vector3 normal;
- RID rid;
- ObjectID collider_id;
- int shape = 0;
- Vector3 linear_velocity; // Velocity at contact point.
- };
-
- virtual int intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) = 0;
- virtual bool cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, ShapeRestInfo *r_info = nullptr) = 0;
- virtual bool collide_shape(const ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) = 0;
- virtual bool rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) = 0;
-
- virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const = 0;
-
- PhysicsDirectSpaceState3D();
-};
-
-class PhysicsServer3DRenderingServerHandler : public Object {
- GDCLASS(PhysicsServer3DRenderingServerHandler, Object)
-protected:
- GDVIRTUAL2_REQUIRED(_set_vertex, int, const Vector3 &)
- GDVIRTUAL2_REQUIRED(_set_normal, int, const Vector3 &)
- GDVIRTUAL1_REQUIRED(_set_aabb, const AABB &)
-
- static void _bind_methods();
-
-public:
- virtual void set_vertex(int p_vertex_id, const Vector3 &p_vertex);
- virtual void set_normal(int p_vertex_id, const Vector3 &p_normal);
- virtual void set_aabb(const AABB &p_aabb);
-
- virtual ~PhysicsServer3DRenderingServerHandler() {}
-};
+template <typename T>
+class Ref;
class PhysicsTestMotionParameters3D;
class PhysicsTestMotionResult3D;
@@ -246,21 +61,7 @@ protected:
public:
static PhysicsServer3D *get_singleton();
- enum ShapeType {
- SHAPE_WORLD_BOUNDARY, ///< plane:"plane"
- SHAPE_SEPARATION_RAY, ///< float:"length"
- SHAPE_SPHERE, ///< float:"radius"
- SHAPE_BOX, ///< vec3:"extents"
- SHAPE_CAPSULE, ///< dict( float:"radius", float:"height"):capsule
- SHAPE_CYLINDER, ///< dict( float:"radius", float:"height"):cylinder
- SHAPE_CONVEX_POLYGON, ///< array of planes:"planes"
- SHAPE_CONCAVE_POLYGON, ///< vector3 array:"triangles" , or Dictionary with "indices" (int array) and "triangles" (Vector3 array)
- SHAPE_HEIGHTMAP, ///< dict( int:"width", int:"depth",float:"cell_size", float_array:"heights"
- SHAPE_SOFT_BODY, ///< Used internally, can't be created from the physics server.
- SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error
- };
-
- RID shape_create(ShapeType p_shape);
+ RID shape_create(PS3DE::ShapeType p_shape);
virtual RID world_boundary_shape_create() = 0;
virtual RID separation_ray_shape_create() = 0;
@@ -276,7 +77,7 @@ public:
virtual void shape_set_data(RID p_shape, const Variant &p_data) = 0;
virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias) = 0;
- virtual ShapeType shape_get_type(RID p_shape) const = 0;
+ virtual PS3DE::ShapeType shape_get_type(RID p_shape) const = 0;
virtual Variant shape_get_data(RID p_shape) const = 0;
virtual void shape_set_margin(RID p_shape, real_t p_margin) = 0;
@@ -290,19 +91,8 @@ public:
virtual void space_set_active(RID p_space, bool p_active) = 0;
virtual bool space_is_active(RID p_space) const = 0;
- enum SpaceParameter {
- SPACE_PARAM_CONTACT_RECYCLE_RADIUS,
- SPACE_PARAM_CONTACT_MAX_SEPARATION,
- SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION,
- SPACE_PARAM_CONTACT_DEFAULT_BIAS,
- SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD,
- SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD,
- SPACE_PARAM_BODY_TIME_TO_SLEEP,
- SPACE_PARAM_SOLVER_ITERATIONS,
- };
-
- virtual void space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) = 0;
- virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const = 0;
+ virtual void space_set_param(RID p_space, PS3DE::SpaceParameter p_param, real_t p_value) = 0;
+ virtual real_t space_get_param(RID p_space, PS3DE::SpaceParameter p_param) const = 0;
// this function only works on physics process, errors and returns null otherwise
virtual PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space) = 0;
@@ -317,36 +107,11 @@ public:
//missing attenuation? missing better override?
- enum AreaParameter {
- AREA_PARAM_GRAVITY_OVERRIDE_MODE,
- AREA_PARAM_GRAVITY,
- AREA_PARAM_GRAVITY_VECTOR,
- AREA_PARAM_GRAVITY_IS_POINT,
- AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE,
- AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE,
- AREA_PARAM_LINEAR_DAMP,
- AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE,
- AREA_PARAM_ANGULAR_DAMP,
- AREA_PARAM_PRIORITY,
- AREA_PARAM_WIND_FORCE_MAGNITUDE,
- AREA_PARAM_WIND_SOURCE,
- AREA_PARAM_WIND_DIRECTION,
- AREA_PARAM_WIND_ATTENUATION_FACTOR,
- };
-
virtual RID area_create() = 0;
virtual void area_set_space(RID p_area, RID p_space) = 0;
virtual RID area_get_space(RID p_area) const = 0;
- enum AreaSpaceOverrideMode {
- AREA_SPACE_OVERRIDE_DISABLED,
- AREA_SPACE_OVERRIDE_COMBINE,
- AREA_SPACE_OVERRIDE_COMBINE_REPLACE,
- AREA_SPACE_OVERRIDE_REPLACE,
- AREA_SPACE_OVERRIDE_REPLACE_COMBINE
- };
-
virtual void area_add_shape(RID p_area, RID p_shape, const Transform3D &p_transform = Transform3D(), bool p_disabled = false) = 0;
virtual void area_set_shape(RID p_area, int p_shape_idx, RID p_shape) = 0;
virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Transform3D &p_transform) = 0;
@@ -363,10 +128,10 @@ public:
virtual void area_attach_object_instance_id(RID p_area, ObjectID p_id) = 0;
virtual ObjectID area_get_object_instance_id(RID p_area) const = 0;
- virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) = 0;
+ virtual void area_set_param(RID p_area, PS3DE::AreaParameter p_param, const Variant &p_value) = 0;
virtual void area_set_transform(RID p_area, const Transform3D &p_transform) = 0;
- virtual Variant area_get_param(RID p_parea, AreaParameter p_param) const = 0;
+ virtual Variant area_get_param(RID p_parea, PS3DE::AreaParameter p_param) const = 0;
virtual Transform3D area_get_transform(RID p_area) const = 0;
virtual void area_set_collision_layer(RID p_area, uint32_t p_layer) = 0;
@@ -386,25 +151,13 @@ public:
//missing ccd?
- enum BodyMode {
- BODY_MODE_STATIC,
- BODY_MODE_KINEMATIC,
- BODY_MODE_RIGID,
- BODY_MODE_RIGID_LINEAR,
- };
-
- enum BodyDampMode {
- BODY_DAMP_MODE_COMBINE,
- BODY_DAMP_MODE_REPLACE,
- };
-
virtual RID body_create() = 0;
virtual void body_set_space(RID p_body, RID p_space) = 0;
virtual RID body_get_space(RID p_body) const = 0;
- virtual void body_set_mode(RID p_body, BodyMode p_mode) = 0;
- virtual BodyMode body_get_mode(RID p_body) const = 0;
+ virtual void body_set_mode(RID p_body, PS3DE::BodyMode p_mode) = 0;
+ virtual PS3DE::BodyMode body_get_mode(RID p_body) const = 0;
virtual void body_add_shape(RID p_body, RID p_shape, const Transform3D &p_transform = Transform3D(), bool p_disabled = false) = 0;
virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape) = 0;
@@ -438,36 +191,16 @@ public:
virtual uint32_t body_get_user_flags(RID p_body) const = 0;
// common body variables
- enum BodyParameter {
- BODY_PARAM_BOUNCE,
- BODY_PARAM_FRICTION,
- BODY_PARAM_MASS, ///< unused for static, always infinite
- BODY_PARAM_INERTIA,
- BODY_PARAM_CENTER_OF_MASS,
- BODY_PARAM_GRAVITY_SCALE,
- BODY_PARAM_LINEAR_DAMP_MODE,
- BODY_PARAM_ANGULAR_DAMP_MODE,
- BODY_PARAM_LINEAR_DAMP,
- BODY_PARAM_ANGULAR_DAMP,
- BODY_PARAM_MAX,
- };
- virtual void body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) = 0;
- virtual Variant body_get_param(RID p_body, BodyParameter p_param) const = 0;
+ virtual void body_set_param(RID p_body, PS3DE::BodyParameter p_param, const Variant &p_value) = 0;
+ virtual Variant body_get_param(RID p_body, PS3DE::BodyParameter p_param) const = 0;
virtual void body_reset_mass_properties(RID p_body) = 0;
//state
- enum BodyState {
- BODY_STATE_TRANSFORM,
- BODY_STATE_LINEAR_VELOCITY,
- BODY_STATE_ANGULAR_VELOCITY,
- BODY_STATE_SLEEPING,
- BODY_STATE_CAN_SLEEP
- };
- virtual void body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) = 0;
- virtual Variant body_get_state(RID p_body, BodyState p_state) const = 0;
+ virtual void body_set_state(RID p_body, PS3DE::BodyState p_state, const Variant &p_variant) = 0;
+ virtual Variant body_get_state(RID p_body, PS3DE::BodyState p_state) const = 0;
virtual void body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) = 0;
virtual void body_apply_impulse(RID p_body, const Vector3 &p_impulse, const Vector3 &p_position = Vector3()) = 0;
@@ -489,17 +222,8 @@ public:
virtual void body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) = 0;
- enum BodyAxis {
- BODY_AXIS_LINEAR_X = 1 << 0,
- BODY_AXIS_LINEAR_Y = 1 << 1,
- BODY_AXIS_LINEAR_Z = 1 << 2,
- BODY_AXIS_ANGULAR_X = 1 << 3,
- BODY_AXIS_ANGULAR_Y = 1 << 4,
- BODY_AXIS_ANGULAR_Z = 1 << 5
- };
-
- virtual void body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) = 0;
- virtual bool body_is_axis_locked(RID p_body, BodyAxis p_axis) const = 0;
+ virtual void body_set_axis_lock(RID p_body, PS3DE::BodyAxis p_axis, bool p_lock) = 0;
+ virtual bool body_is_axis_locked(RID p_body, PS3DE::BodyAxis p_axis) const = 0;
//fix
virtual void body_add_collision_exception(RID p_body, RID p_body_b) = 0;
@@ -524,53 +248,7 @@ public:
// this function only works on physics process, errors and returns null otherwise
virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) = 0;
- struct MotionParameters {
- Transform3D from;
- Vector3 motion;
- real_t margin = 0.001;
- int max_collisions = 1;
- bool collide_separation_ray = false;
- HashSet<RID> exclude_bodies;
- HashSet<ObjectID> exclude_objects;
- bool recovery_as_collision = false;
-
- MotionParameters() {}
-
- MotionParameters(const Transform3D &p_from, const Vector3 &p_motion, real_t p_margin = 0.001) :
- from(p_from),
- motion(p_motion),
- margin(p_margin) {}
- };
-
- struct MotionCollision {
- Vector3 position;
- Vector3 normal;
- Vector3 collider_velocity;
- Vector3 collider_angular_velocity;
- real_t depth = 0.0;
- int local_shape = 0;
- ObjectID collider_id;
- RID collider;
- int collider_shape = 0;
-
- real_t get_angle(Vector3 p_up_direction) const {
- return Math::acos(normal.dot(p_up_direction));
- }
- };
-
- struct MotionResult {
- Vector3 travel;
- Vector3 remainder;
- real_t collision_depth = 0.0;
- real_t collision_safe_fraction = 0.0;
- real_t collision_unsafe_fraction = 0.0;
-
- static const int MAX_COLLISIONS = 32;
- MotionCollision collisions[MAX_COLLISIONS];
- int collision_count = 0;
- };
-
- virtual bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) = 0;
+ virtual bool body_test_motion(RID p_body, const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult *r_result = nullptr) = 0;
/* SOFT BODY */
@@ -595,8 +273,8 @@ public:
virtual void soft_body_remove_collision_exception(RID p_body, RID p_body_b) = 0;
virtual void soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) = 0;
- virtual void soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) = 0;
- virtual Variant soft_body_get_state(RID p_body, BodyState p_state) const = 0;
+ virtual void soft_body_set_state(RID p_body, PS3DE::BodyState p_state, const Variant &p_variant) = 0;
+ virtual Variant soft_body_get_state(RID p_body, PS3DE::BodyState p_state) const = 0;
virtual void soft_body_set_transform(RID p_body, const Transform3D &p_transform) = 0;
@@ -637,21 +315,11 @@ public:
/* JOINT API */
- enum JointType {
- JOINT_TYPE_PIN,
- JOINT_TYPE_HINGE,
- JOINT_TYPE_SLIDER,
- JOINT_TYPE_CONE_TWIST,
- JOINT_TYPE_6DOF,
- JOINT_TYPE_MAX,
-
- };
-
virtual RID joint_create() = 0;
virtual void joint_clear(RID p_joint) = 0;
- virtual JointType joint_get_type(RID p_joint) const = 0;
+ virtual PS3DE::JointType joint_get_type(RID p_joint) const = 0;
virtual void joint_set_solver_priority(RID p_joint, int p_priority) = 0;
virtual int joint_get_solver_priority(RID p_joint) const = 0;
@@ -661,14 +329,8 @@ public:
virtual void joint_make_pin(RID p_joint, RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) = 0;
- enum PinJointParam {
- PIN_JOINT_BIAS,
- PIN_JOINT_DAMPING,
- PIN_JOINT_IMPULSE_CLAMP
- };
-
- virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) = 0;
- virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const = 0;
+ virtual void pin_joint_set_param(RID p_joint, PS3DE::PinJointParam p_param, real_t p_value) = 0;
+ virtual real_t pin_joint_get_param(RID p_joint, PS3DE::PinJointParam p_param) const = 0;
virtual void pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) = 0;
virtual Vector3 pin_joint_get_local_a(RID p_joint) const = 0;
@@ -676,136 +338,38 @@ public:
virtual void pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) = 0;
virtual Vector3 pin_joint_get_local_b(RID p_joint) const = 0;
- enum HingeJointParam {
- HINGE_JOINT_BIAS,
- HINGE_JOINT_LIMIT_UPPER,
- HINGE_JOINT_LIMIT_LOWER,
- HINGE_JOINT_LIMIT_BIAS,
- HINGE_JOINT_LIMIT_SOFTNESS,
- HINGE_JOINT_LIMIT_RELAXATION,
- HINGE_JOINT_MOTOR_TARGET_VELOCITY,
- HINGE_JOINT_MOTOR_MAX_IMPULSE,
- HINGE_JOINT_MAX
- };
-
- enum HingeJointFlag {
- HINGE_JOINT_FLAG_USE_LIMIT,
- HINGE_JOINT_FLAG_ENABLE_MOTOR,
- HINGE_JOINT_FLAG_MAX
- };
-
virtual void joint_make_hinge(RID p_joint, RID p_body_A, const Transform3D &p_hinge_A, RID p_body_B, const Transform3D &p_hinge_B) = 0;
virtual void 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) = 0;
- virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) = 0;
- virtual real_t hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const = 0;
-
- virtual void hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_enabled) = 0;
- virtual bool hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const = 0;
-
- enum SliderJointParam {
- SLIDER_JOINT_LINEAR_LIMIT_UPPER,
- SLIDER_JOINT_LINEAR_LIMIT_LOWER,
- SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS,
- SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION,
- SLIDER_JOINT_LINEAR_LIMIT_DAMPING,
- SLIDER_JOINT_LINEAR_MOTION_SOFTNESS,
- SLIDER_JOINT_LINEAR_MOTION_RESTITUTION,
- SLIDER_JOINT_LINEAR_MOTION_DAMPING,
- SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS,
- SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION,
- SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING,
-
- SLIDER_JOINT_ANGULAR_LIMIT_UPPER,
- SLIDER_JOINT_ANGULAR_LIMIT_LOWER,
- SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS,
- SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION,
- SLIDER_JOINT_ANGULAR_LIMIT_DAMPING,
- SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS,
- SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION,
- SLIDER_JOINT_ANGULAR_MOTION_DAMPING,
- SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS,
- SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION,
- SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING,
- SLIDER_JOINT_MAX
+ virtual void hinge_joint_set_param(RID p_joint, PS3DE::HingeJointParam p_param, real_t p_value) = 0;
+ virtual real_t hinge_joint_get_param(RID p_joint, PS3DE::HingeJointParam p_param) const = 0;
- };
+ virtual void hinge_joint_set_flag(RID p_joint, PS3DE::HingeJointFlag p_flag, bool p_enabled) = 0;
+ virtual bool hinge_joint_get_flag(RID p_joint, PS3DE::HingeJointFlag p_flag) const = 0;
virtual void joint_make_slider(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) = 0; //reference frame is A
- virtual void slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) = 0;
- virtual real_t slider_joint_get_param(RID p_joint, SliderJointParam p_param) const = 0;
-
- enum ConeTwistJointParam {
- CONE_TWIST_JOINT_SWING_SPAN,
- CONE_TWIST_JOINT_TWIST_SPAN,
- CONE_TWIST_JOINT_BIAS,
- CONE_TWIST_JOINT_SOFTNESS,
- CONE_TWIST_JOINT_RELAXATION,
- CONE_TWIST_MAX
- };
+ virtual void slider_joint_set_param(RID p_joint, PS3DE::SliderJointParam p_param, real_t p_value) = 0;
+ virtual real_t slider_joint_get_param(RID p_joint, PS3DE::SliderJointParam p_param) const = 0;
virtual void joint_make_cone_twist(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) = 0; //reference frame is A
- virtual void cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) = 0;
- virtual real_t cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const = 0;
-
- enum G6DOFJointAxisParam {
- G6DOF_JOINT_LINEAR_LOWER_LIMIT,
- G6DOF_JOINT_LINEAR_UPPER_LIMIT,
- G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS,
- G6DOF_JOINT_LINEAR_RESTITUTION,
- G6DOF_JOINT_LINEAR_DAMPING,
- G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY,
- G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT,
- G6DOF_JOINT_LINEAR_SPRING_STIFFNESS,
- G6DOF_JOINT_LINEAR_SPRING_DAMPING,
- G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT,
- G6DOF_JOINT_ANGULAR_LOWER_LIMIT,
- G6DOF_JOINT_ANGULAR_UPPER_LIMIT,
- G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS,
- G6DOF_JOINT_ANGULAR_DAMPING,
- G6DOF_JOINT_ANGULAR_RESTITUTION,
- G6DOF_JOINT_ANGULAR_FORCE_LIMIT,
- G6DOF_JOINT_ANGULAR_ERP,
- G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY,
- G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT,
- G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS,
- G6DOF_JOINT_ANGULAR_SPRING_DAMPING,
- G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT,
- G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT,
- G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT,
- G6DOF_JOINT_MAX
- };
-
- enum G6DOFJointAxisFlag {
- G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT,
- G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT,
- G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING,
- G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING,
- G6DOF_JOINT_FLAG_ENABLE_MOTOR,
- G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR,
- G6DOF_JOINT_FLAG_MAX
- };
+ virtual void cone_twist_joint_set_param(RID p_joint, PS3DE::ConeTwistJointParam p_param, real_t p_value) = 0;
+ virtual real_t cone_twist_joint_get_param(RID p_joint, PS3DE::ConeTwistJointParam p_param) const = 0;
virtual void joint_make_generic_6dof(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) = 0; //reference frame is A
- virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param, real_t p_value) = 0;
- virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param) const = 0;
+ virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis, PS3DE::G6DOFJointAxisParam p_param, real_t p_value) = 0;
+ virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis, PS3DE::G6DOFJointAxisParam p_param) const = 0;
- virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag, bool p_enable) = 0;
- virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag) const = 0;
+ virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis, PS3DE::G6DOFJointAxisFlag p_flag, bool p_enable) = 0;
+ virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis, PS3DE::G6DOFJointAxisFlag p_flag) const = 0;
virtual void generic_6dof_joint_set_angular_target_rotation(RID p_joint, const Quaternion &p_target_rotation) = 0;
virtual Quaternion generic_6dof_joint_get_angular_target_rotation(RID p_joint) const = 0;
/* QUERY API */
- enum AreaBodyStatus {
- AREA_BODY_ADDED,
- AREA_BODY_REMOVED
- };
-
/* MISC */
virtual void free_rid(RID p_rid) = 0;
@@ -825,188 +389,12 @@ public:
virtual bool is_flushing_queries() const = 0;
- enum ProcessInfo {
- INFO_ACTIVE_OBJECTS,
- INFO_COLLISION_PAIRS,
- INFO_ISLAND_COUNT
- };
-
- virtual int get_process_info(ProcessInfo p_info) = 0;
+ virtual int get_process_info(PS3DE::ProcessInfo p_info) = 0;
PhysicsServer3D();
~PhysicsServer3D();
};
-class PhysicsRayQueryParameters3D : public RefCounted {
- GDCLASS(PhysicsRayQueryParameters3D, RefCounted);
-
- PhysicsDirectSpaceState3D::RayParameters parameters;
-
-protected:
- static void _bind_methods();
-
-public:
- static Ref<PhysicsRayQueryParameters3D> create(Vector3 p_from, Vector3 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude);
- const PhysicsDirectSpaceState3D::RayParameters &get_parameters() const { return parameters; }
-
- void set_from(const Vector3 &p_from) { parameters.from = p_from; }
- const Vector3 &get_from() const { return parameters.from; }
-
- void set_to(const Vector3 &p_to) { parameters.to = p_to; }
- const Vector3 &get_to() const { return parameters.to; }
-
- void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
- uint32_t get_collision_mask() const { return parameters.collision_mask; }
-
- void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
- bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
-
- void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
- bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
-
- void set_hit_from_inside(bool p_enable) { parameters.hit_from_inside = p_enable; }
- bool is_hit_from_inside_enabled() const { return parameters.hit_from_inside; }
-
- void set_hit_back_faces(bool p_enable) { parameters.hit_back_faces = p_enable; }
- bool is_hit_back_faces_enabled() const { return parameters.hit_back_faces; }
-
- void set_exclude(const TypedArray<RID> &p_exclude);
- TypedArray<RID> get_exclude() const;
-};
-
-class PhysicsPointQueryParameters3D : public RefCounted {
- GDCLASS(PhysicsPointQueryParameters3D, RefCounted);
-
- PhysicsDirectSpaceState3D::PointParameters parameters;
-
-protected:
- static void _bind_methods();
-
-public:
- const PhysicsDirectSpaceState3D::PointParameters &get_parameters() const { return parameters; }
-
- void set_position(const Vector3 &p_position) { parameters.position = p_position; }
- const Vector3 &get_position() const { return parameters.position; }
-
- void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
- uint32_t get_collision_mask() const { return parameters.collision_mask; }
-
- void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
- bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
-
- void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
- bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
-
- void set_exclude(const TypedArray<RID> &p_exclude);
- TypedArray<RID> get_exclude() const;
-};
-
-class PhysicsShapeQueryParameters3D : public RefCounted {
- GDCLASS(PhysicsShapeQueryParameters3D, RefCounted);
-
- PhysicsDirectSpaceState3D::ShapeParameters parameters;
-
- Ref<Resource> shape_ref;
-
-protected:
- static void _bind_methods();
-
-public:
- const PhysicsDirectSpaceState3D::ShapeParameters &get_parameters() const { return parameters; }
-
- void set_shape(const Ref<Resource> &p_shape_ref);
- Ref<Resource> get_shape() const { return shape_ref; }
-
- void set_shape_rid(const RID &p_shape);
- RID get_shape_rid() const { return parameters.shape_rid; }
-
- void set_transform(const Transform3D &p_transform) { parameters.transform = p_transform; }
- const Transform3D &get_transform() const { return parameters.transform; }
-
- void set_motion(const Vector3 &p_motion) { parameters.motion = p_motion; }
- const Vector3 &get_motion() const { return parameters.motion; }
-
- void set_margin(real_t p_margin) { parameters.margin = p_margin; }
- real_t get_margin() const { return parameters.margin; }
-
- void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
- uint32_t get_collision_mask() const { return parameters.collision_mask; }
-
- void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
- bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
-
- void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
- bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
-
- void set_exclude(const TypedArray<RID> &p_exclude);
- TypedArray<RID> get_exclude() const;
-};
-
-class PhysicsTestMotionParameters3D : public RefCounted {
- GDCLASS(PhysicsTestMotionParameters3D, RefCounted);
-
- PhysicsServer3D::MotionParameters parameters;
-
-protected:
- static void _bind_methods();
-
-public:
- const PhysicsServer3D::MotionParameters &get_parameters() const { return parameters; }
-
- const Transform3D &get_from() const { return parameters.from; }
- void set_from(const Transform3D &p_from) { parameters.from = p_from; }
-
- const Vector3 &get_motion() const { return parameters.motion; }
- void set_motion(const Vector3 &p_motion) { parameters.motion = p_motion; }
-
- real_t get_margin() const { return parameters.margin; }
- void set_margin(real_t p_margin) { parameters.margin = p_margin; }
-
- int get_max_collisions() const { return parameters.max_collisions; }
- void set_max_collisions(int p_max_collisions) { parameters.max_collisions = p_max_collisions; }
-
- bool is_collide_separation_ray_enabled() const { return parameters.collide_separation_ray; }
- void set_collide_separation_ray_enabled(bool p_enabled) { parameters.collide_separation_ray = p_enabled; }
-
- TypedArray<RID> get_exclude_bodies() const;
- void set_exclude_bodies(const TypedArray<RID> &p_exclude);
-
- TypedArray<uint64_t> get_exclude_objects() const;
- void set_exclude_objects(const TypedArray<uint64_t> &p_exclude);
-
- bool is_recovery_as_collision_enabled() const { return parameters.recovery_as_collision; }
- void set_recovery_as_collision_enabled(bool p_enabled) { parameters.recovery_as_collision = p_enabled; }
-};
-
-class PhysicsTestMotionResult3D : public RefCounted {
- GDCLASS(PhysicsTestMotionResult3D, RefCounted);
-
- PhysicsServer3D::MotionResult result;
-
-protected:
- static void _bind_methods();
-
-public:
- PhysicsServer3D::MotionResult *get_result_ptr() { return &result; }
-
- Vector3 get_travel() const;
- Vector3 get_remainder() const;
- real_t get_collision_safe_fraction() const;
- real_t get_collision_unsafe_fraction() const;
-
- int get_collision_count() const;
-
- Vector3 get_collision_point(int p_collision_index = 0) const;
- Vector3 get_collision_normal(int p_collision_index = 0) const;
- Vector3 get_collider_velocity(int p_collision_index = 0) const;
- ObjectID get_collider_id(int p_collision_index = 0) const;
- RID get_collider_rid(int p_collision_index = 0) const;
- Object *get_collider(int p_collision_index = 0) const;
- int get_collider_shape(int p_collision_index = 0) const;
- int get_collision_local_shape(int p_collision_index = 0) const;
- real_t get_collision_depth(int p_collision_index = 0) const;
-};
-
class PhysicsServer3DManager : public Object {
GDCLASS(PhysicsServer3DManager, Object);
@@ -1058,22 +446,22 @@ public:
~PhysicsServer3DManager();
};
-VARIANT_ENUM_CAST(PhysicsServer3D::ShapeType);
-VARIANT_ENUM_CAST(PhysicsServer3D::SpaceParameter);
-VARIANT_ENUM_CAST(PhysicsServer3D::AreaParameter);
-VARIANT_ENUM_CAST(PhysicsServer3D::AreaSpaceOverrideMode);
-VARIANT_ENUM_CAST(PhysicsServer3D::BodyMode);
-VARIANT_ENUM_CAST(PhysicsServer3D::BodyParameter);
-VARIANT_ENUM_CAST(PhysicsServer3D::BodyDampMode);
-VARIANT_ENUM_CAST(PhysicsServer3D::BodyState);
-VARIANT_ENUM_CAST(PhysicsServer3D::BodyAxis);
-VARIANT_ENUM_CAST(PhysicsServer3D::PinJointParam);
-VARIANT_ENUM_CAST(PhysicsServer3D::JointType);
-VARIANT_ENUM_CAST(PhysicsServer3D::HingeJointParam);
-VARIANT_ENUM_CAST(PhysicsServer3D::HingeJointFlag);
-VARIANT_ENUM_CAST(PhysicsServer3D::SliderJointParam);
-VARIANT_ENUM_CAST(PhysicsServer3D::ConeTwistJointParam);
-VARIANT_ENUM_CAST(PhysicsServer3D::G6DOFJointAxisParam);
-VARIANT_ENUM_CAST(PhysicsServer3D::G6DOFJointAxisFlag);
-VARIANT_ENUM_CAST(PhysicsServer3D::AreaBodyStatus);
-VARIANT_ENUM_CAST(PhysicsServer3D::ProcessInfo);
+VARIANT_ENUM_CAST_EXT(PS3DE::ShapeType, PhysicsServer3D::ShapeType);
+VARIANT_ENUM_CAST_EXT(PS3DE::SpaceParameter, PhysicsServer3D::SpaceParameter);
+VARIANT_ENUM_CAST_EXT(PS3DE::AreaParameter, PhysicsServer3D::AreaParameter);
+VARIANT_ENUM_CAST_EXT(PS3DE::AreaSpaceOverrideMode, PhysicsServer3D::AreaSpaceOverrideMode);
+VARIANT_ENUM_CAST_EXT(PS3DE::BodyMode, PhysicsServer3D::BodyMode);
+VARIANT_ENUM_CAST_EXT(PS3DE::BodyParameter, PhysicsServer3D::BodyParameter);
+VARIANT_ENUM_CAST_EXT(PS3DE::BodyDampMode, PhysicsServer3D::BodyDampMode);
+VARIANT_ENUM_CAST_EXT(PS3DE::BodyState, PhysicsServer3D::BodyState);
+VARIANT_ENUM_CAST_EXT(PS3DE::BodyAxis, PhysicsServer3D::BodyAxis);
+VARIANT_ENUM_CAST_EXT(PS3DE::PinJointParam, PhysicsServer3D::PinJointParam);
+VARIANT_ENUM_CAST_EXT(PS3DE::JointType, PhysicsServer3D::JointType);
+VARIANT_ENUM_CAST_EXT(PS3DE::HingeJointParam, PhysicsServer3D::HingeJointParam);
+VARIANT_ENUM_CAST_EXT(PS3DE::HingeJointFlag, PhysicsServer3D::HingeJointFlag);
+VARIANT_ENUM_CAST_EXT(PS3DE::SliderJointParam, PhysicsServer3D::SliderJointParam);
+VARIANT_ENUM_CAST_EXT(PS3DE::ConeTwistJointParam, PhysicsServer3D::ConeTwistJointParam);
+VARIANT_ENUM_CAST_EXT(PS3DE::G6DOFJointAxisParam, PhysicsServer3D::G6DOFJointAxisParam);
+VARIANT_ENUM_CAST_EXT(PS3DE::G6DOFJointAxisFlag, PhysicsServer3D::G6DOFJointAxisFlag);
+VARIANT_ENUM_CAST_EXT(PS3DE::AreaBodyStatus, PhysicsServer3D::AreaBodyStatus);
+VARIANT_ENUM_CAST_EXT(PS3DE::ProcessInfo, PhysicsServer3D::ProcessInfo);
diff --git a/servers/physics_3d/physics_server_3d_constants.h b/servers/physics_3d/physics_server_3d_constants.h
new file mode 100644
index 00000000000..65c127ac522
--- /dev/null
+++ b/servers/physics_3d/physics_server_3d_constants.h
@@ -0,0 +1,40 @@
+/**************************************************************************/
+/* physics_server_3d_constants.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+namespace PhysicsServer3DConstants {
+
+constexpr int MAX_CONTACTS_REPORTED_3D_MAX = 4096;
+
+} // namespace PhysicsServer3DConstants
+
+// Alias to make it easier to use.
+#define PS3DC PhysicsServer3DConstants
diff --git a/servers/physics_3d/physics_server_3d_dummy.h b/servers/physics_3d/physics_server_3d_dummy.h
index 7e4186191dc..6e120655fcd 100644
--- a/servers/physics_3d/physics_server_3d_dummy.h
+++ b/servers/physics_3d/physics_server_3d_dummy.h
@@ -116,14 +116,14 @@ class PhysicsDirectSpaceState3DDummy : public PhysicsDirectSpaceState3D {
GDCLASS(PhysicsDirectSpaceState3DDummy, PhysicsDirectSpaceState3D);
public:
- virtual bool intersect_ray(const RayParameters &p_parameters, RayResult &r_result) override { return false; }
+ virtual bool intersect_ray(const PS3DT::RayParameters &p_parameters, PS3DT::RayResult &r_result) override { return false; }
- virtual int intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) override { return 0; }
+ virtual int intersect_point(const PS3DT::PointParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) override { return 0; }
- virtual int intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) override { return 0; }
- virtual bool cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, ShapeRestInfo *r_info = nullptr) override { return false; }
- virtual bool collide_shape(const ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) override { return false; }
- virtual bool rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) override { return false; }
+ virtual int intersect_shape(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) override { return 0; }
+ virtual bool cast_motion(const PS3DT::ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, PS3DT::ShapeRestInfo *r_info = nullptr) override { return false; }
+ virtual bool collide_shape(const PS3DT::ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) override { return false; }
+ virtual bool rest_info(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeRestInfo *r_info) override { return false; }
virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const override { return Vector3(); }
};
@@ -149,7 +149,7 @@ public:
virtual void shape_set_data(RID p_shape, const Variant &p_data) override {}
virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias) override {}
- virtual ShapeType shape_get_type(RID p_shape) const override { return SHAPE_SPHERE; }
+ virtual PS3DE::ShapeType shape_get_type(RID p_shape) const override { return PS3DE::SHAPE_SPHERE; }
virtual Variant shape_get_data(RID p_shape) const override { return Variant(); }
virtual void shape_set_margin(RID p_shape, real_t p_margin) override {}
@@ -163,8 +163,8 @@ public:
virtual void space_set_active(RID p_space, bool p_active) override {}
virtual bool space_is_active(RID p_space) const override { return false; }
- virtual void space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) override {}
- virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const override { return 0; }
+ virtual void space_set_param(RID p_space, PS3DE::SpaceParameter p_param, real_t p_value) override {}
+ virtual real_t space_get_param(RID p_space, PS3DE::SpaceParameter p_param) const override { return 0; }
virtual PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space) override { return space_state_dummy; }
@@ -195,10 +195,10 @@ public:
virtual void area_attach_object_instance_id(RID p_area, ObjectID p_id) override {}
virtual ObjectID area_get_object_instance_id(RID p_area) const override { return ObjectID(); }
- virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) override {}
+ virtual void area_set_param(RID p_area, PS3DE::AreaParameter p_param, const Variant &p_value) override {}
virtual void area_set_transform(RID p_area, const Transform3D &p_transform) override {}
- virtual Variant area_get_param(RID p_parea, AreaParameter p_param) const override { return Variant(); }
+ virtual Variant area_get_param(RID p_parea, PS3DE::AreaParameter p_param) const override { return Variant(); }
virtual Transform3D area_get_transform(RID p_area) const override { return Transform3D(); }
virtual void area_set_collision_layer(RID p_area, uint32_t p_layer) override {}
@@ -221,8 +221,8 @@ public:
virtual void body_set_space(RID p_body, RID p_space) override {}
virtual RID body_get_space(RID p_body) const override { return RID(); }
- virtual void body_set_mode(RID p_body, BodyMode p_mode) override {}
- virtual BodyMode body_get_mode(RID p_body) const override { return BodyMode::BODY_MODE_STATIC; }
+ virtual void body_set_mode(RID p_body, PS3DE::BodyMode p_mode) override {}
+ virtual PS3DE::BodyMode body_get_mode(RID p_body) const override { return PS3DE::BodyMode::BODY_MODE_STATIC; }
virtual void body_add_shape(RID p_body, RID p_shape, const Transform3D &p_transform = Transform3D(), bool p_disabled = false) override {}
virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape) override {}
@@ -255,13 +255,13 @@ public:
virtual void body_set_user_flags(RID p_body, uint32_t p_flags) override {}
virtual uint32_t body_get_user_flags(RID p_body) const override { return 0; }
- virtual void body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) override {}
- virtual Variant body_get_param(RID p_body, BodyParameter p_param) const override { return Variant(); }
+ virtual void body_set_param(RID p_body, PS3DE::BodyParameter p_param, const Variant &p_value) override {}
+ virtual Variant body_get_param(RID p_body, PS3DE::BodyParameter p_param) const override { return Variant(); }
virtual void body_reset_mass_properties(RID p_body) override {}
- virtual void body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) override {}
- virtual Variant body_get_state(RID p_body, BodyState p_state) const override { return Variant(); }
+ virtual void body_set_state(RID p_body, PS3DE::BodyState p_state, const Variant &p_variant) override {}
+ virtual Variant body_get_state(RID p_body, PS3DE::BodyState p_state) const override { return Variant(); }
virtual void body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) override {}
virtual void body_apply_impulse(RID p_body, const Vector3 &p_impulse, const Vector3 &p_position = Vector3()) override {}
@@ -283,8 +283,8 @@ public:
virtual void body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) override {}
- virtual void body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) override {}
- virtual bool body_is_axis_locked(RID p_body, BodyAxis p_axis) const override { return false; }
+ virtual void body_set_axis_lock(RID p_body, PS3DE::BodyAxis p_axis, bool p_lock) override {}
+ virtual bool body_is_axis_locked(RID p_body, PS3DE::BodyAxis p_axis) const override { return false; }
virtual void body_add_collision_exception(RID p_body, RID p_body_b) override {}
virtual void body_remove_collision_exception(RID p_body, RID p_body_b) override {}
@@ -306,7 +306,7 @@ public:
virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) override { return body_state_dummy; }
- virtual bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) override { return false; }
+ virtual bool body_test_motion(RID p_body, const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult *r_result = nullptr) override { return false; }
/* SOFT BODY */
@@ -331,8 +331,8 @@ public:
virtual void soft_body_remove_collision_exception(RID p_body, RID p_body_b) override {}
virtual void soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) override {}
- virtual void soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) override {}
- virtual Variant soft_body_get_state(RID p_body, BodyState p_state) const override { return Variant(); }
+ virtual void soft_body_set_state(RID p_body, PS3DE::BodyState p_state, const Variant &p_variant) override {}
+ virtual Variant soft_body_get_state(RID p_body, PS3DE::BodyState p_state) const override { return Variant(); }
virtual void soft_body_set_transform(RID p_body, const Transform3D &p_transform) override {}
@@ -377,7 +377,7 @@ public:
virtual void joint_clear(RID p_joint) override {}
- virtual JointType joint_get_type(RID p_joint) const override { return JointType::JOINT_TYPE_PIN; }
+ virtual PS3DE::JointType joint_get_type(RID p_joint) const override { return PS3DE::JointType::JOINT_TYPE_PIN; }
virtual void joint_set_solver_priority(RID p_joint, int p_priority) override {}
virtual int joint_get_solver_priority(RID p_joint) const override { return 0; }
@@ -387,8 +387,8 @@ public:
virtual void joint_make_pin(RID p_joint, RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) override {}
- virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) override {}
- virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const override { return 0; }
+ virtual void pin_joint_set_param(RID p_joint, PS3DE::PinJointParam p_param, real_t p_value) override {}
+ virtual real_t pin_joint_get_param(RID p_joint, PS3DE::PinJointParam p_param) const override { return 0; }
virtual void pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) override {}
virtual Vector3 pin_joint_get_local_a(RID p_joint) const override { return Vector3(); }
@@ -399,29 +399,29 @@ public:
virtual void joint_make_hinge(RID p_joint, RID p_body_A, const Transform3D &p_hinge_A, RID p_body_B, const Transform3D &p_hinge_B) override {}
virtual void 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) override {}
- virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) override {}
- virtual real_t hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const override { return 0; }
+ virtual void hinge_joint_set_param(RID p_joint, PS3DE::HingeJointParam p_param, real_t p_value) override {}
+ virtual real_t hinge_joint_get_param(RID p_joint, PS3DE::HingeJointParam p_param) const override { return 0; }
- virtual void hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_enabled) override {}
- virtual bool hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const override { return false; }
+ virtual void hinge_joint_set_flag(RID p_joint, PS3DE::HingeJointFlag p_flag, bool p_enabled) override {}
+ virtual bool hinge_joint_get_flag(RID p_joint, PS3DE::HingeJointFlag p_flag) const override { return false; }
virtual void joint_make_slider(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) override {}
- virtual void slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) override {}
- virtual real_t slider_joint_get_param(RID p_joint, SliderJointParam p_param) const override { return 0; }
+ virtual void slider_joint_set_param(RID p_joint, PS3DE::SliderJointParam p_param, real_t p_value) override {}
+ virtual real_t slider_joint_get_param(RID p_joint, PS3DE::SliderJointParam p_param) const override { return 0; }
virtual void joint_make_cone_twist(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) override {}
- virtual void cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) override {}
- virtual real_t cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const override { return 0; }
+ virtual void cone_twist_joint_set_param(RID p_joint, PS3DE::ConeTwistJointParam p_param, real_t p_value) override {}
+ virtual real_t cone_twist_joint_get_param(RID p_joint, PS3DE::ConeTwistJointParam p_param) const override { return 0; }
virtual void joint_make_generic_6dof(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) override {}
- virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param, real_t p_value) override {}
- virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param) const override { return 0; }
+ virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis, PS3DE::G6DOFJointAxisParam p_param, real_t p_value) override {}
+ virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis, PS3DE::G6DOFJointAxisParam p_param) const override { return 0; }
- virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag, bool p_enable) override {}
- virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag) const override { return false; }
+ virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis, PS3DE::G6DOFJointAxisFlag p_flag, bool p_enable) override {}
+ virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis, PS3DE::G6DOFJointAxisFlag p_flag) const override { return false; }
virtual void generic_6dof_joint_set_angular_target_rotation(RID p_joint, const Quaternion &p_target_rotation) override {}
virtual Quaternion generic_6dof_joint_get_angular_target_rotation(RID p_joint) const override { return Quaternion(); }
@@ -446,5 +446,5 @@ public:
virtual bool is_flushing_queries() const override { return false; }
- virtual int get_process_info(ProcessInfo p_info) override { return 0; }
+ virtual int get_process_info(PS3DE::ProcessInfo p_info) override { return 0; }
};
diff --git a/servers/physics_3d/physics_server_3d_enums.h b/servers/physics_3d/physics_server_3d_enums.h
new file mode 100644
index 00000000000..0e10052b20b
--- /dev/null
+++ b/servers/physics_3d/physics_server_3d_enums.h
@@ -0,0 +1,266 @@
+/**************************************************************************/
+/* physics_server_3d_enums.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+namespace PhysicsServer3DEnums {
+
+/* SHAPE API */
+
+enum ShapeType {
+ SHAPE_WORLD_BOUNDARY, ///< plane:"plane"
+ SHAPE_SEPARATION_RAY, ///< float:"length"
+ SHAPE_SPHERE, ///< float:"radius"
+ SHAPE_BOX, ///< vec3:"extents"
+ SHAPE_CAPSULE, ///< dict( float:"radius", float:"height"):capsule
+ SHAPE_CYLINDER, ///< dict( float:"radius", float:"height"):cylinder
+ SHAPE_CONVEX_POLYGON, ///< array of planes:"planes"
+ SHAPE_CONCAVE_POLYGON, ///< vector3 array:"triangles" , or Dictionary with "indices" (int array) and "triangles" (Vector3 array)
+ SHAPE_HEIGHTMAP, ///< dict( int:"width", int:"depth",float:"cell_size", float_array:"heights"
+ SHAPE_SOFT_BODY, ///< Used internally, can't be created from the physics server.
+ SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error
+};
+
+/* SPACE API */
+
+enum SpaceParameter {
+ SPACE_PARAM_CONTACT_RECYCLE_RADIUS,
+ SPACE_PARAM_CONTACT_MAX_SEPARATION,
+ SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION,
+ SPACE_PARAM_CONTACT_DEFAULT_BIAS,
+ SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD,
+ SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD,
+ SPACE_PARAM_BODY_TIME_TO_SLEEP,
+ SPACE_PARAM_SOLVER_ITERATIONS,
+};
+
+/* AREA API */
+
+enum AreaParameter {
+ AREA_PARAM_GRAVITY_OVERRIDE_MODE,
+ AREA_PARAM_GRAVITY,
+ AREA_PARAM_GRAVITY_VECTOR,
+ AREA_PARAM_GRAVITY_IS_POINT,
+ AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE,
+ AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE,
+ AREA_PARAM_LINEAR_DAMP,
+ AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE,
+ AREA_PARAM_ANGULAR_DAMP,
+ AREA_PARAM_PRIORITY,
+ AREA_PARAM_WIND_FORCE_MAGNITUDE,
+ AREA_PARAM_WIND_SOURCE,
+ AREA_PARAM_WIND_DIRECTION,
+ AREA_PARAM_WIND_ATTENUATION_FACTOR,
+};
+
+enum AreaSpaceOverrideMode {
+ AREA_SPACE_OVERRIDE_DISABLED,
+ AREA_SPACE_OVERRIDE_COMBINE,
+ AREA_SPACE_OVERRIDE_COMBINE_REPLACE,
+ AREA_SPACE_OVERRIDE_REPLACE,
+ AREA_SPACE_OVERRIDE_REPLACE_COMBINE
+};
+
+/* BODY API */
+
+enum BodyMode {
+ BODY_MODE_STATIC,
+ BODY_MODE_KINEMATIC,
+ BODY_MODE_RIGID,
+ BODY_MODE_RIGID_LINEAR,
+};
+
+enum BodyDampMode {
+ BODY_DAMP_MODE_COMBINE,
+ BODY_DAMP_MODE_REPLACE,
+};
+
+enum BodyParameter {
+ BODY_PARAM_BOUNCE,
+ BODY_PARAM_FRICTION,
+ BODY_PARAM_MASS, ///< unused for static, always infinite
+ BODY_PARAM_INERTIA,
+ BODY_PARAM_CENTER_OF_MASS,
+ BODY_PARAM_GRAVITY_SCALE,
+ BODY_PARAM_LINEAR_DAMP_MODE,
+ BODY_PARAM_ANGULAR_DAMP_MODE,
+ BODY_PARAM_LINEAR_DAMP,
+ BODY_PARAM_ANGULAR_DAMP,
+ BODY_PARAM_MAX,
+};
+
+enum BodyState {
+ BODY_STATE_TRANSFORM,
+ BODY_STATE_LINEAR_VELOCITY,
+ BODY_STATE_ANGULAR_VELOCITY,
+ BODY_STATE_SLEEPING,
+ BODY_STATE_CAN_SLEEP
+};
+
+enum BodyAxis {
+ BODY_AXIS_LINEAR_X = 1 << 0,
+ BODY_AXIS_LINEAR_Y = 1 << 1,
+ BODY_AXIS_LINEAR_Z = 1 << 2,
+ BODY_AXIS_ANGULAR_X = 1 << 3,
+ BODY_AXIS_ANGULAR_Y = 1 << 4,
+ BODY_AXIS_ANGULAR_Z = 1 << 5
+};
+
+/* JOINT API */
+
+enum JointType {
+ JOINT_TYPE_PIN,
+ JOINT_TYPE_HINGE,
+ JOINT_TYPE_SLIDER,
+ JOINT_TYPE_CONE_TWIST,
+ JOINT_TYPE_6DOF,
+ JOINT_TYPE_MAX,
+
+};
+
+enum PinJointParam {
+ PIN_JOINT_BIAS,
+ PIN_JOINT_DAMPING,
+ PIN_JOINT_IMPULSE_CLAMP
+};
+
+enum HingeJointParam {
+ HINGE_JOINT_BIAS,
+ HINGE_JOINT_LIMIT_UPPER,
+ HINGE_JOINT_LIMIT_LOWER,
+ HINGE_JOINT_LIMIT_BIAS,
+ HINGE_JOINT_LIMIT_SOFTNESS,
+ HINGE_JOINT_LIMIT_RELAXATION,
+ HINGE_JOINT_MOTOR_TARGET_VELOCITY,
+ HINGE_JOINT_MOTOR_MAX_IMPULSE,
+ HINGE_JOINT_MAX
+};
+
+enum HingeJointFlag {
+ HINGE_JOINT_FLAG_USE_LIMIT,
+ HINGE_JOINT_FLAG_ENABLE_MOTOR,
+ HINGE_JOINT_FLAG_MAX
+};
+
+enum SliderJointParam {
+ SLIDER_JOINT_LINEAR_LIMIT_UPPER,
+ SLIDER_JOINT_LINEAR_LIMIT_LOWER,
+ SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS,
+ SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION,
+ SLIDER_JOINT_LINEAR_LIMIT_DAMPING,
+ SLIDER_JOINT_LINEAR_MOTION_SOFTNESS,
+ SLIDER_JOINT_LINEAR_MOTION_RESTITUTION,
+ SLIDER_JOINT_LINEAR_MOTION_DAMPING,
+ SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS,
+ SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION,
+ SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING,
+
+ SLIDER_JOINT_ANGULAR_LIMIT_UPPER,
+ SLIDER_JOINT_ANGULAR_LIMIT_LOWER,
+ SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS,
+ SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION,
+ SLIDER_JOINT_ANGULAR_LIMIT_DAMPING,
+ SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS,
+ SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION,
+ SLIDER_JOINT_ANGULAR_MOTION_DAMPING,
+ SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS,
+ SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION,
+ SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING,
+ SLIDER_JOINT_MAX
+};
+
+enum ConeTwistJointParam {
+ CONE_TWIST_JOINT_SWING_SPAN,
+ CONE_TWIST_JOINT_TWIST_SPAN,
+ CONE_TWIST_JOINT_BIAS,
+ CONE_TWIST_JOINT_SOFTNESS,
+ CONE_TWIST_JOINT_RELAXATION,
+ CONE_TWIST_MAX
+};
+
+enum G6DOFJointAxisParam {
+ G6DOF_JOINT_LINEAR_LOWER_LIMIT,
+ G6DOF_JOINT_LINEAR_UPPER_LIMIT,
+ G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS,
+ G6DOF_JOINT_LINEAR_RESTITUTION,
+ G6DOF_JOINT_LINEAR_DAMPING,
+ G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY,
+ G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT,
+ G6DOF_JOINT_LINEAR_SPRING_STIFFNESS,
+ G6DOF_JOINT_LINEAR_SPRING_DAMPING,
+ G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT,
+ G6DOF_JOINT_ANGULAR_LOWER_LIMIT,
+ G6DOF_JOINT_ANGULAR_UPPER_LIMIT,
+ G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS,
+ G6DOF_JOINT_ANGULAR_DAMPING,
+ G6DOF_JOINT_ANGULAR_RESTITUTION,
+ G6DOF_JOINT_ANGULAR_FORCE_LIMIT,
+ G6DOF_JOINT_ANGULAR_ERP,
+ G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY,
+ G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT,
+ G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS,
+ G6DOF_JOINT_ANGULAR_SPRING_DAMPING,
+ G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT,
+ G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT,
+ G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT,
+ G6DOF_JOINT_MAX
+};
+
+enum G6DOFJointAxisFlag {
+ G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT,
+ G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT,
+ G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING,
+ G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING,
+ G6DOF_JOINT_FLAG_ENABLE_MOTOR,
+ G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR,
+ G6DOF_JOINT_FLAG_MAX
+};
+
+/* QUERY API */
+
+enum AreaBodyStatus {
+ AREA_BODY_ADDED,
+ AREA_BODY_REMOVED
+};
+
+enum ProcessInfo {
+ INFO_ACTIVE_OBJECTS,
+ INFO_COLLISION_PAIRS,
+ INFO_ISLAND_COUNT
+};
+
+#ifndef DISABLE_DEPRECATED
+// Graveyard.
+#endif
+
+} // namespace PhysicsServer3DEnums
+
+// Alias to make it easier to use.
+#define PS3DE PhysicsServer3DEnums
diff --git a/servers/physics_3d/physics_server_3d_extension.h b/servers/physics_3d/physics_server_3d_extension.h
index 7473f7ad9d2..8e3ab50e0ff 100644
--- a/servers/physics_3d/physics_server_3d_extension.h
+++ b/servers/physics_3d/physics_server_3d_extension.h
@@ -116,9 +116,9 @@ public:
PhysicsDirectBodyState3DExtension();
};
-typedef PhysicsDirectSpaceState3D::RayResult PhysicsServer3DExtensionRayResult;
-typedef PhysicsDirectSpaceState3D::ShapeResult PhysicsServer3DExtensionShapeResult;
-typedef PhysicsDirectSpaceState3D::ShapeRestInfo PhysicsServer3DExtensionShapeRestInfo;
+typedef PS3DT::RayResult PhysicsServer3DExtensionRayResult;
+typedef PS3DT::ShapeResult PhysicsServer3DExtensionShapeResult;
+typedef PS3DT::ShapeRestInfo PhysicsServer3DExtensionShapeRestInfo;
GDVIRTUAL_NATIVE_PTR(PhysicsServer3DExtensionRayResult)
GDVIRTUAL_NATIVE_PTR(PhysicsServer3DExtensionShapeResult)
@@ -142,42 +142,42 @@ protected:
GDVIRTUAL2RC_REQUIRED(Vector3, _get_closest_point_to_object_volume, RID, const Vector3 &)
public:
- virtual bool intersect_ray(const RayParameters &p_parameters, RayResult &r_result) override {
+ virtual bool intersect_ray(const PS3DT::RayParameters &p_parameters, PS3DT::RayResult &r_result) override {
exclude = &p_parameters.exclude;
bool ret = false;
GDVIRTUAL_CALL(_intersect_ray, p_parameters.from, p_parameters.to, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, p_parameters.hit_from_inside, p_parameters.hit_back_faces, p_parameters.pick_ray, &r_result, ret);
exclude = nullptr;
return ret;
}
- virtual int intersect_point(const PointParameters &p_parameters, ShapeResult *r_results, int p_result_max) override {
+ virtual int intersect_point(const PS3DT::PointParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) override {
exclude = &p_parameters.exclude;
int ret = false;
GDVIRTUAL_CALL(_intersect_point, p_parameters.position, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_results, p_result_max, ret);
exclude = nullptr;
return ret;
}
- virtual int intersect_shape(const ShapeParameters &p_parameters, ShapeResult *r_results, int p_result_max) override {
+ virtual int intersect_shape(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) override {
exclude = &p_parameters.exclude;
int ret = 0;
GDVIRTUAL_CALL(_intersect_shape, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_results, p_result_max, ret);
exclude = nullptr;
return ret;
}
- virtual bool cast_motion(const ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, ShapeRestInfo *r_info = nullptr) override {
+ virtual bool cast_motion(const PS3DT::ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, PS3DT::ShapeRestInfo *r_info = nullptr) override {
exclude = &p_parameters.exclude;
bool ret = false;
GDVIRTUAL_CALL(_cast_motion, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, &p_closest_safe, &p_closest_unsafe, r_info, ret);
exclude = nullptr;
return ret;
}
- virtual bool collide_shape(const ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) override {
+ virtual bool collide_shape(const PS3DT::ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) override {
exclude = &p_parameters.exclude;
bool ret = false;
GDVIRTUAL_CALL(_collide_shape, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_results, p_result_max, &r_result_count, ret);
exclude = nullptr;
return ret;
}
- virtual bool rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) override {
+ virtual bool rest_info(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeRestInfo *r_info) override {
exclude = &p_parameters.exclude;
bool ret = false;
GDVIRTUAL_CALL(_rest_info, p_parameters.shape_rid, p_parameters.transform, p_parameters.motion, p_parameters.margin, p_parameters.collision_mask, p_parameters.collide_with_bodies, p_parameters.collide_with_areas, r_info, ret);
@@ -194,8 +194,8 @@ public:
PhysicsDirectSpaceState3DExtension();
};
-typedef PhysicsServer3D::MotionCollision PhysicsServer3DExtensionMotionCollision;
-typedef PhysicsServer3D::MotionResult PhysicsServer3DExtensionMotionResult;
+typedef PS3DT::MotionCollision PhysicsServer3DExtensionMotionCollision;
+typedef PS3DT::MotionResult PhysicsServer3DExtensionMotionResult;
GDVIRTUAL_NATIVE_PTR(PhysicsServer3DExtensionMotionCollision)
GDVIRTUAL_NATIVE_PTR(PhysicsServer3DExtensionMotionResult)
@@ -228,7 +228,7 @@ public:
EXBIND2(shape_set_margin, RID, real_t)
EXBIND1RC(real_t, shape_get_margin, RID)
- EXBIND1RC(ShapeType, shape_get_type, RID)
+ EXBIND1RC(PS3DE::ShapeType, shape_get_type, RID)
EXBIND1RC(Variant, shape_get_data, RID)
EXBIND1RC(real_t, shape_get_custom_solver_bias, RID)
@@ -238,8 +238,8 @@ public:
EXBIND2(space_set_active, RID, bool)
EXBIND1RC(bool, space_is_active, RID)
- EXBIND3(space_set_param, RID, SpaceParameter, real_t)
- EXBIND2RC(real_t, space_get_param, RID, SpaceParameter)
+ EXBIND3(space_set_param, RID, PS3DE::SpaceParameter, real_t)
+ EXBIND2RC(real_t, space_get_param, RID, PS3DE::SpaceParameter)
EXBIND1R(PhysicsDirectSpaceState3D *, space_get_direct_state, RID)
@@ -270,10 +270,10 @@ public:
EXBIND2(area_attach_object_instance_id, RID, ObjectID)
EXBIND1RC(ObjectID, area_get_object_instance_id, RID)
- EXBIND3(area_set_param, RID, AreaParameter, const Variant &)
+ EXBIND3(area_set_param, RID, PS3DE::AreaParameter, const Variant &)
EXBIND2(area_set_transform, RID, const Transform3D &)
- EXBIND2RC(Variant, area_get_param, RID, AreaParameter)
+ EXBIND2RC(Variant, area_get_param, RID, PS3DE::AreaParameter)
EXBIND1RC(Transform3D, area_get_transform, RID)
EXBIND2(area_set_collision_layer, RID, uint32_t)
@@ -296,8 +296,8 @@ public:
EXBIND2(body_set_space, RID, RID)
EXBIND1RC(RID, body_get_space, RID)
- EXBIND2(body_set_mode, RID, BodyMode)
- EXBIND1RC(BodyMode, body_get_mode, RID)
+ EXBIND2(body_set_mode, RID, PS3DE::BodyMode)
+ EXBIND1RC(PS3DE::BodyMode, body_get_mode, RID)
EXBIND4(body_add_shape, RID, RID, const Transform3D &, bool)
EXBIND3(body_set_shape, RID, int, RID)
@@ -329,13 +329,13 @@ public:
EXBIND2(body_set_user_flags, RID, uint32_t)
EXBIND1RC(uint32_t, body_get_user_flags, RID)
- EXBIND3(body_set_param, RID, BodyParameter, const Variant &)
- EXBIND2RC(Variant, body_get_param, RID, BodyParameter)
+ EXBIND3(body_set_param, RID, PS3DE::BodyParameter, const Variant &)
+ EXBIND2RC(Variant, body_get_param, RID, PS3DE::BodyParameter)
EXBIND1(body_reset_mass_properties, RID)
- EXBIND3(body_set_state, RID, BodyState, const Variant &)
- EXBIND2RC(Variant, body_get_state, RID, BodyState)
+ EXBIND3(body_set_state, RID, PS3DE::BodyState, const Variant &)
+ EXBIND2RC(Variant, body_get_state, RID, PS3DE::BodyState)
EXBIND2(body_apply_central_impulse, RID, const Vector3 &)
EXBIND3(body_apply_impulse, RID, const Vector3 &, const Vector3 &)
@@ -357,8 +357,8 @@ public:
EXBIND2(body_set_axis_velocity, RID, const Vector3 &)
- EXBIND3(body_set_axis_lock, RID, BodyAxis, bool)
- EXBIND2RC(bool, body_is_axis_locked, RID, BodyAxis)
+ EXBIND3(body_set_axis_lock, RID, PS3DE::BodyAxis, bool)
+ EXBIND2RC(bool, body_is_axis_locked, RID, PS3DE::BodyAxis)
EXBIND2(body_add_collision_exception, RID, RID)
EXBIND2(body_remove_collision_exception, RID, RID)
@@ -395,7 +395,7 @@ public:
bool body_test_motion_is_excluding_body(RID p_body) const;
bool body_test_motion_is_excluding_object(ObjectID p_object) const;
- bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) override {
+ bool body_test_motion(RID p_body, const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult *r_result = nullptr) override {
bool ret = false;
exclude_bodies = &p_parameters.exclude_bodies;
exclude_objects = &p_parameters.exclude_objects;
@@ -437,8 +437,8 @@ public:
}
}
- EXBIND3(soft_body_set_state, RID, BodyState, const Variant &)
- EXBIND2RC(Variant, soft_body_get_state, RID, BodyState)
+ EXBIND3(soft_body_set_state, RID, PS3DE::BodyState, const Variant &)
+ EXBIND2RC(Variant, soft_body_get_state, RID, PS3DE::BodyState)
EXBIND2(soft_body_set_transform, RID, const Transform3D &)
@@ -486,8 +486,8 @@ public:
EXBIND5(joint_make_pin, RID, RID, const Vector3 &, RID, const Vector3 &)
- EXBIND3(pin_joint_set_param, RID, PinJointParam, real_t)
- EXBIND2RC(real_t, pin_joint_get_param, RID, PinJointParam)
+ EXBIND3(pin_joint_set_param, RID, PS3DE::PinJointParam, real_t)
+ EXBIND2RC(real_t, pin_joint_get_param, RID, PS3DE::PinJointParam)
EXBIND2(pin_joint_set_local_a, RID, const Vector3 &)
EXBIND1RC(Vector3, pin_joint_get_local_a, RID)
@@ -498,34 +498,34 @@ public:
EXBIND5(joint_make_hinge, RID, RID, const Transform3D &, RID, const Transform3D &)
EXBIND7(joint_make_hinge_simple, RID, RID, const Vector3 &, const Vector3 &, RID, const Vector3 &, const Vector3 &)
- EXBIND3(hinge_joint_set_param, RID, HingeJointParam, real_t)
- EXBIND2RC(real_t, hinge_joint_get_param, RID, HingeJointParam)
+ EXBIND3(hinge_joint_set_param, RID, PS3DE::HingeJointParam, real_t)
+ EXBIND2RC(real_t, hinge_joint_get_param, RID, PS3DE::HingeJointParam)
- EXBIND3(hinge_joint_set_flag, RID, HingeJointFlag, bool)
- EXBIND2RC(bool, hinge_joint_get_flag, RID, HingeJointFlag)
+ EXBIND3(hinge_joint_set_flag, RID, PS3DE::HingeJointFlag, bool)
+ EXBIND2RC(bool, hinge_joint_get_flag, RID, PS3DE::HingeJointFlag)
EXBIND5(joint_make_slider, RID, RID, const Transform3D &, RID, const Transform3D &)
- EXBIND3(slider_joint_set_param, RID, SliderJointParam, real_t)
- EXBIND2RC(real_t, slider_joint_get_param, RID, SliderJointParam)
+ EXBIND3(slider_joint_set_param, RID, PS3DE::SliderJointParam, real_t)
+ EXBIND2RC(real_t, slider_joint_get_param, RID, PS3DE::SliderJointParam)
EXBIND5(joint_make_cone_twist, RID, RID, const Transform3D &, RID, const Transform3D &)
- EXBIND3(cone_twist_joint_set_param, RID, ConeTwistJointParam, real_t)
- EXBIND2RC(real_t, cone_twist_joint_get_param, RID, ConeTwistJointParam)
+ EXBIND3(cone_twist_joint_set_param, RID, PS3DE::ConeTwistJointParam, real_t)
+ EXBIND2RC(real_t, cone_twist_joint_get_param, RID, PS3DE::ConeTwistJointParam)
EXBIND5(joint_make_generic_6dof, RID, RID, const Transform3D &, RID, const Transform3D &)
- EXBIND4(generic_6dof_joint_set_param, RID, Vector3::Axis, G6DOFJointAxisParam, real_t)
- EXBIND3RC(real_t, generic_6dof_joint_get_param, RID, Vector3::Axis, G6DOFJointAxisParam)
+ EXBIND4(generic_6dof_joint_set_param, RID, Vector3::Axis, PS3DE::G6DOFJointAxisParam, real_t)
+ EXBIND3RC(real_t, generic_6dof_joint_get_param, RID, Vector3::Axis, PS3DE::G6DOFJointAxisParam)
- EXBIND4(generic_6dof_joint_set_flag, RID, Vector3::Axis, G6DOFJointAxisFlag, bool)
- EXBIND3RC(bool, generic_6dof_joint_get_flag, RID, Vector3::Axis, G6DOFJointAxisFlag)
+ EXBIND4(generic_6dof_joint_set_flag, RID, Vector3::Axis, PS3DE::G6DOFJointAxisFlag, bool)
+ EXBIND3RC(bool, generic_6dof_joint_get_flag, RID, Vector3::Axis, PS3DE::G6DOFJointAxisFlag)
EXBIND2(generic_6dof_joint_set_angular_target_rotation, RID, const Quaternion &)
EXBIND1RC(Quaternion, generic_6dof_joint_get_angular_target_rotation, RID)
- EXBIND1RC(JointType, joint_get_type, RID)
+ EXBIND1RC(PS3DE::JointType, joint_get_type, RID)
EXBIND2(joint_set_solver_priority, RID, int)
EXBIND1RC(int, joint_get_solver_priority, RID)
@@ -550,7 +550,7 @@ public:
EXBIND0(finish)
EXBIND0RC(bool, is_flushing_queries)
- EXBIND1R(int, get_process_info, ProcessInfo)
+ EXBIND1R(int, get_process_info, PS3DE::ProcessInfo)
PhysicsServer3DExtension();
~PhysicsServer3DExtension();
diff --git a/servers/physics_3d/physics_server_3d_rendering_server_handler.cpp b/servers/physics_3d/physics_server_3d_rendering_server_handler.cpp
new file mode 100644
index 00000000000..b44a6a9f527
--- /dev/null
+++ b/servers/physics_3d/physics_server_3d_rendering_server_handler.cpp
@@ -0,0 +1,55 @@
+/**************************************************************************/
+/* physics_server_3d_rendering_server_handler.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 "physics_server_3d_rendering_server_handler.h"
+
+#include "core/math/aabb.h"
+#include "core/math/vector3.h"
+#include "core/object/class_db.h"
+
+void PhysicsServer3DRenderingServerHandler::set_vertex(int p_vertex_id, const Vector3 &p_vertex) {
+ GDVIRTUAL_CALL(_set_vertex, p_vertex_id, p_vertex);
+}
+void PhysicsServer3DRenderingServerHandler::set_normal(int p_vertex_id, const Vector3 &p_normal) {
+ GDVIRTUAL_CALL(_set_normal, p_vertex_id, p_normal);
+}
+void PhysicsServer3DRenderingServerHandler::set_aabb(const AABB &p_aabb) {
+ GDVIRTUAL_CALL(_set_aabb, p_aabb);
+}
+
+void PhysicsServer3DRenderingServerHandler::_bind_methods() {
+ GDVIRTUAL_BIND(_set_vertex, "vertex_id", "vertex");
+ GDVIRTUAL_BIND(_set_normal, "vertex_id", "normal");
+ GDVIRTUAL_BIND(_set_aabb, "aabb");
+
+ ClassDB::bind_method(D_METHOD("set_vertex", "vertex_id", "vertex"), &PhysicsServer3DRenderingServerHandler::set_vertex);
+ ClassDB::bind_method(D_METHOD("set_normal", "vertex_id", "normal"), &PhysicsServer3DRenderingServerHandler::set_normal);
+ ClassDB::bind_method(D_METHOD("set_aabb", "aabb"), &PhysicsServer3DRenderingServerHandler::set_aabb);
+}
diff --git a/servers/physics_3d/physics_server_3d_rendering_server_handler.h b/servers/physics_3d/physics_server_3d_rendering_server_handler.h
new file mode 100644
index 00000000000..1249a05b3cc
--- /dev/null
+++ b/servers/physics_3d/physics_server_3d_rendering_server_handler.h
@@ -0,0 +1,54 @@
+/**************************************************************************/
+/* physics_server_3d_rendering_server_handler.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/object/gdvirtual.gen.h"
+#include "core/object/object.h"
+
+struct AABB;
+struct Vector3;
+
+class PhysicsServer3DRenderingServerHandler : public Object {
+ GDCLASS(PhysicsServer3DRenderingServerHandler, Object)
+protected:
+ GDVIRTUAL2_REQUIRED(_set_vertex, int, const Vector3 &)
+ GDVIRTUAL2_REQUIRED(_set_normal, int, const Vector3 &)
+ GDVIRTUAL1_REQUIRED(_set_aabb, const AABB &)
+
+ static void _bind_methods();
+
+public:
+ virtual void set_vertex(int p_vertex_id, const Vector3 &p_vertex);
+ virtual void set_normal(int p_vertex_id, const Vector3 &p_normal);
+ virtual void set_aabb(const AABB &p_aabb);
+
+ virtual ~PhysicsServer3DRenderingServerHandler() {}
+};
diff --git a/servers/physics_3d/physics_server_3d_types.h b/servers/physics_3d/physics_server_3d_types.h
new file mode 100644
index 00000000000..c7398064f73
--- /dev/null
+++ b/servers/physics_3d/physics_server_3d_types.h
@@ -0,0 +1,155 @@
+/**************************************************************************/
+/* physics_server_3d_types.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/math/vector3.h"
+#include "core/object/object.h"
+#include "core/templates/hash_set.h"
+#include "core/templates/rid.h"
+
+namespace PhysicsServer3DTypes {
+
+struct RayParameters {
+ Vector3 from;
+ Vector3 to;
+ HashSet<RID> exclude;
+ uint32_t collision_mask = UINT32_MAX;
+
+ bool collide_with_bodies = true;
+ bool collide_with_areas = false;
+
+ bool hit_from_inside = false;
+ bool hit_back_faces = true;
+
+ bool pick_ray = false;
+};
+
+struct RayResult {
+ Vector3 position;
+ Vector3 normal;
+ RID rid;
+ ObjectID collider_id;
+ Object *collider = nullptr;
+ int shape = 0;
+ int face_index = -1;
+};
+
+struct ShapeResult {
+ RID rid;
+ ObjectID collider_id;
+ Object *collider = nullptr;
+ int shape = 0;
+};
+
+struct PointParameters {
+ Vector3 position;
+ HashSet<RID> exclude;
+ uint32_t collision_mask = UINT32_MAX;
+
+ bool collide_with_bodies = true;
+ bool collide_with_areas = false;
+};
+
+struct ShapeParameters {
+ RID shape_rid;
+ Transform3D transform;
+ Vector3 motion;
+ real_t margin = 0.0;
+ HashSet<RID> exclude;
+ uint32_t collision_mask = UINT32_MAX;
+
+ bool collide_with_bodies = true;
+ bool collide_with_areas = false;
+};
+
+struct ShapeRestInfo {
+ Vector3 point;
+ Vector3 normal;
+ RID rid;
+ ObjectID collider_id;
+ int shape = 0;
+ Vector3 linear_velocity; // Velocity at contact point.
+};
+
+struct MotionParameters {
+ Transform3D from;
+ Vector3 motion;
+ real_t margin = 0.001;
+ int max_collisions = 1;
+ bool collide_separation_ray = false;
+ HashSet<RID> exclude_bodies;
+ HashSet<ObjectID> exclude_objects;
+ bool recovery_as_collision = false;
+
+ MotionParameters() {}
+
+ MotionParameters(const Transform3D &p_from, const Vector3 &p_motion, real_t p_margin = 0.001) :
+ from(p_from),
+ motion(p_motion),
+ margin(p_margin) {}
+};
+
+struct MotionCollision {
+ Vector3 position;
+ Vector3 normal;
+ Vector3 collider_velocity;
+ Vector3 collider_angular_velocity;
+ real_t depth = 0.0;
+ int local_shape = 0;
+ ObjectID collider_id;
+ RID collider;
+ int collider_shape = 0;
+
+ real_t get_angle(Vector3 p_up_direction) const {
+ return Math::acos(normal.dot(p_up_direction));
+ }
+};
+
+struct MotionResult {
+ Vector3 travel;
+ Vector3 remainder;
+ real_t collision_depth = 0.0;
+ real_t collision_safe_fraction = 0.0;
+ real_t collision_unsafe_fraction = 0.0;
+
+ static const int MAX_COLLISIONS = 32;
+ MotionCollision collisions[MAX_COLLISIONS];
+ int collision_count = 0;
+};
+
+#ifndef DISABLE_DEPRECATED
+// Graveyard.
+#endif
+
+} // namespace PhysicsServer3DTypes
+
+// Alias to make it easier to use.
+#define PS3DT PhysicsServer3DTypes
diff --git a/servers/physics_3d/physics_server_3d_wrap_mt.h b/servers/physics_3d/physics_server_3d_wrap_mt.h
index 0958a95f2e1..dd41ff89a26 100644
--- a/servers/physics_3d/physics_server_3d_wrap_mt.h
+++ b/servers/physics_3d/physics_server_3d_wrap_mt.h
@@ -80,7 +80,7 @@ class PhysicsServer3DWrapMT : public PhysicsServer3D {
void _thread_sync();
public:
- //FUNC1RID(shape,ShapeType); todo fix
+ //FUNC1RID(shape,PS3DE::ShapeType); todo fix
FUNCRID(world_boundary_shape)
FUNCRID(separation_ray_shape)
FUNCRID(sphere_shape)
@@ -98,7 +98,7 @@ public:
FUNC2(shape_set_margin, RID, real_t)
FUNC1RC(real_t, shape_get_margin, RID)
- FUNC1RC(ShapeType, shape_get_type, RID);
+ FUNC1RC(PS3DE::ShapeType, shape_get_type, RID);
FUNC1RC(Variant, shape_get_data, RID);
FUNC1RC(real_t, shape_get_custom_solver_bias, RID);
#if 0
@@ -114,8 +114,8 @@ public:
FUNC2(space_set_active, RID, bool);
FUNC1RC(bool, space_is_active, RID);
- FUNC3(space_set_param, RID, SpaceParameter, real_t);
- FUNC2RC(real_t, space_get_param, RID, SpaceParameter);
+ FUNC3(space_set_param, RID, PS3DE::SpaceParameter, real_t);
+ FUNC2RC(real_t, space_get_param, RID, PS3DE::SpaceParameter);
// this function only works on physics process, errors and returns null otherwise
PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space) override {
@@ -156,10 +156,10 @@ public:
FUNC2(area_attach_object_instance_id, RID, ObjectID);
FUNC1RC(ObjectID, area_get_object_instance_id, RID);
- FUNC3(area_set_param, RID, AreaParameter, const Variant &);
+ FUNC3(area_set_param, RID, PS3DE::AreaParameter, const Variant &);
FUNC2(area_set_transform, RID, const Transform3D &);
- FUNC2RC(Variant, area_get_param, RID, AreaParameter);
+ FUNC2RC(Variant, area_get_param, RID, PS3DE::AreaParameter);
FUNC1RC(Transform3D, area_get_transform, RID);
FUNC2(area_set_collision_layer, RID, uint32_t);
@@ -182,8 +182,8 @@ public:
FUNC2(body_set_space, RID, RID);
FUNC1RC(RID, body_get_space, RID);
- FUNC2(body_set_mode, RID, BodyMode);
- FUNC1RC(BodyMode, body_get_mode, RID);
+ FUNC2(body_set_mode, RID, PS3DE::BodyMode);
+ FUNC1RC(PS3DE::BodyMode, body_get_mode, RID);
FUNC4(body_add_shape, RID, RID, const Transform3D &, bool);
FUNC3(body_set_shape, RID, int, RID);
@@ -216,13 +216,13 @@ public:
FUNC2(body_set_user_flags, RID, uint32_t);
FUNC1RC(uint32_t, body_get_user_flags, RID);
- FUNC3(body_set_param, RID, BodyParameter, const Variant &);
- FUNC2RC(Variant, body_get_param, RID, BodyParameter);
+ FUNC3(body_set_param, RID, PS3DE::BodyParameter, const Variant &);
+ FUNC2RC(Variant, body_get_param, RID, PS3DE::BodyParameter);
FUNC1(body_reset_mass_properties, RID);
- FUNC3(body_set_state, RID, BodyState, const Variant &);
- FUNC2RC(Variant, body_get_state, RID, BodyState);
+ FUNC3(body_set_state, RID, PS3DE::BodyState, const Variant &);
+ FUNC2RC(Variant, body_get_state, RID, PS3DE::BodyState);
FUNC2(body_apply_torque_impulse, RID, const Vector3 &);
FUNC2(body_apply_central_impulse, RID, const Vector3 &);
@@ -249,8 +249,8 @@ public:
FUNC2(body_set_axis_velocity, RID, const Vector3 &);
- FUNC3(body_set_axis_lock, RID, BodyAxis, bool);
- FUNC2RC(bool, body_is_axis_locked, RID, BodyAxis);
+ FUNC3(body_set_axis_lock, RID, PS3DE::BodyAxis, bool);
+ FUNC2RC(bool, body_is_axis_locked, RID, PS3DE::BodyAxis);
FUNC2(body_add_collision_exception, RID, RID);
FUNC2(body_remove_collision_exception, RID, RID);
@@ -270,7 +270,7 @@ public:
FUNC2(body_set_ray_pickable, RID, bool);
- bool body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result = nullptr) override {
+ bool body_test_motion(RID p_body, const PS3DT::MotionParameters &p_parameters, PS3DT::MotionResult *r_result = nullptr) override {
ERR_FAIL_COND_V(!Thread::is_main_thread(), false);
return physics_server_3d->body_test_motion(p_body, p_parameters, r_result);
}
@@ -302,8 +302,8 @@ public:
FUNC2(soft_body_remove_collision_exception, RID, RID)
FUNC2S(soft_body_get_collision_exceptions, RID, List<RID> *)
- FUNC3(soft_body_set_state, RID, BodyState, const Variant &);
- FUNC2RC(Variant, soft_body_get_state, RID, BodyState);
+ FUNC3(soft_body_set_state, RID, PS3DE::BodyState, const Variant &);
+ FUNC2RC(Variant, soft_body_get_state, RID, PS3DE::BodyState);
FUNC2(soft_body_set_transform, RID, const Transform3D &);
@@ -347,8 +347,8 @@ public:
FUNC5(joint_make_pin, RID, RID, const Vector3 &, RID, const Vector3 &)
- FUNC3(pin_joint_set_param, RID, PinJointParam, real_t)
- FUNC2RC(real_t, pin_joint_get_param, RID, PinJointParam)
+ FUNC3(pin_joint_set_param, RID, PS3DE::PinJointParam, real_t)
+ FUNC2RC(real_t, pin_joint_get_param, RID, PS3DE::PinJointParam)
FUNC2(pin_joint_set_local_a, RID, const Vector3 &)
FUNC1RC(Vector3, pin_joint_get_local_a, RID)
@@ -359,34 +359,34 @@ public:
FUNC5(joint_make_hinge, RID, RID, const Transform3D &, RID, const Transform3D &)
FUNC7(joint_make_hinge_simple, RID, RID, const Vector3 &, const Vector3 &, RID, const Vector3 &, const Vector3 &)
- FUNC3(hinge_joint_set_param, RID, HingeJointParam, real_t)
- FUNC2RC(real_t, hinge_joint_get_param, RID, HingeJointParam)
+ FUNC3(hinge_joint_set_param, RID, PS3DE::HingeJointParam, real_t)
+ FUNC2RC(real_t, hinge_joint_get_param, RID, PS3DE::HingeJointParam)
- FUNC3(hinge_joint_set_flag, RID, HingeJointFlag, bool)
- FUNC2RC(bool, hinge_joint_get_flag, RID, HingeJointFlag)
+ FUNC3(hinge_joint_set_flag, RID, PS3DE::HingeJointFlag, bool)
+ FUNC2RC(bool, hinge_joint_get_flag, RID, PS3DE::HingeJointFlag)
FUNC5(joint_make_slider, RID, RID, const Transform3D &, RID, const Transform3D &)
- FUNC3(slider_joint_set_param, RID, SliderJointParam, real_t)
- FUNC2RC(real_t, slider_joint_get_param, RID, SliderJointParam)
+ FUNC3(slider_joint_set_param, RID, PS3DE::SliderJointParam, real_t)
+ FUNC2RC(real_t, slider_joint_get_param, RID, PS3DE::SliderJointParam)
FUNC5(joint_make_cone_twist, RID, RID, const Transform3D &, RID, const Transform3D &)
- FUNC3(cone_twist_joint_set_param, RID, ConeTwistJointParam, real_t)
- FUNC2RC(real_t, cone_twist_joint_get_param, RID, ConeTwistJointParam)
+ FUNC3(cone_twist_joint_set_param, RID, PS3DE::ConeTwistJointParam, real_t)
+ FUNC2RC(real_t, cone_twist_joint_get_param, RID, PS3DE::ConeTwistJointParam)
FUNC5(joint_make_generic_6dof, RID, RID, const Transform3D &, RID, const Transform3D &)
- FUNC4(generic_6dof_joint_set_param, RID, Vector3::Axis, G6DOFJointAxisParam, real_t)
- FUNC3RC(real_t, generic_6dof_joint_get_param, RID, Vector3::Axis, G6DOFJointAxisParam)
+ FUNC4(generic_6dof_joint_set_param, RID, Vector3::Axis, PS3DE::G6DOFJointAxisParam, real_t)
+ FUNC3RC(real_t, generic_6dof_joint_get_param, RID, Vector3::Axis, PS3DE::G6DOFJointAxisParam)
- FUNC4(generic_6dof_joint_set_flag, RID, Vector3::Axis, G6DOFJointAxisFlag, bool)
- FUNC3RC(bool, generic_6dof_joint_get_flag, RID, Vector3::Axis, G6DOFJointAxisFlag)
+ FUNC4(generic_6dof_joint_set_flag, RID, Vector3::Axis, PS3DE::G6DOFJointAxisFlag, bool)
+ FUNC3RC(bool, generic_6dof_joint_get_flag, RID, Vector3::Axis, PS3DE::G6DOFJointAxisFlag)
FUNC2(generic_6dof_joint_set_angular_target_rotation, RID, const Quaternion &)
FUNC1RC(Quaternion, generic_6dof_joint_get_angular_target_rotation, RID)
- FUNC1RC(JointType, joint_get_type, RID);
+ FUNC1RC(PS3DE::JointType, joint_get_type, RID);
FUNC2(joint_set_solver_priority, RID, int);
FUNC1RC(int, joint_get_solver_priority, RID);
@@ -410,7 +410,7 @@ public:
return physics_server_3d->is_flushing_queries();
}
- int get_process_info(ProcessInfo p_info) override {
+ int get_process_info(PS3DE::ProcessInfo p_info) override {
return physics_server_3d->get_process_info(p_info);
}
diff --git a/servers/physics_3d/queries/SCsub b/servers/physics_3d/queries/SCsub
new file mode 100644
index 00000000000..87926c3a3d4
--- /dev/null
+++ b/servers/physics_3d/queries/SCsub
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+from misc.utility.scons_hints import *
+
+Import("env")
+
+if not env["disable_physics_3d"]:
+ env.add_source_files(env.servers_sources, "*.cpp")
diff --git a/servers/physics_3d/queries/physics_point_query_parameters_3d.cpp b/servers/physics_3d/queries/physics_point_query_parameters_3d.cpp
new file mode 100644
index 00000000000..d02a5c6efa2
--- /dev/null
+++ b/servers/physics_3d/queries/physics_point_query_parameters_3d.cpp
@@ -0,0 +1,74 @@
+/**************************************************************************/
+/* physics_point_query_parameters_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 "physics_point_query_parameters_3d.h"
+
+#include "core/object/class_db.h"
+#include "core/variant/typed_array.h"
+
+void PhysicsPointQueryParameters3D::set_exclude(const TypedArray<RID> &p_exclude) {
+ parameters.exclude.clear();
+ for (int i = 0; i < p_exclude.size(); i++) {
+ parameters.exclude.insert(p_exclude[i]);
+ }
+}
+
+TypedArray<RID> PhysicsPointQueryParameters3D::get_exclude() const {
+ TypedArray<RID> ret;
+ ret.resize(parameters.exclude.size());
+ int idx = 0;
+ for (const RID &E : parameters.exclude) {
+ ret[idx++] = E;
+ }
+ return ret;
+}
+
+void PhysicsPointQueryParameters3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_position", "position"), &PhysicsPointQueryParameters3D::set_position);
+ ClassDB::bind_method(D_METHOD("get_position"), &PhysicsPointQueryParameters3D::get_position);
+
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsPointQueryParameters3D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsPointQueryParameters3D::get_collision_mask);
+
+ ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsPointQueryParameters3D::set_exclude);
+ ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsPointQueryParameters3D::get_exclude);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsPointQueryParameters3D::set_collide_with_bodies);
+ ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsPointQueryParameters3D::is_collide_with_bodies_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsPointQueryParameters3D::set_collide_with_areas);
+ ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsPointQueryParameters3D::is_collide_with_areas_enabled);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "set_position", "get_position");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude", "get_exclude");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
+}
diff --git a/servers/physics_3d/queries/physics_point_query_parameters_3d.h b/servers/physics_3d/queries/physics_point_query_parameters_3d.h
new file mode 100644
index 00000000000..3e4400d25f5
--- /dev/null
+++ b/servers/physics_3d/queries/physics_point_query_parameters_3d.h
@@ -0,0 +1,61 @@
+/**************************************************************************/
+/* physics_point_query_parameters_3d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/object/ref_counted.h"
+#include "servers/physics_3d/physics_server_3d_types.h"
+
+class PhysicsPointQueryParameters3D : public RefCounted {
+ GDCLASS(PhysicsPointQueryParameters3D, RefCounted);
+
+ PS3DT::PointParameters parameters;
+
+protected:
+ static void _bind_methods();
+
+public:
+ const PS3DT::PointParameters &get_parameters() const { return parameters; }
+
+ void set_position(const Vector3 &p_position) { parameters.position = p_position; }
+ const Vector3 &get_position() const { return parameters.position; }
+
+ void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
+ uint32_t get_collision_mask() const { return parameters.collision_mask; }
+
+ void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
+ bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
+
+ void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
+ bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
+
+ void set_exclude(const TypedArray<RID> &p_exclude);
+ TypedArray<RID> get_exclude() const;
+};
diff --git a/servers/physics_3d/queries/physics_ray_query_parameters_3d.cpp b/servers/physics_3d/queries/physics_ray_query_parameters_3d.cpp
new file mode 100644
index 00000000000..b61b94f83d6
--- /dev/null
+++ b/servers/physics_3d/queries/physics_ray_query_parameters_3d.cpp
@@ -0,0 +1,98 @@
+/**************************************************************************/
+/* physics_ray_query_parameters_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 "physics_ray_query_parameters_3d.h"
+
+#include "core/object/class_db.h"
+#include "core/variant/typed_array.h"
+
+void PhysicsRayQueryParameters3D::set_exclude(const TypedArray<RID> &p_exclude) {
+ parameters.exclude.clear();
+ for (int i = 0; i < p_exclude.size(); i++) {
+ parameters.exclude.insert(p_exclude[i]);
+ }
+}
+
+TypedArray<RID> PhysicsRayQueryParameters3D::get_exclude() const {
+ TypedArray<RID> ret;
+ ret.resize(parameters.exclude.size());
+ int idx = 0;
+ for (const RID &E : parameters.exclude) {
+ ret[idx++] = E;
+ }
+ return ret;
+}
+
+Ref<PhysicsRayQueryParameters3D> PhysicsRayQueryParameters3D::create(Vector3 p_from, Vector3 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude) {
+ Ref<PhysicsRayQueryParameters3D> params;
+ params.instantiate();
+ params->set_from(p_from);
+ params->set_to(p_to);
+ params->set_collision_mask(p_mask);
+ params->set_exclude(p_exclude);
+ return params;
+}
+
+void PhysicsRayQueryParameters3D::_bind_methods() {
+ ClassDB::bind_static_method("PhysicsRayQueryParameters3D", D_METHOD("create", "from", "to", "collision_mask", "exclude"), &PhysicsRayQueryParameters3D::create, DEFVAL(UINT32_MAX), DEFVAL(TypedArray<RID>()));
+
+ ClassDB::bind_method(D_METHOD("set_from", "from"), &PhysicsRayQueryParameters3D::set_from);
+ ClassDB::bind_method(D_METHOD("get_from"), &PhysicsRayQueryParameters3D::get_from);
+
+ ClassDB::bind_method(D_METHOD("set_to", "to"), &PhysicsRayQueryParameters3D::set_to);
+ ClassDB::bind_method(D_METHOD("get_to"), &PhysicsRayQueryParameters3D::get_to);
+
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsRayQueryParameters3D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsRayQueryParameters3D::get_collision_mask);
+
+ ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsRayQueryParameters3D::set_exclude);
+ ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsRayQueryParameters3D::get_exclude);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsRayQueryParameters3D::set_collide_with_bodies);
+ ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsRayQueryParameters3D::is_collide_with_bodies_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsRayQueryParameters3D::set_collide_with_areas);
+ ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsRayQueryParameters3D::is_collide_with_areas_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_hit_from_inside", "enable"), &PhysicsRayQueryParameters3D::set_hit_from_inside);
+ ClassDB::bind_method(D_METHOD("is_hit_from_inside_enabled"), &PhysicsRayQueryParameters3D::is_hit_from_inside_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_hit_back_faces", "enable"), &PhysicsRayQueryParameters3D::set_hit_back_faces);
+ ClassDB::bind_method(D_METHOD("is_hit_back_faces_enabled"), &PhysicsRayQueryParameters3D::is_hit_back_faces_enabled);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "from"), "set_from", "get_from");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "to"), "set_to", "get_to");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude", "get_exclude");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hit_from_inside"), "set_hit_from_inside", "is_hit_from_inside_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hit_back_faces"), "set_hit_back_faces", "is_hit_back_faces_enabled");
+}
diff --git a/servers/physics_3d/queries/physics_ray_query_parameters_3d.h b/servers/physics_3d/queries/physics_ray_query_parameters_3d.h
new file mode 100644
index 00000000000..5e9ce2d6ed7
--- /dev/null
+++ b/servers/physics_3d/queries/physics_ray_query_parameters_3d.h
@@ -0,0 +1,71 @@
+/**************************************************************************/
+/* physics_ray_query_parameters_3d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/object/ref_counted.h"
+#include "servers/physics_3d/physics_server_3d_types.h"
+
+class PhysicsRayQueryParameters3D : public RefCounted {
+ GDCLASS(PhysicsRayQueryParameters3D, RefCounted);
+
+ PS3DT::RayParameters parameters;
+
+protected:
+ static void _bind_methods();
+
+public:
+ static Ref<PhysicsRayQueryParameters3D> create(Vector3 p_from, Vector3 p_to, uint32_t p_mask, const TypedArray<RID> &p_exclude);
+ const PS3DT::RayParameters &get_parameters() const { return parameters; }
+
+ void set_from(const Vector3 &p_from) { parameters.from = p_from; }
+ const Vector3 &get_from() const { return parameters.from; }
+
+ void set_to(const Vector3 &p_to) { parameters.to = p_to; }
+ const Vector3 &get_to() const { return parameters.to; }
+
+ void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
+ uint32_t get_collision_mask() const { return parameters.collision_mask; }
+
+ void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
+ bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
+
+ void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
+ bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
+
+ void set_hit_from_inside(bool p_enable) { parameters.hit_from_inside = p_enable; }
+ bool is_hit_from_inside_enabled() const { return parameters.hit_from_inside; }
+
+ void set_hit_back_faces(bool p_enable) { parameters.hit_back_faces = p_enable; }
+ bool is_hit_back_faces_enabled() const { return parameters.hit_back_faces; }
+
+ void set_exclude(const TypedArray<RID> &p_exclude);
+ TypedArray<RID> get_exclude() const;
+};
diff --git a/servers/physics_3d/queries/physics_shape_query_parameters_3d.cpp b/servers/physics_3d/queries/physics_shape_query_parameters_3d.cpp
new file mode 100644
index 00000000000..e30dea98814
--- /dev/null
+++ b/servers/physics_3d/queries/physics_shape_query_parameters_3d.cpp
@@ -0,0 +1,108 @@
+/**************************************************************************/
+/* physics_shape_query_parameters_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 "physics_shape_query_parameters_3d.h"
+
+#include "core/io/resource.h"
+#include "core/object/class_db.h"
+#include "core/variant/typed_array.h"
+
+Ref<Resource> PhysicsShapeQueryParameters3D::get_shape() const {
+ return shape_ref;
+}
+
+void PhysicsShapeQueryParameters3D::set_shape(const Ref<Resource> &p_shape_ref) {
+ ERR_FAIL_COND(p_shape_ref.is_null());
+ shape_ref = p_shape_ref;
+ parameters.shape_rid = p_shape_ref->get_rid();
+}
+
+void PhysicsShapeQueryParameters3D::set_shape_rid(const RID &p_shape) {
+ if (parameters.shape_rid != p_shape) {
+ shape_ref = Ref<Resource>();
+ parameters.shape_rid = p_shape;
+ }
+}
+
+void PhysicsShapeQueryParameters3D::set_exclude(const TypedArray<RID> &p_exclude) {
+ parameters.exclude.clear();
+ for (int i = 0; i < p_exclude.size(); i++) {
+ parameters.exclude.insert(p_exclude[i]);
+ }
+}
+
+TypedArray<RID> PhysicsShapeQueryParameters3D::get_exclude() const {
+ TypedArray<RID> ret;
+ ret.resize(parameters.exclude.size());
+ int idx = 0;
+ for (const RID &E : parameters.exclude) {
+ ret[idx++] = E;
+ }
+ return ret;
+}
+
+void PhysicsShapeQueryParameters3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters3D::set_shape);
+ ClassDB::bind_method(D_METHOD("get_shape"), &PhysicsShapeQueryParameters3D::get_shape);
+
+ ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters3D::set_shape_rid);
+ ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters3D::get_shape_rid);
+
+ ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsShapeQueryParameters3D::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsShapeQueryParameters3D::get_transform);
+
+ ClassDB::bind_method(D_METHOD("set_motion", "motion"), &PhysicsShapeQueryParameters3D::set_motion);
+ ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsShapeQueryParameters3D::get_motion);
+
+ ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsShapeQueryParameters3D::set_margin);
+ ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsShapeQueryParameters3D::get_margin);
+
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsShapeQueryParameters3D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsShapeQueryParameters3D::get_collision_mask);
+
+ ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsShapeQueryParameters3D::set_exclude);
+ ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsShapeQueryParameters3D::get_exclude);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsShapeQueryParameters3D::set_collide_with_bodies);
+ ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsShapeQueryParameters3D::is_collide_with_bodies_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsShapeQueryParameters3D::set_collide_with_areas);
+ ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsShapeQueryParameters3D::is_collide_with_areas_enabled);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude", "get_exclude");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin", PROPERTY_HINT_RANGE, "0,100,0.01"), "set_margin", "get_margin");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "motion"), "set_motion", "get_motion");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape3D"), "set_shape", "get_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::RID, "shape_rid"), "set_shape_rid", "get_shape_rid");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "transform"), "set_transform", "get_transform");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
+}
diff --git a/servers/physics_3d/queries/physics_shape_query_parameters_3d.h b/servers/physics_3d/queries/physics_shape_query_parameters_3d.h
new file mode 100644
index 00000000000..e9aa9ded1fe
--- /dev/null
+++ b/servers/physics_3d/queries/physics_shape_query_parameters_3d.h
@@ -0,0 +1,77 @@
+/**************************************************************************/
+/* physics_shape_query_parameters_3d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/object/ref_counted.h"
+#include "servers/physics_3d/physics_server_3d_types.h"
+
+class Resource;
+
+class PhysicsShapeQueryParameters3D : public RefCounted {
+ GDCLASS(PhysicsShapeQueryParameters3D, RefCounted);
+
+ PS3DT::ShapeParameters parameters;
+
+ Ref<Resource> shape_ref;
+
+protected:
+ static void _bind_methods();
+
+public:
+ const PS3DT::ShapeParameters &get_parameters() const { return parameters; }
+
+ void set_shape(const Ref<Resource> &p_shape_ref);
+ Ref<Resource> get_shape() const;
+
+ void set_shape_rid(const RID &p_shape);
+ RID get_shape_rid() const { return parameters.shape_rid; }
+
+ void set_transform(const Transform3D &p_transform) { parameters.transform = p_transform; }
+ const Transform3D &get_transform() const { return parameters.transform; }
+
+ void set_motion(const Vector3 &p_motion) { parameters.motion = p_motion; }
+ const Vector3 &get_motion() const { return parameters.motion; }
+
+ void set_margin(real_t p_margin) { parameters.margin = p_margin; }
+ real_t get_margin() const { return parameters.margin; }
+
+ void set_collision_mask(uint32_t p_mask) { parameters.collision_mask = p_mask; }
+ uint32_t get_collision_mask() const { return parameters.collision_mask; }
+
+ void set_collide_with_bodies(bool p_enable) { parameters.collide_with_bodies = p_enable; }
+ bool is_collide_with_bodies_enabled() const { return parameters.collide_with_bodies; }
+
+ void set_collide_with_areas(bool p_enable) { parameters.collide_with_areas = p_enable; }
+ bool is_collide_with_areas_enabled() const { return parameters.collide_with_areas; }
+
+ void set_exclude(const TypedArray<RID> &p_exclude);
+ TypedArray<RID> get_exclude() const;
+};
diff --git a/servers/physics_3d/queries/physics_testmotion_query_parameters_3d.cpp b/servers/physics_3d/queries/physics_testmotion_query_parameters_3d.cpp
new file mode 100644
index 00000000000..45401408644
--- /dev/null
+++ b/servers/physics_3d/queries/physics_testmotion_query_parameters_3d.cpp
@@ -0,0 +1,109 @@
+/**************************************************************************/
+/* physics_testmotion_query_parameters_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 "physics_testmotion_query_parameters_3d.h"
+
+#include "core/object/class_db.h"
+#include "core/variant/typed_array.h"
+
+TypedArray<RID> PhysicsTestMotionParameters3D::get_exclude_bodies() const {
+ TypedArray<RID> exclude;
+ exclude.resize(parameters.exclude_bodies.size());
+
+ int body_index = 0;
+ for (const RID &body : parameters.exclude_bodies) {
+ exclude[body_index++] = body;
+ }
+
+ return exclude;
+}
+
+void PhysicsTestMotionParameters3D::set_exclude_bodies(const TypedArray<RID> &p_exclude) {
+ parameters.exclude_bodies.clear();
+ for (int i = 0; i < p_exclude.size(); i++) {
+ parameters.exclude_bodies.insert(p_exclude[i]);
+ }
+}
+
+TypedArray<uint64_t> PhysicsTestMotionParameters3D::get_exclude_objects() const {
+ TypedArray<uint64_t> exclude;
+ exclude.resize(parameters.exclude_objects.size());
+
+ int object_index = 0;
+ for (const ObjectID &object_id : parameters.exclude_objects) {
+ exclude[object_index++] = object_id;
+ }
+
+ return exclude;
+}
+
+void PhysicsTestMotionParameters3D::set_exclude_objects(const TypedArray<uint64_t> &p_exclude) {
+ parameters.exclude_objects.clear();
+ for (int i = 0; i < p_exclude.size(); ++i) {
+ ObjectID object_id = p_exclude[i];
+ ERR_CONTINUE(object_id.is_null());
+ parameters.exclude_objects.insert(object_id);
+ }
+}
+
+void PhysicsTestMotionParameters3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_from"), &PhysicsTestMotionParameters3D::get_from);
+ ClassDB::bind_method(D_METHOD("set_from", "from"), &PhysicsTestMotionParameters3D::set_from);
+
+ ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsTestMotionParameters3D::get_motion);
+ ClassDB::bind_method(D_METHOD("set_motion", "motion"), &PhysicsTestMotionParameters3D::set_motion);
+
+ ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsTestMotionParameters3D::get_margin);
+ ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsTestMotionParameters3D::set_margin);
+
+ ClassDB::bind_method(D_METHOD("get_max_collisions"), &PhysicsTestMotionParameters3D::get_max_collisions);
+ ClassDB::bind_method(D_METHOD("set_max_collisions", "max_collisions"), &PhysicsTestMotionParameters3D::set_max_collisions);
+
+ ClassDB::bind_method(D_METHOD("is_collide_separation_ray_enabled"), &PhysicsTestMotionParameters3D::is_collide_separation_ray_enabled);
+ ClassDB::bind_method(D_METHOD("set_collide_separation_ray_enabled", "enabled"), &PhysicsTestMotionParameters3D::set_collide_separation_ray_enabled);
+
+ ClassDB::bind_method(D_METHOD("get_exclude_bodies"), &PhysicsTestMotionParameters3D::get_exclude_bodies);
+ ClassDB::bind_method(D_METHOD("set_exclude_bodies", "exclude_list"), &PhysicsTestMotionParameters3D::set_exclude_bodies);
+
+ ClassDB::bind_method(D_METHOD("get_exclude_objects"), &PhysicsTestMotionParameters3D::get_exclude_objects);
+ ClassDB::bind_method(D_METHOD("set_exclude_objects", "exclude_list"), &PhysicsTestMotionParameters3D::set_exclude_objects);
+
+ ClassDB::bind_method(D_METHOD("is_recovery_as_collision_enabled"), &PhysicsTestMotionParameters3D::is_recovery_as_collision_enabled);
+ ClassDB::bind_method(D_METHOD("set_recovery_as_collision_enabled", "enabled"), &PhysicsTestMotionParameters3D::set_recovery_as_collision_enabled);
+
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "from"), "set_from", "get_from");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "motion"), "set_motion", "get_motion");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin"), "set_margin", "get_margin");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "max_collisions"), "set_max_collisions", "get_max_collisions");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_separation_ray"), "set_collide_separation_ray_enabled", "is_collide_separation_ray_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude_bodies", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_exclude_bodies", "get_exclude_bodies");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude_objects"), "set_exclude_objects", "get_exclude_objects");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "recovery_as_collision"), "set_recovery_as_collision_enabled", "is_recovery_as_collision_enabled");
+}
diff --git a/servers/physics_3d/queries/physics_testmotion_query_parameters_3d.h b/servers/physics_3d/queries/physics_testmotion_query_parameters_3d.h
new file mode 100644
index 00000000000..defc9242b7f
--- /dev/null
+++ b/servers/physics_3d/queries/physics_testmotion_query_parameters_3d.h
@@ -0,0 +1,70 @@
+/**************************************************************************/
+/* physics_testmotion_query_parameters_3d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/object/ref_counted.h"
+#include "servers/physics_3d/physics_server_3d_types.h"
+
+class PhysicsTestMotionParameters3D : public RefCounted {
+ GDCLASS(PhysicsTestMotionParameters3D, RefCounted);
+
+ PS3DT::MotionParameters parameters;
+
+protected:
+ static void _bind_methods();
+
+public:
+ const PS3DT::MotionParameters &get_parameters() const { return parameters; }
+
+ const Transform3D &get_from() const { return parameters.from; }
+ void set_from(const Transform3D &p_from) { parameters.from = p_from; }
+
+ const Vector3 &get_motion() const { return parameters.motion; }
+ void set_motion(const Vector3 &p_motion) { parameters.motion = p_motion; }
+
+ real_t get_margin() const { return parameters.margin; }
+ void set_margin(real_t p_margin) { parameters.margin = p_margin; }
+
+ int get_max_collisions() const { return parameters.max_collisions; }
+ void set_max_collisions(int p_max_collisions) { parameters.max_collisions = p_max_collisions; }
+
+ bool is_collide_separation_ray_enabled() const { return parameters.collide_separation_ray; }
+ void set_collide_separation_ray_enabled(bool p_enabled) { parameters.collide_separation_ray = p_enabled; }
+
+ TypedArray<RID> get_exclude_bodies() const;
+ void set_exclude_bodies(const TypedArray<RID> &p_exclude);
+
+ TypedArray<uint64_t> get_exclude_objects() const;
+ void set_exclude_objects(const TypedArray<uint64_t> &p_exclude);
+
+ bool is_recovery_as_collision_enabled() const { return parameters.recovery_as_collision; }
+ void set_recovery_as_collision_enabled(bool p_enabled) { parameters.recovery_as_collision = p_enabled; }
+};
diff --git a/servers/physics_3d/queries/physics_testmotion_query_result_3d.cpp b/servers/physics_3d/queries/physics_testmotion_query_result_3d.cpp
new file mode 100644
index 00000000000..7278a75e1ca
--- /dev/null
+++ b/servers/physics_3d/queries/physics_testmotion_query_result_3d.cpp
@@ -0,0 +1,115 @@
+/**************************************************************************/
+/* physics_testmotion_query_result_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 "physics_testmotion_query_result_3d.h"
+
+#include "core/object/class_db.h"
+
+Vector3 PhysicsTestMotionResult3D::get_travel() const {
+ return result.travel;
+}
+
+Vector3 PhysicsTestMotionResult3D::get_remainder() const {
+ return result.remainder;
+}
+
+real_t PhysicsTestMotionResult3D::get_collision_safe_fraction() const {
+ return result.collision_safe_fraction;
+}
+
+real_t PhysicsTestMotionResult3D::get_collision_unsafe_fraction() const {
+ return result.collision_unsafe_fraction;
+}
+
+int PhysicsTestMotionResult3D::get_collision_count() const {
+ return result.collision_count;
+}
+
+Vector3 PhysicsTestMotionResult3D::get_collision_point(int p_collision_index) const {
+ ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, Vector3());
+ return result.collisions[p_collision_index].position;
+}
+
+Vector3 PhysicsTestMotionResult3D::get_collision_normal(int p_collision_index) const {
+ ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, Vector3());
+ return result.collisions[p_collision_index].normal;
+}
+
+Vector3 PhysicsTestMotionResult3D::get_collider_velocity(int p_collision_index) const {
+ ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, Vector3());
+ return result.collisions[p_collision_index].collider_velocity;
+}
+
+ObjectID PhysicsTestMotionResult3D::get_collider_id(int p_collision_index) const {
+ ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, ObjectID());
+ return result.collisions[p_collision_index].collider_id;
+}
+
+RID PhysicsTestMotionResult3D::get_collider_rid(int p_collision_index) const {
+ ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, RID());
+ return result.collisions[p_collision_index].collider;
+}
+
+Object *PhysicsTestMotionResult3D::get_collider(int p_collision_index) const {
+ ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, nullptr);
+ return ObjectDB::get_instance(result.collisions[p_collision_index].collider_id);
+}
+
+int PhysicsTestMotionResult3D::get_collider_shape(int p_collision_index) const {
+ ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, 0);
+ return result.collisions[p_collision_index].collider_shape;
+}
+
+int PhysicsTestMotionResult3D::get_collision_local_shape(int p_collision_index) const {
+ ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, 0);
+ return result.collisions[p_collision_index].local_shape;
+}
+
+real_t PhysicsTestMotionResult3D::get_collision_depth(int p_collision_index) const {
+ ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, 0.0);
+ return result.collisions[p_collision_index].depth;
+}
+
+void PhysicsTestMotionResult3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_travel"), &PhysicsTestMotionResult3D::get_travel);
+ ClassDB::bind_method(D_METHOD("get_remainder"), &PhysicsTestMotionResult3D::get_remainder);
+ ClassDB::bind_method(D_METHOD("get_collision_safe_fraction"), &PhysicsTestMotionResult3D::get_collision_safe_fraction);
+ ClassDB::bind_method(D_METHOD("get_collision_unsafe_fraction"), &PhysicsTestMotionResult3D::get_collision_unsafe_fraction);
+ ClassDB::bind_method(D_METHOD("get_collision_count"), &PhysicsTestMotionResult3D::get_collision_count);
+ ClassDB::bind_method(D_METHOD("get_collision_point", "collision_index"), &PhysicsTestMotionResult3D::get_collision_point, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_collision_normal", "collision_index"), &PhysicsTestMotionResult3D::get_collision_normal, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_collider_velocity", "collision_index"), &PhysicsTestMotionResult3D::get_collider_velocity, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_collider_id", "collision_index"), &PhysicsTestMotionResult3D::get_collider_id, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_collider_rid", "collision_index"), &PhysicsTestMotionResult3D::get_collider_rid, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_collider", "collision_index"), &PhysicsTestMotionResult3D::get_collider, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_collider_shape", "collision_index"), &PhysicsTestMotionResult3D::get_collider_shape, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_collision_local_shape", "collision_index"), &PhysicsTestMotionResult3D::get_collision_local_shape, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_collision_depth", "collision_index"), &PhysicsTestMotionResult3D::get_collision_depth, DEFVAL(0));
+}
diff --git a/servers/physics_3d/queries/physics_testmotion_query_result_3d.h b/servers/physics_3d/queries/physics_testmotion_query_result_3d.h
new file mode 100644
index 00000000000..ee4fbea71af
--- /dev/null
+++ b/servers/physics_3d/queries/physics_testmotion_query_result_3d.h
@@ -0,0 +1,63 @@
+/**************************************************************************/
+/* physics_testmotion_query_result_3d.h */
+/**************************************************************************/
+/* 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. */
+/**************************************************************************/
+
+#pragma once
+
+#include "core/object/ref_counted.h"
+#include "servers/physics_3d/physics_server_3d_types.h"
+
+class PhysicsTestMotionResult3D : public RefCounted {
+ GDCLASS(PhysicsTestMotionResult3D, RefCounted);
+
+ PS3DT::MotionResult result;
+
+protected:
+ static void _bind_methods();
+
+public:
+ PS3DT::MotionResult *get_result_ptr() { return &result; }
+
+ Vector3 get_travel() const;
+ Vector3 get_remainder() const;
+ real_t get_collision_safe_fraction() const;
+ real_t get_collision_unsafe_fraction() const;
+
+ int get_collision_count() const;
+
+ Vector3 get_collision_point(int p_collision_index = 0) const;
+ Vector3 get_collision_normal(int p_collision_index = 0) const;
+ Vector3 get_collider_velocity(int p_collision_index = 0) const;
+ ObjectID get_collider_id(int p_collision_index = 0) const;
+ RID get_collider_rid(int p_collision_index = 0) const;
+ Object *get_collider(int p_collision_index = 0) const;
+ int get_collider_shape(int p_collision_index = 0) const;
+ int get_collision_local_shape(int p_collision_index = 0) const;
+ real_t get_collision_depth(int p_collision_index = 0) const;
+};
diff --git a/tests/scene/test_generic_6dof_joint_3d.cpp b/tests/scene/test_generic_6dof_joint_3d.cpp
index da967f66c14..ed31a8551b1 100644
--- a/tests/scene/test_generic_6dof_joint_3d.cpp
+++ b/tests/scene/test_generic_6dof_joint_3d.cpp
@@ -157,13 +157,13 @@ TEST_CASE("[SceneTree][PhysicsServer3D][Generic6DOFJoint3D] Drive force and torq
constexpr real_t angular_values[] = { 7.0, 8.0, 9.0 };
for (int i = 0; i < 3; i++) {
- physics_server->generic_6dof_joint_set_param(joint, axes[i], PhysicsServer3D::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT, linear_values[i]);
- physics_server->generic_6dof_joint_set_param(joint, axes[i], PhysicsServer3D::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT, angular_values[i]);
+ physics_server->generic_6dof_joint_set_param(joint, axes[i], PS3DE::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT, linear_values[i]);
+ physics_server->generic_6dof_joint_set_param(joint, axes[i], PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT, angular_values[i]);
}
for (int i = 0; i < 3; i++) {
- CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, axes[i], PhysicsServer3D::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT), doctest::Approx(linear_values[i]));
- CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, axes[i], PhysicsServer3D::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT), doctest::Approx(angular_values[i]));
+ CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, axes[i], PS3DE::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT), doctest::Approx(linear_values[i]));
+ CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, axes[i], PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT), doctest::Approx(angular_values[i]));
}
physics_server->free_rid(joint);
@@ -179,13 +179,13 @@ TEST_CASE("[SceneTree][PhysicsServer3D][Generic6DOFJoint3D] Drive force and torq
RID body_b;
RID joint = make_configured_generic_6dof_joint(physics_server, body_a, body_b);
- CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_X, PhysicsServer3D::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT), FLT_MAX);
- CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_Y, PhysicsServer3D::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT), FLT_MAX);
- CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_Z, PhysicsServer3D::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT), FLT_MAX);
+ CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_X, PS3DE::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT), FLT_MAX);
+ CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_Y, PS3DE::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT), FLT_MAX);
+ CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_Z, PS3DE::G6DOF_JOINT_LINEAR_DRIVE_FORCE_LIMIT), FLT_MAX);
- CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_X, PhysicsServer3D::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT), FLT_MAX);
- CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_Y, PhysicsServer3D::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT), FLT_MAX);
- CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_Z, PhysicsServer3D::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT), FLT_MAX);
+ CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_X, PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT), FLT_MAX);
+ CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_Y, PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT), FLT_MAX);
+ CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_Z, PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT), FLT_MAX);
physics_server->free_rid(joint);
physics_server->free_rid(body_a);
@@ -216,10 +216,10 @@ TEST_CASE("[SceneTree][PhysicsServer3D][Generic6DOFJoint3D] DRIVE FLT_MAX after
RID joint = make_configured_generic_6dof_joint(physics_server, body_a, body_b);
// Legacy motor limit set first, then explicit DRIVE FLT_MAX
- physics_server->generic_6dof_joint_set_param(joint, Vector3::AXIS_X, PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT, 50.0);
- physics_server->generic_6dof_joint_set_param(joint, Vector3::AXIS_X, PhysicsServer3D::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT, FLT_MAX);
+ physics_server->generic_6dof_joint_set_param(joint, Vector3::AXIS_X, PS3DE::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT, 50.0);
+ physics_server->generic_6dof_joint_set_param(joint, Vector3::AXIS_X, PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT, FLT_MAX);
- CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_X, PhysicsServer3D::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT), FLT_MAX);
+ CHECK_EQ(physics_server->generic_6dof_joint_get_param(joint, Vector3::AXIS_X, PS3DE::G6DOF_JOINT_ANGULAR_DRIVE_TORQUE_LIMIT), FLT_MAX);
physics_server->free_rid(joint);
physics_server->free_rid(body_a);