Merge pull request #108332 from WhalesState/templates

Fix remaining physics and navigation disabling issues.
This commit is contained in:
Thaddeus Crews
2025-07-15 08:04:22 -05:00
5 changed files with 28 additions and 11 deletions

View File

@@ -31,24 +31,27 @@
#include "grid_map.h"
#include "core/io/marshalls.h"
#include "core/math/convex_hull.h"
#include "core/templates/a_hash_map.h"
#include "scene/resources/3d/mesh_library.h"
#include "scene/resources/3d/primitive_meshes.h"
#include "scene/resources/surface_tool.h"
#include "servers/rendering_server.h"
#ifndef PHYSICS_3D_DISABLED
#include "core/math/convex_hull.h"
#include "scene/resources/3d/box_shape_3d.h"
#include "scene/resources/3d/capsule_shape_3d.h"
#include "scene/resources/3d/concave_polygon_shape_3d.h"
#include "scene/resources/3d/convex_polygon_shape_3d.h"
#include "scene/resources/3d/cylinder_shape_3d.h"
#include "scene/resources/3d/height_map_shape_3d.h"
#include "scene/resources/3d/mesh_library.h"
#include "scene/resources/3d/navigation_mesh_source_geometry_data_3d.h"
#include "scene/resources/3d/primitive_meshes.h"
#include "scene/resources/3d/shape_3d.h"
#include "scene/resources/3d/sphere_shape_3d.h"
#include "scene/resources/physics_material.h"
#include "scene/resources/surface_tool.h"
#include "servers/rendering_server.h"
#endif // PHYSICS_3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
#include "scene/resources/3d/navigation_mesh_source_geometry_data_3d.h"
#include "servers/navigation_server_3d.h"
Callable GridMap::_navmesh_source_geometry_parsing_callback;
@@ -1234,7 +1237,9 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("make_baked_meshes", "gen_lightmap_uv", "lightmap_uv_texel_size"), &GridMap::make_baked_meshes, DEFVAL(false), DEFVAL(0.1));
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh_library", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"), "set_mesh_library", "get_mesh_library");
#ifndef PHYSICS_3D_DISABLED
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material", "get_physics_material");
#endif // PHYSICS_3D_DISABLED
ADD_GROUP("Cell", "cell_");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "cell_size", PROPERTY_HINT_NONE, "suffix:m"), "set_cell_size", "get_cell_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_octant_size", PROPERTY_HINT_RANGE, "1,1024,1"), "set_octant_size", "get_octant_size");

View File

@@ -410,10 +410,10 @@ Vector<AudioFrame> AudioStreamPlayer3D::_update_panning() {
float dist = local_pos.length();
#ifndef PHYSICS_3D_DISABLED
Vector3 area_sound_pos;
Vector3 listener_area_pos;
#ifndef PHYSICS_3D_DISABLED
Area3D *area = _get_overriding_area();
if (area && area->is_using_reverb_bus() && area->get_reverb_uniformity() > 0) {
area_sound_pos = space_state->get_closest_point_to_object_volume(area->get_rid(), listener_node->get_global_transform().origin);

View File

@@ -1634,8 +1634,8 @@ void RuntimeNodeSelect::_root_window_input(const Ref<InputEvent> &p_event) {
if (camera_override) {
if (node_select_type == NODE_TYPE_2D) {
is_dragging_camera = panner->gui_input(p_event, Rect2(Vector2(), root->get_visible_rect().get_size()));
} else if (node_select_type == NODE_TYPE_3D && selection_drag_state == SELECTION_DRAG_NONE) {
#ifndef _3D_DISABLED
} else if (node_select_type == NODE_TYPE_3D && selection_drag_state == SELECTION_DRAG_NONE) {
if (_handle_3d_input(p_event)) {
return;
}
@@ -1807,8 +1807,8 @@ void RuntimeNodeSelect::_physics_frame() {
}
}
}
} else if (node_select_type == NODE_TYPE_3D) {
#ifndef _3D_DISABLED
} else if (node_select_type == NODE_TYPE_3D) {
if (selection_drag_valid) {
_find_3d_items_at_rect(selection_drag_area, items);
} else {
@@ -2175,7 +2175,7 @@ void RuntimeNodeSelect::_update_selection() {
if (visual_instance) {
bounds = visual_instance->get_aabb();
} else {
#ifndef PHYSICS_2D_DISABLED
#ifndef PHYSICS_3D_DISABLED
CollisionShape3D *collision_shape = Object::cast_to<CollisionShape3D>(node_3d);
if (collision_shape) {
Ref<Shape3D> shape = collision_shape->get_shape();
@@ -2183,7 +2183,7 @@ void RuntimeNodeSelect::_update_selection() {
bounds = shape->get_debug_mesh()->get_aabb();
}
}
#endif // PHYSICS_2D_DISABLED
#endif // PHYSICS_3D_DISABLED
}
Transform3D xform_to_top_level_parent_space = node_3d->get_global_transform().affine_inverse() * node_3d->get_global_transform();

View File

@@ -34,7 +34,9 @@
#include "scene/3d/camera_3d.h"
#include "scene/resources/camera_attributes.h"
#include "scene/resources/environment.h"
#ifndef NAVIGATION_3D_DISABLED
#include "servers/navigation_server_3d.h"
#endif // NAVIGATION_3D_DISABLED
void World3D::_register_camera(Camera3D *p_camera) {
cameras.insert(p_camera);
@@ -58,6 +60,7 @@ RID World3D::get_space() const {
return space;
}
#ifndef NAVIGATION_3D_DISABLED
RID World3D::get_navigation_map() const {
if (navigation_map.is_null()) {
navigation_map = NavigationServer3D::get_singleton()->map_create();
@@ -72,6 +75,7 @@ RID World3D::get_navigation_map() const {
}
return navigation_map;
}
#endif // NAVIGATION_3D_DISABLED
RID World3D::get_scenario() const {
return scenario;
@@ -149,7 +153,9 @@ PhysicsDirectSpaceState3D *World3D::get_direct_space_state() {
void World3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_space"), &World3D::get_space);
#ifndef NAVIGATION_3D_DISABLED
ClassDB::bind_method(D_METHOD("get_navigation_map"), &World3D::get_navigation_map);
#endif // NAVIGATION_3D_DISABLED
ClassDB::bind_method(D_METHOD("get_scenario"), &World3D::get_scenario);
ClassDB::bind_method(D_METHOD("set_environment", "env"), &World3D::set_environment);
ClassDB::bind_method(D_METHOD("get_environment"), &World3D::get_environment);
@@ -164,7 +170,9 @@ void World3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fallback_environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), "set_fallback_environment", "get_fallback_environment");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "camera_attributes", PROPERTY_HINT_RESOURCE_TYPE, "CameraAttributesPractical,CameraAttributesPhysical"), "set_camera_attributes", "get_camera_attributes");
ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_space");
#ifndef NAVIGATION_3D_DISABLED
ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_navigation_map");
#endif // NAVIGATION_3D_DISABLED
ADD_PROPERTY(PropertyInfo(Variant::RID, "scenario", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_scenario");
#ifndef PHYSICS_3D_DISABLED
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState3D", PROPERTY_USAGE_NONE), "", "get_direct_space_state");

View File

@@ -48,7 +48,9 @@ class World3D : public Resource {
private:
RID scenario;
mutable RID space;
#ifndef NAVIGATION_3D_DISABLED
mutable RID navigation_map;
#endif // NAVIGATION_3D_DISABLED
Ref<Environment> environment;
Ref<Environment> fallback_environment;
@@ -67,7 +69,9 @@ protected:
public:
RID get_space() const;
#ifndef NAVIGATION_3D_DISABLED
RID get_navigation_map() const;
#endif // NAVIGATION_3D_DISABLED
RID get_scenario() const;
void set_environment(const Ref<Environment> &p_environment);