You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 19:31:35 +00:00
Merge pull request #63959 from KoBeWi/typo_arrray
Replace Array return types with TypedArray (part 1)
This commit is contained in:
@@ -361,8 +361,8 @@ void CollisionObject2D::get_shape_owners(List<uint32_t> *r_owners) {
|
||||
}
|
||||
}
|
||||
|
||||
Array CollisionObject2D::_get_shape_owners() {
|
||||
Array ret;
|
||||
PackedInt32Array CollisionObject2D::_get_shape_owners() {
|
||||
PackedInt32Array ret;
|
||||
for (const KeyValue<uint32_t, ShapeData> &E : shapes) {
|
||||
ret.push_back(E.key);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
uint32_t create_shape_owner(Object *p_owner);
|
||||
void remove_shape_owner(uint32_t owner);
|
||||
void get_shape_owners(List<uint32_t> *r_owners);
|
||||
Array _get_shape_owners();
|
||||
PackedInt32Array _get_shape_owners();
|
||||
|
||||
void shape_owner_set_transform(uint32_t p_owner, const Transform2D &p_transform);
|
||||
Transform2D shape_owner_get_transform(uint32_t p_owner) const;
|
||||
|
||||
@@ -485,7 +485,7 @@ void Camera3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_keep_aspect_mode"), &Camera3D::get_keep_aspect_mode);
|
||||
ClassDB::bind_method(D_METHOD("set_doppler_tracking", "mode"), &Camera3D::set_doppler_tracking);
|
||||
ClassDB::bind_method(D_METHOD("get_doppler_tracking"), &Camera3D::get_doppler_tracking);
|
||||
ClassDB::bind_method(D_METHOD("get_frustum"), &Camera3D::get_frustum);
|
||||
ClassDB::bind_method(D_METHOD("get_frustum"), &Camera3D::_get_frustum);
|
||||
ClassDB::bind_method(D_METHOD("is_position_in_frustum", "world_point"), &Camera3D::is_position_in_frustum);
|
||||
ClassDB::bind_method(D_METHOD("get_camera_rid"), &Camera3D::get_camera);
|
||||
ClassDB::bind_method(D_METHOD("get_pyramid_shape_rid"), &Camera3D::get_pyramid_shape_rid);
|
||||
@@ -615,6 +615,11 @@ Vector<Plane> Camera3D::get_frustum() const {
|
||||
return cm.get_projection_planes(get_camera_transform());
|
||||
}
|
||||
|
||||
TypedArray<Plane> Camera3D::_get_frustum() const {
|
||||
Variant ret = get_frustum();
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Camera3D::is_position_in_frustum(const Vector3 &p_position) const {
|
||||
Vector<Plane> frustum = get_frustum();
|
||||
for (int i = 0; i < frustum.size(); i++) {
|
||||
|
||||
@@ -86,6 +86,7 @@ private:
|
||||
// void _camera_make_current(Node *p_camera);
|
||||
friend class Viewport;
|
||||
void _update_audio_listener_state();
|
||||
TypedArray<Plane> _get_frustum() const;
|
||||
|
||||
DopplerTracking doppler_tracking = DOPPLER_TRACKING_DISABLED;
|
||||
Ref<VelocityTracker3D> velocity_tracker;
|
||||
|
||||
@@ -546,8 +546,8 @@ void CollisionObject3D::get_shape_owners(List<uint32_t> *r_owners) {
|
||||
}
|
||||
}
|
||||
|
||||
Array CollisionObject3D::_get_shape_owners() {
|
||||
Array ret;
|
||||
PackedInt32Array CollisionObject3D::_get_shape_owners() {
|
||||
PackedInt32Array ret;
|
||||
for (const KeyValue<uint32_t, ShapeData> &E : shapes) {
|
||||
ret.push_back(E.key);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
uint32_t create_shape_owner(Object *p_owner);
|
||||
void remove_shape_owner(uint32_t owner);
|
||||
void get_shape_owners(List<uint32_t> *r_owners);
|
||||
Array _get_shape_owners();
|
||||
PackedInt32Array _get_shape_owners();
|
||||
|
||||
void shape_owner_set_transform(uint32_t p_owner, const Transform3D &p_transform);
|
||||
Transform3D shape_owner_get_transform(uint32_t p_owner) const;
|
||||
|
||||
@@ -432,7 +432,7 @@ void Label3D::_shape() {
|
||||
TS->shaped_text_set_spacing(text_rid, TextServer::SpacingType(i), font->get_spacing(TextServer::SpacingType(i)));
|
||||
}
|
||||
|
||||
Array stt;
|
||||
TypedArray<Vector2i> stt;
|
||||
if (st_parser == TextServer::STRUCTURED_TEXT_CUSTOM) {
|
||||
GDVIRTUAL_CALL(_structured_text_parser, st_args, text, stt);
|
||||
} else {
|
||||
|
||||
@@ -490,8 +490,8 @@ void ButtonGroup::get_buttons(List<BaseButton *> *r_buttons) {
|
||||
}
|
||||
}
|
||||
|
||||
Array ButtonGroup::_get_buttons() {
|
||||
Array btns;
|
||||
TypedArray<BaseButton> ButtonGroup::_get_buttons() {
|
||||
TypedArray<BaseButton> btns;
|
||||
for (const BaseButton *E : buttons) {
|
||||
btns.push_back(E);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ protected:
|
||||
public:
|
||||
BaseButton *get_pressed_button();
|
||||
void get_buttons(List<BaseButton *> *r_buttons);
|
||||
Array _get_buttons();
|
||||
TypedArray<BaseButton> _get_buttons();
|
||||
ButtonGroup();
|
||||
};
|
||||
|
||||
|
||||
@@ -1280,8 +1280,8 @@ void CodeEdit::clear_breakpointed_lines() {
|
||||
}
|
||||
}
|
||||
|
||||
Array CodeEdit::get_breakpointed_lines() const {
|
||||
Array ret;
|
||||
PackedInt32Array CodeEdit::get_breakpointed_lines() const {
|
||||
PackedInt32Array ret;
|
||||
for (int i = 0; i < get_line_count(); i++) {
|
||||
if (is_line_breakpointed(i)) {
|
||||
ret.append(i);
|
||||
@@ -1309,8 +1309,8 @@ void CodeEdit::clear_bookmarked_lines() {
|
||||
}
|
||||
}
|
||||
|
||||
Array CodeEdit::get_bookmarked_lines() const {
|
||||
Array ret;
|
||||
PackedInt32Array CodeEdit::get_bookmarked_lines() const {
|
||||
PackedInt32Array ret;
|
||||
for (int i = 0; i < get_line_count(); i++) {
|
||||
if (is_line_bookmarked(i)) {
|
||||
ret.append(i);
|
||||
@@ -1338,8 +1338,8 @@ void CodeEdit::clear_executing_lines() {
|
||||
}
|
||||
}
|
||||
|
||||
Array CodeEdit::get_executing_lines() const {
|
||||
Array ret;
|
||||
PackedInt32Array CodeEdit::get_executing_lines() const {
|
||||
PackedInt32Array ret;
|
||||
for (int i = 0; i < get_line_count(); i++) {
|
||||
if (is_line_executing(i)) {
|
||||
ret.append(i);
|
||||
@@ -2769,7 +2769,7 @@ void CodeEdit::_filter_code_completion_candidates_impl() {
|
||||
i++;
|
||||
}
|
||||
|
||||
Array completion_options;
|
||||
TypedArray<Dictionary> completion_options;
|
||||
|
||||
GDVIRTUAL_CALL(_filter_code_completion_candidates, completion_options_sources, completion_options);
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ protected:
|
||||
|
||||
GDVIRTUAL1(_confirm_code_completion, bool)
|
||||
GDVIRTUAL1(_request_code_completion, bool)
|
||||
GDVIRTUAL1RC(Array, _filter_code_completion_candidates, TypedArray<Dictionary>)
|
||||
GDVIRTUAL1RC(TypedArray<Dictionary>, _filter_code_completion_candidates, TypedArray<Dictionary>)
|
||||
|
||||
public:
|
||||
/* General overrides */
|
||||
@@ -322,19 +322,19 @@ public:
|
||||
void set_line_as_breakpoint(int p_line, bool p_breakpointed);
|
||||
bool is_line_breakpointed(int p_line) const;
|
||||
void clear_breakpointed_lines();
|
||||
Array get_breakpointed_lines() const;
|
||||
PackedInt32Array get_breakpointed_lines() const;
|
||||
|
||||
// bookmarks
|
||||
void set_line_as_bookmarked(int p_line, bool p_bookmarked);
|
||||
bool is_line_bookmarked(int p_line) const;
|
||||
void clear_bookmarked_lines();
|
||||
Array get_bookmarked_lines() const;
|
||||
PackedInt32Array get_bookmarked_lines() const;
|
||||
|
||||
// executing lines
|
||||
void set_line_as_executing(int p_line, bool p_executing);
|
||||
bool is_line_executing(int p_line) const;
|
||||
void clear_executing_lines();
|
||||
Array get_executing_lines() const;
|
||||
PackedInt32Array get_executing_lines() const;
|
||||
|
||||
/* Line numbers */
|
||||
void set_draw_line_numbers(bool p_draw);
|
||||
|
||||
@@ -2946,13 +2946,13 @@ void Control::end_bulk_theme_override() {
|
||||
|
||||
// Internationalization.
|
||||
|
||||
Array Control::structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const {
|
||||
TypedArray<Vector2i> Control::structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const {
|
||||
if (p_parser_type == TextServer::STRUCTURED_TEXT_CUSTOM) {
|
||||
Array ret;
|
||||
TypedArray<Vector2i> ret;
|
||||
if (GDVIRTUAL_CALL(_structured_text_parser, p_args, p_text, ret)) {
|
||||
return ret;
|
||||
} else {
|
||||
return Array();
|
||||
return TypedArray<Vector2i>();
|
||||
}
|
||||
} else {
|
||||
return TS->parse_structured_text(p_parser_type, p_args, p_text);
|
||||
|
||||
@@ -328,7 +328,7 @@ protected:
|
||||
|
||||
// Internationalization.
|
||||
|
||||
virtual Array structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const;
|
||||
virtual TypedArray<Vector2i> structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const;
|
||||
|
||||
// Base object overrides.
|
||||
|
||||
@@ -341,7 +341,7 @@ protected:
|
||||
// Exposed virtual methods.
|
||||
|
||||
GDVIRTUAL1RC(bool, _has_point, Vector2)
|
||||
GDVIRTUAL2RC(Array, _structured_text_parser, Array, String)
|
||||
GDVIRTUAL2RC(TypedArray<Vector2i>, _structured_text_parser, Array, String)
|
||||
GDVIRTUAL0RC(Vector2, _get_minimum_size)
|
||||
|
||||
GDVIRTUAL1RC(Variant, _get_drag_data, Vector2)
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "bit_map.h"
|
||||
|
||||
#include "core/io/image_loader.h"
|
||||
#include "core/variant/typed_array.h"
|
||||
|
||||
void BitMap::create(const Size2 &p_size) {
|
||||
ERR_FAIL_COND(p_size.width < 1);
|
||||
@@ -576,12 +577,12 @@ void BitMap::shrink_mask(int p_pixels, const Rect2 &p_rect) {
|
||||
grow_mask(-p_pixels, p_rect);
|
||||
}
|
||||
|
||||
Array BitMap::_opaque_to_polygons_bind(const Rect2 &p_rect, float p_epsilon) const {
|
||||
TypedArray<PackedVector2Array> BitMap::_opaque_to_polygons_bind(const Rect2 &p_rect, float p_epsilon) const {
|
||||
Vector<Vector<Vector2>> result = clip_opaque_to_polygons(p_rect, p_epsilon);
|
||||
|
||||
// Convert result to bindable types
|
||||
|
||||
Array result_array;
|
||||
TypedArray<PackedVector2Array> result_array;
|
||||
result_array.resize(result.size());
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
const Vector<Vector2> &polygon = result[i];
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
#include "core/io/resource.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
|
||||
template <typename T>
|
||||
class TypedArray;
|
||||
|
||||
class BitMap : public Resource {
|
||||
GDCLASS(BitMap, Resource);
|
||||
OBJ_SAVE_TYPE(BitMap);
|
||||
@@ -45,7 +48,7 @@ class BitMap : public Resource {
|
||||
|
||||
Vector<Vector2> _march_square(const Rect2i &rect, const Point2i &start) const;
|
||||
|
||||
Array _opaque_to_polygons_bind(const Rect2 &p_rect, float p_epsilon) const;
|
||||
TypedArray<PackedVector2Array> _opaque_to_polygons_bind(const Rect2 &p_rect, float p_epsilon) const;
|
||||
|
||||
protected:
|
||||
void _set_data(const Dictionary &p_d);
|
||||
|
||||
@@ -1267,7 +1267,7 @@ void FontFile::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
}
|
||||
for (int i = 0; i < cache.size(); i++) {
|
||||
String prefix = "cache/" + itos(i) + "/";
|
||||
Array sizes = get_size_cache_list(i);
|
||||
TypedArray<Vector2i> sizes = get_size_cache_list(i);
|
||||
p_list->push_back(PropertyInfo(Variant::DICTIONARY, prefix + "variation_coordinates", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "face_index", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
|
||||
p_list->push_back(PropertyInfo(Variant::FLOAT, "embolden", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
|
||||
@@ -1289,7 +1289,7 @@ void FontFile::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, prefix_sz + "textures/" + itos(k) + "/offsets", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, prefix_sz + "textures/" + itos(k) + "/image", PROPERTY_HINT_RESOURCE_TYPE, "Image", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT));
|
||||
}
|
||||
Array glyphs = get_glyph_list(i, sz);
|
||||
PackedInt32Array glyphs = get_glyph_list(i, sz);
|
||||
for (int k = 0; k < glyphs.size(); k++) {
|
||||
const int32_t &gl = glyphs[k];
|
||||
if (sz.y == 0) {
|
||||
@@ -1301,7 +1301,7 @@ void FontFile::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::INT, prefix_sz + "glyphs/" + itos(gl) + "/texture_idx", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
|
||||
}
|
||||
if (sz.y == 0) {
|
||||
Array kerning_map = get_kerning_list(i, sz.x);
|
||||
TypedArray<Vector2i> kerning_map = get_kerning_list(i, sz.x);
|
||||
for (int k = 0; k < kerning_map.size(); k++) {
|
||||
const Vector2i &gl_pair = kerning_map[k];
|
||||
p_list->push_back(PropertyInfo(Variant::VECTOR2, prefix_sz + "kerning_overrides/" + itos(gl_pair.x) + "/" + itos(gl_pair.y), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
|
||||
@@ -2089,7 +2089,7 @@ void FontFile::remove_cache(int p_cache_index) {
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
Array FontFile::get_size_cache_list(int p_cache_index) const {
|
||||
TypedArray<Vector2i> FontFile::get_size_cache_list(int p_cache_index) const {
|
||||
ERR_FAIL_COND_V(p_cache_index < 0, Array());
|
||||
_ensure_rid(p_cache_index);
|
||||
return TS->font_get_size_cache_list(cache[p_cache_index]);
|
||||
@@ -2260,8 +2260,8 @@ PackedInt32Array FontFile::get_texture_offsets(int p_cache_index, const Vector2i
|
||||
return TS->font_get_texture_offsets(cache[p_cache_index], p_size, p_texture_index);
|
||||
}
|
||||
|
||||
Array FontFile::get_glyph_list(int p_cache_index, const Vector2i &p_size) const {
|
||||
ERR_FAIL_COND_V(p_cache_index < 0, Array());
|
||||
PackedInt32Array FontFile::get_glyph_list(int p_cache_index, const Vector2i &p_size) const {
|
||||
ERR_FAIL_COND_V(p_cache_index < 0, PackedInt32Array());
|
||||
_ensure_rid(p_cache_index);
|
||||
return TS->font_get_glyph_list(cache[p_cache_index], p_size);
|
||||
}
|
||||
@@ -2338,7 +2338,7 @@ int FontFile::get_glyph_texture_idx(int p_cache_index, const Vector2i &p_size, i
|
||||
return TS->font_get_glyph_texture_idx(cache[p_cache_index], p_size, p_glyph);
|
||||
}
|
||||
|
||||
Array FontFile::get_kerning_list(int p_cache_index, int p_size) const {
|
||||
TypedArray<Vector2i> FontFile::get_kerning_list(int p_cache_index, int p_size) const {
|
||||
ERR_FAIL_COND_V(p_cache_index < 0, Array());
|
||||
_ensure_rid(p_cache_index);
|
||||
return TS->font_get_kerning_list(cache[p_cache_index], p_size);
|
||||
|
||||
@@ -230,7 +230,7 @@ public:
|
||||
virtual void clear_cache();
|
||||
virtual void remove_cache(int p_cache_index);
|
||||
|
||||
virtual Array get_size_cache_list(int p_cache_index) const;
|
||||
virtual TypedArray<Vector2i> get_size_cache_list(int p_cache_index) const;
|
||||
virtual void clear_size_cache(int p_cache_index);
|
||||
virtual void remove_size_cache(int p_cache_index, const Vector2i &p_size);
|
||||
|
||||
@@ -271,7 +271,7 @@ public:
|
||||
virtual void set_texture_offsets(int p_cache_index, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset);
|
||||
virtual PackedInt32Array get_texture_offsets(int p_cache_index, const Vector2i &p_size, int p_texture_index) const;
|
||||
|
||||
virtual Array get_glyph_list(int p_cache_index, const Vector2i &p_size) const;
|
||||
virtual PackedInt32Array get_glyph_list(int p_cache_index, const Vector2i &p_size) const;
|
||||
virtual void clear_glyphs(int p_cache_index, const Vector2i &p_size);
|
||||
virtual void remove_glyph(int p_cache_index, const Vector2i &p_size, int32_t p_glyph);
|
||||
|
||||
@@ -290,7 +290,7 @@ public:
|
||||
virtual void set_glyph_texture_idx(int p_cache_index, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx);
|
||||
virtual int get_glyph_texture_idx(int p_cache_index, const Vector2i &p_size, int32_t p_glyph) const;
|
||||
|
||||
virtual Array get_kerning_list(int p_cache_index, int p_size) const;
|
||||
virtual TypedArray<Vector2i> get_kerning_list(int p_cache_index, int p_size) const;
|
||||
virtual void clear_kerning_map(int p_cache_index, int p_size);
|
||||
virtual void remove_kerning(int p_cache_index, int p_size, const Vector2i &p_glyph_pair);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user