Replace Array return types with TypedArray 2

This commit is contained in:
kobewi 2022-08-05 20:35:08 +02:00
parent d5606503b4
commit 1abdffe7a0
75 changed files with 301 additions and 263 deletions

View file

@ -819,7 +819,7 @@ Vector<Point2> Geometry2D::convex_hull(const Vector<Point2> &p_points) {
return ::Geometry2D::convex_hull(p_points); return ::Geometry2D::convex_hull(p_points);
} }
Array Geometry2D::merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) { TypedArray<PackedVector2Array> Geometry2D::merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
Vector<Vector<Point2>> polys = ::Geometry2D::merge_polygons(p_polygon_a, p_polygon_b); Vector<Vector<Point2>> polys = ::Geometry2D::merge_polygons(p_polygon_a, p_polygon_b);
Array ret; Array ret;
@ -830,10 +830,10 @@ Array Geometry2D::merge_polygons(const Vector<Vector2> &p_polygon_a, const Vecto
return ret; return ret;
} }
Array Geometry2D::clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) { TypedArray<PackedVector2Array> Geometry2D::clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
Vector<Vector<Point2>> polys = ::Geometry2D::clip_polygons(p_polygon_a, p_polygon_b); Vector<Vector<Point2>> polys = ::Geometry2D::clip_polygons(p_polygon_a, p_polygon_b);
Array ret; TypedArray<PackedVector2Array> ret;
for (int i = 0; i < polys.size(); ++i) { for (int i = 0; i < polys.size(); ++i) {
ret.push_back(polys[i]); ret.push_back(polys[i]);
@ -841,7 +841,7 @@ Array Geometry2D::clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector
return ret; return ret;
} }
Array Geometry2D::intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) { TypedArray<PackedVector2Array> Geometry2D::intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
Vector<Vector<Point2>> polys = ::Geometry2D::intersect_polygons(p_polygon_a, p_polygon_b); Vector<Vector<Point2>> polys = ::Geometry2D::intersect_polygons(p_polygon_a, p_polygon_b);
Array ret; Array ret;
@ -852,7 +852,7 @@ Array Geometry2D::intersect_polygons(const Vector<Vector2> &p_polygon_a, const V
return ret; return ret;
} }
Array Geometry2D::exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) { TypedArray<PackedVector2Array> Geometry2D::exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
Vector<Vector<Point2>> polys = ::Geometry2D::exclude_polygons(p_polygon_a, p_polygon_b); Vector<Vector<Point2>> polys = ::Geometry2D::exclude_polygons(p_polygon_a, p_polygon_b);
Array ret; Array ret;
@ -863,7 +863,7 @@ Array Geometry2D::exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vec
return ret; return ret;
} }
Array Geometry2D::clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) { TypedArray<PackedVector2Array> Geometry2D::clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
Vector<Vector<Point2>> polys = ::Geometry2D::clip_polyline_with_polygon(p_polyline, p_polygon); Vector<Vector<Point2>> polys = ::Geometry2D::clip_polyline_with_polygon(p_polyline, p_polygon);
Array ret; Array ret;
@ -874,7 +874,7 @@ Array Geometry2D::clip_polyline_with_polygon(const Vector<Vector2> &p_polyline,
return ret; return ret;
} }
Array Geometry2D::intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) { TypedArray<PackedVector2Array> Geometry2D::intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
Vector<Vector<Point2>> polys = ::Geometry2D::intersect_polyline_with_polygon(p_polyline, p_polygon); Vector<Vector<Point2>> polys = ::Geometry2D::intersect_polyline_with_polygon(p_polyline, p_polygon);
Array ret; Array ret;
@ -885,7 +885,7 @@ Array Geometry2D::intersect_polyline_with_polygon(const Vector<Vector2> &p_polyl
return ret; return ret;
} }
Array Geometry2D::offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type) { TypedArray<PackedVector2Array> Geometry2D::offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type) {
Vector<Vector<Point2>> polys = ::Geometry2D::offset_polygon(p_polygon, p_delta, ::Geometry2D::PolyJoinType(p_join_type)); Vector<Vector<Point2>> polys = ::Geometry2D::offset_polygon(p_polygon, p_delta, ::Geometry2D::PolyJoinType(p_join_type));
Array ret; Array ret;
@ -896,7 +896,7 @@ Array Geometry2D::offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delt
return ret; return ret;
} }
Array Geometry2D::offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) { TypedArray<PackedVector2Array> Geometry2D::offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) {
Vector<Vector<Point2>> polys = ::Geometry2D::offset_polyline(p_polygon, p_delta, ::Geometry2D::PolyJoinType(p_join_type), ::Geometry2D::PolyEndType(p_end_type)); Vector<Vector<Point2>> polys = ::Geometry2D::offset_polyline(p_polygon, p_delta, ::Geometry2D::PolyJoinType(p_join_type), ::Geometry2D::PolyEndType(p_end_type));
Array ret; Array ret;
@ -989,16 +989,19 @@ Geometry3D *Geometry3D::get_singleton() {
return singleton; return singleton;
} }
Vector<Plane> Geometry3D::build_box_planes(const Vector3 &p_extents) { TypedArray<Plane> Geometry3D::build_box_planes(const Vector3 &p_extents) {
return ::Geometry3D::build_box_planes(p_extents); Variant ret = ::Geometry3D::build_box_planes(p_extents);
return ret;
} }
Vector<Plane> Geometry3D::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) { TypedArray<Plane> Geometry3D::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
return ::Geometry3D::build_cylinder_planes(p_radius, p_height, p_sides, p_axis); Variant ret = ::Geometry3D::build_cylinder_planes(p_radius, p_height, p_sides, p_axis);
return ret;
} }
Vector<Plane> Geometry3D::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) { TypedArray<Plane> Geometry3D::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
return ::Geometry3D::build_capsule_planes(p_radius, p_height, p_sides, p_lats, p_axis); Variant ret = ::Geometry3D::build_capsule_planes(p_radius, p_height, p_sides, p_lats, p_axis);
return ret;
} }
Vector<Vector3> Geometry3D::get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2) { Vector<Vector3> Geometry3D::get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2) {

View file

@ -303,14 +303,14 @@ public:
OPERATION_XOR OPERATION_XOR
}; };
// 2D polygon boolean operations. // 2D polygon boolean operations.
Array merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add). TypedArray<PackedVector2Array> merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
Array clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract). TypedArray<PackedVector2Array> clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
Array intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply). TypedArray<PackedVector2Array> intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
Array exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor). TypedArray<PackedVector2Array> exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
// 2D polyline vs polygon operations. // 2D polyline vs polygon operations.
Array clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut. TypedArray<PackedVector2Array> clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
Array intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop. TypedArray<PackedVector2Array> intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
// 2D offset polygons/polylines. // 2D offset polygons/polylines.
enum PolyJoinType { enum PolyJoinType {
@ -325,8 +325,8 @@ public:
END_SQUARE, END_SQUARE,
END_ROUND END_ROUND
}; };
Array offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE); TypedArray<PackedVector2Array> offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
Array offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE); TypedArray<PackedVector2Array> offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE);
Dictionary make_atlas(const Vector<Size2> &p_rects); Dictionary make_atlas(const Vector<Size2> &p_rects);
@ -343,9 +343,9 @@ protected:
public: public:
static Geometry3D *get_singleton(); static Geometry3D *get_singleton();
Vector<Plane> build_box_planes(const Vector3 &p_extents); TypedArray<Plane> build_box_planes(const Vector3 &p_extents);
Vector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z); TypedArray<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
Vector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z); TypedArray<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
Vector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2); Vector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b); Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b); Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);

View file

@ -34,6 +34,7 @@
#include "core/input/input.h" #include "core/input/input.h"
#include "core/os/keyboard.h" #include "core/os/keyboard.h"
#include "core/os/os.h" #include "core/os/os.h"
#include "core/variant/typed_array.h"
InputMap *InputMap::singleton = nullptr; InputMap *InputMap::singleton = nullptr;
@ -99,8 +100,8 @@ void InputMap::erase_action(const StringName &p_action) {
input_map.erase(p_action); input_map.erase(p_action);
} }
Array InputMap::_get_actions() { TypedArray<StringName> InputMap::_get_actions() {
Array ret; TypedArray<StringName> ret;
List<StringName> actions = get_actions(); List<StringName> actions = get_actions();
if (actions.is_empty()) { if (actions.is_empty()) {
return ret; return ret;
@ -190,8 +191,8 @@ void InputMap::action_erase_events(const StringName &p_action) {
input_map[p_action].inputs.clear(); input_map[p_action].inputs.clear();
} }
Array InputMap::_action_get_events(const StringName &p_action) { TypedArray<InputEvent> InputMap::_action_get_events(const StringName &p_action) {
Array ret; TypedArray<InputEvent> ret;
const List<Ref<InputEvent>> *al = action_get_events(p_action); const List<Ref<InputEvent>> *al = action_get_events(p_action);
if (al) { if (al) {
for (const List<Ref<InputEvent>>::Element *E = al->front(); E; E = E->next()) { for (const List<Ref<InputEvent>>::Element *E = al->front(); E; E = E->next()) {

View file

@ -36,6 +36,9 @@
#include "core/object/object.h" #include "core/object/object.h"
#include "core/templates/hash_map.h" #include "core/templates/hash_map.h"
template <typename T>
class TypedArray;
class InputMap : public Object { class InputMap : public Object {
GDCLASS(InputMap, Object); GDCLASS(InputMap, Object);
@ -60,8 +63,8 @@ private:
List<Ref<InputEvent>>::Element *_find_event(Action &p_action, const Ref<InputEvent> &p_event, bool p_exact_match = false, bool *r_pressed = nullptr, float *r_strength = nullptr, float *r_raw_strength = nullptr) const; List<Ref<InputEvent>>::Element *_find_event(Action &p_action, const Ref<InputEvent> &p_event, bool p_exact_match = false, bool *r_pressed = nullptr, float *r_strength = nullptr, float *r_raw_strength = nullptr) const;
Array _action_get_events(const StringName &p_action); TypedArray<InputEvent> _action_get_events(const StringName &p_action);
Array _get_actions(); TypedArray<StringName> _get_actions();
protected: protected:
static void _bind_methods(); static void _bind_methods();

View file

@ -33,6 +33,7 @@
#include "core/os/semaphore.h" #include "core/os/semaphore.h"
#include "core/os/thread.h" #include "core/os/thread.h"
#include "core/templates/hash_map.h" #include "core/templates/hash_map.h"
#include "core/variant/typed_array.h"
VARIANT_ENUM_CAST(IP::ResolverStatus); VARIANT_ENUM_CAST(IP::ResolverStatus);
@ -124,11 +125,11 @@ struct _IP_ResolverPrivate {
}; };
IPAddress IP::resolve_hostname(const String &p_hostname, IP::Type p_type) { IPAddress IP::resolve_hostname(const String &p_hostname, IP::Type p_type) {
const Array addresses = resolve_hostname_addresses(p_hostname, p_type); const PackedStringArray addresses = resolve_hostname_addresses(p_hostname, p_type);
return addresses.size() ? addresses[0].operator IPAddress() : IPAddress(); return addresses.size() ? (IPAddress)addresses[0] : IPAddress();
} }
Array IP::resolve_hostname_addresses(const String &p_hostname, Type p_type) { PackedStringArray IP::resolve_hostname_addresses(const String &p_hostname, Type p_type) {
List<IPAddress> res; List<IPAddress> res;
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type); String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
@ -148,7 +149,7 @@ Array IP::resolve_hostname_addresses(const String &p_hostname, Type p_type) {
} }
resolver->mutex.unlock(); resolver->mutex.unlock();
Array result; PackedStringArray result;
for (int i = 0; i < res.size(); ++i) { for (int i = 0; i < res.size(); ++i) {
result.push_back(String(res[i])); result.push_back(String(res[i]));
} }
@ -254,8 +255,8 @@ void IP::clear_cache(const String &p_hostname) {
} }
} }
Array IP::_get_local_addresses() const { PackedStringArray IP::_get_local_addresses() const {
Array addresses; PackedStringArray addresses;
List<IPAddress> ip_addresses; List<IPAddress> ip_addresses;
get_local_addresses(&ip_addresses); get_local_addresses(&ip_addresses);
for (const IPAddress &E : ip_addresses) { for (const IPAddress &E : ip_addresses) {
@ -265,8 +266,8 @@ Array IP::_get_local_addresses() const {
return addresses; return addresses;
} }
Array IP::_get_local_interfaces() const { TypedArray<Dictionary> IP::_get_local_interfaces() const {
Array results; TypedArray<Dictionary> results;
HashMap<String, Interface_Info> interfaces; HashMap<String, Interface_Info> interfaces;
get_local_interfaces(&interfaces); get_local_interfaces(&interfaces);
for (KeyValue<String, Interface_Info> &E : interfaces) { for (KeyValue<String, Interface_Info> &E : interfaces) {

View file

@ -34,6 +34,9 @@
#include "core/io/ip_address.h" #include "core/io/ip_address.h"
#include "core/os/os.h" #include "core/os/os.h"
template <typename T>
class TypedArray;
struct _IP_ResolverPrivate; struct _IP_ResolverPrivate;
class IP : public Object { class IP : public Object {
@ -68,8 +71,8 @@ protected:
static IP *singleton; static IP *singleton;
static void _bind_methods(); static void _bind_methods();
Array _get_local_addresses() const; PackedStringArray _get_local_addresses() const;
Array _get_local_interfaces() const; TypedArray<Dictionary> _get_local_interfaces() const;
static IP *(*_create)(); static IP *(*_create)();
@ -82,7 +85,7 @@ public:
}; };
IPAddress resolve_hostname(const String &p_hostname, Type p_type = TYPE_ANY); IPAddress resolve_hostname(const String &p_hostname, Type p_type = TYPE_ANY);
Array resolve_hostname_addresses(const String &p_hostname, Type p_type = TYPE_ANY); PackedStringArray resolve_hostname_addresses(const String &p_hostname, Type p_type = TYPE_ANY);
// async resolver hostname // async resolver hostname
ResolverID resolve_hostname_queue_item(const String &p_hostname, Type p_type = TYPE_ANY); ResolverID resolve_hostname_queue_item(const String &p_hostname, Type p_type = TYPE_ANY);
ResolverStatus get_resolve_item_status(ResolverID p_id) const; ResolverStatus get_resolve_item_status(ResolverID p_id) const;

View file

@ -38,6 +38,7 @@
#include "core/os/os.h" #include "core/os/os.h"
#include "core/string/print_string.h" #include "core/string/print_string.h"
#include "core/string/translation.h" #include "core/string/translation.h"
#include "core/variant/typed_array.h"
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
@ -102,8 +103,8 @@ PropertyInfo PropertyInfo::from_dict(const Dictionary &p_dict) {
return pi; return pi;
} }
Array convert_property_list(const List<PropertyInfo> *p_list) { TypedArray<Dictionary> convert_property_list(const List<PropertyInfo> *p_list) {
Array va; TypedArray<Dictionary> va;
for (const List<PropertyInfo>::Element *E = p_list->front(); E; E = E->next()) { for (const List<PropertyInfo>::Element *E = p_list->front(); E; E = E->next()) {
va.push_back(Dictionary(E->get())); va.push_back(Dictionary(E->get()));
} }
@ -912,16 +913,16 @@ void Object::remove_meta(const StringName &p_name) {
set_meta(p_name, Variant()); set_meta(p_name, Variant());
} }
Array Object::_get_property_list_bind() const { TypedArray<Dictionary> Object::_get_property_list_bind() const {
List<PropertyInfo> lpi; List<PropertyInfo> lpi;
get_property_list(&lpi); get_property_list(&lpi);
return convert_property_list(&lpi); return convert_property_list(&lpi);
} }
Array Object::_get_method_list_bind() const { TypedArray<Dictionary> Object::_get_method_list_bind() const {
List<MethodInfo> ml; List<MethodInfo> ml;
get_method_list(&ml); get_method_list(&ml);
Array ret; TypedArray<Dictionary> ret;
for (List<MethodInfo>::Element *E = ml.front(); E; E = E->next()) { for (List<MethodInfo>::Element *E = ml.front(); E; E = E->next()) {
Dictionary d = E->get(); Dictionary d = E->get();
@ -1109,11 +1110,11 @@ void Object::_add_user_signal(const String &p_name, const Array &p_args) {
add_user_signal(mi); add_user_signal(mi);
} }
Array Object::_get_signal_list() const { TypedArray<Dictionary> Object::_get_signal_list() const {
List<MethodInfo> signal_list; List<MethodInfo> signal_list;
get_signal_list(&signal_list); get_signal_list(&signal_list);
Array ret; TypedArray<Dictionary> ret;
for (const MethodInfo &E : signal_list) { for (const MethodInfo &E : signal_list) {
ret.push_back(Dictionary(E)); ret.push_back(Dictionary(E));
} }
@ -1121,11 +1122,11 @@ Array Object::_get_signal_list() const {
return ret; return ret;
} }
Array Object::_get_signal_connection_list(const StringName &p_signal) const { TypedArray<Dictionary> Object::_get_signal_connection_list(const StringName &p_signal) const {
List<Connection> conns; List<Connection> conns;
get_all_signal_connections(&conns); get_all_signal_connections(&conns);
Array ret; TypedArray<Dictionary> ret;
for (const Connection &c : conns) { for (const Connection &c : conns) {
if (c.signal.get_name() == p_signal) { if (c.signal.get_name() == p_signal) {
@ -1136,8 +1137,8 @@ Array Object::_get_signal_connection_list(const StringName &p_signal) const {
return ret; return ret;
} }
Array Object::_get_incoming_connections() const { TypedArray<Dictionary> Object::_get_incoming_connections() const {
Array ret; TypedArray<Dictionary> ret;
int connections_amount = connections.size(); int connections_amount = connections.size();
for (int idx_conn = 0; idx_conn < connections_amount; idx_conn++) { for (int idx_conn = 0; idx_conn < connections_amount; idx_conn++) {
ret.push_back(connections[idx_conn]); ret.push_back(connections[idx_conn]);
@ -1553,7 +1554,12 @@ void Object::_bind_methods() {
miget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; miget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
BIND_OBJ_CORE_METHOD(miget); BIND_OBJ_CORE_METHOD(miget);
BIND_OBJ_CORE_METHOD(MethodInfo(Variant::ARRAY, "_get_property_list")); MethodInfo plget("_get_property_list");
plget.return_val.type = Variant::ARRAY;
plget.return_val.hint = PROPERTY_HINT_ARRAY_TYPE;
plget.return_val.hint_string = "Dictionary";
BIND_OBJ_CORE_METHOD(plget);
BIND_OBJ_CORE_METHOD(MethodInfo(Variant::BOOL, "_property_can_revert", PropertyInfo(Variant::STRING_NAME, "property"))); BIND_OBJ_CORE_METHOD(MethodInfo(Variant::BOOL, "_property_can_revert", PropertyInfo(Variant::STRING_NAME, "property")));
MethodInfo mipgr("_property_get_revert", PropertyInfo(Variant::STRING_NAME, "property")); MethodInfo mipgr("_property_get_revert", PropertyInfo(Variant::STRING_NAME, "property"));
mipgr.return_val.name = "Variant"; mipgr.return_val.name = "Variant";

View file

@ -45,6 +45,9 @@
#include "core/variant/callable_bind.h" #include "core/variant/callable_bind.h"
#include "core/variant/variant.h" #include "core/variant/variant.h"
template <typename T>
class TypedArray;
enum PropertyHint { enum PropertyHint {
PROPERTY_HINT_NONE, ///< no hint provided. PROPERTY_HINT_NONE, ///< no hint provided.
PROPERTY_HINT_RANGE, ///< hint_text = "min,max[,step][,or_greater][,or_lesser][,no_slider][,radians][,degrees][,exp][,suffix:<keyword>] range. PROPERTY_HINT_RANGE, ///< hint_text = "min,max[,step][,or_greater][,or_lesser][,no_slider][,radians][,degrees][,exp][,suffix:<keyword>] range.
@ -207,7 +210,7 @@ struct PropertyInfo {
} }
}; };
Array convert_property_list(const List<PropertyInfo> *p_list); TypedArray<Dictionary> convert_property_list(const List<PropertyInfo> *p_list);
enum MethodFlags { enum MethodFlags {
METHOD_FLAG_NORMAL = 1, METHOD_FLAG_NORMAL = 1,
@ -597,9 +600,9 @@ private:
void _add_user_signal(const String &p_name, const Array &p_args = Array()); void _add_user_signal(const String &p_name, const Array &p_args = Array());
bool _has_user_signal(const StringName &p_name) const; bool _has_user_signal(const StringName &p_name) const;
Error _emit_signal(const Variant **p_args, int p_argcount, Callable::CallError &r_error); Error _emit_signal(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
Array _get_signal_list() const; TypedArray<Dictionary> _get_signal_list() const;
Array _get_signal_connection_list(const StringName &p_signal) const; TypedArray<Dictionary> _get_signal_connection_list(const StringName &p_signal) const;
Array _get_incoming_connections() const; TypedArray<Dictionary> _get_incoming_connections() const;
void _set_bind(const StringName &p_set, const Variant &p_value); void _set_bind(const StringName &p_set, const Variant &p_value);
Variant _get_bind(const StringName &p_name) const; Variant _get_bind(const StringName &p_name) const;
void _set_indexed_bind(const NodePath &p_name, const Variant &p_value); void _set_indexed_bind(const NodePath &p_name, const Variant &p_value);
@ -698,8 +701,8 @@ protected:
} }
Vector<StringName> _get_meta_list_bind() const; Vector<StringName> _get_meta_list_bind() const;
Array _get_property_list_bind() const; TypedArray<Dictionary> _get_property_list_bind() const;
Array _get_method_list_bind() const; TypedArray<Dictionary> _get_method_list_bind() const;
void _clear_internal_resource_paths(const Variant &p_var); void _clear_internal_resource_paths(const Variant &p_var);

View file

@ -34,6 +34,7 @@
#include "core/core_string_names.h" #include "core/core_string_names.h"
#include "core/debugger/engine_debugger.h" #include "core/debugger/engine_debugger.h"
#include "core/debugger/script_debugger.h" #include "core/debugger/script_debugger.h"
#include "core/variant/typed_array.h"
#include <stdint.h> #include <stdint.h>
@ -61,8 +62,8 @@ Variant Script::_get_property_default_value(const StringName &p_property) {
return ret; return ret;
} }
Array Script::_get_script_property_list() { TypedArray<Dictionary> Script::_get_script_property_list() {
Array ret; TypedArray<Dictionary> ret;
List<PropertyInfo> list; List<PropertyInfo> list;
get_script_property_list(&list); get_script_property_list(&list);
for (const PropertyInfo &E : list) { for (const PropertyInfo &E : list) {
@ -71,8 +72,8 @@ Array Script::_get_script_property_list() {
return ret; return ret;
} }
Array Script::_get_script_method_list() { TypedArray<Dictionary> Script::_get_script_method_list() {
Array ret; TypedArray<Dictionary> ret;
List<MethodInfo> list; List<MethodInfo> list;
get_script_method_list(&list); get_script_method_list(&list);
for (const MethodInfo &E : list) { for (const MethodInfo &E : list) {
@ -81,8 +82,8 @@ Array Script::_get_script_method_list() {
return ret; return ret;
} }
Array Script::_get_script_signal_list() { TypedArray<Dictionary> Script::_get_script_signal_list() {
Array ret; TypedArray<Dictionary> ret;
List<MethodInfo> list; List<MethodInfo> list;
get_script_signal_list(&list); get_script_signal_list(&list);
for (const MethodInfo &E : list) { for (const MethodInfo &E : list) {

View file

@ -37,6 +37,8 @@
#include "core/templates/rb_map.h" #include "core/templates/rb_map.h"
class ScriptLanguage; class ScriptLanguage;
template <typename T>
class TypedArray;
typedef void (*ScriptEditRequestFunction)(const String &p_path); typedef void (*ScriptEditRequestFunction)(const String &p_path);
@ -108,9 +110,9 @@ protected:
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {} virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {}
Variant _get_property_default_value(const StringName &p_property); Variant _get_property_default_value(const StringName &p_property);
Array _get_script_property_list(); TypedArray<Dictionary> _get_script_property_list();
Array _get_script_method_list(); TypedArray<Dictionary> _get_script_method_list();
Array _get_script_signal_list(); TypedArray<Dictionary> _get_script_signal_list();
Dictionary _get_script_constant_map(); Dictionary _get_script_constant_map();
public: public:

View file

@ -10,7 +10,7 @@
</tutorials> </tutorials>
<methods> <methods>
<method name="clip_polygons"> <method name="clip_polygons">
<return type="Array" /> <return type="PackedVector2Array[]" />
<param index="0" name="polygon_a" type="PackedVector2Array" /> <param index="0" name="polygon_a" type="PackedVector2Array" />
<param index="1" name="polygon_b" type="PackedVector2Array" /> <param index="1" name="polygon_b" type="PackedVector2Array" />
<description> <description>
@ -19,7 +19,7 @@
</description> </description>
</method> </method>
<method name="clip_polyline_with_polygon"> <method name="clip_polyline_with_polygon">
<return type="Array" /> <return type="PackedVector2Array[]" />
<param index="0" name="polyline" type="PackedVector2Array" /> <param index="0" name="polyline" type="PackedVector2Array" />
<param index="1" name="polygon" type="PackedVector2Array" /> <param index="1" name="polygon" type="PackedVector2Array" />
<description> <description>
@ -34,7 +34,7 @@
</description> </description>
</method> </method>
<method name="exclude_polygons"> <method name="exclude_polygons">
<return type="Array" /> <return type="PackedVector2Array[]" />
<param index="0" name="polygon_a" type="PackedVector2Array" /> <param index="0" name="polygon_a" type="PackedVector2Array" />
<param index="1" name="polygon_b" type="PackedVector2Array" /> <param index="1" name="polygon_b" type="PackedVector2Array" />
<description> <description>
@ -71,7 +71,7 @@
</description> </description>
</method> </method>
<method name="intersect_polygons"> <method name="intersect_polygons">
<return type="Array" /> <return type="PackedVector2Array[]" />
<param index="0" name="polygon_a" type="PackedVector2Array" /> <param index="0" name="polygon_a" type="PackedVector2Array" />
<param index="1" name="polygon_b" type="PackedVector2Array" /> <param index="1" name="polygon_b" type="PackedVector2Array" />
<description> <description>
@ -80,7 +80,7 @@
</description> </description>
</method> </method>
<method name="intersect_polyline_with_polygon"> <method name="intersect_polyline_with_polygon">
<return type="Array" /> <return type="PackedVector2Array[]" />
<param index="0" name="polyline" type="PackedVector2Array" /> <param index="0" name="polyline" type="PackedVector2Array" />
<param index="1" name="polygon" type="PackedVector2Array" /> <param index="1" name="polygon" type="PackedVector2Array" />
<description> <description>
@ -130,7 +130,7 @@
</description> </description>
</method> </method>
<method name="merge_polygons"> <method name="merge_polygons">
<return type="Array" /> <return type="PackedVector2Array[]" />
<param index="0" name="polygon_a" type="PackedVector2Array" /> <param index="0" name="polygon_a" type="PackedVector2Array" />
<param index="1" name="polygon_b" type="PackedVector2Array" /> <param index="1" name="polygon_b" type="PackedVector2Array" />
<description> <description>
@ -139,7 +139,7 @@
</description> </description>
</method> </method>
<method name="offset_polygon"> <method name="offset_polygon">
<return type="Array" /> <return type="PackedVector2Array[]" />
<param index="0" name="polygon" type="PackedVector2Array" /> <param index="0" name="polygon" type="PackedVector2Array" />
<param index="1" name="delta" type="float" /> <param index="1" name="delta" type="float" />
<param index="2" name="join_type" type="int" enum="Geometry2D.PolyJoinType" default="0" /> <param index="2" name="join_type" type="int" enum="Geometry2D.PolyJoinType" default="0" />
@ -166,7 +166,7 @@
</description> </description>
</method> </method>
<method name="offset_polyline"> <method name="offset_polyline">
<return type="Array" /> <return type="PackedVector2Array[]" />
<param index="0" name="polyline" type="PackedVector2Array" /> <param index="0" name="polyline" type="PackedVector2Array" />
<param index="1" name="delta" type="float" /> <param index="1" name="delta" type="float" />
<param index="2" name="join_type" type="int" enum="Geometry2D.PolyJoinType" default="0" /> <param index="2" name="join_type" type="int" enum="Geometry2D.PolyJoinType" default="0" />

View file

@ -10,14 +10,14 @@
</tutorials> </tutorials>
<methods> <methods>
<method name="build_box_planes"> <method name="build_box_planes">
<return type="Array" /> <return type="Plane[]" />
<param index="0" name="extents" type="Vector3" /> <param index="0" name="extents" type="Vector3" />
<description> <description>
Returns an array with 6 [Plane]s that describe the sides of a box centered at the origin. The box size is defined by [param extents], which represents one (positive) corner of the box (i.e. half its actual size). Returns an array with 6 [Plane]s that describe the sides of a box centered at the origin. The box size is defined by [param extents], which represents one (positive) corner of the box (i.e. half its actual size).
</description> </description>
</method> </method>
<method name="build_capsule_planes"> <method name="build_capsule_planes">
<return type="Array" /> <return type="Plane[]" />
<param index="0" name="radius" type="float" /> <param index="0" name="radius" type="float" />
<param index="1" name="height" type="float" /> <param index="1" name="height" type="float" />
<param index="2" name="sides" type="int" /> <param index="2" name="sides" type="int" />
@ -28,7 +28,7 @@
</description> </description>
</method> </method>
<method name="build_cylinder_planes"> <method name="build_cylinder_planes">
<return type="Array" /> <return type="Plane[]" />
<param index="0" name="radius" type="float" /> <param index="0" name="radius" type="float" />
<param index="1" name="height" type="float" /> <param index="1" name="height" type="float" />
<param index="2" name="sides" type="int" /> <param index="2" name="sides" type="int" />

View file

@ -149,7 +149,7 @@
</description> </description>
</method> </method>
<method name="get_connection_list" qualifiers="const"> <method name="get_connection_list" qualifiers="const">
<return type="Array" /> <return type="Dictionary[]" />
<description> <description>
Returns an Array containing the list of connections. A connection consists in a structure of the form [code]{ from_port: 0, from: "GraphNode name 0", to_port: 1, to: "GraphNode name 1" }[/code]. Returns an Array containing the list of connections. A connection consists in a structure of the form [code]{ from_port: 0, from: "GraphNode name 0", to_port: 1, to: "GraphNode name 1" }[/code].
</description> </description>

View file

@ -24,13 +24,13 @@
</description> </description>
</method> </method>
<method name="get_local_addresses" qualifiers="const"> <method name="get_local_addresses" qualifiers="const">
<return type="Array" /> <return type="PackedStringArray" />
<description> <description>
Returns all the user's current IPv4 and IPv6 addresses as an array. Returns all the user's current IPv4 and IPv6 addresses as an array.
</description> </description>
</method> </method>
<method name="get_local_interfaces" qualifiers="const"> <method name="get_local_interfaces" qualifiers="const">
<return type="Array" /> <return type="Dictionary[]" />
<description> <description>
Returns all network adapters as an array. Returns all network adapters as an array.
Each adapter is a dictionary of the form: Each adapter is a dictionary of the form:
@ -74,7 +74,7 @@
</description> </description>
</method> </method>
<method name="resolve_hostname_addresses"> <method name="resolve_hostname_addresses">
<return type="Array" /> <return type="PackedStringArray" />
<param index="0" name="host" type="String" /> <param index="0" name="host" type="String" />
<param index="1" name="ip_type" type="int" enum="IP.Type" default="3" /> <param index="1" name="ip_type" type="int" enum="IP.Type" default="3" />
<description> <description>

View file

@ -41,7 +41,7 @@
</description> </description>
</method> </method>
<method name="action_get_events"> <method name="action_get_events">
<return type="Array" /> <return type="InputEvent[]" />
<param index="0" name="action" type="StringName" /> <param index="0" name="action" type="StringName" />
<description> <description>
Returns an array of [InputEvent]s associated with a given action. Returns an array of [InputEvent]s associated with a given action.
@ -91,7 +91,7 @@
</description> </description>
</method> </method>
<method name="get_actions"> <method name="get_actions">
<return type="Array" /> <return type="StringName[]" />
<description> <description>
Returns an array of all actions in the [InputMap]. Returns an array of all actions in the [InputMap].
</description> </description>

View file

@ -60,7 +60,7 @@
</description> </description>
</method> </method>
<method name="_surface_get_blend_shape_arrays" qualifiers="virtual const"> <method name="_surface_get_blend_shape_arrays" qualifiers="virtual const">
<return type="Array" /> <return type="Array[]" />
<param index="0" name="index" type="int" /> <param index="0" name="index" type="int" />
<description> <description>
</description> </description>
@ -153,7 +153,7 @@
</description> </description>
</method> </method>
<method name="surface_get_blend_shape_arrays" qualifiers="const"> <method name="surface_get_blend_shape_arrays" qualifiers="const">
<return type="Array" /> <return type="Array[]" />
<param index="0" name="surf_idx" type="int" /> <param index="0" name="surf_idx" type="int" />
<description> <description>
Returns the blend shape arrays for the requested surface. Returns the blend shape arrays for the requested surface.

View file

@ -128,7 +128,7 @@
</description> </description>
</method> </method>
<method name="get_maps" qualifiers="const"> <method name="get_maps" qualifiers="const">
<return type="Array" /> <return type="RID[]" />
<description> <description>
Returns all created navigation map [RID]s on the NavigationServer. This returns both 2D and 3D created navigation maps as there is technically no distinction between them. Returns all created navigation map [RID]s on the NavigationServer. This returns both 2D and 3D created navigation maps as there is technically no distinction between them.
</description> </description>
@ -150,7 +150,7 @@
</description> </description>
</method> </method>
<method name="map_get_agents" qualifiers="const"> <method name="map_get_agents" qualifiers="const">
<return type="Array" /> <return type="RID[]" />
<param index="0" name="map" type="RID" /> <param index="0" name="map" type="RID" />
<description> <description>
Returns all navigation agents [RID]s that are currently assigned to the requested navigation [param map]. Returns all navigation agents [RID]s that are currently assigned to the requested navigation [param map].
@ -198,7 +198,7 @@
</description> </description>
</method> </method>
<method name="map_get_regions" qualifiers="const"> <method name="map_get_regions" qualifiers="const">
<return type="Array" /> <return type="RID[]" />
<param index="0" name="map" type="RID" /> <param index="0" name="map" type="RID" />
<description> <description>
Returns all navigation regions [RID]s that are currently assigned to the requested navigation [param map]. Returns all navigation regions [RID]s that are currently assigned to the requested navigation [param map].

View file

@ -128,7 +128,7 @@
</description> </description>
</method> </method>
<method name="get_maps" qualifiers="const"> <method name="get_maps" qualifiers="const">
<return type="Array" /> <return type="RID[]" />
<description> <description>
Returns all created navigation map [RID]s on the NavigationServer. This returns both 2D and 3D created navigation maps as there is technically no distinction between them. Returns all created navigation map [RID]s on the NavigationServer. This returns both 2D and 3D created navigation maps as there is technically no distinction between them.
</description> </description>
@ -150,7 +150,7 @@
</description> </description>
</method> </method>
<method name="map_get_agents" qualifiers="const"> <method name="map_get_agents" qualifiers="const">
<return type="Array" /> <return type="RID[]" />
<param index="0" name="map" type="RID" /> <param index="0" name="map" type="RID" />
<description> <description>
Returns all navigation agents [RID]s that are currently assigned to the requested navigation [param map]. Returns all navigation agents [RID]s that are currently assigned to the requested navigation [param map].
@ -216,7 +216,7 @@
</description> </description>
</method> </method>
<method name="map_get_regions" qualifiers="const"> <method name="map_get_regions" qualifiers="const">
<return type="Array" /> <return type="RID[]" />
<param index="0" name="map" type="RID" /> <param index="0" name="map" type="RID" />
<description> <description>
Returns all navigation regions [RID]s that are currently assigned to the requested navigation [param map]. Returns all navigation regions [RID]s that are currently assigned to the requested navigation [param map].

View file

@ -262,7 +262,7 @@
</description> </description>
</method> </method>
<method name="get_groups" qualifiers="const"> <method name="get_groups" qualifiers="const">
<return type="Array" /> <return type="StringName[]" />
<description> <description>
Returns an array listing the groups that the node is a member of. Returns an array listing the groups that the node is a member of.
[b]Note:[/b] For performance reasons, the order of node groups is [i]not[/i] guaranteed. The order of node groups should not be relied upon as it can vary across project runs. [b]Note:[/b] For performance reasons, the order of node groups is [i]not[/i] guaranteed. The order of node groups should not be relied upon as it can vary across project runs.

View file

@ -39,7 +39,7 @@
</description> </description>
</method> </method>
<method name="get_gizmos" qualifiers="const"> <method name="get_gizmos" qualifiers="const">
<return type="Array" /> <return type="Node3DGizmo[]" />
<description> <description>
Returns all the gizmos attached to this [code]Node3D[/code]. Returns all the gizmos attached to this [code]Node3D[/code].
</description> </description>

View file

@ -43,7 +43,7 @@
</description> </description>
</method> </method>
<method name="_get_property_list" qualifiers="virtual"> <method name="_get_property_list" qualifiers="virtual">
<return type="Array" /> <return type="Dictionary[]" />
<description> <description>
Virtual method which can be overridden to customize the return value of [method get_property_list]. Virtual method which can be overridden to customize the return value of [method get_property_list].
Returns the object's property list as an [Array] of dictionaries. Returns the object's property list as an [Array] of dictionaries.
@ -353,7 +353,7 @@
</description> </description>
</method> </method>
<method name="get_incoming_connections" qualifiers="const"> <method name="get_incoming_connections" qualifiers="const">
<return type="Array" /> <return type="Dictionary[]" />
<description> <description>
Returns an [Array] of dictionaries with information about signals that are connected to the object. Returns an [Array] of dictionaries with information about signals that are connected to the object.
Each [Dictionary] contains three String entries: Each [Dictionary] contains three String entries:
@ -394,13 +394,13 @@
</description> </description>
</method> </method>
<method name="get_method_list" qualifiers="const"> <method name="get_method_list" qualifiers="const">
<return type="Array" /> <return type="Dictionary[]" />
<description> <description>
Returns the object's methods and their signatures as an [Array]. Returns the object's methods and their signatures as an [Array].
</description> </description>
</method> </method>
<method name="get_property_list" qualifiers="const"> <method name="get_property_list" qualifiers="const">
<return type="Array" /> <return type="Dictionary[]" />
<description> <description>
Returns the object's property list as an [Array] of dictionaries. Returns the object's property list as an [Array] of dictionaries.
Each property's [Dictionary] contain at least [code]name: String[/code] and [code]type: int[/code] (see [enum Variant.Type]) entries. Optionally, it can also include [code]hint: int[/code] (see [enum PropertyHint]), [code]hint_string: String[/code], and [code]usage: int[/code] (see [enum PropertyUsageFlags]). Each property's [Dictionary] contain at least [code]name: String[/code] and [code]type: int[/code] (see [enum Variant.Type]) entries. Optionally, it can also include [code]hint: int[/code] (see [enum PropertyHint]), [code]hint_string: String[/code], and [code]usage: int[/code] (see [enum PropertyUsageFlags]).
@ -413,14 +413,14 @@
</description> </description>
</method> </method>
<method name="get_signal_connection_list" qualifiers="const"> <method name="get_signal_connection_list" qualifiers="const">
<return type="Array" /> <return type="Dictionary[]" />
<param index="0" name="signal" type="StringName" /> <param index="0" name="signal" type="StringName" />
<description> <description>
Returns an [Array] of connections for the given [param signal]. Returns an [Array] of connections for the given [param signal].
</description> </description>
</method> </method>
<method name="get_signal_list" qualifiers="const"> <method name="get_signal_list" qualifiers="const">
<return type="Array" /> <return type="Dictionary[]" />
<description> <description>
Returns the list of signals as an [Array] of dictionaries. Returns the list of signals as an [Array] of dictionaries.
</description> </description>

View file

@ -79,7 +79,7 @@
</description> </description>
</method> </method>
<method name="get_custom_monitor_names"> <method name="get_custom_monitor_names">
<return type="Array" /> <return type="StringName[]" />
<description> <description>
Returns the names of active custom monitors in an [Array]. Returns the names of active custom monitors in an [Array].
</description> </description>

View file

@ -12,7 +12,7 @@
</tutorials> </tutorials>
<methods> <methods>
<method name="cast_motion"> <method name="cast_motion">
<return type="Array" /> <return type="PackedFloat32Array" />
<param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" /> <param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" />
<description> <description>
Checks how far a [Shape2D] can move without colliding. All the parameters for the query, including the shape and the motion, are supplied through a [PhysicsShapeQueryParameters2D] object. Checks how far a [Shape2D] can move without colliding. All the parameters for the query, including the shape and the motion, are supplied through a [PhysicsShapeQueryParameters2D] object.
@ -21,7 +21,7 @@
</description> </description>
</method> </method>
<method name="collide_shape"> <method name="collide_shape">
<return type="Array" /> <return type="PackedVector2Array[]" />
<param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" /> <param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" />
<param index="1" name="max_results" type="int" default="32" /> <param index="1" name="max_results" type="int" default="32" />
<description> <description>
@ -44,7 +44,7 @@
</description> </description>
</method> </method>
<method name="intersect_point"> <method name="intersect_point">
<return type="Array" /> <return type="Dictionary[]" />
<param index="0" name="parameters" type="PhysicsPointQueryParameters2D" /> <param index="0" name="parameters" type="PhysicsPointQueryParameters2D" />
<param index="1" name="max_results" type="int" default="32" /> <param index="1" name="max_results" type="int" default="32" />
<description> <description>
@ -72,7 +72,7 @@
</description> </description>
</method> </method>
<method name="intersect_shape"> <method name="intersect_shape">
<return type="Array" /> <return type="Dictionary[]" />
<param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" /> <param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" />
<param index="1" name="max_results" type="int" default="32" /> <param index="1" name="max_results" type="int" default="32" />
<description> <description>

View file

@ -12,7 +12,7 @@
</tutorials> </tutorials>
<methods> <methods>
<method name="cast_motion"> <method name="cast_motion">
<return type="Array" /> <return type="PackedFloat32Array" />
<param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" /> <param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" />
<description> <description>
Checks how far a [Shape3D] can move without colliding. All the parameters for the query, including the shape, are supplied through a [PhysicsShapeQueryParameters3D] object. Checks how far a [Shape3D] can move without colliding. All the parameters for the query, including the shape, are supplied through a [PhysicsShapeQueryParameters3D] object.
@ -21,7 +21,7 @@
</description> </description>
</method> </method>
<method name="collide_shape"> <method name="collide_shape">
<return type="Array" /> <return type="PackedVector2Array[]" />
<param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" /> <param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" />
<param index="1" name="max_results" type="int" default="32" /> <param index="1" name="max_results" type="int" default="32" />
<description> <description>
@ -46,7 +46,7 @@
</description> </description>
</method> </method>
<method name="intersect_point"> <method name="intersect_point">
<return type="Array" /> <return type="Dictionary[]" />
<param index="0" name="parameters" type="PhysicsPointQueryParameters3D" /> <param index="0" name="parameters" type="PhysicsPointQueryParameters3D" />
<param index="1" name="max_results" type="int" default="32" /> <param index="1" name="max_results" type="int" default="32" />
<description> <description>
@ -73,7 +73,7 @@
</description> </description>
</method> </method>
<method name="intersect_shape"> <method name="intersect_shape">
<return type="Array" /> <return type="Dictionary[]" />
<param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" /> <param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" />
<param index="1" name="max_results" type="int" default="32" /> <param index="1" name="max_results" type="int" default="32" />
<description> <description>

View file

@ -19,7 +19,7 @@
</description> </description>
</method> </method>
<method name="get_ids" qualifiers="const"> <method name="get_ids" qualifiers="const">
<return type="Array" /> <return type="RID[]" />
<description> <description>
</description> </description>
</method> </method>

View file

@ -1959,7 +1959,7 @@
</description> </description>
</method> </method>
<method name="mesh_surface_get_blend_shape_arrays" qualifiers="const"> <method name="mesh_surface_get_blend_shape_arrays" qualifiers="const">
<return type="Array" /> <return type="Array[]" />
<param index="0" name="mesh" type="RID" /> <param index="0" name="mesh" type="RID" />
<param index="1" name="surface" type="int" /> <param index="1" name="surface" type="int" />
<description> <description>

View file

@ -98,7 +98,7 @@
</description> </description>
</method> </method>
<method name="get_colliding_bodies" qualifiers="const"> <method name="get_colliding_bodies" qualifiers="const">
<return type="Array" /> <return type="Node3D[]" />
<description> <description>
Returns a list of the bodies colliding with this one. Requires [member contact_monitor] to be set to [code]true[/code] and [member contacts_reported] to be set high enough to detect all the collisions. Returns a list of the bodies colliding with this one. Requires [member contact_monitor] to be set to [code]true[/code] and [member contacts_reported] to be set high enough to detect all the collisions.
[b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead. [b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead.

View file

@ -113,14 +113,14 @@
</description> </description>
</method> </method>
<method name="get_nodes_in_group"> <method name="get_nodes_in_group">
<return type="Array" /> <return type="Node[]" />
<param index="0" name="group" type="StringName" /> <param index="0" name="group" type="StringName" />
<description> <description>
Returns a list of all nodes assigned to the given group. Returns a list of all nodes assigned to the given group.
</description> </description>
</method> </method>
<method name="get_processed_tweens"> <method name="get_processed_tweens">
<return type="Array" /> <return type="Tween[]" />
<description> <description>
Returns an array of currently existing [Tween]s in the [SceneTree] (both running and paused). Returns an array of currently existing [Tween]s in the [SceneTree] (both running and paused).
</description> </description>

View file

@ -44,19 +44,19 @@
</description> </description>
</method> </method>
<method name="get_script_method_list"> <method name="get_script_method_list">
<return type="Array" /> <return type="Dictionary[]" />
<description> <description>
Returns the list of methods in this [Script]. Returns the list of methods in this [Script].
</description> </description>
</method> </method>
<method name="get_script_property_list"> <method name="get_script_property_list">
<return type="Array" /> <return type="Dictionary[]" />
<description> <description>
Returns the list of properties in this [Script]. Returns the list of properties in this [Script].
</description> </description>
</method> </method>
<method name="get_script_signal_list"> <method name="get_script_signal_list">
<return type="Array" /> <return type="Dictionary[]" />
<description> <description>
Returns the list of user signals defined in this [Script]. Returns the list of user signals defined in this [Script].
</description> </description>

View file

@ -22,13 +22,13 @@
</description> </description>
</method> </method>
<method name="get_open_script_editors" qualifiers="const"> <method name="get_open_script_editors" qualifiers="const">
<return type="Array" /> <return type="ScriptEditorBase[]" />
<description> <description>
Returns an array with all [ScriptEditorBase] objects which are currently open in editor. Returns an array with all [ScriptEditorBase] objects which are currently open in editor.
</description> </description>
</method> </method>
<method name="get_open_scripts" qualifiers="const"> <method name="get_open_scripts" qualifiers="const">
<return type="Array" /> <return type="Script[]" />
<description> <description>
Returns an array with all [Script] objects which are currently open in editor. Returns an array with all [Script] objects which are currently open in editor.
</description> </description>

View file

@ -21,7 +21,7 @@
</description> </description>
</method> </method>
<method name="collide_and_get_contacts"> <method name="collide_and_get_contacts">
<return type="Array" /> <return type="PackedVector2Array" />
<param index="0" name="local_xform" type="Transform2D" /> <param index="0" name="local_xform" type="Transform2D" />
<param index="1" name="with_shape" type="Shape2D" /> <param index="1" name="with_shape" type="Shape2D" />
<param index="2" name="shape_xform" type="Transform2D" /> <param index="2" name="shape_xform" type="Transform2D" />
@ -45,7 +45,7 @@
</description> </description>
</method> </method>
<method name="collide_with_motion_and_get_contacts"> <method name="collide_with_motion_and_get_contacts">
<return type="Array" /> <return type="PackedVector2Array" />
<param index="0" name="local_xform" type="Transform2D" /> <param index="0" name="local_xform" type="Transform2D" />
<param index="1" name="local_motion" type="Vector2" /> <param index="1" name="local_motion" type="Vector2" />
<param index="2" name="with_shape" type="Shape2D" /> <param index="2" name="with_shape" type="Shape2D" />

View file

@ -19,7 +19,7 @@
</description> </description>
</method> </method>
<method name="get_collision_exceptions"> <method name="get_collision_exceptions">
<return type="Array" /> <return type="PhysicsBody3D[]" />
<description> <description>
Returns an array of nodes that were added as collision exceptions for this body. Returns an array of nodes that were added as collision exceptions for this body.
</description> </description>

View file

@ -81,7 +81,7 @@
</description> </description>
</method> </method>
<method name="get_node_connections" qualifiers="const"> <method name="get_node_connections" qualifiers="const">
<return type="Array" /> <return type="Dictionary[]" />
<param index="0" name="type" type="int" enum="VisualShader.Type" /> <param index="0" name="type" type="int" enum="VisualShader.Type" />
<description> <description>
Returns the list of connected nodes with the specified type. Returns the list of connected nodes with the specified type.

View file

@ -1156,8 +1156,8 @@ Ref<Script> ScriptEditor::_get_current_script() {
} }
} }
Array ScriptEditor::_get_open_scripts() const { TypedArray<Script> ScriptEditor::_get_open_scripts() const {
Array ret; TypedArray<Script> ret;
Vector<Ref<Script>> scripts = get_open_scripts(); Vector<Ref<Script>> scripts = get_open_scripts();
int scrits_amount = scripts.size(); int scrits_amount = scripts.size();
for (int idx_script = 0; idx_script < scrits_amount; idx_script++) { for (int idx_script = 0; idx_script < scrits_amount; idx_script++) {
@ -3446,8 +3446,8 @@ Vector<Ref<Script>> ScriptEditor::get_open_scripts() const {
return out_scripts; return out_scripts;
} }
Array ScriptEditor::_get_open_script_editors() const { TypedArray<ScriptEditorBase> ScriptEditor::_get_open_script_editors() const {
Array script_editors; TypedArray<ScriptEditorBase> script_editors;
for (int i = 0; i < tab_container->get_tab_count(); i++) { for (int i = 0; i < tab_container->get_tab_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
if (!se) { if (!se) {

View file

@ -386,7 +386,7 @@ class ScriptEditor : public PanelContainer {
Array _get_cached_breakpoints_for_script(const String &p_path) const; Array _get_cached_breakpoints_for_script(const String &p_path) const;
ScriptEditorBase *_get_current_editor() const; ScriptEditorBase *_get_current_editor() const;
Array _get_open_script_editors() const; TypedArray<ScriptEditorBase> _get_open_script_editors() const;
Ref<ConfigFile> script_editor_cache; Ref<ConfigFile> script_editor_cache;
void _save_editor_state(ScriptEditorBase *p_editor); void _save_editor_state(ScriptEditorBase *p_editor);
@ -452,7 +452,7 @@ class ScriptEditor : public PanelContainer {
void _file_dialog_action(String p_file); void _file_dialog_action(String p_file);
Ref<Script> _get_current_script(); Ref<Script> _get_current_script();
Array _get_open_scripts() const; TypedArray<Script> _get_open_scripts() const;
HashSet<String> textfile_extensions; HashSet<String> textfile_extensions;
Ref<TextFile> _load_text_file(const String &p_path, Error *r_error) const; Ref<TextFile> _load_text_file(const String &p_path, Error *r_error) const;

View file

@ -32,6 +32,7 @@
#include "core/object/message_queue.h" #include "core/object/message_queue.h"
#include "core/os/os.h" #include "core/os/os.h"
#include "core/variant/typed_array.h"
#include "scene/main/node.h" #include "scene/main/node.h"
#include "scene/main/scene_tree.h" #include "scene/main/scene_tree.h"
#include "servers/audio_server.h" #include "servers/audio_server.h"
@ -240,11 +241,11 @@ Variant Performance::get_custom_monitor(const StringName &p_id) {
return return_value; return return_value;
} }
Array Performance::get_custom_monitor_names() { TypedArray<StringName> Performance::get_custom_monitor_names() {
if (!_monitor_map.size()) { if (!_monitor_map.size()) {
return Array(); return TypedArray<StringName>();
} }
Array return_array; TypedArray<StringName> return_array;
return_array.resize(_monitor_map.size()); return_array.resize(_monitor_map.size());
int index = 0; int index = 0;
for (KeyValue<StringName, MonitorCall> i : _monitor_map) { for (KeyValue<StringName, MonitorCall> i : _monitor_map) {

View file

@ -37,6 +37,9 @@
#define PERF_WARN_OFFLINE_FUNCTION #define PERF_WARN_OFFLINE_FUNCTION
#define PERF_WARN_PROCESS_SYNC #define PERF_WARN_PROCESS_SYNC
template <typename T>
class TypedArray;
class Performance : public Object { class Performance : public Object {
GDCLASS(Performance, Object); GDCLASS(Performance, Object);
@ -107,7 +110,7 @@ public:
void remove_custom_monitor(const StringName &p_id); void remove_custom_monitor(const StringName &p_id);
bool has_custom_monitor(const StringName &p_id); bool has_custom_monitor(const StringName &p_id);
Variant get_custom_monitor(const StringName &p_id); Variant get_custom_monitor(const StringName &p_id);
Array get_custom_monitor_names(); TypedArray<StringName> get_custom_monitor_names();
uint64_t get_monitor_modification_time(); uint64_t get_monitor_modification_time();

View file

@ -102,13 +102,13 @@
</description> </description>
</method> </method>
<method name="get_used_cells" qualifiers="const"> <method name="get_used_cells" qualifiers="const">
<return type="Array" /> <return type="Vector3i[]" />
<description> <description>
Returns an array of [Vector3] with the non-empty cell coordinates in the grid map. Returns an array of [Vector3] with the non-empty cell coordinates in the grid map.
</description> </description>
</method> </method>
<method name="get_used_cells_by_item" qualifiers="const"> <method name="get_used_cells_by_item" qualifiers="const">
<return type="Array" /> <return type="Vector3i[]" />
<param index="0" name="item" type="int" /> <param index="0" name="item" type="int" />
<description> <description>
Returns an array of all cells with the given item index specified in [code]item[/code]. Returns an array of all cells with the given item index specified in [code]item[/code].

View file

@ -1049,23 +1049,23 @@ float GridMap::get_cell_scale() const {
return cell_scale; return cell_scale;
} }
Array GridMap::get_used_cells() const { TypedArray<Vector3i> GridMap::get_used_cells() const {
Array a; TypedArray<Vector3i> a;
a.resize(cell_map.size()); a.resize(cell_map.size());
int i = 0; int i = 0;
for (const KeyValue<IndexKey, Cell> &E : cell_map) { for (const KeyValue<IndexKey, Cell> &E : cell_map) {
Vector3 p(E.key.x, E.key.y, E.key.z); Vector3i p(E.key.x, E.key.y, E.key.z);
a[i++] = p; a[i++] = p;
} }
return a; return a;
} }
Array GridMap::get_used_cells_by_item(int p_item) const { TypedArray<Vector3i> GridMap::get_used_cells_by_item(int p_item) const {
Array a; TypedArray<Vector3i> a;
for (const KeyValue<IndexKey, Cell> &E : cell_map) { for (const KeyValue<IndexKey, Cell> &E : cell_map) {
if (E.value.item == p_item) { if (E.value.item == p_item) {
Vector3 p(E.key.x, E.key.y, E.key.z); Vector3i p(E.key.x, E.key.y, E.key.z);
a.push_back(p); a.push_back(p);
} }
} }

View file

@ -273,8 +273,8 @@ public:
void set_cell_scale(float p_scale); void set_cell_scale(float p_scale);
float get_cell_scale() const; float get_cell_scale() const;
Array get_used_cells() const; TypedArray<Vector3i> get_used_cells() const;
Array get_used_cells_by_item(int p_item) const; TypedArray<Vector3i> get_used_cells_by_item(int p_item) const;
Array get_meshes() const; Array get_meshes() const;

View file

@ -123,8 +123,8 @@ void GodotNavigationServer::add_command(SetCommand *command) const {
} }
} }
Array GodotNavigationServer::get_maps() const { TypedArray<RID> GodotNavigationServer::get_maps() const {
Array all_map_rids; TypedArray<RID> all_map_rids;
List<RID> maps_owned; List<RID> maps_owned;
map_owner.get_owned_list(&maps_owned); map_owner.get_owned_list(&maps_owned);
if (maps_owned.size()) { if (maps_owned.size()) {
@ -245,8 +245,8 @@ RID GodotNavigationServer::map_get_closest_point_owner(RID p_map, const Vector3
return map->get_closest_point_owner(p_point); return map->get_closest_point_owner(p_point);
} }
Array GodotNavigationServer::map_get_regions(RID p_map) const { TypedArray<RID> GodotNavigationServer::map_get_regions(RID p_map) const {
Array regions_rids; TypedArray<RID> regions_rids;
const NavMap *map = map_owner.get_or_null(p_map); const NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND_V(map == nullptr, regions_rids); ERR_FAIL_COND_V(map == nullptr, regions_rids);
const LocalVector<NavRegion *> regions = map->get_regions(); const LocalVector<NavRegion *> regions = map->get_regions();
@ -257,8 +257,8 @@ Array GodotNavigationServer::map_get_regions(RID p_map) const {
return regions_rids; return regions_rids;
} }
Array GodotNavigationServer::map_get_agents(RID p_map) const { TypedArray<RID> GodotNavigationServer::map_get_agents(RID p_map) const {
Array agents_rids; TypedArray<RID> agents_rids;
const NavMap *map = map_owner.get_or_null(p_map); const NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND_V(map == nullptr, agents_rids); ERR_FAIL_COND_V(map == nullptr, agents_rids);
const LocalVector<RvoAgent *> agents = map->get_agents(); const LocalVector<RvoAgent *> agents = map->get_agents();

View file

@ -85,7 +85,7 @@ public:
void add_command(SetCommand *command) const; void add_command(SetCommand *command) const;
virtual Array get_maps() const override; virtual TypedArray<RID> get_maps() const override;
virtual RID map_create() const override; virtual RID map_create() const override;
COMMAND_2(map_set_active, RID, p_map, bool, p_active); COMMAND_2(map_set_active, RID, p_map, bool, p_active);
@ -107,8 +107,8 @@ public:
virtual Vector3 map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const override; virtual Vector3 map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const override;
virtual RID map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const override; virtual RID map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const override;
virtual Array map_get_regions(RID p_map) const override; virtual TypedArray<RID> map_get_regions(RID p_map) const override;
virtual Array map_get_agents(RID p_map) const override; virtual TypedArray<RID> map_get_agents(RID p_map) const override;
virtual void map_force_update(RID p_map) override; virtual void map_force_update(RID p_map) override;

View file

@ -849,7 +849,7 @@ RigidDynamicBody2D::CCDMode RigidDynamicBody2D::get_continuous_collision_detecti
} }
TypedArray<Node2D> RigidDynamicBody2D::get_colliding_bodies() const { TypedArray<Node2D> RigidDynamicBody2D::get_colliding_bodies() const {
ERR_FAIL_COND_V(!contact_monitor, Array()); ERR_FAIL_COND_V(!contact_monitor, TypedArray<Node2D>());
TypedArray<Node2D> ret; TypedArray<Node2D> ret;
ret.resize(contact_monitor->body_map.size()); ret.resize(contact_monitor->body_map.size());

View file

@ -561,8 +561,8 @@ void Node3D::clear_gizmos() {
#endif #endif
} }
Array Node3D::get_gizmos_bind() const { TypedArray<Node3DGizmo> Node3D::get_gizmos_bind() const {
Array ret; TypedArray<Node3DGizmo> ret;
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
for (int i = 0; i < data.gizmos.size(); i++) { for (int i = 0; i < data.gizmos.size(); i++) {

View file

@ -216,7 +216,7 @@ public:
void set_subgizmo_selection(Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform = Transform3D()); void set_subgizmo_selection(Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform = Transform3D());
void clear_subgizmo_selection(); void clear_subgizmo_selection();
Vector<Ref<Node3DGizmo>> get_gizmos() const; Vector<Ref<Node3DGizmo>> get_gizmos() const;
Array get_gizmos_bind() const; TypedArray<Node3DGizmo> get_gizmos_bind() const;
void add_gizmo(Ref<Node3DGizmo> p_gizmo); void add_gizmo(Ref<Node3DGizmo> p_gizmo);
void remove_gizmo(Ref<Node3DGizmo> p_gizmo); void remove_gizmo(Ref<Node3DGizmo> p_gizmo);
void clear_gizmos(); void clear_gizmos();

View file

@ -960,10 +960,10 @@ bool RigidDynamicBody3D::is_contact_monitor_enabled() const {
return contact_monitor != nullptr; return contact_monitor != nullptr;
} }
Array RigidDynamicBody3D::get_colliding_bodies() const { TypedArray<Node3D> RigidDynamicBody3D::get_colliding_bodies() const {
ERR_FAIL_COND_V(!contact_monitor, Array()); ERR_FAIL_COND_V(!contact_monitor, TypedArray<Node3D>());
Array ret; TypedArray<Node3D> ret;
ret.resize(contact_monitor->body_map.size()); ret.resize(contact_monitor->body_map.size());
int idx = 0; int idx = 0;
for (const KeyValue<ObjectID, BodyState> &E : contact_monitor->body_map) { for (const KeyValue<ObjectID, BodyState> &E : contact_monitor->body_map) {

View file

@ -304,7 +304,7 @@ public:
void set_use_continuous_collision_detection(bool p_enable); void set_use_continuous_collision_detection(bool p_enable);
bool is_using_continuous_collision_detection() const; bool is_using_continuous_collision_detection() const;
Array get_colliding_bodies() const; TypedArray<Node3D> get_colliding_bodies() const;
void apply_central_impulse(const Vector3 &p_impulse); void apply_central_impulse(const Vector3 &p_impulse);
void apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position = Vector3()); void apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position = Vector3());

View file

@ -591,10 +591,10 @@ Vector<SoftDynamicBody3D::PinnedPoint> SoftDynamicBody3D::get_pinned_points_indi
return pinned_points; return pinned_points;
} }
Array SoftDynamicBody3D::get_collision_exceptions() { TypedArray<PhysicsBody3D> SoftDynamicBody3D::get_collision_exceptions() {
List<RID> exceptions; List<RID> exceptions;
PhysicsServer3D::get_singleton()->soft_body_get_collision_exceptions(physics_rid, &exceptions); PhysicsServer3D::get_singleton()->soft_body_get_collision_exceptions(physics_rid, &exceptions);
Array ret; TypedArray<PhysicsBody3D> ret;
for (const RID &body : exceptions) { for (const RID &body : exceptions) {
ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body); ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body);
Object *obj = ObjectDB::get_instance(instance_id); Object *obj = ObjectDB::get_instance(instance_id);

View file

@ -34,6 +34,7 @@
#include "scene/3d/mesh_instance_3d.h" #include "scene/3d/mesh_instance_3d.h"
#include "servers/physics_server_3d.h" #include "servers/physics_server_3d.h"
class PhysicsBody3D;
class SoftDynamicBody3D; class SoftDynamicBody3D;
class SoftDynamicBodyRenderingServerHandler : public PhysicsServer3DRenderingServerHandler { class SoftDynamicBodyRenderingServerHandler : public PhysicsServer3DRenderingServerHandler {
@ -168,7 +169,7 @@ public:
void set_drag_coefficient(real_t p_drag_coefficient); void set_drag_coefficient(real_t p_drag_coefficient);
real_t get_drag_coefficient(); real_t get_drag_coefficient();
Array get_collision_exceptions(); TypedArray<PhysicsBody3D> get_collision_exceptions();
void add_collision_exception_with(Node *p_node); void add_collision_exception_with(Node *p_node);
void remove_collision_exception_with(Node *p_node); void remove_collision_exception_with(Node *p_node);

View file

@ -1591,10 +1591,10 @@ void GraphEdit::remove_valid_left_disconnect_type(int p_type) {
valid_left_disconnect_types.erase(p_type); valid_left_disconnect_types.erase(p_type);
} }
Array GraphEdit::_get_connection_list() const { TypedArray<Dictionary> GraphEdit::_get_connection_list() const {
List<Connection> conns; List<Connection> conns;
get_connection_list(&conns); get_connection_list(&conns);
Array arr; TypedArray<Dictionary> arr;
for (const Connection &E : conns) { for (const Connection &E : conns) {
Dictionary d; Dictionary d;
d["from"] = E.from; d["from"] = E.from;

View file

@ -206,7 +206,7 @@ private:
void _minimap_draw(); void _minimap_draw();
void _update_scroll_offset(); void _update_scroll_offset();
Array _get_connection_list() const; TypedArray<Dictionary> _get_connection_list() const;
bool lines_on_bg = false; bool lines_on_bg = false;

View file

@ -1778,8 +1778,8 @@ void Node::remove_from_group(const StringName &p_identifier) {
data.grouped.remove(E); data.grouped.remove(E);
} }
Array Node::_get_groups() const { TypedArray<StringName> Node::_get_groups() const {
Array groups; TypedArray<StringName> groups;
List<GroupInfo> gi; List<GroupInfo> gi;
get_groups(&gi); get_groups(&gi);
for (const GroupInfo &E : gi) { for (const GroupInfo &E : gi) {

View file

@ -181,7 +181,7 @@ private:
Node *_duplicate(int p_flags, HashMap<const Node *, Node *> *r_duplimap = nullptr) const; Node *_duplicate(int p_flags, HashMap<const Node *, Node *> *r_duplimap = nullptr) const;
TypedArray<Node> _get_children(bool p_include_internal = true) const; TypedArray<Node> _get_children(bool p_include_internal = true) const;
Array _get_groups() const; TypedArray<StringName> _get_groups() const;
Error _rpc_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error); Error _rpc_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
Error _rpc_id_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error); Error _rpc_id_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);

View file

@ -1000,8 +1000,8 @@ int64_t SceneTree::get_frame() const {
return current_frame; return current_frame;
} }
Array SceneTree::_get_nodes_in_group(const StringName &p_group) { TypedArray<Node> SceneTree::_get_nodes_in_group(const StringName &p_group) {
Array ret; TypedArray<Node> ret;
HashMap<StringName, Group>::Iterator E = group_map.find(p_group); HashMap<StringName, Group>::Iterator E = group_map.find(p_group);
if (!E) { if (!E) {
return ret; return ret;
@ -1171,8 +1171,8 @@ Ref<Tween> SceneTree::create_tween() {
return tween; return tween;
} }
Array SceneTree::get_processed_tweens() { TypedArray<Tween> SceneTree::get_processed_tweens() {
Array ret; TypedArray<Tween> ret;
ret.resize(tweens.size()); ret.resize(tweens.size());
int i = 0; int i = 0;

View file

@ -141,7 +141,7 @@ private:
_FORCE_INLINE_ void _update_group_order(Group &g, bool p_use_priority = false); _FORCE_INLINE_ void _update_group_order(Group &g, bool p_use_priority = false);
Array _get_nodes_in_group(const StringName &p_group); TypedArray<Node> _get_nodes_in_group(const StringName &p_group);
Node *current_scene = nullptr; Node *current_scene = nullptr;
@ -367,7 +367,7 @@ public:
Ref<SceneTreeTimer> create_timer(double p_delay_sec, bool p_process_always = true); Ref<SceneTreeTimer> create_timer(double p_delay_sec, bool p_process_always = true);
Ref<Tween> create_tween(); Ref<Tween> create_tween();
Array get_processed_tweens(); TypedArray<Tween> get_processed_tweens();
//used by Main::start, don't use otherwise //used by Main::start, don't use otherwise
void add_current_scene(Node *p_current); void add_current_scene(Node *p_current);

View file

@ -340,8 +340,8 @@ Array ImmediateMesh::surface_get_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface, int(surfaces.size()), Array()); ERR_FAIL_INDEX_V(p_surface, int(surfaces.size()), Array());
return RS::get_singleton()->mesh_surface_get_arrays(mesh, p_surface); return RS::get_singleton()->mesh_surface_get_arrays(mesh, p_surface);
} }
Array ImmediateMesh::surface_get_blend_shape_arrays(int p_surface) const { TypedArray<Array> ImmediateMesh::surface_get_blend_shape_arrays(int p_surface) const {
return Array(); return TypedArray<Array>();
} }
Dictionary ImmediateMesh::surface_get_lods(int p_surface) const { Dictionary ImmediateMesh::surface_get_lods(int p_surface) const {
return Dictionary(); return Dictionary();

View file

@ -97,7 +97,7 @@ public:
virtual int surface_get_array_len(int p_idx) const override; virtual int surface_get_array_len(int p_idx) const override;
virtual int surface_get_array_index_len(int p_idx) const override; virtual int surface_get_array_index_len(int p_idx) const override;
virtual Array surface_get_arrays(int p_surface) const override; virtual Array surface_get_arrays(int p_surface) const override;
virtual Array surface_get_blend_shape_arrays(int p_surface) const override; virtual TypedArray<Array> surface_get_blend_shape_arrays(int p_surface) const override;
virtual Dictionary surface_get_lods(int p_surface) const override; virtual Dictionary surface_get_lods(int p_surface) const override;
virtual uint32_t surface_get_format(int p_idx) const override; virtual uint32_t surface_get_format(int p_idx) const override;
virtual PrimitiveType surface_get_primitive_type(int p_idx) const override; virtual PrimitiveType surface_get_primitive_type(int p_idx) const override;

View file

@ -71,13 +71,13 @@ Array Mesh::surface_get_arrays(int p_surface) const {
return Array(); return Array();
} }
Array Mesh::surface_get_blend_shape_arrays(int p_surface) const { TypedArray<Array> Mesh::surface_get_blend_shape_arrays(int p_surface) const {
Array ret; TypedArray<Array> ret;
if (GDVIRTUAL_REQUIRED_CALL(_surface_get_blend_shape_arrays, p_surface, ret)) { if (GDVIRTUAL_REQUIRED_CALL(_surface_get_blend_shape_arrays, p_surface, ret)) {
return ret; return ret;
} }
return Array(); return TypedArray<Array>();
} }
Dictionary Mesh::surface_get_lods(int p_surface) const { Dictionary Mesh::surface_get_lods(int p_surface) const {
@ -1640,8 +1640,8 @@ Array ArrayMesh::surface_get_arrays(int p_surface) const {
return RenderingServer::get_singleton()->mesh_surface_get_arrays(mesh, p_surface); return RenderingServer::get_singleton()->mesh_surface_get_arrays(mesh, p_surface);
} }
Array ArrayMesh::surface_get_blend_shape_arrays(int p_surface) const { TypedArray<Array> ArrayMesh::surface_get_blend_shape_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array()); ERR_FAIL_INDEX_V(p_surface, surfaces.size(), TypedArray<Array>());
return RenderingServer::get_singleton()->mesh_surface_get_blend_shape_arrays(mesh, p_surface); return RenderingServer::get_singleton()->mesh_surface_get_blend_shape_arrays(mesh, p_surface);
} }

View file

@ -63,7 +63,7 @@ protected:
GDVIRTUAL1RC(int, _surface_get_array_len, int) GDVIRTUAL1RC(int, _surface_get_array_len, int)
GDVIRTUAL1RC(int, _surface_get_array_index_len, int) GDVIRTUAL1RC(int, _surface_get_array_index_len, int)
GDVIRTUAL1RC(Array, _surface_get_arrays, int) GDVIRTUAL1RC(Array, _surface_get_arrays, int)
GDVIRTUAL1RC(Array, _surface_get_blend_shape_arrays, int) GDVIRTUAL1RC(TypedArray<Array>, _surface_get_blend_shape_arrays, int)
GDVIRTUAL1RC(Dictionary, _surface_get_lods, int) GDVIRTUAL1RC(Dictionary, _surface_get_lods, int)
GDVIRTUAL1RC(uint32_t, _surface_get_format, int) GDVIRTUAL1RC(uint32_t, _surface_get_format, int)
GDVIRTUAL1RC(uint32_t, _surface_get_primitive_type, int) GDVIRTUAL1RC(uint32_t, _surface_get_primitive_type, int)
@ -151,7 +151,7 @@ public:
virtual int surface_get_array_len(int p_idx) const; virtual int surface_get_array_len(int p_idx) const;
virtual int surface_get_array_index_len(int p_idx) const; virtual int surface_get_array_index_len(int p_idx) const;
virtual Array surface_get_arrays(int p_surface) const; virtual Array surface_get_arrays(int p_surface) const;
virtual Array surface_get_blend_shape_arrays(int p_surface) const; virtual TypedArray<Array> surface_get_blend_shape_arrays(int p_surface) const;
virtual Dictionary surface_get_lods(int p_surface) const; virtual Dictionary surface_get_lods(int p_surface) const;
virtual uint32_t surface_get_format(int p_idx) const; virtual uint32_t surface_get_format(int p_idx) const;
virtual PrimitiveType surface_get_primitive_type(int p_idx) const; virtual PrimitiveType surface_get_primitive_type(int p_idx) const;
@ -270,7 +270,7 @@ public:
void add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, const Vector<uint8_t> &p_attribute_array, const Vector<uint8_t> &p_skin_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<uint8_t> &p_blend_shape_data = Vector<uint8_t>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>(), const Vector<RS::SurfaceData::LOD> &p_lods = Vector<RS::SurfaceData::LOD>()); void add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, const Vector<uint8_t> &p_attribute_array, const Vector<uint8_t> &p_skin_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<uint8_t> &p_blend_shape_data = Vector<uint8_t>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>(), const Vector<RS::SurfaceData::LOD> &p_lods = Vector<RS::SurfaceData::LOD>());
Array surface_get_arrays(int p_surface) const override; Array surface_get_arrays(int p_surface) const override;
Array surface_get_blend_shape_arrays(int p_surface) const override; TypedArray<Array> surface_get_blend_shape_arrays(int p_surface) const override;
Dictionary surface_get_lods(int p_surface) const override; Dictionary surface_get_lods(int p_surface) const override;
void add_blend_shape(const StringName &p_name); void add_blend_shape(const StringName &p_name);
@ -345,7 +345,7 @@ public:
virtual int surface_get_array_len(int p_idx) const override { return 0; } virtual int surface_get_array_len(int p_idx) const override { return 0; }
virtual int surface_get_array_index_len(int p_idx) const override { return 0; } virtual int surface_get_array_index_len(int p_idx) const override { return 0; }
virtual Array surface_get_arrays(int p_surface) const override { return Array(); } virtual Array surface_get_arrays(int p_surface) const override { return Array(); }
virtual Array surface_get_blend_shape_arrays(int p_surface) const override { return Array(); } virtual TypedArray<Array> surface_get_blend_shape_arrays(int p_surface) const override { return TypedArray<Array>(); }
virtual Dictionary surface_get_lods(int p_surface) const override { return Dictionary(); } virtual Dictionary surface_get_lods(int p_surface) const override { return Dictionary(); }
virtual uint32_t surface_get_format(int p_idx) const override { return 0; } virtual uint32_t surface_get_format(int p_idx) const override { return 0; }
virtual PrimitiveType surface_get_primitive_type(int p_idx) const override { return PRIMITIVE_TRIANGLES; } virtual PrimitiveType surface_get_primitive_type(int p_idx) const override { return PRIMITIVE_TRIANGLES; }

View file

@ -152,8 +152,8 @@ Dictionary PrimitiveMesh::surface_get_lods(int p_surface) const {
return Dictionary(); //not really supported return Dictionary(); //not really supported
} }
Array PrimitiveMesh::surface_get_blend_shape_arrays(int p_surface) const { TypedArray<Array> PrimitiveMesh::surface_get_blend_shape_arrays(int p_surface) const {
return Array(); //not really supported return TypedArray<Array>(); //not really supported
} }
uint32_t PrimitiveMesh::surface_get_format(int p_idx) const { uint32_t PrimitiveMesh::surface_get_format(int p_idx) const {

View file

@ -75,7 +75,7 @@ public:
virtual int surface_get_array_len(int p_idx) const override; virtual int surface_get_array_len(int p_idx) const override;
virtual int surface_get_array_index_len(int p_idx) const override; virtual int surface_get_array_index_len(int p_idx) const override;
virtual Array surface_get_arrays(int p_surface) const override; virtual Array surface_get_arrays(int p_surface) const override;
virtual Array surface_get_blend_shape_arrays(int p_surface) const override; virtual TypedArray<Array> surface_get_blend_shape_arrays(int p_surface) const override;
virtual Dictionary surface_get_lods(int p_surface) const override; virtual Dictionary surface_get_lods(int p_surface) const override;
virtual uint32_t surface_get_format(int p_idx) const override; virtual uint32_t surface_get_format(int p_idx) const override;
virtual Mesh::PrimitiveType surface_get_primitive_type(int p_idx) const override; virtual Mesh::PrimitiveType surface_get_primitive_type(int p_idx) const override;

View file

@ -59,39 +59,39 @@ bool Shape2D::collide(const Transform2D &p_local_xform, const Ref<Shape2D> &p_sh
return PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), nullptr, 0, r); return PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), nullptr, 0, r);
} }
Array Shape2D::collide_with_motion_and_get_contacts(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_shape_motion) { PackedVector2Array Shape2D::collide_with_motion_and_get_contacts(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_shape_motion) {
ERR_FAIL_COND_V(p_shape.is_null(), Array()); ERR_FAIL_COND_V(p_shape.is_null(), PackedVector2Array());
const int max_contacts = 16; const int max_contacts = 16;
Vector2 result[max_contacts * 2]; Vector2 result[max_contacts * 2];
int contacts = 0; int contacts = 0;
if (!PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, result, max_contacts, contacts)) { if (!PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, result, max_contacts, contacts)) {
return Array(); return PackedVector2Array();
} }
Array results; PackedVector2Array results;
results.resize(contacts * 2); results.resize(contacts * 2);
for (int i = 0; i < contacts * 2; i++) { for (int i = 0; i < contacts * 2; i++) {
results[i] = result[i]; results.write[i] = result[i];
} }
return results; return results;
} }
Array Shape2D::collide_and_get_contacts(const Transform2D &p_local_xform, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform) { PackedVector2Array Shape2D::collide_and_get_contacts(const Transform2D &p_local_xform, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform) {
ERR_FAIL_COND_V(p_shape.is_null(), Array()); ERR_FAIL_COND_V(p_shape.is_null(), PackedVector2Array());
const int max_contacts = 16; const int max_contacts = 16;
Vector2 result[max_contacts * 2]; Vector2 result[max_contacts * 2];
int contacts = 0; int contacts = 0;
if (!PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), result, max_contacts, contacts)) { if (!PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), result, max_contacts, contacts)) {
return Array(); return PackedVector2Array();
} }
Array results; PackedVector2Array results;
results.resize(contacts * 2); results.resize(contacts * 2);
for (int i = 0; i < contacts * 2; i++) { for (int i = 0; i < contacts * 2; i++) {
results[i] = result[i]; results.write[i] = result[i];
} }
return results; return results;

View file

@ -53,8 +53,8 @@ public:
bool collide_with_motion(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_shape_motion); bool collide_with_motion(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_shape_motion);
bool collide(const Transform2D &p_local_xform, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform); bool collide(const Transform2D &p_local_xform, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform);
Array collide_with_motion_and_get_contacts(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_shape_motion); PackedVector2Array collide_with_motion_and_get_contacts(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_shape_motion);
Array collide_and_get_contacts(const Transform2D &p_local_xform, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform); PackedVector2Array collide_and_get_contacts(const Transform2D &p_local_xform, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform);
virtual void draw(const RID &p_to_rid, const Color &p_color) {} virtual void draw(const RID &p_to_rid, const Color &p_color) {}
virtual Rect2 get_rect() const { return Rect2(); } virtual Rect2 get_rect() const { return Rect2(); }

View file

@ -1036,11 +1036,11 @@ void VisualShader::disconnect_nodes(Type p_type, int p_from_node, int p_from_por
} }
} }
Array VisualShader::_get_node_connections(Type p_type) const { TypedArray<Dictionary> VisualShader::_get_node_connections(Type p_type) const {
ERR_FAIL_INDEX_V(p_type, TYPE_MAX, Array()); ERR_FAIL_INDEX_V(p_type, TYPE_MAX, Array());
const Graph *g = &graph[p_type]; const Graph *g = &graph[p_type];
Array ret; TypedArray<Dictionary> ret;
for (const Connection &E : g->connections) { for (const Connection &E : g->connections) {
Dictionary d; Dictionary d;
d["from_node"] = E.from_node; d["from_node"] = E.from_node;

View file

@ -132,7 +132,7 @@ private:
Shader::Mode shader_mode = Shader::MODE_SPATIAL; Shader::Mode shader_mode = Shader::MODE_SPATIAL;
mutable String previous_code; mutable String previous_code;
Array _get_node_connections(Type p_type) const; TypedArray<Dictionary> _get_node_connections(Type p_type) const;
Vector2 graph_offset; Vector2 graph_offset;

View file

@ -263,11 +263,11 @@ NavigationServer2D::~NavigationServer2D() {
singleton = nullptr; singleton = nullptr;
} }
Array FORWARD_0_C(get_maps); TypedArray<RID> FORWARD_0_C(get_maps);
Array FORWARD_1_C(map_get_regions, RID, p_map, rid_to_rid); TypedArray<RID> FORWARD_1_C(map_get_regions, RID, p_map, rid_to_rid);
Array FORWARD_1_C(map_get_agents, RID, p_map, rid_to_rid); TypedArray<RID> FORWARD_1_C(map_get_agents, RID, p_map, rid_to_rid);
RID FORWARD_1_C(region_get_map, RID, p_region, rid_to_rid); RID FORWARD_1_C(region_get_map, RID, p_region, rid_to_rid);

View file

@ -53,7 +53,7 @@ public:
/// MUST be used in single thread! /// MUST be used in single thread!
static NavigationServer2D *get_singleton_mut() { return singleton; } static NavigationServer2D *get_singleton_mut() { return singleton; }
virtual Array get_maps() const; virtual TypedArray<RID> get_maps() const;
/// Create a new map. /// Create a new map.
virtual RID map_create() const; virtual RID map_create() const;
@ -82,8 +82,8 @@ public:
virtual Vector2 map_get_closest_point(RID p_map, const Vector2 &p_point) const; virtual Vector2 map_get_closest_point(RID p_map, const Vector2 &p_point) const;
virtual RID map_get_closest_point_owner(RID p_map, const Vector2 &p_point) const; virtual RID map_get_closest_point_owner(RID p_map, const Vector2 &p_point) const;
virtual Array map_get_regions(RID p_map) const; virtual TypedArray<RID> map_get_regions(RID p_map) const;
virtual Array map_get_agents(RID p_map) const; virtual TypedArray<RID> map_get_agents(RID p_map) const;
virtual void map_force_update(RID p_map); virtual void map_force_update(RID p_map);

View file

@ -56,7 +56,7 @@ public:
/// MUST be used in single thread! /// MUST be used in single thread!
static NavigationServer3D *get_singleton_mut(); static NavigationServer3D *get_singleton_mut();
virtual Array get_maps() const = 0; virtual TypedArray<RID> get_maps() const = 0;
/// Create a new map. /// Create a new map.
virtual RID map_create() const = 0; virtual RID map_create() const = 0;
@ -93,8 +93,8 @@ public:
virtual Vector3 map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const = 0; virtual Vector3 map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const = 0;
virtual RID map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const = 0; virtual RID map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const = 0;
virtual Array map_get_regions(RID p_map) const = 0; virtual TypedArray<RID> map_get_regions(RID p_map) const = 0;
virtual Array map_get_agents(RID p_map) const = 0; virtual TypedArray<RID> map_get_agents(RID p_map) const = 0;
virtual void map_force_update(RID p_map) = 0; virtual void map_force_update(RID p_map) = 0;

View file

@ -32,6 +32,7 @@
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
#include "core/string/print_string.h" #include "core/string/print_string.h"
#include "core/variant/typed_array.h"
PhysicsServer2D *PhysicsServer2D::singleton = nullptr; PhysicsServer2D *PhysicsServer2D::singleton = nullptr;
@ -347,7 +348,7 @@ Dictionary PhysicsDirectSpaceState2D::_intersect_ray(const Ref<PhysicsRayQueryPa
return d; return d;
} }
Array PhysicsDirectSpaceState2D::_intersect_point(const Ref<PhysicsPointQueryParameters2D> &p_point_query, int p_max_results) { TypedArray<Dictionary> PhysicsDirectSpaceState2D::_intersect_point(const Ref<PhysicsPointQueryParameters2D> &p_point_query, int p_max_results) {
ERR_FAIL_COND_V(p_point_query.is_null(), Array()); ERR_FAIL_COND_V(p_point_query.is_null(), Array());
Vector<ShapeResult> ret; Vector<ShapeResult> ret;
@ -356,10 +357,10 @@ Array PhysicsDirectSpaceState2D::_intersect_point(const Ref<PhysicsPointQueryPar
int rc = intersect_point(p_point_query->get_parameters(), ret.ptrw(), ret.size()); int rc = intersect_point(p_point_query->get_parameters(), ret.ptrw(), ret.size());
if (rc == 0) { if (rc == 0) {
return Array(); return TypedArray<Dictionary>();
} }
Array r; TypedArray<Dictionary> r;
r.resize(rc); r.resize(rc);
for (int i = 0; i < rc; i++) { for (int i = 0; i < rc; i++) {
Dictionary d; Dictionary d;
@ -372,13 +373,13 @@ Array PhysicsDirectSpaceState2D::_intersect_point(const Ref<PhysicsPointQueryPar
return r; return r;
} }
Array PhysicsDirectSpaceState2D::_intersect_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results) { TypedArray<Dictionary> PhysicsDirectSpaceState2D::_intersect_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); ERR_FAIL_COND_V(!p_shape_query.is_valid(), TypedArray<Dictionary>());
Vector<ShapeResult> sr; Vector<ShapeResult> sr;
sr.resize(p_max_results); sr.resize(p_max_results);
int rc = intersect_shape(p_shape_query->get_parameters(), sr.ptrw(), sr.size()); int rc = intersect_shape(p_shape_query->get_parameters(), sr.ptrw(), sr.size());
Array ret; TypedArray<Dictionary> ret;
ret.resize(rc); ret.resize(rc);
for (int i = 0; i < rc; i++) { for (int i = 0; i < rc; i++) {
Dictionary d; Dictionary d;
@ -392,22 +393,22 @@ Array PhysicsDirectSpaceState2D::_intersect_shape(const Ref<PhysicsShapeQueryPar
return ret; return ret;
} }
Array PhysicsDirectSpaceState2D::_cast_motion(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query) { Vector<real_t> PhysicsDirectSpaceState2D::_cast_motion(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); ERR_FAIL_COND_V(!p_shape_query.is_valid(), Vector<real_t>());
real_t closest_safe, closest_unsafe; real_t closest_safe, closest_unsafe;
bool res = cast_motion(p_shape_query->get_parameters(), closest_safe, closest_unsafe); bool res = cast_motion(p_shape_query->get_parameters(), closest_safe, closest_unsafe);
if (!res) { if (!res) {
return Array(); return Vector<real_t>();
} }
Array ret; Vector<real_t> ret;
ret.resize(2); ret.resize(2);
ret[0] = closest_safe; ret.write[0] = closest_safe;
ret[1] = closest_unsafe; ret.write[1] = closest_unsafe;
return ret; return ret;
} }
Array PhysicsDirectSpaceState2D::_collide_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results) { TypedArray<PackedVector2Array> PhysicsDirectSpaceState2D::_collide_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
Vector<Vector2> ret; Vector<Vector2> ret;
@ -415,9 +416,9 @@ Array PhysicsDirectSpaceState2D::_collide_shape(const Ref<PhysicsShapeQueryParam
int rc = 0; int rc = 0;
bool res = collide_shape(p_shape_query->get_parameters(), ret.ptrw(), p_max_results, rc); bool res = collide_shape(p_shape_query->get_parameters(), ret.ptrw(), p_max_results, rc);
if (!res) { if (!res) {
return Array(); return TypedArray<PackedVector2Array>();
} }
Array r; TypedArray<PackedVector2Array> r;
r.resize(rc * 2); r.resize(rc * 2);
for (int i = 0; i < rc * 2; i++) { for (int i = 0; i < rc * 2; i++) {
r[i] = ret[i]; r[i] = ret[i];

View file

@ -36,6 +36,8 @@
#include "core/object/ref_counted.h" #include "core/object/ref_counted.h"
class PhysicsDirectSpaceState2D; class PhysicsDirectSpaceState2D;
template <typename T>
class TypedArray;
class PhysicsDirectBodyState2D : public Object { class PhysicsDirectBodyState2D : public Object {
GDCLASS(PhysicsDirectBodyState2D, Object); GDCLASS(PhysicsDirectBodyState2D, Object);
@ -114,10 +116,10 @@ class PhysicsDirectSpaceState2D : public Object {
GDCLASS(PhysicsDirectSpaceState2D, Object); GDCLASS(PhysicsDirectSpaceState2D, Object);
Dictionary _intersect_ray(const Ref<PhysicsRayQueryParameters2D> &p_ray_query); Dictionary _intersect_ray(const Ref<PhysicsRayQueryParameters2D> &p_ray_query);
Array _intersect_point(const Ref<PhysicsPointQueryParameters2D> &p_point_query, int p_max_results = 32); TypedArray<Dictionary> _intersect_point(const Ref<PhysicsPointQueryParameters2D> &p_point_query, int p_max_results = 32);
Array _intersect_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results = 32); TypedArray<Dictionary> _intersect_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results = 32);
Array _cast_motion(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query); Vector<real_t> _cast_motion(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query);
Array _collide_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results = 32); TypedArray<PackedVector2Array> _collide_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results = 32);
Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query); Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query);
protected: protected:

View file

@ -32,6 +32,7 @@
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
#include "core/string/print_string.h" #include "core/string/print_string.h"
#include "core/variant/typed_array.h"
void PhysicsServer3DRenderingServerHandler::set_vertex(int p_vertex_id, const void *p_vector3) { void PhysicsServer3DRenderingServerHandler::set_vertex(int p_vertex_id, const void *p_vector3) {
GDVIRTUAL_REQUIRED_CALL(_set_vertex, p_vertex_id, p_vector3); GDVIRTUAL_REQUIRED_CALL(_set_vertex, p_vertex_id, p_vector3);
@ -366,8 +367,8 @@ Dictionary PhysicsDirectSpaceState3D::_intersect_ray(const Ref<PhysicsRayQueryPa
return d; return d;
} }
Array PhysicsDirectSpaceState3D::_intersect_point(const Ref<PhysicsPointQueryParameters3D> &p_point_query, int p_max_results) { TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_point(const Ref<PhysicsPointQueryParameters3D> &p_point_query, int p_max_results) {
ERR_FAIL_COND_V(p_point_query.is_null(), Array()); ERR_FAIL_COND_V(p_point_query.is_null(), TypedArray<Dictionary>());
Vector<ShapeResult> ret; Vector<ShapeResult> ret;
ret.resize(p_max_results); ret.resize(p_max_results);
@ -375,10 +376,10 @@ Array PhysicsDirectSpaceState3D::_intersect_point(const Ref<PhysicsPointQueryPar
int rc = intersect_point(p_point_query->get_parameters(), ret.ptrw(), ret.size()); int rc = intersect_point(p_point_query->get_parameters(), ret.ptrw(), ret.size());
if (rc == 0) { if (rc == 0) {
return Array(); return TypedArray<Dictionary>();
} }
Array r; TypedArray<Dictionary> r;
r.resize(rc); r.resize(rc);
for (int i = 0; i < rc; i++) { for (int i = 0; i < rc; i++) {
Dictionary d; Dictionary d;
@ -391,13 +392,13 @@ Array PhysicsDirectSpaceState3D::_intersect_point(const Ref<PhysicsPointQueryPar
return r; return r;
} }
Array PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) { TypedArray<Dictionary> PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); ERR_FAIL_COND_V(!p_shape_query.is_valid(), TypedArray<Dictionary>());
Vector<ShapeResult> sr; Vector<ShapeResult> sr;
sr.resize(p_max_results); sr.resize(p_max_results);
int rc = intersect_shape(p_shape_query->get_parameters(), sr.ptrw(), sr.size()); int rc = intersect_shape(p_shape_query->get_parameters(), sr.ptrw(), sr.size());
Array ret; TypedArray<Dictionary> ret;
ret.resize(rc); ret.resize(rc);
for (int i = 0; i < rc; i++) { for (int i = 0; i < rc; i++) {
Dictionary d; Dictionary d;
@ -411,22 +412,22 @@ Array PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryPar
return ret; return ret;
} }
Array PhysicsDirectSpaceState3D::_cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query) { Vector<real_t> PhysicsDirectSpaceState3D::_cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); ERR_FAIL_COND_V(!p_shape_query.is_valid(), Vector<real_t>());
real_t closest_safe = 1.0f, closest_unsafe = 1.0f; real_t closest_safe = 1.0f, closest_unsafe = 1.0f;
bool res = cast_motion(p_shape_query->get_parameters(), closest_safe, closest_unsafe); bool res = cast_motion(p_shape_query->get_parameters(), closest_safe, closest_unsafe);
if (!res) { if (!res) {
return Array(); return Vector<real_t>();
} }
Array ret; Vector<real_t> ret;
ret.resize(2); ret.resize(2);
ret[0] = closest_safe; ret.write[0] = closest_safe;
ret[1] = closest_unsafe; ret.write[1] = closest_unsafe;
return ret; return ret;
} }
Array PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) { TypedArray<PackedVector2Array> PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
Vector<Vector3> ret; Vector<Vector3> ret;
@ -434,9 +435,9 @@ Array PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParam
int rc = 0; int rc = 0;
bool res = collide_shape(p_shape_query->get_parameters(), ret.ptrw(), p_max_results, rc); bool res = collide_shape(p_shape_query->get_parameters(), ret.ptrw(), p_max_results, rc);
if (!res) { if (!res) {
return Array(); return TypedArray<PackedVector2Array>();
} }
Array r; TypedArray<PackedVector2Array> r;
r.resize(rc * 2); r.resize(rc * 2);
for (int i = 0; i < rc * 2; i++) { for (int i = 0; i < rc * 2; i++) {
r[i] = ret[i]; r[i] = ret[i];

View file

@ -38,6 +38,8 @@
#include "core/variant/native_ptr.h" #include "core/variant/native_ptr.h"
class PhysicsDirectSpaceState3D; class PhysicsDirectSpaceState3D;
template <typename T>
class TypedArray;
class PhysicsDirectBodyState3D : public Object { class PhysicsDirectBodyState3D : public Object {
GDCLASS(PhysicsDirectBodyState3D, Object); GDCLASS(PhysicsDirectBodyState3D, Object);
@ -120,10 +122,10 @@ class PhysicsDirectSpaceState3D : public Object {
private: private:
Dictionary _intersect_ray(const Ref<PhysicsRayQueryParameters3D> &p_ray_query); Dictionary _intersect_ray(const Ref<PhysicsRayQueryParameters3D> &p_ray_query);
Array _intersect_point(const Ref<PhysicsPointQueryParameters3D> &p_point_query, int p_max_results = 32); TypedArray<Dictionary> _intersect_point(const Ref<PhysicsPointQueryParameters3D> &p_point_query, int p_max_results = 32);
Array _intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32); TypedArray<Dictionary> _intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32);
Array _cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query); Vector<real_t> _cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query);
Array _collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32); TypedArray<PackedVector2Array> _collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32);
Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query); Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query);
protected: protected:

View file

@ -443,8 +443,8 @@ public:
void add_id(const RID &p_id) { base.append_id(p_id); } void add_id(const RID &p_id) { base.append_id(p_id); }
void clear_ids() { base.clear_ids(); } void clear_ids() { base.clear_ids(); }
Array get_ids() const { TypedArray<RID> get_ids() const {
Array ids; TypedArray<RID> ids;
for (uint32_t i = 0; i < base.get_id_count(); i++) { for (uint32_t i = 0; i < base.get_id_count(); i++) {
ids.push_back(base.get_id(i)); ids.push_back(base.get_id(i));
} }
@ -452,7 +452,7 @@ public:
} }
protected: protected:
void _set_ids(const Array &p_ids) { void _set_ids(const TypedArray<RID> &p_ids) {
base.clear_ids(); base.clear_ids();
for (int i = 0; i < p_ids.size(); i++) { for (int i = 0; i < p_ids.size(); i++) {
RID id = p_ids[i]; RID id = p_ids[i];

View file

@ -31,6 +31,7 @@
#include "rendering_server.h" #include "rendering_server.h"
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
#include "core/variant/typed_array.h"
#include "servers/rendering/rendering_server_globals.h" #include "servers/rendering/rendering_server_globals.h"
#include "servers/rendering/shader_language.h" #include "servers/rendering/shader_language.h"
@ -1337,7 +1338,7 @@ Dictionary RenderingServer::mesh_surface_get_lods(RID p_mesh, int p_surface) con
return ret; return ret;
} }
Array RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const { TypedArray<Array> RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const {
SurfaceData sd = mesh_get_surface(p_mesh, p_surface); SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
ERR_FAIL_COND_V(sd.vertex_count == 0, Array()); ERR_FAIL_COND_V(sd.vertex_count == 0, Array());
@ -1359,7 +1360,7 @@ Array RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_sur
ERR_FAIL_COND_V(blend_shape_count != (uint32_t)mesh_get_blend_shape_count(p_mesh), Array()); ERR_FAIL_COND_V(blend_shape_count != (uint32_t)mesh_get_blend_shape_count(p_mesh), Array());
Array blend_shape_array; TypedArray<Array> blend_shape_array;
blend_shape_array.resize(mesh_get_blend_shape_count(p_mesh)); blend_shape_array.resize(mesh_get_blend_shape_count(p_mesh));
for (uint32_t i = 0; i < blend_shape_count; i++) { for (uint32_t i = 0; i < blend_shape_count; i++) {
Vector<uint8_t> bs_data = blend_shape_data.slice(i * divisor, (i + 1) * divisor); Vector<uint8_t> bs_data = blend_shape_data.slice(i * divisor, (i + 1) * divisor);
@ -1369,7 +1370,7 @@ Array RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_sur
return blend_shape_array; return blend_shape_array;
} else { } else {
return Array(); return TypedArray<Array>();
} }
} }

View file

@ -42,6 +42,9 @@
#include "servers/display_server.h" #include "servers/display_server.h"
#include "servers/rendering/rendering_device.h" #include "servers/rendering/rendering_device.h"
template <typename T>
class TypedArray;
class RenderingServer : public Object { class RenderingServer : public Object {
GDCLASS(RenderingServer, Object); GDCLASS(RenderingServer, Object);
@ -325,7 +328,7 @@ public:
virtual Error mesh_create_surface_data_from_arrays(SurfaceData *r_surface_data, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), uint32_t p_compress_format = 0); virtual Error mesh_create_surface_data_from_arrays(SurfaceData *r_surface_data, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), uint32_t p_compress_format = 0);
Array mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const; Array mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const;
Array mesh_surface_get_arrays(RID p_mesh, int p_surface) const; Array mesh_surface_get_arrays(RID p_mesh, int p_surface) const;
Array mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const; TypedArray<Array> mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const;
Dictionary mesh_surface_get_lods(RID p_mesh, int p_surface) const; Dictionary mesh_surface_get_lods(RID p_mesh, int p_surface) const;
virtual void mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), uint32_t p_compress_format = 0); virtual void mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), uint32_t p_compress_format = 0);