summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorHein-Pieter van Braam <hp@tmm.cx>2017-08-24 22:58:51 +0200
committerHein-Pieter van Braam <hp@tmm.cx>2017-08-24 23:08:24 +0200
commitcacced7e507f7603bacc03ae2616e58f0ede122a (patch)
tree7af89373e86cd1a7af6ea04e10280084cabb7144 /editor/plugins
parent4aa2c18cb428ffde05c67987926736a9ca62703b (diff)
Convert Object::cast_to() to the static version
Currently we rely on some undefined behavior when Object->cast_to() gets called with a Null pointer. This used to work fine with GCC < 6 but newer versions of GCC remove all codepaths in which the this pointer is Null. However, the non-static cast_to() was supposed to be null safe. This patch makes cast_to() Null safe and removes the now redundant Null checks where they existed. It is explained in this article: https://www.viva64.com/en/b/0226/
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp10
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp8
-rw-r--r--editor/plugins/baked_light_baker.cpp13
-rw-r--r--editor/plugins/baked_light_editor_plugin.cpp2
-rw-r--r--editor/plugins/camera_editor_plugin.cpp6
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp252
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.cpp4
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp20
-rw-r--r--editor/plugins/cube_grid_theme_editor_plugin.cpp18
-rw-r--r--editor/plugins/curve_editor_plugin.cpp14
-rw-r--r--editor/plugins/gi_probe_editor_plugin.cpp2
-rw-r--r--editor/plugins/gradient_editor_plugin.cpp2
-rw-r--r--editor/plugins/item_list_editor_plugin.cpp10
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/line_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/material_editor_plugin.cpp2
-rw-r--r--editor/plugins/mesh_editor_plugin.cpp2
-rw-r--r--editor/plugins/mesh_instance_editor_plugin.cpp4
-rw-r--r--editor/plugins/multimesh_editor_plugin.cpp8
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.cpp4
-rw-r--r--editor/plugins/particles_2d_editor_plugin.cpp7
-rw-r--r--editor/plugins/particles_editor_plugin.cpp6
-rw-r--r--editor/plugins/path_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/path_editor_plugin.cpp8
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp2
-rw-r--r--editor/plugins/rich_text_editor_plugin.cpp4
-rw-r--r--editor/plugins/sample_editor_plugin.cpp2
-rw-r--r--editor/plugins/sample_library_editor_plugin.cpp8
-rw-r--r--editor/plugins/sample_player_editor_plugin.cpp2
-rw-r--r--editor/plugins/script_editor_plugin.cpp162
-rw-r--r--editor/plugins/shader_editor_plugin.cpp10
-rw-r--r--editor/plugins/shader_graph_editor_plugin.cpp34
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp110
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp6
-rw-r--r--editor/plugins/stream_editor_plugin.cpp2
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp4
-rw-r--r--editor/plugins/texture_editor_plugin.cpp12
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp12
-rw-r--r--editor/plugins/theme_editor_plugin.cpp6
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp6
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp20
43 files changed, 388 insertions, 436 deletions
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index ecae272b6d..a1fec795f8 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -656,8 +656,8 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
return;
Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["player"]);
- if (n && n->cast_to<AnimationPlayer>() && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) {
- player = n->cast_to<AnimationPlayer>();
+ if (Object::cast_to<AnimationPlayer>(n) && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) {
+ player = Object::cast_to<AnimationPlayer>(n);
_update_player();
show();
set_process(true);
@@ -737,9 +737,9 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
if (current != "") {
Ref<Animation> anim = player->get_animation(current);
- ERR_FAIL_COND(!anim->cast_to<Resource>())
+ ERR_FAIL_COND(!Object::cast_to<Resource>(*anim))
- RES current_res = RES(anim->cast_to<Resource>());
+ RES current_res = RES(Object::cast_to<Resource>(*anim));
_animation_save_in_path(current_res, p_file);
}
@@ -1461,7 +1461,7 @@ void AnimationPlayerEditorPlugin::edit(Object *p_object) {
anim_editor->set_undo_redo(&get_undo_redo());
if (!p_object)
return;
- anim_editor->edit(p_object->cast_to<AnimationPlayer>());
+ anim_editor->edit(Object::cast_to<AnimationPlayer>(p_object));
}
bool AnimationPlayerEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index 55975bdefa..9d150150a1 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -281,9 +281,9 @@ void AnimationTreeEditor::_popup_edit_dialog() {
case AnimationTreePlayer::NODE_ANIMATION:
- if (anim_tree->get_master_player() != NodePath() && anim_tree->has_node(anim_tree->get_master_player()) && anim_tree->get_node(anim_tree->get_master_player())->cast_to<AnimationPlayer>()) {
+ if (anim_tree->get_master_player() != NodePath() && anim_tree->has_node(anim_tree->get_master_player()) && Object::cast_to<AnimationPlayer>(anim_tree->get_node(anim_tree->get_master_player()))) {
- AnimationPlayer *ap = anim_tree->get_node(anim_tree->get_master_player())->cast_to<AnimationPlayer>();
+ AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(anim_tree->get_node(anim_tree->get_master_player()));
master_anim_popup->clear();
master_anim_popup->add_item("Edit Filters");
master_anim_popup->add_separator();
@@ -1233,7 +1233,7 @@ void AnimationTreeEditor::_edit_filters() {
if (np.get_property() != StringName()) {
Node *n = base->get_node(np);
- Skeleton *s = n->cast_to<Skeleton>();
+ Skeleton *s = Object::cast_to<Skeleton>(n);
if (s) {
String skelbase = E->get().substr(0, E->get().find(":"));
@@ -1439,7 +1439,7 @@ AnimationTreeEditor::AnimationTreeEditor() {
void AnimationTreeEditorPlugin::edit(Object *p_object) {
- anim_tree_editor->edit(p_object->cast_to<AnimationTreePlayer>());
+ anim_tree_editor->edit(Object::cast_to<AnimationTreePlayer>(p_object));
}
bool AnimationTreeEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/baked_light_baker.cpp b/editor/plugins/baked_light_baker.cpp
index bef35647d4..d76bdad858 100644
--- a/editor/plugins/baked_light_baker.cpp
+++ b/editor/plugins/baked_light_baker.cpp
@@ -301,16 +301,13 @@ void BakedLightBaker::_add_mesh(const Ref<Mesh>& p_mesh,const Ref<Material>& p_m
void BakedLightBaker::_parse_geometry(Node* p_node) {
- if (p_node->cast_to<MeshInstance>()) {
+ if (MeshInstance *meshi=Object::cast_to<MeshInstance>(p_node)) {
- MeshInstance *meshi=p_node->cast_to<MeshInstance>();
Ref<Mesh> mesh=meshi->get_mesh();
if (mesh.is_valid()) {
_add_mesh(mesh,meshi->get_material_override(),base_inv * meshi->get_global_transform(),meshi->get_baked_light_texture_id());
}
- } else if (p_node->cast_to<Light>()) {
-
- Light *dl=p_node->cast_to<Light>();
+ } else if (Light *dl=Object::cast_to<Light>(p_node)) {
if (dl->get_bake_mode()!=Light::BAKE_MODE_DISABLED) {
@@ -340,9 +337,7 @@ void BakedLightBaker::_parse_geometry(Node* p_node) {
lights.push_back(dirl);
}
- } else if (p_node->cast_to<Spatial>()){
-
- Spatial *sp = p_node->cast_to<Spatial>();
+ } else if (Spatial *sp = Object::cast_to<Spatial>(p_node)){
Array arr = p_node->call("_get_baked_light_meshes");
for(int i=0;i<arr.size();i+=2) {
@@ -1741,7 +1736,7 @@ void BakedLightBaker::bake(const Ref<BakedLight> &p_light, Node* p_node) {
return;
cell_count=0;
- base_inv=p_node->cast_to<Spatial>()->get_global_transform().affine_inverse();
+ base_inv=Object::cast_to<Spatial>(p_node)->get_global_transform().affine_inverse();
EditorProgress ep("bake",TTR("Light Baker Setup:"),5);
baked_light=p_light;
lattice_size=baked_light->get_initial_lattice_subdiv();
diff --git a/editor/plugins/baked_light_editor_plugin.cpp b/editor/plugins/baked_light_editor_plugin.cpp
index f973639a67..85058ed108 100644
--- a/editor/plugins/baked_light_editor_plugin.cpp
+++ b/editor/plugins/baked_light_editor_plugin.cpp
@@ -337,7 +337,7 @@ BakedLightEditor::~BakedLightEditor() {
void BakedLightEditorPlugin::edit(Object *p_object) {
- baked_light_editor->edit(p_object->cast_to<BakedLightInstance>());
+ baked_light_editor->edit(Object::cast_to<BakedLightInstance>(p_object));
}
bool BakedLightEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/camera_editor_plugin.cpp b/editor/plugins/camera_editor_plugin.cpp
index 8e625c4a73..18ee8d8db3 100644
--- a/editor/plugins/camera_editor_plugin.cpp
+++ b/editor/plugins/camera_editor_plugin.cpp
@@ -97,8 +97,8 @@ CameraEditor::CameraEditor() {
void CameraEditorPlugin::edit(Object *p_object) {
- SpatialEditor::get_singleton()->set_can_preview(p_object->cast_to<Camera>());
- //camera_editor->edit(p_object->cast_to<Node>());
+ SpatialEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object));
+ //camera_editor->edit(Object::cast_to<Node>(p_object));
}
bool CameraEditorPlugin::handles(Object *p_object) const {
@@ -109,7 +109,7 @@ bool CameraEditorPlugin::handles(Object *p_object) const {
void CameraEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- //SpatialEditor::get_singleton()->set_can_preview(p_object->cast_to<Camera>());
+ //SpatialEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object));
} else {
SpatialEditor::get_singleton()->set_can_preview(NULL);
}
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 79bf68b061..0dcabb1776 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -175,7 +175,7 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Node2D *n2d = E->get()->cast_to<Node2D>();
+ Node2D *n2d = Object::cast_to<Node2D>(E->get());
if (n2d && n2d->edit_has_pivot()) {
Vector2 offset = n2d->edit_get_pivot();
@@ -190,7 +190,7 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) {
undo_redo->add_undo_method(n2d, "set_global_position", gpos);
undo_redo->add_undo_method(n2d, "edit_set_pivot", offset);
for (int i = 0; i < n2d->get_child_count(); i++) {
- Node2D *n2dc = n2d->get_child(i)->cast_to<Node2D>();
+ Node2D *n2dc = Object::cast_to<Node2D>(n2d->get_child(i));
if (!n2dc)
continue;
@@ -199,7 +199,7 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) {
}
}
- Control *cnt = E->get()->cast_to<Control>();
+ Control *cnt = Object::cast_to<Control>(E->get());
if (cnt) {
Vector2 old_pivot = cnt->get_pivot_offset();
@@ -265,7 +265,7 @@ void CanvasItemEditor::_tool_select(int p_index) {
Object *CanvasItemEditor::_get_editor_data(Object *p_what) {
- CanvasItem *ci = p_what->cast_to<CanvasItem>();
+ CanvasItem *ci = Object::cast_to<CanvasItem>(p_what);
if (!ci)
return NULL;
@@ -413,7 +413,7 @@ void CanvasItemEditor::_visibility_changed(ObjectID p_canvas_item) {
Object *c = ObjectDB::get_instance(p_canvas_item);
if (!c)
return;
- CanvasItem *ct = c->cast_to<CanvasItem>();
+ CanvasItem *ct = Object::cast_to<CanvasItem>(c);
if (!ct)
return;
canvas_items.erase(ct);
@@ -451,17 +451,17 @@ bool CanvasItemEditor::_is_part_of_subscene(CanvasItem *p_item) {
void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items, unsigned int limit) {
if (!p_node)
return;
- if (p_node->cast_to<Viewport>())
+ if (Object::cast_to<Viewport>(p_node))
return;
- CanvasItem *c = p_node->cast_to<CanvasItem>();
+ CanvasItem *c = Object::cast_to<CanvasItem>(p_node);
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
if (c && !c->is_set_as_toplevel())
_find_canvas_items_at_pos(p_pos, p_node->get_child(i), p_parent_xform * c->get_transform(), p_canvas_xform, r_items);
else {
- CanvasLayer *cl = p_node->cast_to<CanvasLayer>();
+ CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
_find_canvas_items_at_pos(p_pos, p_node->get_child(i), transform, cl ? cl->get_transform() : p_canvas_xform, r_items); //use base transform
}
@@ -469,13 +469,13 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
return;
}
- if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) {
+ if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !Object::cast_to<CanvasLayer>(c)) {
Rect2 rect = c->get_item_rect();
Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos);
if (rect.has_point(local_pos)) {
- Node2D *node = c->cast_to<Node2D>();
+ Node2D *node = Object::cast_to<Node2D>(c);
_SelectResult res;
res.item = c;
@@ -492,10 +492,10 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_n
if (!p_node)
return;
- if (p_node->cast_to<Viewport>())
+ if (Object::cast_to<Viewport>(p_node))
return;
- CanvasItem *c = p_node->cast_to<CanvasItem>();
+ CanvasItem *c = Object::cast_to<CanvasItem>(p_node);
bool inherited = p_node != get_tree()->get_edited_scene_root() && p_node->get_filename() != "";
bool editable = false;
@@ -509,13 +509,13 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_n
if (c && !c->is_set_as_toplevel())
_find_canvas_items_at_rect(p_rect, p_node->get_child(i), p_parent_xform * c->get_transform(), p_canvas_xform, r_items);
else {
- CanvasLayer *cl = p_node->cast_to<CanvasLayer>();
+ CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
_find_canvas_items_at_rect(p_rect, p_node->get_child(i), transform, cl ? cl->get_transform() : p_canvas_xform, r_items);
}
}
}
- if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) {
+ if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !Object::cast_to<CanvasLayer>(c)) {
Rect2 rect = c->get_item_rect();
Transform2D xform = p_parent_xform * p_canvas_xform * c->get_transform();
@@ -590,7 +590,7 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@@ -619,7 +619,7 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE
} else { // p_move_mode==MOVE_LOCAL_BASE || p_move_mode==MOVE_LOCAL_WITH_ROT
- if (Node2D *node_2d = canvas_item->cast_to<Node2D>()) {
+ if (Node2D *node_2d = Object::cast_to<Node2D>(canvas_item)) {
if (p_move_mode == MOVE_LOCAL_WITH_ROT) {
Transform2D m;
@@ -628,7 +628,7 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE
}
node_2d->set_position(node_2d->get_position() + drag);
- } else if (Control *control = canvas_item->cast_to<Control>()) {
+ } else if (Control *control = Object::cast_to<Control>(canvas_item)) {
control->set_position(control->get_position() + drag);
}
@@ -648,7 +648,7 @@ Point2 CanvasItemEditor::_find_topleftmost_point() {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@@ -673,7 +673,7 @@ int CanvasItemEditor::get_item_count() {
int ic = 0;
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@@ -694,7 +694,7 @@ CanvasItem *CanvasItemEditor::get_single_item() {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@@ -822,7 +822,7 @@ CanvasItemEditor::DragType CanvasItemEditor::_get_anchor_handle_drag_type(const
CanvasItem *canvas_item = get_single_item();
ERR_FAIL_COND_V(!canvas_item, DRAG_NONE);
- Control *control = canvas_item->cast_to<Control>();
+ Control *control = Object::cast_to<Control>(canvas_item);
ERR_FAIL_COND_V(!control, DRAG_NONE);
Vector2 anchor_pos[4];
@@ -865,7 +865,7 @@ void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@@ -876,15 +876,15 @@ void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) {
continue;
se->undo_state = canvas_item->edit_get_state();
- if (canvas_item->cast_to<Node2D>())
- se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
- if (canvas_item->cast_to<Control>())
- se->undo_pivot = canvas_item->cast_to<Control>()->get_pivot_offset();
+ if (Object::cast_to<Node2D>(canvas_item))
+ se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
+ if (Object::cast_to<Control>(canvas_item))
+ se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
}
- if (selection.size() == 1 && selection[0]->cast_to<Node2D>()) {
+ if (selection.size() == 1 && Object::cast_to<Node2D>(selection[0])) {
drag = DRAG_NODE_2D;
- drag_point_from = selection[0]->cast_to<Node2D>()->get_global_position();
+ drag_point_from = Object::cast_to<Node2D>(selection[0])->get_global_position();
} else {
drag = DRAG_ALL;
drag_point_from = _find_topleftmost_point();
@@ -1169,7 +1169,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@@ -1180,10 +1180,10 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
continue;
canvas_item->edit_set_state(se->undo_state);
- if (canvas_item->cast_to<Node2D>())
- canvas_item->cast_to<Node2D>()->edit_set_pivot(se->undo_pivot);
- if (canvas_item->cast_to<Control>())
- canvas_item->cast_to<Control>()->set_pivot_offset(se->undo_pivot);
+ if (Object::cast_to<Node2D>(canvas_item))
+ Object::cast_to<Node2D>(canvas_item)->edit_set_pivot(se->undo_pivot);
+ if (Object::cast_to<Control>(canvas_item))
+ Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot);
}
}
@@ -1251,7 +1251,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@@ -1265,13 +1265,13 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
undo_redo->add_do_method(canvas_item, "edit_set_state", state);
undo_redo->add_undo_method(canvas_item, "edit_set_state", se->undo_state);
{
- Node2D *pvt = canvas_item->cast_to<Node2D>();
+ Node2D *pvt = Object::cast_to<Node2D>(canvas_item);
if (pvt && pvt->edit_has_pivot()) {
undo_redo->add_do_method(canvas_item, "edit_set_pivot", pvt->edit_get_pivot());
undo_redo->add_undo_method(canvas_item, "edit_set_pivot", se->undo_pivot);
}
- Control *cnt = canvas_item->cast_to<Control>();
+ Control *cnt = Object::cast_to<Control>(canvas_item);
if (cnt) {
undo_redo->add_do_method(canvas_item, "set_pivot_offset", cnt->get_pivot_offset());
undo_redo->add_undo_method(canvas_item, "set_pivot_offset", se->undo_pivot);
@@ -1341,10 +1341,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
if (Cbone) {
- Node2D *b = NULL;
- Object *obj = ObjectDB::get_instance(Cbone->get().bone);
- if (obj)
- b = obj->cast_to<Node2D>();
+ Node2D *b = Object::cast_to<Node2D>(ObjectDB::get_instance(Cbone->get().bone));
if (b) {
@@ -1359,7 +1356,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
break;
float len = pi->get_global_transform().get_origin().distance_to(b->get_global_position());
- b = pi->cast_to<Node2D>();
+ b = Object::cast_to<Node2D>(pi);
if (!b)
break;
@@ -1405,10 +1402,10 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
drag = DRAG_ROTATE;
drag_from = transform.affine_inverse().xform(click);
se->undo_state = canvas_item->edit_get_state();
- if (canvas_item->cast_to<Node2D>())
- se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
- if (canvas_item->cast_to<Control>())
- se->undo_pivot = canvas_item->cast_to<Control>()->get_pivot_offset();
+ if (Object::cast_to<Node2D>(canvas_item))
+ se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
+ if (Object::cast_to<Control>(canvas_item))
+ se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
return;
}
@@ -1426,15 +1423,15 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
if (drag != DRAG_NONE) {
drag_from = transform.affine_inverse().xform(click);
se->undo_state = canvas_item->edit_get_state();
- if (canvas_item->cast_to<Node2D>())
- se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
- if (canvas_item->cast_to<Control>())
- se->undo_pivot = canvas_item->cast_to<Control>()->get_pivot_offset();
+ if (Object::cast_to<Node2D>(canvas_item))
+ se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
+ if (Object::cast_to<Control>(canvas_item))
+ se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
return;
}
// Drag anchor handles
- if (canvas_item->cast_to<Control>()) {
+ if (Object::cast_to<Control>(canvas_item)) {
drag = _get_anchor_handle_drag_type(click, drag_point_from);
if (drag != DRAG_NONE) {
drag_from = transform.affine_inverse().xform(click);
@@ -1457,9 +1454,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
CanvasItem *c = NULL;
if (Cbone) {
- Object *obj = ObjectDB::get_instance(Cbone->get().bone);
- if (obj)
- c = obj->cast_to<CanvasItem>();
+ c = Object::cast_to<CanvasItem>(ObjectDB::get_instance(Cbone->get().bone));
if (c)
c = c->get_parent_item();
}
@@ -1489,7 +1484,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
};
if (n) {
- c = n->cast_to<CanvasItem>();
+ c = Object::cast_to<CanvasItem>(n);
} else {
c = NULL;
}
@@ -1537,7 +1532,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@@ -1551,10 +1546,10 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
if (!dragging_bone) {
canvas_item->edit_set_state(se->undo_state); //reset state and reapply
- if (canvas_item->cast_to<Node2D>())
- canvas_item->cast_to<Node2D>()->edit_set_pivot(se->undo_pivot);
- if (canvas_item->cast_to<Control>())
- canvas_item->cast_to<Control>()->set_pivot_offset(se->undo_pivot);
+ if (Object::cast_to<Node2D>(canvas_item))
+ Object::cast_to<Node2D>(canvas_item)->edit_set_pivot(se->undo_pivot);
+ if (Object::cast_to<Control>(canvas_item))
+ Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot);
}
Vector2 dfrom = drag_from;
@@ -1566,7 +1561,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
// Rotate the node
Vector2 center = canvas_item->get_global_transform_with_canvas().get_origin();
{
- Node2D *node = canvas_item->cast_to<Node2D>();
+ Node2D *node = Object::cast_to<Node2D>(canvas_item);
if (node) {
real_t angle = node->get_rotation();
@@ -1578,7 +1573,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
{
- Control *node = canvas_item->cast_to<Control>();
+ Control *node = Object::cast_to<Control>(canvas_item);
if (node) {
real_t angle = node->get_rotation();
@@ -1592,7 +1587,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
continue;
}
- Control *control = canvas_item->cast_to<Control>();
+ Control *control = Object::cast_to<Control>(canvas_item);
if (control) {
// Drag and snap the anchor
Vector2 anchor = _position_to_anchor(control, canvas_item->get_global_transform_with_canvas().affine_inverse().xform(dto - drag_from + drag_point_from));
@@ -1728,19 +1723,19 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
case DRAG_PIVOT:
- if (canvas_item->cast_to<Node2D>()) {
- Node2D *n2d = canvas_item->cast_to<Node2D>();
+ if (Object::cast_to<Node2D>(canvas_item)) {
+ Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
n2d->edit_set_pivot(se->undo_pivot + drag_vector);
}
- if (canvas_item->cast_to<Control>()) {
- canvas_item->cast_to<Control>()->set_pivot_offset(se->undo_pivot + drag_vector);
+ if (Object::cast_to<Control>(canvas_item)) {
+ Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot + drag_vector);
}
continue;
break;
case DRAG_NODE_2D:
- ERR_FAIL_COND(!canvas_item->cast_to<Node2D>());
- canvas_item->cast_to<Node2D>()->set_global_position(dto);
+ ERR_FAIL_COND(!Object::cast_to<Node2D>(canvas_item));
+ Object::cast_to<Node2D>(canvas_item)->set_global_position(dto);
continue;
break;
}
@@ -1754,7 +1749,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
} else {
//ok, all that had to be done was done, now solve IK
- Node2D *n2d = canvas_item->cast_to<Node2D>();
+ Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
Transform2D final_xform = bone_orig_xform;
if (n2d) {
@@ -1981,7 +1976,7 @@ void CanvasItemEditor::_viewport_draw() {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@@ -2013,16 +2008,16 @@ void CanvasItemEditor::_viewport_draw() {
if (single && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks
- if (canvas_item->cast_to<Node2D>()) {
+ if (Object::cast_to<Node2D>(canvas_item)) {
- if (canvas_item->cast_to<Node2D>()->edit_has_pivot()) {
+ if (Object::cast_to<Node2D>(canvas_item)->edit_has_pivot()) {
viewport->draw_texture(pivot, xform.get_origin() + (-pivot->get_size() / 2).floor());
can_move_pivot = true;
pivot_found = true;
}
}
- Control *control = canvas_item->cast_to<Control>();
+ Control *control = Object::cast_to<Control>(canvas_item);
if (control) {
Vector2 pivot_ofs = control->get_pivot_offset();
if (pivot_ofs != Vector2()) {
@@ -2214,11 +2209,7 @@ void CanvasItemEditor::_viewport_draw() {
E->get().from = Vector2();
E->get().to = Vector2();
- Object *obj = ObjectDB::get_instance(E->get().bone);
- if (!obj)
- continue;
-
- Node2D *n2d = obj->cast_to<Node2D>();
+ Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E->get().bone));
if (!n2d)
continue;
@@ -2227,7 +2218,7 @@ void CanvasItemEditor::_viewport_draw() {
CanvasItem *pi = n2d->get_parent_item();
- Node2D *pn2d = n2d->get_parent()->cast_to<Node2D>();
+ Node2D *pn2d = Object::cast_to<Node2D>(n2d->get_parent());
if (!pn2d)
continue;
@@ -2283,14 +2274,14 @@ void CanvasItemEditor::_notification(int p_what) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- if (canvas_item->cast_to<Control>())
+ if (Object::cast_to<Control>(canvas_item))
has_control = true;
else
all_control = false;
@@ -2304,12 +2295,12 @@ void CanvasItemEditor::_notification(int p_what) {
float anchors[4];
Vector2 pivot;
- if (canvas_item->cast_to<Control>()) {
- pivot = canvas_item->cast_to<Control>()->get_pivot_offset();
- anchors[MARGIN_LEFT] = canvas_item->cast_to<Control>()->get_anchor(MARGIN_LEFT);
- anchors[MARGIN_RIGHT] = canvas_item->cast_to<Control>()->get_anchor(MARGIN_RIGHT);
- anchors[MARGIN_TOP] = canvas_item->cast_to<Control>()->get_anchor(MARGIN_TOP);
- anchors[MARGIN_BOTTOM] = canvas_item->cast_to<Control>()->get_anchor(MARGIN_BOTTOM);
+ if (Object::cast_to<Control>(canvas_item)) {
+ pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
+ anchors[MARGIN_LEFT] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_LEFT);
+ anchors[MARGIN_RIGHT] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_RIGHT);
+ anchors[MARGIN_TOP] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_TOP);
+ anchors[MARGIN_BOTTOM] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_BOTTOM);
}
if (r != se->prev_rect || xform != se->prev_xform || pivot != se->prev_pivot || anchors[MARGIN_LEFT] != se->prev_anchors[MARGIN_LEFT] || anchors[MARGIN_RIGHT] != se->prev_anchors[MARGIN_RIGHT] || anchors[MARGIN_TOP] != se->prev_anchors[MARGIN_TOP] || anchors[MARGIN_BOTTOM] != se->prev_anchors[MARGIN_BOTTOM]) {
@@ -2338,7 +2329,7 @@ void CanvasItemEditor::_notification(int p_what) {
break;
}
- Node2D *b2 = b->cast_to<Node2D>();
+ Node2D *b2 = Object::cast_to<Node2D>(b);
if (!b2) {
continue;
}
@@ -2426,7 +2417,7 @@ void CanvasItemEditor::_find_canvas_items_span(Node *p_node, Rect2 &r_rect, cons
if (!p_node)
return;
- CanvasItem *c = p_node->cast_to<CanvasItem>();
+ CanvasItem *c = Object::cast_to<CanvasItem>(p_node);
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
@@ -2587,7 +2578,7 @@ void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) {
undo_redo->create_action(TTR("Change Anchors"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Control *c = E->get()->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(E->get());
undo_redo->add_do_method(c, "set_anchors_preset", p_preset);
undo_redo->add_undo_method(c, "set_anchor", MARGIN_LEFT, c->get_anchor(MARGIN_LEFT));
@@ -2605,7 +2596,7 @@ void CanvasItemEditor::_set_full_rect() {
undo_redo->create_action(TTR("Change Anchors"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Control *c = E->get()->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(E->get());
undo_redo->add_do_method(c, "set_anchors_preset", PRESET_WIDE);
undo_redo->add_do_method(c, "set_margin", MARGIN_LEFT, 0);
@@ -2713,7 +2704,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@@ -2731,7 +2722,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@@ -2751,7 +2742,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@@ -2769,7 +2760,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@@ -2888,15 +2879,15 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- if (canvas_item->cast_to<Node2D>()) {
- Node2D *n2d = canvas_item->cast_to<Node2D>();
+ if (Object::cast_to<Node2D>(canvas_item)) {
+ Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
if (key_pos)
AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "position", n2d->get_position(), existing);
@@ -2909,7 +2900,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
//look for an IK chain
List<Node2D *> ik_chain;
- Node2D *n = n2d->get_parent_item()->cast_to<Node2D>();
+ Node2D *n = Object::cast_to<Node2D>(n2d->get_parent_item());
bool has_chain = false;
while (n) {
@@ -2922,7 +2913,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!n->get_parent_item())
break;
- n = n->get_parent_item()->cast_to<Node2D>();
+ n = Object::cast_to<Node2D>(n->get_parent_item());
}
if (has_chain && ik_chain.size()) {
@@ -2939,9 +2930,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
}
}
- } else if (canvas_item->cast_to<Control>()) {
+ } else if (Object::cast_to<Control>(canvas_item)) {
- Control *ctrl = canvas_item->cast_to<Control>();
+ Control *ctrl = Object::cast_to<Control>(canvas_item);
if (key_pos)
AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_position", ctrl->get_position(), existing);
@@ -2998,16 +2989,16 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- if (canvas_item->cast_to<Node2D>()) {
+ if (Object::cast_to<Node2D>(canvas_item)) {
- Node2D *n2d = canvas_item->cast_to<Node2D>();
+ Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
PoseClipboard pc;
pc.pos = n2d->get_position();
pc.rot = n2d->get_rotation();
@@ -3026,10 +3017,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
undo_redo->create_action(TTR("Paste Pose"));
for (List<PoseClipboard>::Element *E = pose_clipboard.front(); E; E = E->next()) {
- Object *o = ObjectDB::get_instance(E->get().id);
- if (!o)
- continue;
- Node2D *n2d = o->cast_to<Node2D>();
+ Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E->get().id));
if (!n2d)
continue;
undo_redo->add_do_method(n2d, "set_position", E->get().pos);
@@ -3048,15 +3036,15 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- if (canvas_item->cast_to<Node2D>()) {
- Node2D *n2d = canvas_item->cast_to<Node2D>();
+ if (Object::cast_to<Node2D>(canvas_item)) {
+ Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
if (key_pos)
n2d->set_position(Vector2());
@@ -3064,9 +3052,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
n2d->set_rotation(0);
if (key_scale)
n2d->set_scale(Vector2(1, 1));
- } else if (canvas_item->cast_to<Control>()) {
+ } else if (Object::cast_to<Control>(canvas_item)) {
- Control *ctrl = canvas_item->cast_to<Control>();
+ Control *ctrl = Object::cast_to<Control>(canvas_item);
if (key_pos)
ctrl->set_position(Point2());
@@ -3090,7 +3078,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- Node2D *n2d = E->key()->cast_to<Node2D>();
+ Node2D *n2d = Object::cast_to<Node2D>(E->key());
if (!n2d)
continue;
if (!n2d->is_visible_in_tree())
@@ -3111,7 +3099,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- Node2D *n2d = E->key()->cast_to<Node2D>();
+ Node2D *n2d = Object::cast_to<Node2D>(E->key());
if (!n2d)
continue;
if (!n2d->is_visible_in_tree())
@@ -3130,7 +3118,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@@ -3151,7 +3139,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *n2d = E->key()->cast_to<CanvasItem>();
+ CanvasItem *n2d = Object::cast_to<CanvasItem>(E->key());
if (!n2d)
continue;
if (!n2d->is_visible_in_tree())
@@ -3202,7 +3190,7 @@ void CanvasItemEditor::_focus_selection(int p_op) {
Map<Node *, Object *> &selection = editor_selection->get_selection();
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
if (!canvas_item) continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
@@ -3302,7 +3290,7 @@ void CanvasItemEditor::box_selection_start( Point2 &click ) {
bool CanvasItemEditor::box_selection_end() {
print_line( "box selection end" );
- Node* scene = get_scene()->get_root_node()->cast_to<EditorNode>()->get_edited_scene();
+ Node* scene = Object::cast_to<EditorNode>(get_scene()->get_root_node())->get_edited_scene();
if (scene) {
List<CanvasItem*> selitems;
@@ -3651,7 +3639,7 @@ CanvasItemEditor *CanvasItemEditor::singleton = NULL;
void CanvasItemEditorPlugin::edit(Object *p_object) {
canvas_item_editor->set_undo_redo(&get_undo_redo());
- canvas_item_editor->edit(p_object->cast_to<CanvasItem>());
+ canvas_item_editor->edit(Object::cast_to<CanvasItem>(p_object));
}
bool CanvasItemEditorPlugin::handles(Object *p_object) const {
@@ -3704,7 +3692,7 @@ void CanvasItemEditorViewport::_on_mouse_exit() {
}
void CanvasItemEditorViewport::_on_select_type(Object *selected) {
- CheckBox *check = selected->cast_to<CheckBox>();
+ CheckBox *check = Object::cast_to<CheckBox>(selected);
String type = check->get_text();
selector_label->set_text(vformat(TTR("Add %s"), type));
label->set_text(vformat(TTR("Adding %s..."), type));
@@ -3714,7 +3702,7 @@ void CanvasItemEditorViewport::_on_change_type() {
if (!button_group->get_pressed_button())
return;
- CheckBox *check = button_group->get_pressed_button()->cast_to<CheckBox>();
+ CheckBox *check = Object::cast_to<CheckBox>(button_group->get_pressed_button());
default_type = check->get_text();
_perform_drop_data();
selector->hide();
@@ -3726,8 +3714,8 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
for (int i = 0; i < files.size(); i++) {
String path = files[i];
RES res = ResourceLoader::load(path);
- Ref<Texture> texture = Ref<Texture>(res->cast_to<Texture>());
- Ref<PackedScene> scene = Ref<PackedScene>(res->cast_to<PackedScene>());
+ Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
+ Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
if (texture != NULL || scene != NULL) {
if (texture != NULL) {
Sprite *sprite = memnew(Sprite);
@@ -3778,7 +3766,7 @@ bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String &p_targe
void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point) {
child->set_name(path.get_file().get_basename());
- Ref<Texture> texture = Ref<Texture>(ResourceCache::get(path)->cast_to<Texture>());
+ Ref<Texture> texture = Object::cast_to<Texture>(Ref<Texture>(ResourceCache::get(path)).ptr());
Size2 texture_size = texture->get_size();
editor_data->get_undo_redo().add_do_method(parent, "add_child", child);
@@ -3867,11 +3855,11 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
Point2 pos;
- Node2D *parent_node2d = parent->cast_to<Node2D>();
+ Node2D *parent_node2d = Object::cast_to<Node2D>(parent);
if (parent_node2d) {
pos = parent_node2d->get_global_position();
} else {
- Control *parent_control = parent->cast_to<Control>();
+ Control *parent_control = Object::cast_to<Control>(parent);
if (parent_control) {
pos = parent_control->get_global_position();
}
@@ -3879,7 +3867,7 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons
Transform2D trans = canvas->get_canvas_transform();
Vector2 target_pos = (p_point - trans.get_origin()) / trans.get_scale().x - pos;
// in relative snapping it may be useful for the user to take the original node position into account
- Vector2 start_pos = instanced_scene->cast_to<Node2D>() ? instanced_scene->cast_to<Node2D>()->get_position() : target_pos;
+ Vector2 start_pos = Object::cast_to<Node2D>(instanced_scene) ? Object::cast_to<Node2D>(instanced_scene)->get_position() : target_pos;
target_pos = canvas->snap_point(target_pos, start_pos);
editor_data->get_undo_redo().add_do_method(instanced_scene, "set_position", target_pos);
@@ -3899,8 +3887,8 @@ void CanvasItemEditorViewport::_perform_drop_data() {
if (res.is_null()) {
continue;
}
- Ref<Texture> texture = Ref<Texture>(res->cast_to<Texture>());
- Ref<PackedScene> scene = Ref<PackedScene>(res->cast_to<PackedScene>());
+ Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
+ Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
if (texture != NULL) {
Node *child;
if (default_type == "Light2D")
@@ -4016,7 +4004,7 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
button_group->get_buttons(&btn_list);
for (int i = 0; i < btn_list.size(); i++) {
- CheckBox *check = btn_list[i]->cast_to<CheckBox>();
+ CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]);
check->set_pressed(check->get_text() == default_type);
}
selector_label->set_text(vformat(TTR("Add %s"), default_type));
diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp
index 346c00df64..dd9bd6c34a 100644
--- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp
@@ -343,7 +343,7 @@ void CollisionPolygon2DEditor::edit(Node *p_collision_polygon) {
if (p_collision_polygon) {
- node = p_collision_polygon->cast_to<CollisionPolygon2D>();
+ node = Object::cast_to<CollisionPolygon2D>(p_collision_polygon);
if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
wip.clear();
@@ -403,7 +403,7 @@ CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) {
void CollisionPolygon2DEditorPlugin::edit(Object *p_object) {
- collision_polygon_editor->edit(p_object->cast_to<Node>());
+ collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
}
bool CollisionPolygon2DEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp
index 5b364ed2c1..5520d196e0 100644
--- a/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -464,7 +464,7 @@ void CollisionPolygonEditor::edit(Node *p_collision_polygon) {
if (p_collision_polygon) {
- node = p_collision_polygon->cast_to<CollisionPolygon>();
+ node = Object::cast_to<CollisionPolygon>(p_collision_polygon);
wip.clear();
wip_active = false;
edited_point = -1;
@@ -555,7 +555,7 @@ CollisionPolygonEditor::~CollisionPolygonEditor() {
void CollisionPolygonEditorPlugin::edit(Object *p_object) {
- collision_polygon_editor->edit(p_object->cast_to<Node>());
+ collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
}
bool CollisionPolygonEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp
index fb2aa16383..945801548c 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -393,21 +393,21 @@ void CollisionShape2DEditor::_get_current_shape_type() {
return;
}
- if (s->cast_to<CapsuleShape2D>()) {
+ if (Object::cast_to<CapsuleShape2D>(*s)) {
shape_type = CAPSULE_SHAPE;
- } else if (s->cast_to<CircleShape2D>()) {
+ } else if (Object::cast_to<CircleShape2D>(*s)) {
shape_type = CIRCLE_SHAPE;
- } else if (s->cast_to<ConcavePolygonShape2D>()) {
+ } else if (Object::cast_to<ConcavePolygonShape2D>(*s)) {
shape_type = CONCAVE_POLYGON_SHAPE;
- } else if (s->cast_to<ConvexPolygonShape2D>()) {
+ } else if (Object::cast_to<ConvexPolygonShape2D>(*s)) {
shape_type = CONVEX_POLYGON_SHAPE;
- } else if (s->cast_to<LineShape2D>()) {
+ } else if (Object::cast_to<LineShape2D>(*s)) {
shape_type = LINE_SHAPE;
- } else if (s->cast_to<RayShape2D>()) {
+ } else if (Object::cast_to<RayShape2D>(*s)) {
shape_type = RAY_SHAPE;
- } else if (s->cast_to<RectangleShape2D>()) {
+ } else if (Object::cast_to<RectangleShape2D>(*s)) {
shape_type = RECTANGLE_SHAPE;
- } else if (s->cast_to<SegmentShape2D>()) {
+ } else if (Object::cast_to<SegmentShape2D>(*s)) {
shape_type = SEGMENT_SHAPE;
} else {
shape_type = -1;
@@ -530,7 +530,7 @@ void CollisionShape2DEditor::edit(Node *p_node) {
}
if (p_node) {
- node = p_node->cast_to<CollisionShape2D>();
+ node = Object::cast_to<CollisionShape2D>(p_node);
if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
@@ -570,7 +570,7 @@ CollisionShape2DEditor::CollisionShape2DEditor(EditorNode *p_editor) {
void CollisionShape2DEditorPlugin::edit(Object *p_obj) {
- collision_shape_2d_editor->edit(p_obj->cast_to<Node>());
+ collision_shape_2d_editor->edit(Object::cast_to<Node>(p_obj));
}
bool CollisionShape2DEditorPlugin::handles(Object *p_obj) const {
diff --git a/editor/plugins/cube_grid_theme_editor_plugin.cpp b/editor/plugins/cube_grid_theme_editor_plugin.cpp
index 1fcd514b31..84faa8a265 100644
--- a/editor/plugins/cube_grid_theme_editor_plugin.cpp
+++ b/editor/plugins/cube_grid_theme_editor_plugin.cpp
@@ -72,10 +72,10 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
Node *child = p_scene->get_child(i);
- if (!child->cast_to<MeshInstance>()) {
+ if (!Object::cast_to<MeshInstance>(child)) {
if (child->get_child_count() > 0) {
child = child->get_child(0);
- if (!child->cast_to<MeshInstance>()) {
+ if (!Object::cast_to<MeshInstance>(child)) {
continue;
}
@@ -83,7 +83,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
continue;
}
- MeshInstance *mi = child->cast_to<MeshInstance>();
+ MeshInstance *mi = Object::cast_to<MeshInstance>(child);
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_null())
continue;
@@ -103,10 +103,10 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j);
- if (!child2->cast_to<StaticBody>())
+ if (!Object::cast_to<StaticBody>(child2))
continue;
- StaticBody *sb = child2->cast_to<StaticBody>();
+ StaticBody *sb = Object::cast_to<StaticBody>(child2);
List<uint32_t> shapes;
sb->get_shape_owners(&shapes);
@@ -140,9 +140,9 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
Ref<NavigationMesh> navmesh;
for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j);
- if (!child2->cast_to<NavigationMeshInstance>())
+ if (!Object::cast_to<NavigationMeshInstance>(child2))
continue;
- NavigationMeshInstance *sb = child2->cast_to<NavigationMeshInstance>();
+ NavigationMeshInstance *sb = Object::cast_to<NavigationMeshInstance>(child2);
navmesh = sb->get_navigation_mesh();
if (!navmesh.is_null())
break;
@@ -341,8 +341,8 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
void MeshLibraryEditorPlugin::edit(Object *p_node) {
- if (p_node && p_node->cast_to<MeshLibrary>()) {
- theme_editor->edit(p_node->cast_to<MeshLibrary>());
+ if (Object::cast_to<MeshLibrary>(p_node)) {
+ theme_editor->edit(Object::cast_to<MeshLibrary>(p_node));
theme_editor->show();
} else
theme_editor->hide();
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 2d05c8eba1..5f50978693 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -786,24 +786,24 @@ void CurveEditorPlugin::edit(Object *p_object) {
Ref<Curve> curve_ref;
if (_current_ref.is_valid()) {
- CurveTexture *ct = _current_ref->cast_to<CurveTexture>();
+ CurveTexture *ct = Object::cast_to<CurveTexture>(*_current_ref);
if (ct)
ct->disconnect(CoreStringNames::get_singleton()->changed, this, "_curve_texture_changed");
}
if (p_object) {
- Resource *res = p_object->cast_to<Resource>();
+ Resource *res = Object::cast_to<Resource>(p_object);
ERR_FAIL_COND(res == NULL);
ERR_FAIL_COND(!handles(p_object));
- _current_ref = Ref<Resource>(p_object->cast_to<Resource>());
+ _current_ref = Ref<Resource>(Object::cast_to<Resource>(p_object));
if (_current_ref.is_valid()) {
- Curve *curve = _current_ref->cast_to<Curve>();
+ Curve *curve = Object::cast_to<Curve>(*_current_ref);
if (curve)
curve_ref = Ref<Curve>(curve);
else {
- CurveTexture *ct = _current_ref->cast_to<CurveTexture>();
+ CurveTexture *ct = Object::cast_to<CurveTexture>(*_current_ref);
if (ct) {
ct->connect(CoreStringNames::get_singleton()->changed, this, "_curve_texture_changed");
curve_ref = ct->get_curve();
@@ -820,7 +820,7 @@ void CurveEditorPlugin::edit(Object *p_object) {
bool CurveEditorPlugin::handles(Object *p_object) const {
// Both handled so that we can keep the curve editor open
- return p_object->cast_to<Curve>() || p_object->cast_to<CurveTexture>();
+ return Object::cast_to<Curve>(p_object) || Object::cast_to<CurveTexture>(p_object);
}
void CurveEditorPlugin::make_visible(bool p_visible) {
@@ -837,7 +837,7 @@ void CurveEditorPlugin::make_visible(bool p_visible) {
void CurveEditorPlugin::_curve_texture_changed() {
// If the curve is shown indirectly as a CurveTexture is edited,
// we need to monitor when the curve property gets assigned
- CurveTexture *ct = _current_ref->cast_to<CurveTexture>();
+ CurveTexture *ct = Object::cast_to<CurveTexture>(*_current_ref);
if (ct) {
_view->set_curve(ct->get_curve());
}
diff --git a/editor/plugins/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp
index a8f840a8b1..bac35dbdb0 100644
--- a/editor/plugins/gi_probe_editor_plugin.cpp
+++ b/editor/plugins/gi_probe_editor_plugin.cpp
@@ -38,7 +38,7 @@ void GIProbeEditorPlugin::_bake() {
void GIProbeEditorPlugin::edit(Object *p_object) {
- GIProbe *s = p_object->cast_to<GIProbe>();
+ GIProbe *s = Object::cast_to<GIProbe>(p_object);
if (!s)
return;
diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp
index 4aaa155cfd..f6e50988de 100644
--- a/editor/plugins/gradient_editor_plugin.cpp
+++ b/editor/plugins/gradient_editor_plugin.cpp
@@ -46,7 +46,7 @@ GradientEditorPlugin::GradientEditorPlugin(EditorNode *p_node) {
void GradientEditorPlugin::edit(Object *p_object) {
- Gradient *gradient = p_object->cast_to<Gradient>();
+ Gradient *gradient = Object::cast_to<Gradient>(p_object);
if (!gradient)
return;
gradient_ref = Ref<Gradient>(gradient);
diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp
index f567abc5b1..99eb02c5df 100644
--- a/editor/plugins/item_list_editor_plugin.cpp
+++ b/editor/plugins/item_list_editor_plugin.cpp
@@ -115,7 +115,7 @@ void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const {
void ItemListOptionButtonPlugin::set_object(Object *p_object) {
- ob = p_object->cast_to<OptionButton>();
+ ob = Object::cast_to<OptionButton>(p_object);
}
bool ItemListOptionButtonPlugin::handles(Object *p_object) const {
@@ -155,9 +155,9 @@ ItemListOptionButtonPlugin::ItemListOptionButtonPlugin() {
void ItemListPopupMenuPlugin::set_object(Object *p_object) {
if (p_object->is_class("MenuButton"))
- pp = p_object->cast_to<MenuButton>()->get_popup();
+ pp = Object::cast_to<MenuButton>(p_object)->get_popup();
else
- pp = p_object->cast_to<PopupMenu>();
+ pp = Object::cast_to<PopupMenu>(p_object);
}
bool ItemListPopupMenuPlugin::handles(Object *p_object) const {
@@ -196,7 +196,7 @@ ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() {
void ItemListItemListPlugin::set_object(Object *p_object) {
- pp = p_object->cast_to<ItemList>();
+ pp = Object::cast_to<ItemList>(p_object);
}
bool ItemListItemListPlugin::handles(Object *p_object) const {
@@ -384,7 +384,7 @@ ItemListEditor::~ItemListEditor() {
void ItemListEditorPlugin::edit(Object *p_object) {
- item_list_editor->edit(p_object->cast_to<Node>());
+ item_list_editor->edit(Object::cast_to<Node>(p_object));
}
bool ItemListEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp
index a7a20e71fe..14d9f39913 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -367,7 +367,7 @@ void LightOccluder2DEditor::edit(Node *p_collision_polygon) {
if (p_collision_polygon) {
- node = p_collision_polygon->cast_to<LightOccluder2D>();
+ node = Object::cast_to<LightOccluder2D>(p_collision_polygon);
if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
wip.clear();
@@ -441,7 +441,7 @@ LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) {
void LightOccluder2DEditorPlugin::edit(Object *p_object) {
- collision_polygon_editor->edit(p_object->cast_to<Node>());
+ collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
}
bool LightOccluder2DEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp
index 41327fb07e..36e2999fe2 100644
--- a/editor/plugins/line_2d_editor_plugin.cpp
+++ b/editor/plugins/line_2d_editor_plugin.cpp
@@ -189,7 +189,7 @@ void Line2DEditor::edit(Node *p_line2d) {
canvas_item_editor = CanvasItemEditor::get_singleton();
if (p_line2d) {
- node = p_line2d->cast_to<Line2D>();
+ node = Object::cast_to<Line2D>(p_line2d);
if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
if (!node->is_connected("visibility_changed", this, "_node_visibility_changed"))
@@ -276,7 +276,7 @@ Line2DEditor::Line2DEditor(EditorNode *p_editor) {
//----------------------------------------------------------------------------
void Line2DEditorPlugin::edit(Object *p_object) {
- line2d_editor->edit(p_object->cast_to<Node>());
+ line2d_editor->edit(Object::cast_to<Node>(p_object));
}
bool Line2DEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index 179ef27eda..751f39e55d 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -372,7 +372,7 @@ MaterialEditor::MaterialEditor() {
void MaterialEditorPlugin::edit(Object *p_object) {
- Material * s = p_object->cast_to<Material>();
+ Material * s = Object::cast_to<Material>(p_object);
if (!s)
return;
diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp
index 23b19e61b9..c87f274345 100644
--- a/editor/plugins/mesh_editor_plugin.cpp
+++ b/editor/plugins/mesh_editor_plugin.cpp
@@ -187,7 +187,7 @@ MeshEditor::MeshEditor() {
void MeshEditorPlugin::edit(Object *p_object) {
- Mesh *s = p_object->cast_to<Mesh>();
+ Mesh *s = Object::cast_to<Mesh>(p_object);
if (!s)
return;
diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp
index 49498d0fa0..06fca06bab 100644
--- a/editor/plugins/mesh_instance_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_editor_plugin.cpp
@@ -101,7 +101,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- MeshInstance *instance = E->get()->cast_to<MeshInstance>();
+ MeshInstance *instance = Object::cast_to<MeshInstance>(E->get());
if (!instance)
continue;
@@ -290,7 +290,7 @@ MeshInstanceEditor::MeshInstanceEditor() {
void MeshInstanceEditorPlugin::edit(Object *p_object) {
- mesh_editor->edit(p_object->cast_to<MeshInstance>());
+ mesh_editor->edit(Object::cast_to<MeshInstance>(p_object));
}
bool MeshInstanceEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp
index a9689cce56..6ecb49b16c 100644
--- a/editor/plugins/multimesh_editor_plugin.cpp
+++ b/editor/plugins/multimesh_editor_plugin.cpp
@@ -77,7 +77,7 @@ void MultiMeshEditor::_populate() {
return;
}
- MeshInstance *ms_instance = ms_node->cast_to<MeshInstance>();
+ MeshInstance *ms_instance = Object::cast_to<MeshInstance>(ms_node);
if (!ms_instance) {
@@ -112,7 +112,7 @@ void MultiMeshEditor::_populate() {
return;
}
- GeometryInstance *ss_instance = ss_node->cast_to<MeshInstance>();
+ GeometryInstance *ss_instance = Object::cast_to<MeshInstance>(ss_node);
if (!ss_instance) {
@@ -155,7 +155,7 @@ void MultiMeshEditor::_populate() {
ERR_EXPLAIN("Multimesh not present.");
ERR_FAIL_COND(multimesh.is_null());
- VisualInstance *vi = get_parent()->cast_to<VisualInstance>();
+ VisualInstance *vi = Object::cast_to<VisualInstance>(get_parent());
ERR_EXPLAIN("Parent is not of type VisualInstance, can't be populated.");
ERR_FAIL_COND(!vi);
@@ -402,7 +402,7 @@ MultiMeshEditor::MultiMeshEditor() {
void MultiMeshEditorPlugin::edit(Object *p_object) {
- multimesh_editor->edit(p_object->cast_to<MultiMeshInstance>());
+ multimesh_editor->edit(Object::cast_to<MultiMeshInstance>(p_object));
}
bool MultiMeshEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp
index 725e57fe0b..663db26ac3 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -422,7 +422,7 @@ void NavigationPolygonEditor::edit(Node *p_collision_polygon) {
if (p_collision_polygon) {
- node = p_collision_polygon->cast_to<NavigationPolygonInstance>();
+ node = Object::cast_to<NavigationPolygonInstance>(p_collision_polygon);
if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
wip.clear();
@@ -486,7 +486,7 @@ NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) {
void NavigationPolygonEditorPlugin::edit(Object *p_object) {
- collision_polygon_editor->edit(p_object->cast_to<Node>());
+ collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
}
bool NavigationPolygonEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp
index a759e5892f..076e27c741 100644
--- a/editor/plugins/particles_2d_editor_plugin.cpp
+++ b/editor/plugins/particles_2d_editor_plugin.cpp
@@ -33,13 +33,10 @@
#include "io/image_loader.h"
#include "scene/3d/particles.h"
#include "scene/gui/separator.h"
+
void Particles2DEditorPlugin::edit(Object *p_object) {
- if (p_object) {
- particles = p_object->cast_to<Particles2D>();
- } else {
- particles = NULL;
- }
+ particles = Object::cast_to<Particles2D>(p_object);
}
bool Particles2DEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp
index 1e3723a911..ef959682c4 100644
--- a/editor/plugins/particles_editor_plugin.cpp
+++ b/editor/plugins/particles_editor_plugin.cpp
@@ -51,7 +51,7 @@ void ParticlesEditor::_node_selected(const NodePath &p_path) {
if (!sel)
return;
- VisualInstance *vi = sel->cast_to<VisualInstance>();
+ VisualInstance *vi = Object::cast_to<VisualInstance>(sel);
if (!vi) {
err_dialog->set_text(TTR("Node does not contain geometry."));
@@ -135,7 +135,7 @@ void ParticlesEditor::_menu_option(int p_option) {
/*
Node *root = get_scene()->get_root_node();
ERR_FAIL_COND(!root);
- EditorNode *en = root->cast_to<EditorNode>();
+ EditorNode *en = Object::cast_to<EditorNode>(root);
ERR_FAIL_COND(!en);
Node * node = en->get_edited_scene();
*/
@@ -461,7 +461,7 @@ ParticlesEditor::ParticlesEditor() {
void ParticlesEditorPlugin::edit(Object *p_object) {
- particles_editor->edit(p_object->cast_to<Particles>());
+ particles_editor->edit(Object::cast_to<Particles>(p_object));
}
bool ParticlesEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp
index 3a210f3fe0..693614b552 100644
--- a/editor/plugins/path_2d_editor_plugin.cpp
+++ b/editor/plugins/path_2d_editor_plugin.cpp
@@ -534,7 +534,7 @@ void Path2DEditor::edit(Node *p_path2d) {
if (p_path2d) {
- node = p_path2d->cast_to<Path2D>();
+ node = Object::cast_to<Path2D>(p_path2d);
if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
if (!node->is_connected("visibility_changed", this, "_node_visibility_changed"))
@@ -676,7 +676,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) {
void Path2DEditorPlugin::edit(Object *p_object) {
- path2d_editor->edit(p_object->cast_to<Node>());
+ path2d_editor->edit(Object::cast_to<Node>(p_object));
}
bool Path2DEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp
index 96a98f3c48..45343ec2dd 100644
--- a/editor/plugins/path_editor_plugin.cpp
+++ b/editor/plugins/path_editor_plugin.cpp
@@ -269,9 +269,9 @@ PathSpatialGizmo::PathSpatialGizmo(Path *p_path) {
Ref<SpatialEditorGizmo> PathEditorPlugin::create_spatial_gizmo(Spatial *p_spatial) {
- if (p_spatial->cast_to<Path>()) {
+ if (Object::cast_to<Path>(p_spatial)) {
- return memnew(PathSpatialGizmo(p_spatial->cast_to<Path>()));
+ return memnew(PathSpatialGizmo(Object::cast_to<Path>(p_spatial)));
}
return Ref<SpatialEditorGizmo>();
@@ -433,7 +433,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp
void PathEditorPlugin::edit(Object *p_object) {
if (p_object) {
- path = p_object->cast_to<Path>();
+ path = Object::cast_to<Path>(p_object);
if (path) {
if (path->get_curve().is_valid()) {
@@ -447,7 +447,7 @@ void PathEditorPlugin::edit(Object *p_object) {
pre->get_curve()->emit_signal("changed");
}
}
- //collision_polygon_editor->edit(p_object->cast_to<Node>());
+ //collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
}
bool PathEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index 24ccdcd445..74df553bde 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -697,7 +697,7 @@ void Polygon2DEditor::edit(Node *p_collision_polygon) {
if (p_collision_polygon) {
- node = p_collision_polygon->cast_to<Polygon2D>();
+ node = Object::cast_to<Polygon2D>(p_collision_polygon);
if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
@@ -925,7 +925,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) {
void Polygon2DEditorPlugin::edit(Object *p_object) {
- collision_polygon_editor->edit(p_object->cast_to<Node>());
+ collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
}
bool Polygon2DEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index ccefbc1843..001db2cbc5 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -410,7 +410,7 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() {
void ResourcePreloaderEditorPlugin::edit(Object *p_object) {
preloader_editor->set_undo_redo(&get_undo_redo());
- ResourcePreloader *s = p_object->cast_to<ResourcePreloader>();
+ ResourcePreloader *s = Object::cast_to<ResourcePreloader>(p_object);
if (!s)
return;
diff --git a/editor/plugins/rich_text_editor_plugin.cpp b/editor/plugins/rich_text_editor_plugin.cpp
index 07c0cced49..2a6474023c 100644
--- a/editor/plugins/rich_text_editor_plugin.cpp
+++ b/editor/plugins/rich_text_editor_plugin.cpp
@@ -91,7 +91,7 @@ void RichTextEditor::_bind_methods() {
void RichTextEditor::edit(Node *p_rich_text) {
- node = p_rich_text->cast_to<RichTextLabel>();
+ node = Object::cast_to<RichTextLabel>(p_rich_text);
}
RichTextEditor::RichTextEditor() {
@@ -114,7 +114,7 @@ RichTextEditor::RichTextEditor() {
void RichTextEditorPlugin::edit(Object *p_object) {
- rich_text_editor->edit(p_object->cast_to<Node>());
+ rich_text_editor->edit(Object::cast_to<Node>(p_object));
}
bool RichTextEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/sample_editor_plugin.cpp b/editor/plugins/sample_editor_plugin.cpp
index 2dd6de1683..f6f776f670 100644
--- a/editor/plugins/sample_editor_plugin.cpp
+++ b/editor/plugins/sample_editor_plugin.cpp
@@ -408,7 +408,7 @@ SampleEditor::SampleEditor() {
void SampleEditorPlugin::edit(Object *p_object) {
- Sample * s = p_object->cast_to<Sample>();
+ Sample * s = Object::cast_to<Sample>(p_object);
if (!s)
return;
diff --git a/editor/plugins/sample_library_editor_plugin.cpp b/editor/plugins/sample_library_editor_plugin.cpp
index 3deb634491..761301610e 100644
--- a/editor/plugins/sample_library_editor_plugin.cpp
+++ b/editor/plugins/sample_library_editor_plugin.cpp
@@ -47,7 +47,7 @@ void SampleLibraryEditor::_notification(int p_what) {
if (p_what==NOTIFICATION_PROCESS) {
if (is_playing && !player->is_active()) {
- TreeItem *tl=last_sample_playing->cast_to<TreeItem>();
+ TreeItem *tl=Object::cast_to<TreeItem>(last_sample_playing);
tl->set_button(0,0,get_icon("Play","EditorIcons"));
is_playing = false;
set_process(false);
@@ -109,7 +109,7 @@ void SampleLibraryEditor::_load_pressed() {
void SampleLibraryEditor::_button_pressed(Object *p_item,int p_column, int p_id) {
- TreeItem *ti=p_item->cast_to<TreeItem>();
+ TreeItem *ti=Object::cast_to<TreeItem>(p_item);
String name = ti->get_text(0);
if (p_column==0) { // Play/Stop
@@ -124,7 +124,7 @@ void SampleLibraryEditor::_button_pressed(Object *p_item,int p_column, int p_id)
} else {
player->stop_all();
if(last_sample_playing != p_item){
- TreeItem *tl=last_sample_playing->cast_to<TreeItem>();
+ TreeItem *tl=Object::cast_to<TreeItem>(last_sample_playing);
tl->set_button(p_column,0,get_icon("Play","EditorIcons"));
btn_type = TTR("Stop");
player->play(name,true);
@@ -491,7 +491,7 @@ SampleLibraryEditor::SampleLibraryEditor() {
void SampleLibraryEditorPlugin::edit(Object *p_object) {
sample_library_editor->set_undo_redo(&get_undo_redo());
- SampleLibrary * s = p_object->cast_to<SampleLibrary>();
+ SampleLibrary * s = Object::cast_to<SampleLibrary>(p_object);
if (!s)
return;
diff --git a/editor/plugins/sample_player_editor_plugin.cpp b/editor/plugins/sample_player_editor_plugin.cpp
index ea9b646a9b..821c7ecc01 100644
--- a/editor/plugins/sample_player_editor_plugin.cpp
+++ b/editor/plugins/sample_player_editor_plugin.cpp
@@ -152,7 +152,7 @@ SamplePlayerEditor::SamplePlayerEditor() {
void SamplePlayerEditorPlugin::edit(Object *p_object) {
- sample_player_editor->edit(p_object->cast_to<Node>());
+ sample_player_editor->edit(Object::cast_to<Node>(p_object));
}
bool SamplePlayerEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index e8770febd9..5b0891e0cd 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -256,7 +256,7 @@ ScriptEditor *ScriptEditor::script_editor = NULL;
String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) {
- //ScriptEditorBase *se=_se->cast_to<ScriptEditorBase>();
+ //ScriptEditorBase *se=Object::cast_to<ScriptEditorBase>(_se);
String val = debugger->get_var_value(p_text);
if (val != String()) {
@@ -280,7 +280,7 @@ void ScriptEditor::_breaked(bool p_breaked, bool p_can_debug) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
continue;
@@ -305,7 +305,7 @@ void ScriptEditor::_goto_script_line2(int p_line) {
if (selected < 0 || selected >= tab_container->get_child_count())
return;
- ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (!current)
return;
@@ -318,7 +318,7 @@ void ScriptEditor::_goto_script_line(REF p_script, int p_line) {
if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
- Ref<Script> script = p_script->cast_to<Script>();
+ Ref<Script> script = Object::cast_to<Script>(*p_script);
if (!script.is_null() && script->get_path().is_resource_file())
edit(p_script, p_line, 0);
}
@@ -327,7 +327,7 @@ void ScriptEditor::_goto_script_line(REF p_script, int p_line) {
if (selected < 0 || selected >= tab_container->get_child_count())
return;
- ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (!current)
return;
@@ -346,13 +346,13 @@ void ScriptEditor::_save_history() {
Node *n = tab_container->get_current_tab_control();
- if (n->cast_to<ScriptEditorBase>()) {
+ if (Object::cast_to<ScriptEditorBase>(n)) {
- history[history_pos].state = n->cast_to<ScriptEditorBase>()->get_edit_state();
+ history[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state();
}
- if (n->cast_to<EditorHelp>()) {
+ if (Object::cast_to<EditorHelp>(n)) {
- history[history_pos].state = n->cast_to<EditorHelp>()->get_scroll();
+ history[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
}
}
@@ -369,10 +369,7 @@ void ScriptEditor::_save_history() {
void ScriptEditor::_go_to_tab(int p_idx) {
- Node *cn = tab_container->get_child(p_idx);
- if (!cn)
- return;
- Control *c = cn->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(tab_container->get_child(p_idx));
if (!c)
return;
@@ -380,13 +377,13 @@ void ScriptEditor::_go_to_tab(int p_idx) {
Node *n = tab_container->get_current_tab_control();
- if (n->cast_to<ScriptEditorBase>()) {
+ if (Object::cast_to<ScriptEditorBase>(n)) {
- history[history_pos].state = n->cast_to<ScriptEditorBase>()->get_edit_state();
+ history[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state();
}
- if (n->cast_to<EditorHelp>()) {
+ if (Object::cast_to<EditorHelp>(n)) {
- history[history_pos].state = n->cast_to<EditorHelp>()->get_scroll();
+ history[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
}
}
@@ -402,21 +399,21 @@ void ScriptEditor::_go_to_tab(int p_idx) {
c = tab_container->get_current_tab_control();
- if (c->cast_to<ScriptEditorBase>()) {
+ if (Object::cast_to<ScriptEditorBase>(c)) {
- script_name_label->set_text(c->cast_to<ScriptEditorBase>()->get_name());
- script_icon->set_texture(c->cast_to<ScriptEditorBase>()->get_icon());
+ script_name_label->set_text(Object::cast_to<ScriptEditorBase>(c)->get_name());
+ script_icon->set_texture(Object::cast_to<ScriptEditorBase>(c)->get_icon());
if (is_visible_in_tree())
- c->cast_to<ScriptEditorBase>()->ensure_focus();
+ Object::cast_to<ScriptEditorBase>(c)->ensure_focus();
- notify_script_changed(c->cast_to<ScriptEditorBase>()->get_edited_script());
+ notify_script_changed(Object::cast_to<ScriptEditorBase>(c)->get_edited_script());
}
- if (c->cast_to<EditorHelp>()) {
+ if (Object::cast_to<EditorHelp>(c)) {
- script_name_label->set_text(c->cast_to<EditorHelp>()->get_class());
+ script_name_label->set_text(Object::cast_to<EditorHelp>(c)->get_class());
script_icon->set_texture(get_icon("Help", "EditorIcons"));
if (is_visible_in_tree())
- c->cast_to<EditorHelp>()->set_focused();
+ Object::cast_to<EditorHelp>(c)->set_focused();
}
c->set_meta("__editor_pass", ++edit_pass);
@@ -508,7 +505,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) {
return;
Node *tselected = tab_container->get_child(selected);
- ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (current) {
_add_recent_script(current->get_edited_script()->get_path());
if (p_save) {
@@ -517,7 +514,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) {
current->clear_edit_menu();
notify_script_close(current->get_edited_script());
} else {
- EditorHelp *help = tab_container->get_child(selected)->cast_to<EditorHelp>();
+ EditorHelp *help = Object::cast_to<EditorHelp>(tab_container->get_child(selected));
_add_recent_script(help->get_class());
}
@@ -575,7 +572,7 @@ void ScriptEditor::_close_docs_tab() {
int child_count = tab_container->get_child_count();
for (int i = child_count - 1; i >= 0; i--) {
- EditorHelp *se = tab_container->get_child(i)->cast_to<EditorHelp>();
+ EditorHelp *se = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (se) {
_close_tab(i);
@@ -589,7 +586,7 @@ void ScriptEditor::_close_all_tabs() {
for (int i = child_count - 1; i >= 0; i--) {
tab_container->set_current_tab(i);
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
@@ -615,7 +612,7 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
@@ -647,7 +644,7 @@ void ScriptEditor::_reload_scripts() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
continue;
@@ -684,7 +681,7 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
continue;
@@ -727,7 +724,7 @@ bool ScriptEditor::_test_script_times_on_disk(Ref<Script> p_for_script) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
Ref<Script> script = se->get_edited_script();
@@ -791,7 +788,7 @@ Ref<Script> ScriptEditor::_get_current_script() {
if (selected < 0 || selected >= tab_container->get_child_count())
return NULL;
- ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (current) {
return current->get_edited_script();
} else {
@@ -865,7 +862,7 @@ void ScriptEditor::_menu_option(int p_option) {
String current;
if (tab_container->get_tab_count() > 0) {
- EditorHelp *eh = tab_container->get_child(tab_container->get_current_tab())->cast_to<EditorHelp>();
+ EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(tab_container->get_current_tab()));
if (eh) {
current = eh->get_class();
}
@@ -919,7 +916,7 @@ void ScriptEditor::_menu_option(int p_option) {
if (selected < 0 || selected >= tab_container->get_child_count())
return;
- ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (current) {
switch (p_option) {
@@ -956,7 +953,7 @@ void ScriptEditor::_menu_option(int p_option) {
current->convert_indent_to_tabs();
}
}
- editor->push_item(current->get_edited_script()->cast_to<Object>());
+ editor->push_item(Object::cast_to<Object>(current->get_edited_script().ptr()));
editor->save_resource_as(current->get_edited_script());
} break;
@@ -1035,7 +1032,7 @@ void ScriptEditor::_menu_option(int p_option) {
}
} else {
- EditorHelp *help = tab_container->get_current_tab_control()->cast_to<EditorHelp>();
+ EditorHelp *help = Object::cast_to<EditorHelp>(tab_container->get_current_tab_control());
if (help) {
switch (p_option) {
@@ -1139,7 +1136,7 @@ bool ScriptEditor::can_take_away_focus() const {
if (selected < 0 || selected >= tab_container->get_child_count())
return true;
- ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (!current)
return true;
@@ -1150,7 +1147,7 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
@@ -1205,7 +1202,7 @@ Dictionary ScriptEditor::get_state() const {
for(int i=0;i<tab_container->get_child_count();i++) {
- ScriptTextEditor *se = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
+ ScriptTextEditor *se = Object::cast_to<ScriptTextEditor>(tab_container->get_child(i));
if (!se)
continue;
@@ -1281,7 +1278,7 @@ void ScriptEditor::clear() {
List<ScriptTextEditor*> stes;
for(int i=0;i<tab_container->get_child_count();i++) {
- ScriptTextEditor *se = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
+ ScriptTextEditor *se = Object::cast_to<ScriptTextEditor>(tab_container->get_child(i));
if (!se)
continue;
stes.push_back(se);
@@ -1309,7 +1306,7 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
@@ -1335,10 +1332,8 @@ void ScriptEditor::ensure_focus_current() {
if (cidx < 0 || cidx >= tab_container->get_tab_count())
return;
- Control *c = tab_container->get_child(cidx)->cast_to<Control>();
- if (!c)
- return;
- ScriptEditorBase *se = c->cast_to<ScriptEditorBase>();
+ Control *c = Object::cast_to<Control>(tab_container->get_child(cidx));
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(c);
if (!se)
return;
se->ensure_focus();
@@ -1346,7 +1341,7 @@ void ScriptEditor::ensure_focus_current() {
void ScriptEditor::_members_overview_selected(int p_idx) {
Node *current = tab_container->get_child(tab_container->get_current_tab());
- ScriptEditorBase *se = current->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(current);
if (!se) {
return;
}
@@ -1368,7 +1363,7 @@ void ScriptEditor::ensure_select_current() {
Node *current = tab_container->get_child(tab_container->get_current_tab());
- ScriptEditorBase *se = current->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(current);
if (se) {
Ref<Script> script = se->get_edited_script();
@@ -1380,7 +1375,7 @@ void ScriptEditor::ensure_select_current() {
//search_menu->show();
}
- EditorHelp *eh = current->cast_to<EditorHelp>();
+ EditorHelp *eh = Object::cast_to<EditorHelp>(current);
if (eh) {
//edit_menu->hide();
@@ -1430,7 +1425,7 @@ void ScriptEditor::_update_members_overview_visibility() {
return;
Node *current = tab_container->get_child(tab_container->get_current_tab());
- ScriptEditorBase *se = current->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(current);
if (!se) {
members_overview->set_visible(false);
return;
@@ -1451,7 +1446,7 @@ void ScriptEditor::_update_members_overview() {
return;
Node *current = tab_container->get_child(tab_container->get_current_tab());
- ScriptEditorBase *se = current->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(current);
if (!se) {
return;
}
@@ -1525,7 +1520,7 @@ void ScriptEditor::_update_script_names() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
String name = se->get_name();
@@ -1568,7 +1563,7 @@ void ScriptEditor::_update_script_names() {
sedata.push_back(sd);
}
- EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>();
+ EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh) {
String name = eh->get_class();
@@ -1663,7 +1658,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
@@ -1733,7 +1728,7 @@ void ScriptEditor::save_all_scripts() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
@@ -1771,7 +1766,7 @@ void ScriptEditor::apply_scripts() const {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
se->apply_code();
@@ -1802,7 +1797,7 @@ void ScriptEditor::_editor_stop() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
continue;
@@ -1823,7 +1818,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
if (se->get_edited_script() != script)
@@ -1874,7 +1869,7 @@ void ScriptEditor::_editor_settings_changed() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
@@ -1977,7 +1972,7 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
String path = se->get_edited_script()->get_path();
@@ -1987,7 +1982,7 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
scripts.push_back(path);
}
- EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>();
+ EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh) {
@@ -2007,7 +2002,7 @@ void ScriptEditor::_help_class_open(const String &p_class) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>();
+ EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh && eh->get_class() == p_class) {
@@ -2034,7 +2029,7 @@ void ScriptEditor::_help_class_goto(const String &p_desc) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
- EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>();
+ EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh && eh->get_class() == cname) {
@@ -2062,7 +2057,7 @@ void ScriptEditor::_update_selected_editor_menu() {
bool current = tab_container->get_current_tab() == i;
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se && se->get_edit_menu()) {
if (current)
@@ -2072,10 +2067,7 @@ void ScriptEditor::_update_selected_editor_menu() {
}
}
- EditorHelp *eh = NULL;
- if (tab_container->get_current_tab_control())
- eh = tab_container->get_current_tab_control()->cast_to<EditorHelp>();
-
+ EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_current_tab_control());
if (eh) {
script_search_menu->show();
} else {
@@ -2087,13 +2079,13 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
Node *n = tab_container->get_current_tab_control();
- if (n->cast_to<ScriptEditorBase>()) {
+ if (Object::cast_to<ScriptEditorBase>(n)) {
- history[history_pos].state = n->cast_to<ScriptEditorBase>()->get_edit_state();
+ history[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state();
}
- if (n->cast_to<EditorHelp>()) {
+ if (Object::cast_to<EditorHelp>(n)) {
- history[history_pos].state = n->cast_to<EditorHelp>()->get_scroll();
+ history[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
}
history_pos = p_new_pos;
@@ -2101,18 +2093,18 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
n = history[history_pos].control;
- if (n->cast_to<ScriptEditorBase>()) {
+ if (Object::cast_to<ScriptEditorBase>(n)) {
- n->cast_to<ScriptEditorBase>()->set_edit_state(history[history_pos].state);
- n->cast_to<ScriptEditorBase>()->ensure_focus();
+ Object::cast_to<ScriptEditorBase>(n)->set_edit_state(history[history_pos].state);
+ Object::cast_to<ScriptEditorBase>(n)->ensure_focus();
- notify_script_changed(n->cast_to<ScriptEditorBase>()->get_edited_script());
+ notify_script_changed(Object::cast_to<ScriptEditorBase>(n)->get_edited_script());
}
- if (n->cast_to<EditorHelp>()) {
+ if (Object::cast_to<EditorHelp>(n)) {
- n->cast_to<EditorHelp>()->set_scroll(history[history_pos].state);
- n->cast_to<EditorHelp>()->set_focused();
+ Object::cast_to<EditorHelp>(n)->set_scroll(history[history_pos].state);
+ Object::cast_to<EditorHelp>(n)->set_focused();
}
n->set_meta("__editor_pass", ++edit_pass);
@@ -2140,7 +2132,7 @@ Vector<Ref<Script> > ScriptEditor::get_open_scripts() const {
Vector<Ref<Script> > out_scripts = Vector<Ref<Script> >();
for (int i = 0; i < tab_container->get_child_count(); i++) {
- ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
out_scripts.push_back(se->get_edited_script());
@@ -2510,17 +2502,17 @@ ScriptEditor::~ScriptEditor() {
void ScriptEditorPlugin::edit(Object *p_object) {
- if (!p_object->cast_to<Script>())
+ if (!Object::cast_to<Script>(p_object))
return;
- script_editor->edit(p_object->cast_to<Script>());
+ script_editor->edit(Object::cast_to<Script>(p_object));
}
bool ScriptEditorPlugin::handles(Object *p_object) const {
- if (p_object->cast_to<Script>()) {
+ if (Object::cast_to<Script>(p_object)) {
- bool valid = _can_open_in_editor(p_object->cast_to<Script>());
+ bool valid = _can_open_in_editor(Object::cast_to<Script>(p_object));
if (!valid) { //user tried to open it by clicking
EditorNode::get_singleton()->show_warning(TTR("Built-in scripts can only be edited when the scene they belong to is loaded"));
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index bad88979ac..251416f853 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -288,7 +288,7 @@ Dictionary ShaderEditor::get_state() const {
for(int i=0;i<tab_container->get_child_count();i++) {
- ShaderTextEditor *ste = tab_container->get_child(i)->cast_to<ShaderTextEditor>();
+ ShaderTextEditor *ste = tab_container->Object::cast_to<ShaderTextEditor>(get_child(i));
if (!ste)
continue;
@@ -397,7 +397,7 @@ void ShaderEditor::ensure_select_current() {
/*
if (tab_container->get_child_count() && tab_container->get_current_tab()>=0) {
- ShaderTextEditor *ste = tab_container->get_child(tab_container->get_current_tab())->cast_to<ShaderTextEditor>();
+ ShaderTextEditor *ste = Object::cast_to<ShaderTextEditor>(tab_container->get_child(tab_container->get_current_tab()));
if (!ste)
return;
Ref<Shader> shader = ste->get_edited_shader();
@@ -486,16 +486,16 @@ ShaderEditor::ShaderEditor() {
void ShaderEditorPlugin::edit(Object *p_object) {
- Shader *s = p_object->cast_to<Shader>();
+ Shader *s = Object::cast_to<Shader>(p_object);
shader_editor->edit(s);
}
bool ShaderEditorPlugin::handles(Object *p_object) const {
bool handles = true;
- Shader *shader = p_object->cast_to<Shader>();
+ Shader *shader = Object::cast_to<Shader>(p_object);
/*
- if (!shader || shader->cast_to<ShaderGraph>()) // Don't handle ShaderGraph's
+ if (Object::cast_to<ShaderGraph>(shader)) // Don't handle ShaderGraph's
handles = false;
*/
diff --git a/editor/plugins/shader_graph_editor_plugin.cpp b/editor/plugins/shader_graph_editor_plugin.cpp
index 5506c035ec..7ad32464af 100644
--- a/editor/plugins/shader_graph_editor_plugin.cpp
+++ b/editor/plugins/shader_graph_editor_plugin.cpp
@@ -839,7 +839,7 @@ void ShaderGraphView::_vec_input_changed(double p_value, int p_id,Array p_arr){
void ShaderGraphView::_xform_input_changed(int p_id, Node *p_button){
- ToolButton *tb = p_button->cast_to<ToolButton>();
+ ToolButton *tb = Object::cast_to<ToolButton>(p_button);
ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size());
edited_id=p_id;
@@ -850,7 +850,7 @@ void ShaderGraphView::_xform_input_changed(int p_id, Node *p_button){
}
void ShaderGraphView::_xform_const_changed(int p_id, Node *p_button){
- ToolButton *tb = p_button->cast_to<ToolButton>();
+ ToolButton *tb = Object::cast_to<ToolButton>(p_button);
ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size());
edited_id=p_id;
@@ -964,7 +964,7 @@ void ShaderGraphView::_variant_edited() {
void ShaderGraphView::_comment_edited(int p_id,Node* p_button) {
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
- TextEdit *te=p_button->cast_to<TextEdit>();
+ TextEdit *te=Object::cast_to<TextEdit>(p_button);
ur->create_action(TTR("Change Comment"),UndoRedo::MERGE_ENDS);
ur->add_do_method(graph.ptr(),"comment_node_set_text",type,p_id,te->get_text());
ur->add_undo_method(graph.ptr(),"comment_node_set_text",type,p_id,graph->comment_node_get_text(type,p_id));
@@ -978,7 +978,7 @@ void ShaderGraphView::_comment_edited(int p_id,Node* p_button) {
void ShaderGraphView::_color_ramp_changed(int p_id,Node* p_ramp) {
- GraphColorRampEdit *cr=p_ramp->cast_to<GraphColorRampEdit>();
+ GraphColorRampEdit *cr=Object::cast_to<GraphColorRampEdit>(p_ramp);
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
@@ -1020,7 +1020,7 @@ void ShaderGraphView::_color_ramp_changed(int p_id,Node* p_ramp) {
void ShaderGraphView::_curve_changed(int p_id,Node* p_curve) {
- GraphCurveMapEdit *cr=p_curve->cast_to<GraphCurveMapEdit>();
+ GraphCurveMapEdit *cr=Object::cast_to<GraphCurveMapEdit>(p_curve);
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
@@ -1057,7 +1057,7 @@ void ShaderGraphView::_curve_changed(int p_id,Node* p_curve) {
void ShaderGraphView::_input_name_changed(const String& p_name, int p_id, Node *p_line_edit) {
- LineEdit *le=p_line_edit->cast_to<LineEdit>();
+ LineEdit *le=Object::cast_to<LineEdit>(p_line_edit);
ERR_FAIL_COND(!le);
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
@@ -1074,7 +1074,7 @@ void ShaderGraphView::_input_name_changed(const String& p_name, int p_id, Node *
void ShaderGraphView::_tex_edited(int p_id,Node* p_button) {
- ToolButton *tb = p_button->cast_to<ToolButton>();
+ ToolButton *tb = Object::cast_to<ToolButton>(p_button);
ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size());
edited_id=p_id;
@@ -1084,7 +1084,7 @@ void ShaderGraphView::_tex_edited(int p_id,Node* p_button) {
void ShaderGraphView::_cube_edited(int p_id,Node* p_button) {
- ToolButton *tb = p_button->cast_to<ToolButton>();
+ ToolButton *tb = Object::cast_to<ToolButton>(p_button);
ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size());
edited_id=p_id;
@@ -1299,7 +1299,7 @@ void ShaderGraphView::_delete_nodes_request()
void ShaderGraphView::_default_changed(int p_id, Node *p_button, int p_param, int v_type, String p_hint)
{
- ToolButton *tb = p_button->cast_to<ToolButton>();
+ ToolButton *tb = Object::cast_to<ToolButton>(p_button);
ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size());
edited_id=p_id;
@@ -2530,7 +2530,7 @@ void ShaderGraphView::_sg_updated() {
Variant ShaderGraphView::get_drag_data_fw(const Point2 &p_point, Control *p_from)
{
- TextureRect* frame = p_from->cast_to<TextureRect>();
+ TextureRect* frame = Object::cast_to<TextureRect>(p_from);
if (!frame)
return Variant();
@@ -2556,7 +2556,7 @@ bool ShaderGraphView::can_drop_data_fw(const Point2 &p_point, const Variant &p_d
if (val.get_type()==Variant::OBJECT) {
RES res = val;
- if (res.is_valid() && res->cast_to<Texture>())
+ if (res.is_valid() && Object::cast_to<Texture>(res))
return true;
}
}
@@ -2576,7 +2576,7 @@ void ShaderGraphView::drop_data_fw(const Point2 &p_point, const Variant &p_data,
if (!can_drop_data_fw(p_point, p_data, p_from))
return;
- TextureRect *frame = p_from->cast_to<TextureRect>();
+ TextureRect *frame = Object::cast_to<TextureRect>(p_from);
if (!frame)
return;
@@ -2590,20 +2590,20 @@ void ShaderGraphView::drop_data_fw(const Point2 &p_point, const Variant &p_data,
if (val.get_type()==Variant::OBJECT) {
RES res = val;
if (res.is_valid())
- tex = Ref<Texture>(res->cast_to<Texture>());
+ tex = Ref<Texture>(Object::cast_to<Texture>(*res));
}
}
else if (d["type"] == "files" && d.has("files")) {
Vector<String> files = d["files"];
RES res = ResourceLoader::load(files[0]);
if (res.is_valid())
- tex = Ref<Texture>(res->cast_to<Texture>());
+ tex = Ref<Texture>(Object::cast_to<Texture>(*res));
}
}
if (!tex.is_valid()) return;
- GraphNode *gn = frame->get_parent()->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(frame->get_parent());
if (!gn) return;
int id = -1;
@@ -2896,12 +2896,12 @@ ShaderGraphEditor::ShaderGraphEditor(bool p_2d) {
void ShaderGraphEditorPlugin::edit(Object *p_object) {
- shader_editor->edit(p_object->cast_to<ShaderGraph>());
+ shader_editor->edit(Object::cast_to<ShaderGraph>(p_object));
}
bool ShaderGraphEditorPlugin::handles(Object *p_object) const {
- ShaderGraph *shader=p_object->cast_to<ShaderGraph>();
+ ShaderGraph *shader=Object::cast_to<ShaderGraph>(p_object);
if (!shader)
return false;
if (_2d)
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 1d25f9e56b..c4e4050539 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -143,7 +143,7 @@ int SpatialEditorViewport::get_selected_count() const {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->key()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->key());
if (!sp)
continue;
@@ -218,11 +218,7 @@ void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single) {
if (!clicked)
return;
- Object *obj = ObjectDB::get_instance(clicked);
- if (!obj)
- return;
-
- Spatial *sp = obj->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(ObjectDB::get_instance(clicked));
if (!sp)
return;
@@ -271,11 +267,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
for (int i = 0; i < instances.size(); i++) {
- Object *obj = ObjectDB::get_instance(instances[i]);
- if (!obj)
- continue;
-
- Spatial *spat = obj->cast_to<Spatial>();
+ Spatial *spat = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i]));
if (!spat)
continue;
@@ -290,7 +282,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
while ((subscene_candidate->get_owner() != NULL) && (subscene_candidate->get_owner() != editor->get_edited_scene()))
subscene_candidate = subscene_candidate->get_owner();
- spat = subscene_candidate->cast_to<Spatial>();
+ spat = Object::cast_to<Spatial>(subscene_candidate);
if (spat && (spat->get_filename() != "") && (subscene_candidate->get_owner() != NULL)) {
subscenes.push_back(spat);
subscenes_positions.push_back(source_click_spatial_pos);
@@ -365,12 +357,7 @@ void SpatialEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_incl
for (int i = 0; i < instances.size(); i++) {
- Object *obj = ObjectDB::get_instance(instances[i]);
-
- if (!obj)
- continue;
-
- Spatial *spat = obj->cast_to<Spatial>();
+ Spatial *spat = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i]));
if (!spat)
continue;
@@ -480,10 +467,7 @@ void SpatialEditorViewport::_select_region() {
for (int i = 0; i < instances.size(); i++) {
- Object *obj = ObjectDB::get_instance(instances[i]);
- if (!obj)
- continue;
- Spatial *sp = obj->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i]));
if (!sp)
continue;
@@ -524,7 +508,7 @@ void SpatialEditorViewport::_compute_edit(const Point2 &p_point) {
//int nc=0;
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->get()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
if (!sp)
continue;
@@ -796,7 +780,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->get()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
if (!sp)
continue;
@@ -967,22 +951,18 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (clicked && gizmo_handle >= 0) {
- Object *obj = ObjectDB::get_instance(clicked);
- if (obj) {
-
- Spatial *spa = obj->cast_to<Spatial>();
- if (spa) {
+ Spatial *spa = Object::cast_to<Spatial>(ObjectDB::get_instance(clicked));
+ if (spa) {
- Ref<SpatialEditorGizmo> seg = spa->get_gizmo();
- if (seg.is_valid()) {
+ Ref<SpatialEditorGizmo> seg = spa->get_gizmo();
+ if (seg.is_valid()) {
- _edit.gizmo = seg;
- _edit.gizmo_handle = gizmo_handle;
- //_edit.gizmo_initial_pos=seg->get_handle_pos(gizmo_handle);
- _edit.gizmo_initial_value = seg->get_handle_value(gizmo_handle);
- //print_line("GIZMO: "+itos(gizmo_handle)+" FROMPOS: "+_edit.orig_gizmo_pos);
- break;
- }
+ _edit.gizmo = seg;
+ _edit.gizmo_handle = gizmo_handle;
+ //_edit.gizmo_initial_pos=seg->get_handle_pos(gizmo_handle);
+ _edit.gizmo_initial_value = seg->get_handle_value(gizmo_handle);
+ //print_line("GIZMO: "+itos(gizmo_handle)+" FROMPOS: "+_edit.orig_gizmo_pos);
+ break;
}
}
//_compute_edit(Point2(b.x,b.y)); //in case a motion happens..
@@ -1018,7 +998,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->get()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
if (!sp)
continue;
@@ -1162,7 +1142,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->get()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
if (!sp)
continue;
@@ -1236,7 +1216,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Spatial *node = NULL;
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->get()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
if (!sp) {
continue;
}
@@ -1264,7 +1244,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->get()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
if (!sp) {
continue;
}
@@ -1334,7 +1314,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->get()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
if (!sp)
continue;
@@ -1569,7 +1549,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->get()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
if (!sp)
continue;
@@ -1626,13 +1606,13 @@ void SpatialEditorViewport::_update_freelook(real_t delta) {
Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0));
Vector3 up = camera->get_transform().basis.xform(Vector3(0, 1, 0));
- int key_left = ED_GET_SHORTCUT("spatial_editor/freelook_left")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
- int key_right = ED_GET_SHORTCUT("spatial_editor/freelook_right")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
- int key_forward = ED_GET_SHORTCUT("spatial_editor/freelook_forward")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
- int key_backwards = ED_GET_SHORTCUT("spatial_editor/freelook_backwards")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
- int key_up = ED_GET_SHORTCUT("spatial_editor/freelook_up")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
- int key_down = ED_GET_SHORTCUT("spatial_editor/freelook_down")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
- int key_speed_modifier = ED_GET_SHORTCUT("spatial_editor/freelook_speed_modifier")->get_shortcut()->cast_to<InputEventKey>()->get_scancode();
+ int key_left = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_left")->get_shortcut().ptr())->get_scancode();
+ int key_right = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_right")->get_shortcut().ptr())->get_scancode();
+ int key_forward = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_forward")->get_shortcut().ptr())->get_scancode();
+ int key_backwards = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_backwards")->get_shortcut().ptr())->get_scancode();
+ int key_up = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_up")->get_shortcut().ptr())->get_scancode();
+ int key_down = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_down")->get_shortcut().ptr())->get_scancode();
+ int key_speed_modifier = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_speed_modifier")->get_shortcut().ptr())->get_scancode();
Vector3 velocity;
bool pressed = false;
@@ -1739,7 +1719,7 @@ void SpatialEditorViewport::_notification(int p_what) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->key()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->key());
if (!sp)
continue;
@@ -1747,7 +1727,7 @@ void SpatialEditorViewport::_notification(int p_what) {
if (!se)
continue;
- VisualInstance *vi = sp->cast_to<VisualInstance>();
+ VisualInstance *vi = Object::cast_to<VisualInstance>(sp);
if (se->aabb.has_no_surface()) {
@@ -2037,7 +2017,7 @@ void SpatialEditorViewport::_menu_option(int p_option) {
undo_redo->create_action(TTR("Align with view"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->get()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
if (!sp)
continue;
@@ -2327,8 +2307,8 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) {
if (p_state.has("previewing")) {
Node *pv = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["previewing"]);
- if (pv && pv->cast_to<Camera>()) {
- previewing = pv->cast_to<Camera>();
+ if (Object::cast_to<Camera>(pv)) {
+ previewing = Object::cast_to<Camera>(pv);
previewing->connect("tree_exited", this, "_preview_exited_scene");
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace
view_menu->hide();
@@ -2397,7 +2377,7 @@ void SpatialEditorViewport::focus_selection() {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->get()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
if (!sp)
continue;
@@ -2693,7 +2673,7 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
SpatialEditorViewport *viewports[4];
int vc = 0;
for (int i = 0; i < get_child_count(); i++) {
- viewports[vc] = get_child(i)->cast_to<SpatialEditorViewport>();
+ viewports[vc] = Object::cast_to<SpatialEditorViewport>(get_child(i));
if (viewports[vc]) {
vc++;
}
@@ -2864,7 +2844,7 @@ void SpatialEditor::update_transform_gizmo() {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->get()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
if (!sp)
continue;
@@ -2899,7 +2879,7 @@ void SpatialEditor::update_transform_gizmo() {
Object *SpatialEditor::_get_editor_data(Object *p_what) {
- Spatial *sp = p_what->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(p_what);
if (!sp)
return NULL;
@@ -3139,7 +3119,7 @@ void SpatialEditor::_xform_dialog_action() {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = E->get()->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(E->get());
if (!sp)
continue;
@@ -3562,7 +3542,7 @@ void SpatialEditor::_init_indicators() {
_generate_selection_box();
- //get_scene()->get_root_node()->cast_to<EditorNode>()->get_scene_root()->add_child(camera);
+ //Object::cast_to<EditorNode>(get_scene()->get_root_node())->get_scene_root()->add_child(camera);
//current_camera=camera;
}
@@ -3694,7 +3674,7 @@ HSplitContainer *SpatialEditor::get_palette_split() {
void SpatialEditor::_request_gizmo(Object *p_obj) {
- Spatial *sp = p_obj->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(p_obj);
if (!sp)
return;
if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || sp->get_owner() == editor->get_edited_scene() || editor->get_edited_scene()->is_editable_instance(sp->get_owner()))) {
@@ -3725,7 +3705,7 @@ void SpatialEditor::_request_gizmo(Object *p_obj) {
void SpatialEditor::_toggle_maximize_view(Object *p_viewport) {
if (!p_viewport) return;
- SpatialEditorViewport *current_viewport = p_viewport->cast_to<SpatialEditorViewport>();
+ SpatialEditorViewport *current_viewport = Object::cast_to<SpatialEditorViewport>(p_viewport);
if (!current_viewport) return;
int index = -1;
@@ -4122,7 +4102,7 @@ void SpatialEditorPlugin::make_visible(bool p_visible) {
}
void SpatialEditorPlugin::edit(Object *p_object) {
- spatial_editor->edit(p_object->cast_to<Spatial>());
+ spatial_editor->edit(Object::cast_to<Spatial>(p_object));
}
bool SpatialEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 0608ecec58..203734a928 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -334,14 +334,14 @@ static void _find_anim_sprites(Node *p_node, List<Node *> *r_nodes, Ref<SpriteFr
return;
{
- AnimatedSprite *as = p_node->cast_to<AnimatedSprite>();
+ AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node);
if (as && as->get_sprite_frames() == p_sfames) {
r_nodes->push_back(p_node);
}
}
{
- AnimatedSprite3D *as = p_node->cast_to<AnimatedSprite3D>();
+ AnimatedSprite3D *as = Object::cast_to<AnimatedSprite3D>(p_node);
if (as && as->get_sprite_frames() == p_sfames) {
r_nodes->push_back(p_node);
}
@@ -842,7 +842,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
void SpriteFramesEditorPlugin::edit(Object *p_object) {
frames_editor->set_undo_redo(&get_undo_redo());
- SpriteFrames *s = p_object->cast_to<SpriteFrames>();
+ SpriteFrames *s = Object::cast_to<SpriteFrames>(p_object);
if (!s)
return;
diff --git a/editor/plugins/stream_editor_plugin.cpp b/editor/plugins/stream_editor_plugin.cpp
index dd97ce936d..1ae2ea4998 100644
--- a/editor/plugins/stream_editor_plugin.cpp
+++ b/editor/plugins/stream_editor_plugin.cpp
@@ -100,7 +100,7 @@ StreamEditor::StreamEditor() {
void StreamEditorPlugin::edit(Object *p_object) {
- stream_editor->edit(p_object->cast_to<Node>());
+ stream_editor->edit(Object::cast_to<Node>(p_object));
}
bool StreamEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp
index d421b203e9..24af6233cb 100644
--- a/editor/plugins/style_box_editor_plugin.cpp
+++ b/editor/plugins/style_box_editor_plugin.cpp
@@ -72,8 +72,8 @@ StyleBoxEditor::StyleBoxEditor() {
void StyleBoxEditorPlugin::edit(Object *p_node) {
- if (p_node && p_node->cast_to<StyleBox>()) {
- stylebox_editor->edit(p_node->cast_to<StyleBox>());
+ if (Object::cast_to<StyleBox>(p_node)) {
+ stylebox_editor->edit(Object::cast_to<StyleBox>(p_node));
stylebox_editor->show();
} else
stylebox_editor->hide();
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index 57c27a8a7e..5648ee510e 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -70,7 +70,7 @@ void TextureEditor::_notification(int p_what) {
int ofs_x = (size.width - tex_width) / 2;
int ofs_y = (size.height - tex_height) / 2;
- if (texture->cast_to<CurveTexture>()) {
+ if (Object::cast_to<CurveTexture>(*texture)) {
// In the case of CurveTextures we know they are 1 in height, so fill the preview to see the gradient
ofs_y = 0;
tex_height = size.height;
@@ -81,10 +81,10 @@ void TextureEditor::_notification(int p_what) {
Ref<Font> font = get_font("font", "Label");
String format;
- if (texture->cast_to<ImageTexture>()) {
- format = Image::get_format_name(texture->cast_to<ImageTexture>()->get_format());
- } else if (texture->cast_to<StreamTexture>()) {
- format = Image::get_format_name(texture->cast_to<StreamTexture>()->get_format());
+ if (Object::cast_to<ImageTexture>(*texture)) {
+ format = Image::get_format_name(Object::cast_to<ImageTexture>(*texture)->get_format());
+ } else if (Object::cast_to<StreamTexture>(*texture)) {
+ format = Image::get_format_name(Object::cast_to<StreamTexture>(*texture)->get_format());
} else {
format = texture->get_class();
}
@@ -136,7 +136,7 @@ TextureEditor::TextureEditor() {
void TextureEditorPlugin::edit(Object *p_object) {
- Texture *s = p_object->cast_to<Texture>();
+ Texture *s = Object::cast_to<Texture>(p_object);
if (!s)
return;
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index d878bba427..d9e310a586 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -626,12 +626,12 @@ void TextureRegionEditor::edit(Object *p_obj) {
if (atlas_tex.is_valid())
atlas_tex->remove_change_receptor(this);
if (p_obj) {
- node_sprite = p_obj->cast_to<Sprite>();
- node_patch9 = p_obj->cast_to<NinePatchRect>();
- if (p_obj->cast_to<StyleBoxTexture>())
- obj_styleBox = Ref<StyleBoxTexture>(p_obj->cast_to<StyleBoxTexture>());
- if (p_obj->cast_to<AtlasTexture>())
- atlas_tex = Ref<AtlasTexture>(p_obj->cast_to<AtlasTexture>());
+ node_sprite = Object::cast_to<Sprite>(p_obj);
+ node_patch9 = Object::cast_to<NinePatchRect>(p_obj);
+ if (Object::cast_to<StyleBoxTexture>(p_obj))
+ obj_styleBox = Ref<StyleBoxTexture>(Object::cast_to<StyleBoxTexture>(p_obj));
+ if (Object::cast_to<AtlasTexture>(p_obj))
+ atlas_tex = Ref<AtlasTexture>(Object::cast_to<AtlasTexture>(p_obj));
p_obj->add_change_receptor(this);
_edit_region();
} else {
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index d45a3b1312..9cf43e6564 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -44,7 +44,7 @@ void ThemeEditor::_propagate_redraw(Control *p_at) {
p_at->minimum_size_changed();
p_at->update();
for (int i = 0; i < p_at->get_child_count(); i++) {
- Control *a = p_at->get_child(i)->cast_to<Control>();
+ Control *a = Object::cast_to<Control>(p_at->get_child(i));
if (a)
_propagate_redraw(a);
}
@@ -892,9 +892,9 @@ ThemeEditor::ThemeEditor() {
void ThemeEditorPlugin::edit(Object *p_node) {
- if (p_node && p_node->cast_to<Theme>()) {
+ if (Object::cast_to<Theme>(p_node)) {
theme_editor->show();
- theme_editor->edit(p_node->cast_to<Theme>());
+ theme_editor->edit(Object::cast_to<Theme>(p_node));
} else {
theme_editor->edit(Ref<Theme>());
theme_editor->hide();
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 80ff6627b2..d89fe43ed2 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -1329,7 +1329,7 @@ void TileMapEditor::edit(Node *p_tile_map) {
node->disconnect("settings_changed", this, "_tileset_settings_changed");
if (p_tile_map) {
- node = p_tile_map->cast_to<TileMap>();
+ node = Object::cast_to<TileMap>(p_tile_map);
if (!canvas_item_editor->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->connect("draw", this, "_canvas_draw");
if (!canvas_item_editor->is_connected("mouse_entered", this, "_canvas_mouse_enter"))
@@ -1407,7 +1407,7 @@ TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i &p_pos) {
void TileMapEditor::_update_transform_buttons(Object *p_button) {
//ERR_FAIL_NULL(p_button);
- ToolButton *b = p_button->cast_to<ToolButton>();
+ ToolButton *b = Object::cast_to<ToolButton>(p_button);
//ERR_FAIL_COND(!b);
if (b == rotate_0) {
@@ -1582,7 +1582,7 @@ TileMapEditor::~TileMapEditor() {
void TileMapEditorPlugin::edit(Object *p_object) {
- tile_map_editor->edit(p_object->cast_to<Node>());
+ tile_map_editor->edit(Object::cast_to<Node>(p_object));
}
bool TileMapEditorPlugin::handles(Object *p_object) const {
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 8396b4d412..7637ce97fc 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -43,7 +43,7 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
Node *child = p_node->get_child(i);
- if (!child->cast_to<Sprite>()) {
+ if (!Object::cast_to<Sprite>(child)) {
if (child->get_child_count() > 0) {
_import_node(child, p_library);
}
@@ -51,7 +51,7 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
continue;
}
- Sprite *mi = child->cast_to<Sprite>();
+ Sprite *mi = Object::cast_to<Sprite>(child);
Ref<Texture> texture = mi->get_texture();
Ref<Texture> normal_map = mi->get_normal_map();
Ref<ShaderMaterial> material = mi->get_material();
@@ -99,18 +99,18 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
Node *child2 = mi->get_child(j);
- if (child2->cast_to<NavigationPolygonInstance>())
- nav_poly = child2->cast_to<NavigationPolygonInstance>()->get_navigation_polygon();
+ if (Object::cast_to<NavigationPolygonInstance>(child2))
+ nav_poly = Object::cast_to<NavigationPolygonInstance>(child2)->get_navigation_polygon();
- if (child2->cast_to<LightOccluder2D>())
- occluder = child2->cast_to<LightOccluder2D>()->get_occluder_polygon();
+ if (Object::cast_to<LightOccluder2D>(child2))
+ occluder = Object::cast_to<LightOccluder2D>(child2)->get_occluder_polygon();
- if (!child2->cast_to<StaticBody2D>())
+ if (!Object::cast_to<StaticBody2D>(child2))
continue;
found_collisions = true;
- StaticBody2D *sb = child2->cast_to<StaticBody2D>();
+ StaticBody2D *sb = Object::cast_to<StaticBody2D>(child2);
List<uint32_t> shapes;
sb->get_shape_owners(&shapes);
@@ -268,8 +268,8 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
void TileSetEditorPlugin::edit(Object *p_node) {
- if (p_node && p_node->cast_to<TileSet>()) {
- tileset_editor->edit(p_node->cast_to<TileSet>());
+ if (Object::cast_to<TileSet>(p_node)) {
+ tileset_editor->edit(Object::cast_to<TileSet>(p_node));
tileset_editor->show();
} else
tileset_editor->hide();