Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions editor/scene/3d/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions editor/scene/3d/node_3d_editor_viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.

Expand Down
8 changes: 4 additions & 4 deletions editor/scene/3d/path_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions main/performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions modules/csg/csg_shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand All @@ -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;
Expand Down
60 changes: 30 additions & 30 deletions modules/godot_physics_2d/godot_area_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,72 +112,72 @@ 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();
r_mode = p_new_mode;
_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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 8 additions & 7 deletions modules/godot_physics_2d/godot_area_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -111,8 +112,8 @@ class GodotArea2D : public GodotCollisionObject2D {
_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; }
Expand Down
8 changes: 4 additions & 4 deletions modules/godot_physics_2d/godot_area_pair_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
Loading