1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Merge pull request #103373 from YeldhamDev/build_remove_physics

Allow to compile templates without physics servers
This commit is contained in:
Rémi Verschelde
2025-03-28 17:30:03 +01:00
72 changed files with 951 additions and 364 deletions

View File

@@ -36,16 +36,6 @@
#include "core/math/math_fieldwise.h"
#include "core/object/script_language.h"
#include "core/templates/local_vector.h"
#include "scene/2d/physics/collision_object_2d.h"
#include "scene/2d/physics/collision_polygon_2d.h"
#include "scene/2d/physics/collision_shape_2d.h"
#ifndef _3D_DISABLED
#include "scene/3d/physics/collision_object_3d.h"
#include "scene/3d/physics/collision_shape_3d.h"
#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/3d/convex_polygon_shape_3d.h"
#include "scene/resources/surface_tool.h"
#endif // _3D_DISABLED
#include "scene/gui/popup_menu.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/scene_tree.h"
@@ -54,6 +44,23 @@
#include "scene/theme/theme_db.h"
#include "servers/audio_server.h"
#ifndef PHYSICS_2D_DISABLED
#include "scene/2d/physics/collision_object_2d.h"
#include "scene/2d/physics/collision_polygon_2d.h"
#include "scene/2d/physics/collision_shape_2d.h"
#endif // PHYSICS_2D_DISABLED
#ifndef _3D_DISABLED
#include "scene/3d/camera_3d.h"
#ifndef PHYSICS_3D_DISABLED
#include "scene/3d/physics/collision_object_3d.h"
#include "scene/3d/physics/collision_shape_3d.h"
#endif // PHYSICS_3D_DISABLED
#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/3d/convex_polygon_shape_3d.h"
#include "scene/resources/surface_tool.h"
#endif // _3D_DISABLED
SceneDebugger::SceneDebugger() {
singleton = this;
@@ -1921,6 +1928,7 @@ void RuntimeNodeSelect::_update_selection() {
if (ci->_edit_use_rect()) {
rect = ci->_edit_get_rect();
} else {
#ifndef PHYSICS_2D_DISABLED
CollisionShape2D *collision_shape = Object::cast_to<CollisionShape2D>(ci);
if (collision_shape) {
Ref<Shape2D> shape = collision_shape->get_shape();
@@ -1928,6 +1936,7 @@ void RuntimeNodeSelect::_update_selection() {
rect = shape->get_rect();
}
}
#endif // PHYSICS_2D_DISABLED
}
const Vector2 endpoints[4] = {
@@ -1960,6 +1969,7 @@ void RuntimeNodeSelect::_update_selection() {
if (visual_instance) {
bounds = visual_instance->get_aabb();
} else {
#ifndef PHYSICS_2D_DISABLED
CollisionShape3D *collision_shape = Object::cast_to<CollisionShape3D>(node_3d);
if (collision_shape) {
Ref<Shape3D> shape = collision_shape->get_shape();
@@ -1967,6 +1977,7 @@ void RuntimeNodeSelect::_update_selection() {
bounds = shape->get_debug_mesh()->get_aabb();
}
}
#endif // PHYSICS_2D_DISABLED
}
Transform3D xform_to_top_level_parent_space = node_3d->get_global_transform().affine_inverse() * node_3d->get_global_transform();
@@ -2162,6 +2173,7 @@ void RuntimeNodeSelect::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_n
res.order = ci->get_effective_z_index() + ci->get_canvas_layer();
r_items.push_back(res);
#ifndef PHYSICS_2D_DISABLED
// If it's a shape, get the collision object it's from.
// FIXME: If the collision object has multiple shapes, only the topmost will be above it in the list.
if (Object::cast_to<CollisionShape2D>(ci) || Object::cast_to<CollisionPolygon2D>(ci)) {
@@ -2173,6 +2185,7 @@ void RuntimeNodeSelect::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_n
r_items.push_back(res_col);
}
}
#endif // PHYSICS_2D_DISABLED
}
}
@@ -2304,6 +2317,7 @@ void RuntimeNodeSelect::_find_3d_items_at_pos(const Point2 &p_pos, Vector<Select
to = pos + ray * camera->get_far();
}
#ifndef PHYSICS_3D_DISABLED
// Start with physical objects.
PhysicsDirectSpaceState3D *ss = root->get_world_3d()->get_direct_space_state();
PhysicsDirectSpaceState3D::RayResult result;
@@ -2339,6 +2353,7 @@ void RuntimeNodeSelect::_find_3d_items_at_pos(const Point2 &p_pos, Vector<Select
break;
}
}
#endif // PHYSICS_3D_DISABLED
// Then go for the meshes.
Vector<ObjectID> items = RS::get_singleton()->instances_cull_ray(pos, to, root->get_world_3d()->get_scenario());
@@ -2442,6 +2457,7 @@ void RuntimeNodeSelect::_find_3d_items_at_rect(const Rect2 &p_rect, Vector<Selec
far_plane.d += zfar;
frustum.push_back(far_plane);
#ifndef PHYSICS_3D_DISABLED
Vector<Vector3> points = Geometry3D::compute_convex_mesh_points(&frustum[0], frustum.size());
Ref<ConvexPolygonShape3D> shape;
shape.instantiate();
@@ -2473,6 +2489,7 @@ void RuntimeNodeSelect::_find_3d_items_at_rect(const Rect2 &p_rect, Vector<Selec
r_items.push_back(res);
}
#endif // PHYSICS_3D_DISABLED
// Then go for the meshes.
Vector<ObjectID> items = RS::get_singleton()->instances_cull_convex(frustum, root->get_world_3d()->get_scenario());