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/
This commit is contained in:
Hein-Pieter van Braam 2017-08-24 22:58:51 +02:00
parent 4aa2c18cb4
commit cacced7e50
185 changed files with 1314 additions and 1508 deletions

View file

@ -2354,7 +2354,7 @@ Variant _ClassDB::instance(const StringName &p_class) const {
if (!obj) if (!obj)
return Variant(); return Variant();
Reference *r = obj->cast_to<Reference>(); Reference *r = Object::cast_to<Reference>(obj);
if (r) { if (r) {
return REF(r); return REF(r);
} else { } else {

View file

@ -463,8 +463,8 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
obj->set(str, value); obj->set(str, value);
} }
if (obj->cast_to<Reference>()) { if (Object::cast_to<Reference>(obj)) {
REF ref = REF(obj->cast_to<Reference>()); REF ref = REF(Object::cast_to<Reference>(obj));
r_variant = ref; r_variant = ref;
} else { } else {
r_variant = obj; r_variant = obj;

View file

@ -713,7 +713,7 @@ Error ResourceInteractiveLoaderBinary::poll() {
} }
ERR_FAIL_COND_V(!obj, ERR_FILE_CORRUPT); ERR_FAIL_COND_V(!obj, ERR_FILE_CORRUPT);
Resource *r = obj->cast_to<Resource>(); Resource *r = Object::cast_to<Resource>(obj);
if (!r) { if (!r) {
error = ERR_FILE_CORRUPT; error = ERR_FILE_CORRUPT;
memdelete(obj); //bye memdelete(obj); //bye

View file

@ -29,7 +29,7 @@ public:
virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error) { virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error) {
T *instance=p_object->cast_to<T>(); T *instance=Object::cast_to<T>(p_object);
r_error.error=Variant::CallError::CALL_OK; r_error.error=Variant::CallError::CALL_OK;
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
@ -57,7 +57,7 @@ public:
#ifdef PTRCALL_ENABLED #ifdef PTRCALL_ENABLED
virtual void ptrcall(Object*p_object,const void** p_args,void *r_ret) { virtual void ptrcall(Object*p_object,const void** p_args,void *r_ret) {
T *instance=p_object->cast_to<T>(); T *instance=Object::cast_to<T>(p_object);
$ifret PtrToArg<R>::encode( $ (instance->*method)($arg, PtrToArg<P@>::convert(p_args[@-1])$) $ifret ,r_ret)$ ; $ifret PtrToArg<R>::encode( $ (instance->*method)($arg, PtrToArg<P@>::convert(p_args[@-1])$) $ifret ,r_ret)$ ;
} }
#endif #endif

View file

@ -654,7 +654,7 @@ void Object::call_multilevel(const StringName &p_method, const Variant **p_args,
if (p_method == CoreStringNames::get_singleton()->_free) { if (p_method == CoreStringNames::get_singleton()->_free) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (cast_to<Reference>()) { if (Object::cast_to<Reference>(this)) {
ERR_EXPLAIN("Can't 'free' a reference."); ERR_EXPLAIN("Can't 'free' a reference.");
ERR_FAIL(); ERR_FAIL();
return; return;
@ -900,7 +900,7 @@ Variant Object::call(const StringName &p_method, const Variant **p_args, int p_a
r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
return Variant(); return Variant();
} }
if (cast_to<Reference>()) { if (Object::cast_to<Reference>(this)) {
r_error.argument = 0; r_error.argument = 0;
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
ERR_EXPLAIN("Can't 'free' a reference."); ERR_EXPLAIN("Can't 'free' a reference.");

View file

@ -598,46 +598,6 @@ public:
#endif #endif
} }
// TODO: ensure 'this' is never NULL since it's UB, but by now, avoid warning flood
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundefined-bool-conversion"
#endif
template <class T>
T *cast_to() {
#ifndef NO_SAFE_CAST
return SAFE_CAST<T *>(this);
#else
if (!this)
return NULL;
if (is_class_ptr(T::get_class_ptr_static()))
return static_cast<T *>(this);
else
return NULL;
#endif
}
template <class T>
const T *cast_to() const {
#ifndef NO_SAFE_CAST
return SAFE_CAST<const T *>(this);
#else
if (!this)
return NULL;
if (is_class_ptr(T::get_class_ptr_static()))
return static_cast<const T *>(this);
else
return NULL;
#endif
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
enum { enum {
NOTIFICATION_POSTINITIALIZE = 0, NOTIFICATION_POSTINITIALIZE = 0,

View file

@ -171,7 +171,7 @@ static FileAccess *_OSPRF = NULL;
static void _OS_printres(Object *p_obj) { static void _OS_printres(Object *p_obj) {
Resource *res = p_obj->cast_to<Resource>(); Resource *res = Object::cast_to<Resource>(p_obj);
if (!res) if (!res)
return; return;

View file

@ -69,7 +69,7 @@ RID RefPtr::get_rid() const {
Ref<Reference> *ref = reinterpret_cast<Ref<Reference> *>(&data[0]); Ref<Reference> *ref = reinterpret_cast<Ref<Reference> *>(&data[0]);
if (ref->is_null()) if (ref->is_null())
return RID(); return RID();
Resource *res = (*ref)->cast_to<Resource>(); Resource *res = Object::cast_to<Resource>(ref->ptr());
if (res) if (res)
return res->get_rid(); return res->get_rid();
return RID(); return RID();

View file

@ -98,7 +98,7 @@ Variant WeakRef::get_ref() const {
Object *obj = ObjectDB::get_instance(ref); Object *obj = ObjectDB::get_instance(ref);
if (!obj) if (!obj)
return Variant(); return Variant();
Reference *r = obj->cast_to<Reference>(); Reference *r = cast_to<Reference>(obj);
if (r) { if (r) {
return REF(r); return REF(r);

View file

@ -180,7 +180,7 @@ public:
return; return;
} }
Ref r; Ref r;
r.reference = refb->cast_to<T>(); r.reference = Object::cast_to<T>(refb);
ref(r); ref(r);
r.reference = NULL; r.reference = NULL;
} }
@ -194,7 +194,7 @@ public:
return; return;
} }
Ref r; Ref r;
r.reference = refb->cast_to<T>(); r.reference = Object::cast_to<T>(refb);
ref(r); ref(r);
r.reference = NULL; r.reference = NULL;
} }
@ -209,7 +209,7 @@ public:
return; return;
} }
Ref r; Ref r;
r.reference = refb->cast_to<T>(); r.reference = Object::cast_to<T>(refb);
ref(r); ref(r);
r.reference = NULL; r.reference = NULL;
} }
@ -230,7 +230,7 @@ public:
return; return;
} }
Ref r; Ref r;
r.reference = refb->cast_to<T>(); r.reference = Object::cast_to<T>(refb);
ref(r); ref(r);
r.reference = NULL; r.reference = NULL;
} }
@ -254,7 +254,7 @@ public:
return; return;
} }
Ref r; Ref r;
r.reference = refb->cast_to<T>(); r.reference = Object::cast_to<T>(refb);
ref(r); ref(r);
r.reference = NULL; r.reference = NULL;
} }
@ -269,7 +269,7 @@ public:
return; return;
} }
Ref r; Ref r;
r.reference = refb->cast_to<T>(); r.reference = Object::cast_to<T>(refb);
ref(r); ref(r);
r.reference = NULL; r.reference = NULL;
} }

View file

@ -111,8 +111,8 @@ void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_A
ERR_FAIL_COND((current_action + 1) >= actions.size()); ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op; Operation do_op;
do_op.object = p_object->get_instance_id(); do_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>()) if (Object::cast_to<Resource>(p_object))
do_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
do_op.type = Operation::TYPE_METHOD; do_op.type = Operation::TYPE_METHOD;
do_op.name = p_method; do_op.name = p_method;
@ -135,8 +135,8 @@ void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT
Operation undo_op; Operation undo_op;
undo_op.object = p_object->get_instance_id(); undo_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>()) if (Object::cast_to<Resource>(p_object))
undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
undo_op.type = Operation::TYPE_METHOD; undo_op.type = Operation::TYPE_METHOD;
undo_op.name = p_method; undo_op.name = p_method;
@ -152,8 +152,8 @@ void UndoRedo::add_do_property(Object *p_object, const String &p_property, const
ERR_FAIL_COND((current_action + 1) >= actions.size()); ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op; Operation do_op;
do_op.object = p_object->get_instance_id(); do_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>()) if (Object::cast_to<Resource>(p_object))
do_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
do_op.type = Operation::TYPE_PROPERTY; do_op.type = Operation::TYPE_PROPERTY;
do_op.name = p_property; do_op.name = p_property;
@ -171,8 +171,8 @@ void UndoRedo::add_undo_property(Object *p_object, const String &p_property, con
Operation undo_op; Operation undo_op;
undo_op.object = p_object->get_instance_id(); undo_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>()) if (Object::cast_to<Resource>(p_object))
undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
undo_op.type = Operation::TYPE_PROPERTY; undo_op.type = Operation::TYPE_PROPERTY;
undo_op.name = p_property; undo_op.name = p_property;
@ -185,8 +185,8 @@ void UndoRedo::add_do_reference(Object *p_object) {
ERR_FAIL_COND((current_action + 1) >= actions.size()); ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op; Operation do_op;
do_op.object = p_object->get_instance_id(); do_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>()) if (Object::cast_to<Resource>(p_object))
do_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
do_op.type = Operation::TYPE_REFERENCE; do_op.type = Operation::TYPE_REFERENCE;
actions[current_action + 1].do_ops.push_back(do_op); actions[current_action + 1].do_ops.push_back(do_op);
@ -202,8 +202,8 @@ void UndoRedo::add_undo_reference(Object *p_object) {
Operation undo_op; Operation undo_op;
undo_op.object = p_object->get_instance_id(); undo_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>()) if (Object::cast_to<Resource>(p_object))
undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
undo_op.type = Operation::TYPE_REFERENCE; undo_op.type = Operation::TYPE_REFERENCE;
actions[current_action + 1].undo_ops.push_back(undo_op); actions[current_action + 1].undo_ops.push_back(undo_op);
@ -270,7 +270,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
obj->call(op.name, VARIANT_ARGS_FROM_ARRAY(op.args)); obj->call(op.name, VARIANT_ARGS_FROM_ARRAY(op.args));
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
Resource *res = obj->cast_to<Resource>(); Resource *res = Object::cast_to<Resource>(obj);
if (res) if (res)
res->set_edited(true); res->set_edited(true);
@ -284,7 +284,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
obj->set(op.name, op.args[0]); obj->set(op.name, op.args[0]);
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
Resource *res = obj->cast_to<Resource>(); Resource *res = Object::cast_to<Resource>(obj);
if (res) if (res)
res->set_edited(true); res->set_edited(true);
#endif #endif

View file

@ -1764,14 +1764,14 @@ Variant::operator Object *() const {
Variant::operator Node *() const { Variant::operator Node *() const {
if (type == OBJECT) if (type == OBJECT)
return _get_obj().obj ? _get_obj().obj->cast_to<Node>() : NULL; return Object::cast_to<Node>(_get_obj().obj);
else else
return NULL; return NULL;
} }
Variant::operator Control *() const { Variant::operator Control *() const {
if (type == OBJECT) if (type == OBJECT)
return _get_obj().obj ? _get_obj().obj->cast_to<Control>() : NULL; return Object::cast_to<Control>(_get_obj().obj);
else else
return NULL; return NULL;
} }

View file

@ -742,7 +742,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return err; return err;
if (token.type == TK_PARENTHESIS_CLOSE) { if (token.type == TK_PARENTHESIS_CLOSE) {
Reference *reference = obj->cast_to<Reference>(); Reference *reference = Object::cast_to<Reference>(obj);
if (reference) { if (reference) {
value = REF(reference); value = REF(reference);
} else { } else {

View file

@ -187,7 +187,7 @@ bool ResourceSaverPNG::recognize(const RES &p_resource) const {
} }
void ResourceSaverPNG::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { void ResourceSaverPNG::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
if (p_resource->cast_to<Texture>()) { if (Object::cast_to<Texture>(*p_resource)) {
p_extensions->push_back("png"); p_extensions->push_back("png");
} }
} }

View file

@ -3249,9 +3249,9 @@ void AnimationKeyEditor::insert_value_key(const String &p_property, const Varian
//let's build a node path //let's build a node path
ERR_FAIL_COND(history->get_path_size() == 0); ERR_FAIL_COND(history->get_path_size() == 0);
Object *obj = ObjectDB::get_instance(history->get_path_object(0)); Object *obj = ObjectDB::get_instance(history->get_path_object(0));
ERR_FAIL_COND(!obj || !obj->cast_to<Node>()); ERR_FAIL_COND(!Object::cast_to<Node>(obj));
Node *node = obj->cast_to<Node>(); Node *node = Object::cast_to<Node>(obj);
String path = root->get_path_to(node); String path = root->get_path_to(node);

View file

@ -273,11 +273,7 @@ void ArrayPropertyEdit::edit(Object *p_obj, const StringName &p_prop, const Stri
Node *ArrayPropertyEdit::get_node() { Node *ArrayPropertyEdit::get_node() {
Object *o = ObjectDB::get_instance(obj); return Object::cast_to<Node>(ObjectDB::get_instance(obj));
if (!o)
return NULL;
return o->cast_to<Node>();
} }
void ArrayPropertyEdit::_bind_methods() { void ArrayPropertyEdit::_bind_methods() {

View file

@ -595,7 +595,7 @@ void EditorAssetLibrary::_install_asset() {
for (int i = 0; i < downloads_hb->get_child_count(); i++) { for (int i = 0; i < downloads_hb->get_child_count(); i++) {
EditorAssetLibraryItemDownload *d = downloads_hb->get_child(i)->cast_to<EditorAssetLibraryItemDownload>(); EditorAssetLibraryItemDownload *d = Object::cast_to<EditorAssetLibraryItemDownload>(downloads_hb->get_child(i));
if (d && d->get_asset_id() == description->get_asset_id()) { if (d && d->get_asset_id() == description->get_asset_id()) {
if (EditorNode::get_singleton() != NULL) if (EditorNode::get_singleton() != NULL)

View file

@ -664,7 +664,7 @@ void ConnectionsDock::update_tree() {
if (!(c.flags & CONNECT_PERSIST)) if (!(c.flags & CONNECT_PERSIST))
continue; continue;
Node *target = c.target->cast_to<Node>(); Node *target = Object::cast_to<Node>(c.target);
if (!target) if (!target)
continue; continue;

View file

@ -50,7 +50,7 @@ void DependencyEditor::_searched(const String &p_path) {
void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) { void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) {
TreeItem *ti = p_item->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(p_item);
String fname = ti->get_text(0); String fname = ti->get_text(0);
replacing = ti->get_text(1); replacing = ti->get_text(1);
@ -626,7 +626,7 @@ void OrphanResourcesDialog::_delete_confirm() {
void OrphanResourcesDialog::_button_pressed(Object *p_item, int p_column, int p_id) { void OrphanResourcesDialog::_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 path = ti->get_metadata(0); String path = ti->get_metadata(0);
dep_edit->edit(path); dep_edit->edit(path);

View file

@ -376,7 +376,7 @@ void EditorAudioBus::_effect_add(int p_which) {
Object *fx = ClassDB::instance(name); Object *fx = ClassDB::instance(name);
ERR_FAIL_COND(!fx); ERR_FAIL_COND(!fx);
AudioEffect *afx = fx->cast_to<AudioEffect>(); AudioEffect *afx = Object::cast_to<AudioEffect>(fx);
ERR_FAIL_COND(!afx); ERR_FAIL_COND(!afx);
Ref<AudioEffect> afxr = Ref<AudioEffect>(afx); Ref<AudioEffect> afxr = Ref<AudioEffect>(afx);
@ -865,7 +865,7 @@ void EditorAudioBuses::_update_sends() {
void EditorAudioBuses::_delete_bus(Object *p_which) { void EditorAudioBuses::_delete_bus(Object *p_which) {
EditorAudioBus *bus = p_which->cast_to<EditorAudioBus>(); EditorAudioBus *bus = Object::cast_to<EditorAudioBus>(p_which);
int index = bus->get_index(); int index = bus->get_index();
if (index == 0) { if (index == 0) {
EditorNode::get_singleton()->show_warning("Master bus can't be deleted!"); EditorNode::get_singleton()->show_warning("Master bus can't be deleted!");
@ -922,7 +922,7 @@ void EditorAudioBuses::_request_drop_end() {
drop_end = memnew(EditorAudioBusDrop); drop_end = memnew(EditorAudioBusDrop);
bus_hb->add_child(drop_end); bus_hb->add_child(drop_end);
drop_end->set_custom_minimum_size(bus_hb->get_child(0)->cast_to<Control>()->get_size()); drop_end->set_custom_minimum_size(Object::cast_to<Control>(bus_hb->get_child(0))->get_size());
drop_end->connect("dropped", this, "_drop_at_index", varray(), CONNECT_DEFERRED); drop_end->connect("dropped", this, "_drop_at_index", varray(), CONNECT_DEFERRED);
} }
} }
@ -1158,9 +1158,9 @@ void EditorAudioBuses::open_layout(const String &p_path) {
void AudioBusesEditorPlugin::edit(Object *p_node) { void AudioBusesEditorPlugin::edit(Object *p_node) {
if (p_node->cast_to<AudioBusLayout>()) { if (Object::cast_to<AudioBusLayout>(p_node)) {
String path = p_node->cast_to<AudioBusLayout>()->get_path(); String path = Object::cast_to<AudioBusLayout>(p_node)->get_path();
if (path.is_resource_file()) { if (path.is_resource_file()) {
audio_bus_editor->open_layout(path); audio_bus_editor->open_layout(path);
} }
@ -1169,7 +1169,7 @@ void AudioBusesEditorPlugin::edit(Object *p_node) {
bool AudioBusesEditorPlugin::handles(Object *p_node) const { bool AudioBusesEditorPlugin::handles(Object *p_node) const {
return (p_node->cast_to<AudioBusLayout>() != NULL); return (Object::cast_to<AudioBusLayout>(p_node) != NULL);
} }
void AudioBusesEditorPlugin::make_visible(bool p_visible) { void AudioBusesEditorPlugin::make_visible(bool p_visible) {

View file

@ -238,7 +238,7 @@ void EditorAutoloadSettings::_autoload_edited() {
void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_column, int p_button) { void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_column, int p_button) {
TreeItem *ti = p_item->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(p_item);
String name = "autoload/" + ti->get_text(0); String name = "autoload/" + ti->get_text(0);

View file

@ -75,7 +75,7 @@ void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int
Object *obj = ObjectDB::get_instance(p_object); Object *obj = ObjectDB::get_instance(p_object);
ERR_FAIL_COND(!obj); ERR_FAIL_COND(!obj);
Reference *r = obj->cast_to<Reference>(); Reference *r = Object::cast_to<Reference>(obj);
Obj o; Obj o;
if (r) if (r)
o.ref = REF(r); o.ref = REF(r);

View file

@ -236,10 +236,7 @@ public:
T *get_node_editor_data(Node *p_node) { T *get_node_editor_data(Node *p_node) {
if (!selection.has(p_node)) if (!selection.has(p_node))
return NULL; return NULL;
Object *obj = selection[p_node]; return Object::cast_to<T>(selection[p_node]);
if (!obj)
return NULL;
return obj->cast_to<T>();
} }
void add_editor_plugin(Object *p_object); void add_editor_plugin(Object *p_object);

View file

@ -114,7 +114,7 @@ void EditorDirDialog::_notification(int p_what) {
void EditorDirDialog::_item_collapsed(Object *p_item) { void EditorDirDialog::_item_collapsed(Object *p_item) {
TreeItem *item = p_item->cast_to<TreeItem>(); TreeItem *item = Object::cast_to<TreeItem>(p_item);
if (updating || item->is_collapsed()) if (updating || item->is_collapsed())
return; return;

View file

@ -930,7 +930,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
// we must update it, but also let the previous scene state go, as // we must update it, but also let the previous scene state go, as
// old version still work for referencing changes in instanced or inherited scenes // old version still work for referencing changes in instanced or inherited scenes
sdata = Ref<PackedScene>(ResourceCache::get(p_file)->cast_to<PackedScene>()); sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(ResourceCache::get(p_file)));
if (sdata.is_valid()) if (sdata.is_valid())
sdata->recreate_state(); sdata->recreate_state();
else else
@ -1291,9 +1291,9 @@ void EditorNode::_dialog_action(String p_file) {
uint32_t current = editor_history.get_current(); uint32_t current = editor_history.get_current();
Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL; Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!current_obj->cast_to<Resource>()) ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj))
RES current_res = RES(current_obj->cast_to<Resource>()); RES current_res = RES(Object::cast_to<Resource>(current_obj));
save_resource_in_path(current_res, p_file); save_resource_in_path(current_res, p_file);
@ -1428,8 +1428,8 @@ void EditorNode::_prepare_history() {
icon = base_icon; icon = base_icon;
String text; String text;
if (obj->cast_to<Resource>()) { if (Object::cast_to<Resource>(obj)) {
Resource *r = obj->cast_to<Resource>(); Resource *r = Object::cast_to<Resource>(obj);
if (r->get_path().is_resource_file()) if (r->get_path().is_resource_file())
text = r->get_path().get_file(); text = r->get_path().get_file();
else if (r->get_name() != String()) { else if (r->get_name() != String()) {
@ -1437,8 +1437,8 @@ void EditorNode::_prepare_history() {
} else { } else {
text = r->get_class(); text = r->get_class();
} }
} else if (obj->cast_to<Node>()) { } else if (Object::cast_to<Node>(obj)) {
text = obj->cast_to<Node>()->get_name(); text = Object::cast_to<Node>(obj)->get_name();
} else { } else {
text = obj->get_class(); text = obj->get_class();
} }
@ -1536,7 +1536,7 @@ void EditorNode::_edit_current() {
if (is_resource) { if (is_resource) {
Resource *current_res = current_obj->cast_to<Resource>(); Resource *current_res = Object::cast_to<Resource>(current_obj);
ERR_FAIL_COND(!current_res); ERR_FAIL_COND(!current_res);
scene_tree_dock->set_selected(NULL); scene_tree_dock->set_selected(NULL);
property_editor->edit(current_res); property_editor->edit(current_res);
@ -1548,7 +1548,7 @@ void EditorNode::_edit_current() {
//top_pallete->set_current_tab(1); //top_pallete->set_current_tab(1);
} else if (is_node) { } else if (is_node) {
Node *current_node = current_obj->cast_to<Node>(); Node *current_node = Object::cast_to<Node>(current_obj);
ERR_FAIL_COND(!current_node); ERR_FAIL_COND(!current_node);
// ERR_FAIL_COND(!current_node->is_inside_tree()); // ERR_FAIL_COND(!current_node->is_inside_tree());
@ -1688,7 +1688,7 @@ void EditorNode::_resource_created() {
Object *c = create_dialog->instance_selected(); Object *c = create_dialog->instance_selected();
ERR_FAIL_COND(!c); ERR_FAIL_COND(!c);
Resource *r = c->cast_to<Resource>(); Resource *r = Object::cast_to<Resource>(c);
ERR_FAIL_COND(!r); ERR_FAIL_COND(!r);
REF res(r); REF res(r);
@ -2273,9 +2273,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
uint32_t current = editor_history.get_current(); uint32_t current = editor_history.get_current();
Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL; Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!current_obj->cast_to<Resource>()) ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj))
RES current_res = RES(current_obj->cast_to<Resource>()); RES current_res = RES(Object::cast_to<Resource>(current_obj));
save_resource(current_res); save_resource(current_res);
@ -2285,9 +2285,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
uint32_t current = editor_history.get_current(); uint32_t current = editor_history.get_current();
Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL; Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!current_obj->cast_to<Resource>()) ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj))
RES current_res = RES(current_obj->cast_to<Resource>()); RES current_res = RES(Object::cast_to<Resource>(current_obj));
save_resource_as(current_res); save_resource_as(current_res);
@ -2297,9 +2297,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
uint32_t current = editor_history.get_current(); uint32_t current = editor_history.get_current();
Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL; Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!current_obj->cast_to<Resource>()) ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj))
RES current_res = RES(current_obj->cast_to<Resource>()); RES current_res = RES(Object::cast_to<Resource>(current_obj));
current_res->set_path(""); current_res->set_path("");
_edit_current(); _edit_current();
} break; } break;
@ -2308,9 +2308,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
uint32_t current = editor_history.get_current(); uint32_t current = editor_history.get_current();
Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL; Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!current_obj->cast_to<Resource>()) ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj))
RES current_res = RES(current_obj->cast_to<Resource>()); RES current_res = RES(Object::cast_to<Resource>(current_obj));
EditorSettings::get_singleton()->set_resource_clipboard(current_res); EditorSettings::get_singleton()->set_resource_clipboard(current_res);
@ -3038,8 +3038,8 @@ void EditorNode::set_edited_scene(Node *p_scene) {
} }
get_editor_data().set_edited_scene_root(p_scene); get_editor_data().set_edited_scene_root(p_scene);
if (p_scene && p_scene->cast_to<Popup>()) if (Object::cast_to<Popup>(p_scene))
p_scene->cast_to<Popup>()->show(); //show popups Object::cast_to<Popup>(p_scene)->show(); //show popups
scene_tree_dock->set_edited_scene(p_scene); scene_tree_dock->set_edited_scene(p_scene);
if (get_tree()) if (get_tree())
get_tree()->set_edited_scene_root(p_scene); get_tree()->set_edited_scene_root(p_scene);
@ -3182,8 +3182,8 @@ void EditorNode::set_current_scene(int p_idx) {
Node *new_scene = editor_data.get_edited_scene_root(); Node *new_scene = editor_data.get_edited_scene_root();
if (new_scene && new_scene->cast_to<Popup>()) if (Object::cast_to<Popup>(new_scene))
new_scene->cast_to<Popup>()->show(); //show popups Object::cast_to<Popup>(new_scene)->show(); //show popups
//print_line("set current 3 "); //print_line("set current 3 ");
@ -3333,7 +3333,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
if (ResourceCache::has(lpath)) { if (ResourceCache::has(lpath)) {
//used from somewhere else? no problem! update state and replace sdata //used from somewhere else? no problem! update state and replace sdata
Ref<PackedScene> ps = Ref<PackedScene>(ResourceCache::get(lpath)->cast_to<PackedScene>()); Ref<PackedScene> ps = Ref<PackedScene>(Object::cast_to<PackedScene>(ResourceCache::get(lpath)));
if (ps.is_valid()) { if (ps.is_valid()) {
ps->replace_state(sdata->get_state()); ps->replace_state(sdata->get_state());
ps->set_last_modified_time(sdata->get_last_modified_time()); ps->set_last_modified_time(sdata->get_last_modified_time());
@ -3461,7 +3461,7 @@ void EditorNode::_property_keyed(const String &p_keyed, const Variant &p_value,
void EditorNode::_transform_keyed(Object *sp, const String &p_sub, const Transform &p_key) { void EditorNode::_transform_keyed(Object *sp, const String &p_sub, const Transform &p_key) {
Spatial *s = sp->cast_to<Spatial>(); Spatial *s = Object::cast_to<Spatial>(sp);
if (!s) if (!s)
return; return;
AnimationPlayerEditor::singleton->get_key_editor()->insert_transform_key(s, p_sub, p_key); AnimationPlayerEditor::singleton->get_key_editor()->insert_transform_key(s, p_sub, p_key);
@ -3478,7 +3478,7 @@ void EditorNode::update_keying() {
if (editor_history.get_path_size() >= 1) { if (editor_history.get_path_size() >= 1) {
Object *obj = ObjectDB::get_instance(editor_history.get_path_object(0)); Object *obj = ObjectDB::get_instance(editor_history.get_path_object(0));
if (obj && obj->cast_to<Node>()) { if (Object::cast_to<Node>(obj)) {
valid = true; valid = true;
} }
@ -4200,7 +4200,7 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String
for (int k = 0; k < DOCK_SLOT_MAX; k++) { for (int k = 0; k < DOCK_SLOT_MAX; k++) {
if (!dock_slot[k]->has_node(name)) if (!dock_slot[k]->has_node(name))
continue; continue;
node = dock_slot[k]->get_node(name)->cast_to<Control>(); node = Object::cast_to<Control>(dock_slot[k]->get_node(name));
if (!node) if (!node)
continue; continue;
atidx = k; atidx = k;
@ -4785,7 +4785,7 @@ void EditorNode::reload_scene(const String &p_path) {
if (E->get()->get_path().begins_with(p_path + "::")) //subresources of existing scene if (E->get()->get_path().begins_with(p_path + "::")) //subresources of existing scene
to_clear.push_back(E->get()); to_clear.push_back(E->get());
if (!E->get()->cast_to<Texture>()) if (!cast_to<Texture>(E->get().ptr()))
continue; continue;
if (!E->get()->get_path().is_resource_file() && !E->get()->get_path().is_abs_path()) if (!E->get()->get_path().is_resource_file() && !E->get()->get_path().is_abs_path())
continue; continue;
@ -4926,13 +4926,13 @@ void EditorNode::_dim_timeout() {
void EditorNode::_check_gui_base_size() { void EditorNode::_check_gui_base_size() {
if (gui_base->get_size().width > 1200 * EDSCALE) { if (gui_base->get_size().width > 1200 * EDSCALE) {
for (int i = 0; i < singleton->main_editor_button_vb->get_child_count(); i++) { for (int i = 0; i < singleton->main_editor_button_vb->get_child_count(); i++) {
ToolButton *btn = singleton->main_editor_button_vb->get_child(i)->cast_to<ToolButton>(); ToolButton *btn = Object::cast_to<ToolButton>(singleton->main_editor_button_vb->get_child(i));
if (btn == singleton->distraction_free) continue; if (btn == singleton->distraction_free) continue;
btn->set_text(btn->get_name()); btn->set_text(btn->get_name());
} }
} else { } else {
for (int i = 0; i < singleton->main_editor_button_vb->get_child_count(); i++) { for (int i = 0; i < singleton->main_editor_button_vb->get_child_count(); i++) {
ToolButton *btn = singleton->main_editor_button_vb->get_child(i)->cast_to<ToolButton>(); ToolButton *btn = Object::cast_to<ToolButton>(singleton->main_editor_button_vb->get_child(i));
if (btn == singleton->distraction_free) continue; if (btn == singleton->distraction_free) continue;
btn->set_text(""); btn->set_text("");
} }
@ -5056,7 +5056,7 @@ EditorNode::EditorNode() {
ResourceLoader::clear_translation_remaps(); //no remaps using during editor ResourceLoader::clear_translation_remaps(); //no remaps using during editor
editor_initialize_certificates(); //for asset sharing editor_initialize_certificates(); //for asset sharing
InputDefault *id = Input::get_singleton()->cast_to<InputDefault>(); InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());
if (id) { if (id) {

View file

@ -139,9 +139,9 @@ void EditorPath::_notification(int p_what) {
if (left < 0) if (left < 0)
continue; continue;
String name; String name;
if (obj->cast_to<Resource>()) { if (Object::cast_to<Resource>(obj)) {
Resource *r = obj->cast_to<Resource>(); Resource *r = Object::cast_to<Resource>(obj);
if (r->get_path().is_resource_file()) if (r->get_path().is_resource_file())
name = r->get_path().get_file(); name = r->get_path().get_file();
else else
@ -149,11 +149,11 @@ void EditorPath::_notification(int p_what) {
if (name == "") if (name == "")
name = r->get_class(); name = r->get_class();
} else if (obj->cast_to<Node>()) { } else if (Object::cast_to<Node>(obj)) {
name = obj->cast_to<Node>()->get_name(); name = Object::cast_to<Node>(obj)->get_name();
} else if (obj->cast_to<Resource>() && obj->cast_to<Resource>()->get_name() != "") { } else if (Object::cast_to<Resource>(obj) && Object::cast_to<Resource>(obj)->get_name() != "") {
name = obj->cast_to<Resource>()->get_name(); name = Object::cast_to<Resource>(obj)->get_name();
} else { } else {
name = obj->get_class(); name = obj->get_class();
} }

View file

@ -155,7 +155,7 @@ void EditorPlugin::add_tool_menu_item(const String &p_name, Object *p_handler, c
void EditorPlugin::add_tool_submenu_item(const String &p_name, Object *p_submenu) { void EditorPlugin::add_tool_submenu_item(const String &p_name, Object *p_submenu) {
ERR_FAIL_NULL(p_submenu); ERR_FAIL_NULL(p_submenu);
PopupMenu *submenu = p_submenu->cast_to<PopupMenu>(); PopupMenu *submenu = Object::cast_to<PopupMenu>(p_submenu);
ERR_FAIL_NULL(submenu); ERR_FAIL_NULL(submenu);
//EditorNode::get_singleton()->add_tool_submenu_item(p_name, submenu); //EditorNode::get_singleton()->add_tool_submenu_item(p_name, submenu);
} }

View file

@ -804,10 +804,7 @@ void EditorSettings::notify_changes() {
_THREAD_SAFE_METHOD_ _THREAD_SAFE_METHOD_
SceneTree *sml = NULL; SceneTree *sml = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
if (OS::get_singleton()->get_main_loop())
sml = OS::get_singleton()->get_main_loop()->cast_to<SceneTree>();
if (!sml) { if (!sml) {
return; return;

View file

@ -65,7 +65,7 @@ void GroupsEditor::_remove_group(Object *p_item, int p_column, int p_id) {
if (!node) if (!node)
return; return;
TreeItem *ti = p_item->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(p_item);
if (!ti) if (!ti)
return; return;

View file

@ -320,7 +320,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
} else { } else {
//mesh since nothing else //mesh since nothing else
node = memnew(MeshInstance); node = memnew(MeshInstance);
node->cast_to<MeshInstance>()->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true); Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true);
} }
} break; } break;
case Collada::Node::TYPE_SKELETON: { case Collada::Node::TYPE_SKELETON: {
@ -1448,9 +1448,9 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
Spatial *node = node_map[p_node->id].node; Spatial *node = node_map[p_node->id].node;
Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node); Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node);
if (node->cast_to<Path>()) { if (Object::cast_to<Path>(node)) {
Path *path = node->cast_to<Path>(); Path *path = Object::cast_to<Path>(node);
String curve = ng->source; String curve = ng->source;
@ -1523,11 +1523,11 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
} }
} }
if (node->cast_to<MeshInstance>()) { if (Object::cast_to<MeshInstance>(node)) {
Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node); Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node);
MeshInstance *mi = node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(node);
ERR_FAIL_COND_V(!mi, ERR_BUG); ERR_FAIL_COND_V(!mi, ERR_BUG);
@ -1561,7 +1561,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
} }
ERR_FAIL_COND_V(!node_map.has(skname), ERR_INVALID_DATA); ERR_FAIL_COND_V(!node_map.has(skname), ERR_INVALID_DATA);
NodeMap nmsk = node_map[skname]; NodeMap nmsk = node_map[skname];
Skeleton *sk = nmsk.node->cast_to<Skeleton>(); Skeleton *sk = Object::cast_to<Skeleton>(nmsk.node);
ERR_FAIL_COND_V(!sk, ERR_INVALID_DATA); ERR_FAIL_COND_V(!sk, ERR_INVALID_DATA);
ERR_FAIL_COND_V(!skeleton_bone_map.has(sk), ERR_INVALID_DATA); ERR_FAIL_COND_V(!skeleton_bone_map.has(sk), ERR_INVALID_DATA);
Map<String, int> &bone_remap_map = skeleton_bone_map[sk]; Map<String, int> &bone_remap_map = skeleton_bone_map[sk];
@ -2092,7 +2092,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
if (nm.bone >= 0) { if (nm.bone >= 0) {
//make bone transform relative to rest (in case of skeleton) //make bone transform relative to rest (in case of skeleton)
Skeleton *sk = nm.node->cast_to<Skeleton>(); Skeleton *sk = Object::cast_to<Skeleton>(nm.node);
if (sk) { if (sk) {
xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform; xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform;

View file

@ -172,9 +172,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
return NULL; return NULL;
} }
#if 0 #if 0
if (p_node->cast_to<MeshInstance>()) { if (Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
bool bb = false; bool bb = false;
@ -203,9 +203,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
} }
} }
#endif #endif
if (p_node->cast_to<MeshInstance>()) { if (Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Ref<ArrayMesh> m = mi->get_mesh(); Ref<ArrayMesh> m = mi->get_mesh();
@ -232,9 +232,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
} }
} }
if (p_node->cast_to<AnimationPlayer>()) { if (Object::cast_to<AnimationPlayer>(p_node)) {
//remove animations referencing non-importable nodes //remove animations referencing non-importable nodes
AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>(); AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
List<StringName> anims; List<StringName> anims;
ap->get_animation_list(&anims); ap->get_animation_list(&anims);
@ -257,9 +257,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
} }
} }
#if 0 #if 0
if (p_node->cast_to<MeshInstance>()) { if (Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
String str; String str;
@ -269,9 +269,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
str = mi->get_mesh()->get_name(); str = mi->get_mesh()->get_name();
} }
if (p_node->get_parent() && p_node->get_parent()->cast_to<MeshInstance>()) { if (Object::cast_to<MeshInstance>(p_node->get_parent())) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>(); MeshInstance *mip = Object::cast_to<MeshInstance>(p_node->get_parent());
String d = str.substr(str.find("imp") + 3, str.length()); String d = str.substr(str.find("imp") + 3, str.length());
if (d != "") { if (d != "") {
if ((d[0] < '0' || d[0] > '9')) if ((d[0] < '0' || d[0] > '9'))
@ -307,9 +307,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
#endif #endif
#if 0 #if 0
if (p_flags&SCENE_FLAG_CREATE_LODS && p_node->cast_to<MeshInstance>()) { if (p_flags&SCENE_FLAG_CREATE_LODS && Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
String str; String str;
@ -321,9 +321,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
} }
if (p_node->get_parent() && p_node->get_parent()->cast_to<MeshInstance>()) { if (Object::cast_to<MeshInstance>(p_node->get_parent())) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>(); MeshInstance *mip = Object::cast_to<MeshInstance>(p_node->get_parent());
String d=str.substr(str.find("lod")+3,str.length()); String d=str.substr(str.find("lod")+3,str.length());
if (d!="") { if (d!="") {
if ((d[0]<'0' || d[0]>'9')) if ((d[0]<'0' || d[0]>'9'))
@ -356,9 +356,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
} }
if (p_flags&SCENE_FLAG_DETECT_LIGHTMAP_LAYER && _teststr(name,"lm") && p_node->cast_to<MeshInstance>()) { if (p_flags&SCENE_FLAG_DETECT_LIGHTMAP_LAYER && _teststr(name,"lm") && Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
String str=name; String str=name;
int layer = str.substr(str.find("lm")+3,str.length()).to_int(); int layer = str.substr(str.find("lm")+3,str.length()).to_int();
@ -370,19 +370,18 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
if (isroot) if (isroot)
return p_node; return p_node;
if (p_node->cast_to<MeshInstance>()) { if (MeshInstance *mi = Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
Node *col = mi->create_trimesh_collision_node(); Node *col = mi->create_trimesh_collision_node();
ERR_FAIL_COND_V(!col, NULL); ERR_FAIL_COND_V(!col, NULL);
col->set_name(_fixstr(name, "colonly")); col->set_name(_fixstr(name, "colonly"));
col->cast_to<Spatial>()->set_transform(mi->get_transform()); Object::cast_to<Spatial>(col)->set_transform(mi->get_transform());
p_node->replace_by(col); p_node->replace_by(col);
memdelete(p_node); memdelete(p_node);
p_node = col; p_node = col;
StaticBody *sb = col->cast_to<StaticBody>(); StaticBody *sb = Object::cast_to<StaticBody>(col);
CollisionShape *colshape = sb->get_child(0)->cast_to<CollisionShape>(); CollisionShape *colshape = Object::cast_to<CollisionShape>(sb->get_child(0));
colshape->set_name("shape"); colshape->set_name("shape");
colshape->set_owner(p_node->get_owner()); colshape->set_owner(p_node->get_owner());
} else if (p_node->has_meta("empty_draw_type")) { } else if (p_node->has_meta("empty_draw_type")) {
@ -390,7 +389,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
print_line(empty_draw_type); print_line(empty_draw_type);
StaticBody *sb = memnew(StaticBody); StaticBody *sb = memnew(StaticBody);
sb->set_name(_fixstr(name, "colonly")); sb->set_name(_fixstr(name, "colonly"));
sb->cast_to<Spatial>()->set_transform(p_node->cast_to<Spatial>()->get_transform()); Object::cast_to<Spatial>(sb)->set_transform(Object::cast_to<Spatial>(p_node)->get_transform());
p_node->replace_by(sb); p_node->replace_by(sb);
memdelete(p_node); memdelete(p_node);
CollisionShape *colshape = memnew(CollisionShape); CollisionShape *colshape = memnew(CollisionShape);
@ -404,7 +403,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
rayShape->set_length(1); rayShape->set_length(1);
colshape->set_shape(rayShape); colshape->set_shape(rayShape);
colshape->set_name("RayShape"); colshape->set_name("RayShape");
sb->cast_to<Spatial>()->rotate_x(Math_PI / 2); Object::cast_to<Spatial>(sb)->rotate_x(Math_PI / 2);
} else if (empty_draw_type == "IMAGE") { } else if (empty_draw_type == "IMAGE") {
PlaneShape *planeShape = memnew(PlaneShape); PlaneShape *planeShape = memnew(PlaneShape);
colshape->set_shape(planeShape); colshape->set_shape(planeShape);
@ -419,13 +418,13 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
colshape->set_owner(sb->get_owner()); colshape->set_owner(sb->get_owner());
} }
} else if (_teststr(name, "rigid") && p_node->cast_to<MeshInstance>()) { } else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance>(p_node)) {
if (isroot) if (isroot)
return p_node; return p_node;
// get mesh instance and bounding box // get mesh instance and bounding box
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Rect3 aabb = mi->get_aabb(); Rect3 aabb = mi->get_aabb();
// create a new rigid body collision node // create a new rigid body collision node
@ -436,12 +435,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
// remove node name postfix // remove node name postfix
col->set_name(_fixstr(name, "rigid")); col->set_name(_fixstr(name, "rigid"));
// get mesh instance xform matrix to the rigid body collision node // get mesh instance xform matrix to the rigid body collision node
col->cast_to<Spatial>()->set_transform(mi->get_transform()); Object::cast_to<Spatial>(col)->set_transform(mi->get_transform());
// save original node by duplicating it into a new instance and correcting the name // save original node by duplicating it into a new instance and correcting the name
Node *mesh = p_node->duplicate(); Node *mesh = p_node->duplicate();
mesh->set_name(_fixstr(name, "rigid")); mesh->set_name(_fixstr(name, "rigid"));
// reset the xform matrix of the duplicated node so it can inherit parent node xform // reset the xform matrix of the duplicated node so it can inherit parent node xform
mesh->cast_to<Spatial>()->set_transform(Transform(Basis())); Object::cast_to<Spatial>(mesh)->set_transform(Transform(Basis()));
// reparent the new mesh node to the rigid body collision node // reparent the new mesh node to the rigid body collision node
p_node->add_child(mesh); p_node->add_child(mesh);
mesh->set_owner(p_node->get_owner()); mesh->set_owner(p_node->get_owner());
@ -451,7 +450,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
p_node = col; p_node = col;
// create an alias for the rigid body collision node // create an alias for the rigid body collision node
RigidBody *rb = col->cast_to<RigidBody>(); RigidBody *rb = Object::cast_to<RigidBody>(col);
// create a new Box collision shape and set the right extents // create a new Box collision shape and set the right extents
Ref<BoxShape> shape = memnew(BoxShape); Ref<BoxShape> shape = memnew(BoxShape);
shape->set_extents(aabb.get_size() * 0.5); shape->set_extents(aabb.get_size() * 0.5);
@ -462,9 +461,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
rb->add_child(colshape); rb->add_child(colshape);
colshape->set_owner(p_node->get_owner()); colshape->set_owner(p_node->get_owner());
} else if (_teststr(name, "col") && p_node->cast_to<MeshInstance>()) { } else if (_teststr(name, "col") && Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
mi->set_name(_fixstr(name, "col")); mi->set_name(_fixstr(name, "col"));
Node *col = mi->create_trimesh_collision_node(); Node *col = mi->create_trimesh_collision_node();
@ -473,19 +472,19 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
col->set_name("col"); col->set_name("col");
p_node->add_child(col); p_node->add_child(col);
StaticBody *sb = col->cast_to<StaticBody>(); StaticBody *sb = Object::cast_to<StaticBody>(col);
CollisionShape *colshape = sb->get_child(0)->cast_to<CollisionShape>(); CollisionShape *colshape = Object::cast_to<CollisionShape>(sb->get_child(0));
colshape->set_name("shape"); colshape->set_name("shape");
col->add_child(colshape); col->add_child(colshape);
colshape->set_owner(p_node->get_owner()); colshape->set_owner(p_node->get_owner());
sb->set_owner(p_node->get_owner()); sb->set_owner(p_node->get_owner());
} else if (_teststr(name, "navmesh") && p_node->cast_to<MeshInstance>()) { } else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance>(p_node)) {
if (isroot) if (isroot)
return p_node; return p_node;
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Ref<ArrayMesh> mesh = mi->get_mesh(); Ref<ArrayMesh> mesh = mi->get_mesh();
ERR_FAIL_COND_V(mesh.is_null(), NULL); ERR_FAIL_COND_V(mesh.is_null(), NULL);
@ -495,7 +494,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
Ref<NavigationMesh> nmesh = memnew(NavigationMesh); Ref<NavigationMesh> nmesh = memnew(NavigationMesh);
nmesh->create_from_mesh(mesh); nmesh->create_from_mesh(mesh);
nmi->set_navigation_mesh(nmesh); nmi->set_navigation_mesh(nmesh);
nmi->cast_to<Spatial>()->set_transform(mi->get_transform()); Object::cast_to<Spatial>(nmi)->set_transform(mi->get_transform());
p_node->replace_by(nmi); p_node->replace_by(nmi);
memdelete(p_node); memdelete(p_node);
p_node = nmi; p_node = nmi;
@ -505,7 +504,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
return p_node; return p_node;
Node *owner = p_node->get_owner(); Node *owner = p_node->get_owner();
Spatial *s = p_node->cast_to<Spatial>(); Spatial *s = Object::cast_to<Spatial>(p_node);
VehicleBody *bv = memnew(VehicleBody); VehicleBody *bv = memnew(VehicleBody);
String n = _fixstr(p_node->get_name(), "vehicle"); String n = _fixstr(p_node->get_name(), "vehicle");
bv->set_name(n); bv->set_name(n);
@ -525,7 +524,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
return p_node; return p_node;
Node *owner = p_node->get_owner(); Node *owner = p_node->get_owner();
Spatial *s = p_node->cast_to<Spatial>(); Spatial *s = Object::cast_to<Spatial>(p_node);
VehicleWheel *bv = memnew(VehicleWheel); VehicleWheel *bv = memnew(VehicleWheel);
String n = _fixstr(p_node->get_name(), "wheel"); String n = _fixstr(p_node->get_name(), "wheel");
bv->set_name(n); bv->set_name(n);
@ -539,12 +538,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
p_node = bv; p_node = bv;
} else if (_teststr(name, "room") && p_node->cast_to<MeshInstance>()) { } else if (_teststr(name, "room") && Object::cast_to<MeshInstance>(p_node)) {
if (isroot) if (isroot)
return p_node; return p_node;
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID); PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID);
BSP_Tree bsptree(faces); BSP_Tree bsptree(faces);
@ -567,7 +566,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
if (isroot) if (isroot)
return p_node; return p_node;
Spatial *dummy = p_node->cast_to<Spatial>(); Spatial *dummy = Object::cast_to<Spatial>(p_node);
ERR_FAIL_COND_V(!dummy, NULL); ERR_FAIL_COND_V(!dummy, NULL);
Room *room = memnew(Room); Room *room = memnew(Room);
@ -580,12 +579,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
//room->compute_room_from_subtree(); //room->compute_room_from_subtree();
} else if (_teststr(name, "portal") && p_node->cast_to<MeshInstance>()) { } else if (_teststr(name, "portal") && Object::cast_to<MeshInstance>(p_node)) {
if (isroot) if (isroot)
return p_node; return p_node;
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID); PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID);
ERR_FAIL_COND_V(faces.size() == 0, NULL); ERR_FAIL_COND_V(faces.size() == 0, NULL);
@ -659,11 +658,11 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
memdelete(p_node); memdelete(p_node);
p_node = portal; p_node = portal;
} else if (p_node->cast_to<MeshInstance>()) { } else if (Object::cast_to<MeshInstance>(p_node)) {
//last attempt, maybe collision insde the mesh data //last attempt, maybe collision insde the mesh data
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Ref<ArrayMesh> mesh = mi->get_mesh(); Ref<ArrayMesh> mesh = mi->get_mesh();
if (!mesh.is_null()) { if (!mesh.is_null()) {
@ -728,7 +727,7 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo
Node *n = scene->get_node(String("AnimationPlayer")); Node *n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n); ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>(); AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
ERR_FAIL_COND(!anim); ERR_FAIL_COND(!anim);
if (!anim->has_animation("default")) if (!anim->has_animation("default"))
@ -847,7 +846,7 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) {
return; return;
Node *n = scene->get_node(String("AnimationPlayer")); Node *n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n); ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>(); AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
ERR_FAIL_COND(!anim); ERR_FAIL_COND(!anim);
Vector<String> strings = p_text.split("\n"); Vector<String> strings = p_text.split("\n");
@ -954,7 +953,7 @@ void ResourceImporterScene::_optimize_animations(Node *scene, float p_max_lin_er
return; return;
Node *n = scene->get_node(String("AnimationPlayer")); Node *n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n); ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>(); AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
ERR_FAIL_COND(!anim); ERR_FAIL_COND(!anim);
List<StringName> anim_names; List<StringName> anim_names;
@ -1196,10 +1195,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
String root_type = p_options["nodes/root_type"]; String root_type = p_options["nodes/root_type"];
if (scene->get_class() != root_type) { if (scene->get_class() != root_type) {
Object *base = ClassDB::instance(root_type); Node *base_node = base_node = Object::cast_to<Node>(ClassDB::instance(root_type));
Node *base_node = NULL;
if (base)
base_node = base->cast_to<Node>();
if (base_node) { if (base_node) {

View file

@ -1603,7 +1603,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe
if (p_existing!=String() && ResourceCache::has(p_existing)) { if (p_existing!=String() && ResourceCache::has(p_existing)) {
font = Ref<BitmapFont>( ResourceCache::get(p_existing)->cast_to<BitmapFont>()); font = Ref<BitmapFont>( Object::cast_to<BitmapFont>(ResourceCache::get(p_existing)));
} }
if (font.is_null()) { if (font.is_null()) {

View file

@ -679,7 +679,7 @@ Error EditorSampleImportPlugin::import(const String& p_path, const Ref<ResourceI
if (ResourceCache::has(p_path)) { if (ResourceCache::has(p_path)) {
target = Ref<Sample>( ResourceCache::get(p_path)->cast_to<Sample>() ); target = Ref<Sample>( Object::cast_to<Sample>(ResourceCache::get(p_path)) );
} else { } else {
target = smp; target = smp;

View file

@ -1409,7 +1409,7 @@ void EditorSceneImportPlugin::_find_resources(const Variant& p_var, Map<Ref<Imag
for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) { for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) {
if (E->get().type==Variant::OBJECT || E->get().type==Variant::ARRAY || E->get().type==Variant::DICTIONARY) { if (E->get().type==Variant::OBJECT || E->get().type==Variant::ARRAY || E->get().type==Variant::DICTIONARY) {
if (E->get().type==Variant::OBJECT && res->cast_to<SpatialMaterial>() && (E->get().name=="textures/diffuse" || E->get().name=="textures/detail" || E->get().name=="textures/emission")) { if (E->get().type==Variant::OBJECT && Object::cast_to<SpatialMaterial>(*res) && (E->get().name=="textures/diffuse" || E->get().name=="textures/detail" || E->get().name=="textures/emission")) {
Ref<ImageTexture> tex =res->get(E->get().name); Ref<ImageTexture> tex =res->get(E->get().name);
if (tex.is_valid()) { if (tex.is_valid()) {
@ -1417,7 +1417,7 @@ void EditorSceneImportPlugin::_find_resources(const Variant& p_var, Map<Ref<Imag
image_map.insert(tex,TEXTURE_ROLE_DIFFUSE); image_map.insert(tex,TEXTURE_ROLE_DIFFUSE);
} }
} else if (E->get().type==Variant::OBJECT && res->cast_to<SpatialMaterial>() && (E->get().name=="textures/normal")) { } else if (E->get().type==Variant::OBJECT && Object::cast_to<SpatialMaterial>(*res) && (E->get().name=="textures/normal")) {
Ref<ImageTexture> tex =res->get(E->get().name); Ref<ImageTexture> tex =res->get(E->get().name);
if (tex.is_valid()) { if (tex.is_valid()) {
@ -1425,7 +1425,7 @@ void EditorSceneImportPlugin::_find_resources(const Variant& p_var, Map<Ref<Imag
image_map.insert(tex,TEXTURE_ROLE_NORMALMAP); image_map.insert(tex,TEXTURE_ROLE_NORMALMAP);
/* /*
if (p_flags&SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY) if (p_flags&SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY)
res->cast_to<SpatialMaterial>()->set_fixed_flag(SpatialMaterial::FLAG_USE_XY_NORMALMAP,true); Object::cast_to<SpatialMaterial>(*res)->set_fixed_flag(SpatialMaterial::FLAG_USE_XY_NORMALMAP,true);
*/ */
} }
@ -1513,9 +1513,9 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
if (p_flags&SCENE_FLAG_CREATE_BILLBOARDS && p_node->cast_to<MeshInstance>()) { if (p_flags&SCENE_FLAG_CREATE_BILLBOARDS && Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
bool bb=false; bool bb=false;
@ -1546,9 +1546,9 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
} }
if (p_flags&(SCENE_FLAG_DETECT_ALPHA|SCENE_FLAG_DETECT_VCOLOR|SCENE_FLAG_SET_LIGHTMAP_TO_UV2_IF_EXISTS) && p_node->cast_to<MeshInstance>()) { if (p_flags&(SCENE_FLAG_DETECT_ALPHA|SCENE_FLAG_DETECT_VCOLOR|SCENE_FLAG_SET_LIGHTMAP_TO_UV2_IF_EXISTS) && Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Ref<Mesh> m = mi->get_mesh(); Ref<Mesh> m = mi->get_mesh();
@ -1579,9 +1579,9 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
} }
} }
if (p_flags&SCENE_FLAG_REMOVE_NOIMP && p_node->cast_to<AnimationPlayer>()) { if (p_flags&SCENE_FLAG_REMOVE_NOIMP && Object::cast_to<AnimationPlayer>(p_node)) {
//remove animations referencing non-importable nodes //remove animations referencing non-importable nodes
AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>(); AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
List<StringName> anims; List<StringName> anims;
ap->get_animation_list(&anims); ap->get_animation_list(&anims);
@ -1606,9 +1606,9 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
} }
if (p_flags&SCENE_FLAG_CREATE_IMPOSTORS && p_node->cast_to<MeshInstance>()) { if (p_flags&SCENE_FLAG_CREATE_IMPOSTORS && Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
String str; String str;
@ -1620,9 +1620,9 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
} }
if (p_node->get_parent() && p_node->get_parent()->cast_to<MeshInstance>()) { if (Object::cast_to<MeshInstance>(p_node->get_parent())) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>(); MeshInstance *mip = Object::cast_to<MeshInstance>(p_node->get_parent());
String d=str.substr(str.find("imp")+3,str.length()); String d=str.substr(str.find("imp")+3,str.length());
if (d!="") { if (d!="") {
if ((d[0]<'0' || d[0]>'9')) if ((d[0]<'0' || d[0]>'9'))
@ -1656,9 +1656,9 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
} }
} }
if (p_flags&SCENE_FLAG_CREATE_LODS && p_node->cast_to<MeshInstance>()) { if (p_flags&SCENE_FLAG_CREATE_LODS && Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
String str; String str;
@ -1670,9 +1670,9 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
} }
if (p_node->get_parent() && p_node->get_parent()->cast_to<MeshInstance>()) { if (Object::cast_to<MeshInstance>(p_node->get_parent())) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>(); MeshInstance *mip = Object::cast_to<MeshInstance>(p_node->get_parent());
String d=str.substr(str.find("lod")+3,str.length()); String d=str.substr(str.find("lod")+3,str.length());
if (d!="") { if (d!="") {
if ((d[0]<'0' || d[0]>'9')) if ((d[0]<'0' || d[0]>'9'))
@ -1705,9 +1705,9 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
} }
if (p_flags&SCENE_FLAG_DETECT_LIGHTMAP_LAYER && _teststr(name,"lm") && p_node->cast_to<MeshInstance>()) { if (p_flags&SCENE_FLAG_DETECT_LIGHTMAP_LAYER && _teststr(name,"lm") && Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
String str=name; String str=name;
int layer = str.substr(str.find("lm")+3,str.length()).to_int(); int layer = str.substr(str.find("lm")+3,str.length()).to_int();
@ -1721,18 +1721,18 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
if (isroot) if (isroot)
return p_node; return p_node;
if (p_node->cast_to<MeshInstance>() && !is_rigid) { if (Object::cast_to<MeshInstance>(p_node) && !is_rigid) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Node * col = mi->create_trimesh_collision_node(); Node * col = mi->create_trimesh_collision_node();
ERR_FAIL_COND_V(!col,NULL); ERR_FAIL_COND_V(!col,NULL);
col->set_name(_fixstr(name,"colonly")); col->set_name(_fixstr(name,"colonly"));
col->cast_to<Spatial>()->set_transform(mi->get_transform()); Object::cast_to<Spatial>(col)->set_transform(mi->get_transform());
p_node->replace_by(col); p_node->replace_by(col);
memdelete(p_node); memdelete(p_node);
p_node=col; p_node=col;
StaticBody *sb = col->cast_to<StaticBody>(); StaticBody *sb = Object::cast_to<StaticBody>(col);
CollisionShape *colshape = memnew( CollisionShape); CollisionShape *colshape = memnew( CollisionShape);
colshape->set_shape(sb->get_shape(0)); colshape->set_shape(sb->get_shape(0));
colshape->set_name("shape"); colshape->set_name("shape");
@ -1749,7 +1749,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
pb = memnew(StaticBody); pb = memnew(StaticBody);
pb->set_name(_fixstr(name, "colonly")); pb->set_name(_fixstr(name, "colonly"));
} }
pb->cast_to<Spatial>()->set_transform(p_node->cast_to<Spatial>()->get_transform()); Object::cast_to<Spatial>(pb)->set_transform(Object::cast_to<Spatial>(p_node)->get_transform());
p_node->replace_by(pb); p_node->replace_by(pb);
memdelete(p_node); memdelete(p_node);
CollisionShape *colshape = memnew( CollisionShape); CollisionShape *colshape = memnew( CollisionShape);
@ -1763,7 +1763,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
rayShape->set_length(1); rayShape->set_length(1);
colshape->set_shape(rayShape); colshape->set_shape(rayShape);
colshape->set_name("RayShape"); colshape->set_name("RayShape");
pb->cast_to<Spatial>()->rotate_x(Math_PI / 2); Object::cast_to<Spatial>(pb)->rotate_x(Math_PI / 2);
} else if (empty_draw_type == "IMAGE") { } else if (empty_draw_type == "IMAGE") {
PlaneShape *planeShape = memnew( PlaneShape); PlaneShape *planeShape = memnew( PlaneShape);
colshape->set_shape(planeShape); colshape->set_shape(planeShape);
@ -1778,13 +1778,13 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
colshape->set_owner(pb->get_owner()); colshape->set_owner(pb->get_owner());
} }
} else if (p_flags&SCENE_FLAG_CREATE_COLLISIONS && _teststr(name,"rigid") && p_node->cast_to<MeshInstance>()) { } else if (p_flags&SCENE_FLAG_CREATE_COLLISIONS && _teststr(name,"rigid") && Object::cast_to<MeshInstance>(p_node)) {
if (isroot) if (isroot)
return p_node; return p_node;
// get mesh instance and bounding box // get mesh instance and bounding box
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Rect3 aabb = mi->get_aabb(); Rect3 aabb = mi->get_aabb();
// create a new rigid body collision node // create a new rigid body collision node
@ -1795,12 +1795,12 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
// remove node name postfix // remove node name postfix
col->set_name(_fixstr(name,"rigid")); col->set_name(_fixstr(name,"rigid"));
// get mesh instance xform matrix to the rigid body collision node // get mesh instance xform matrix to the rigid body collision node
col->cast_to<Spatial>()->set_transform(mi->get_transform()); Object::cast_to<Spatial>(col)->set_transform(mi->get_transform());
// save original node by duplicating it into a new instance and correcting the name // save original node by duplicating it into a new instance and correcting the name
Node * mesh = p_node->duplicate(); Node * mesh = p_node->duplicate();
mesh->set_name(_fixstr(name,"rigid")); mesh->set_name(_fixstr(name,"rigid"));
// reset the xform matrix of the duplicated node so it can inherit parent node xform // reset the xform matrix of the duplicated node so it can inherit parent node xform
mesh->cast_to<Spatial>()->set_transform(Transform(Basis())); Object::cast_to<Spatial>(mesh)->set_transform(Transform(Basis()));
// reparent the new mesh node to the rigid body collision node // reparent the new mesh node to the rigid body collision node
p_node->add_child(mesh); p_node->add_child(mesh);
mesh->set_owner(p_node->get_owner()); mesh->set_owner(p_node->get_owner());
@ -1810,7 +1810,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
p_node=col; p_node=col;
// create an alias for the rigid body collision node // create an alias for the rigid body collision node
RigidBody *rb = col->cast_to<RigidBody>(); RigidBody *rb = Object::cast_to<RigidBody>(col);
// create a new Box collision shape and set the right extents // create a new Box collision shape and set the right extents
Ref<BoxShape> shape = memnew( BoxShape ); Ref<BoxShape> shape = memnew( BoxShape );
shape->set_extents(aabb.get_size() * 0.5); shape->set_extents(aabb.get_size() * 0.5);
@ -1821,10 +1821,10 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
rb->add_child(colshape); rb->add_child(colshape);
colshape->set_owner(p_node->get_owner()); colshape->set_owner(p_node->get_owner());
} else if (p_flags&SCENE_FLAG_CREATE_COLLISIONS &&_teststr(name,"col") && p_node->cast_to<MeshInstance>()) { } else if (p_flags&SCENE_FLAG_CREATE_COLLISIONS &&_teststr(name,"col") && Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
mi->set_name(_fixstr(name,"col")); mi->set_name(_fixstr(name,"col"));
Node *col= mi->create_trimesh_collision_node(); Node *col= mi->create_trimesh_collision_node();
@ -1833,7 +1833,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
col->set_name("col"); col->set_name("col");
p_node->add_child(col); p_node->add_child(col);
StaticBody *sb=col->cast_to<StaticBody>(); StaticBody *sb=Object::cast_to<StaticBody>(col);
CollisionShape *colshape = memnew( CollisionShape); CollisionShape *colshape = memnew( CollisionShape);
colshape->set_shape(sb->get_shape(0)); colshape->set_shape(sb->get_shape(0));
colshape->set_name("shape"); colshape->set_name("shape");
@ -1841,12 +1841,12 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
colshape->set_owner(p_node->get_owner()); colshape->set_owner(p_node->get_owner());
sb->set_owner(p_node->get_owner()); sb->set_owner(p_node->get_owner());
} else if (p_flags&SCENE_FLAG_CREATE_NAVMESH &&_teststr(name,"navmesh") && p_node->cast_to<MeshInstance>()) { } else if (p_flags&SCENE_FLAG_CREATE_NAVMESH &&_teststr(name,"navmesh") && Object::cast_to<MeshInstance>(p_node)) {
if (isroot) if (isroot)
return p_node; return p_node;
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Ref<Mesh> mesh=mi->get_mesh(); Ref<Mesh> mesh=mi->get_mesh();
ERR_FAIL_COND_V(mesh.is_null(),NULL); ERR_FAIL_COND_V(mesh.is_null(),NULL);
@ -1857,7 +1857,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
Ref<NavigationMesh> nmesh = memnew( NavigationMesh); Ref<NavigationMesh> nmesh = memnew( NavigationMesh);
nmesh->create_from_mesh(mesh); nmesh->create_from_mesh(mesh);
nmi->set_navigation_mesh(nmesh); nmi->set_navigation_mesh(nmesh);
nmi->cast_to<Spatial>()->set_transform(mi->get_transform()); Object::cast_to<Spatial>(nmi)->set_transform(mi->get_transform());
p_node->replace_by(nmi); p_node->replace_by(nmi);
memdelete(p_node); memdelete(p_node);
p_node=nmi; p_node=nmi;
@ -1867,7 +1867,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
return p_node; return p_node;
Node *owner = p_node->get_owner(); Node *owner = p_node->get_owner();
Spatial *s = p_node->cast_to<Spatial>(); Spatial *s = Object::cast_to<Spatial>(p_node);
VehicleBody *bv = memnew( VehicleBody ); VehicleBody *bv = memnew( VehicleBody );
String n = _fixstr(p_node->get_name(),"vehicle"); String n = _fixstr(p_node->get_name(),"vehicle");
bv->set_name(n); bv->set_name(n);
@ -1888,7 +1888,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
return p_node; return p_node;
Node *owner = p_node->get_owner(); Node *owner = p_node->get_owner();
Spatial *s = p_node->cast_to<Spatial>(); Spatial *s = Object::cast_to<Spatial>(p_node);
VehicleWheel *bv = memnew( VehicleWheel ); VehicleWheel *bv = memnew( VehicleWheel );
String n = _fixstr(p_node->get_name(),"wheel"); String n = _fixstr(p_node->get_name(),"wheel");
bv->set_name(n); bv->set_name(n);
@ -1902,13 +1902,13 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
p_node=bv; p_node=bv;
} else if (p_flags&SCENE_FLAG_CREATE_ROOMS && _teststr(name,"room") && p_node->cast_to<MeshInstance>()) { } else if (p_flags&SCENE_FLAG_CREATE_ROOMS && _teststr(name,"room") && Object::cast_to<MeshInstance>(p_node)) {
if (isroot) if (isroot)
return p_node; return p_node;
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID); PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID);
@ -1933,7 +1933,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
if (isroot) if (isroot)
return p_node; return p_node;
Spatial *dummy = p_node->cast_to<Spatial>(); Spatial *dummy = Object::cast_to<Spatial>(p_node);
ERR_FAIL_COND_V(!dummy,NULL); ERR_FAIL_COND_V(!dummy,NULL);
Room * room = memnew( Room ); Room * room = memnew( Room );
@ -1946,12 +1946,12 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
//room->compute_room_from_subtree(); //room->compute_room_from_subtree();
} else if (p_flags&SCENE_FLAG_CREATE_PORTALS &&_teststr(name,"portal") && p_node->cast_to<MeshInstance>()) { } else if (p_flags&SCENE_FLAG_CREATE_PORTALS &&_teststr(name,"portal") && Object::cast_to<MeshInstance>(p_node)) {
if (isroot) if (isroot)
return p_node; return p_node;
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID); PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID);
ERR_FAIL_COND_V(faces.size()==0,NULL); ERR_FAIL_COND_V(faces.size()==0,NULL);
@ -2027,11 +2027,11 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
memdelete(p_node); memdelete(p_node);
p_node=portal; p_node=portal;
} else if (p_node->cast_to<MeshInstance>()) { } else if (Object::cast_to<MeshInstance>(p_node)) {
//last attempt, maybe collision insde the mesh data //last attempt, maybe collision insde the mesh data
MeshInstance *mi = p_node->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Ref<Mesh> mesh = mi->get_mesh(); Ref<Mesh> mesh = mi->get_mesh();
if (!mesh.is_null()) { if (!mesh.is_null()) {
@ -2111,7 +2111,7 @@ void EditorSceneImportPlugin::_tag_import_paths(Node *p_scene,Node *p_node) {
NodePath path = p_scene->get_path_to(p_node); NodePath path = p_scene->get_path_to(p_node);
p_node->set_import_path( path ); p_node->set_import_path( path );
Spatial *snode=p_node->cast_to<Spatial>(); Spatial *snode=Object::cast_to<Spatial>(p_node);
if (snode) { if (snode) {
@ -2200,10 +2200,7 @@ Error EditorSceneImportPlugin::import1(const Ref<ResourceImportMetadata>& p_from
if (from->has_option("root_type")) { if (from->has_option("root_type")) {
String type = from->get_option("root_type"); String type = from->get_option("root_type");
Object *base = ClassDB::instance(type); Node *base_node = Object::cast_to<Node>(ClassDB::instance(type));
Node *base_node = NULL;
if (base)
base_node=base->cast_to<Node>();
if (base_node) { if (base_node) {
@ -2228,7 +2225,7 @@ void EditorSceneImportPlugin::_create_clips(Node *scene, const Array& p_clips,bo
Node* n = scene->get_node(String("AnimationPlayer")); Node* n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n); ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>(); AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
ERR_FAIL_COND(!anim); ERR_FAIL_COND(!anim);
if (!anim->has_animation("default")) if (!anim->has_animation("default"))
@ -2357,7 +2354,7 @@ void EditorSceneImportPlugin::_filter_tracks(Node *scene, const String& p_text)
return; return;
Node* n = scene->get_node(String("AnimationPlayer")); Node* n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n); ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>(); AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
ERR_FAIL_COND(!anim); ERR_FAIL_COND(!anim);
Vector<String> strings = p_text.split("\n"); Vector<String> strings = p_text.split("\n");
@ -2475,7 +2472,7 @@ void EditorSceneImportPlugin::_optimize_animations(Node *scene, float p_max_lin_
return; return;
Node* n = scene->get_node(String("AnimationPlayer")); Node* n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n); ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>(); AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
ERR_FAIL_COND(!anim); ERR_FAIL_COND(!anim);
@ -2496,9 +2493,9 @@ void EditorSceneImportPlugin::_find_resources_to_merge(Node *scene, Node *node,
String path = scene->get_path_to(node); String path = scene->get_path_to(node);
if (p_merge_anims && node->cast_to<AnimationPlayer>()) { if (p_merge_anims && Object::cast_to<AnimationPlayer>(node)) {
AnimationPlayer *ap = node->cast_to<AnimationPlayer>(); AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(node);
List<StringName> anims; List<StringName> anims;
ap->get_animation_list(&anims); ap->get_animation_list(&anims);
for (List<StringName>::Element *E=anims.front();E;E=E->next()) { for (List<StringName>::Element *E=anims.front();E;E=E->next()) {
@ -2532,8 +2529,8 @@ void EditorSceneImportPlugin::_find_resources_to_merge(Node *scene, Node *node,
if (p_merge_material && node->cast_to<MeshInstance>()) { if (p_merge_material && Object::cast_to<MeshInstance>(node)) {
MeshInstance *mi=node->cast_to<MeshInstance>(); MeshInstance *mi=Object::cast_to<MeshInstance>(node);
Ref<Mesh> mesh = mi->get_mesh(); Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid() && mesh->get_name()!=String() && !tested_meshes.has(mesh)) { if (mesh.is_valid() && mesh->get_name()!=String() && !tested_meshes.has(mesh)) {
@ -2596,9 +2593,8 @@ void EditorSceneImportPlugin::_merge_found_resources(Node *scene, Node *node, bo
print_line("at path: "+path); print_line("at path: "+path);
if (node->cast_to<AnimationPlayer>()) { if (AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(node)) {
AnimationPlayer *ap = node->cast_to<AnimationPlayer>();
List<StringName> anims; List<StringName> anims;
ap->get_animation_list(&anims); ap->get_animation_list(&anims);
for (List<StringName>::Element *E=anims.front();E;E=E->next()) { for (List<StringName>::Element *E=anims.front();E;E=E->next()) {
@ -2630,8 +2626,8 @@ void EditorSceneImportPlugin::_merge_found_resources(Node *scene, Node *node, bo
if (node->cast_to<MeshInstance>()) { if (MeshInstance *mi=Object::cast_to<MeshInstance>(node)) {
MeshInstance *mi=node->cast_to<MeshInstance>();
Ref<Mesh> mesh = mi->get_mesh(); Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid() && mesh->get_name()!=String() && !tested_meshes.has(mesh)) { if (mesh.is_valid() && mesh->get_name()!=String() && !tested_meshes.has(mesh)) {

View file

@ -407,7 +407,7 @@ Error EditorSceneImporterFBXConv::_parse_nodes(State& state,const Array &p_nodes
print_line("IS SKELETON! "); print_line("IS SKELETON! ");
} else if (state.bones.has(id)) { } else if (state.bones.has(id)) {
if (p_base) if (p_base)
node=p_base->cast_to<Spatial>(); node=Object::cast_to<Spatial>(p_base);
if (!state.bones[id].has_anim_chan) { if (!state.bones[id].has_anim_chan) {
print_line("no has anim "+id); print_line("no has anim "+id);
} }

View file

@ -703,7 +703,7 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin*
VBoxContainer *source_vb=memnew(VBoxContainer); VBoxContainer *source_vb=memnew(VBoxContainer);
MarginContainer *source_mc = vbc->add_margin_child(TTR("Source Texture(s):"),source_vb); MarginContainer *source_mc = vbc->add_margin_child(TTR("Source Texture(s):"),source_vb);
source_label = vbc->get_child(source_mc->get_index()-1)->cast_to<Label>(); source_label = Object::cast_to<Label>(vbc->get_child(source_mc->get_index()-1));
HBoxContainer *hbc = memnew( HBoxContainer ); HBoxContainer *hbc = memnew( HBoxContainer );
source_vb->add_child(hbc); source_vb->add_child(hbc);
@ -733,7 +733,7 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin*
size->set_value(256); size->set_value(256);
size_mc=vbc->add_margin_child(TTR("Cell Size:"),size); size_mc=vbc->add_margin_child(TTR("Cell Size:"),size);
size_label=vbc->get_child(size_mc->get_index()-1)->cast_to<Label>(); size_label=Object::cast_to<Label>(vbc->get_child(size_mc->get_index()-1));
save_path = memnew( LineEdit ); save_path = memnew( LineEdit );
@ -1326,7 +1326,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
if (ResourceCache::has(apath)) { if (ResourceCache::has(apath)) {
at = Ref<AtlasTexture>( ResourceCache::get(apath)->cast_to<AtlasTexture>() ); at = Ref<AtlasTexture>( Object::cast_to<AtlasTexture>(ResourceCache::get(apath)) );
} else { } else {
at = Ref<AtlasTexture>( memnew( AtlasTexture ) ); at = Ref<AtlasTexture>( memnew( AtlasTexture ) );
@ -1340,7 +1340,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
} }
} }
if (ResourceCache::has(p_path)) { if (ResourceCache::has(p_path)) {
texture = Ref<ImageTexture> ( ResourceCache::get(p_path)->cast_to<ImageTexture>() ); texture = Ref<ImageTexture> ( Object::cast_to<ImageTexture>(ResourceCache::get(p_path)) );
} else { } else {
texture = Ref<ImageTexture>( memnew( ImageTexture ) ); texture = Ref<ImageTexture>( memnew( ImageTexture ) );
} }
@ -1354,7 +1354,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
if (ResourceCache::has(p_path)) { if (ResourceCache::has(p_path)) {
Resource *r = ResourceCache::get(p_path); Resource *r = ResourceCache::get(p_path);
texture = Ref<ImageTexture> ( r->cast_to<ImageTexture>() ); texture = Ref<ImageTexture> ( Object::cast_to<ImageTexture>(r) );
Image img; Image img;
Error err = img.load(src_path); Error err = img.load(src_path);

View file

@ -656,8 +656,8 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
return; return;
Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["player"]); 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)) { if (Object::cast_to<AnimationPlayer>(n) && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) {
player = n->cast_to<AnimationPlayer>(); player = Object::cast_to<AnimationPlayer>(n);
_update_player(); _update_player();
show(); show();
set_process(true); set_process(true);
@ -737,9 +737,9 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
if (current != "") { if (current != "") {
Ref<Animation> anim = player->get_animation(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); _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()); anim_editor->set_undo_redo(&get_undo_redo());
if (!p_object) if (!p_object)
return; 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 { bool AnimationPlayerEditorPlugin::handles(Object *p_object) const {

View file

@ -281,9 +281,9 @@ void AnimationTreeEditor::_popup_edit_dialog() {
case AnimationTreePlayer::NODE_ANIMATION: 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->clear();
master_anim_popup->add_item("Edit Filters"); master_anim_popup->add_item("Edit Filters");
master_anim_popup->add_separator(); master_anim_popup->add_separator();
@ -1233,7 +1233,7 @@ void AnimationTreeEditor::_edit_filters() {
if (np.get_property() != StringName()) { if (np.get_property() != StringName()) {
Node *n = base->get_node(np); Node *n = base->get_node(np);
Skeleton *s = n->cast_to<Skeleton>(); Skeleton *s = Object::cast_to<Skeleton>(n);
if (s) { if (s) {
String skelbase = E->get().substr(0, E->get().find(":")); String skelbase = E->get().substr(0, E->get().find(":"));
@ -1439,7 +1439,7 @@ AnimationTreeEditor::AnimationTreeEditor() {
void AnimationTreeEditorPlugin::edit(Object *p_object) { 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 { bool AnimationTreeEditorPlugin::handles(Object *p_object) const {

View file

@ -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) { 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(); Ref<Mesh> mesh=meshi->get_mesh();
if (mesh.is_valid()) { if (mesh.is_valid()) {
_add_mesh(mesh,meshi->get_material_override(),base_inv * meshi->get_global_transform(),meshi->get_baked_light_texture_id()); _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>()) { } else if (Light *dl=Object::cast_to<Light>(p_node)) {
Light *dl=p_node->cast_to<Light>();
if (dl->get_bake_mode()!=Light::BAKE_MODE_DISABLED) { if (dl->get_bake_mode()!=Light::BAKE_MODE_DISABLED) {
@ -340,9 +337,7 @@ void BakedLightBaker::_parse_geometry(Node* p_node) {
lights.push_back(dirl); lights.push_back(dirl);
} }
} else if (p_node->cast_to<Spatial>()){ } else if (Spatial *sp = Object::cast_to<Spatial>(p_node)){
Spatial *sp = p_node->cast_to<Spatial>();
Array arr = p_node->call("_get_baked_light_meshes"); Array arr = p_node->call("_get_baked_light_meshes");
for(int i=0;i<arr.size();i+=2) { 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; return;
cell_count=0; 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); EditorProgress ep("bake",TTR("Light Baker Setup:"),5);
baked_light=p_light; baked_light=p_light;
lattice_size=baked_light->get_initial_lattice_subdiv(); lattice_size=baked_light->get_initial_lattice_subdiv();

View file

@ -337,7 +337,7 @@ BakedLightEditor::~BakedLightEditor() {
void BakedLightEditorPlugin::edit(Object *p_object) { 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 { bool BakedLightEditorPlugin::handles(Object *p_object) const {

View file

@ -97,8 +97,8 @@ CameraEditor::CameraEditor() {
void CameraEditorPlugin::edit(Object *p_object) { void CameraEditorPlugin::edit(Object *p_object) {
SpatialEditor::get_singleton()->set_can_preview(p_object->cast_to<Camera>()); SpatialEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object));
//camera_editor->edit(p_object->cast_to<Node>()); //camera_editor->edit(Object::cast_to<Node>(p_object));
} }
bool CameraEditorPlugin::handles(Object *p_object) const { 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) { void CameraEditorPlugin::make_visible(bool p_visible) {
if (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 { } else {
SpatialEditor::get_singleton()->set_can_preview(NULL); SpatialEditor::get_singleton()->set_can_preview(NULL);
} }

View file

@ -175,7 +175,7 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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()) { if (n2d && n2d->edit_has_pivot()) {
Vector2 offset = n2d->edit_get_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, "set_global_position", gpos);
undo_redo->add_undo_method(n2d, "edit_set_pivot", offset); undo_redo->add_undo_method(n2d, "edit_set_pivot", offset);
for (int i = 0; i < n2d->get_child_count(); i++) { 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) if (!n2dc)
continue; 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) { if (cnt) {
Vector2 old_pivot = cnt->get_pivot_offset(); 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) { 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) if (!ci)
return NULL; return NULL;
@ -413,7 +413,7 @@ void CanvasItemEditor::_visibility_changed(ObjectID p_canvas_item) {
Object *c = ObjectDB::get_instance(p_canvas_item); Object *c = ObjectDB::get_instance(p_canvas_item);
if (!c) if (!c)
return; return;
CanvasItem *ct = c->cast_to<CanvasItem>(); CanvasItem *ct = Object::cast_to<CanvasItem>(c);
if (!ct) if (!ct)
return; return;
canvas_items.erase(ct); 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) { 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) if (!p_node)
return; return;
if (p_node->cast_to<Viewport>()) if (Object::cast_to<Viewport>(p_node))
return; 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--) { for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
if (c && !c->is_set_as_toplevel()) 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); _find_canvas_items_at_pos(p_pos, p_node->get_child(i), p_parent_xform * c->get_transform(), p_canvas_xform, r_items);
else { 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 _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; 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(); Rect2 rect = c->get_item_rect();
Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos); Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos);
if (rect.has_point(local_pos)) { if (rect.has_point(local_pos)) {
Node2D *node = c->cast_to<Node2D>(); Node2D *node = Object::cast_to<Node2D>(c);
_SelectResult res; _SelectResult res;
res.item = c; res.item = c;
@ -492,10 +492,10 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_n
if (!p_node) if (!p_node)
return; return;
if (p_node->cast_to<Viewport>()) if (Object::cast_to<Viewport>(p_node))
return; 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 inherited = p_node != get_tree()->get_edited_scene_root() && p_node->get_filename() != "";
bool editable = false; 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()) 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); _find_canvas_items_at_rect(p_rect, p_node->get_child(i), p_parent_xform * c->get_transform(), p_canvas_xform, r_items);
else { 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); _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(); Rect2 rect = c->get_item_rect();
Transform2D xform = p_parent_xform * p_canvas_xform * c->get_transform(); 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()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) 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 } 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) { if (p_move_mode == MOVE_LOCAL_WITH_ROT) {
Transform2D m; 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); 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); 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()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@ -673,7 +673,7 @@ int CanvasItemEditor::get_item_count() {
int ic = 0; int ic = 0;
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
@ -694,7 +694,7 @@ CanvasItem *CanvasItemEditor::get_single_item() {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) 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(); CanvasItem *canvas_item = get_single_item();
ERR_FAIL_COND_V(!canvas_item, DRAG_NONE); 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); ERR_FAIL_COND_V(!control, DRAG_NONE);
Vector2 anchor_pos[4]; 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()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) 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; continue;
se->undo_state = canvas_item->edit_get_state(); se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>()) if (Object::cast_to<Node2D>(canvas_item))
se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot(); se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
if (canvas_item->cast_to<Control>()) if (Object::cast_to<Control>(canvas_item))
se->undo_pivot = canvas_item->cast_to<Control>()->get_pivot_offset(); 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 = 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 { } else {
drag = DRAG_ALL; drag = DRAG_ALL;
drag_point_from = _find_topleftmost_point(); 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(); List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) 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; continue;
canvas_item->edit_set_state(se->undo_state); canvas_item->edit_set_state(se->undo_state);
if (canvas_item->cast_to<Node2D>()) if (Object::cast_to<Node2D>(canvas_item))
canvas_item->cast_to<Node2D>()->edit_set_pivot(se->undo_pivot); Object::cast_to<Node2D>(canvas_item)->edit_set_pivot(se->undo_pivot);
if (canvas_item->cast_to<Control>()) if (Object::cast_to<Control>(canvas_item))
canvas_item->cast_to<Control>()->set_pivot_offset(se->undo_pivot); 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()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) 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_do_method(canvas_item, "edit_set_state", state);
undo_redo->add_undo_method(canvas_item, "edit_set_state", se->undo_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()) { if (pvt && pvt->edit_has_pivot()) {
undo_redo->add_do_method(canvas_item, "edit_set_pivot", pvt->edit_get_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); 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) { if (cnt) {
undo_redo->add_do_method(canvas_item, "set_pivot_offset", cnt->get_pivot_offset()); 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); 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) { if (Cbone) {
Node2D *b = NULL; Node2D *b = Object::cast_to<Node2D>(ObjectDB::get_instance(Cbone->get().bone));
Object *obj = ObjectDB::get_instance(Cbone->get().bone);
if (obj)
b = obj->cast_to<Node2D>();
if (b) { if (b) {
@ -1359,7 +1356,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
break; break;
float len = pi->get_global_transform().get_origin().distance_to(b->get_global_position()); 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) if (!b)
break; break;
@ -1405,10 +1402,10 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
drag = DRAG_ROTATE; drag = DRAG_ROTATE;
drag_from = transform.affine_inverse().xform(click); drag_from = transform.affine_inverse().xform(click);
se->undo_state = canvas_item->edit_get_state(); se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>()) if (Object::cast_to<Node2D>(canvas_item))
se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot(); se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
if (canvas_item->cast_to<Control>()) if (Object::cast_to<Control>(canvas_item))
se->undo_pivot = canvas_item->cast_to<Control>()->get_pivot_offset(); se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
return; return;
} }
@ -1426,15 +1423,15 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
if (drag != DRAG_NONE) { if (drag != DRAG_NONE) {
drag_from = transform.affine_inverse().xform(click); drag_from = transform.affine_inverse().xform(click);
se->undo_state = canvas_item->edit_get_state(); se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>()) if (Object::cast_to<Node2D>(canvas_item))
se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot(); se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
if (canvas_item->cast_to<Control>()) if (Object::cast_to<Control>(canvas_item))
se->undo_pivot = canvas_item->cast_to<Control>()->get_pivot_offset(); se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
return; return;
} }
// Drag anchor handles // 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); drag = _get_anchor_handle_drag_type(click, drag_point_from);
if (drag != DRAG_NONE) { if (drag != DRAG_NONE) {
drag_from = transform.affine_inverse().xform(click); drag_from = transform.affine_inverse().xform(click);
@ -1457,9 +1454,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
CanvasItem *c = NULL; CanvasItem *c = NULL;
if (Cbone) { if (Cbone) {
Object *obj = ObjectDB::get_instance(Cbone->get().bone); c = Object::cast_to<CanvasItem>(ObjectDB::get_instance(Cbone->get().bone));
if (obj)
c = obj->cast_to<CanvasItem>();
if (c) if (c)
c = c->get_parent_item(); c = c->get_parent_item();
} }
@ -1489,7 +1484,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}; };
if (n) { if (n) {
c = n->cast_to<CanvasItem>(); c = Object::cast_to<CanvasItem>(n);
} else { } else {
c = NULL; 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(); List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) 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) { if (!dragging_bone) {
canvas_item->edit_set_state(se->undo_state); //reset state and reapply canvas_item->edit_set_state(se->undo_state); //reset state and reapply
if (canvas_item->cast_to<Node2D>()) if (Object::cast_to<Node2D>(canvas_item))
canvas_item->cast_to<Node2D>()->edit_set_pivot(se->undo_pivot); Object::cast_to<Node2D>(canvas_item)->edit_set_pivot(se->undo_pivot);
if (canvas_item->cast_to<Control>()) if (Object::cast_to<Control>(canvas_item))
canvas_item->cast_to<Control>()->set_pivot_offset(se->undo_pivot); Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot);
} }
Vector2 dfrom = drag_from; Vector2 dfrom = drag_from;
@ -1566,7 +1561,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
// Rotate the node // Rotate the node
Vector2 center = canvas_item->get_global_transform_with_canvas().get_origin(); 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) { if (node) {
real_t angle = node->get_rotation(); 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) { if (node) {
real_t angle = node->get_rotation(); real_t angle = node->get_rotation();
@ -1592,7 +1587,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
continue; continue;
} }
Control *control = canvas_item->cast_to<Control>(); Control *control = Object::cast_to<Control>(canvas_item);
if (control) { if (control) {
// Drag and snap the anchor // 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)); 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: case DRAG_PIVOT:
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);
n2d->edit_set_pivot(se->undo_pivot + drag_vector); n2d->edit_set_pivot(se->undo_pivot + drag_vector);
} }
if (canvas_item->cast_to<Control>()) { if (Object::cast_to<Control>(canvas_item)) {
canvas_item->cast_to<Control>()->set_pivot_offset(se->undo_pivot + drag_vector); Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot + drag_vector);
} }
continue; continue;
break; break;
case DRAG_NODE_2D: case DRAG_NODE_2D:
ERR_FAIL_COND(!canvas_item->cast_to<Node2D>()); ERR_FAIL_COND(!Object::cast_to<Node2D>(canvas_item));
canvas_item->cast_to<Node2D>()->set_global_position(dto); Object::cast_to<Node2D>(canvas_item)->set_global_position(dto);
continue; continue;
break; break;
} }
@ -1754,7 +1749,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
} else { } else {
//ok, all that had to be done was done, now solve IK //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; Transform2D final_xform = bone_orig_xform;
if (n2d) { if (n2d) {
@ -1981,7 +1976,7 @@ void CanvasItemEditor::_viewport_draw() {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) 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 (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()); viewport->draw_texture(pivot, xform.get_origin() + (-pivot->get_size() / 2).floor());
can_move_pivot = true; can_move_pivot = true;
pivot_found = true; pivot_found = true;
} }
} }
Control *control = canvas_item->cast_to<Control>(); Control *control = Object::cast_to<Control>(canvas_item);
if (control) { if (control) {
Vector2 pivot_ofs = control->get_pivot_offset(); Vector2 pivot_ofs = control->get_pivot_offset();
if (pivot_ofs != Vector2()) { if (pivot_ofs != Vector2()) {
@ -2214,11 +2209,7 @@ void CanvasItemEditor::_viewport_draw() {
E->get().from = Vector2(); E->get().from = Vector2();
E->get().to = Vector2(); E->get().to = Vector2();
Object *obj = ObjectDB::get_instance(E->get().bone); Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E->get().bone));
if (!obj)
continue;
Node2D *n2d = obj->cast_to<Node2D>();
if (!n2d) if (!n2d)
continue; continue;
@ -2227,7 +2218,7 @@ void CanvasItemEditor::_viewport_draw() {
CanvasItem *pi = n2d->get_parent_item(); 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) if (!pn2d)
continue; continue;
@ -2283,14 +2274,14 @@ void CanvasItemEditor::_notification(int p_what) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue; continue;
if (canvas_item->cast_to<Control>()) if (Object::cast_to<Control>(canvas_item))
has_control = true; has_control = true;
else else
all_control = false; all_control = false;
@ -2304,12 +2295,12 @@ void CanvasItemEditor::_notification(int p_what) {
float anchors[4]; float anchors[4];
Vector2 pivot; Vector2 pivot;
if (canvas_item->cast_to<Control>()) { if (Object::cast_to<Control>(canvas_item)) {
pivot = canvas_item->cast_to<Control>()->get_pivot_offset(); pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
anchors[MARGIN_LEFT] = canvas_item->cast_to<Control>()->get_anchor(MARGIN_LEFT); anchors[MARGIN_LEFT] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_LEFT);
anchors[MARGIN_RIGHT] = canvas_item->cast_to<Control>()->get_anchor(MARGIN_RIGHT); anchors[MARGIN_RIGHT] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_RIGHT);
anchors[MARGIN_TOP] = canvas_item->cast_to<Control>()->get_anchor(MARGIN_TOP); anchors[MARGIN_TOP] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_TOP);
anchors[MARGIN_BOTTOM] = canvas_item->cast_to<Control>()->get_anchor(MARGIN_BOTTOM); 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]) { 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; break;
} }
Node2D *b2 = b->cast_to<Node2D>(); Node2D *b2 = Object::cast_to<Node2D>(b);
if (!b2) { if (!b2) {
continue; continue;
} }
@ -2426,7 +2417,7 @@ void CanvasItemEditor::_find_canvas_items_span(Node *p_node, Rect2 &r_rect, cons
if (!p_node) if (!p_node)
return; 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--) { 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")); undo_redo->create_action(TTR("Change Anchors"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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_do_method(c, "set_anchors_preset", p_preset);
undo_redo->add_undo_method(c, "set_anchor", MARGIN_LEFT, c->get_anchor(MARGIN_LEFT)); 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")); undo_redo->create_action(TTR("Change Anchors"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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_anchors_preset", PRESET_WIDE);
undo_redo->add_do_method(c, "set_margin", MARGIN_LEFT, 0); 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()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
@ -2731,7 +2722,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
@ -2751,7 +2742,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
@ -2769,7 +2760,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
@ -2888,15 +2879,15 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue; 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);
if (key_pos) if (key_pos)
AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "position", n2d->get_position(), existing); 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 //look for an IK chain
List<Node2D *> 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; bool has_chain = false;
while (n) { while (n) {
@ -2922,7 +2913,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!n->get_parent_item()) if (!n->get_parent_item())
break; break;
n = n->get_parent_item()->cast_to<Node2D>(); n = Object::cast_to<Node2D>(n->get_parent_item());
} }
if (has_chain && ik_chain.size()) { 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) if (key_pos)
AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_position", ctrl->get_position(), existing); 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()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue; 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; PoseClipboard pc;
pc.pos = n2d->get_position(); pc.pos = n2d->get_position();
pc.rot = n2d->get_rotation(); pc.rot = n2d->get_rotation();
@ -3026,10 +3017,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
undo_redo->create_action(TTR("Paste Pose")); undo_redo->create_action(TTR("Paste Pose"));
for (List<PoseClipboard>::Element *E = pose_clipboard.front(); E; E = E->next()) { for (List<PoseClipboard>::Element *E = pose_clipboard.front(); E; E = E->next()) {
Object *o = ObjectDB::get_instance(E->get().id); Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E->get().id));
if (!o)
continue;
Node2D *n2d = o->cast_to<Node2D>();
if (!n2d) if (!n2d)
continue; continue;
undo_redo->add_do_method(n2d, "set_position", E->get().pos); 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()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue; 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);
if (key_pos) if (key_pos)
n2d->set_position(Vector2()); n2d->set_position(Vector2());
@ -3064,9 +3052,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
n2d->set_rotation(0); n2d->set_rotation(0);
if (key_scale) if (key_scale)
n2d->set_scale(Vector2(1, 1)); 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) if (key_pos)
ctrl->set_position(Point2()); 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()) { 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) if (!n2d)
continue; continue;
if (!n2d->is_visible_in_tree()) 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()) { 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) if (!n2d)
continue; continue;
if (!n2d->is_visible_in_tree()) 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()) { 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()) if (!canvas_item || !canvas_item->is_visible_in_tree())
continue; continue;
@ -3151,7 +3139,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { 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) if (!n2d)
continue; continue;
if (!n2d->is_visible_in_tree()) 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(); Map<Node *, Object *> &selection = editor_selection->get_selection();
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { 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) continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue; continue;
@ -3302,7 +3290,7 @@ void CanvasItemEditor::box_selection_start( Point2 &click ) {
bool CanvasItemEditor::box_selection_end() { bool CanvasItemEditor::box_selection_end() {
print_line( "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) { if (scene) {
List<CanvasItem*> selitems; List<CanvasItem*> selitems;
@ -3651,7 +3639,7 @@ CanvasItemEditor *CanvasItemEditor::singleton = NULL;
void CanvasItemEditorPlugin::edit(Object *p_object) { void CanvasItemEditorPlugin::edit(Object *p_object) {
canvas_item_editor->set_undo_redo(&get_undo_redo()); 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 { bool CanvasItemEditorPlugin::handles(Object *p_object) const {
@ -3704,7 +3692,7 @@ void CanvasItemEditorViewport::_on_mouse_exit() {
} }
void CanvasItemEditorViewport::_on_select_type(Object *selected) { 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(); String type = check->get_text();
selector_label->set_text(vformat(TTR("Add %s"), type)); selector_label->set_text(vformat(TTR("Add %s"), type));
label->set_text(vformat(TTR("Adding %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()) if (!button_group->get_pressed_button())
return; 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(); default_type = check->get_text();
_perform_drop_data(); _perform_drop_data();
selector->hide(); selector->hide();
@ -3726,8 +3714,8 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
for (int i = 0; i < files.size(); i++) { for (int i = 0; i < files.size(); i++) {
String path = files[i]; String path = files[i];
RES res = ResourceLoader::load(path); RES res = ResourceLoader::load(path);
Ref<Texture> texture = Ref<Texture>(res->cast_to<Texture>()); Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
Ref<PackedScene> scene = Ref<PackedScene>(res->cast_to<PackedScene>()); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
if (texture != NULL || scene != NULL) { if (texture != NULL || scene != NULL) {
if (texture != NULL) { if (texture != NULL) {
Sprite *sprite = memnew(Sprite); 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) { void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point) {
child->set_name(path.get_file().get_basename()); 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(); Size2 texture_size = texture->get_size();
editor_data->get_undo_redo().add_do_method(parent, "add_child", child); 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)); 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; Point2 pos;
Node2D *parent_node2d = parent->cast_to<Node2D>(); Node2D *parent_node2d = Object::cast_to<Node2D>(parent);
if (parent_node2d) { if (parent_node2d) {
pos = parent_node2d->get_global_position(); pos = parent_node2d->get_global_position();
} else { } else {
Control *parent_control = parent->cast_to<Control>(); Control *parent_control = Object::cast_to<Control>(parent);
if (parent_control) { if (parent_control) {
pos = parent_control->get_global_position(); 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(); Transform2D trans = canvas->get_canvas_transform();
Vector2 target_pos = (p_point - trans.get_origin()) / trans.get_scale().x - pos; 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 // 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); target_pos = canvas->snap_point(target_pos, start_pos);
editor_data->get_undo_redo().add_do_method(instanced_scene, "set_position", target_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()) { if (res.is_null()) {
continue; continue;
} }
Ref<Texture> texture = Ref<Texture>(res->cast_to<Texture>()); Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
Ref<PackedScene> scene = Ref<PackedScene>(res->cast_to<PackedScene>()); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
if (texture != NULL) { if (texture != NULL) {
Node *child; Node *child;
if (default_type == "Light2D") 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); button_group->get_buttons(&btn_list);
for (int i = 0; i < btn_list.size(); i++) { 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); check->set_pressed(check->get_text() == default_type);
} }
selector_label->set_text(vformat(TTR("Add %s"), default_type)); selector_label->set_text(vformat(TTR("Add %s"), default_type));

View file

@ -343,7 +343,7 @@ void CollisionPolygon2DEditor::edit(Node *p_collision_polygon) {
if (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")) if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw"); canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
wip.clear(); wip.clear();
@ -403,7 +403,7 @@ CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) {
void CollisionPolygon2DEditorPlugin::edit(Object *p_object) { 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 { bool CollisionPolygon2DEditorPlugin::handles(Object *p_object) const {

View file

@ -464,7 +464,7 @@ void CollisionPolygonEditor::edit(Node *p_collision_polygon) {
if (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.clear();
wip_active = false; wip_active = false;
edited_point = -1; edited_point = -1;
@ -555,7 +555,7 @@ CollisionPolygonEditor::~CollisionPolygonEditor() {
void CollisionPolygonEditorPlugin::edit(Object *p_object) { 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 { bool CollisionPolygonEditorPlugin::handles(Object *p_object) const {

View file

@ -393,21 +393,21 @@ void CollisionShape2DEditor::_get_current_shape_type() {
return; return;
} }
if (s->cast_to<CapsuleShape2D>()) { if (Object::cast_to<CapsuleShape2D>(*s)) {
shape_type = CAPSULE_SHAPE; shape_type = CAPSULE_SHAPE;
} else if (s->cast_to<CircleShape2D>()) { } else if (Object::cast_to<CircleShape2D>(*s)) {
shape_type = CIRCLE_SHAPE; shape_type = CIRCLE_SHAPE;
} else if (s->cast_to<ConcavePolygonShape2D>()) { } else if (Object::cast_to<ConcavePolygonShape2D>(*s)) {
shape_type = CONCAVE_POLYGON_SHAPE; shape_type = CONCAVE_POLYGON_SHAPE;
} else if (s->cast_to<ConvexPolygonShape2D>()) { } else if (Object::cast_to<ConvexPolygonShape2D>(*s)) {
shape_type = CONVEX_POLYGON_SHAPE; shape_type = CONVEX_POLYGON_SHAPE;
} else if (s->cast_to<LineShape2D>()) { } else if (Object::cast_to<LineShape2D>(*s)) {
shape_type = LINE_SHAPE; shape_type = LINE_SHAPE;
} else if (s->cast_to<RayShape2D>()) { } else if (Object::cast_to<RayShape2D>(*s)) {
shape_type = RAY_SHAPE; shape_type = RAY_SHAPE;
} else if (s->cast_to<RectangleShape2D>()) { } else if (Object::cast_to<RectangleShape2D>(*s)) {
shape_type = RECTANGLE_SHAPE; shape_type = RECTANGLE_SHAPE;
} else if (s->cast_to<SegmentShape2D>()) { } else if (Object::cast_to<SegmentShape2D>(*s)) {
shape_type = SEGMENT_SHAPE; shape_type = SEGMENT_SHAPE;
} else { } else {
shape_type = -1; shape_type = -1;
@ -530,7 +530,7 @@ void CollisionShape2DEditor::edit(Node *p_node) {
} }
if (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")) if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("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) { 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 { bool CollisionShape2DEditorPlugin::handles(Object *p_obj) const {

View file

@ -72,10 +72,10 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
Node *child = p_scene->get_child(i); Node *child = p_scene->get_child(i);
if (!child->cast_to<MeshInstance>()) { if (!Object::cast_to<MeshInstance>(child)) {
if (child->get_child_count() > 0) { if (child->get_child_count() > 0) {
child = child->get_child(0); child = child->get_child(0);
if (!child->cast_to<MeshInstance>()) { if (!Object::cast_to<MeshInstance>(child)) {
continue; continue;
} }
@ -83,7 +83,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
continue; continue;
} }
MeshInstance *mi = child->cast_to<MeshInstance>(); MeshInstance *mi = Object::cast_to<MeshInstance>(child);
Ref<Mesh> mesh = mi->get_mesh(); Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_null()) if (mesh.is_null())
continue; 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++) { for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j); Node *child2 = mi->get_child(j);
if (!child2->cast_to<StaticBody>()) if (!Object::cast_to<StaticBody>(child2))
continue; continue;
StaticBody *sb = child2->cast_to<StaticBody>(); StaticBody *sb = Object::cast_to<StaticBody>(child2);
List<uint32_t> shapes; List<uint32_t> shapes;
sb->get_shape_owners(&shapes); sb->get_shape_owners(&shapes);
@ -140,9 +140,9 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
Ref<NavigationMesh> navmesh; Ref<NavigationMesh> navmesh;
for (int j = 0; j < mi->get_child_count(); j++) { for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j); Node *child2 = mi->get_child(j);
if (!child2->cast_to<NavigationMeshInstance>()) if (!Object::cast_to<NavigationMeshInstance>(child2))
continue; continue;
NavigationMeshInstance *sb = child2->cast_to<NavigationMeshInstance>(); NavigationMeshInstance *sb = Object::cast_to<NavigationMeshInstance>(child2);
navmesh = sb->get_navigation_mesh(); navmesh = sb->get_navigation_mesh();
if (!navmesh.is_null()) if (!navmesh.is_null())
break; break;
@ -341,8 +341,8 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
void MeshLibraryEditorPlugin::edit(Object *p_node) { void MeshLibraryEditorPlugin::edit(Object *p_node) {
if (p_node && p_node->cast_to<MeshLibrary>()) { if (Object::cast_to<MeshLibrary>(p_node)) {
theme_editor->edit(p_node->cast_to<MeshLibrary>()); theme_editor->edit(Object::cast_to<MeshLibrary>(p_node));
theme_editor->show(); theme_editor->show();
} else } else
theme_editor->hide(); theme_editor->hide();

View file

@ -786,24 +786,24 @@ void CurveEditorPlugin::edit(Object *p_object) {
Ref<Curve> curve_ref; Ref<Curve> curve_ref;
if (_current_ref.is_valid()) { if (_current_ref.is_valid()) {
CurveTexture *ct = _current_ref->cast_to<CurveTexture>(); CurveTexture *ct = Object::cast_to<CurveTexture>(*_current_ref);
if (ct) if (ct)
ct->disconnect(CoreStringNames::get_singleton()->changed, this, "_curve_texture_changed"); ct->disconnect(CoreStringNames::get_singleton()->changed, this, "_curve_texture_changed");
} }
if (p_object) { 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(res == NULL);
ERR_FAIL_COND(!handles(p_object)); 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()) { if (_current_ref.is_valid()) {
Curve *curve = _current_ref->cast_to<Curve>(); Curve *curve = Object::cast_to<Curve>(*_current_ref);
if (curve) if (curve)
curve_ref = Ref<Curve>(curve); curve_ref = Ref<Curve>(curve);
else { else {
CurveTexture *ct = _current_ref->cast_to<CurveTexture>(); CurveTexture *ct = Object::cast_to<CurveTexture>(*_current_ref);
if (ct) { if (ct) {
ct->connect(CoreStringNames::get_singleton()->changed, this, "_curve_texture_changed"); ct->connect(CoreStringNames::get_singleton()->changed, this, "_curve_texture_changed");
curve_ref = ct->get_curve(); curve_ref = ct->get_curve();
@ -820,7 +820,7 @@ void CurveEditorPlugin::edit(Object *p_object) {
bool CurveEditorPlugin::handles(Object *p_object) const { bool CurveEditorPlugin::handles(Object *p_object) const {
// Both handled so that we can keep the curve editor open // 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) { void CurveEditorPlugin::make_visible(bool p_visible) {
@ -837,7 +837,7 @@ void CurveEditorPlugin::make_visible(bool p_visible) {
void CurveEditorPlugin::_curve_texture_changed() { void CurveEditorPlugin::_curve_texture_changed() {
// If the curve is shown indirectly as a CurveTexture is edited, // If the curve is shown indirectly as a CurveTexture is edited,
// we need to monitor when the curve property gets assigned // 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) { if (ct) {
_view->set_curve(ct->get_curve()); _view->set_curve(ct->get_curve());
} }

View file

@ -38,7 +38,7 @@ void GIProbeEditorPlugin::_bake() {
void GIProbeEditorPlugin::edit(Object *p_object) { void GIProbeEditorPlugin::edit(Object *p_object) {
GIProbe *s = p_object->cast_to<GIProbe>(); GIProbe *s = Object::cast_to<GIProbe>(p_object);
if (!s) if (!s)
return; return;

View file

@ -46,7 +46,7 @@ GradientEditorPlugin::GradientEditorPlugin(EditorNode *p_node) {
void GradientEditorPlugin::edit(Object *p_object) { void GradientEditorPlugin::edit(Object *p_object) {
Gradient *gradient = p_object->cast_to<Gradient>(); Gradient *gradient = Object::cast_to<Gradient>(p_object);
if (!gradient) if (!gradient)
return; return;
gradient_ref = Ref<Gradient>(gradient); gradient_ref = Ref<Gradient>(gradient);

View file

@ -115,7 +115,7 @@ void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const {
void ItemListOptionButtonPlugin::set_object(Object *p_object) { 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 { bool ItemListOptionButtonPlugin::handles(Object *p_object) const {
@ -155,9 +155,9 @@ ItemListOptionButtonPlugin::ItemListOptionButtonPlugin() {
void ItemListPopupMenuPlugin::set_object(Object *p_object) { void ItemListPopupMenuPlugin::set_object(Object *p_object) {
if (p_object->is_class("MenuButton")) if (p_object->is_class("MenuButton"))
pp = p_object->cast_to<MenuButton>()->get_popup(); pp = Object::cast_to<MenuButton>(p_object)->get_popup();
else else
pp = p_object->cast_to<PopupMenu>(); pp = Object::cast_to<PopupMenu>(p_object);
} }
bool ItemListPopupMenuPlugin::handles(Object *p_object) const { bool ItemListPopupMenuPlugin::handles(Object *p_object) const {
@ -196,7 +196,7 @@ ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() {
void ItemListItemListPlugin::set_object(Object *p_object) { 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 { bool ItemListItemListPlugin::handles(Object *p_object) const {
@ -384,7 +384,7 @@ ItemListEditor::~ItemListEditor() {
void ItemListEditorPlugin::edit(Object *p_object) { 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 { bool ItemListEditorPlugin::handles(Object *p_object) const {

View file

@ -367,7 +367,7 @@ void LightOccluder2DEditor::edit(Node *p_collision_polygon) {
if (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")) if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw"); canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
wip.clear(); wip.clear();
@ -441,7 +441,7 @@ LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) {
void LightOccluder2DEditorPlugin::edit(Object *p_object) { 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 { bool LightOccluder2DEditorPlugin::handles(Object *p_object) const {

View file

@ -189,7 +189,7 @@ void Line2DEditor::edit(Node *p_line2d) {
canvas_item_editor = CanvasItemEditor::get_singleton(); canvas_item_editor = CanvasItemEditor::get_singleton();
if (p_line2d) { 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")) if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("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")) 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) { 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 { bool Line2DEditorPlugin::handles(Object *p_object) const {

View file

@ -372,7 +372,7 @@ MaterialEditor::MaterialEditor() {
void MaterialEditorPlugin::edit(Object *p_object) { void MaterialEditorPlugin::edit(Object *p_object) {
Material * s = p_object->cast_to<Material>(); Material * s = Object::cast_to<Material>(p_object);
if (!s) if (!s)
return; return;

View file

@ -187,7 +187,7 @@ MeshEditor::MeshEditor() {
void MeshEditorPlugin::edit(Object *p_object) { void MeshEditorPlugin::edit(Object *p_object) {
Mesh *s = p_object->cast_to<Mesh>(); Mesh *s = Object::cast_to<Mesh>(p_object);
if (!s) if (!s)
return; return;

View file

@ -101,7 +101,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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) if (!instance)
continue; continue;
@ -290,7 +290,7 @@ MeshInstanceEditor::MeshInstanceEditor() {
void MeshInstanceEditorPlugin::edit(Object *p_object) { 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 { bool MeshInstanceEditorPlugin::handles(Object *p_object) const {

View file

@ -77,7 +77,7 @@ void MultiMeshEditor::_populate() {
return; return;
} }
MeshInstance *ms_instance = ms_node->cast_to<MeshInstance>(); MeshInstance *ms_instance = Object::cast_to<MeshInstance>(ms_node);
if (!ms_instance) { if (!ms_instance) {
@ -112,7 +112,7 @@ void MultiMeshEditor::_populate() {
return; return;
} }
GeometryInstance *ss_instance = ss_node->cast_to<MeshInstance>(); GeometryInstance *ss_instance = Object::cast_to<MeshInstance>(ss_node);
if (!ss_instance) { if (!ss_instance) {
@ -155,7 +155,7 @@ void MultiMeshEditor::_populate() {
ERR_EXPLAIN("Multimesh not present."); ERR_EXPLAIN("Multimesh not present.");
ERR_FAIL_COND(multimesh.is_null()); 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_EXPLAIN("Parent is not of type VisualInstance, can't be populated.");
ERR_FAIL_COND(!vi); ERR_FAIL_COND(!vi);
@ -402,7 +402,7 @@ MultiMeshEditor::MultiMeshEditor() {
void MultiMeshEditorPlugin::edit(Object *p_object) { 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 { bool MultiMeshEditorPlugin::handles(Object *p_object) const {

View file

@ -422,7 +422,7 @@ void NavigationPolygonEditor::edit(Node *p_collision_polygon) {
if (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")) if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw"); canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
wip.clear(); wip.clear();
@ -486,7 +486,7 @@ NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) {
void NavigationPolygonEditorPlugin::edit(Object *p_object) { 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 { bool NavigationPolygonEditorPlugin::handles(Object *p_object) const {

View file

@ -33,13 +33,10 @@
#include "io/image_loader.h" #include "io/image_loader.h"
#include "scene/3d/particles.h" #include "scene/3d/particles.h"
#include "scene/gui/separator.h" #include "scene/gui/separator.h"
void Particles2DEditorPlugin::edit(Object *p_object) { void Particles2DEditorPlugin::edit(Object *p_object) {
if (p_object) { particles = Object::cast_to<Particles2D>(p_object);
particles = p_object->cast_to<Particles2D>();
} else {
particles = NULL;
}
} }
bool Particles2DEditorPlugin::handles(Object *p_object) const { bool Particles2DEditorPlugin::handles(Object *p_object) const {

View file

@ -51,7 +51,7 @@ void ParticlesEditor::_node_selected(const NodePath &p_path) {
if (!sel) if (!sel)
return; return;
VisualInstance *vi = sel->cast_to<VisualInstance>(); VisualInstance *vi = Object::cast_to<VisualInstance>(sel);
if (!vi) { if (!vi) {
err_dialog->set_text(TTR("Node does not contain geometry.")); 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(); Node *root = get_scene()->get_root_node();
ERR_FAIL_COND(!root); ERR_FAIL_COND(!root);
EditorNode *en = root->cast_to<EditorNode>(); EditorNode *en = Object::cast_to<EditorNode>(root);
ERR_FAIL_COND(!en); ERR_FAIL_COND(!en);
Node * node = en->get_edited_scene(); Node * node = en->get_edited_scene();
*/ */
@ -461,7 +461,7 @@ ParticlesEditor::ParticlesEditor() {
void ParticlesEditorPlugin::edit(Object *p_object) { 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 { bool ParticlesEditorPlugin::handles(Object *p_object) const {

View file

@ -534,7 +534,7 @@ void Path2DEditor::edit(Node *p_path2d) {
if (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")) if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("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")) 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) { 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 { bool Path2DEditorPlugin::handles(Object *p_object) const {

View file

@ -269,9 +269,9 @@ PathSpatialGizmo::PathSpatialGizmo(Path *p_path) {
Ref<SpatialEditorGizmo> PathEditorPlugin::create_spatial_gizmo(Spatial *p_spatial) { 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>(); 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) { void PathEditorPlugin::edit(Object *p_object) {
if (p_object) { if (p_object) {
path = p_object->cast_to<Path>(); path = Object::cast_to<Path>(p_object);
if (path) { if (path) {
if (path->get_curve().is_valid()) { if (path->get_curve().is_valid()) {
@ -447,7 +447,7 @@ void PathEditorPlugin::edit(Object *p_object) {
pre->get_curve()->emit_signal("changed"); 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 { bool PathEditorPlugin::handles(Object *p_object) const {

View file

@ -697,7 +697,7 @@ void Polygon2DEditor::edit(Node *p_collision_polygon) {
if (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")) if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("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) { 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 { bool Polygon2DEditorPlugin::handles(Object *p_object) const {

View file

@ -410,7 +410,7 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() {
void ResourcePreloaderEditorPlugin::edit(Object *p_object) { void ResourcePreloaderEditorPlugin::edit(Object *p_object) {
preloader_editor->set_undo_redo(&get_undo_redo()); 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) if (!s)
return; return;

View file

@ -91,7 +91,7 @@ void RichTextEditor::_bind_methods() {
void RichTextEditor::edit(Node *p_rich_text) { void RichTextEditor::edit(Node *p_rich_text) {
node = p_rich_text->cast_to<RichTextLabel>(); node = Object::cast_to<RichTextLabel>(p_rich_text);
} }
RichTextEditor::RichTextEditor() { RichTextEditor::RichTextEditor() {
@ -114,7 +114,7 @@ RichTextEditor::RichTextEditor() {
void RichTextEditorPlugin::edit(Object *p_object) { 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 { bool RichTextEditorPlugin::handles(Object *p_object) const {

View file

@ -408,7 +408,7 @@ SampleEditor::SampleEditor() {
void SampleEditorPlugin::edit(Object *p_object) { void SampleEditorPlugin::edit(Object *p_object) {
Sample * s = p_object->cast_to<Sample>(); Sample * s = Object::cast_to<Sample>(p_object);
if (!s) if (!s)
return; return;

View file

@ -47,7 +47,7 @@ void SampleLibraryEditor::_notification(int p_what) {
if (p_what==NOTIFICATION_PROCESS) { if (p_what==NOTIFICATION_PROCESS) {
if (is_playing && !player->is_active()) { 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")); tl->set_button(0,0,get_icon("Play","EditorIcons"));
is_playing = false; is_playing = false;
set_process(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) { 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); String name = ti->get_text(0);
if (p_column==0) { // Play/Stop if (p_column==0) { // Play/Stop
@ -124,7 +124,7 @@ void SampleLibraryEditor::_button_pressed(Object *p_item,int p_column, int p_id)
} else { } else {
player->stop_all(); player->stop_all();
if(last_sample_playing != p_item){ 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")); tl->set_button(p_column,0,get_icon("Play","EditorIcons"));
btn_type = TTR("Stop"); btn_type = TTR("Stop");
player->play(name,true); player->play(name,true);
@ -491,7 +491,7 @@ SampleLibraryEditor::SampleLibraryEditor() {
void SampleLibraryEditorPlugin::edit(Object *p_object) { void SampleLibraryEditorPlugin::edit(Object *p_object) {
sample_library_editor->set_undo_redo(&get_undo_redo()); 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) if (!s)
return; return;

View file

@ -152,7 +152,7 @@ SamplePlayerEditor::SamplePlayerEditor() {
void SamplePlayerEditorPlugin::edit(Object *p_object) { 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 { bool SamplePlayerEditorPlugin::handles(Object *p_object) const {

View file

@ -256,7 +256,7 @@ ScriptEditor *ScriptEditor::script_editor = NULL;
String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) { 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); String val = debugger->get_var_value(p_text);
if (val != String()) { 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++) { 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) { if (!se) {
continue; continue;
@ -305,7 +305,7 @@ void ScriptEditor::_goto_script_line2(int p_line) {
if (selected < 0 || selected >= tab_container->get_child_count()) if (selected < 0 || selected >= tab_container->get_child_count())
return; return;
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>(); ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (!current) if (!current)
return; 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"))) { 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()) if (!script.is_null() && script->get_path().is_resource_file())
edit(p_script, p_line, 0); 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()) if (selected < 0 || selected >= tab_container->get_child_count())
return; return;
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>(); ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (!current) if (!current)
return; return;
@ -346,13 +346,13 @@ void ScriptEditor::_save_history() {
Node *n = tab_container->get_current_tab_control(); 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) { void ScriptEditor::_go_to_tab(int p_idx) {
Node *cn = tab_container->get_child(p_idx); Control *c = Object::cast_to<Control>(tab_container->get_child(p_idx));
if (!cn)
return;
Control *c = cn->cast_to<Control>();
if (!c) if (!c)
return; return;
@ -380,13 +377,13 @@ void ScriptEditor::_go_to_tab(int p_idx) {
Node *n = tab_container->get_current_tab_control(); 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(); 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_name_label->set_text(Object::cast_to<ScriptEditorBase>(c)->get_name());
script_icon->set_texture(c->cast_to<ScriptEditorBase>()->get_icon()); script_icon->set_texture(Object::cast_to<ScriptEditorBase>(c)->get_icon());
if (is_visible_in_tree()) 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")); script_icon->set_texture(get_icon("Help", "EditorIcons"));
if (is_visible_in_tree()) 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); c->set_meta("__editor_pass", ++edit_pass);
@ -508,7 +505,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) {
return; return;
Node *tselected = tab_container->get_child(selected); 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) { if (current) {
_add_recent_script(current->get_edited_script()->get_path()); _add_recent_script(current->get_edited_script()->get_path());
if (p_save) { if (p_save) {
@ -517,7 +514,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) {
current->clear_edit_menu(); current->clear_edit_menu();
notify_script_close(current->get_edited_script()); notify_script_close(current->get_edited_script());
} else { } 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()); _add_recent_script(help->get_class());
} }
@ -575,7 +572,7 @@ void ScriptEditor::_close_docs_tab() {
int child_count = tab_container->get_child_count(); int child_count = tab_container->get_child_count();
for (int i = child_count - 1; i >= 0; i--) { 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) { if (se) {
_close_tab(i); _close_tab(i);
@ -589,7 +586,7 @@ void ScriptEditor::_close_all_tabs() {
for (int i = child_count - 1; i >= 0; i--) { for (int i = child_count - 1; i >= 0; i--) {
tab_container->set_current_tab(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) { 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++) { 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) if (!se)
continue; continue;
@ -647,7 +644,7 @@ void ScriptEditor::_reload_scripts() {
for (int i = 0; i < tab_container->get_child_count(); i++) { 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) { if (!se) {
continue; 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++) { 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) { if (!se) {
continue; 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++) { 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) { if (se) {
Ref<Script> script = se->get_edited_script(); 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()) if (selected < 0 || selected >= tab_container->get_child_count())
return NULL; 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) { if (current) {
return current->get_edited_script(); return current->get_edited_script();
} else { } else {
@ -865,7 +862,7 @@ void ScriptEditor::_menu_option(int p_option) {
String current; String current;
if (tab_container->get_tab_count() > 0) { 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) { if (eh) {
current = eh->get_class(); current = eh->get_class();
} }
@ -919,7 +916,7 @@ void ScriptEditor::_menu_option(int p_option) {
if (selected < 0 || selected >= tab_container->get_child_count()) if (selected < 0 || selected >= tab_container->get_child_count())
return; return;
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>(); ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (current) { if (current) {
switch (p_option) { switch (p_option) {
@ -956,7 +953,7 @@ void ScriptEditor::_menu_option(int p_option) {
current->convert_indent_to_tabs(); 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()); editor->save_resource_as(current->get_edited_script());
} break; } break;
@ -1035,7 +1032,7 @@ void ScriptEditor::_menu_option(int p_option) {
} }
} else { } 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) { if (help) {
switch (p_option) { switch (p_option) {
@ -1139,7 +1136,7 @@ bool ScriptEditor::can_take_away_focus() const {
if (selected < 0 || selected >= tab_container->get_child_count()) if (selected < 0 || selected >= tab_container->get_child_count())
return true; 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) if (!current)
return true; 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++) { 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) { if (se) {
@ -1205,7 +1202,7 @@ Dictionary ScriptEditor::get_state() const {
for(int i=0;i<tab_container->get_child_count();i++) { 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) if (!se)
continue; continue;
@ -1281,7 +1278,7 @@ void ScriptEditor::clear() {
List<ScriptTextEditor*> stes; List<ScriptTextEditor*> stes;
for(int i=0;i<tab_container->get_child_count();i++) { 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) if (!se)
continue; continue;
stes.push_back(se); 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++) { 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) if (!se)
continue; continue;
@ -1335,10 +1332,8 @@ void ScriptEditor::ensure_focus_current() {
if (cidx < 0 || cidx >= tab_container->get_tab_count()) if (cidx < 0 || cidx >= tab_container->get_tab_count())
return; return;
Control *c = tab_container->get_child(cidx)->cast_to<Control>(); Control *c = Object::cast_to<Control>(tab_container->get_child(cidx));
if (!c) ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(c);
return;
ScriptEditorBase *se = c->cast_to<ScriptEditorBase>();
if (!se) if (!se)
return; return;
se->ensure_focus(); se->ensure_focus();
@ -1346,7 +1341,7 @@ void ScriptEditor::ensure_focus_current() {
void ScriptEditor::_members_overview_selected(int p_idx) { void ScriptEditor::_members_overview_selected(int p_idx) {
Node *current = tab_container->get_child(tab_container->get_current_tab()); 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) { if (!se) {
return; return;
} }
@ -1368,7 +1363,7 @@ void ScriptEditor::ensure_select_current() {
Node *current = tab_container->get_child(tab_container->get_current_tab()); 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) { if (se) {
Ref<Script> script = se->get_edited_script(); Ref<Script> script = se->get_edited_script();
@ -1380,7 +1375,7 @@ void ScriptEditor::ensure_select_current() {
//search_menu->show(); //search_menu->show();
} }
EditorHelp *eh = current->cast_to<EditorHelp>(); EditorHelp *eh = Object::cast_to<EditorHelp>(current);
if (eh) { if (eh) {
//edit_menu->hide(); //edit_menu->hide();
@ -1430,7 +1425,7 @@ void ScriptEditor::_update_members_overview_visibility() {
return; return;
Node *current = tab_container->get_child(tab_container->get_current_tab()); 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) { if (!se) {
members_overview->set_visible(false); members_overview->set_visible(false);
return; return;
@ -1451,7 +1446,7 @@ void ScriptEditor::_update_members_overview() {
return; return;
Node *current = tab_container->get_child(tab_container->get_current_tab()); 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) { if (!se) {
return; return;
} }
@ -1525,7 +1520,7 @@ void ScriptEditor::_update_script_names() {
for (int i = 0; i < tab_container->get_child_count(); i++) { 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) { if (se) {
String name = se->get_name(); String name = se->get_name();
@ -1568,7 +1563,7 @@ void ScriptEditor::_update_script_names() {
sedata.push_back(sd); 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) { if (eh) {
String name = eh->get_class(); 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++) { 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) if (!se)
continue; continue;
@ -1733,7 +1728,7 @@ void ScriptEditor::save_all_scripts() {
for (int i = 0; i < tab_container->get_child_count(); i++) { 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) if (!se)
continue; continue;
@ -1771,7 +1766,7 @@ void ScriptEditor::apply_scripts() const {
for (int i = 0; i < tab_container->get_child_count(); i++) { 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) if (!se)
continue; continue;
se->apply_code(); se->apply_code();
@ -1802,7 +1797,7 @@ void ScriptEditor::_editor_stop() {
for (int i = 0; i < tab_container->get_child_count(); i++) { 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) { if (!se) {
continue; 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++) { 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) if (!se)
continue; continue;
if (se->get_edited_script() != script) 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++) { 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) if (!se)
continue; 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++) { 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) { if (se) {
String path = se->get_edited_script()->get_path(); 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); 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) { 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++) { 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) { 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++) { 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) { if (eh && eh->get_class() == cname) {
@ -2062,7 +2057,7 @@ void ScriptEditor::_update_selected_editor_menu() {
bool current = tab_container->get_current_tab() == i; 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 (se && se->get_edit_menu()) {
if (current) if (current)
@ -2072,10 +2067,7 @@ void ScriptEditor::_update_selected_editor_menu() {
} }
} }
EditorHelp *eh = NULL; EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_current_tab_control());
if (tab_container->get_current_tab_control())
eh = tab_container->get_current_tab_control()->cast_to<EditorHelp>();
if (eh) { if (eh) {
script_search_menu->show(); script_search_menu->show();
} else { } else {
@ -2087,13 +2079,13 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
Node *n = tab_container->get_current_tab_control(); 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; history_pos = p_new_pos;
@ -2101,18 +2093,18 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
n = history[history_pos].control; 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); Object::cast_to<ScriptEditorBase>(n)->set_edit_state(history[history_pos].state);
n->cast_to<ScriptEditorBase>()->ensure_focus(); 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); Object::cast_to<EditorHelp>(n)->set_scroll(history[history_pos].state);
n->cast_to<EditorHelp>()->set_focused(); Object::cast_to<EditorHelp>(n)->set_focused();
} }
n->set_meta("__editor_pass", ++edit_pass); 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> >(); Vector<Ref<Script> > out_scripts = Vector<Ref<Script> >();
for (int i = 0; i < tab_container->get_child_count(); i++) { 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) if (!se)
continue; continue;
out_scripts.push_back(se->get_edited_script()); out_scripts.push_back(se->get_edited_script());
@ -2510,17 +2502,17 @@ ScriptEditor::~ScriptEditor() {
void ScriptEditorPlugin::edit(Object *p_object) { void ScriptEditorPlugin::edit(Object *p_object) {
if (!p_object->cast_to<Script>()) if (!Object::cast_to<Script>(p_object))
return; 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 { 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 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")); EditorNode::get_singleton()->show_warning(TTR("Built-in scripts can only be edited when the scene they belong to is loaded"));

View file

@ -288,7 +288,7 @@ Dictionary ShaderEditor::get_state() const {
for(int i=0;i<tab_container->get_child_count();i++) { 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) if (!ste)
continue; continue;
@ -397,7 +397,7 @@ void ShaderEditor::ensure_select_current() {
/* /*
if (tab_container->get_child_count() && tab_container->get_current_tab()>=0) { 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) if (!ste)
return; return;
Ref<Shader> shader = ste->get_edited_shader(); Ref<Shader> shader = ste->get_edited_shader();
@ -486,16 +486,16 @@ ShaderEditor::ShaderEditor() {
void ShaderEditorPlugin::edit(Object *p_object) { 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); shader_editor->edit(s);
} }
bool ShaderEditorPlugin::handles(Object *p_object) const { bool ShaderEditorPlugin::handles(Object *p_object) const {
bool handles = true; 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; handles = false;
*/ */

View file

@ -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){ 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_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size()); ped_popup->set_size(tb->get_size());
edited_id=p_id; 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){ 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_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size()); ped_popup->set_size(tb->get_size());
edited_id=p_id; edited_id=p_id;
@ -964,7 +964,7 @@ void ShaderGraphView::_variant_edited() {
void ShaderGraphView::_comment_edited(int p_id,Node* p_button) { void ShaderGraphView::_comment_edited(int p_id,Node* p_button) {
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); 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->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_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)); 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) { 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(); 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) { 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(); 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) { 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); ERR_FAIL_COND(!le);
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo(); 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) { 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_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size()); ped_popup->set_size(tb->get_size());
edited_id=p_id; 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) { 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_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size()); ped_popup->set_size(tb->get_size());
edited_id=p_id; 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) 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_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size()); ped_popup->set_size(tb->get_size());
edited_id=p_id; 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) 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) if (!frame)
return Variant(); 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) { if (val.get_type()==Variant::OBJECT) {
RES res = val; RES res = val;
if (res.is_valid() && res->cast_to<Texture>()) if (res.is_valid() && Object::cast_to<Texture>(res))
return true; 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)) if (!can_drop_data_fw(p_point, p_data, p_from))
return; return;
TextureRect *frame = p_from->cast_to<TextureRect>(); TextureRect *frame = Object::cast_to<TextureRect>(p_from);
if (!frame) if (!frame)
return; return;
@ -2590,20 +2590,20 @@ void ShaderGraphView::drop_data_fw(const Point2 &p_point, const Variant &p_data,
if (val.get_type()==Variant::OBJECT) { if (val.get_type()==Variant::OBJECT) {
RES res = val; RES res = val;
if (res.is_valid()) 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")) { else if (d["type"] == "files" && d.has("files")) {
Vector<String> files = d["files"]; Vector<String> files = d["files"];
RES res = ResourceLoader::load(files[0]); RES res = ResourceLoader::load(files[0]);
if (res.is_valid()) if (res.is_valid())
tex = Ref<Texture>(res->cast_to<Texture>()); tex = Ref<Texture>(Object::cast_to<Texture>(*res));
} }
} }
if (!tex.is_valid()) return; 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; if (!gn) return;
int id = -1; int id = -1;
@ -2896,12 +2896,12 @@ ShaderGraphEditor::ShaderGraphEditor(bool p_2d) {
void ShaderGraphEditorPlugin::edit(Object *p_object) { 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 { bool ShaderGraphEditorPlugin::handles(Object *p_object) const {
ShaderGraph *shader=p_object->cast_to<ShaderGraph>(); ShaderGraph *shader=Object::cast_to<ShaderGraph>(p_object);
if (!shader) if (!shader)
return false; return false;
if (_2d) if (_2d)

View file

@ -143,7 +143,7 @@ int SpatialEditorViewport::get_selected_count() const {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { 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) if (!sp)
continue; continue;
@ -218,11 +218,7 @@ void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single) {
if (!clicked) if (!clicked)
return; return;
Object *obj = ObjectDB::get_instance(clicked); Spatial *sp = Object::cast_to<Spatial>(ObjectDB::get_instance(clicked));
if (!obj)
return;
Spatial *sp = obj->cast_to<Spatial>();
if (!sp) if (!sp)
return; return;
@ -271,11 +267,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
for (int i = 0; i < instances.size(); i++) { for (int i = 0; i < instances.size(); i++) {
Object *obj = ObjectDB::get_instance(instances[i]); Spatial *spat = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i]));
if (!obj)
continue;
Spatial *spat = obj->cast_to<Spatial>();
if (!spat) if (!spat)
continue; 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())) while ((subscene_candidate->get_owner() != NULL) && (subscene_candidate->get_owner() != editor->get_edited_scene()))
subscene_candidate = subscene_candidate->get_owner(); 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)) { if (spat && (spat->get_filename() != "") && (subscene_candidate->get_owner() != NULL)) {
subscenes.push_back(spat); subscenes.push_back(spat);
subscenes_positions.push_back(source_click_spatial_pos); 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++) { for (int i = 0; i < instances.size(); i++) {
Object *obj = ObjectDB::get_instance(instances[i]); Spatial *spat = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i]));
if (!obj)
continue;
Spatial *spat = obj->cast_to<Spatial>();
if (!spat) if (!spat)
continue; continue;
@ -480,10 +467,7 @@ void SpatialEditorViewport::_select_region() {
for (int i = 0; i < instances.size(); i++) { for (int i = 0; i < instances.size(); i++) {
Object *obj = ObjectDB::get_instance(instances[i]); Spatial *sp = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i]));
if (!obj)
continue;
Spatial *sp = obj->cast_to<Spatial>();
if (!sp) if (!sp)
continue; continue;
@ -524,7 +508,7 @@ void SpatialEditorViewport::_compute_edit(const Point2 &p_point) {
//int nc=0; //int nc=0;
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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) if (!sp)
continue; continue;
@ -796,7 +780,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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) if (!sp)
continue; continue;
@ -967,22 +951,18 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (clicked && gizmo_handle >= 0) { if (clicked && gizmo_handle >= 0) {
Object *obj = ObjectDB::get_instance(clicked); Spatial *spa = Object::cast_to<Spatial>(ObjectDB::get_instance(clicked));
if (obj) { if (spa) {
Spatial *spa = obj->cast_to<Spatial>(); Ref<SpatialEditorGizmo> seg = spa->get_gizmo();
if (spa) { if (seg.is_valid()) {
Ref<SpatialEditorGizmo> seg = spa->get_gizmo(); _edit.gizmo = seg;
if (seg.is_valid()) { _edit.gizmo_handle = gizmo_handle;
//_edit.gizmo_initial_pos=seg->get_handle_pos(gizmo_handle);
_edit.gizmo = seg; _edit.gizmo_initial_value = seg->get_handle_value(gizmo_handle);
_edit.gizmo_handle = gizmo_handle; //print_line("GIZMO: "+itos(gizmo_handle)+" FROMPOS: "+_edit.orig_gizmo_pos);
//_edit.gizmo_initial_pos=seg->get_handle_pos(gizmo_handle); break;
_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.. //_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()) { 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) if (!sp)
continue; continue;
@ -1162,7 +1142,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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) if (!sp)
continue; continue;
@ -1236,7 +1216,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Spatial *node = NULL; Spatial *node = NULL;
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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) { if (!sp) {
continue; continue;
} }
@ -1264,7 +1244,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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) { if (!sp) {
continue; continue;
} }
@ -1334,7 +1314,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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) if (!sp)
continue; continue;
@ -1569,7 +1549,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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) if (!sp)
continue; continue;
@ -1626,13 +1606,13 @@ void SpatialEditorViewport::_update_freelook(real_t delta) {
Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0)); Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0));
Vector3 up = camera->get_transform().basis.xform(Vector3(0, 1, 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_left = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_left")->get_shortcut().ptr())->get_scancode();
int key_right = ED_GET_SHORTCUT("spatial_editor/freelook_right")->get_shortcut()->cast_to<InputEventKey>()->get_scancode(); int key_right = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_right")->get_shortcut().ptr())->get_scancode();
int key_forward = ED_GET_SHORTCUT("spatial_editor/freelook_forward")->get_shortcut()->cast_to<InputEventKey>()->get_scancode(); int key_forward = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_forward")->get_shortcut().ptr())->get_scancode();
int key_backwards = ED_GET_SHORTCUT("spatial_editor/freelook_backwards")->get_shortcut()->cast_to<InputEventKey>()->get_scancode(); int key_backwards = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_backwards")->get_shortcut().ptr())->get_scancode();
int key_up = ED_GET_SHORTCUT("spatial_editor/freelook_up")->get_shortcut()->cast_to<InputEventKey>()->get_scancode(); int key_up = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_up")->get_shortcut().ptr())->get_scancode();
int key_down = ED_GET_SHORTCUT("spatial_editor/freelook_down")->get_shortcut()->cast_to<InputEventKey>()->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 = ED_GET_SHORTCUT("spatial_editor/freelook_speed_modifier")->get_shortcut()->cast_to<InputEventKey>()->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; Vector3 velocity;
bool pressed = false; 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()) { 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) if (!sp)
continue; continue;
@ -1747,7 +1727,7 @@ void SpatialEditorViewport::_notification(int p_what) {
if (!se) if (!se)
continue; continue;
VisualInstance *vi = sp->cast_to<VisualInstance>(); VisualInstance *vi = Object::cast_to<VisualInstance>(sp);
if (se->aabb.has_no_surface()) { 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")); undo_redo->create_action(TTR("Align with view"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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) if (!sp)
continue; continue;
@ -2327,8 +2307,8 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) {
if (p_state.has("previewing")) { if (p_state.has("previewing")) {
Node *pv = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["previewing"]); Node *pv = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["previewing"]);
if (pv && pv->cast_to<Camera>()) { if (Object::cast_to<Camera>(pv)) {
previewing = pv->cast_to<Camera>(); previewing = Object::cast_to<Camera>(pv);
previewing->connect("tree_exited", this, "_preview_exited_scene"); previewing->connect("tree_exited", this, "_preview_exited_scene");
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace
view_menu->hide(); view_menu->hide();
@ -2397,7 +2377,7 @@ void SpatialEditorViewport::focus_selection() {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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) if (!sp)
continue; continue;
@ -2693,7 +2673,7 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
SpatialEditorViewport *viewports[4]; SpatialEditorViewport *viewports[4];
int vc = 0; int vc = 0;
for (int i = 0; i < get_child_count(); i++) { 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]) { if (viewports[vc]) {
vc++; vc++;
} }
@ -2864,7 +2844,7 @@ void SpatialEditor::update_transform_gizmo() {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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) if (!sp)
continue; continue;
@ -2899,7 +2879,7 @@ void SpatialEditor::update_transform_gizmo() {
Object *SpatialEditor::_get_editor_data(Object *p_what) { 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) if (!sp)
return NULL; return NULL;
@ -3139,7 +3119,7 @@ void SpatialEditor::_xform_dialog_action() {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { 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) if (!sp)
continue; continue;
@ -3562,7 +3542,7 @@ void SpatialEditor::_init_indicators() {
_generate_selection_box(); _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; //current_camera=camera;
} }
@ -3694,7 +3674,7 @@ HSplitContainer *SpatialEditor::get_palette_split() {
void SpatialEditor::_request_gizmo(Object *p_obj) { void SpatialEditor::_request_gizmo(Object *p_obj) {
Spatial *sp = p_obj->cast_to<Spatial>(); Spatial *sp = Object::cast_to<Spatial>(p_obj);
if (!sp) if (!sp)
return; 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()))) { 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) { void SpatialEditor::_toggle_maximize_view(Object *p_viewport) {
if (!p_viewport) return; 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; if (!current_viewport) return;
int index = -1; int index = -1;
@ -4122,7 +4102,7 @@ void SpatialEditorPlugin::make_visible(bool p_visible) {
} }
void SpatialEditorPlugin::edit(Object *p_object) { 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 { bool SpatialEditorPlugin::handles(Object *p_object) const {

View file

@ -334,14 +334,14 @@ static void _find_anim_sprites(Node *p_node, List<Node *> *r_nodes, Ref<SpriteFr
return; return;
{ {
AnimatedSprite *as = p_node->cast_to<AnimatedSprite>(); AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node);
if (as && as->get_sprite_frames() == p_sfames) { if (as && as->get_sprite_frames() == p_sfames) {
r_nodes->push_back(p_node); 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) { if (as && as->get_sprite_frames() == p_sfames) {
r_nodes->push_back(p_node); r_nodes->push_back(p_node);
} }
@ -842,7 +842,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
void SpriteFramesEditorPlugin::edit(Object *p_object) { void SpriteFramesEditorPlugin::edit(Object *p_object) {
frames_editor->set_undo_redo(&get_undo_redo()); 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) if (!s)
return; return;

View file

@ -100,7 +100,7 @@ StreamEditor::StreamEditor() {
void StreamEditorPlugin::edit(Object *p_object) { 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 { bool StreamEditorPlugin::handles(Object *p_object) const {

View file

@ -72,8 +72,8 @@ StyleBoxEditor::StyleBoxEditor() {
void StyleBoxEditorPlugin::edit(Object *p_node) { void StyleBoxEditorPlugin::edit(Object *p_node) {
if (p_node && p_node->cast_to<StyleBox>()) { if (Object::cast_to<StyleBox>(p_node)) {
stylebox_editor->edit(p_node->cast_to<StyleBox>()); stylebox_editor->edit(Object::cast_to<StyleBox>(p_node));
stylebox_editor->show(); stylebox_editor->show();
} else } else
stylebox_editor->hide(); stylebox_editor->hide();

View file

@ -70,7 +70,7 @@ void TextureEditor::_notification(int p_what) {
int ofs_x = (size.width - tex_width) / 2; int ofs_x = (size.width - tex_width) / 2;
int ofs_y = (size.height - tex_height) / 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 // In the case of CurveTextures we know they are 1 in height, so fill the preview to see the gradient
ofs_y = 0; ofs_y = 0;
tex_height = size.height; tex_height = size.height;
@ -81,10 +81,10 @@ void TextureEditor::_notification(int p_what) {
Ref<Font> font = get_font("font", "Label"); Ref<Font> font = get_font("font", "Label");
String format; String format;
if (texture->cast_to<ImageTexture>()) { if (Object::cast_to<ImageTexture>(*texture)) {
format = Image::get_format_name(texture->cast_to<ImageTexture>()->get_format()); format = Image::get_format_name(Object::cast_to<ImageTexture>(*texture)->get_format());
} else if (texture->cast_to<StreamTexture>()) { } else if (Object::cast_to<StreamTexture>(*texture)) {
format = Image::get_format_name(texture->cast_to<StreamTexture>()->get_format()); format = Image::get_format_name(Object::cast_to<StreamTexture>(*texture)->get_format());
} else { } else {
format = texture->get_class(); format = texture->get_class();
} }
@ -136,7 +136,7 @@ TextureEditor::TextureEditor() {
void TextureEditorPlugin::edit(Object *p_object) { void TextureEditorPlugin::edit(Object *p_object) {
Texture *s = p_object->cast_to<Texture>(); Texture *s = Object::cast_to<Texture>(p_object);
if (!s) if (!s)
return; return;

View file

@ -626,12 +626,12 @@ void TextureRegionEditor::edit(Object *p_obj) {
if (atlas_tex.is_valid()) if (atlas_tex.is_valid())
atlas_tex->remove_change_receptor(this); atlas_tex->remove_change_receptor(this);
if (p_obj) { if (p_obj) {
node_sprite = p_obj->cast_to<Sprite>(); node_sprite = Object::cast_to<Sprite>(p_obj);
node_patch9 = p_obj->cast_to<NinePatchRect>(); node_patch9 = Object::cast_to<NinePatchRect>(p_obj);
if (p_obj->cast_to<StyleBoxTexture>()) if (Object::cast_to<StyleBoxTexture>(p_obj))
obj_styleBox = Ref<StyleBoxTexture>(p_obj->cast_to<StyleBoxTexture>()); obj_styleBox = Ref<StyleBoxTexture>(Object::cast_to<StyleBoxTexture>(p_obj));
if (p_obj->cast_to<AtlasTexture>()) if (Object::cast_to<AtlasTexture>(p_obj))
atlas_tex = Ref<AtlasTexture>(p_obj->cast_to<AtlasTexture>()); atlas_tex = Ref<AtlasTexture>(Object::cast_to<AtlasTexture>(p_obj));
p_obj->add_change_receptor(this); p_obj->add_change_receptor(this);
_edit_region(); _edit_region();
} else { } else {

View file

@ -44,7 +44,7 @@ void ThemeEditor::_propagate_redraw(Control *p_at) {
p_at->minimum_size_changed(); p_at->minimum_size_changed();
p_at->update(); p_at->update();
for (int i = 0; i < p_at->get_child_count(); i++) { 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) if (a)
_propagate_redraw(a); _propagate_redraw(a);
} }
@ -892,9 +892,9 @@ ThemeEditor::ThemeEditor() {
void ThemeEditorPlugin::edit(Object *p_node) { 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->show();
theme_editor->edit(p_node->cast_to<Theme>()); theme_editor->edit(Object::cast_to<Theme>(p_node));
} else { } else {
theme_editor->edit(Ref<Theme>()); theme_editor->edit(Ref<Theme>());
theme_editor->hide(); theme_editor->hide();

View file

@ -1329,7 +1329,7 @@ void TileMapEditor::edit(Node *p_tile_map) {
node->disconnect("settings_changed", this, "_tileset_settings_changed"); node->disconnect("settings_changed", this, "_tileset_settings_changed");
if (p_tile_map) { 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")) if (!canvas_item_editor->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->connect("draw", this, "_canvas_draw"); canvas_item_editor->connect("draw", this, "_canvas_draw");
if (!canvas_item_editor->is_connected("mouse_entered", this, "_canvas_mouse_enter")) 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) { void TileMapEditor::_update_transform_buttons(Object *p_button) {
//ERR_FAIL_NULL(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); //ERR_FAIL_COND(!b);
if (b == rotate_0) { if (b == rotate_0) {
@ -1582,7 +1582,7 @@ TileMapEditor::~TileMapEditor() {
void TileMapEditorPlugin::edit(Object *p_object) { 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 { bool TileMapEditorPlugin::handles(Object *p_object) const {

View file

@ -43,7 +43,7 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
Node *child = p_node->get_child(i); Node *child = p_node->get_child(i);
if (!child->cast_to<Sprite>()) { if (!Object::cast_to<Sprite>(child)) {
if (child->get_child_count() > 0) { if (child->get_child_count() > 0) {
_import_node(child, p_library); _import_node(child, p_library);
} }
@ -51,7 +51,7 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
continue; continue;
} }
Sprite *mi = child->cast_to<Sprite>(); Sprite *mi = Object::cast_to<Sprite>(child);
Ref<Texture> texture = mi->get_texture(); Ref<Texture> texture = mi->get_texture();
Ref<Texture> normal_map = mi->get_normal_map(); Ref<Texture> normal_map = mi->get_normal_map();
Ref<ShaderMaterial> material = mi->get_material(); 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); Node *child2 = mi->get_child(j);
if (child2->cast_to<NavigationPolygonInstance>()) if (Object::cast_to<NavigationPolygonInstance>(child2))
nav_poly = child2->cast_to<NavigationPolygonInstance>()->get_navigation_polygon(); nav_poly = Object::cast_to<NavigationPolygonInstance>(child2)->get_navigation_polygon();
if (child2->cast_to<LightOccluder2D>()) if (Object::cast_to<LightOccluder2D>(child2))
occluder = child2->cast_to<LightOccluder2D>()->get_occluder_polygon(); occluder = Object::cast_to<LightOccluder2D>(child2)->get_occluder_polygon();
if (!child2->cast_to<StaticBody2D>()) if (!Object::cast_to<StaticBody2D>(child2))
continue; continue;
found_collisions = true; found_collisions = true;
StaticBody2D *sb = child2->cast_to<StaticBody2D>(); StaticBody2D *sb = Object::cast_to<StaticBody2D>(child2);
List<uint32_t> shapes; List<uint32_t> shapes;
sb->get_shape_owners(&shapes); sb->get_shape_owners(&shapes);
@ -268,8 +268,8 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
void TileSetEditorPlugin::edit(Object *p_node) { void TileSetEditorPlugin::edit(Object *p_node) {
if (p_node && p_node->cast_to<TileSet>()) { if (Object::cast_to<TileSet>(p_node)) {
tileset_editor->edit(p_node->cast_to<TileSet>()); tileset_editor->edit(Object::cast_to<TileSet>(p_node));
tileset_editor->show(); tileset_editor->show();
} else } else
tileset_editor->hide(); tileset_editor->hide();

View file

@ -475,7 +475,7 @@ void ProjectManager::_notification(int p_what) {
void ProjectManager::_panel_draw(Node *p_hb) { void ProjectManager::_panel_draw(Node *p_hb) {
HBoxContainer *hb = p_hb->cast_to<HBoxContainer>(); HBoxContainer *hb = Object::cast_to<HBoxContainer>(p_hb);
hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x - 10, hb->get_size().y + 1), get_color("guide_color", "Tree")); hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x - 10, hb->get_size().y + 1), get_color("guide_color", "Tree"));
@ -487,7 +487,7 @@ void ProjectManager::_panel_draw(Node *p_hb) {
void ProjectManager::_update_project_buttons() { void ProjectManager::_update_project_buttons() {
for (int i = 0; i < scroll_childs->get_child_count(); i++) { for (int i = 0; i < scroll_childs->get_child_count(); i++) {
CanvasItem *item = scroll_childs->get_child(i)->cast_to<CanvasItem>(); CanvasItem *item = Object::cast_to<CanvasItem>(scroll_childs->get_child(i));
item->update(); item->update();
} }
@ -509,7 +509,7 @@ void ProjectManager::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
int clicked_id = -1; int clicked_id = -1;
int last_clicked_id = -1; int last_clicked_id = -1;
for (int i = 0; i < scroll_childs->get_child_count(); i++) { for (int i = 0; i < scroll_childs->get_child_count(); i++) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>(); HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
if (!hb) continue; if (!hb) continue;
if (hb->get_meta("name") == clicked) clicked_id = i; if (hb->get_meta("name") == clicked) clicked_id = i;
if (hb->get_meta("name") == last_clicked) last_clicked_id = i; if (hb->get_meta("name") == last_clicked) last_clicked_id = i;
@ -519,7 +519,7 @@ void ProjectManager::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
int min = clicked_id < last_clicked_id ? clicked_id : last_clicked_id; int min = clicked_id < last_clicked_id ? clicked_id : last_clicked_id;
int max = clicked_id > last_clicked_id ? clicked_id : last_clicked_id; int max = clicked_id > last_clicked_id ? clicked_id : last_clicked_id;
for (int i = 0; i < scroll_childs->get_child_count(); ++i) { for (int i = 0; i < scroll_childs->get_child_count(); ++i) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>(); HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
if (!hb) continue; if (!hb) continue;
if (i != clicked_id && (i < min || i > max) && !mb->get_control()) { if (i != clicked_id && (i < min || i > max) && !mb->get_control()) {
selected_list.erase(hb->get_meta("name")); selected_list.erase(hb->get_meta("name"));
@ -572,7 +572,7 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
for (int i = 0; i < scroll_childs->get_child_count(); i++) { for (int i = 0; i < scroll_childs->get_child_count(); i++) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>(); HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
if (hb) { if (hb) {
selected_list.clear(); selected_list.clear();
selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene")); selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
@ -587,7 +587,7 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
for (int i = scroll_childs->get_child_count() - 1; i >= 0; i--) { for (int i = scroll_childs->get_child_count() - 1; i >= 0; i--) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>(); HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
if (hb) { if (hb) {
selected_list.clear(); selected_list.clear();
selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene")); selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
@ -609,7 +609,7 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
for (int i = scroll_childs->get_child_count() - 1; i >= 0; i--) { for (int i = scroll_childs->get_child_count() - 1; i >= 0; i--) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>(); HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
if (!hb) continue; if (!hb) continue;
String current = hb->get_meta("name"); String current = hb->get_meta("name");
@ -646,7 +646,7 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
for (int i = 0; i < scroll_childs->get_child_count(); i++) { for (int i = 0; i < scroll_childs->get_child_count(); i++) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>(); HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
if (!hb) continue; if (!hb) continue;
String current = hb->get_meta("name"); String current = hb->get_meta("name");
@ -885,8 +885,8 @@ void ProjectManager::_load_recent_projects() {
void ProjectManager::_on_project_created(const String &dir) { void ProjectManager::_on_project_created(const String &dir) {
bool has_already = false; bool has_already = false;
for (int i = 0; i < scroll_childs->get_child_count(); i++) { for (int i = 0; i < scroll_childs->get_child_count(); i++) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>(); HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
Label *fpath = hb->get_node(NodePath("project/path"))->cast_to<Label>(); Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path")));
if (fpath->get_text() == dir) { if (fpath->get_text() == dir) {
has_already = true; has_already = true;
break; break;
@ -903,8 +903,8 @@ void ProjectManager::_on_project_created(const String &dir) {
void ProjectManager::_update_scroll_pos(const String &dir) { void ProjectManager::_update_scroll_pos(const String &dir) {
for (int i = 0; i < scroll_childs->get_child_count(); i++) { for (int i = 0; i < scroll_childs->get_child_count(); i++) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>(); HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
Label *fpath = hb->get_node(NodePath("project/path"))->cast_to<Label>(); Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path")));
if (fpath->get_text() == dir) { if (fpath->get_text() == dir) {
last_clicked = hb->get_meta("name"); last_clicked = hb->get_meta("name");
selected_list.clear(); selected_list.clear();

View file

@ -505,7 +505,7 @@ void ProjectSettingsEditor::_action_activated() {
void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column, int p_id) { void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column, int p_id) {
TreeItem *ti = p_obj->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(p_obj);
ERR_FAIL_COND(!ti); ERR_FAIL_COND(!ti);
@ -1010,7 +1010,7 @@ void ProjectSettingsEditor::_translation_file_open() {
void ProjectSettingsEditor::_translation_delete(Object *p_item, int p_column, int p_button) { void ProjectSettingsEditor::_translation_delete(Object *p_item, int p_column, int p_button) {
TreeItem *ti = p_item->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti); ERR_FAIL_COND(!ti);
int idx = ti->get_metadata(0); int idx = ti->get_metadata(0);
@ -1151,7 +1151,7 @@ void ProjectSettingsEditor::_translation_res_delete(Object *p_item, int p_column
Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
TreeItem *k = p_item->cast_to<TreeItem>(); TreeItem *k = Object::cast_to<TreeItem>(p_item);
String key = k->get_metadata(0); String key = k->get_metadata(0);
ERR_FAIL_COND(!remaps.has(key)); ERR_FAIL_COND(!remaps.has(key));
@ -1180,7 +1180,7 @@ void ProjectSettingsEditor::_translation_res_option_delete(Object *p_item, int p
TreeItem *k = translation_remap->get_selected(); TreeItem *k = translation_remap->get_selected();
ERR_FAIL_COND(!k); ERR_FAIL_COND(!k);
TreeItem *ed = p_item->cast_to<TreeItem>(); TreeItem *ed = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ed); ERR_FAIL_COND(!ed);
String key = k->get_metadata(0); String key = k->get_metadata(0);

View file

@ -176,7 +176,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
Object *inst = ClassDB::instance(orig_type); Object *inst = ClassDB::instance(orig_type);
Ref<Resource> res = Ref<Resource>(inst->cast_to<Resource>()); Ref<Resource> res = Ref<Resource>(Object::cast_to<Resource>(inst));
ERR_FAIL_COND(res.is_null()); ERR_FAIL_COND(res.is_null());
@ -215,8 +215,8 @@ void CustomPropertyEditor::_menu_option(int p_which) {
} break; } break;
case OBJ_MENU_NEW_SCRIPT: { case OBJ_MENU_NEW_SCRIPT: {
if (owner->cast_to<Node>()) if (Object::cast_to<Node>(owner))
EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(owner->cast_to<Node>()); EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(owner));
} break; } break;
case OBJ_MENU_SHOW_IN_FILE_SYSTEM: { case OBJ_MENU_SHOW_IN_FILE_SYSTEM: {
@ -243,7 +243,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
Object *obj = ClassDB::instance(intype); Object *obj = ClassDB::instance(intype);
ERR_BREAK(!obj); ERR_BREAK(!obj);
Resource *res = obj->cast_to<Resource>(); Resource *res = Object::cast_to<Resource>(obj);
ERR_BREAK(!res); ERR_BREAK(!res);
if (owner && hint == PROPERTY_HINT_RESOURCE_TYPE && hint_text == "Script") { if (owner && hint == PROPERTY_HINT_RESOURCE_TYPE && hint_text == "Script") {
//make visual script the right type //make visual script the right type
@ -593,8 +593,8 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
MAKE_PROPSELECT MAKE_PROPSELECT
Object *obj = ObjectDB::get_instance(hint_text.to_int64()); Object *obj = ObjectDB::get_instance(hint_text.to_int64());
if (obj && obj->cast_to<Script>()) { if (Object::cast_to<Script>(obj)) {
property_select->select_method_from_script(obj->cast_to<Script>(), v); property_select->select_method_from_script(Object::cast_to<Script>(obj), v);
} }
updating = false; updating = false;
@ -641,8 +641,8 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
MAKE_PROPSELECT MAKE_PROPSELECT
Object *obj = ObjectDB::get_instance(hint_text.to_int64()); Object *obj = ObjectDB::get_instance(hint_text.to_int64());
if (obj && obj->cast_to<Script>()) { if (Object::cast_to<Script>(obj)) {
property_select->select_property_from_script(obj->cast_to<Script>(), v); property_select->select_property_from_script(Object::cast_to<Script>(obj), v);
} }
updating = false; updating = false;
@ -864,7 +864,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
names.push_back(TTR("Assign")); names.push_back(TTR("Assign"));
names.push_back(TTR("Clear")); names.push_back(TTR("Clear"));
if (owner->is_class("Node") && (v.get_type() == Variant::NODE_PATH) && owner->cast_to<Node>()->has_node(v)) if (owner->is_class("Node") && (v.get_type() == Variant::NODE_PATH) && Object::cast_to<Node>(owner)->has_node(v))
names.push_back(TTR("Select Node")); names.push_back(TTR("Select Node"));
config_action_buttons(names); config_action_buttons(names);
@ -878,7 +878,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
menu->clear(); menu->clear();
menu->set_size(Size2(1, 1) * EDSCALE); menu->set_size(Size2(1, 1) * EDSCALE);
if (p_name == "script" && hint_text == "Script" && owner->cast_to<Node>()) { if (p_name == "script" && hint_text == "Script" && Object::cast_to<Node>(owner)) {
menu->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT); menu->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
menu->add_separator(); menu->add_separator();
} else if (hint_text != "") { } else if (hint_text != "") {
@ -1104,7 +1104,7 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
ERR_FAIL_COND(!obj); ERR_FAIL_COND(!obj);
Resource *res = obj->cast_to<Resource>(); Resource *res = Object::cast_to<Resource>(obj);
ERR_FAIL_COND(!res); ERR_FAIL_COND(!res);
v = Ref<Resource>(res).get_ref_ptr(); v = Ref<Resource>(res).get_ref_ptr();
@ -1124,7 +1124,7 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) {
if (picking_viewport) { if (picking_viewport) {
Node *to_node = get_node(p_path); Node *to_node = get_node(p_path);
if (!to_node->cast_to<Viewport>()) { if (!Object::cast_to<Viewport>(to_node)) {
EditorNode::get_singleton()->show_warning("Selected node is not a Viewport!"); EditorNode::get_singleton()->show_warning("Selected node is not a Viewport!");
return; return;
} }
@ -1154,9 +1154,9 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) {
Node *node = NULL; Node *node = NULL;
if (owner->is_class("Node")) if (owner->is_class("Node"))
node = owner->cast_to<Node>(); node = Object::cast_to<Node>(owner);
else if (owner->is_class("ArrayPropertyEdit")) else if (owner->is_class("ArrayPropertyEdit"))
node = owner->cast_to<ArrayPropertyEdit>()->get_node(); node = Object::cast_to<ArrayPropertyEdit>(owner)->get_node();
if (!node) { if (!node) {
v = p_path; v = p_path;
@ -1276,9 +1276,9 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
hide(); hide();
} else if (p_which == 2) { } else if (p_which == 2) {
if (owner->is_class("Node") && (v.get_type() == Variant::NODE_PATH) && owner->cast_to<Node>()->has_node(v)) { if (owner->is_class("Node") && (v.get_type() == Variant::NODE_PATH) && Object::cast_to<Node>(owner)->has_node(v)) {
Node *target_node = owner->cast_to<Node>()->get_node(v); Node *target_node = Object::cast_to<Node>(owner)->get_node(v);
EditorNode::get_singleton()->get_editor_selection()->clear(); EditorNode::get_singleton()->get_editor_selection()->clear();
EditorNode::get_singleton()->get_scene_tree_dock()->set_selected(target_node); EditorNode::get_singleton()->get_scene_tree_dock()->set_selected(target_node);
} }
@ -1299,7 +1299,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
Object *obj = ClassDB::instance(intype); Object *obj = ClassDB::instance(intype);
ERR_BREAK(!obj); ERR_BREAK(!obj);
Resource *res = obj->cast_to<Resource>(); Resource *res = Object::cast_to<Resource>(obj);
ERR_BREAK(!res); ERR_BREAK(!res);
v = Ref<Resource>(res).get_ref_ptr(); v = Ref<Resource>(res).get_ref_ptr();
@ -2017,7 +2017,7 @@ bool PropertyEditor::_might_be_in_instance() {
if (!obj) if (!obj)
return false; return false;
Node *node = obj->cast_to<Node>(); Node *node = Object::cast_to<Node>(obj);
Node *edited_scene = EditorNode::get_singleton()->get_edited_scene(); Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
@ -2045,7 +2045,7 @@ bool PropertyEditor::_might_be_in_instance() {
bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_prop, Variant &value) { bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_prop, Variant &value) {
Node *node = obj->cast_to<Node>(); Node *node = Object::cast_to<Node>(obj);
if (!node) if (!node)
return false; return false;
@ -2100,7 +2100,7 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_p
bool PropertyEditor::_is_property_different(const Variant &p_current, const Variant &p_orig, int p_usage) { bool PropertyEditor::_is_property_different(const Variant &p_current, const Variant &p_orig, int p_usage) {
{ {
Node *node = obj->cast_to<Node>(); Node *node = Object::cast_to<Node>(obj);
if (!node) if (!node)
return false; return false;
@ -2888,7 +2888,7 @@ void PropertyEditor::update_tree() {
*/ */
/* /*
if (obj->cast_to<Node>() || obj->cast_to<Resource>()) { if (Object::cast_to<Node>() || Object::cast_to<Resource>(obj)) {
TreeItem *type = tree->create_item(root); TreeItem *type = tree->create_item(root);
type->set_text(0,"Type"); // todo, fetch name if ID exists in database type->set_text(0,"Type"); // todo, fetch name if ID exists in database
@ -2906,9 +2906,9 @@ void PropertyEditor::update_tree() {
name->set_text(0,"Name"); // todo, fetch name if ID exists in database name->set_text(0,"Name"); // todo, fetch name if ID exists in database
if (obj->is_type("Resource")) if (obj->is_type("Resource"))
name->set_text(1,obj->cast_to<Resource>()->get_name()); name->set_text(1,Object::cast_to<Resource>(obj)->get_name());
else if (obj->is_type("Node")) else if (obj->is_type("Node"))
name->set_text(1,obj->cast_to<Node>()->get_name()); name->set_text(1,Object::cast_to<Node>(obj)->get_name());
name->set_selectable(0,false); name->set_selectable(0,false);
name->set_selectable(1,false); name->set_selectable(1,false);
} }
@ -2919,7 +2919,7 @@ void PropertyEditor::update_tree() {
bool draw_red = false; bool draw_red = false;
{ {
Node *nod = obj->cast_to<Node>(); Node *nod = Object::cast_to<Node>(obj);
Node *es = EditorNode::get_singleton()->get_edited_scene(); Node *es = EditorNode::get_singleton()->get_edited_scene();
if (nod && es != nod && nod->get_owner() != es) { if (nod && es != nod && nod->get_owner() != es) {
draw_red = true; draw_red = true;
@ -3742,7 +3742,7 @@ void PropertyEditor::update_tree() {
void PropertyEditor::_draw_transparency(Object *t, const Rect2 &p_rect) { void PropertyEditor::_draw_transparency(Object *t, const Rect2 &p_rect) {
TreeItem *ti = t->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(t);
if (!ti) if (!ti)
return; return;
@ -3763,7 +3763,7 @@ void PropertyEditor::_item_folded(Object *item_obj) {
if (updating_folding) if (updating_folding)
return; return;
TreeItem *item = item_obj->cast_to<TreeItem>(); TreeItem *item = Object::cast_to<TreeItem>(item_obj);
obj->editor_set_section_unfold(item->get_metadata(0), !item->is_collapsed()); obj->editor_set_section_unfold(item->get_metadata(0), !item->is_collapsed());
} }
@ -3789,7 +3789,7 @@ void PropertyEditor::_edit_set(const String &p_name, const Variant &p_value, boo
} }
} }
if (!undo_redo || obj->cast_to<ArrayPropertyEdit>()) { //kind of hacky if (!undo_redo || Object::cast_to<ArrayPropertyEdit>(obj)) { //kind of hacky
obj->set(p_name, p_value); obj->set(p_name, p_value);
if (p_refresh_all) if (p_refresh_all)
@ -3799,9 +3799,9 @@ void PropertyEditor::_edit_set(const String &p_name, const Variant &p_value, boo
emit_signal(_prop_edited, p_name); emit_signal(_prop_edited, p_name);
} else if (obj->cast_to<MultiNodeEdit>()) { } else if (Object::cast_to<MultiNodeEdit>(obj)) {
obj->cast_to<MultiNodeEdit>()->set_property_field(p_name, p_value, p_changed_field); Object::cast_to<MultiNodeEdit>(obj)->set_property_field(p_name, p_value, p_changed_field);
_changed_callbacks(obj, p_name); _changed_callbacks(obj, p_name);
emit_signal(_prop_edited, p_name); emit_signal(_prop_edited, p_name);
} else { } else {
@ -3819,7 +3819,7 @@ void PropertyEditor::_edit_set(const String &p_name, const Variant &p_value, boo
undo_redo->add_undo_method(this, "_changed_callback", obj, p_name); undo_redo->add_undo_method(this, "_changed_callback", obj, p_name);
} }
Resource *r = obj->cast_to<Resource>(); Resource *r = Object::cast_to<Resource>(obj);
if (r) { if (r) {
if (!r->is_edited() && String(p_name) != "resource/edited") { if (!r->is_edited() && String(p_name) != "resource/edited") {
undo_redo->add_do_method(r, "set_edited", true); undo_redo->add_do_method(r, "set_edited", true);
@ -4070,7 +4070,7 @@ void PropertyEditor::edit(Object *p_object) {
void PropertyEditor::_set_range_def(Object *p_item, String prop, float p_frame) { void PropertyEditor::_set_range_def(Object *p_item, String prop, float p_frame) {
TreeItem *ti = p_item->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti); ERR_FAIL_COND(!ti);
ti->call_deferred("set_range", 1, p_frame); ti->call_deferred("set_range", 1, p_frame);
@ -4078,7 +4078,7 @@ void PropertyEditor::_set_range_def(Object *p_item, String prop, float p_frame)
} }
void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
TreeItem *ti = p_item->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti); ERR_FAIL_COND(!ti);
Dictionary d = ti->get_metadata(0); Dictionary d = ti->get_metadata(0);
@ -4216,7 +4216,7 @@ void PropertyEditor::set_keying(bool p_active) {
void PropertyEditor::_draw_flags(Object *p_object, const Rect2 &p_rect) { void PropertyEditor::_draw_flags(Object *p_object, const Rect2 &p_rect) {
TreeItem *ti = p_object->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(p_object);
if (!ti) if (!ti)
return; return;
@ -4268,7 +4268,7 @@ void PropertyEditor::_resource_preview_done(const String &p_path, const Ref<Text
if (!obj) if (!obj)
return; return;
TreeItem *ti = obj->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(obj);
ERR_FAIL_COND(!ti); ERR_FAIL_COND(!ti);
@ -4374,7 +4374,7 @@ void PropertyEditor::set_use_filter(bool p_use) {
void PropertyEditor::register_text_enter(Node *p_line_edit) { void PropertyEditor::register_text_enter(Node *p_line_edit) {
ERR_FAIL_NULL(p_line_edit); ERR_FAIL_NULL(p_line_edit);
search_box = p_line_edit->cast_to<LineEdit>(); search_box = Object::cast_to<LineEdit>(p_line_edit);
if (search_box) if (search_box)
search_box->connect("text_changed", this, "_filter_changed"); search_box->connect("text_changed", this, "_filter_changed");

View file

@ -98,10 +98,10 @@ void PropertySelector::_update_search() {
} else { } else {
Object *obj = ObjectDB::get_instance(script); Object *obj = ObjectDB::get_instance(script);
if (obj && obj->cast_to<Script>()) { if (Object::cast_to<Script>(obj)) {
props.push_back(PropertyInfo(Variant::NIL, "Script Variables", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_CATEGORY)); props.push_back(PropertyInfo(Variant::NIL, "Script Variables", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_CATEGORY));
obj->cast_to<Script>()->get_script_property_list(&props); Object::cast_to<Script>(obj)->get_script_property_list(&props);
} }
StringName base = base_type; StringName base = base_type;
@ -200,10 +200,10 @@ void PropertySelector::_update_search() {
} else { } else {
Object *obj = ObjectDB::get_instance(script); Object *obj = ObjectDB::get_instance(script);
if (obj && obj->cast_to<Script>()) { if (Object::cast_to<Script>(obj)) {
methods.push_back(MethodInfo("*Script Methods")); methods.push_back(MethodInfo("*Script Methods"));
obj->cast_to<Script>()->get_script_method_list(&methods); Object::cast_to<Script>(obj)->get_script_method_list(&methods);
} }
StringName base = base_type; StringName base = base_type;

View file

@ -279,7 +279,7 @@ void ResourcesDock::_resource_selected() {
void ResourcesDock::_delete(Object *p_item, int p_column, int p_id) { void ResourcesDock::_delete(Object *p_item, int p_column, int p_id) {
TreeItem *ti = p_item->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti); ERR_FAIL_COND(!ti);
call_deferred("remove_resource", ti->get_metadata(0)); call_deferred("remove_resource", ti->get_metadata(0));
@ -290,7 +290,7 @@ void ResourcesDock::_create() {
Object *c = create_dialog->instance_selected(); Object *c = create_dialog->instance_selected();
ERR_FAIL_COND(!c); ERR_FAIL_COND(!c);
Resource *r = c->cast_to<Resource>(); Resource *r = Object::cast_to<Resource>(c);
ERR_FAIL_COND(!r); ERR_FAIL_COND(!r);
REF res(r); REF res(r);

View file

@ -775,7 +775,7 @@ void SceneTreeDock::_notification(int p_what) {
break; break;
first_enter = false; first_enter = false;
CanvasItemEditorPlugin *canvas_item_plugin = editor_data->get_editor("2D")->cast_to<CanvasItemEditorPlugin>(); CanvasItemEditorPlugin *canvas_item_plugin = Object::cast_to<CanvasItemEditorPlugin>(editor_data->get_editor("2D"));
if (canvas_item_plugin) { if (canvas_item_plugin) {
canvas_item_plugin->get_canvas_item_editor()->connect("item_lock_status_changed", scene_tree, "_update_tree"); canvas_item_plugin->get_canvas_item_editor()->connect("item_lock_status_changed", scene_tree, "_update_tree");
canvas_item_plugin->get_canvas_item_editor()->connect("item_group_status_changed", scene_tree, "_update_tree"); canvas_item_plugin->get_canvas_item_editor()->connect("item_group_status_changed", scene_tree, "_update_tree");
@ -864,7 +864,7 @@ Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node *, Node *> &duplimap) {
} else { } else {
Object *obj = ClassDB::instance(p_node->get_class()); Object *obj = ClassDB::instance(p_node->get_class());
ERR_FAIL_COND_V(!obj, NULL); ERR_FAIL_COND_V(!obj, NULL);
node = obj->cast_to<Node>(); node = Object::cast_to<Node>(obj);
if (!node) if (!node)
memdelete(obj); memdelete(obj);
ERR_FAIL_COND_V(!node, NULL); ERR_FAIL_COND_V(!node, NULL);
@ -915,11 +915,7 @@ void SceneTreeDock::_set_owners(Node *p_owner, const Array &p_nodes) {
for (int i = 0; i < p_nodes.size(); i++) { for (int i = 0; i < p_nodes.size(); i++) {
Object *obj = p_nodes[i]; Node *n = Object::cast_to<Node>(p_nodes[i]);
if (!obj)
continue;
Node *n = obj->cast_to<Node>();
if (!n) if (!n)
continue; continue;
n->set_owner(p_owner); n->set_owner(p_owner);
@ -994,9 +990,9 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
if (!p_base) if (!p_base)
return; return;
if (p_base->cast_to<AnimationPlayer>()) { if (Object::cast_to<AnimationPlayer>(p_base)) {
AnimationPlayer *ap = p_base->cast_to<AnimationPlayer>(); AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_base);
List<StringName> anims; List<StringName> anims;
ap->get_animation_list(&anims); ap->get_animation_list(&anims);
Node *root = ap->get_node(ap->get_root()); Node *root = ap->get_node(ap->get_root());
@ -1235,12 +1231,12 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_reparent_node", NodePath(String(edited_scene->get_path_to(new_parent)) + "/" + new_name), edited_scene->get_path_to(node->get_parent()), node->get_name(), node->get_index()); editor_data->get_undo_redo().add_undo_method(sed, "live_debug_reparent_node", NodePath(String(edited_scene->get_path_to(new_parent)) + "/" + new_name), edited_scene->get_path_to(node->get_parent()), node->get_name(), node->get_index());
if (p_keep_global_xform) { if (p_keep_global_xform) {
if (node->cast_to<Node2D>()) if (Object::cast_to<Node2D>(node))
editor_data->get_undo_redo().add_do_method(node, "set_global_transform", node->cast_to<Node2D>()->get_global_transform()); editor_data->get_undo_redo().add_do_method(node, "set_global_transform", Object::cast_to<Node2D>(node)->get_global_transform());
if (node->cast_to<Spatial>()) if (Object::cast_to<Spatial>(node))
editor_data->get_undo_redo().add_do_method(node, "set_global_transform", node->cast_to<Spatial>()->get_global_transform()); editor_data->get_undo_redo().add_do_method(node, "set_global_transform", Object::cast_to<Spatial>(node)->get_global_transform());
if (node->cast_to<Control>()) if (Object::cast_to<Control>(node))
editor_data->get_undo_redo().add_do_method(node, "set_global_position", node->cast_to<Control>()->get_global_position()); editor_data->get_undo_redo().add_do_method(node, "set_global_position", Object::cast_to<Control>(node)->get_global_position());
} }
editor_data->get_undo_redo().add_do_method(this, "_set_owners", edited_scene, owners); editor_data->get_undo_redo().add_do_method(this, "_set_owners", edited_scene, owners);
@ -1277,12 +1273,12 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_key_editor(), "set_root", node); editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_key_editor(), "set_root", node);
if (p_keep_global_xform) { if (p_keep_global_xform) {
if (node->cast_to<Node2D>()) if (Object::cast_to<Node2D>(node))
editor_data->get_undo_redo().add_undo_method(node, "set_transform", node->cast_to<Node2D>()->get_transform()); editor_data->get_undo_redo().add_undo_method(node, "set_transform", Object::cast_to<Node2D>(node)->get_transform());
if (node->cast_to<Spatial>()) if (Object::cast_to<Spatial>(node))
editor_data->get_undo_redo().add_undo_method(node, "set_transform", node->cast_to<Spatial>()->get_transform()); editor_data->get_undo_redo().add_undo_method(node, "set_transform", Object::cast_to<Spatial>(node)->get_transform());
if (node->cast_to<Control>()) if (Object::cast_to<Control>(node))
editor_data->get_undo_redo().add_undo_method(node, "set_position", node->cast_to<Control>()->get_position()); editor_data->get_undo_redo().add_undo_method(node, "set_position", Object::cast_to<Control>(node)->get_position());
} }
} }
@ -1421,7 +1417,7 @@ void SceneTreeDock::_create() {
Object *c = create_dialog->instance_selected(); Object *c = create_dialog->instance_selected();
ERR_FAIL_COND(!c); ERR_FAIL_COND(!c);
Node *child = c->cast_to<Node>(); Node *child = Object::cast_to<Node>(c);
ERR_FAIL_COND(!child); ERR_FAIL_COND(!child);
editor_data->get_undo_redo().create_action(TTR("Create Node")); editor_data->get_undo_redo().create_action(TTR("Create Node"));
@ -1450,9 +1446,9 @@ void SceneTreeDock::_create() {
editor_data->get_undo_redo().commit_action(); editor_data->get_undo_redo().commit_action();
editor->push_item(c); editor->push_item(c);
if (c->cast_to<Control>()) { if (Object::cast_to<Control>(c)) {
//make editor more comfortable, so some controls don't appear super shrunk //make editor more comfortable, so some controls don't appear super shrunk
Control *ct = c->cast_to<Control>(); Control *ct = Object::cast_to<Control>(c);
Size2 ms = ct->get_minimum_size(); Size2 ms = ct->get_minimum_size();
if (ms.width < 4) if (ms.width < 4)
@ -1469,7 +1465,7 @@ void SceneTreeDock::_create() {
Object *c = create_dialog->instance_selected(); Object *c = create_dialog->instance_selected();
ERR_FAIL_COND(!c); ERR_FAIL_COND(!c);
Node *newnode = c->cast_to<Node>(); Node *newnode = Object::cast_to<Node>(c);
ERR_FAIL_COND(!newnode); ERR_FAIL_COND(!newnode);
List<PropertyInfo> pinfo; List<PropertyInfo> pinfo;
@ -1931,10 +1927,10 @@ void SceneTreeDock::_focus_node() {
ERR_FAIL_COND(!node); ERR_FAIL_COND(!node);
if (node->is_class("CanvasItem")) { if (node->is_class("CanvasItem")) {
CanvasItemEditorPlugin *editor = editor_data->get_editor("2D")->cast_to<CanvasItemEditorPlugin>(); CanvasItemEditorPlugin *editor = Object::cast_to<CanvasItemEditorPlugin>(editor_data->get_editor("2D"));
editor->get_canvas_item_editor()->focus_selection(); editor->get_canvas_item_editor()->focus_selection();
} else { } else {
SpatialEditorPlugin *editor = editor_data->get_editor("3D")->cast_to<SpatialEditorPlugin>(); SpatialEditorPlugin *editor = Object::cast_to<SpatialEditorPlugin>(editor_data->get_editor("3D"));
editor->get_spatial_editor()->get_editor_viewport(0)->focus_selection(); editor->get_spatial_editor()->get_editor_viewport(0)->focus_selection();
} }
} }

View file

@ -46,7 +46,7 @@ Node *SceneTreeEditor::get_scene_node() {
void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id) { void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id) {
TreeItem *item = p_item->cast_to<TreeItem>(); TreeItem *item = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!item); ERR_FAIL_COND(!item);
NodePath np = item->get_metadata(0); NodePath np = item->get_metadata(0);
@ -475,7 +475,7 @@ void SceneTreeEditor::_selected_changed() {
void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_selected) { void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_selected) {
TreeItem *item = p_object->cast_to<TreeItem>(); TreeItem *item = Object::cast_to<TreeItem>(p_object);
ERR_FAIL_COND(!item); ERR_FAIL_COND(!item);
NodePath np = item->get_metadata(0); NodePath np = item->get_metadata(0);
@ -584,7 +584,7 @@ void SceneTreeEditor::_rename_node(ObjectID p_node, const String &p_name) {
Object *o = ObjectDB::get_instance(p_node); Object *o = ObjectDB::get_instance(p_node);
ERR_FAIL_COND(!o); ERR_FAIL_COND(!o);
Node *n = o->cast_to<Node>(); Node *n = Object::cast_to<Node>(o);
ERR_FAIL_COND(!n); ERR_FAIL_COND(!n);
TreeItem *item = _find(tree->get_root(), n->get_path()); TreeItem *item = _find(tree->get_root(), n->get_path());
ERR_FAIL_COND(!item); ERR_FAIL_COND(!item);
@ -732,7 +732,7 @@ void SceneTreeEditor::_cell_collapsed(Object *p_obj) {
if (!can_rename) if (!can_rename)
return; return;
TreeItem *ti = p_obj->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(p_obj);
if (!ti) if (!ti)
return; return;

View file

@ -215,7 +215,7 @@ void ScriptEditorDebugger::_scene_tree_folded(Object *obj) {
return; return;
} }
TreeItem *item = obj->cast_to<TreeItem>(); TreeItem *item = Object::cast_to<TreeItem>(obj);
if (!item) if (!item)
return; return;
@ -1221,7 +1221,7 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n
if (!p_base || !live_debug || !connection.is_valid() || !editor->get_edited_scene()) if (!p_base || !live_debug || !connection.is_valid() || !editor->get_edited_scene())
return; return;
Node *node = p_base->cast_to<Node>(); Node *node = Object::cast_to<Node>(p_base);
VARIANT_ARGPTRS VARIANT_ARGPTRS
@ -1249,7 +1249,7 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n
return; return;
} }
Resource *res = p_base->cast_to<Resource>(); Resource *res = Object::cast_to<Resource>(p_base);
if (res && res->get_path() != String()) { if (res && res->get_path() != String()) {
@ -1277,7 +1277,7 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p
if (!p_base || !live_debug || !connection.is_valid() || !editor->get_edited_scene()) if (!p_base || !live_debug || !connection.is_valid() || !editor->get_edited_scene())
return; return;
Node *node = p_base->cast_to<Node>(); Node *node = Object::cast_to<Node>(p_base);
if (node) { if (node) {
@ -1308,7 +1308,7 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p
return; return;
} }
Resource *res = p_base->cast_to<Resource>(); Resource *res = Object::cast_to<Resource>(p_base);
if (res && res->get_path() != String()) { if (res && res->get_path() != String()) {

View file

@ -191,7 +191,7 @@ void EditorSettingsDialog::_update_shortcuts() {
void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column, int p_idx) { void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column, int p_idx) {
TreeItem *ti = p_item->cast_to<TreeItem>(); TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti); ERR_FAIL_COND(!ti);
String item = ti->get_metadata(0); String item = ti->get_metadata(0);

View file

@ -660,7 +660,7 @@ void LightSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_
Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
if (p_idx == 0) { if (p_idx == 0) {
if (light->cast_to<SpotLight>()) { if (Object::cast_to<SpotLight>(light)) {
Vector3 ra, rb; Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), Vector3(0, 0, -4096), s[0], s[1], ra, rb); Geometry::get_closest_points_between_segments(Vector3(), Vector3(0, 0, -4096), s[0], s[1], ra, rb);
@ -669,7 +669,7 @@ void LightSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_
d = 0; d = 0;
light->set_param(Light::PARAM_RANGE, d); light->set_param(Light::PARAM_RANGE, d);
} else if (light->cast_to<OmniLight>()) { } else if (Object::cast_to<OmniLight>(light)) {
Plane cp = Plane(gt.origin, p_camera->get_transform().basis.get_axis(2)); Plane cp = Plane(gt.origin, p_camera->get_transform().basis.get_axis(2));
@ -713,7 +713,7 @@ void LightSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool
void LightSpatialGizmo::redraw() { void LightSpatialGizmo::redraw() {
if (light->cast_to<DirectionalLight>()) { if (Object::cast_to<DirectionalLight>(light)) {
const int arrow_points = 5; const int arrow_points = 5;
Vector3 arrow[arrow_points] = { Vector3 arrow[arrow_points] = {
@ -751,11 +751,11 @@ void LightSpatialGizmo::redraw() {
add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_directional_icon, 0.05); add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_directional_icon, 0.05);
} }
if (light->cast_to<OmniLight>()) { if (Object::cast_to<OmniLight>(light)) {
clear(); clear();
OmniLight *on = light->cast_to<OmniLight>(); OmniLight *on = Object::cast_to<OmniLight>(light);
float r = on->get_param(Light::PARAM_RANGE); float r = on->get_param(Light::PARAM_RANGE);
@ -786,12 +786,12 @@ void LightSpatialGizmo::redraw() {
add_handles(handles, true); add_handles(handles, true);
} }
if (light->cast_to<SpotLight>()) { if (Object::cast_to<SpotLight>(light)) {
clear(); clear();
Vector<Vector3> points; Vector<Vector3> points;
SpotLight *on = light->cast_to<SpotLight>(); SpotLight *on = Object::cast_to<SpotLight>(light);
float r = on->get_param(Light::PARAM_RANGE); float r = on->get_param(Light::PARAM_RANGE);
float w = r * Math::sin(Math::deg2rad(on->get_param(Light::PARAM_SPOT_ANGLE))); float w = r * Math::sin(Math::deg2rad(on->get_param(Light::PARAM_SPOT_ANGLE)));
@ -1568,22 +1568,22 @@ String CollisionShapeSpatialGizmo::get_handle_name(int p_idx) const {
if (s.is_null()) if (s.is_null())
return ""; return "";
if (s->cast_to<SphereShape>()) { if (Object::cast_to<SphereShape>(*s)) {
return "Radius"; return "Radius";
} }
if (s->cast_to<BoxShape>()) { if (Object::cast_to<BoxShape>(*s)) {
return "Extents"; return "Extents";
} }
if (s->cast_to<CapsuleShape>()) { if (Object::cast_to<CapsuleShape>(*s)) {
return p_idx == 0 ? "Radius" : "Height"; return p_idx == 0 ? "Radius" : "Height";
} }
if (s->cast_to<RayShape>()) { if (Object::cast_to<RayShape>(*s)) {
return "Length"; return "Length";
} }
@ -1596,25 +1596,25 @@ Variant CollisionShapeSpatialGizmo::get_handle_value(int p_idx) const {
if (s.is_null()) if (s.is_null())
return Variant(); return Variant();
if (s->cast_to<SphereShape>()) { if (Object::cast_to<SphereShape>(*s)) {
Ref<SphereShape> ss = s; Ref<SphereShape> ss = s;
return ss->get_radius(); return ss->get_radius();
} }
if (s->cast_to<BoxShape>()) { if (Object::cast_to<BoxShape>(*s)) {
Ref<BoxShape> bs = s; Ref<BoxShape> bs = s;
return bs->get_extents(); return bs->get_extents();
} }
if (s->cast_to<CapsuleShape>()) { if (Object::cast_to<CapsuleShape>(*s)) {
Ref<CapsuleShape> cs = s; Ref<CapsuleShape> cs = s;
return p_idx == 0 ? cs->get_radius() : cs->get_height(); return p_idx == 0 ? cs->get_radius() : cs->get_height();
} }
if (s->cast_to<RayShape>()) { if (Object::cast_to<RayShape>(*s)) {
Ref<RayShape> cs = s; Ref<RayShape> cs = s;
return cs->get_length(); return cs->get_length();
@ -1636,7 +1636,7 @@ void CollisionShapeSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const P
Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
if (s->cast_to<SphereShape>()) { if (Object::cast_to<SphereShape>(*s)) {
Ref<SphereShape> ss = s; Ref<SphereShape> ss = s;
Vector3 ra, rb; Vector3 ra, rb;
@ -1648,7 +1648,7 @@ void CollisionShapeSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const P
ss->set_radius(d); ss->set_radius(d);
} }
if (s->cast_to<RayShape>()) { if (Object::cast_to<RayShape>(*s)) {
Ref<RayShape> rs = s; Ref<RayShape> rs = s;
Vector3 ra, rb; Vector3 ra, rb;
@ -1660,7 +1660,7 @@ void CollisionShapeSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const P
rs->set_length(d); rs->set_length(d);
} }
if (s->cast_to<BoxShape>()) { if (Object::cast_to<BoxShape>(*s)) {
Vector3 axis; Vector3 axis;
axis[p_idx] = 1.0; axis[p_idx] = 1.0;
@ -1676,7 +1676,7 @@ void CollisionShapeSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const P
bs->set_extents(he); bs->set_extents(he);
} }
if (s->cast_to<CapsuleShape>()) { if (Object::cast_to<CapsuleShape>(*s)) {
Vector3 axis; Vector3 axis;
axis[p_idx == 0 ? 0 : 2] = 1.0; axis[p_idx == 0 ? 0 : 2] = 1.0;
@ -1700,7 +1700,7 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx, const Variant &p_resto
if (s.is_null()) if (s.is_null())
return; return;
if (s->cast_to<SphereShape>()) { if (Object::cast_to<SphereShape>(*s)) {
Ref<SphereShape> ss = s; Ref<SphereShape> ss = s;
if (p_cancel) { if (p_cancel) {
@ -1715,7 +1715,7 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx, const Variant &p_resto
ur->commit_action(); ur->commit_action();
} }
if (s->cast_to<BoxShape>()) { if (Object::cast_to<BoxShape>(*s)) {
Ref<BoxShape> ss = s; Ref<BoxShape> ss = s;
if (p_cancel) { if (p_cancel) {
@ -1730,7 +1730,7 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx, const Variant &p_resto
ur->commit_action(); ur->commit_action();
} }
if (s->cast_to<CapsuleShape>()) { if (Object::cast_to<CapsuleShape>(*s)) {
Ref<CapsuleShape> ss = s; Ref<CapsuleShape> ss = s;
if (p_cancel) { if (p_cancel) {
@ -1755,7 +1755,7 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx, const Variant &p_resto
ur->commit_action(); ur->commit_action();
} }
if (s->cast_to<RayShape>()) { if (Object::cast_to<RayShape>(*s)) {
Ref<RayShape> ss = s; Ref<RayShape> ss = s;
if (p_cancel) { if (p_cancel) {
@ -1778,7 +1778,7 @@ void CollisionShapeSpatialGizmo::redraw() {
if (s.is_null()) if (s.is_null())
return; return;
if (s->cast_to<SphereShape>()) { if (Object::cast_to<SphereShape>(*s)) {
Ref<SphereShape> sp = s; Ref<SphereShape> sp = s;
float r = sp->get_radius(); float r = sp->get_radius();
@ -1824,7 +1824,7 @@ void CollisionShapeSpatialGizmo::redraw() {
add_handles(handles); add_handles(handles);
} }
if (s->cast_to<BoxShape>()) { if (Object::cast_to<BoxShape>(*s)) {
Ref<BoxShape> bs = s; Ref<BoxShape> bs = s;
Vector<Vector3> lines; Vector<Vector3> lines;
@ -1853,7 +1853,7 @@ void CollisionShapeSpatialGizmo::redraw() {
add_handles(handles); add_handles(handles);
} }
if (s->cast_to<CapsuleShape>()) { if (Object::cast_to<CapsuleShape>(*s)) {
Ref<CapsuleShape> cs = s; Ref<CapsuleShape> cs = s;
float radius = cs->get_radius(); float radius = cs->get_radius();
@ -1928,7 +1928,7 @@ void CollisionShapeSpatialGizmo::redraw() {
add_handles(handles); add_handles(handles);
} }
if (s->cast_to<PlaneShape>()) { if (Object::cast_to<PlaneShape>(*s)) {
Ref<PlaneShape> ps = s; Ref<PlaneShape> ps = s;
Plane p = ps->get_plane(); Plane p = ps->get_plane();
@ -1959,9 +1959,9 @@ void CollisionShapeSpatialGizmo::redraw() {
add_collision_segments(points); add_collision_segments(points);
} }
if (s->cast_to<ConvexPolygonShape>()) { if (Object::cast_to<ConvexPolygonShape>(*s)) {
PoolVector<Vector3> points = s->cast_to<ConvexPolygonShape>()->get_points(); PoolVector<Vector3> points = Object::cast_to<ConvexPolygonShape>(*s)->get_points();
if (points.size() > 3) { if (points.size() > 3) {
@ -1983,7 +1983,7 @@ void CollisionShapeSpatialGizmo::redraw() {
} }
} }
if (s->cast_to<RayShape>()) { if (Object::cast_to<RayShape>(*s)) {
Ref<RayShape> rs = s; Ref<RayShape> rs = s;
@ -3098,133 +3098,133 @@ SpatialEditorGizmos *SpatialEditorGizmos::singleton = NULL;
Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) { Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
if (p_spatial->cast_to<Light>()) { if (Object::cast_to<Light>(p_spatial)) {
Ref<LightSpatialGizmo> lsg = memnew(LightSpatialGizmo(p_spatial->cast_to<Light>())); Ref<LightSpatialGizmo> lsg = memnew(LightSpatialGizmo(Object::cast_to<Light>(p_spatial)));
return lsg; return lsg;
} }
if (p_spatial->cast_to<Camera>()) { if (Object::cast_to<Camera>(p_spatial)) {
Ref<CameraSpatialGizmo> lsg = memnew(CameraSpatialGizmo(p_spatial->cast_to<Camera>())); Ref<CameraSpatialGizmo> lsg = memnew(CameraSpatialGizmo(Object::cast_to<Camera>(p_spatial)));
return lsg; return lsg;
} }
if (p_spatial->cast_to<Skeleton>()) { if (Object::cast_to<Skeleton>(p_spatial)) {
Ref<SkeletonSpatialGizmo> lsg = memnew(SkeletonSpatialGizmo(p_spatial->cast_to<Skeleton>())); Ref<SkeletonSpatialGizmo> lsg = memnew(SkeletonSpatialGizmo(Object::cast_to<Skeleton>(p_spatial)));
return lsg; return lsg;
} }
if (p_spatial->cast_to<Position3D>()) { if (Object::cast_to<Position3D>(p_spatial)) {
Ref<Position3DSpatialGizmo> lsg = memnew(Position3DSpatialGizmo(p_spatial->cast_to<Position3D>())); Ref<Position3DSpatialGizmo> lsg = memnew(Position3DSpatialGizmo(Object::cast_to<Position3D>(p_spatial)));
return lsg; return lsg;
} }
if (p_spatial->cast_to<MeshInstance>()) { if (Object::cast_to<MeshInstance>(p_spatial)) {
Ref<MeshInstanceSpatialGizmo> misg = memnew(MeshInstanceSpatialGizmo(p_spatial->cast_to<MeshInstance>())); Ref<MeshInstanceSpatialGizmo> misg = memnew(MeshInstanceSpatialGizmo(Object::cast_to<MeshInstance>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<Room>()) { if (Object::cast_to<Room>(p_spatial)) {
Ref<RoomSpatialGizmo> misg = memnew(RoomSpatialGizmo(p_spatial->cast_to<Room>())); Ref<RoomSpatialGizmo> misg = memnew(RoomSpatialGizmo(Object::cast_to<Room>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<NavigationMeshInstance>()) { if (Object::cast_to<NavigationMeshInstance>(p_spatial)) {
Ref<NavigationMeshSpatialGizmo> misg = memnew(NavigationMeshSpatialGizmo(p_spatial->cast_to<NavigationMeshInstance>())); Ref<NavigationMeshSpatialGizmo> misg = memnew(NavigationMeshSpatialGizmo(Object::cast_to<NavigationMeshInstance>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<RayCast>()) { if (Object::cast_to<RayCast>(p_spatial)) {
Ref<RayCastSpatialGizmo> misg = memnew(RayCastSpatialGizmo(p_spatial->cast_to<RayCast>())); Ref<RayCastSpatialGizmo> misg = memnew(RayCastSpatialGizmo(Object::cast_to<RayCast>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<Portal>()) { if (Object::cast_to<Portal>(p_spatial)) {
Ref<PortalSpatialGizmo> misg = memnew(PortalSpatialGizmo(p_spatial->cast_to<Portal>())); Ref<PortalSpatialGizmo> misg = memnew(PortalSpatialGizmo(Object::cast_to<Portal>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<CollisionShape>()) { if (Object::cast_to<CollisionShape>(p_spatial)) {
Ref<CollisionShapeSpatialGizmo> misg = memnew(CollisionShapeSpatialGizmo(p_spatial->cast_to<CollisionShape>())); Ref<CollisionShapeSpatialGizmo> misg = memnew(CollisionShapeSpatialGizmo(Object::cast_to<CollisionShape>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<VisibilityNotifier>()) { if (Object::cast_to<VisibilityNotifier>(p_spatial)) {
Ref<VisibilityNotifierGizmo> misg = memnew(VisibilityNotifierGizmo(p_spatial->cast_to<VisibilityNotifier>())); Ref<VisibilityNotifierGizmo> misg = memnew(VisibilityNotifierGizmo(Object::cast_to<VisibilityNotifier>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<Particles>()) { if (Object::cast_to<Particles>(p_spatial)) {
Ref<ParticlesGizmo> misg = memnew(ParticlesGizmo(p_spatial->cast_to<Particles>())); Ref<ParticlesGizmo> misg = memnew(ParticlesGizmo(Object::cast_to<Particles>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<ReflectionProbe>()) { if (Object::cast_to<ReflectionProbe>(p_spatial)) {
Ref<ReflectionProbeGizmo> misg = memnew(ReflectionProbeGizmo(p_spatial->cast_to<ReflectionProbe>())); Ref<ReflectionProbeGizmo> misg = memnew(ReflectionProbeGizmo(Object::cast_to<ReflectionProbe>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<GIProbe>()) { if (Object::cast_to<GIProbe>(p_spatial)) {
Ref<GIProbeGizmo> misg = memnew(GIProbeGizmo(p_spatial->cast_to<GIProbe>())); Ref<GIProbeGizmo> misg = memnew(GIProbeGizmo(Object::cast_to<GIProbe>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<VehicleWheel>()) { if (Object::cast_to<VehicleWheel>(p_spatial)) {
Ref<VehicleWheelSpatialGizmo> misg = memnew(VehicleWheelSpatialGizmo(p_spatial->cast_to<VehicleWheel>())); Ref<VehicleWheelSpatialGizmo> misg = memnew(VehicleWheelSpatialGizmo(Object::cast_to<VehicleWheel>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<PinJoint>()) { if (Object::cast_to<PinJoint>(p_spatial)) {
Ref<PinJointSpatialGizmo> misg = memnew(PinJointSpatialGizmo(p_spatial->cast_to<PinJoint>())); Ref<PinJointSpatialGizmo> misg = memnew(PinJointSpatialGizmo(Object::cast_to<PinJoint>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<HingeJoint>()) { if (Object::cast_to<HingeJoint>(p_spatial)) {
Ref<HingeJointSpatialGizmo> misg = memnew(HingeJointSpatialGizmo(p_spatial->cast_to<HingeJoint>())); Ref<HingeJointSpatialGizmo> misg = memnew(HingeJointSpatialGizmo(Object::cast_to<HingeJoint>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<SliderJoint>()) { if (Object::cast_to<SliderJoint>(p_spatial)) {
Ref<SliderJointSpatialGizmo> misg = memnew(SliderJointSpatialGizmo(p_spatial->cast_to<SliderJoint>())); Ref<SliderJointSpatialGizmo> misg = memnew(SliderJointSpatialGizmo(Object::cast_to<SliderJoint>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<ConeTwistJoint>()) { if (Object::cast_to<ConeTwistJoint>(p_spatial)) {
Ref<ConeTwistJointSpatialGizmo> misg = memnew(ConeTwistJointSpatialGizmo(p_spatial->cast_to<ConeTwistJoint>())); Ref<ConeTwistJointSpatialGizmo> misg = memnew(ConeTwistJointSpatialGizmo(Object::cast_to<ConeTwistJoint>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<Generic6DOFJoint>()) { if (Object::cast_to<Generic6DOFJoint>(p_spatial)) {
Ref<Generic6DOFJointSpatialGizmo> misg = memnew(Generic6DOFJointSpatialGizmo(p_spatial->cast_to<Generic6DOFJoint>())); Ref<Generic6DOFJointSpatialGizmo> misg = memnew(Generic6DOFJointSpatialGizmo(Object::cast_to<Generic6DOFJoint>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<CollisionPolygon>()) { if (Object::cast_to<CollisionPolygon>(p_spatial)) {
Ref<CollisionPolygonSpatialGizmo> misg = memnew(CollisionPolygonSpatialGizmo(p_spatial->cast_to<CollisionPolygon>())); Ref<CollisionPolygonSpatialGizmo> misg = memnew(CollisionPolygonSpatialGizmo(Object::cast_to<CollisionPolygon>(p_spatial)));
return misg; return misg;
} }
if (p_spatial->cast_to<AudioStreamPlayer3D>()) { if (Object::cast_to<AudioStreamPlayer3D>(p_spatial)) {
Ref<AudioStreamPlayer3DSpatialGizmo> misg = memnew(AudioStreamPlayer3DSpatialGizmo(p_spatial->cast_to<AudioStreamPlayer3D>())); Ref<AudioStreamPlayer3DSpatialGizmo> misg = memnew(AudioStreamPlayer3DSpatialGizmo(Object::cast_to<AudioStreamPlayer3D>(p_spatial)));
return misg; return misg;
} }

View file

@ -93,7 +93,7 @@ class EditorSpatialGizmo : public SpatialEditorGizmo {
Vector<Instance> instances; Vector<Instance> instances;
Spatial *spatial_node; Spatial *spatial_node;
void _set_spatial_node(Node *p_node) { set_spatial_node(p_node->cast_to<Spatial>()); } void _set_spatial_node(Node *p_node) { set_spatial_node(Object::cast_to<Spatial>(p_node)); }
protected: protected:
void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false); void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false);

View file

@ -981,7 +981,7 @@ Error Main::setup2() {
if (bool(GLOBAL_DEF("display/window/handheld/emulate_touchscreen", false))) { if (bool(GLOBAL_DEF("display/window/handheld/emulate_touchscreen", false))) {
if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton() && !editor) { if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton() && !editor) {
//only if no touchscreen ui hint, set emulation //only if no touchscreen ui hint, set emulation
InputDefault *id = Input::get_singleton()->cast_to<InputDefault>(); InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());
if (id) if (id)
id->set_emulate_touch(true); id->set_emulate_touch(true);
} }
@ -1181,7 +1181,7 @@ bool Main::start() {
StringName instance_type = script_res->get_instance_base_type(); StringName instance_type = script_res->get_instance_base_type();
Object *obj = ClassDB::instance(instance_type); Object *obj = ClassDB::instance(instance_type);
MainLoop *script_loop = obj ? obj->cast_to<MainLoop>() : NULL; MainLoop *script_loop = Object::cast_to<MainLoop>(obj);
if (!script_loop) { if (!script_loop) {
if (obj) if (obj)
memdelete(obj); memdelete(obj);
@ -1215,7 +1215,7 @@ bool Main::start() {
ERR_FAIL_V(false); ERR_FAIL_V(false);
} }
main_loop = ml->cast_to<MainLoop>(); main_loop = Object::cast_to<MainLoop>(ml);
if (!main_loop) { if (!main_loop) {
memdelete(ml); memdelete(ml);
@ -1227,7 +1227,7 @@ bool Main::start() {
if (main_loop->is_class("SceneTree")) { if (main_loop->is_class("SceneTree")) {
SceneTree *sml = main_loop->cast_to<SceneTree>(); SceneTree *sml = Object::cast_to<SceneTree>(main_loop);
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (debug_collisions) { if (debug_collisions) {
@ -1421,7 +1421,7 @@ bool Main::start() {
ERR_EXPLAIN("Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt)); ERR_EXPLAIN("Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt));
ERR_CONTINUE(obj == NULL); ERR_CONTINUE(obj == NULL);
n = obj->cast_to<Node>(); n = Object::cast_to<Node>(obj);
n->set_script(s.get_ref_ptr()); n->set_script(s.get_ref_ptr());
} }

View file

@ -125,9 +125,7 @@ float Performance::get_monitor(Monitor p_monitor) const {
case OBJECT_NODE_COUNT: { case OBJECT_NODE_COUNT: {
MainLoop *ml = OS::get_singleton()->get_main_loop(); MainLoop *ml = OS::get_singleton()->get_main_loop();
if (!ml) SceneTree *sml = Object::cast_to<SceneTree>(ml);
return 0;
SceneTree *sml = ml->cast_to<SceneTree>();
if (!sml) if (!sml)
return 0; return 0;
return sml->get_node_count(); return sml->get_node_count();

View file

@ -50,7 +50,7 @@ godot_int GDAPI godot_rid_get_id(const godot_rid *p_self) {
} }
void GDAPI godot_rid_new_with_resource(godot_rid *r_dest, const godot_object *p_from) { void GDAPI godot_rid_new_with_resource(godot_rid *r_dest, const godot_object *p_from) {
const Resource *res_from = ((const Object *)p_from)->cast_to<Resource>(); const Resource *res_from = Object::cast_to<Resource>((Object *)p_from);
godot_rid_new(r_dest); godot_rid_new(r_dest);
if (res_from) { if (res_from) {
RID *dest = (RID *)r_dest; RID *dest = (RID *)r_dest;

View file

@ -1971,7 +1971,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
p_script->placeholders.erase(psi); //remove placeholder p_script->placeholders.erase(psi); //remove placeholder
GDInstance *instance = memnew(GDInstance); GDInstance *instance = memnew(GDInstance);
instance->base_ref = E->get()->cast_to<Reference>(); instance->base_ref = Object::cast_to<Reference>(E->get());
instance->members.resize(p_script->member_indices.size()); instance->members.resize(p_script->member_indices.size());
instance->script = Ref<GDScript>(p_script); instance->script = Ref<GDScript>(p_script);
instance->owner = E->get(); instance->owner = E->get();

View file

@ -372,8 +372,8 @@ static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) {
Object *obj = p_variant; Object *obj = p_variant;
if (obj) { if (obj) {
/* /*
if (obj->cast_to<GDNativeClass>()) { if (Object::cast_to<GDNativeClass>(obj)) {
t.obj_type=obj->cast_to<GDNativeClass>()->get_name(); t.obj_type=Object::cast_to<GDNativeClass>(obj)->get_name();
t.value=Variant(); t.value=Variant();
} else { } else {
*/ */
@ -597,8 +597,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
if (id.operator String() == "new" && base.value.get_type() == Variant::OBJECT) { if (id.operator String() == "new" && base.value.get_type() == Variant::OBJECT) {
Object *obj = base.value; Object *obj = base.value;
if (obj && obj->cast_to<GDNativeClass>()) { if (GDNativeClass *gdnc = Object::cast_to<GDNativeClass>(obj)) {
GDNativeClass *gdnc = obj->cast_to<GDNativeClass>();
r_type.type = Variant::OBJECT; r_type.type = Variant::OBJECT;
r_type.value = Variant(); r_type.value = Variant();
r_type.obj_type = gdnc->get_name(); r_type.obj_type = gdnc->get_name();
@ -1495,48 +1494,45 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
if (id.value.get_type()) { if (id.value.get_type()) {
Object *obj = id.value; Object *obj = id.value;
if (obj) { GDScript *scr = Object::cast_to<GDScript>(obj);
if (scr) {
while (scr) {
GDScript *scr = obj->cast_to<GDScript>(); for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
if (scr) { if (E->get()->is_static() && p_method == E->get()->get_name()) {
while (scr) { arghint = "static func " + String(p_method) + "(";
for (int i = 0; i < E->get()->get_argument_count(); i++) {
for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { if (i > 0)
if (E->get()->is_static() && p_method == E->get()->get_name()) { arghint += ", ";
arghint = "static func " + String(p_method) + "("; else
for (int i = 0; i < E->get()->get_argument_count(); i++) { arghint += " ";
if (i > 0) if (i == p_argidx) {
arghint += ", "; arghint += String::chr(0xFFFF);
else }
arghint += " "; arghint += "var " + E->get()->get_argument_name(i);
if (i == p_argidx) { int deffrom = E->get()->get_argument_count() - E->get()->get_default_argument_count();
arghint += String::chr(0xFFFF); if (i >= deffrom) {
} int defidx = deffrom - i;
arghint += "var " + E->get()->get_argument_name(i); if (defidx >= 0 && defidx < E->get()->get_default_argument_count()) {
int deffrom = E->get()->get_argument_count() - E->get()->get_default_argument_count(); arghint += "=" + E->get()->get_default_argument(defidx).get_construct_string();
if (i >= deffrom) {
int defidx = deffrom - i;
if (defidx >= 0 && defidx < E->get()->get_default_argument_count()) {
arghint += "=" + E->get()->get_default_argument(defidx).get_construct_string();
}
}
if (i == p_argidx) {
arghint += String::chr(0xFFFF);
} }
} }
arghint += ")"; if (i == p_argidx) {
return; //found arghint += String::chr(0xFFFF);
}
} }
arghint += ")";
return; //found
} }
if (scr->get_base().is_valid())
scr = scr->get_base().ptr();
else
scr = NULL;
} }
} else {
on_script = obj->get_script(); if (scr->get_base().is_valid())
scr = scr->get_base().ptr();
else
scr = NULL;
} }
} else {
on_script = obj->get_script();
} }
} }
@ -2207,30 +2203,27 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
if (t.value.get_type()) { if (t.value.get_type()) {
Object *obj = t.value; Object *obj = t.value;
if (obj) { GDScript *scr = Object::cast_to<GDScript>(obj);
if (scr) {
while (scr) {
GDScript *scr = obj->cast_to<GDScript>(); if (!isfunction) {
if (scr) { for (const Map<StringName, Variant>::Element *E = scr->get_constants().front(); E; E = E->next()) {
while (scr) { options.insert(E->key());
if (!isfunction) {
for (const Map<StringName, Variant>::Element *E = scr->get_constants().front(); E; E = E->next()) {
options.insert(E->key());
}
} }
for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
if (E->get()->is_static())
options.insert(E->key());
}
if (scr->get_base().is_valid())
scr = scr->get_base().ptr();
else
scr = NULL;
} }
} else { for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
on_script = obj->get_script(); if (E->get()->is_static())
options.insert(E->key());
}
if (scr->get_base().is_valid())
scr = scr->get_base().ptr();
else
scr = NULL;
} }
} else {
on_script = obj->get_script();
} }
} }
@ -2822,9 +2815,9 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
Object *obj = value; Object *obj = value;
if (obj) { if (obj) {
if (obj->cast_to<GDNativeClass>()) { if (Object::cast_to<GDNativeClass>(obj)) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
r_result.class_name = obj->cast_to<GDNativeClass>()->get_name(); r_result.class_name = Object::cast_to<GDNativeClass>(obj)->get_name();
} else { } else {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;

View file

@ -371,7 +371,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
Object *obj_A = *a; Object *obj_A = *a;
Object *obj_B = *b; Object *obj_B = *b;
GDScript *scr_B = obj_B->cast_to<GDScript>(); GDScript *scr_B = Object::cast_to<GDScript>(obj_B);
bool extends_ok = false; bool extends_ok = false;
@ -397,7 +397,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
} else { } else {
GDNativeClass *nc = obj_B->cast_to<GDNativeClass>(); GDNativeClass *nc = Object::cast_to<GDNativeClass>(obj_B);
if (!nc) { if (!nc) {
@ -1434,7 +1434,7 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
// If the return value is a GDFunctionState reference, // If the return value is a GDFunctionState reference,
// then the function did yield again after resuming. // then the function did yield again after resuming.
if (ret.is_ref()) { if (ret.is_ref()) {
GDFunctionState *gdfs = ret.operator Object *()->cast_to<GDFunctionState>(); GDFunctionState *gdfs = Object::cast_to<GDFunctionState>((Object *)&ret);
if (gdfs && gdfs->function == function) if (gdfs && gdfs->function == function)
completed = false; completed = false;
} }
@ -1490,7 +1490,7 @@ Variant GDFunctionState::resume(const Variant &p_arg) {
// If the return value is a GDFunctionState reference, // If the return value is a GDFunctionState reference,
// then the function did yield again after resuming. // then the function did yield again after resuming.
if (ret.is_ref()) { if (ret.is_ref()) {
GDFunctionState *gdfs = ret.operator Object *()->cast_to<GDFunctionState>(); GDFunctionState *gdfs = Object::cast_to<GDFunctionState>((Object *)&ret);
if (gdfs && gdfs->function == function) if (gdfs && gdfs->function == function)
completed = false; completed = false;
} }

View file

@ -3957,7 +3957,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
member._export.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE; member._export.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
if (cn->value.get_type() == Variant::OBJECT) { if (cn->value.get_type() == Variant::OBJECT) {
Object *obj = cn->value; Object *obj = cn->value;
Resource *res = obj->cast_to<Resource>(); Resource *res = Object::cast_to<Resource>(obj);
if (res == NULL) { if (res == NULL) {
_set_error("Exported constant not a type or resource."); _set_error("Exported constant not a type or resource.");
return; return;

View file

@ -73,7 +73,7 @@ Variant GDNativeClass::_new() {
ERR_FAIL_COND_V(!o, Variant()); ERR_FAIL_COND_V(!o, Variant());
} }
Reference *ref = o->cast_to<Reference>(); Reference *ref = Object::cast_to<Reference>(o);
if (ref) { if (ref) {
return REF(ref); return REF(ref);
} else { } else {
@ -161,7 +161,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro
owner = memnew(Reference); //by default, no base means use reference owner = memnew(Reference); //by default, no base means use reference
} }
Reference *r = owner->cast_to<Reference>(); Reference *r = Object::cast_to<Reference>(owner);
if (r) { if (r) {
ref = REF(r); ref = REF(r);
} }
@ -397,7 +397,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
} }
Variant::CallError unchecked_error; Variant::CallError unchecked_error;
return _create_instance(NULL, 0, p_this, p_this->cast_to<Reference>(), unchecked_error); return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this), unchecked_error);
} }
bool GDScript::instance_has(const Object *p_this) const { bool GDScript::instance_has(const Object *p_this) const {
@ -575,9 +575,7 @@ void GDScript::update_exports() {
//print_line("update exports for "+get_path()+" ic: "+itos(copy.size())); //print_line("update exports for "+get_path()+" ic: "+itos(copy.size()));
for (Set<ObjectID>::Element *E = copy.front(); E; E = E->next()) { for (Set<ObjectID>::Element *E = copy.front(); E; E = E->next()) {
Object *id = ObjectDB::get_instance(E->get()); Object *id = ObjectDB::get_instance(E->get());
if (!id) GDScript *s = Object::cast_to<GDScript>(id);
continue;
GDScript *s = id->cast_to<GDScript>();
if (!s) if (!s)
continue; continue;
s->update_exports(); s->update_exports();
@ -2006,11 +2004,11 @@ Error ResourceFormatSaverGDScript::save(const String &p_path, const RES &p_resou
void ResourceFormatSaverGDScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { void ResourceFormatSaverGDScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
if (p_resource->cast_to<GDScript>()) { if (Object::cast_to<GDScript>(*p_resource)) {
p_extensions->push_back("gd"); p_extensions->push_back("gd");
} }
} }
bool ResourceFormatSaverGDScript::recognize(const RES &p_resource) const { bool ResourceFormatSaverGDScript::recognize(const RES &p_resource) const {
return p_resource->cast_to<GDScript>() != NULL; return Object::cast_to<GDScript>(*p_resource) != NULL;
} }

View file

@ -715,12 +715,12 @@ void GridMap::_notification(int p_what) {
Spatial *c = this; Spatial *c = this;
while (c) { while (c) {
navigation = c->cast_to<Navigation>(); navigation = Object::cast_to<Navigation>(c);
if (navigation) { if (navigation) {
break; break;
} }
c = c->get_parent()->cast_to<Spatial>(); c = Object::cast_to<Spatial>(c->get_parent());
} }
if (navigation) { if (navigation) {

View file

@ -806,7 +806,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
_update_selection_transform(); _update_selection_transform();
_update_duplicate_indicator(); _update_duplicate_indicator();
spatial_editor = editor->get_editor_plugin_screen()->cast_to<SpatialEditorPlugin>(); spatial_editor = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen());
if (!node) { if (!node) {
set_process(false); set_process(false);
@ -978,14 +978,14 @@ void GridMapEditor::_notification(int p_what) {
if (lock_view) { if (lock_view) {
EditorNode *editor = get_tree()->get_root()->get_child(0)->cast_to<EditorNode>(); EditorNode *editor = Object::cast_to<EditorNode>(get_tree()->get_root()->get_child(0));
Plane p; Plane p;
p.normal[edit_axis] = 1.0; p.normal[edit_axis] = 1.0;
p.d = edit_floor[edit_axis] * node->get_cell_size(); p.d = edit_floor[edit_axis] * node->get_cell_size();
p = node->get_transform().xform(p); // plane to snap p = node->get_transform().xform(p); // plane to snap
SpatialEditorPlugin *sep = editor->get_editor_plugin_screen()->cast_to<SpatialEditorPlugin>(); SpatialEditorPlugin *sep = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen());
if (sep) if (sep)
sep->snap_cursor_to_plane(p); sep->snap_cursor_to_plane(p);
//editor->get_editor_plugin_screen()->call("snap_cursor_to_plane",p); //editor->get_editor_plugin_screen()->call("snap_cursor_to_plane",p);
@ -1371,7 +1371,7 @@ GridMapEditor::~GridMapEditor() {
void GridMapEditorPlugin::edit(Object *p_object) { void GridMapEditorPlugin::edit(Object *p_object) {
gridmap_editor->edit(p_object ? p_object->cast_to<GridMap>() : NULL); gridmap_editor->edit(Object::cast_to<GridMap>(p_object));
} }
bool GridMapEditorPlugin::handles(Object *p_object) const { bool GridMapEditorPlugin::handles(Object *p_object) const {

Some files were not shown because too many files have changed in this diff Show more