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)
return Variant();
Reference *r = obj->cast_to<Reference>();
Reference *r = Object::cast_to<Reference>(obj);
if (r) {
return REF(r);
} 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);
}
if (obj->cast_to<Reference>()) {
REF ref = REF(obj->cast_to<Reference>());
if (Object::cast_to<Reference>(obj)) {
REF ref = REF(Object::cast_to<Reference>(obj));
r_variant = ref;
} else {
r_variant = obj;

View file

@ -713,7 +713,7 @@ Error ResourceInteractiveLoaderBinary::poll() {
}
ERR_FAIL_COND_V(!obj, ERR_FILE_CORRUPT);
Resource *r = obj->cast_to<Resource>();
Resource *r = Object::cast_to<Resource>(obj);
if (!r) {
error = ERR_FILE_CORRUPT;
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) {
T *instance=p_object->cast_to<T>();
T *instance=Object::cast_to<T>(p_object);
r_error.error=Variant::CallError::CALL_OK;
#ifdef DEBUG_METHODS_ENABLED
@ -57,7 +57,7 @@ public:
#ifdef PTRCALL_ENABLED
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)$ ;
}
#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) {
#ifdef DEBUG_ENABLED
if (cast_to<Reference>()) {
if (Object::cast_to<Reference>(this)) {
ERR_EXPLAIN("Can't 'free' a reference.");
ERR_FAIL();
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;
return Variant();
}
if (cast_to<Reference>()) {
if (Object::cast_to<Reference>(this)) {
r_error.argument = 0;
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
ERR_EXPLAIN("Can't 'free' a reference.");

View file

@ -598,46 +598,6 @@ public:
#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 {
NOTIFICATION_POSTINITIALIZE = 0,

View file

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

View file

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

View file

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

View file

@ -180,7 +180,7 @@ public:
return;
}
Ref r;
r.reference = refb->cast_to<T>();
r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = NULL;
}
@ -194,7 +194,7 @@ public:
return;
}
Ref r;
r.reference = refb->cast_to<T>();
r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = NULL;
}
@ -209,7 +209,7 @@ public:
return;
}
Ref r;
r.reference = refb->cast_to<T>();
r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = NULL;
}
@ -230,7 +230,7 @@ public:
return;
}
Ref r;
r.reference = refb->cast_to<T>();
r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = NULL;
}
@ -254,7 +254,7 @@ public:
return;
}
Ref r;
r.reference = refb->cast_to<T>();
r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = NULL;
}
@ -269,7 +269,7 @@ public:
return;
}
Ref r;
r.reference = refb->cast_to<T>();
r.reference = Object::cast_to<T>(refb);
ref(r);
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());
Operation do_op;
do_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>())
do_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
if (Object::cast_to<Resource>(p_object))
do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
do_op.type = Operation::TYPE_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;
undo_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>())
undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
if (Object::cast_to<Resource>(p_object))
undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
undo_op.type = Operation::TYPE_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());
Operation do_op;
do_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>())
do_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
if (Object::cast_to<Resource>(p_object))
do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
do_op.type = Operation::TYPE_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;
undo_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>())
undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
if (Object::cast_to<Resource>(p_object))
undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
undo_op.type = Operation::TYPE_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());
Operation do_op;
do_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>())
do_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
if (Object::cast_to<Resource>(p_object))
do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
do_op.type = Operation::TYPE_REFERENCE;
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;
undo_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>())
undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
if (Object::cast_to<Resource>(p_object))
undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
undo_op.type = Operation::TYPE_REFERENCE;
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));
#ifdef TOOLS_ENABLED
Resource *res = obj->cast_to<Resource>();
Resource *res = Object::cast_to<Resource>(obj);
if (res)
res->set_edited(true);
@ -284,7 +284,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
obj->set(op.name, op.args[0]);
#ifdef TOOLS_ENABLED
Resource *res = obj->cast_to<Resource>();
Resource *res = Object::cast_to<Resource>(obj);
if (res)
res->set_edited(true);
#endif

View file

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

View file

@ -742,7 +742,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return err;
if (token.type == TK_PARENTHESIS_CLOSE) {
Reference *reference = obj->cast_to<Reference>();
Reference *reference = Object::cast_to<Reference>(obj);
if (reference) {
value = REF(reference);
} 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 {
if (p_resource->cast_to<Texture>()) {
if (Object::cast_to<Texture>(*p_resource)) {
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
ERR_FAIL_COND(history->get_path_size() == 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);

View file

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

View file

@ -664,7 +664,7 @@ void ConnectionsDock::update_tree() {
if (!(c.flags & CONNECT_PERSIST))
continue;
Node *target = c.target->cast_to<Node>();
Node *target = Object::cast_to<Node>(c.target);
if (!target)
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) {
TreeItem *ti = p_item->cast_to<TreeItem>();
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
String fname = ti->get_text(0);
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) {
TreeItem *ti = p_item->cast_to<TreeItem>();
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
String path = ti->get_metadata(0);
dep_edit->edit(path);

View file

@ -376,7 +376,7 @@ void EditorAudioBus::_effect_add(int p_which) {
Object *fx = ClassDB::instance(name);
ERR_FAIL_COND(!fx);
AudioEffect *afx = fx->cast_to<AudioEffect>();
AudioEffect *afx = Object::cast_to<AudioEffect>(fx);
ERR_FAIL_COND(!afx);
Ref<AudioEffect> afxr = Ref<AudioEffect>(afx);
@ -865,7 +865,7 @@ void EditorAudioBuses::_update_sends() {
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();
if (index == 0) {
EditorNode::get_singleton()->show_warning("Master bus can't be deleted!");
@ -922,7 +922,7 @@ void EditorAudioBuses::_request_drop_end() {
drop_end = memnew(EditorAudioBusDrop);
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);
}
}
@ -1158,9 +1158,9 @@ void EditorAudioBuses::open_layout(const String &p_path) {
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()) {
audio_bus_editor->open_layout(path);
}
@ -1169,7 +1169,7 @@ void AudioBusesEditorPlugin::edit(Object *p_node) {
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) {

View file

@ -238,7 +238,7 @@ void EditorAutoloadSettings::_autoload_edited() {
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);

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);
ERR_FAIL_COND(!obj);
Reference *r = obj->cast_to<Reference>();
Reference *r = Object::cast_to<Reference>(obj);
Obj o;
if (r)
o.ref = REF(r);

View file

@ -236,10 +236,7 @@ public:
T *get_node_editor_data(Node *p_node) {
if (!selection.has(p_node))
return NULL;
Object *obj = selection[p_node];
if (!obj)
return NULL;
return obj->cast_to<T>();
return Object::cast_to<T>(selection[p_node]);
}
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) {
TreeItem *item = p_item->cast_to<TreeItem>();
TreeItem *item = Object::cast_to<TreeItem>(p_item);
if (updating || item->is_collapsed())
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
// 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())
sdata->recreate_state();
else
@ -1291,9 +1291,9 @@ void EditorNode::_dialog_action(String p_file) {
uint32_t current = editor_history.get_current();
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);
@ -1428,8 +1428,8 @@ void EditorNode::_prepare_history() {
icon = base_icon;
String text;
if (obj->cast_to<Resource>()) {
Resource *r = obj->cast_to<Resource>();
if (Object::cast_to<Resource>(obj)) {
Resource *r = Object::cast_to<Resource>(obj);
if (r->get_path().is_resource_file())
text = r->get_path().get_file();
else if (r->get_name() != String()) {
@ -1437,8 +1437,8 @@ void EditorNode::_prepare_history() {
} else {
text = r->get_class();
}
} else if (obj->cast_to<Node>()) {
text = obj->cast_to<Node>()->get_name();
} else if (Object::cast_to<Node>(obj)) {
text = Object::cast_to<Node>(obj)->get_name();
} else {
text = obj->get_class();
}
@ -1536,7 +1536,7 @@ void EditorNode::_edit_current() {
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);
scene_tree_dock->set_selected(NULL);
property_editor->edit(current_res);
@ -1548,7 +1548,7 @@ void EditorNode::_edit_current() {
//top_pallete->set_current_tab(1);
} 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->is_inside_tree());
@ -1688,7 +1688,7 @@ void EditorNode::_resource_created() {
Object *c = create_dialog->instance_selected();
ERR_FAIL_COND(!c);
Resource *r = c->cast_to<Resource>();
Resource *r = Object::cast_to<Resource>(c);
ERR_FAIL_COND(!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();
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);
@ -2285,9 +2285,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
uint32_t current = editor_history.get_current();
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);
@ -2297,9 +2297,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
uint32_t current = editor_history.get_current();
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("");
_edit_current();
} break;
@ -2308,9 +2308,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
uint32_t current = editor_history.get_current();
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);
@ -3038,8 +3038,8 @@ void EditorNode::set_edited_scene(Node *p_scene) {
}
get_editor_data().set_edited_scene_root(p_scene);
if (p_scene && p_scene->cast_to<Popup>())
p_scene->cast_to<Popup>()->show(); //show popups
if (Object::cast_to<Popup>(p_scene))
Object::cast_to<Popup>(p_scene)->show(); //show popups
scene_tree_dock->set_edited_scene(p_scene);
if (get_tree())
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();
if (new_scene && new_scene->cast_to<Popup>())
new_scene->cast_to<Popup>()->show(); //show popups
if (Object::cast_to<Popup>(new_scene))
Object::cast_to<Popup>(new_scene)->show(); //show popups
//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)) {
//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()) {
ps->replace_state(sdata->get_state());
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) {
Spatial *s = sp->cast_to<Spatial>();
Spatial *s = Object::cast_to<Spatial>(sp);
if (!s)
return;
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) {
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;
}
@ -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++) {
if (!dock_slot[k]->has_node(name))
continue;
node = dock_slot[k]->get_node(name)->cast_to<Control>();
node = Object::cast_to<Control>(dock_slot[k]->get_node(name));
if (!node)
continue;
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
to_clear.push_back(E->get());
if (!E->get()->cast_to<Texture>())
if (!cast_to<Texture>(E->get().ptr()))
continue;
if (!E->get()->get_path().is_resource_file() && !E->get()->get_path().is_abs_path())
continue;
@ -4926,13 +4926,13 @@ void EditorNode::_dim_timeout() {
void EditorNode::_check_gui_base_size() {
if (gui_base->get_size().width > 1200 * EDSCALE) {
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;
btn->set_text(btn->get_name());
}
} else {
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;
btn->set_text("");
}
@ -5056,7 +5056,7 @@ EditorNode::EditorNode() {
ResourceLoader::clear_translation_remaps(); //no remaps using during editor
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) {

View file

@ -139,9 +139,9 @@ void EditorPath::_notification(int p_what) {
if (left < 0)
continue;
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())
name = r->get_path().get_file();
else
@ -149,11 +149,11 @@ void EditorPath::_notification(int p_what) {
if (name == "")
name = r->get_class();
} else if (obj->cast_to<Node>()) {
} else if (Object::cast_to<Node>(obj)) {
name = obj->cast_to<Node>()->get_name();
} else if (obj->cast_to<Resource>() && obj->cast_to<Resource>()->get_name() != "") {
name = obj->cast_to<Resource>()->get_name();
name = Object::cast_to<Node>(obj)->get_name();
} else if (Object::cast_to<Resource>(obj) && Object::cast_to<Resource>(obj)->get_name() != "") {
name = Object::cast_to<Resource>(obj)->get_name();
} else {
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) {
ERR_FAIL_NULL(p_submenu);
PopupMenu *submenu = p_submenu->cast_to<PopupMenu>();
PopupMenu *submenu = Object::cast_to<PopupMenu>(p_submenu);
ERR_FAIL_NULL(submenu);
//EditorNode::get_singleton()->add_tool_submenu_item(p_name, submenu);
}

View file

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

View file

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

View file

@ -320,7 +320,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
} else {
//mesh since nothing else
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;
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;
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;
@ -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);
MeshInstance *mi = node->cast_to<MeshInstance>();
MeshInstance *mi = Object::cast_to<MeshInstance>(node);
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);
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(!skeleton_bone_map.has(sk), ERR_INVALID_DATA);
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) {
//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) {
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;
}
#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;
@ -203,9 +203,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
}
}
#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();
@ -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
AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>();
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
List<StringName> 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 (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;
@ -269,9 +269,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
str = mi->get_mesh()->get_name();
}
if (p_node->get_parent() && p_node->get_parent()->cast_to<MeshInstance>()) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>();
if (Object::cast_to<MeshInstance>(p_node->get_parent())) {
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance *mip = Object::cast_to<MeshInstance>(p_node->get_parent());
String d = str.substr(str.find("imp") + 3, str.length());
if (d != "") {
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
#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;
@ -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>()) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>();
if (Object::cast_to<MeshInstance>(p_node->get_parent())) {
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance *mip = Object::cast_to<MeshInstance>(p_node->get_parent());
String d=str.substr(str.find("lod")+3,str.length());
if (d!="") {
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;
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)
return p_node;
if (p_node->cast_to<MeshInstance>()) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
if (MeshInstance *mi = Object::cast_to<MeshInstance>(p_node)) {
Node *col = mi->create_trimesh_collision_node();
ERR_FAIL_COND_V(!col, NULL);
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);
memdelete(p_node);
p_node = col;
StaticBody *sb = col->cast_to<StaticBody>();
CollisionShape *colshape = sb->get_child(0)->cast_to<CollisionShape>();
StaticBody *sb = Object::cast_to<StaticBody>(col);
CollisionShape *colshape = Object::cast_to<CollisionShape>(sb->get_child(0));
colshape->set_name("shape");
colshape->set_owner(p_node->get_owner());
} 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);
StaticBody *sb = memnew(StaticBody);
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);
memdelete(p_node);
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);
colshape->set_shape(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") {
PlaneShape *planeShape = memnew(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());
}
} else if (_teststr(name, "rigid") && p_node->cast_to<MeshInstance>()) {
} else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance>(p_node)) {
if (isroot)
return p_node;
// 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();
// 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
col->set_name(_fixstr(name, "rigid"));
// 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
Node *mesh = p_node->duplicate();
mesh->set_name(_fixstr(name, "rigid"));
// 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
p_node->add_child(mesh);
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;
// 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
Ref<BoxShape> shape = memnew(BoxShape);
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);
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"));
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");
p_node->add_child(col);
StaticBody *sb = col->cast_to<StaticBody>();
CollisionShape *colshape = sb->get_child(0)->cast_to<CollisionShape>();
StaticBody *sb = Object::cast_to<StaticBody>(col);
CollisionShape *colshape = Object::cast_to<CollisionShape>(sb->get_child(0));
colshape->set_name("shape");
col->add_child(colshape);
colshape->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)
return p_node;
MeshInstance *mi = p_node->cast_to<MeshInstance>();
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Ref<ArrayMesh> mesh = mi->get_mesh();
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);
nmesh->create_from_mesh(mesh);
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);
memdelete(p_node);
p_node = nmi;
@ -505,7 +504,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
return p_node;
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);
String n = _fixstr(p_node->get_name(), "vehicle");
bv->set_name(n);
@ -525,7 +524,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
return p_node;
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);
String n = _fixstr(p_node->get_name(), "wheel");
bv->set_name(n);
@ -539,12 +538,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
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)
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);
BSP_Tree bsptree(faces);
@ -567,7 +566,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
if (isroot)
return p_node;
Spatial *dummy = p_node->cast_to<Spatial>();
Spatial *dummy = Object::cast_to<Spatial>(p_node);
ERR_FAIL_COND_V(!dummy, NULL);
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();
} else if (_teststr(name, "portal") && p_node->cast_to<MeshInstance>()) {
} else if (_teststr(name, "portal") && Object::cast_to<MeshInstance>(p_node)) {
if (isroot)
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);
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);
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
MeshInstance *mi = p_node->cast_to<MeshInstance>();
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Ref<ArrayMesh> mesh = mi->get_mesh();
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"));
ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>();
AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
ERR_FAIL_COND(!anim);
if (!anim->has_animation("default"))
@ -847,7 +846,7 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) {
return;
Node *n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>();
AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
ERR_FAIL_COND(!anim);
Vector<String> strings = p_text.split("\n");
@ -954,7 +953,7 @@ void ResourceImporterScene::_optimize_animations(Node *scene, float p_max_lin_er
return;
Node *n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>();
AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
ERR_FAIL_COND(!anim);
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"];
if (scene->get_class() != root_type) {
Object *base = ClassDB::instance(root_type);
Node *base_node = NULL;
if (base)
base_node = base->cast_to<Node>();
Node *base_node = base_node = Object::cast_to<Node>(ClassDB::instance(root_type));
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)) {
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()) {

View file

@ -679,7 +679,7 @@ Error EditorSampleImportPlugin::import(const String& p_path, const Ref<ResourceI
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 {
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()) {
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);
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);
}
} 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);
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);
/*
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;
@ -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();
@ -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
AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>();
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
List<StringName> 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;
@ -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>()) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>();
if (Object::cast_to<MeshInstance>(p_node->get_parent())) {
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance *mip = Object::cast_to<MeshInstance>(p_node->get_parent());
String d=str.substr(str.find("imp")+3,str.length());
if (d!="") {
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;
@ -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>()) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>();
if (Object::cast_to<MeshInstance>(p_node->get_parent())) {
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance *mip = Object::cast_to<MeshInstance>(p_node->get_parent());
String d=str.substr(str.find("lod")+3,str.length());
if (d!="") {
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;
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)
return p_node;
if (p_node->cast_to<MeshInstance>() && !is_rigid) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
if (Object::cast_to<MeshInstance>(p_node) && !is_rigid) {
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Node * col = mi->create_trimesh_collision_node();
ERR_FAIL_COND_V(!col,NULL);
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);
memdelete(p_node);
p_node=col;
StaticBody *sb = col->cast_to<StaticBody>();
StaticBody *sb = Object::cast_to<StaticBody>(col);
CollisionShape *colshape = memnew( CollisionShape);
colshape->set_shape(sb->get_shape(0));
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->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);
memdelete(p_node);
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);
colshape->set_shape(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") {
PlaneShape *planeShape = memnew( 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());
}
} 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)
return p_node;
// 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();
// 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
col->set_name(_fixstr(name,"rigid"));
// 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
Node * mesh = p_node->duplicate();
mesh->set_name(_fixstr(name,"rigid"));
// 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
p_node->add_child(mesh);
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;
// 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
Ref<BoxShape> shape = memnew( BoxShape );
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);
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"));
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");
p_node->add_child(col);
StaticBody *sb=col->cast_to<StaticBody>();
StaticBody *sb=Object::cast_to<StaticBody>(col);
CollisionShape *colshape = memnew( CollisionShape);
colshape->set_shape(sb->get_shape(0));
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());
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)
return p_node;
MeshInstance *mi = p_node->cast_to<MeshInstance>();
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Ref<Mesh> mesh=mi->get_mesh();
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);
nmesh->create_from_mesh(mesh);
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);
memdelete(p_node);
p_node=nmi;
@ -1867,7 +1867,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
return p_node;
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 );
String n = _fixstr(p_node->get_name(),"vehicle");
bv->set_name(n);
@ -1888,7 +1888,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
return p_node;
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 );
String n = _fixstr(p_node->get_name(),"wheel");
bv->set_name(n);
@ -1902,13 +1902,13 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
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)
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);
@ -1933,7 +1933,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
if (isroot)
return p_node;
Spatial *dummy = p_node->cast_to<Spatial>();
Spatial *dummy = Object::cast_to<Spatial>(p_node);
ERR_FAIL_COND_V(!dummy,NULL);
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();
} 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)
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);
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);
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
MeshInstance *mi = p_node->cast_to<MeshInstance>();
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Ref<Mesh> mesh = mi->get_mesh();
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);
p_node->set_import_path( path );
Spatial *snode=p_node->cast_to<Spatial>();
Spatial *snode=Object::cast_to<Spatial>(p_node);
if (snode) {
@ -2200,10 +2200,7 @@ Error EditorSceneImportPlugin::import1(const Ref<ResourceImportMetadata>& p_from
if (from->has_option("root_type")) {
String type = from->get_option("root_type");
Object *base = ClassDB::instance(type);
Node *base_node = NULL;
if (base)
base_node=base->cast_to<Node>();
Node *base_node = Object::cast_to<Node>(ClassDB::instance(type));
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"));
ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>();
AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
ERR_FAIL_COND(!anim);
if (!anim->has_animation("default"))
@ -2357,7 +2354,7 @@ void EditorSceneImportPlugin::_filter_tracks(Node *scene, const String& p_text)
return;
Node* n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>();
AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
ERR_FAIL_COND(!anim);
Vector<String> strings = p_text.split("\n");
@ -2475,7 +2472,7 @@ void EditorSceneImportPlugin::_optimize_animations(Node *scene, float p_max_lin_
return;
Node* n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>();
AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
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);
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;
ap->get_animation_list(&anims);
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>()) {
MeshInstance *mi=node->cast_to<MeshInstance>();
if (p_merge_material && Object::cast_to<MeshInstance>(node)) {
MeshInstance *mi=Object::cast_to<MeshInstance>(node);
Ref<Mesh> mesh = mi->get_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);
if (node->cast_to<AnimationPlayer>()) {
if (AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(node)) {
AnimationPlayer *ap = node->cast_to<AnimationPlayer>();
List<StringName> anims;
ap->get_animation_list(&anims);
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>()) {
MeshInstance *mi=node->cast_to<MeshInstance>();
if (MeshInstance *mi=Object::cast_to<MeshInstance>(node)) {
Ref<Mesh> mesh = mi->get_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! ");
} else if (state.bones.has(id)) {
if (p_base)
node=p_base->cast_to<Spatial>();
node=Object::cast_to<Spatial>(p_base);
if (!state.bones[id].has_anim_chan) {
print_line("no has anim "+id);
}

View file

@ -703,7 +703,7 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin*
VBoxContainer *source_vb=memnew(VBoxContainer);
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 );
source_vb->add_child(hbc);
@ -733,7 +733,7 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin*
size->set_value(256);
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 );
@ -1326,7 +1326,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
if (ResourceCache::has(apath)) {
at = Ref<AtlasTexture>( ResourceCache::get(apath)->cast_to<AtlasTexture>() );
at = Ref<AtlasTexture>( Object::cast_to<AtlasTexture>(ResourceCache::get(apath)) );
} else {
at = Ref<AtlasTexture>( memnew( AtlasTexture ) );
@ -1340,7 +1340,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
}
}
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 {
texture = Ref<ImageTexture>( memnew( ImageTexture ) );
}
@ -1354,7 +1354,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
if (ResourceCache::has(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;
Error err = img.load(src_path);

View file

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

View file

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

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

View file

@ -337,7 +337,7 @@ BakedLightEditor::~BakedLightEditor() {
void BakedLightEditorPlugin::edit(Object *p_object) {
baked_light_editor->edit(p_object->cast_to<BakedLightInstance>());
baked_light_editor->edit(Object::cast_to<BakedLightInstance>(p_object));
}
bool BakedLightEditorPlugin::handles(Object *p_object) const {

View file

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

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()) {
Node2D *n2d = E->get()->cast_to<Node2D>();
Node2D *n2d = Object::cast_to<Node2D>(E->get());
if (n2d && n2d->edit_has_pivot()) {
Vector2 offset = n2d->edit_get_pivot();
@ -190,7 +190,7 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) {
undo_redo->add_undo_method(n2d, "set_global_position", gpos);
undo_redo->add_undo_method(n2d, "edit_set_pivot", offset);
for (int i = 0; i < n2d->get_child_count(); i++) {
Node2D *n2dc = n2d->get_child(i)->cast_to<Node2D>();
Node2D *n2dc = Object::cast_to<Node2D>(n2d->get_child(i));
if (!n2dc)
continue;
@ -199,7 +199,7 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) {
}
}
Control *cnt = E->get()->cast_to<Control>();
Control *cnt = Object::cast_to<Control>(E->get());
if (cnt) {
Vector2 old_pivot = cnt->get_pivot_offset();
@ -265,7 +265,7 @@ void CanvasItemEditor::_tool_select(int p_index) {
Object *CanvasItemEditor::_get_editor_data(Object *p_what) {
CanvasItem *ci = p_what->cast_to<CanvasItem>();
CanvasItem *ci = Object::cast_to<CanvasItem>(p_what);
if (!ci)
return NULL;
@ -413,7 +413,7 @@ void CanvasItemEditor::_visibility_changed(ObjectID p_canvas_item) {
Object *c = ObjectDB::get_instance(p_canvas_item);
if (!c)
return;
CanvasItem *ct = c->cast_to<CanvasItem>();
CanvasItem *ct = Object::cast_to<CanvasItem>(c);
if (!ct)
return;
canvas_items.erase(ct);
@ -451,17 +451,17 @@ bool CanvasItemEditor::_is_part_of_subscene(CanvasItem *p_item) {
void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items, unsigned int limit) {
if (!p_node)
return;
if (p_node->cast_to<Viewport>())
if (Object::cast_to<Viewport>(p_node))
return;
CanvasItem *c = p_node->cast_to<CanvasItem>();
CanvasItem *c = Object::cast_to<CanvasItem>(p_node);
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
if (c && !c->is_set_as_toplevel())
_find_canvas_items_at_pos(p_pos, p_node->get_child(i), p_parent_xform * c->get_transform(), p_canvas_xform, r_items);
else {
CanvasLayer *cl = p_node->cast_to<CanvasLayer>();
CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
_find_canvas_items_at_pos(p_pos, p_node->get_child(i), transform, cl ? cl->get_transform() : p_canvas_xform, r_items); //use base transform
}
@ -469,13 +469,13 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
return;
}
if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) {
if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !Object::cast_to<CanvasLayer>(c)) {
Rect2 rect = c->get_item_rect();
Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos);
if (rect.has_point(local_pos)) {
Node2D *node = c->cast_to<Node2D>();
Node2D *node = Object::cast_to<Node2D>(c);
_SelectResult res;
res.item = c;
@ -492,10 +492,10 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_n
if (!p_node)
return;
if (p_node->cast_to<Viewport>())
if (Object::cast_to<Viewport>(p_node))
return;
CanvasItem *c = p_node->cast_to<CanvasItem>();
CanvasItem *c = Object::cast_to<CanvasItem>(p_node);
bool inherited = p_node != get_tree()->get_edited_scene_root() && p_node->get_filename() != "";
bool editable = false;
@ -509,13 +509,13 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_n
if (c && !c->is_set_as_toplevel())
_find_canvas_items_at_rect(p_rect, p_node->get_child(i), p_parent_xform * c->get_transform(), p_canvas_xform, r_items);
else {
CanvasLayer *cl = p_node->cast_to<CanvasLayer>();
CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
_find_canvas_items_at_rect(p_rect, p_node->get_child(i), transform, cl ? cl->get_transform() : p_canvas_xform, r_items);
}
}
}
if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) {
if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !Object::cast_to<CanvasLayer>(c)) {
Rect2 rect = c->get_item_rect();
Transform2D xform = p_parent_xform * p_canvas_xform * c->get_transform();
@ -590,7 +590,7 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@ -619,7 +619,7 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE
} else { // p_move_mode==MOVE_LOCAL_BASE || p_move_mode==MOVE_LOCAL_WITH_ROT
if (Node2D *node_2d = canvas_item->cast_to<Node2D>()) {
if (Node2D *node_2d = Object::cast_to<Node2D>(canvas_item)) {
if (p_move_mode == MOVE_LOCAL_WITH_ROT) {
Transform2D m;
@ -628,7 +628,7 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE
}
node_2d->set_position(node_2d->get_position() + drag);
} else if (Control *control = canvas_item->cast_to<Control>()) {
} else if (Control *control = Object::cast_to<Control>(canvas_item)) {
control->set_position(control->get_position() + drag);
}
@ -648,7 +648,7 @@ Point2 CanvasItemEditor::_find_topleftmost_point() {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@ -673,7 +673,7 @@ int CanvasItemEditor::get_item_count() {
int ic = 0;
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@ -694,7 +694,7 @@ CanvasItem *CanvasItemEditor::get_single_item() {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@ -822,7 +822,7 @@ CanvasItemEditor::DragType CanvasItemEditor::_get_anchor_handle_drag_type(const
CanvasItem *canvas_item = get_single_item();
ERR_FAIL_COND_V(!canvas_item, DRAG_NONE);
Control *control = canvas_item->cast_to<Control>();
Control *control = Object::cast_to<Control>(canvas_item);
ERR_FAIL_COND_V(!control, DRAG_NONE);
Vector2 anchor_pos[4];
@ -865,7 +865,7 @@ void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@ -876,15 +876,15 @@ void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) {
continue;
se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>())
se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
if (canvas_item->cast_to<Control>())
se->undo_pivot = canvas_item->cast_to<Control>()->get_pivot_offset();
if (Object::cast_to<Node2D>(canvas_item))
se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
if (Object::cast_to<Control>(canvas_item))
se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
}
if (selection.size() == 1 && selection[0]->cast_to<Node2D>()) {
if (selection.size() == 1 && Object::cast_to<Node2D>(selection[0])) {
drag = DRAG_NODE_2D;
drag_point_from = selection[0]->cast_to<Node2D>()->get_global_position();
drag_point_from = Object::cast_to<Node2D>(selection[0])->get_global_position();
} else {
drag = DRAG_ALL;
drag_point_from = _find_topleftmost_point();
@ -1169,7 +1169,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@ -1180,10 +1180,10 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
continue;
canvas_item->edit_set_state(se->undo_state);
if (canvas_item->cast_to<Node2D>())
canvas_item->cast_to<Node2D>()->edit_set_pivot(se->undo_pivot);
if (canvas_item->cast_to<Control>())
canvas_item->cast_to<Control>()->set_pivot_offset(se->undo_pivot);
if (Object::cast_to<Node2D>(canvas_item))
Object::cast_to<Node2D>(canvas_item)->edit_set_pivot(se->undo_pivot);
if (Object::cast_to<Control>(canvas_item))
Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot);
}
}
@ -1251,7 +1251,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@ -1265,13 +1265,13 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
undo_redo->add_do_method(canvas_item, "edit_set_state", state);
undo_redo->add_undo_method(canvas_item, "edit_set_state", se->undo_state);
{
Node2D *pvt = canvas_item->cast_to<Node2D>();
Node2D *pvt = Object::cast_to<Node2D>(canvas_item);
if (pvt && pvt->edit_has_pivot()) {
undo_redo->add_do_method(canvas_item, "edit_set_pivot", pvt->edit_get_pivot());
undo_redo->add_undo_method(canvas_item, "edit_set_pivot", se->undo_pivot);
}
Control *cnt = canvas_item->cast_to<Control>();
Control *cnt = Object::cast_to<Control>(canvas_item);
if (cnt) {
undo_redo->add_do_method(canvas_item, "set_pivot_offset", cnt->get_pivot_offset());
undo_redo->add_undo_method(canvas_item, "set_pivot_offset", se->undo_pivot);
@ -1341,10 +1341,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
if (Cbone) {
Node2D *b = NULL;
Object *obj = ObjectDB::get_instance(Cbone->get().bone);
if (obj)
b = obj->cast_to<Node2D>();
Node2D *b = Object::cast_to<Node2D>(ObjectDB::get_instance(Cbone->get().bone));
if (b) {
@ -1359,7 +1356,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
break;
float len = pi->get_global_transform().get_origin().distance_to(b->get_global_position());
b = pi->cast_to<Node2D>();
b = Object::cast_to<Node2D>(pi);
if (!b)
break;
@ -1405,10 +1402,10 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
drag = DRAG_ROTATE;
drag_from = transform.affine_inverse().xform(click);
se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>())
se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
if (canvas_item->cast_to<Control>())
se->undo_pivot = canvas_item->cast_to<Control>()->get_pivot_offset();
if (Object::cast_to<Node2D>(canvas_item))
se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
if (Object::cast_to<Control>(canvas_item))
se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
return;
}
@ -1426,15 +1423,15 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
if (drag != DRAG_NONE) {
drag_from = transform.affine_inverse().xform(click);
se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>())
se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
if (canvas_item->cast_to<Control>())
se->undo_pivot = canvas_item->cast_to<Control>()->get_pivot_offset();
if (Object::cast_to<Node2D>(canvas_item))
se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot();
if (Object::cast_to<Control>(canvas_item))
se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
return;
}
// Drag anchor handles
if (canvas_item->cast_to<Control>()) {
if (Object::cast_to<Control>(canvas_item)) {
drag = _get_anchor_handle_drag_type(click, drag_point_from);
if (drag != DRAG_NONE) {
drag_from = transform.affine_inverse().xform(click);
@ -1457,9 +1454,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
CanvasItem *c = NULL;
if (Cbone) {
Object *obj = ObjectDB::get_instance(Cbone->get().bone);
if (obj)
c = obj->cast_to<CanvasItem>();
c = Object::cast_to<CanvasItem>(ObjectDB::get_instance(Cbone->get().bone));
if (c)
c = c->get_parent_item();
}
@ -1489,7 +1484,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
};
if (n) {
c = n->cast_to<CanvasItem>();
c = Object::cast_to<CanvasItem>(n);
} else {
c = NULL;
}
@ -1537,7 +1532,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@ -1551,10 +1546,10 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
if (!dragging_bone) {
canvas_item->edit_set_state(se->undo_state); //reset state and reapply
if (canvas_item->cast_to<Node2D>())
canvas_item->cast_to<Node2D>()->edit_set_pivot(se->undo_pivot);
if (canvas_item->cast_to<Control>())
canvas_item->cast_to<Control>()->set_pivot_offset(se->undo_pivot);
if (Object::cast_to<Node2D>(canvas_item))
Object::cast_to<Node2D>(canvas_item)->edit_set_pivot(se->undo_pivot);
if (Object::cast_to<Control>(canvas_item))
Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot);
}
Vector2 dfrom = drag_from;
@ -1566,7 +1561,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
// Rotate the node
Vector2 center = canvas_item->get_global_transform_with_canvas().get_origin();
{
Node2D *node = canvas_item->cast_to<Node2D>();
Node2D *node = Object::cast_to<Node2D>(canvas_item);
if (node) {
real_t angle = node->get_rotation();
@ -1578,7 +1573,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
{
Control *node = canvas_item->cast_to<Control>();
Control *node = Object::cast_to<Control>(canvas_item);
if (node) {
real_t angle = node->get_rotation();
@ -1592,7 +1587,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
continue;
}
Control *control = canvas_item->cast_to<Control>();
Control *control = Object::cast_to<Control>(canvas_item);
if (control) {
// Drag and snap the anchor
Vector2 anchor = _position_to_anchor(control, canvas_item->get_global_transform_with_canvas().affine_inverse().xform(dto - drag_from + drag_point_from));
@ -1728,19 +1723,19 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
case DRAG_PIVOT:
if (canvas_item->cast_to<Node2D>()) {
Node2D *n2d = canvas_item->cast_to<Node2D>();
if (Object::cast_to<Node2D>(canvas_item)) {
Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
n2d->edit_set_pivot(se->undo_pivot + drag_vector);
}
if (canvas_item->cast_to<Control>()) {
canvas_item->cast_to<Control>()->set_pivot_offset(se->undo_pivot + drag_vector);
if (Object::cast_to<Control>(canvas_item)) {
Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot + drag_vector);
}
continue;
break;
case DRAG_NODE_2D:
ERR_FAIL_COND(!canvas_item->cast_to<Node2D>());
canvas_item->cast_to<Node2D>()->set_global_position(dto);
ERR_FAIL_COND(!Object::cast_to<Node2D>(canvas_item));
Object::cast_to<Node2D>(canvas_item)->set_global_position(dto);
continue;
break;
}
@ -1754,7 +1749,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
} else {
//ok, all that had to be done was done, now solve IK
Node2D *n2d = canvas_item->cast_to<Node2D>();
Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
Transform2D final_xform = bone_orig_xform;
if (n2d) {
@ -1981,7 +1976,7 @@ void CanvasItemEditor::_viewport_draw() {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
@ -2013,16 +2008,16 @@ void CanvasItemEditor::_viewport_draw() {
if (single && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks
if (canvas_item->cast_to<Node2D>()) {
if (Object::cast_to<Node2D>(canvas_item)) {
if (canvas_item->cast_to<Node2D>()->edit_has_pivot()) {
if (Object::cast_to<Node2D>(canvas_item)->edit_has_pivot()) {
viewport->draw_texture(pivot, xform.get_origin() + (-pivot->get_size() / 2).floor());
can_move_pivot = true;
pivot_found = true;
}
}
Control *control = canvas_item->cast_to<Control>();
Control *control = Object::cast_to<Control>(canvas_item);
if (control) {
Vector2 pivot_ofs = control->get_pivot_offset();
if (pivot_ofs != Vector2()) {
@ -2214,11 +2209,7 @@ void CanvasItemEditor::_viewport_draw() {
E->get().from = Vector2();
E->get().to = Vector2();
Object *obj = ObjectDB::get_instance(E->get().bone);
if (!obj)
continue;
Node2D *n2d = obj->cast_to<Node2D>();
Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E->get().bone));
if (!n2d)
continue;
@ -2227,7 +2218,7 @@ void CanvasItemEditor::_viewport_draw() {
CanvasItem *pi = n2d->get_parent_item();
Node2D *pn2d = n2d->get_parent()->cast_to<Node2D>();
Node2D *pn2d = Object::cast_to<Node2D>(n2d->get_parent());
if (!pn2d)
continue;
@ -2283,14 +2274,14 @@ void CanvasItemEditor::_notification(int p_what) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
if (canvas_item->cast_to<Control>())
if (Object::cast_to<Control>(canvas_item))
has_control = true;
else
all_control = false;
@ -2304,12 +2295,12 @@ void CanvasItemEditor::_notification(int p_what) {
float anchors[4];
Vector2 pivot;
if (canvas_item->cast_to<Control>()) {
pivot = canvas_item->cast_to<Control>()->get_pivot_offset();
anchors[MARGIN_LEFT] = canvas_item->cast_to<Control>()->get_anchor(MARGIN_LEFT);
anchors[MARGIN_RIGHT] = canvas_item->cast_to<Control>()->get_anchor(MARGIN_RIGHT);
anchors[MARGIN_TOP] = canvas_item->cast_to<Control>()->get_anchor(MARGIN_TOP);
anchors[MARGIN_BOTTOM] = canvas_item->cast_to<Control>()->get_anchor(MARGIN_BOTTOM);
if (Object::cast_to<Control>(canvas_item)) {
pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset();
anchors[MARGIN_LEFT] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_LEFT);
anchors[MARGIN_RIGHT] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_RIGHT);
anchors[MARGIN_TOP] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_TOP);
anchors[MARGIN_BOTTOM] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_BOTTOM);
}
if (r != se->prev_rect || xform != se->prev_xform || pivot != se->prev_pivot || anchors[MARGIN_LEFT] != se->prev_anchors[MARGIN_LEFT] || anchors[MARGIN_RIGHT] != se->prev_anchors[MARGIN_RIGHT] || anchors[MARGIN_TOP] != se->prev_anchors[MARGIN_TOP] || anchors[MARGIN_BOTTOM] != se->prev_anchors[MARGIN_BOTTOM]) {
@ -2338,7 +2329,7 @@ void CanvasItemEditor::_notification(int p_what) {
break;
}
Node2D *b2 = b->cast_to<Node2D>();
Node2D *b2 = Object::cast_to<Node2D>(b);
if (!b2) {
continue;
}
@ -2426,7 +2417,7 @@ void CanvasItemEditor::_find_canvas_items_span(Node *p_node, Rect2 &r_rect, cons
if (!p_node)
return;
CanvasItem *c = p_node->cast_to<CanvasItem>();
CanvasItem *c = Object::cast_to<CanvasItem>(p_node);
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
@ -2587,7 +2578,7 @@ void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) {
undo_redo->create_action(TTR("Change Anchors"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Control *c = E->get()->cast_to<Control>();
Control *c = Object::cast_to<Control>(E->get());
undo_redo->add_do_method(c, "set_anchors_preset", p_preset);
undo_redo->add_undo_method(c, "set_anchor", MARGIN_LEFT, c->get_anchor(MARGIN_LEFT));
@ -2605,7 +2596,7 @@ void CanvasItemEditor::_set_full_rect() {
undo_redo->create_action(TTR("Change Anchors"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Control *c = E->get()->cast_to<Control>();
Control *c = Object::cast_to<Control>(E->get());
undo_redo->add_do_method(c, "set_anchors_preset", PRESET_WIDE);
undo_redo->add_do_method(c, "set_margin", MARGIN_LEFT, 0);
@ -2713,7 +2704,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@ -2731,7 +2722,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@ -2751,7 +2742,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@ -2769,7 +2760,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@ -2888,15 +2879,15 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
if (canvas_item->cast_to<Node2D>()) {
Node2D *n2d = canvas_item->cast_to<Node2D>();
if (Object::cast_to<Node2D>(canvas_item)) {
Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
if (key_pos)
AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "position", n2d->get_position(), existing);
@ -2909,7 +2900,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
//look for an IK chain
List<Node2D *> ik_chain;
Node2D *n = n2d->get_parent_item()->cast_to<Node2D>();
Node2D *n = Object::cast_to<Node2D>(n2d->get_parent_item());
bool has_chain = false;
while (n) {
@ -2922,7 +2913,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!n->get_parent_item())
break;
n = n->get_parent_item()->cast_to<Node2D>();
n = Object::cast_to<Node2D>(n->get_parent_item());
}
if (has_chain && ik_chain.size()) {
@ -2939,9 +2930,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
}
}
} else if (canvas_item->cast_to<Control>()) {
} else if (Object::cast_to<Control>(canvas_item)) {
Control *ctrl = canvas_item->cast_to<Control>();
Control *ctrl = Object::cast_to<Control>(canvas_item);
if (key_pos)
AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_position", ctrl->get_position(), existing);
@ -2998,16 +2989,16 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
if (canvas_item->cast_to<Node2D>()) {
if (Object::cast_to<Node2D>(canvas_item)) {
Node2D *n2d = canvas_item->cast_to<Node2D>();
Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
PoseClipboard pc;
pc.pos = n2d->get_position();
pc.rot = n2d->get_rotation();
@ -3026,10 +3017,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
undo_redo->create_action(TTR("Paste Pose"));
for (List<PoseClipboard>::Element *E = pose_clipboard.front(); E; E = E->next()) {
Object *o = ObjectDB::get_instance(E->get().id);
if (!o)
continue;
Node2D *n2d = o->cast_to<Node2D>();
Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E->get().id));
if (!n2d)
continue;
undo_redo->add_do_method(n2d, "set_position", E->get().pos);
@ -3048,15 +3036,15 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
if (canvas_item->cast_to<Node2D>()) {
Node2D *n2d = canvas_item->cast_to<Node2D>();
if (Object::cast_to<Node2D>(canvas_item)) {
Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
if (key_pos)
n2d->set_position(Vector2());
@ -3064,9 +3052,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
n2d->set_rotation(0);
if (key_scale)
n2d->set_scale(Vector2(1, 1));
} else if (canvas_item->cast_to<Control>()) {
} else if (Object::cast_to<Control>(canvas_item)) {
Control *ctrl = canvas_item->cast_to<Control>();
Control *ctrl = Object::cast_to<Control>(canvas_item);
if (key_pos)
ctrl->set_position(Point2());
@ -3090,7 +3078,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
Node2D *n2d = E->key()->cast_to<Node2D>();
Node2D *n2d = Object::cast_to<Node2D>(E->key());
if (!n2d)
continue;
if (!n2d->is_visible_in_tree())
@ -3111,7 +3099,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
Node2D *n2d = E->key()->cast_to<Node2D>();
Node2D *n2d = Object::cast_to<Node2D>(E->key());
if (!n2d)
continue;
if (!n2d->is_visible_in_tree())
@ -3130,7 +3118,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
@ -3151,7 +3139,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *n2d = E->key()->cast_to<CanvasItem>();
CanvasItem *n2d = Object::cast_to<CanvasItem>(E->key());
if (!n2d)
continue;
if (!n2d->is_visible_in_tree())
@ -3202,7 +3190,7 @@ void CanvasItemEditor::_focus_selection(int p_op) {
Map<Node *, Object *> &selection = editor_selection->get_selection();
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
if (!canvas_item) continue;
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
@ -3302,7 +3290,7 @@ void CanvasItemEditor::box_selection_start( Point2 &click ) {
bool CanvasItemEditor::box_selection_end() {
print_line( "box selection end" );
Node* scene = get_scene()->get_root_node()->cast_to<EditorNode>()->get_edited_scene();
Node* scene = Object::cast_to<EditorNode>(get_scene()->get_root_node())->get_edited_scene();
if (scene) {
List<CanvasItem*> selitems;
@ -3651,7 +3639,7 @@ CanvasItemEditor *CanvasItemEditor::singleton = NULL;
void CanvasItemEditorPlugin::edit(Object *p_object) {
canvas_item_editor->set_undo_redo(&get_undo_redo());
canvas_item_editor->edit(p_object->cast_to<CanvasItem>());
canvas_item_editor->edit(Object::cast_to<CanvasItem>(p_object));
}
bool CanvasItemEditorPlugin::handles(Object *p_object) const {
@ -3704,7 +3692,7 @@ void CanvasItemEditorViewport::_on_mouse_exit() {
}
void CanvasItemEditorViewport::_on_select_type(Object *selected) {
CheckBox *check = selected->cast_to<CheckBox>();
CheckBox *check = Object::cast_to<CheckBox>(selected);
String type = check->get_text();
selector_label->set_text(vformat(TTR("Add %s"), type));
label->set_text(vformat(TTR("Adding %s..."), type));
@ -3714,7 +3702,7 @@ void CanvasItemEditorViewport::_on_change_type() {
if (!button_group->get_pressed_button())
return;
CheckBox *check = button_group->get_pressed_button()->cast_to<CheckBox>();
CheckBox *check = Object::cast_to<CheckBox>(button_group->get_pressed_button());
default_type = check->get_text();
_perform_drop_data();
selector->hide();
@ -3726,8 +3714,8 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
for (int i = 0; i < files.size(); i++) {
String path = files[i];
RES res = ResourceLoader::load(path);
Ref<Texture> texture = Ref<Texture>(res->cast_to<Texture>());
Ref<PackedScene> scene = Ref<PackedScene>(res->cast_to<PackedScene>());
Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
if (texture != NULL || scene != NULL) {
if (texture != NULL) {
Sprite *sprite = memnew(Sprite);
@ -3778,7 +3766,7 @@ bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String &p_targe
void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point) {
child->set_name(path.get_file().get_basename());
Ref<Texture> texture = Ref<Texture>(ResourceCache::get(path)->cast_to<Texture>());
Ref<Texture> texture = Object::cast_to<Texture>(Ref<Texture>(ResourceCache::get(path)).ptr());
Size2 texture_size = texture->get_size();
editor_data->get_undo_redo().add_do_method(parent, "add_child", child);
@ -3867,11 +3855,11 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
Point2 pos;
Node2D *parent_node2d = parent->cast_to<Node2D>();
Node2D *parent_node2d = Object::cast_to<Node2D>(parent);
if (parent_node2d) {
pos = parent_node2d->get_global_position();
} else {
Control *parent_control = parent->cast_to<Control>();
Control *parent_control = Object::cast_to<Control>(parent);
if (parent_control) {
pos = parent_control->get_global_position();
}
@ -3879,7 +3867,7 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons
Transform2D trans = canvas->get_canvas_transform();
Vector2 target_pos = (p_point - trans.get_origin()) / trans.get_scale().x - pos;
// in relative snapping it may be useful for the user to take the original node position into account
Vector2 start_pos = instanced_scene->cast_to<Node2D>() ? instanced_scene->cast_to<Node2D>()->get_position() : target_pos;
Vector2 start_pos = Object::cast_to<Node2D>(instanced_scene) ? Object::cast_to<Node2D>(instanced_scene)->get_position() : target_pos;
target_pos = canvas->snap_point(target_pos, start_pos);
editor_data->get_undo_redo().add_do_method(instanced_scene, "set_position", target_pos);
@ -3899,8 +3887,8 @@ void CanvasItemEditorViewport::_perform_drop_data() {
if (res.is_null()) {
continue;
}
Ref<Texture> texture = Ref<Texture>(res->cast_to<Texture>());
Ref<PackedScene> scene = Ref<PackedScene>(res->cast_to<PackedScene>());
Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
if (texture != NULL) {
Node *child;
if (default_type == "Light2D")
@ -4016,7 +4004,7 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
button_group->get_buttons(&btn_list);
for (int i = 0; i < btn_list.size(); i++) {
CheckBox *check = btn_list[i]->cast_to<CheckBox>();
CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]);
check->set_pressed(check->get_text() == default_type);
}
selector_label->set_text(vformat(TTR("Add %s"), default_type));

View file

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

View file

@ -464,7 +464,7 @@ void CollisionPolygonEditor::edit(Node *p_collision_polygon) {
if (p_collision_polygon) {
node = p_collision_polygon->cast_to<CollisionPolygon>();
node = Object::cast_to<CollisionPolygon>(p_collision_polygon);
wip.clear();
wip_active = false;
edited_point = -1;
@ -555,7 +555,7 @@ CollisionPolygonEditor::~CollisionPolygonEditor() {
void CollisionPolygonEditorPlugin::edit(Object *p_object) {
collision_polygon_editor->edit(p_object->cast_to<Node>());
collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
}
bool CollisionPolygonEditorPlugin::handles(Object *p_object) const {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -189,7 +189,7 @@ void Line2DEditor::edit(Node *p_line2d) {
canvas_item_editor = CanvasItemEditor::get_singleton();
if (p_line2d) {
node = p_line2d->cast_to<Line2D>();
node = Object::cast_to<Line2D>(p_line2d);
if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
if (!node->is_connected("visibility_changed", this, "_node_visibility_changed"))
@ -276,7 +276,7 @@ Line2DEditor::Line2DEditor(EditorNode *p_editor) {
//----------------------------------------------------------------------------
void Line2DEditorPlugin::edit(Object *p_object) {
line2d_editor->edit(p_object->cast_to<Node>());
line2d_editor->edit(Object::cast_to<Node>(p_object));
}
bool Line2DEditorPlugin::handles(Object *p_object) const {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -534,7 +534,7 @@ void Path2DEditor::edit(Node *p_path2d) {
if (p_path2d) {
node = p_path2d->cast_to<Path2D>();
node = Object::cast_to<Path2D>(p_path2d);
if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
if (!node->is_connected("visibility_changed", this, "_node_visibility_changed"))
@ -676,7 +676,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) {
void Path2DEditorPlugin::edit(Object *p_object) {
path2d_editor->edit(p_object->cast_to<Node>());
path2d_editor->edit(Object::cast_to<Node>(p_object));
}
bool Path2DEditorPlugin::handles(Object *p_object) const {

View file

@ -269,9 +269,9 @@ PathSpatialGizmo::PathSpatialGizmo(Path *p_path) {
Ref<SpatialEditorGizmo> PathEditorPlugin::create_spatial_gizmo(Spatial *p_spatial) {
if (p_spatial->cast_to<Path>()) {
if (Object::cast_to<Path>(p_spatial)) {
return memnew(PathSpatialGizmo(p_spatial->cast_to<Path>()));
return memnew(PathSpatialGizmo(Object::cast_to<Path>(p_spatial)));
}
return Ref<SpatialEditorGizmo>();
@ -433,7 +433,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp
void PathEditorPlugin::edit(Object *p_object) {
if (p_object) {
path = p_object->cast_to<Path>();
path = Object::cast_to<Path>(p_object);
if (path) {
if (path->get_curve().is_valid()) {
@ -447,7 +447,7 @@ void PathEditorPlugin::edit(Object *p_object) {
pre->get_curve()->emit_signal("changed");
}
}
//collision_polygon_editor->edit(p_object->cast_to<Node>());
//collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
}
bool PathEditorPlugin::handles(Object *p_object) const {

View file

@ -697,7 +697,7 @@ void Polygon2DEditor::edit(Node *p_collision_polygon) {
if (p_collision_polygon) {
node = p_collision_polygon->cast_to<Polygon2D>();
node = Object::cast_to<Polygon2D>(p_collision_polygon);
if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
@ -925,7 +925,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) {
void Polygon2DEditorPlugin::edit(Object *p_object) {
collision_polygon_editor->edit(p_object->cast_to<Node>());
collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
}
bool Polygon2DEditorPlugin::handles(Object *p_object) const {

View file

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

View file

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

View file

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

View file

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

View file

@ -152,7 +152,7 @@ SamplePlayerEditor::SamplePlayerEditor() {
void SamplePlayerEditorPlugin::edit(Object *p_object) {
sample_player_editor->edit(p_object->cast_to<Node>());
sample_player_editor->edit(Object::cast_to<Node>(p_object));
}
bool SamplePlayerEditorPlugin::handles(Object *p_object) const {

View file

@ -256,7 +256,7 @@ ScriptEditor *ScriptEditor::script_editor = NULL;
String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) {
//ScriptEditorBase *se=_se->cast_to<ScriptEditorBase>();
//ScriptEditorBase *se=Object::cast_to<ScriptEditorBase>(_se);
String val = debugger->get_var_value(p_text);
if (val != String()) {
@ -280,7 +280,7 @@ void ScriptEditor::_breaked(bool p_breaked, bool p_can_debug) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
continue;
@ -305,7 +305,7 @@ void ScriptEditor::_goto_script_line2(int p_line) {
if (selected < 0 || selected >= tab_container->get_child_count())
return;
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (!current)
return;
@ -318,7 +318,7 @@ void ScriptEditor::_goto_script_line(REF p_script, int p_line) {
if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
Ref<Script> script = p_script->cast_to<Script>();
Ref<Script> script = Object::cast_to<Script>(*p_script);
if (!script.is_null() && script->get_path().is_resource_file())
edit(p_script, p_line, 0);
}
@ -327,7 +327,7 @@ void ScriptEditor::_goto_script_line(REF p_script, int p_line) {
if (selected < 0 || selected >= tab_container->get_child_count())
return;
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (!current)
return;
@ -346,13 +346,13 @@ void ScriptEditor::_save_history() {
Node *n = tab_container->get_current_tab_control();
if (n->cast_to<ScriptEditorBase>()) {
if (Object::cast_to<ScriptEditorBase>(n)) {
history[history_pos].state = n->cast_to<ScriptEditorBase>()->get_edit_state();
history[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state();
}
if (n->cast_to<EditorHelp>()) {
if (Object::cast_to<EditorHelp>(n)) {
history[history_pos].state = n->cast_to<EditorHelp>()->get_scroll();
history[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
}
}
@ -369,10 +369,7 @@ void ScriptEditor::_save_history() {
void ScriptEditor::_go_to_tab(int p_idx) {
Node *cn = tab_container->get_child(p_idx);
if (!cn)
return;
Control *c = cn->cast_to<Control>();
Control *c = Object::cast_to<Control>(tab_container->get_child(p_idx));
if (!c)
return;
@ -380,13 +377,13 @@ void ScriptEditor::_go_to_tab(int p_idx) {
Node *n = tab_container->get_current_tab_control();
if (n->cast_to<ScriptEditorBase>()) {
if (Object::cast_to<ScriptEditorBase>(n)) {
history[history_pos].state = n->cast_to<ScriptEditorBase>()->get_edit_state();
history[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state();
}
if (n->cast_to<EditorHelp>()) {
if (Object::cast_to<EditorHelp>(n)) {
history[history_pos].state = n->cast_to<EditorHelp>()->get_scroll();
history[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
}
}
@ -402,21 +399,21 @@ void ScriptEditor::_go_to_tab(int p_idx) {
c = tab_container->get_current_tab_control();
if (c->cast_to<ScriptEditorBase>()) {
if (Object::cast_to<ScriptEditorBase>(c)) {
script_name_label->set_text(c->cast_to<ScriptEditorBase>()->get_name());
script_icon->set_texture(c->cast_to<ScriptEditorBase>()->get_icon());
script_name_label->set_text(Object::cast_to<ScriptEditorBase>(c)->get_name());
script_icon->set_texture(Object::cast_to<ScriptEditorBase>(c)->get_icon());
if (is_visible_in_tree())
c->cast_to<ScriptEditorBase>()->ensure_focus();
Object::cast_to<ScriptEditorBase>(c)->ensure_focus();
notify_script_changed(c->cast_to<ScriptEditorBase>()->get_edited_script());
notify_script_changed(Object::cast_to<ScriptEditorBase>(c)->get_edited_script());
}
if (c->cast_to<EditorHelp>()) {
if (Object::cast_to<EditorHelp>(c)) {
script_name_label->set_text(c->cast_to<EditorHelp>()->get_class());
script_name_label->set_text(Object::cast_to<EditorHelp>(c)->get_class());
script_icon->set_texture(get_icon("Help", "EditorIcons"));
if (is_visible_in_tree())
c->cast_to<EditorHelp>()->set_focused();
Object::cast_to<EditorHelp>(c)->set_focused();
}
c->set_meta("__editor_pass", ++edit_pass);
@ -508,7 +505,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) {
return;
Node *tselected = tab_container->get_child(selected);
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (current) {
_add_recent_script(current->get_edited_script()->get_path());
if (p_save) {
@ -517,7 +514,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) {
current->clear_edit_menu();
notify_script_close(current->get_edited_script());
} else {
EditorHelp *help = tab_container->get_child(selected)->cast_to<EditorHelp>();
EditorHelp *help = Object::cast_to<EditorHelp>(tab_container->get_child(selected));
_add_recent_script(help->get_class());
}
@ -575,7 +572,7 @@ void ScriptEditor::_close_docs_tab() {
int child_count = tab_container->get_child_count();
for (int i = child_count - 1; i >= 0; i--) {
EditorHelp *se = tab_container->get_child(i)->cast_to<EditorHelp>();
EditorHelp *se = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (se) {
_close_tab(i);
@ -589,7 +586,7 @@ void ScriptEditor::_close_all_tabs() {
for (int i = child_count - 1; i >= 0; i--) {
tab_container->set_current_tab(i);
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
@ -615,7 +612,7 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
@ -647,7 +644,7 @@ void ScriptEditor::_reload_scripts() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
continue;
@ -684,7 +681,7 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
continue;
@ -727,7 +724,7 @@ bool ScriptEditor::_test_script_times_on_disk(Ref<Script> p_for_script) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
Ref<Script> script = se->get_edited_script();
@ -791,7 +788,7 @@ Ref<Script> ScriptEditor::_get_current_script() {
if (selected < 0 || selected >= tab_container->get_child_count())
return NULL;
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (current) {
return current->get_edited_script();
} else {
@ -865,7 +862,7 @@ void ScriptEditor::_menu_option(int p_option) {
String current;
if (tab_container->get_tab_count() > 0) {
EditorHelp *eh = tab_container->get_child(tab_container->get_current_tab())->cast_to<EditorHelp>();
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(tab_container->get_current_tab()));
if (eh) {
current = eh->get_class();
}
@ -919,7 +916,7 @@ void ScriptEditor::_menu_option(int p_option) {
if (selected < 0 || selected >= tab_container->get_child_count())
return;
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (current) {
switch (p_option) {
@ -956,7 +953,7 @@ void ScriptEditor::_menu_option(int p_option) {
current->convert_indent_to_tabs();
}
}
editor->push_item(current->get_edited_script()->cast_to<Object>());
editor->push_item(Object::cast_to<Object>(current->get_edited_script().ptr()));
editor->save_resource_as(current->get_edited_script());
} break;
@ -1035,7 +1032,7 @@ void ScriptEditor::_menu_option(int p_option) {
}
} else {
EditorHelp *help = tab_container->get_current_tab_control()->cast_to<EditorHelp>();
EditorHelp *help = Object::cast_to<EditorHelp>(tab_container->get_current_tab_control());
if (help) {
switch (p_option) {
@ -1139,7 +1136,7 @@ bool ScriptEditor::can_take_away_focus() const {
if (selected < 0 || selected >= tab_container->get_child_count())
return true;
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (!current)
return true;
@ -1150,7 +1147,7 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
@ -1205,7 +1202,7 @@ Dictionary ScriptEditor::get_state() const {
for(int i=0;i<tab_container->get_child_count();i++) {
ScriptTextEditor *se = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
ScriptTextEditor *se = Object::cast_to<ScriptTextEditor>(tab_container->get_child(i));
if (!se)
continue;
@ -1281,7 +1278,7 @@ void ScriptEditor::clear() {
List<ScriptTextEditor*> stes;
for(int i=0;i<tab_container->get_child_count();i++) {
ScriptTextEditor *se = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
ScriptTextEditor *se = Object::cast_to<ScriptTextEditor>(tab_container->get_child(i));
if (!se)
continue;
stes.push_back(se);
@ -1309,7 +1306,7 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
@ -1335,10 +1332,8 @@ void ScriptEditor::ensure_focus_current() {
if (cidx < 0 || cidx >= tab_container->get_tab_count())
return;
Control *c = tab_container->get_child(cidx)->cast_to<Control>();
if (!c)
return;
ScriptEditorBase *se = c->cast_to<ScriptEditorBase>();
Control *c = Object::cast_to<Control>(tab_container->get_child(cidx));
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(c);
if (!se)
return;
se->ensure_focus();
@ -1346,7 +1341,7 @@ void ScriptEditor::ensure_focus_current() {
void ScriptEditor::_members_overview_selected(int p_idx) {
Node *current = tab_container->get_child(tab_container->get_current_tab());
ScriptEditorBase *se = current->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(current);
if (!se) {
return;
}
@ -1368,7 +1363,7 @@ void ScriptEditor::ensure_select_current() {
Node *current = tab_container->get_child(tab_container->get_current_tab());
ScriptEditorBase *se = current->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(current);
if (se) {
Ref<Script> script = se->get_edited_script();
@ -1380,7 +1375,7 @@ void ScriptEditor::ensure_select_current() {
//search_menu->show();
}
EditorHelp *eh = current->cast_to<EditorHelp>();
EditorHelp *eh = Object::cast_to<EditorHelp>(current);
if (eh) {
//edit_menu->hide();
@ -1430,7 +1425,7 @@ void ScriptEditor::_update_members_overview_visibility() {
return;
Node *current = tab_container->get_child(tab_container->get_current_tab());
ScriptEditorBase *se = current->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(current);
if (!se) {
members_overview->set_visible(false);
return;
@ -1451,7 +1446,7 @@ void ScriptEditor::_update_members_overview() {
return;
Node *current = tab_container->get_child(tab_container->get_current_tab());
ScriptEditorBase *se = current->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(current);
if (!se) {
return;
}
@ -1525,7 +1520,7 @@ void ScriptEditor::_update_script_names() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
String name = se->get_name();
@ -1568,7 +1563,7 @@ void ScriptEditor::_update_script_names() {
sedata.push_back(sd);
}
EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>();
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh) {
String name = eh->get_class();
@ -1663,7 +1658,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
@ -1733,7 +1728,7 @@ void ScriptEditor::save_all_scripts() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
@ -1771,7 +1766,7 @@ void ScriptEditor::apply_scripts() const {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
se->apply_code();
@ -1802,7 +1797,7 @@ void ScriptEditor::_editor_stop() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
continue;
@ -1823,7 +1818,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
if (se->get_edited_script() != script)
@ -1874,7 +1869,7 @@ void ScriptEditor::_editor_settings_changed() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
@ -1977,7 +1972,7 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
String path = se->get_edited_script()->get_path();
@ -1987,7 +1982,7 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
scripts.push_back(path);
}
EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>();
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh) {
@ -2007,7 +2002,7 @@ void ScriptEditor::_help_class_open(const String &p_class) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>();
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh && eh->get_class() == p_class) {
@ -2034,7 +2029,7 @@ void ScriptEditor::_help_class_goto(const String &p_desc) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>();
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh && eh->get_class() == cname) {
@ -2062,7 +2057,7 @@ void ScriptEditor::_update_selected_editor_menu() {
bool current = tab_container->get_current_tab() == i;
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se && se->get_edit_menu()) {
if (current)
@ -2072,10 +2067,7 @@ void ScriptEditor::_update_selected_editor_menu() {
}
}
EditorHelp *eh = NULL;
if (tab_container->get_current_tab_control())
eh = tab_container->get_current_tab_control()->cast_to<EditorHelp>();
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_current_tab_control());
if (eh) {
script_search_menu->show();
} else {
@ -2087,13 +2079,13 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
Node *n = tab_container->get_current_tab_control();
if (n->cast_to<ScriptEditorBase>()) {
if (Object::cast_to<ScriptEditorBase>(n)) {
history[history_pos].state = n->cast_to<ScriptEditorBase>()->get_edit_state();
history[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state();
}
if (n->cast_to<EditorHelp>()) {
if (Object::cast_to<EditorHelp>(n)) {
history[history_pos].state = n->cast_to<EditorHelp>()->get_scroll();
history[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
}
history_pos = p_new_pos;
@ -2101,18 +2093,18 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
n = history[history_pos].control;
if (n->cast_to<ScriptEditorBase>()) {
if (Object::cast_to<ScriptEditorBase>(n)) {
n->cast_to<ScriptEditorBase>()->set_edit_state(history[history_pos].state);
n->cast_to<ScriptEditorBase>()->ensure_focus();
Object::cast_to<ScriptEditorBase>(n)->set_edit_state(history[history_pos].state);
Object::cast_to<ScriptEditorBase>(n)->ensure_focus();
notify_script_changed(n->cast_to<ScriptEditorBase>()->get_edited_script());
notify_script_changed(Object::cast_to<ScriptEditorBase>(n)->get_edited_script());
}
if (n->cast_to<EditorHelp>()) {
if (Object::cast_to<EditorHelp>(n)) {
n->cast_to<EditorHelp>()->set_scroll(history[history_pos].state);
n->cast_to<EditorHelp>()->set_focused();
Object::cast_to<EditorHelp>(n)->set_scroll(history[history_pos].state);
Object::cast_to<EditorHelp>(n)->set_focused();
}
n->set_meta("__editor_pass", ++edit_pass);
@ -2140,7 +2132,7 @@ Vector<Ref<Script> > ScriptEditor::get_open_scripts() const {
Vector<Ref<Script> > out_scripts = Vector<Ref<Script> >();
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
out_scripts.push_back(se->get_edited_script());
@ -2510,17 +2502,17 @@ ScriptEditor::~ScriptEditor() {
void ScriptEditorPlugin::edit(Object *p_object) {
if (!p_object->cast_to<Script>())
if (!Object::cast_to<Script>(p_object))
return;
script_editor->edit(p_object->cast_to<Script>());
script_editor->edit(Object::cast_to<Script>(p_object));
}
bool ScriptEditorPlugin::handles(Object *p_object) const {
if (p_object->cast_to<Script>()) {
if (Object::cast_to<Script>(p_object)) {
bool valid = _can_open_in_editor(p_object->cast_to<Script>());
bool valid = _can_open_in_editor(Object::cast_to<Script>(p_object));
if (!valid) { //user tried to open it by clicking
EditorNode::get_singleton()->show_warning(TTR("Built-in scripts can only be edited when the scene they belong to is loaded"));

View file

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

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){
ToolButton *tb = p_button->cast_to<ToolButton>();
ToolButton *tb = Object::cast_to<ToolButton>(p_button);
ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size());
edited_id=p_id;
@ -850,7 +850,7 @@ void ShaderGraphView::_xform_input_changed(int p_id, Node *p_button){
}
void ShaderGraphView::_xform_const_changed(int p_id, Node *p_button){
ToolButton *tb = p_button->cast_to<ToolButton>();
ToolButton *tb = Object::cast_to<ToolButton>(p_button);
ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size());
edited_id=p_id;
@ -964,7 +964,7 @@ void ShaderGraphView::_variant_edited() {
void ShaderGraphView::_comment_edited(int p_id,Node* p_button) {
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
TextEdit *te=p_button->cast_to<TextEdit>();
TextEdit *te=Object::cast_to<TextEdit>(p_button);
ur->create_action(TTR("Change Comment"),UndoRedo::MERGE_ENDS);
ur->add_do_method(graph.ptr(),"comment_node_set_text",type,p_id,te->get_text());
ur->add_undo_method(graph.ptr(),"comment_node_set_text",type,p_id,graph->comment_node_get_text(type,p_id));
@ -978,7 +978,7 @@ void ShaderGraphView::_comment_edited(int p_id,Node* p_button) {
void ShaderGraphView::_color_ramp_changed(int p_id,Node* p_ramp) {
GraphColorRampEdit *cr=p_ramp->cast_to<GraphColorRampEdit>();
GraphColorRampEdit *cr=Object::cast_to<GraphColorRampEdit>(p_ramp);
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
@ -1020,7 +1020,7 @@ void ShaderGraphView::_color_ramp_changed(int p_id,Node* p_ramp) {
void ShaderGraphView::_curve_changed(int p_id,Node* p_curve) {
GraphCurveMapEdit *cr=p_curve->cast_to<GraphCurveMapEdit>();
GraphCurveMapEdit *cr=Object::cast_to<GraphCurveMapEdit>(p_curve);
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
@ -1057,7 +1057,7 @@ void ShaderGraphView::_curve_changed(int p_id,Node* p_curve) {
void ShaderGraphView::_input_name_changed(const String& p_name, int p_id, Node *p_line_edit) {
LineEdit *le=p_line_edit->cast_to<LineEdit>();
LineEdit *le=Object::cast_to<LineEdit>(p_line_edit);
ERR_FAIL_COND(!le);
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
@ -1074,7 +1074,7 @@ void ShaderGraphView::_input_name_changed(const String& p_name, int p_id, Node *
void ShaderGraphView::_tex_edited(int p_id,Node* p_button) {
ToolButton *tb = p_button->cast_to<ToolButton>();
ToolButton *tb = Object::cast_to<ToolButton>(p_button);
ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size());
edited_id=p_id;
@ -1084,7 +1084,7 @@ void ShaderGraphView::_tex_edited(int p_id,Node* p_button) {
void ShaderGraphView::_cube_edited(int p_id,Node* p_button) {
ToolButton *tb = p_button->cast_to<ToolButton>();
ToolButton *tb = Object::cast_to<ToolButton>(p_button);
ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size());
edited_id=p_id;
@ -1299,7 +1299,7 @@ void ShaderGraphView::_delete_nodes_request()
void ShaderGraphView::_default_changed(int p_id, Node *p_button, int p_param, int v_type, String p_hint)
{
ToolButton *tb = p_button->cast_to<ToolButton>();
ToolButton *tb = Object::cast_to<ToolButton>(p_button);
ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size());
edited_id=p_id;
@ -2530,7 +2530,7 @@ void ShaderGraphView::_sg_updated() {
Variant ShaderGraphView::get_drag_data_fw(const Point2 &p_point, Control *p_from)
{
TextureRect* frame = p_from->cast_to<TextureRect>();
TextureRect* frame = Object::cast_to<TextureRect>(p_from);
if (!frame)
return Variant();
@ -2556,7 +2556,7 @@ bool ShaderGraphView::can_drop_data_fw(const Point2 &p_point, const Variant &p_d
if (val.get_type()==Variant::OBJECT) {
RES res = val;
if (res.is_valid() && res->cast_to<Texture>())
if (res.is_valid() && Object::cast_to<Texture>(res))
return true;
}
}
@ -2576,7 +2576,7 @@ void ShaderGraphView::drop_data_fw(const Point2 &p_point, const Variant &p_data,
if (!can_drop_data_fw(p_point, p_data, p_from))
return;
TextureRect *frame = p_from->cast_to<TextureRect>();
TextureRect *frame = Object::cast_to<TextureRect>(p_from);
if (!frame)
return;
@ -2590,20 +2590,20 @@ void ShaderGraphView::drop_data_fw(const Point2 &p_point, const Variant &p_data,
if (val.get_type()==Variant::OBJECT) {
RES res = val;
if (res.is_valid())
tex = Ref<Texture>(res->cast_to<Texture>());
tex = Ref<Texture>(Object::cast_to<Texture>(*res));
}
}
else if (d["type"] == "files" && d.has("files")) {
Vector<String> files = d["files"];
RES res = ResourceLoader::load(files[0]);
if (res.is_valid())
tex = Ref<Texture>(res->cast_to<Texture>());
tex = Ref<Texture>(Object::cast_to<Texture>(*res));
}
}
if (!tex.is_valid()) return;
GraphNode *gn = frame->get_parent()->cast_to<GraphNode>();
GraphNode *gn = Object::cast_to<GraphNode>(frame->get_parent());
if (!gn) return;
int id = -1;
@ -2896,12 +2896,12 @@ ShaderGraphEditor::ShaderGraphEditor(bool p_2d) {
void ShaderGraphEditorPlugin::edit(Object *p_object) {
shader_editor->edit(p_object->cast_to<ShaderGraph>());
shader_editor->edit(Object::cast_to<ShaderGraph>(p_object));
}
bool ShaderGraphEditorPlugin::handles(Object *p_object) const {
ShaderGraph *shader=p_object->cast_to<ShaderGraph>();
ShaderGraph *shader=Object::cast_to<ShaderGraph>(p_object);
if (!shader)
return false;
if (_2d)

View file

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

View file

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

View file

@ -100,7 +100,7 @@ StreamEditor::StreamEditor() {
void StreamEditorPlugin::edit(Object *p_object) {
stream_editor->edit(p_object->cast_to<Node>());
stream_editor->edit(Object::cast_to<Node>(p_object));
}
bool StreamEditorPlugin::handles(Object *p_object) const {

View file

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

View file

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

View file

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

View file

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

View file

@ -1329,7 +1329,7 @@ void TileMapEditor::edit(Node *p_tile_map) {
node->disconnect("settings_changed", this, "_tileset_settings_changed");
if (p_tile_map) {
node = p_tile_map->cast_to<TileMap>();
node = Object::cast_to<TileMap>(p_tile_map);
if (!canvas_item_editor->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->connect("draw", this, "_canvas_draw");
if (!canvas_item_editor->is_connected("mouse_entered", this, "_canvas_mouse_enter"))
@ -1407,7 +1407,7 @@ TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i &p_pos) {
void TileMapEditor::_update_transform_buttons(Object *p_button) {
//ERR_FAIL_NULL(p_button);
ToolButton *b = p_button->cast_to<ToolButton>();
ToolButton *b = Object::cast_to<ToolButton>(p_button);
//ERR_FAIL_COND(!b);
if (b == rotate_0) {
@ -1582,7 +1582,7 @@ TileMapEditor::~TileMapEditor() {
void TileMapEditorPlugin::edit(Object *p_object) {
tile_map_editor->edit(p_object->cast_to<Node>());
tile_map_editor->edit(Object::cast_to<Node>(p_object));
}
bool TileMapEditorPlugin::handles(Object *p_object) const {

View file

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

View file

@ -475,7 +475,7 @@ void ProjectManager::_notification(int p_what) {
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"));
@ -487,7 +487,7 @@ void ProjectManager::_panel_draw(Node *p_hb) {
void ProjectManager::_update_project_buttons() {
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();
}
@ -509,7 +509,7 @@ void ProjectManager::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
int clicked_id = -1;
int last_clicked_id = -1;
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->get_meta("name") == clicked) 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 max = clicked_id > last_clicked_id ? clicked_id : last_clicked_id;
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 (i != clicked_id && (i < min || i > max) && !mb->get_control()) {
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++) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
if (hb) {
selected_list.clear();
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--) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
if (hb) {
selected_list.clear();
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--) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
if (!hb) continue;
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++) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
if (!hb) continue;
String current = hb->get_meta("name");
@ -885,8 +885,8 @@ void ProjectManager::_load_recent_projects() {
void ProjectManager::_on_project_created(const String &dir) {
bool has_already = false;
for (int i = 0; i < scroll_childs->get_child_count(); i++) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
Label *fpath = hb->get_node(NodePath("project/path"))->cast_to<Label>();
HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path")));
if (fpath->get_text() == dir) {
has_already = true;
break;
@ -903,8 +903,8 @@ void ProjectManager::_on_project_created(const String &dir) {
void ProjectManager::_update_scroll_pos(const String &dir) {
for (int i = 0; i < scroll_childs->get_child_count(); i++) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
Label *fpath = hb->get_node(NodePath("project/path"))->cast_to<Label>();
HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_childs->get_child(i));
Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path")));
if (fpath->get_text() == dir) {
last_clicked = hb->get_meta("name");
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) {
TreeItem *ti = p_obj->cast_to<TreeItem>();
TreeItem *ti = Object::cast_to<TreeItem>(p_obj);
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) {
TreeItem *ti = p_item->cast_to<TreeItem>();
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti);
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");
TreeItem *k = p_item->cast_to<TreeItem>();
TreeItem *k = Object::cast_to<TreeItem>(p_item);
String key = k->get_metadata(0);
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();
ERR_FAIL_COND(!k);
TreeItem *ed = p_item->cast_to<TreeItem>();
TreeItem *ed = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ed);
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);
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());
@ -215,8 +215,8 @@ void CustomPropertyEditor::_menu_option(int p_which) {
} break;
case OBJ_MENU_NEW_SCRIPT: {
if (owner->cast_to<Node>())
EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(owner->cast_to<Node>());
if (Object::cast_to<Node>(owner))
EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(owner));
} break;
case OBJ_MENU_SHOW_IN_FILE_SYSTEM: {
@ -243,7 +243,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
Object *obj = ClassDB::instance(intype);
ERR_BREAK(!obj);
Resource *res = obj->cast_to<Resource>();
Resource *res = Object::cast_to<Resource>(obj);
ERR_BREAK(!res);
if (owner && hint == PROPERTY_HINT_RESOURCE_TYPE && hint_text == "Script") {
//make visual script the right type
@ -593,8 +593,8 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
MAKE_PROPSELECT
Object *obj = ObjectDB::get_instance(hint_text.to_int64());
if (obj && obj->cast_to<Script>()) {
property_select->select_method_from_script(obj->cast_to<Script>(), v);
if (Object::cast_to<Script>(obj)) {
property_select->select_method_from_script(Object::cast_to<Script>(obj), v);
}
updating = false;
@ -641,8 +641,8 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
MAKE_PROPSELECT
Object *obj = ObjectDB::get_instance(hint_text.to_int64());
if (obj && obj->cast_to<Script>()) {
property_select->select_property_from_script(obj->cast_to<Script>(), v);
if (Object::cast_to<Script>(obj)) {
property_select->select_property_from_script(Object::cast_to<Script>(obj), v);
}
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("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"));
config_action_buttons(names);
@ -878,7 +878,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
menu->clear();
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_separator();
} else if (hint_text != "") {
@ -1104,7 +1104,7 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
ERR_FAIL_COND(!obj);
Resource *res = obj->cast_to<Resource>();
Resource *res = Object::cast_to<Resource>(obj);
ERR_FAIL_COND(!res);
v = Ref<Resource>(res).get_ref_ptr();
@ -1124,7 +1124,7 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) {
if (picking_viewport) {
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!");
return;
}
@ -1154,9 +1154,9 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) {
Node *node = NULL;
if (owner->is_class("Node"))
node = owner->cast_to<Node>();
node = Object::cast_to<Node>(owner);
else if (owner->is_class("ArrayPropertyEdit"))
node = owner->cast_to<ArrayPropertyEdit>()->get_node();
node = Object::cast_to<ArrayPropertyEdit>(owner)->get_node();
if (!node) {
v = p_path;
@ -1276,9 +1276,9 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
hide();
} 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_scene_tree_dock()->set_selected(target_node);
}
@ -1299,7 +1299,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
Object *obj = ClassDB::instance(intype);
ERR_BREAK(!obj);
Resource *res = obj->cast_to<Resource>();
Resource *res = Object::cast_to<Resource>(obj);
ERR_BREAK(!res);
v = Ref<Resource>(res).get_ref_ptr();
@ -2017,7 +2017,7 @@ bool PropertyEditor::_might_be_in_instance() {
if (!obj)
return false;
Node *node = obj->cast_to<Node>();
Node *node = Object::cast_to<Node>(obj);
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) {
Node *node = obj->cast_to<Node>();
Node *node = Object::cast_to<Node>(obj);
if (!node)
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) {
{
Node *node = obj->cast_to<Node>();
Node *node = Object::cast_to<Node>(obj);
if (!node)
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);
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
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"))
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(1,false);
}
@ -2919,7 +2919,7 @@ void PropertyEditor::update_tree() {
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();
if (nod && es != nod && nod->get_owner() != es) {
draw_red = true;
@ -3742,7 +3742,7 @@ void PropertyEditor::update_tree() {
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)
return;
@ -3763,7 +3763,7 @@ void PropertyEditor::_item_folded(Object *item_obj) {
if (updating_folding)
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());
}
@ -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);
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);
} 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);
emit_signal(_prop_edited, p_name);
} 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);
}
Resource *r = obj->cast_to<Resource>();
Resource *r = Object::cast_to<Resource>(obj);
if (r) {
if (!r->is_edited() && String(p_name) != "resource/edited") {
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) {
TreeItem *ti = p_item->cast_to<TreeItem>();
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti);
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) {
TreeItem *ti = p_item->cast_to<TreeItem>();
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti);
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) {
TreeItem *ti = p_object->cast_to<TreeItem>();
TreeItem *ti = Object::cast_to<TreeItem>(p_object);
if (!ti)
return;
@ -4268,7 +4268,7 @@ void PropertyEditor::_resource_preview_done(const String &p_path, const Ref<Text
if (!obj)
return;
TreeItem *ti = obj->cast_to<TreeItem>();
TreeItem *ti = Object::cast_to<TreeItem>(obj);
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) {
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)
search_box->connect("text_changed", this, "_filter_changed");

View file

@ -98,10 +98,10 @@ void PropertySelector::_update_search() {
} else {
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));
obj->cast_to<Script>()->get_script_property_list(&props);
Object::cast_to<Script>(obj)->get_script_property_list(&props);
}
StringName base = base_type;
@ -200,10 +200,10 @@ void PropertySelector::_update_search() {
} else {
Object *obj = ObjectDB::get_instance(script);
if (obj && obj->cast_to<Script>()) {
if (Object::cast_to<Script>(obj)) {
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;

View file

@ -279,7 +279,7 @@ void ResourcesDock::_resource_selected() {
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);
call_deferred("remove_resource", ti->get_metadata(0));
@ -290,7 +290,7 @@ void ResourcesDock::_create() {
Object *c = create_dialog->instance_selected();
ERR_FAIL_COND(!c);
Resource *r = c->cast_to<Resource>();
Resource *r = Object::cast_to<Resource>(c);
ERR_FAIL_COND(!r);
REF res(r);

View file

@ -775,7 +775,7 @@ void SceneTreeDock::_notification(int p_what) {
break;
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) {
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");
@ -864,7 +864,7 @@ Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node *, Node *> &duplimap) {
} else {
Object *obj = ClassDB::instance(p_node->get_class());
ERR_FAIL_COND_V(!obj, NULL);
node = obj->cast_to<Node>();
node = Object::cast_to<Node>(obj);
if (!node)
memdelete(obj);
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++) {
Object *obj = p_nodes[i];
if (!obj)
continue;
Node *n = obj->cast_to<Node>();
Node *n = Object::cast_to<Node>(p_nodes[i]);
if (!n)
continue;
n->set_owner(p_owner);
@ -994,9 +990,9 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
if (!p_base)
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;
ap->get_animation_list(&anims);
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());
if (p_keep_global_xform) {
if (node->cast_to<Node2D>())
editor_data->get_undo_redo().add_do_method(node, "set_global_transform", node->cast_to<Node2D>()->get_global_transform());
if (node->cast_to<Spatial>())
editor_data->get_undo_redo().add_do_method(node, "set_global_transform", node->cast_to<Spatial>()->get_global_transform());
if (node->cast_to<Control>())
editor_data->get_undo_redo().add_do_method(node, "set_global_position", node->cast_to<Control>()->get_global_position());
if (Object::cast_to<Node2D>(node))
editor_data->get_undo_redo().add_do_method(node, "set_global_transform", Object::cast_to<Node2D>(node)->get_global_transform());
if (Object::cast_to<Spatial>(node))
editor_data->get_undo_redo().add_do_method(node, "set_global_transform", Object::cast_to<Spatial>(node)->get_global_transform());
if (Object::cast_to<Control>(node))
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);
@ -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);
if (p_keep_global_xform) {
if (node->cast_to<Node2D>())
editor_data->get_undo_redo().add_undo_method(node, "set_transform", node->cast_to<Node2D>()->get_transform());
if (node->cast_to<Spatial>())
editor_data->get_undo_redo().add_undo_method(node, "set_transform", node->cast_to<Spatial>()->get_transform());
if (node->cast_to<Control>())
editor_data->get_undo_redo().add_undo_method(node, "set_position", node->cast_to<Control>()->get_position());
if (Object::cast_to<Node2D>(node))
editor_data->get_undo_redo().add_undo_method(node, "set_transform", Object::cast_to<Node2D>(node)->get_transform());
if (Object::cast_to<Spatial>(node))
editor_data->get_undo_redo().add_undo_method(node, "set_transform", Object::cast_to<Spatial>(node)->get_transform());
if (Object::cast_to<Control>(node))
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();
ERR_FAIL_COND(!c);
Node *child = c->cast_to<Node>();
Node *child = Object::cast_to<Node>(c);
ERR_FAIL_COND(!child);
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->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
Control *ct = c->cast_to<Control>();
Control *ct = Object::cast_to<Control>(c);
Size2 ms = ct->get_minimum_size();
if (ms.width < 4)
@ -1469,7 +1465,7 @@ void SceneTreeDock::_create() {
Object *c = create_dialog->instance_selected();
ERR_FAIL_COND(!c);
Node *newnode = c->cast_to<Node>();
Node *newnode = Object::cast_to<Node>(c);
ERR_FAIL_COND(!newnode);
List<PropertyInfo> pinfo;
@ -1931,10 +1927,10 @@ void SceneTreeDock::_focus_node() {
ERR_FAIL_COND(!node);
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();
} 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();
}
}

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) {
TreeItem *item = p_item->cast_to<TreeItem>();
TreeItem *item = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!item);
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) {
TreeItem *item = p_object->cast_to<TreeItem>();
TreeItem *item = Object::cast_to<TreeItem>(p_object);
ERR_FAIL_COND(!item);
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);
ERR_FAIL_COND(!o);
Node *n = o->cast_to<Node>();
Node *n = Object::cast_to<Node>(o);
ERR_FAIL_COND(!n);
TreeItem *item = _find(tree->get_root(), n->get_path());
ERR_FAIL_COND(!item);
@ -732,7 +732,7 @@ void SceneTreeEditor::_cell_collapsed(Object *p_obj) {
if (!can_rename)
return;
TreeItem *ti = p_obj->cast_to<TreeItem>();
TreeItem *ti = Object::cast_to<TreeItem>(p_obj);
if (!ti)
return;

View file

@ -215,7 +215,7 @@ void ScriptEditorDebugger::_scene_tree_folded(Object *obj) {
return;
}
TreeItem *item = obj->cast_to<TreeItem>();
TreeItem *item = Object::cast_to<TreeItem>(obj);
if (!item)
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())
return;
Node *node = p_base->cast_to<Node>();
Node *node = Object::cast_to<Node>(p_base);
VARIANT_ARGPTRS
@ -1249,7 +1249,7 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n
return;
}
Resource *res = p_base->cast_to<Resource>();
Resource *res = Object::cast_to<Resource>(p_base);
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())
return;
Node *node = p_base->cast_to<Node>();
Node *node = Object::cast_to<Node>(p_base);
if (node) {
@ -1308,7 +1308,7 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p
return;
}
Resource *res = p_base->cast_to<Resource>();
Resource *res = Object::cast_to<Resource>(p_base);
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) {
TreeItem *ti = p_item->cast_to<TreeItem>();
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti);
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) };
if (p_idx == 0) {
if (light->cast_to<SpotLight>()) {
if (Object::cast_to<SpotLight>(light)) {
Vector3 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;
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));
@ -713,7 +713,7 @@ void LightSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool
void LightSpatialGizmo::redraw() {
if (light->cast_to<DirectionalLight>()) {
if (Object::cast_to<DirectionalLight>(light)) {
const int arrow_points = 5;
Vector3 arrow[arrow_points] = {
@ -751,11 +751,11 @@ void LightSpatialGizmo::redraw() {
add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_directional_icon, 0.05);
}
if (light->cast_to<OmniLight>()) {
if (Object::cast_to<OmniLight>(light)) {
clear();
OmniLight *on = light->cast_to<OmniLight>();
OmniLight *on = Object::cast_to<OmniLight>(light);
float r = on->get_param(Light::PARAM_RANGE);
@ -786,12 +786,12 @@ void LightSpatialGizmo::redraw() {
add_handles(handles, true);
}
if (light->cast_to<SpotLight>()) {
if (Object::cast_to<SpotLight>(light)) {
clear();
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 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())
return "";
if (s->cast_to<SphereShape>()) {
if (Object::cast_to<SphereShape>(*s)) {
return "Radius";
}
if (s->cast_to<BoxShape>()) {
if (Object::cast_to<BoxShape>(*s)) {
return "Extents";
}
if (s->cast_to<CapsuleShape>()) {
if (Object::cast_to<CapsuleShape>(*s)) {
return p_idx == 0 ? "Radius" : "Height";
}
if (s->cast_to<RayShape>()) {
if (Object::cast_to<RayShape>(*s)) {
return "Length";
}
@ -1596,25 +1596,25 @@ Variant CollisionShapeSpatialGizmo::get_handle_value(int p_idx) const {
if (s.is_null())
return Variant();
if (s->cast_to<SphereShape>()) {
if (Object::cast_to<SphereShape>(*s)) {
Ref<SphereShape> ss = s;
return ss->get_radius();
}
if (s->cast_to<BoxShape>()) {
if (Object::cast_to<BoxShape>(*s)) {
Ref<BoxShape> bs = s;
return bs->get_extents();
}
if (s->cast_to<CapsuleShape>()) {
if (Object::cast_to<CapsuleShape>(*s)) {
Ref<CapsuleShape> cs = s;
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;
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) };
if (s->cast_to<SphereShape>()) {
if (Object::cast_to<SphereShape>(*s)) {
Ref<SphereShape> ss = s;
Vector3 ra, rb;
@ -1648,7 +1648,7 @@ void CollisionShapeSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const P
ss->set_radius(d);
}
if (s->cast_to<RayShape>()) {
if (Object::cast_to<RayShape>(*s)) {
Ref<RayShape> rs = s;
Vector3 ra, rb;
@ -1660,7 +1660,7 @@ void CollisionShapeSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const P
rs->set_length(d);
}
if (s->cast_to<BoxShape>()) {
if (Object::cast_to<BoxShape>(*s)) {
Vector3 axis;
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);
}
if (s->cast_to<CapsuleShape>()) {
if (Object::cast_to<CapsuleShape>(*s)) {
Vector3 axis;
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())
return;
if (s->cast_to<SphereShape>()) {
if (Object::cast_to<SphereShape>(*s)) {
Ref<SphereShape> ss = s;
if (p_cancel) {
@ -1715,7 +1715,7 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx, const Variant &p_resto
ur->commit_action();
}
if (s->cast_to<BoxShape>()) {
if (Object::cast_to<BoxShape>(*s)) {
Ref<BoxShape> ss = s;
if (p_cancel) {
@ -1730,7 +1730,7 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx, const Variant &p_resto
ur->commit_action();
}
if (s->cast_to<CapsuleShape>()) {
if (Object::cast_to<CapsuleShape>(*s)) {
Ref<CapsuleShape> ss = s;
if (p_cancel) {
@ -1755,7 +1755,7 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx, const Variant &p_resto
ur->commit_action();
}
if (s->cast_to<RayShape>()) {
if (Object::cast_to<RayShape>(*s)) {
Ref<RayShape> ss = s;
if (p_cancel) {
@ -1778,7 +1778,7 @@ void CollisionShapeSpatialGizmo::redraw() {
if (s.is_null())
return;
if (s->cast_to<SphereShape>()) {
if (Object::cast_to<SphereShape>(*s)) {
Ref<SphereShape> sp = s;
float r = sp->get_radius();
@ -1824,7 +1824,7 @@ void CollisionShapeSpatialGizmo::redraw() {
add_handles(handles);
}
if (s->cast_to<BoxShape>()) {
if (Object::cast_to<BoxShape>(*s)) {
Ref<BoxShape> bs = s;
Vector<Vector3> lines;
@ -1853,7 +1853,7 @@ void CollisionShapeSpatialGizmo::redraw() {
add_handles(handles);
}
if (s->cast_to<CapsuleShape>()) {
if (Object::cast_to<CapsuleShape>(*s)) {
Ref<CapsuleShape> cs = s;
float radius = cs->get_radius();
@ -1928,7 +1928,7 @@ void CollisionShapeSpatialGizmo::redraw() {
add_handles(handles);
}
if (s->cast_to<PlaneShape>()) {
if (Object::cast_to<PlaneShape>(*s)) {
Ref<PlaneShape> ps = s;
Plane p = ps->get_plane();
@ -1959,9 +1959,9 @@ void CollisionShapeSpatialGizmo::redraw() {
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) {
@ -1983,7 +1983,7 @@ void CollisionShapeSpatialGizmo::redraw() {
}
}
if (s->cast_to<RayShape>()) {
if (Object::cast_to<RayShape>(*s)) {
Ref<RayShape> rs = s;
@ -3098,133 +3098,133 @@ SpatialEditorGizmos *SpatialEditorGizmos::singleton = NULL;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}

View file

@ -93,7 +93,7 @@ class EditorSpatialGizmo : public SpatialEditorGizmo {
Vector<Instance> instances;
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:
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 (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton() && !editor) {
//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)
id->set_emulate_touch(true);
}
@ -1181,7 +1181,7 @@ bool Main::start() {
StringName instance_type = script_res->get_instance_base_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 (obj)
memdelete(obj);
@ -1215,7 +1215,7 @@ bool Main::start() {
ERR_FAIL_V(false);
}
main_loop = ml->cast_to<MainLoop>();
main_loop = Object::cast_to<MainLoop>(ml);
if (!main_loop) {
memdelete(ml);
@ -1227,7 +1227,7 @@ bool Main::start() {
if (main_loop->is_class("SceneTree")) {
SceneTree *sml = main_loop->cast_to<SceneTree>();
SceneTree *sml = Object::cast_to<SceneTree>(main_loop);
#ifdef DEBUG_ENABLED
if (debug_collisions) {
@ -1421,7 +1421,7 @@ bool Main::start() {
ERR_EXPLAIN("Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt));
ERR_CONTINUE(obj == NULL);
n = obj->cast_to<Node>();
n = Object::cast_to<Node>(obj);
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: {
MainLoop *ml = OS::get_singleton()->get_main_loop();
if (!ml)
return 0;
SceneTree *sml = ml->cast_to<SceneTree>();
SceneTree *sml = Object::cast_to<SceneTree>(ml);
if (!sml)
return 0;
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) {
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);
if (res_from) {
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
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->script = Ref<GDScript>(p_script);
instance->owner = E->get();

View file

@ -372,8 +372,8 @@ static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) {
Object *obj = p_variant;
if (obj) {
/*
if (obj->cast_to<GDNativeClass>()) {
t.obj_type=obj->cast_to<GDNativeClass>()->get_name();
if (Object::cast_to<GDNativeClass>(obj)) {
t.obj_type=Object::cast_to<GDNativeClass>(obj)->get_name();
t.value=Variant();
} 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) {
Object *obj = base.value;
if (obj && obj->cast_to<GDNativeClass>()) {
GDNativeClass *gdnc = obj->cast_to<GDNativeClass>();
if (GDNativeClass *gdnc = Object::cast_to<GDNativeClass>(obj)) {
r_type.type = Variant::OBJECT;
r_type.value = Variant();
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()) {
Object *obj = id.value;
if (obj) {
GDScript *scr = Object::cast_to<GDScript>(obj);
if (scr) {
while (scr) {
GDScript *scr = obj->cast_to<GDScript>();
if (scr) {
while (scr) {
for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
if (E->get()->is_static() && p_method == E->get()->get_name()) {
arghint = "static func " + String(p_method) + "(";
for (int i = 0; i < E->get()->get_argument_count(); i++) {
if (i > 0)
arghint += ", ";
else
arghint += " ";
if (i == p_argidx) {
arghint += String::chr(0xFFFF);
}
arghint += "var " + E->get()->get_argument_name(i);
int deffrom = E->get()->get_argument_count() - E->get()->get_default_argument_count();
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);
for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
if (E->get()->is_static() && p_method == E->get()->get_name()) {
arghint = "static func " + String(p_method) + "(";
for (int i = 0; i < E->get()->get_argument_count(); i++) {
if (i > 0)
arghint += ", ";
else
arghint += " ";
if (i == p_argidx) {
arghint += String::chr(0xFFFF);
}
arghint += "var " + E->get()->get_argument_name(i);
int deffrom = E->get()->get_argument_count() - E->get()->get_default_argument_count();
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();
}
}
arghint += ")";
return; //found
if (i == p_argidx) {
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()) {
Object *obj = t.value;
if (obj) {
GDScript *scr = Object::cast_to<GDScript>(obj);
if (scr) {
while (scr) {
GDScript *scr = obj->cast_to<GDScript>();
if (scr) {
while (scr) {
if (!isfunction) {
for (const Map<StringName, Variant>::Element *E = scr->get_constants().front(); E; E = E->next()) {
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 {
on_script = obj->get_script();
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 {
on_script = obj->get_script();
}
}
@ -2822,9 +2815,9 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
Object *obj = value;
if (obj) {
if (obj->cast_to<GDNativeClass>()) {
if (Object::cast_to<GDNativeClass>(obj)) {
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 {
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_B = *b;
GDScript *scr_B = obj_B->cast_to<GDScript>();
GDScript *scr_B = Object::cast_to<GDScript>(obj_B);
bool extends_ok = false;
@ -397,7 +397,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
} else {
GDNativeClass *nc = obj_B->cast_to<GDNativeClass>();
GDNativeClass *nc = Object::cast_to<GDNativeClass>(obj_B);
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,
// then the function did yield again after resuming.
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)
completed = false;
}
@ -1490,7 +1490,7 @@ Variant GDFunctionState::resume(const Variant &p_arg) {
// If the return value is a GDFunctionState reference,
// then the function did yield again after resuming.
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)
completed = false;
}

View file

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

View file

@ -73,7 +73,7 @@ Variant GDNativeClass::_new() {
ERR_FAIL_COND_V(!o, Variant());
}
Reference *ref = o->cast_to<Reference>();
Reference *ref = Object::cast_to<Reference>(o);
if (ref) {
return REF(ref);
} 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
}
Reference *r = owner->cast_to<Reference>();
Reference *r = Object::cast_to<Reference>(owner);
if (r) {
ref = REF(r);
}
@ -397,7 +397,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
}
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 {
@ -575,9 +575,7 @@ void GDScript::update_exports() {
//print_line("update exports for "+get_path()+" ic: "+itos(copy.size()));
for (Set<ObjectID>::Element *E = copy.front(); E; E = E->next()) {
Object *id = ObjectDB::get_instance(E->get());
if (!id)
continue;
GDScript *s = id->cast_to<GDScript>();
GDScript *s = Object::cast_to<GDScript>(id);
if (!s)
continue;
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 {
if (p_resource->cast_to<GDScript>()) {
if (Object::cast_to<GDScript>(*p_resource)) {
p_extensions->push_back("gd");
}
}
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;
while (c) {
navigation = c->cast_to<Navigation>();
navigation = Object::cast_to<Navigation>(c);
if (navigation) {
break;
}
c = c->get_parent()->cast_to<Spatial>();
c = Object::cast_to<Spatial>(c->get_parent());
}
if (navigation) {

View file

@ -806,7 +806,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
_update_selection_transform();
_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) {
set_process(false);
@ -978,14 +978,14 @@ void GridMapEditor::_notification(int p_what) {
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;
p.normal[edit_axis] = 1.0;
p.d = edit_floor[edit_axis] * node->get_cell_size();
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)
sep->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) {
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 {

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