Reorganize some code to have 2D things grouped together

This commit is contained in:
Aaron Franke 2022-10-01 16:02:46 -05:00
parent 2886511c18
commit 6dd4a68797
No known key found for this signature in database
GPG Key ID: 40A1750B977E56BF
6 changed files with 94 additions and 91 deletions

View File

@ -297,6 +297,7 @@ private:
}; };
HashMap<BoneKey, BoneList> bone_list; HashMap<BoneKey, BoneList> bone_list;
MenuButton *skeleton_menu = nullptr;
struct PoseClipboard { struct PoseClipboard {
Vector2 pos; Vector2 pos;
@ -329,7 +330,6 @@ private:
Button *group_button = nullptr; Button *group_button = nullptr;
Button *ungroup_button = nullptr; Button *ungroup_button = nullptr;
MenuButton *skeleton_menu = nullptr;
Button *override_camera_button = nullptr; Button *override_camera_button = nullptr;
MenuButton *view_menu = nullptr; MenuButton *view_menu = nullptr;
PopupMenu *grid_menu = nullptr; PopupMenu *grid_menu = nullptr;

View File

@ -2317,15 +2317,15 @@ void SpriteFramesEditorPlugin::edit(Object *p_object) {
} }
bool SpriteFramesEditorPlugin::handles(Object *p_object) const { bool SpriteFramesEditorPlugin::handles(Object *p_object) const {
AnimatedSprite2D *animated_sprite = Object::cast_to<AnimatedSprite2D>(p_object); AnimatedSprite2D *animated_sprite_2d = Object::cast_to<AnimatedSprite2D>(p_object);
AnimatedSprite3D *animated_sprite_3d = Object::cast_to<AnimatedSprite3D>(p_object); if (animated_sprite_2d && *animated_sprite_2d->get_sprite_frames()) {
if (animated_sprite && *animated_sprite->get_sprite_frames()) {
return true; return true;
} else if (animated_sprite_3d && *animated_sprite_3d->get_sprite_frames()) {
return true;
} else {
return p_object->is_class("SpriteFrames");
} }
AnimatedSprite3D *animated_sprite_3d = Object::cast_to<AnimatedSprite3D>(p_object);
if (animated_sprite_3d && *animated_sprite_3d->get_sprite_frames()) {
return true;
}
return p_object->is_class("SpriteFrames");
} }
void SpriteFramesEditorPlugin::make_visible(bool p_visible) { void SpriteFramesEditorPlugin::make_visible(bool p_visible) {

View File

@ -69,16 +69,18 @@
#include "servers/display_server.h" #include "servers/display_server.h"
#include "servers/movie_writer/movie_writer.h" #include "servers/movie_writer/movie_writer.h"
#include "servers/movie_writer/movie_writer_mjpeg.h" #include "servers/movie_writer/movie_writer_mjpeg.h"
#include "servers/navigation_server_2d.h"
#include "servers/navigation_server_2d_dummy.h"
#include "servers/navigation_server_3d.h" #include "servers/navigation_server_3d.h"
#include "servers/navigation_server_3d_dummy.h" #include "servers/navigation_server_3d_dummy.h"
#include "servers/physics_server_2d.h"
#include "servers/register_server_types.h" #include "servers/register_server_types.h"
#include "servers/rendering/rendering_server_default.h" #include "servers/rendering/rendering_server_default.h"
#include "servers/text/text_server_dummy.h" #include "servers/text/text_server_dummy.h"
#include "servers/text_server.h" #include "servers/text_server.h"
// 2D
#include "servers/navigation_server_2d.h"
#include "servers/navigation_server_2d_dummy.h"
#include "servers/physics_server_2d.h"
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
#include "servers/physics_server_3d.h" #include "servers/physics_server_3d.h"
#include "servers/xr_server.h" #include "servers/xr_server.h"
@ -143,15 +145,15 @@ static MessageQueue *message_queue = nullptr;
// Initialized in setup2() // Initialized in setup2()
static AudioServer *audio_server = nullptr; static AudioServer *audio_server = nullptr;
static CameraServer *camera_server = nullptr;
static DisplayServer *display_server = nullptr; static DisplayServer *display_server = nullptr;
static RenderingServer *rendering_server = nullptr; static RenderingServer *rendering_server = nullptr;
static CameraServer *camera_server = nullptr;
static TextServerManager *tsman = nullptr; static TextServerManager *tsman = nullptr;
static ThemeDB *theme_db = nullptr;
static NavigationServer2D *navigation_server_2d = nullptr;
static PhysicsServer2DManager *physics_server_2d_manager = nullptr; static PhysicsServer2DManager *physics_server_2d_manager = nullptr;
static PhysicsServer2D *physics_server_2d = nullptr; static PhysicsServer2D *physics_server_2d = nullptr;
static NavigationServer3D *navigation_server_3d = nullptr; static NavigationServer3D *navigation_server_3d = nullptr;
static NavigationServer2D *navigation_server_2d = nullptr;
static ThemeDB *theme_db = nullptr;
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
static PhysicsServer3DManager *physics_server_3d_manager = nullptr; static PhysicsServer3DManager *physics_server_3d_manager = nullptr;
static PhysicsServer3D *physics_server_3d = nullptr; static PhysicsServer3D *physics_server_3d = nullptr;

View File

@ -36,9 +36,11 @@
#include "scene/main/scene_tree.h" #include "scene/main/scene_tree.h"
#include "servers/audio_server.h" #include "servers/audio_server.h"
#include "servers/navigation_server_3d.h" #include "servers/navigation_server_3d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h" #include "servers/rendering_server.h"
// 2D
#include "servers/physics_server_2d.h"
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
#include "servers/physics_server_3d.h" #include "servers/physics_server_3d.h"
#endif // _3D_DISABLED #endif // _3D_DISABLED

View File

@ -33,53 +33,6 @@
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
#include "core/object/class_db.h" #include "core/object/class_db.h"
#include "core/os/os.h" #include "core/os/os.h"
#include "scene/2d/animated_sprite_2d.h"
#include "scene/2d/audio_listener_2d.h"
#include "scene/2d/audio_stream_player_2d.h"
#include "scene/2d/back_buffer_copy.h"
#include "scene/2d/camera_2d.h"
#include "scene/2d/canvas_group.h"
#include "scene/2d/canvas_modulate.h"
#include "scene/2d/cpu_particles_2d.h"
#include "scene/2d/gpu_particles_2d.h"
#include "scene/2d/light_2d.h"
#include "scene/2d/light_occluder_2d.h"
#include "scene/2d/line_2d.h"
#include "scene/2d/marker_2d.h"
#include "scene/2d/mesh_instance_2d.h"
#include "scene/2d/multimesh_instance_2d.h"
#include "scene/2d/navigation_agent_2d.h"
#include "scene/2d/navigation_link_2d.h"
#include "scene/2d/navigation_obstacle_2d.h"
#include "scene/2d/navigation_region_2d.h"
#include "scene/2d/parallax_2d.h"
#include "scene/2d/parallax_background.h"
#include "scene/2d/parallax_layer.h"
#include "scene/2d/path_2d.h"
#include "scene/2d/physics/animatable_body_2d.h"
#include "scene/2d/physics/area_2d.h"
#include "scene/2d/physics/character_body_2d.h"
#include "scene/2d/physics/collision_polygon_2d.h"
#include "scene/2d/physics/collision_shape_2d.h"
#include "scene/2d/physics/joints/damped_spring_joint_2d.h"
#include "scene/2d/physics/joints/groove_joint_2d.h"
#include "scene/2d/physics/joints/joint_2d.h"
#include "scene/2d/physics/joints/pin_joint_2d.h"
#include "scene/2d/physics/kinematic_collision_2d.h"
#include "scene/2d/physics/physical_bone_2d.h"
#include "scene/2d/physics/physics_body_2d.h"
#include "scene/2d/physics/ray_cast_2d.h"
#include "scene/2d/physics/rigid_body_2d.h"
#include "scene/2d/physics/shape_cast_2d.h"
#include "scene/2d/physics/static_body_2d.h"
#include "scene/2d/polygon_2d.h"
#include "scene/2d/remote_transform_2d.h"
#include "scene/2d/skeleton_2d.h"
#include "scene/2d/sprite_2d.h"
#include "scene/2d/tile_map.h"
#include "scene/2d/tile_map_layer.h"
#include "scene/2d/touch_screen_button.h"
#include "scene/2d/visible_on_screen_notifier_2d.h"
#include "scene/animation/animation_blend_space_1d.h" #include "scene/animation/animation_blend_space_1d.h"
#include "scene/animation/animation_blend_space_2d.h" #include "scene/animation/animation_blend_space_2d.h"
#include "scene/animation/animation_blend_tree.h" #include "scene/animation/animation_blend_tree.h"
@ -146,29 +99,11 @@
#include "scene/main/multiplayer_api.h" #include "scene/main/multiplayer_api.h"
#include "scene/main/resource_preloader.h" #include "scene/main/resource_preloader.h"
#include "scene/main/scene_tree.h" #include "scene/main/scene_tree.h"
#include "scene/main/shader_globals_override.h"
#include "scene/main/status_indicator.h" #include "scene/main/status_indicator.h"
#include "scene/main/timer.h" #include "scene/main/timer.h"
#include "scene/main/viewport.h" #include "scene/main/viewport.h"
#include "scene/main/window.h" #include "scene/main/window.h"
#include "scene/resources/2d/capsule_shape_2d.h"
#include "scene/resources/2d/circle_shape_2d.h"
#include "scene/resources/2d/concave_polygon_shape_2d.h"
#include "scene/resources/2d/convex_polygon_shape_2d.h"
#include "scene/resources/2d/polygon_path_finder.h"
#include "scene/resources/2d/rectangle_shape_2d.h"
#include "scene/resources/2d/segment_shape_2d.h"
#include "scene/resources/2d/separation_ray_shape_2d.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_ccdik.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_fabrik.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_jiggle.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_lookat.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_physicalbones.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_stackholder.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_twoboneik.h"
#include "scene/resources/2d/skeleton/skeleton_modification_stack_2d.h"
#include "scene/resources/2d/tile_set.h"
#include "scene/resources/2d/world_boundary_shape_2d.h"
#include "scene/resources/animated_texture.h" #include "scene/resources/animated_texture.h"
#include "scene/resources/animation_library.h" #include "scene/resources/animation_library.h"
#include "scene/resources/atlas_texture.h" #include "scene/resources/atlas_texture.h"
@ -226,7 +161,73 @@
#include "scene/scene_string_names.h" #include "scene/scene_string_names.h"
#include "scene/theme/theme_db.h" #include "scene/theme/theme_db.h"
#include "scene/main/shader_globals_override.h" // 2D
#include "scene/2d/animated_sprite_2d.h"
#include "scene/2d/audio_listener_2d.h"
#include "scene/2d/audio_stream_player_2d.h"
#include "scene/2d/back_buffer_copy.h"
#include "scene/2d/camera_2d.h"
#include "scene/2d/canvas_group.h"
#include "scene/2d/canvas_modulate.h"
#include "scene/2d/cpu_particles_2d.h"
#include "scene/2d/gpu_particles_2d.h"
#include "scene/2d/light_2d.h"
#include "scene/2d/light_occluder_2d.h"
#include "scene/2d/line_2d.h"
#include "scene/2d/marker_2d.h"
#include "scene/2d/mesh_instance_2d.h"
#include "scene/2d/multimesh_instance_2d.h"
#include "scene/2d/navigation_agent_2d.h"
#include "scene/2d/navigation_link_2d.h"
#include "scene/2d/navigation_obstacle_2d.h"
#include "scene/2d/navigation_region_2d.h"
#include "scene/2d/parallax_2d.h"
#include "scene/2d/parallax_background.h"
#include "scene/2d/parallax_layer.h"
#include "scene/2d/path_2d.h"
#include "scene/2d/physics/animatable_body_2d.h"
#include "scene/2d/physics/area_2d.h"
#include "scene/2d/physics/character_body_2d.h"
#include "scene/2d/physics/collision_polygon_2d.h"
#include "scene/2d/physics/collision_shape_2d.h"
#include "scene/2d/physics/joints/damped_spring_joint_2d.h"
#include "scene/2d/physics/joints/groove_joint_2d.h"
#include "scene/2d/physics/joints/joint_2d.h"
#include "scene/2d/physics/joints/pin_joint_2d.h"
#include "scene/2d/physics/kinematic_collision_2d.h"
#include "scene/2d/physics/physical_bone_2d.h"
#include "scene/2d/physics/physics_body_2d.h"
#include "scene/2d/physics/ray_cast_2d.h"
#include "scene/2d/physics/rigid_body_2d.h"
#include "scene/2d/physics/shape_cast_2d.h"
#include "scene/2d/physics/static_body_2d.h"
#include "scene/2d/polygon_2d.h"
#include "scene/2d/remote_transform_2d.h"
#include "scene/2d/skeleton_2d.h"
#include "scene/2d/sprite_2d.h"
#include "scene/2d/tile_map.h"
#include "scene/2d/tile_map_layer.h"
#include "scene/2d/touch_screen_button.h"
#include "scene/2d/visible_on_screen_notifier_2d.h"
#include "scene/resources/2d/capsule_shape_2d.h"
#include "scene/resources/2d/circle_shape_2d.h"
#include "scene/resources/2d/concave_polygon_shape_2d.h"
#include "scene/resources/2d/convex_polygon_shape_2d.h"
#include "scene/resources/2d/polygon_path_finder.h"
#include "scene/resources/2d/rectangle_shape_2d.h"
#include "scene/resources/2d/segment_shape_2d.h"
#include "scene/resources/2d/separation_ray_shape_2d.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_ccdik.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_fabrik.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_jiggle.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_lookat.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_physicalbones.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_stackholder.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_twoboneik.h"
#include "scene/resources/2d/skeleton/skeleton_modification_stack_2d.h"
#include "scene/resources/2d/tile_set.h"
#include "scene/resources/2d/world_boundary_shape_2d.h"
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
#include "scene/3d/audio_listener_3d.h" #include "scene/3d/audio_listener_3d.h"
@ -858,6 +859,7 @@ void register_scene_types() {
GDREGISTER_CLASS(MeshDataTool); GDREGISTER_CLASS(MeshDataTool);
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
GDREGISTER_CLASS(AudioStreamPlayer3D);
GDREGISTER_VIRTUAL_CLASS(PrimitiveMesh); GDREGISTER_VIRTUAL_CLASS(PrimitiveMesh);
GDREGISTER_CLASS(BoxMesh); GDREGISTER_CLASS(BoxMesh);
GDREGISTER_CLASS(CapsuleMesh); GDREGISTER_CLASS(CapsuleMesh);
@ -969,7 +971,6 @@ void register_scene_types() {
GDREGISTER_CLASS(StyleBoxLine); GDREGISTER_CLASS(StyleBoxLine);
GDREGISTER_CLASS(Theme); GDREGISTER_CLASS(Theme);
GDREGISTER_CLASS(PolygonPathFinder);
GDREGISTER_CLASS(BitMap); GDREGISTER_CLASS(BitMap);
GDREGISTER_CLASS(Gradient); GDREGISTER_CLASS(Gradient);
@ -980,16 +981,13 @@ void register_scene_types() {
OS::get_singleton()->yield(); // may take time to init OS::get_singleton()->yield(); // may take time to init
GDREGISTER_CLASS(AudioStreamPlayer); GDREGISTER_CLASS(AudioStreamPlayer);
GDREGISTER_CLASS(AudioStreamPlayer2D);
#ifndef _3D_DISABLED
GDREGISTER_CLASS(AudioStreamPlayer3D);
#endif
GDREGISTER_CLASS(AudioStreamWAV); GDREGISTER_CLASS(AudioStreamWAV);
GDREGISTER_CLASS(AudioStreamPolyphonic); GDREGISTER_CLASS(AudioStreamPolyphonic);
GDREGISTER_ABSTRACT_CLASS(AudioStreamPlaybackPolyphonic); GDREGISTER_ABSTRACT_CLASS(AudioStreamPlaybackPolyphonic);
OS::get_singleton()->yield(); // may take time to init OS::get_singleton()->yield(); // may take time to init
GDREGISTER_CLASS(AudioStreamPlayer2D);
GDREGISTER_ABSTRACT_CLASS(Shape2D); GDREGISTER_ABSTRACT_CLASS(Shape2D);
GDREGISTER_CLASS(WorldBoundaryShape2D); GDREGISTER_CLASS(WorldBoundaryShape2D);
GDREGISTER_CLASS(SegmentShape2D); GDREGISTER_CLASS(SegmentShape2D);
@ -1002,6 +1000,7 @@ void register_scene_types() {
GDREGISTER_CLASS(Curve2D); GDREGISTER_CLASS(Curve2D);
GDREGISTER_CLASS(Path2D); GDREGISTER_CLASS(Path2D);
GDREGISTER_CLASS(PathFollow2D); GDREGISTER_CLASS(PathFollow2D);
GDREGISTER_CLASS(PolygonPathFinder);
GDREGISTER_CLASS(NavigationMesh); GDREGISTER_CLASS(NavigationMesh);
GDREGISTER_CLASS(NavigationMeshSourceGeometryData2D); GDREGISTER_CLASS(NavigationMeshSourceGeometryData2D);

View File

@ -66,6 +66,10 @@ RID World2D::get_navigation_map() const {
return navigation_map; return navigation_map;
} }
PhysicsDirectSpaceState2D *World2D::get_direct_space_state() {
return PhysicsServer2D::get_singleton()->space_get_direct_state(get_space());
}
void World2D::_bind_methods() { void World2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_canvas"), &World2D::get_canvas); 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_space"), &World2D::get_space);
@ -79,10 +83,6 @@ void World2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState2D", PROPERTY_USAGE_NONE), "", "get_direct_space_state"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState2D", PROPERTY_USAGE_NONE), "", "get_direct_space_state");
} }
PhysicsDirectSpaceState2D *World2D::get_direct_space_state() {
return PhysicsServer2D::get_singleton()->space_get_direct_state(get_space());
}
void World2D::register_viewport(Viewport *p_viewport) { void World2D::register_viewport(Viewport *p_viewport) {
viewports.insert(p_viewport); viewports.insert(p_viewport);
} }