feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -32,14 +32,31 @@
#include "core/config/project_settings.h"
#include "scene/2d/visible_on_screen_notifier_2d.h"
#include "servers/navigation_server_2d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
#ifndef NAVIGATION_2D_DISABLED
#include "servers/navigation_server_2d.h"
#endif // NAVIGATION_2D_DISABLED
RID World2D::get_canvas() const {
return canvas;
}
#ifndef NAVIGATION_2D_DISABLED
RID World2D::get_navigation_map() const {
if (navigation_map.is_null()) {
navigation_map = NavigationServer2D::get_singleton()->map_create();
NavigationServer2D::get_singleton()->map_set_active(navigation_map, true);
NavigationServer2D::get_singleton()->map_set_cell_size(navigation_map, GLOBAL_GET("navigation/2d/default_cell_size"));
NavigationServer2D::get_singleton()->map_set_use_edge_connections(navigation_map, GLOBAL_GET("navigation/2d/use_edge_connections"));
NavigationServer2D::get_singleton()->map_set_edge_connection_margin(navigation_map, GLOBAL_GET("navigation/2d/default_edge_connection_margin"));
NavigationServer2D::get_singleton()->map_set_link_connection_radius(navigation_map, GLOBAL_GET("navigation/2d/default_link_connection_radius"));
}
return navigation_map;
}
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_2D_DISABLED
RID World2D::get_space() const {
if (space.is_null()) {
space = PhysicsServer2D::get_singleton()->space_create();
@ -52,33 +69,26 @@ RID World2D::get_space() const {
return space;
}
RID World2D::get_navigation_map() const {
if (navigation_map.is_null()) {
navigation_map = NavigationServer2D::get_singleton()->map_create();
NavigationServer2D::get_singleton()->map_set_active(navigation_map, true);
NavigationServer2D::get_singleton()->map_set_cell_size(navigation_map, GLOBAL_GET("navigation/2d/default_cell_size"));
NavigationServer2D::get_singleton()->map_set_use_edge_connections(navigation_map, GLOBAL_GET("navigation/2d/use_edge_connections"));
NavigationServer2D::get_singleton()->map_set_edge_connection_margin(navigation_map, GLOBAL_GET("navigation/2d/default_edge_connection_margin"));
NavigationServer2D::get_singleton()->map_set_link_connection_radius(navigation_map, GLOBAL_GET("navigation/2d/default_link_connection_radius"));
}
return navigation_map;
}
PhysicsDirectSpaceState2D *World2D::get_direct_space_state() {
return PhysicsServer2D::get_singleton()->space_get_direct_state(get_space());
}
#endif // PHYSICS_2D_DISABLED
void World2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_canvas"), &World2D::get_canvas);
ClassDB::bind_method(D_METHOD("get_space"), &World2D::get_space);
ClassDB::bind_method(D_METHOD("get_navigation_map"), &World2D::get_navigation_map);
ClassDB::bind_method(D_METHOD("get_direct_space_state"), &World2D::get_direct_space_state);
ADD_PROPERTY(PropertyInfo(Variant::RID, "canvas", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_canvas");
ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_space");
#ifndef NAVIGATION_2D_DISABLED
ClassDB::bind_method(D_METHOD("get_navigation_map"), &World2D::get_navigation_map);
ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_navigation_map");
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_2D_DISABLED
ClassDB::bind_method(D_METHOD("get_space"), &World2D::get_space);
ClassDB::bind_method(D_METHOD("get_direct_space_state"), &World2D::get_direct_space_state);
ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_space");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState2D", PROPERTY_USAGE_NONE), "", "get_direct_space_state");
#endif // PHYSICS_2D_DISABLED
}
void World2D::register_viewport(Viewport *p_viewport) {
@ -95,13 +105,19 @@ World2D::World2D() {
World2D::~World2D() {
ERR_FAIL_NULL(RenderingServer::get_singleton());
ERR_FAIL_NULL(PhysicsServer2D::get_singleton());
ERR_FAIL_NULL(NavigationServer2D::get_singleton());
RenderingServer::get_singleton()->free(canvas);
if (space.is_valid()) {
PhysicsServer2D::get_singleton()->free(space);
}
#ifndef NAVIGATION_2D_DISABLED
ERR_FAIL_NULL(NavigationServer2D::get_singleton());
if (navigation_map.is_valid()) {
NavigationServer2D::get_singleton()->free(navigation_map);
}
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_2D_DISABLED
ERR_FAIL_NULL(PhysicsServer2D::get_singleton());
if (space.is_valid()) {
PhysicsServer2D::get_singleton()->free(space);
}
#endif // PHYSICS_2D_DISABLED
}