diff options
-rw-r--r-- | modules/nativescript/godot_nativescript.cpp | 2 | ||||
-rw-r--r-- | modules/nativescript/nativescript.cpp | 37 | ||||
-rw-r--r-- | modules/nativescript/nativescript.h | 4 | ||||
-rw-r--r-- | scene/2d/collision_object_2d.cpp | 27 | ||||
-rw-r--r-- | scene/2d/collision_object_2d.h | 1 | ||||
-rw-r--r-- | scene/3d/collision_object.cpp | 26 | ||||
-rw-r--r-- | scene/3d/collision_object.h | 1 |
7 files changed, 60 insertions, 38 deletions
diff --git a/modules/nativescript/godot_nativescript.cpp b/modules/nativescript/godot_nativescript.cpp index 7da6d14d18..453cee3a18 100644 --- a/modules/nativescript/godot_nativescript.cpp +++ b/modules/nativescript/godot_nativescript.cpp @@ -195,7 +195,7 @@ void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) { if (!instance) return NULL; if (instance->get_script_instance() && instance->get_script_instance()->get_language() == NativeScriptLanguage::get_singleton()) { - // return ((NativeScriptInstance *)instance->get_script_instance())->get_userdata(); + return ((NativeScriptInstance *)instance->get_script_instance())->userdata; } return NULL; } diff --git a/modules/nativescript/nativescript.cpp b/modules/nativescript/nativescript.cpp index 661ae5371d..952e8e349c 100644 --- a/modules/nativescript/nativescript.cpp +++ b/modules/nativescript/nativescript.cpp @@ -532,6 +532,7 @@ bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const { } void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { + script->get_script_property_list(p_properties); NativeScriptDesc *script_data = GET_SCRIPT_DESC(); @@ -799,7 +800,7 @@ NativeScriptLanguage::NativeScriptLanguage() { // TODO(karroffel): implement this NativeScriptLanguage::~NativeScriptLanguage() { - _unload_stuff(); + // _unload_stuff(); // NOTE(karroffel): This gets called in ::finish() for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { @@ -1011,40 +1012,6 @@ void NativeReloadNode::_notification(int p_what) { NSL->library_gdnatives.erase(R->get()); } - /* - for (Set<NativeLibrary *>::Element *L = libs_to_reload.front(); L; L = L->next()) { - - GDNativeLibrary *lib = L->get()->dllib; - - lib->_terminate(); - lib->_initialize(); - - // update placeholders (if any) - - Set<GDNativeScript *> scripts; - - for (Set<GDNativeScript *>::Element *S = GDNativeScriptLanguage::get_singleton()->script_list.front(); S; S = S->next()) { - - if (lib->native_library->scripts.has(S->get()->get_script_name())) { - GDNativeScript *script = S->get(); - script->script_data = lib->get_script_data(script->get_script_name()); - scripts.insert(script); - } - } - - for (Set<GDNativeScript *>::Element *S = scripts.front(); S; S = S->next()) { - GDNativeScript *script = S->get(); - if (script->placeholders.size() == 0) - continue; - - for (Set<PlaceHolderScriptInstance *>::Element *P = script->placeholders.front(); P; P = P->next()) { - PlaceHolderScriptInstance *p = P->get(); - script->_update_placeholder(p); - } - } - } - */ - } break; default: { }; diff --git a/modules/nativescript/nativescript.h b/modules/nativescript/nativescript.h index 0578ffb680..5702ba2e8d 100644 --- a/modules/nativescript/nativescript.h +++ b/modules/nativescript/nativescript.h @@ -160,11 +160,11 @@ class NativeScriptInstance : public ScriptInstance { Object *owner; Ref<NativeScript> script; - void *userdata; - void _ml_call_reversed(NativeScriptDesc *script_data, const StringName &p_method, const Variant **p_args, int p_argcount); public: + void *userdata; + virtual bool set(const StringName &p_name, const Variant &p_value); virtual bool get(const StringName &p_name, Variant &r_ret) const; virtual void get_property_list(List<PropertyInfo> *p_properties) const; diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 0821b00dd9..eb47682884 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -152,6 +152,16 @@ void CollisionObject2D::get_shape_owners(List<uint32_t> *r_owners) { } } +Array CollisionObject2D::_get_shape_owners() { + + Array ret; + for (Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) { + ret.push_back(E->key()); + } + + return ret; +} + void CollisionObject2D::shape_owner_set_transform(uint32_t p_owner, const Transform2D &p_transform) { ERR_FAIL_COND(!shapes.has(p_owner)); @@ -323,6 +333,23 @@ void CollisionObject2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_pickable", "enabled"), &CollisionObject2D::set_pickable); ClassDB::bind_method(D_METHOD("is_pickable"), &CollisionObject2D::is_pickable); + ClassDB::bind_method(D_METHOD("create_shape_owner", "owner:Object"), &CollisionObject2D::create_shape_owner); + ClassDB::bind_method(D_METHOD("remove_shape_owner", "owner_id"), &CollisionObject2D::remove_shape_owner); + ClassDB::bind_method(D_METHOD("get_shape_owners"), &CollisionObject2D::_get_shape_owners); + ClassDB::bind_method(D_METHOD("shape_owner_set_transform", "owner_id", "transform:Transform2D"), &CollisionObject2D::shape_owner_set_transform); + ClassDB::bind_method(D_METHOD("shape_owner_get_transform", "owner_id"), &CollisionObject2D::shape_owner_get_transform); + ClassDB::bind_method(D_METHOD("shape_owner_get_owner", "owner_id"), &CollisionObject2D::shape_owner_get_owner); + ClassDB::bind_method(D_METHOD("shape_owner_set_disabled", "owner_id", "disabled"), &CollisionObject2D::shape_owner_set_disabled); + ClassDB::bind_method(D_METHOD("is_shape_owner_disabled", "owner_id"), &CollisionObject2D::is_shape_owner_disabled); + ClassDB::bind_method(D_METHOD("shape_owner_set_one_way_collision", "owner_id", "enable"), &CollisionObject2D::shape_owner_set_one_way_collision); + ClassDB::bind_method(D_METHOD("is_shape_owner_one_way_collision_enabled", "owner_id"), &CollisionObject2D::is_shape_owner_one_way_collision_enabled); + ClassDB::bind_method(D_METHOD("shape_owner_add_shape", "owner_id", "shape:Shape2D"), &CollisionObject2D::shape_owner_add_shape); + ClassDB::bind_method(D_METHOD("shape_owner_get_shape_count", "owner_id"), &CollisionObject2D::shape_owner_get_shape_count); + ClassDB::bind_method(D_METHOD("shape_owner_get_shape", "owner_id", "shape_id"), &CollisionObject2D::shape_owner_get_shape); + ClassDB::bind_method(D_METHOD("shape_owner_get_shape_index", "owner_id", "shape_id"), &CollisionObject2D::shape_owner_get_shape_index); + ClassDB::bind_method(D_METHOD("shape_owner_remove_shape", "owner_id", "shape_id"), &CollisionObject2D::shape_owner_remove_shape); + ClassDB::bind_method(D_METHOD("shape_owner_clear_shapes", "owner_id"), &CollisionObject2D::shape_owner_clear_shapes); + ClassDB::bind_method(D_METHOD("shape_find_owner", "shape_index"), &CollisionObject2D::shape_find_owner); BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "viewport"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::INT, "shape_idx"))); diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h index 3580d3d942..36bf39ff4e 100644 --- a/scene/2d/collision_object_2d.h +++ b/scene/2d/collision_object_2d.h @@ -81,6 +81,7 @@ public: uint32_t create_shape_owner(Object *p_owner); void remove_shape_owner(uint32_t owner); void get_shape_owners(List<uint32_t> *r_owners); + Array _get_shape_owners(); void shape_owner_set_transform(uint32_t p_owner, const Transform2D &p_transform); Transform2D shape_owner_get_transform(uint32_t p_owner) const; diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index 874e5f01ea..5a3d8e013f 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -128,6 +128,22 @@ void CollisionObject::_bind_methods() { ClassDB::bind_method(D_METHOD("set_capture_input_on_drag", "enable"), &CollisionObject::set_capture_input_on_drag); ClassDB::bind_method(D_METHOD("get_capture_input_on_drag"), &CollisionObject::get_capture_input_on_drag); ClassDB::bind_method(D_METHOD("get_rid"), &CollisionObject::get_rid); + ClassDB::bind_method(D_METHOD("create_shape_owner", "owner:Object"), &CollisionObject::create_shape_owner); + ClassDB::bind_method(D_METHOD("remove_shape_owner", "owner_id"), &CollisionObject::remove_shape_owner); + ClassDB::bind_method(D_METHOD("get_shape_owners"), &CollisionObject::_get_shape_owners); + ClassDB::bind_method(D_METHOD("shape_owner_set_transform", "owner_id", "transform:Transform"), &CollisionObject::shape_owner_set_transform); + ClassDB::bind_method(D_METHOD("shape_owner_get_transform", "owner_id"), &CollisionObject::shape_owner_get_transform); + ClassDB::bind_method(D_METHOD("shape_owner_get_owner", "owner_id"), &CollisionObject::shape_owner_get_owner); + ClassDB::bind_method(D_METHOD("shape_owner_set_disabled", "owner_id", "disabled"), &CollisionObject::shape_owner_set_disabled); + ClassDB::bind_method(D_METHOD("is_shape_owner_disabled", "owner_id"), &CollisionObject::is_shape_owner_disabled); + ClassDB::bind_method(D_METHOD("shape_owner_add_shape", "owner_id", "shape:Shape"), &CollisionObject::shape_owner_add_shape); + ClassDB::bind_method(D_METHOD("shape_owner_get_shape_count", "owner_id"), &CollisionObject::shape_owner_get_shape_count); + ClassDB::bind_method(D_METHOD("shape_owner_get_shape", "owner_id", "shape_id"), &CollisionObject::shape_owner_get_shape); + ClassDB::bind_method(D_METHOD("shape_owner_get_shape_index", "owner_id", "shape_id"), &CollisionObject::shape_owner_get_shape_index); + ClassDB::bind_method(D_METHOD("shape_owner_remove_shape", "owner_id", "shape_id"), &CollisionObject::shape_owner_remove_shape); + ClassDB::bind_method(D_METHOD("shape_owner_clear_shapes", "owner_id"), &CollisionObject::shape_owner_clear_shapes); + ClassDB::bind_method(D_METHOD("shape_find_owner", "shape_index"), &CollisionObject::shape_find_owner); + BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "click_pos"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx"))); ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "click_pos"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx"))); @@ -193,6 +209,16 @@ void CollisionObject::get_shape_owners(List<uint32_t> *r_owners) { } } +Array CollisionObject::_get_shape_owners() { + + Array ret; + for (Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) { + ret.push_back(E->key()); + } + + return ret; +} + void CollisionObject::shape_owner_set_transform(uint32_t p_owner, const Transform &p_transform) { ERR_FAIL_COND(!shapes.has(p_owner)); diff --git a/scene/3d/collision_object.h b/scene/3d/collision_object.h index fac05b6e8c..6c13e5d505 100644 --- a/scene/3d/collision_object.h +++ b/scene/3d/collision_object.h @@ -81,6 +81,7 @@ public: uint32_t create_shape_owner(Object *p_owner); void remove_shape_owner(uint32_t owner); void get_shape_owners(List<uint32_t> *r_owners); + Array _get_shape_owners(); void shape_owner_set_transform(uint32_t p_owner, const Transform &p_transform); Transform shape_owner_get_transform(uint32_t p_owner) const; |