2022-08-29 18:40:38 +02:00
|
|
|
#ifndef WORLD_H
|
|
|
|
#define WORLD_H
|
|
|
|
|
2022-08-29 20:56:17 +02:00
|
|
|
#include "core/containers/vector.h"
|
2022-08-29 19:40:17 +02:00
|
|
|
#include "core/object/reference.h"
|
|
|
|
|
2022-08-29 18:40:38 +02:00
|
|
|
#include "node.h"
|
|
|
|
|
2022-08-30 12:28:05 +02:00
|
|
|
class Camera;
|
2022-08-29 19:40:17 +02:00
|
|
|
class World3D;
|
|
|
|
class World2D;
|
|
|
|
|
2022-08-29 18:40:38 +02:00
|
|
|
class World : public Node {
|
|
|
|
GDCLASS(World, Node);
|
|
|
|
|
|
|
|
public:
|
2022-08-30 14:08:27 +02:00
|
|
|
Camera *get_camera() const;
|
|
|
|
|
2022-08-29 19:48:01 +02:00
|
|
|
Ref<World2D> get_world_2d() const;
|
2022-08-29 19:40:17 +02:00
|
|
|
void set_world_2d(const Ref<World2D> &p_world_2d);
|
|
|
|
|
|
|
|
Ref<World3D> get_world_3d() const;
|
2022-08-29 19:48:01 +02:00
|
|
|
void set_world_3d(const Ref<World3D> &p_world);
|
2022-08-29 19:40:17 +02:00
|
|
|
|
|
|
|
bool is_using_own_world_3d() const;
|
2022-08-29 20:56:17 +02:00
|
|
|
void set_use_own_world_3d(const bool p_use_own_world_3d);
|
|
|
|
|
|
|
|
bool get_override_in_parent_viewport();
|
|
|
|
void set_override_in_parent_viewport(const bool value);
|
2022-08-29 19:40:17 +02:00
|
|
|
|
2022-08-29 19:51:17 +02:00
|
|
|
Ref<World2D> find_world_2d() const;
|
|
|
|
Ref<World3D> find_world_3d() const;
|
2022-08-30 12:28:05 +02:00
|
|
|
Ref<World2D> find_world_2d_no_override() const;
|
|
|
|
Ref<World3D> find_world_3d_no_override() const;
|
2022-08-29 19:51:17 +02:00
|
|
|
|
2022-08-29 20:56:17 +02:00
|
|
|
World *get_override_world();
|
|
|
|
World *get_override_world_or_this();
|
|
|
|
void set_override_world(World *p_world);
|
|
|
|
void set_override_world_bind(Node *p_world);
|
|
|
|
|
2022-08-30 01:40:03 +02:00
|
|
|
virtual void gui_reset_canvas_sort_index();
|
|
|
|
virtual int gui_get_canvas_sort_index();
|
|
|
|
|
|
|
|
virtual void enable_canvas_transform_override(bool p_enable);
|
|
|
|
virtual bool is_canvas_transform_override_enbled() const;
|
|
|
|
|
|
|
|
virtual void set_canvas_transform_override(const Transform2D &p_transform);
|
|
|
|
virtual Transform2D get_canvas_transform_override() const;
|
|
|
|
|
|
|
|
virtual void set_canvas_transform(const Transform2D &p_transform);
|
|
|
|
virtual Transform2D get_canvas_transform() const;
|
|
|
|
|
|
|
|
virtual void set_global_canvas_transform(const Transform2D &p_transform);
|
|
|
|
virtual Transform2D get_global_canvas_transform() const;
|
|
|
|
|
|
|
|
virtual Transform2D get_final_transform() const;
|
|
|
|
|
|
|
|
virtual Rect2 get_visible_rect() const;
|
|
|
|
|
|
|
|
virtual RID get_viewport_rid() const;
|
|
|
|
|
2022-08-30 14:08:27 +02:00
|
|
|
Vector2 get_camera_coords(const Vector2 &p_viewport_coords) const;
|
|
|
|
Vector2 get_camera_rect_size() const;
|
|
|
|
|
2022-08-30 01:40:03 +02:00
|
|
|
void update_worlds();
|
|
|
|
|
2022-08-30 12:28:05 +02:00
|
|
|
void _world_3d_register_camera(Camera *p_camera);
|
|
|
|
void _world_3d_remove_camera(Camera *p_camera);
|
|
|
|
void _world_3d_register_camera_no_override(Camera *p_camera);
|
|
|
|
void _world_3d_remove_camera_no_override(Camera *p_camera);
|
|
|
|
void _world_3d_register_camera_as_override(Camera *p_camera);
|
|
|
|
void _world_3d_remove_camera_as_override(Camera *p_camera);
|
|
|
|
void _clear_override_cameras();
|
|
|
|
void _add_override_cameras_into(World *p_from);
|
|
|
|
|
2022-08-29 18:40:38 +02:00
|
|
|
World();
|
|
|
|
~World();
|
|
|
|
|
2022-08-30 14:08:27 +02:00
|
|
|
//friend class Camera;
|
|
|
|
void _camera_transform_changed_notify();
|
|
|
|
virtual void _camera_set(Camera *p_camera);
|
|
|
|
bool _camera_add(Camera *p_camera); //true if first
|
|
|
|
void _camera_remove(Camera *p_camera);
|
|
|
|
void _camera_make_next_current(Camera *p_exclude);
|
|
|
|
|
|
|
|
virtual void _update_listener();
|
|
|
|
virtual void _update_listener_2d();
|
|
|
|
|
2022-08-29 18:40:38 +02:00
|
|
|
protected:
|
2022-08-29 20:56:17 +02:00
|
|
|
void _add_overridden_world(World *p_world);
|
|
|
|
void _remove_overridden_world(World *p_world);
|
2022-08-29 19:40:17 +02:00
|
|
|
|
|
|
|
virtual void _own_world_3d_changed();
|
|
|
|
virtual void _on_set_use_own_world_3d(bool p_use_own_world_3d);
|
|
|
|
virtual void _on_set_world_3d(const Ref<World3D> &p_old_world);
|
|
|
|
virtual void _on_set_world_2d(const Ref<World2D> &p_old_world_2d);
|
2022-08-29 22:51:09 +02:00
|
|
|
|
|
|
|
virtual void _on_before_world_override_changed();
|
|
|
|
virtual void _on_after_world_override_changed();
|
2022-08-29 19:40:17 +02:00
|
|
|
|
|
|
|
void _propagate_enter_world(Node *p_node);
|
|
|
|
void _propagate_exit_world(Node *p_node);
|
|
|
|
|
2022-08-29 20:56:17 +02:00
|
|
|
void _notification(int p_what);
|
|
|
|
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2022-08-29 19:40:17 +02:00
|
|
|
Ref<World2D> world_2d;
|
|
|
|
Ref<World3D> world_3d;
|
|
|
|
Ref<World3D> own_world_3d;
|
|
|
|
|
|
|
|
World *_parent_world;
|
2022-08-29 20:56:17 +02:00
|
|
|
|
|
|
|
bool _override_in_parent_viewport;
|
|
|
|
World *_override_world;
|
|
|
|
|
|
|
|
Vector<World *> _overriding_worlds;
|
2022-08-30 12:28:05 +02:00
|
|
|
Vector<Camera *> _override_cameras;
|
2022-08-30 14:08:27 +02:00
|
|
|
|
|
|
|
Camera *camera;
|
|
|
|
Set<Camera *> cameras;
|
2022-08-30 14:31:23 +02:00
|
|
|
Camera *_own_active_camera;
|
2022-08-30 14:08:27 +02:00
|
|
|
|
|
|
|
Size2 size;
|
2022-08-29 18:40:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|