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

Allow to compile templates without physics servers

This commit is contained in:
Michael Alexsander
2025-02-27 19:01:23 -03:00
parent b13c96b097
commit 5ad414d046
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;
@@ -1924,6 +1931,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();
@@ -1931,6 +1939,7 @@ void RuntimeNodeSelect::_update_selection() {
rect = shape->get_rect();
}
}
#endif // PHYSICS_2D_DISABLED
}
const Vector2 endpoints[4] = {
@@ -1963,6 +1972,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();
@@ -1970,6 +1980,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();
@@ -2165,6 +2176,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)) {
@@ -2176,6 +2188,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
}
}
@@ -2307,6 +2320,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;
@@ -2342,6 +2356,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());
@@ -2445,6 +2460,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();
@@ -2476,6 +2492,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());