Godot Engine – Multi-platform 2D and 3D game engine
Make templates be compilable when `disable_physics_3d` is enabled
Michael Alexsanderfab89847ada0
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cppindex fffbec32eea..e4b33b57ab6 100644--- a/modules/csg/csg_shape.cpp+++ b/modules/csg/csg_shape.cpp@@ -38,7 +38,10 @@#include "scene/resources/3d/navigation_mesh_source_geometry_data_3d.h"#include "scene/resources/navigation_mesh.h"#include "scene/resources/surface_tool.h"-#include "servers/rendering/rendering_server.h"++#ifndef PHYSICS_3D_DISABLED+#include "servers/rendering/rendering_server.h" // Only used for debug collision shapes.+#endif // PHYSICS_3D_DISABLED#ifdef DEV_ENABLED#include "core/io/json.h"diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.hindex b7324033dba..00a4dc04091 100644--- a/modules/csg/csg_shape.h+++ b/modules/csg/csg_shape.h@@ -134,6 +134,7 @@ public:virtual AABB get_aabb() const override;+#ifndef PHYSICS_3D_DISABLEDvoid set_use_collision(bool p_enable);bool is_using_collision() const;@@ -159,6 +160,7 @@ public:void set_smoothing_angle(const float p_angle);float get_smoothing_angle() const;+#endif // PHYSICS_3D_DISABLED#ifndef DISABLE_DEPRECATEDvoid set_snap(float p_snap);diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cppindex 9c2a07497e5..95e1c362e9a 100644--- a/modules/gridmap/grid_map.cpp+++ b/modules/gridmap/grid_map.cpp@@ -558,7 +558,7 @@ void GridMap::set_cell_item(const Vector3i &p_position, int p_item, int p_rot) {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;switch (collision_visibility_mode) {case DEBUG_VISIBILITY_MODE_DEFAULT: {@@ -577,6 +577,7 @@ void GridMap::set_cell_item(const Vector3i &p_position, int p_item, int p_rot) {g->collision_debug_instance = RS::get_singleton()->instance_create();RS::get_singleton()->instance_set_base(g->collision_debug_instance, g->collision_debug);}+#endif // PHYSICS_3D_DISABLEDoctant_map[octantkey] = g;diff --git a/modules/openxr/extensions/spatial_entities/openxr_spatial_plane_tracking.cpp b/modules/openxr/extensions/spatial_entities/openxr_spatial_plane_tracking.cppindex f5900995e97..d065c65b9a2 100644--- a/modules/openxr/extensions/spatial_entities/openxr_spatial_plane_tracking.cpp+++ b/modules/openxr/extensions/spatial_entities/openxr_spatial_plane_tracking.cpp@@ -36,11 +36,14 @@#include "core/config/project_settings.h"#include "core/object/callable_mp.h"#include "core/object/class_db.h"-#include "scene/resources/3d/box_shape_3d.h"-#include "scene/resources/3d/concave_polygon_shape_3d.h"#include "scene/resources/3d/primitive_meshes.h"#include "servers/xr/xr_server.h"+#ifndef PHYSICS_3D_DISABLED+#include "scene/resources/3d/box_shape_3d.h"+#include "scene/resources/3d/concave_polygon_shape_3d.h"+#endif+////////////////////////////////////////////////////////////////////////////// OpenXRSpatialCapabilityConfigurationPlaneTracking@@ -285,7 +288,9 @@ void OpenXRPlaneTracker::_bind_methods() {ClassDB::bind_method(D_METHOD("get_mesh_offset"), &OpenXRPlaneTracker::get_mesh_offset);ClassDB::bind_method(D_METHOD("get_mesh"), &OpenXRPlaneTracker::get_mesh);+#ifndef PHYSICS_3D_DISABLEDClassDB::bind_method(D_METHOD("get_shape", "thickness"), &OpenXRPlaneTracker::get_shape, DEFVAL(0.01));+#endifADD_SIGNAL(MethodInfo("mesh_changed"));}@@ -390,7 +395,9 @@ void OpenXRPlaneTracker::set_mesh_data(const Transform3D &p_origin, const Packedif (has_changed) {mesh.mesh.unref();+#ifndef PHYSICS_3D_DISABLEDmesh.shape3d.unref();+#endifemit_signal(SNAME("mesh_changed"));}@@ -399,7 +406,9 @@ void OpenXRPlaneTracker::set_mesh_data(const Transform3D &p_origin, const Packedvoid OpenXRPlaneTracker::clear_mesh_data() {mesh.mesh.unref();+#ifndef PHYSICS_3D_DISABLEDmesh.shape3d.unref();+#endifif (mesh.has_mesh_data) {mesh.has_mesh_data = false;@@ -479,6 +488,7 @@ Ref<Mesh> OpenXRPlaneTracker::get_mesh() {return mesh.mesh;}+#ifndef PHYSICS_3D_DISABLEDRef<Shape3D> OpenXRPlaneTracker::get_shape(real_t p_thickness) {// We've already created this? Just return it!if (mesh.shape3d.is_valid()) {@@ -567,6 +577,7 @@ Ref<Shape3D> OpenXRPlaneTracker::get_shape(real_t p_thickness) {return mesh.shape3d;}+#endif // PHYSICS_3D_DISABLED////////////////////////////////////////////////////////////////////////////// OpenXRSpatialPlaneTrackingCapabilitydiff --git a/modules/openxr/extensions/spatial_entities/openxr_spatial_plane_tracking.h b/modules/openxr/extensions/spatial_entities/openxr_spatial_plane_tracking.hindex da80e8a6b0c..18ae70f8552 100644--- a/modules/openxr/extensions/spatial_entities/openxr_spatial_plane_tracking.h+++ b/modules/openxr/extensions/spatial_entities/openxr_spatial_plane_tracking.h@@ -34,7 +34,9 @@#include "../openxr_future_extension.h"#include "openxr_spatial_entities.h"+#ifndef PHYSICS_3D_DISABLED#include "scene/resources/3d/shape_3d.h"+#endif// Plane tracking capability configurationclass OpenXRSpatialCapabilityConfigurationPlaneTracking : public OpenXRSpatialCapabilityConfigurationBaseHeader {@@ -166,7 +168,9 @@ public:Transform3D get_mesh_offset() const;Ref<Mesh> get_mesh();+#ifndef PHYSICS_3D_DISABLEDRef<Shape3D> get_shape(real_t p_thickness = 0.01);+#endifprotected:static void _bind_methods();@@ -184,7 +188,9 @@ private:PackedInt32Array indices;Ref<Mesh> mesh;+#ifndef PHYSICS_3D_DISABLEDRef<Shape3D> shape3d;+#endif} mesh;struct Edge {diff --git a/scene/2d/tile_map_layer.cpp b/scene/2d/tile_map_layer.cppindex 5dcab7b1e9a..e57a280d343 100644--- a/scene/2d/tile_map_layer.cpp+++ b/scene/2d/tile_map_layer.cpp@@ -40,7 +40,6 @@#include "scene/2d/tile_map.h"#include "scene/gui/control.h"#include "scene/main/scene_tree.h"-#include "scene/resources/2d/navigation_mesh_source_geometry_data_2d.h"#include "scene/resources/material.h"#include "scene/resources/world_2d.h"#include "servers/rendering/rendering_server.h"@@ -50,6 +49,7 @@#endif // PHYSICS_3D_DISABLED#ifndef NAVIGATION_2D_DISABLED+#include "scene/resources/2d/navigation_mesh_source_geometry_data_2d.h"#include "servers/navigation_2d/navigation_server_2d.h"Callable TileMapLayer::_navmesh_source_geometry_parsing_callback;RID TileMapLayer::_navmesh_source_geometry_parser;diff --git a/scene/resources/3d/mesh_library.cpp b/scene/resources/3d/mesh_library.cppindex 52f9351e48e..3f81fec76d7 100644--- a/scene/resources/3d/mesh_library.cpp+++ b/scene/resources/3d/mesh_library.cpp@@ -356,24 +356,34 @@ void MeshLibrary::_bind_methods() {ClassDB::bind_method(D_METHOD("set_item_mesh", "id", "mesh"), &MeshLibrary::set_item_mesh);ClassDB::bind_method(D_METHOD("set_item_mesh_transform", "id", "mesh_transform"), &MeshLibrary::set_item_mesh_transform);ClassDB::bind_method(D_METHOD("set_item_mesh_cast_shadow", "id", "shadow_casting_setting"), &MeshLibrary::set_item_mesh_cast_shadow);++#ifndef NAVIGATION_3D_DISABLEDClassDB::bind_method(D_METHOD("set_item_navigation_mesh", "id", "navigation_mesh"), &MeshLibrary::set_item_navigation_mesh);ClassDB::bind_method(D_METHOD("set_item_navigation_mesh_transform", "id", "navigation_mesh"), &MeshLibrary::set_item_navigation_mesh_transform);ClassDB::bind_method(D_METHOD("set_item_navigation_layers", "id", "navigation_layers"), &MeshLibrary::set_item_navigation_layers);+#endif // NAVIGATION_3D_DISABLED+#ifndef PHYSICS_3D_DISABLEDClassDB::bind_method(D_METHOD("set_item_shapes", "id", "shapes"), &MeshLibrary::_set_item_shapes);#endif // PHYSICS_3D_DISABLED+ClassDB::bind_method(D_METHOD("set_item_preview", "id", "texture"), &MeshLibrary::set_item_preview);ClassDB::bind_method(D_METHOD("get_item_name", "id"), &MeshLibrary::get_item_name);ClassDB::bind_method(D_METHOD("get_item_category", "id"), &MeshLibrary::get_item_category);ClassDB::bind_method(D_METHOD("get_item_mesh", "id"), &MeshLibrary::get_item_mesh);ClassDB::bind_method(D_METHOD("get_item_mesh_transform", "id"), &MeshLibrary::get_item_mesh_transform);ClassDB::bind_method(D_METHOD("get_item_mesh_cast_shadow", "id"), &MeshLibrary::get_item_mesh_cast_shadow);++#ifndef NAVIGATION_3D_DISABLEDClassDB::bind_method(D_METHOD("get_item_navigation_mesh", "id"), &MeshLibrary::get_item_navigation_mesh);ClassDB::bind_method(D_METHOD("get_item_navigation_mesh_transform", "id"), &MeshLibrary::get_item_navigation_mesh_transform);ClassDB::bind_method(D_METHOD("get_item_navigation_layers", "id"), &MeshLibrary::get_item_navigation_layers);+#endif // NAVIGATION_3D_DISABLED+#ifndef PHYSICS_3D_DISABLEDClassDB::bind_method(D_METHOD("get_item_shapes", "id"), &MeshLibrary::_get_item_shapes);#endif // PHYSICS_3D_DISABLED+ClassDB::bind_method(D_METHOD("get_item_preview", "id"), &MeshLibrary::get_item_preview);ClassDB::bind_method(D_METHOD("remove_item", "id"), &MeshLibrary::remove_item);ClassDB::bind_method(D_METHOD("find_item_by_name", "name"), &MeshLibrary::find_item_by_name);@@ -392,12 +402,17 @@ void MeshLibrary::_bind_methods() {base_property_helper.register_property(PropertyInfo(Variant::OBJECT, PNAME("mesh"), PROPERTY_HINT_RESOURCE_TYPE, Mesh::get_class_static(), PROPERTY_USAGE_NO_EDITOR), defaults.mesh, &MeshLibrary::set_item_mesh, &MeshLibrary::get_item_mesh);base_property_helper.register_property(PropertyInfo(Variant::TRANSFORM3D, PNAME("mesh_transform"), PROPERTY_HINT_NONE, "suffix:m", PROPERTY_USAGE_NO_EDITOR), defaults.mesh_transform, &MeshLibrary::set_item_mesh_transform, &MeshLibrary::get_item_mesh_transform);base_property_helper.register_property(PropertyInfo(Variant::INT, PNAME("mesh_cast_shadow"), PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only", PROPERTY_USAGE_NO_EDITOR), defaults.mesh_cast_shadow, &MeshLibrary::set_item_mesh_cast_shadow, &MeshLibrary::get_item_mesh_cast_shadow);+#ifndef PHYSICS_3D_DISABLEDbase_property_helper.register_property(PropertyInfo(Variant::ARRAY, PNAME("shapes"), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), Array(), &MeshLibrary::_set_item_shapes, &MeshLibrary::_get_item_shapes);#endif // PHYSICS_3D_DISABLED++#ifndef NAVIGATION_3D_DISABLEDbase_property_helper.register_property(PropertyInfo(Variant::OBJECT, PNAME("navigation_mesh"), PROPERTY_HINT_RESOURCE_TYPE, NavigationMesh::get_class_static(), PROPERTY_USAGE_NO_EDITOR), defaults.navigation_mesh, &MeshLibrary::set_item_navigation_mesh, &MeshLibrary::get_item_navigation_mesh);base_property_helper.register_property(PropertyInfo(Variant::TRANSFORM3D, PNAME("navigation_mesh_transform"), PROPERTY_HINT_NONE, "suffix:m", PROPERTY_USAGE_NO_EDITOR), defaults.navigation_mesh_transform, &MeshLibrary::set_item_mesh_transform, &MeshLibrary::get_item_mesh_transform);base_property_helper.register_property(PropertyInfo(Variant::INT, PNAME("navigation_layers"), PROPERTY_HINT_LAYERS_3D_NAVIGATION, "", PROPERTY_USAGE_NO_EDITOR), defaults.navigation_layers, &MeshLibrary::set_item_navigation_layers, &MeshLibrary::get_item_navigation_layers);+#endif // NAVIGATION_3D_DISABLED+base_property_helper.register_property(PropertyInfo(Variant::OBJECT, PNAME("preview"), PROPERTY_HINT_RESOURCE_TYPE, Texture2D::get_class_static(), PROPERTY_USAGE_NO_EDITOR), defaults.preview, &MeshLibrary::set_item_preview, &MeshLibrary::get_item_preview);PropertyListHelper::register_base_helper(get_class_static(), &base_property_helper);}diff --git a/scene/resources/3d/mesh_library.h b/scene/resources/3d/mesh_library.hindex 2320b572fed..a1d59132fa9 100644--- a/scene/resources/3d/mesh_library.h+++ b/scene/resources/3d/mesh_library.h@@ -100,9 +100,12 @@ public:void set_item_mesh(int p_item, const Ref<Mesh> &p_mesh);void set_item_mesh_transform(int p_item, const Transform3D &p_transform);void set_item_mesh_cast_shadow(int p_item, RSE::ShadowCastingSetting p_shadow_casting_setting);+#ifndef NAVIGATION_3D_DISABLEDvoid set_item_navigation_mesh(int p_item, const Ref<NavigationMesh> &p_navigation_mesh);void set_item_navigation_mesh_transform(int p_item, const Transform3D &p_transform);void set_item_navigation_layers(int p_item, uint32_t p_navigation_layers);+#endif // NAVIGATION_3D_DISABLED+#ifndef PHYSICS_3D_DISABLEDvoid set_item_shapes(int p_item, const Vector<ShapeData> &p_shapes);#endif // PHYSICS_3D_DISABLED