summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-02-18 11:27:04 +0100
committerGitHub <noreply@github.com>2020-02-18 11:27:04 +0100
commitef5891091bceef2800b4fae4cd85af219e791467 (patch)
tree8d58cca8cae2c34d408450cfb5ceb198543147b7 /core
parentc7faf2e16b684f3dd0246dbdb662b1826dd24571 (diff)
parent3205a92ad872f918c8322cdcd1434c231a1fd251 (diff)
Merge pull request #36311 from reduz/poolvector-deprecation
Convert all references and instances of PoolVector to Vector
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp107
-rw-r--r--core/bind/core_bind.h39
-rw-r--r--core/compressed_translation.cpp18
-rw-r--r--core/compressed_translation.h6
-rw-r--r--core/crypto/crypto.cpp4
-rw-r--r--core/crypto/crypto.h2
-rw-r--r--core/crypto/crypto_core.cpp4
-rw-r--r--core/crypto/hashing_context.cpp18
-rw-r--r--core/crypto/hashing_context.h4
-rw-r--r--core/global_constants.cpp14
-rw-r--r--core/image.cpp333
-rw-r--r--core/image.h43
-rw-r--r--core/io/config_file.cpp8
-rw-r--r--core/io/config_file.h4
-rw-r--r--core/io/file_access_buffered.cpp4
-rw-r--r--core/io/file_access_buffered.h2
-rw-r--r--core/io/file_access_buffered_fa.h4
-rw-r--r--core/io/http_client.cpp26
-rw-r--r--core/io/http_client.h6
-rw-r--r--core/io/json.cpp6
-rw-r--r--core/io/marshalls.cpp74
-rw-r--r--core/io/multiplayer_api.cpp10
-rw-r--r--core/io/multiplayer_api.h2
-rw-r--r--core/io/packet_peer.cpp20
-rw-r--r--core/io/packet_peer.h10
-rw-r--r--core/io/resource_format_binary.cpp97
-rw-r--r--core/io/resource_loader.cpp16
-rw-r--r--core/io/resource_saver.cpp6
-rw-r--r--core/io/stream_peer.cpp35
-rw-r--r--core/io/stream_peer.h10
-rw-r--r--core/math/a_star.cpp48
-rw-r--r--core/math/a_star.h12
-rw-r--r--core/math/bsp_tree.cpp581
-rw-r--r--core/math/bsp_tree.h159
-rw-r--r--core/math/expression.cpp18
-rw-r--r--core/math/geometry.cpp49
-rw-r--r--core/math/geometry.h16
-rw-r--r--core/math/transform.h21
-rw-r--r--core/math/transform_2d.h21
-rw-r--r--core/math/triangle_mesh.cpp80
-rw-r--r--core/math/triangle_mesh.h16
-rw-r--r--core/method_ptrcall.h308
-rw-r--r--core/object.cpp4
-rw-r--r--core/object.h2
-rw-r--r--core/os/file_access.cpp8
-rw-r--r--core/os/main_loop.cpp2
-rw-r--r--core/os/memory.h2
-rw-r--r--core/os/midi_driver.cpp4
-rw-r--r--core/os/midi_driver.h2
-rw-r--r--core/os/os.cpp8
-rw-r--r--core/os/os.h3
-rw-r--r--core/packed_data_container.cpp48
-rw-r--r--core/packed_data_container.h6
-rw-r--r--core/pool_vector.cpp70
-rw-r--r--core/pool_vector.h648
-rw-r--r--core/project_settings.cpp4
-rw-r--r--core/register_core_types.cpp3
-rw-r--r--core/script_language.h2
-rw-r--r--core/translation.cpp18
-rw-r--r--core/translation.h6
-rw-r--r--core/type_info.h43
-rw-r--r--core/variant.cpp696
-rw-r--r--core/variant.h72
-rw-r--r--core/variant_call.cpp450
-rw-r--r--core/variant_op.cpp524
-rw-r--r--core/variant_parser.cpp107
-rw-r--r--core/vector.h29
67 files changed, 1608 insertions, 3414 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index d7614c5a82..583a44846f 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -77,11 +77,11 @@ RES _ResourceLoader::load(const String &p_path, const String &p_type_hint, bool
return ret;
}
-PoolVector<String> _ResourceLoader::get_recognized_extensions_for_type(const String &p_type) {
+Vector<String> _ResourceLoader::get_recognized_extensions_for_type(const String &p_type) {
List<String> exts;
ResourceLoader::get_recognized_extensions_for_type(p_type, &exts);
- PoolVector<String> ret;
+ Vector<String> ret;
for (List<String>::Element *E = exts.front(); E; E = E->next()) {
ret.push_back(E->get());
@@ -95,12 +95,12 @@ void _ResourceLoader::set_abort_on_missing_resources(bool p_abort) {
ResourceLoader::set_abort_on_missing_resources(p_abort);
}
-PoolStringArray _ResourceLoader::get_dependencies(const String &p_path) {
+PackedStringArray _ResourceLoader::get_dependencies(const String &p_path) {
List<String> deps;
ResourceLoader::get_dependencies(p_path, &deps);
- PoolStringArray ret;
+ PackedStringArray ret;
for (List<String>::Element *E = deps.front(); E; E = E->next()) {
ret.push_back(E->get());
}
@@ -139,12 +139,12 @@ Error _ResourceSaver::save(const String &p_path, const RES &p_resource, SaverFla
return ResourceSaver::save(p_path, p_resource, p_flags);
}
-PoolVector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource) {
+Vector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource) {
- ERR_FAIL_COND_V_MSG(p_resource.is_null(), PoolVector<String>(), "It's not a reference to a valid Resource object.");
+ ERR_FAIL_COND_V_MSG(p_resource.is_null(), Vector<String>(), "It's not a reference to a valid Resource object.");
List<String> exts;
ResourceSaver::get_recognized_extensions(p_resource, &exts);
- PoolVector<String> ret;
+ Vector<String> ret;
for (List<String>::Element *E = exts.front(); E; E = E->next()) {
ret.push_back(E->get());
@@ -249,7 +249,7 @@ String _OS::get_audio_driver_name(int p_driver) const {
return OS::get_singleton()->get_audio_driver_name(p_driver);
}
-PoolStringArray _OS::get_connected_midi_inputs() {
+PackedStringArray _OS::get_connected_midi_inputs() {
return OS::get_singleton()->get_connected_midi_inputs();
}
@@ -646,11 +646,6 @@ uint64_t _OS::get_static_memory_peak_usage() const {
return OS::get_singleton()->get_static_memory_peak_usage();
}
-uint64_t _OS::get_dynamic_memory_usage() const {
-
- return OS::get_singleton()->get_dynamic_memory_usage();
-}
-
void _OS::set_native_icon(const String &p_filename) {
OS::get_singleton()->set_native_icon(p_filename);
@@ -1301,7 +1296,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_static_memory_usage"), &_OS::get_static_memory_usage);
ClassDB::bind_method(D_METHOD("get_static_memory_peak_usage"), &_OS::get_static_memory_peak_usage);
- ClassDB::bind_method(D_METHOD("get_dynamic_memory_usage"), &_OS::get_dynamic_memory_usage);
ClassDB::bind_method(D_METHOD("get_user_data_dir"), &_OS::get_user_data_dir);
ClassDB::bind_method(D_METHOD("get_system_dir", "dir"), &_OS::get_system_dir);
@@ -1439,16 +1433,16 @@ _Geometry *_Geometry::get_singleton() {
return singleton;
}
-PoolVector<Plane> _Geometry::build_box_planes(const Vector3 &p_extents) {
+Vector<Plane> _Geometry::build_box_planes(const Vector3 &p_extents) {
return Geometry::build_box_planes(p_extents);
}
-PoolVector<Plane> _Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
+Vector<Plane> _Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
return Geometry::build_cylinder_planes(p_radius, p_height, p_sides, p_axis);
}
-PoolVector<Plane> _Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
+Vector<Plane> _Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
return Geometry::build_capsule_planes(p_radius, p_height, p_sides, p_lats, p_axis);
}
@@ -1484,22 +1478,22 @@ Variant _Geometry::line_intersects_line_2d(const Vector2 &p_from_a, const Vector
}
}
-PoolVector<Vector2> _Geometry::get_closest_points_between_segments_2d(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2) {
+Vector<Vector2> _Geometry::get_closest_points_between_segments_2d(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2) {
Vector2 r1, r2;
Geometry::get_closest_points_between_segments(p1, q1, p2, q2, r1, r2);
- PoolVector<Vector2> r;
+ Vector<Vector2> r;
r.resize(2);
r.set(0, r1);
r.set(1, r2);
return r;
}
-PoolVector<Vector3> _Geometry::get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2) {
+Vector<Vector3> _Geometry::get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2) {
Vector3 r1, r2;
Geometry::get_closest_points_between_segments(p1, p2, q1, q2, r1, r2);
- PoolVector<Vector3> r;
+ Vector<Vector3> r;
r.resize(2);
r.set(0, r1);
r.set(1, r2);
@@ -1547,9 +1541,9 @@ bool _Geometry::point_is_inside_triangle(const Vector2 &s, const Vector2 &a, con
return Geometry::is_point_in_triangle(s, a, b, c);
}
-PoolVector<Vector3> _Geometry::segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius) {
+Vector<Vector3> _Geometry::segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius) {
- PoolVector<Vector3> r;
+ Vector<Vector3> r;
Vector3 res, norm;
if (!Geometry::segment_intersects_sphere(p_from, p_to, p_sphere_pos, p_sphere_radius, &res, &norm))
return r;
@@ -1559,9 +1553,9 @@ PoolVector<Vector3> _Geometry::segment_intersects_sphere(const Vector3 &p_from,
r.set(1, norm);
return r;
}
-PoolVector<Vector3> _Geometry::segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius) {
+Vector<Vector3> _Geometry::segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius) {
- PoolVector<Vector3> r;
+ Vector<Vector3> r;
Vector3 res, norm;
if (!Geometry::segment_intersects_cylinder(p_from, p_to, p_height, p_radius, &res, &norm))
return r;
@@ -1571,9 +1565,9 @@ PoolVector<Vector3> _Geometry::segment_intersects_cylinder(const Vector3 &p_from
r.set(1, norm);
return r;
}
-PoolVector<Vector3> _Geometry::segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes) {
+Vector<Vector3> _Geometry::segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes) {
- PoolVector<Vector3> r;
+ Vector<Vector3> r;
Vector3 res, norm;
if (!Geometry::segment_intersects_convex(p_from, p_to, p_planes.ptr(), p_planes.size(), &res, &norm))
return r;
@@ -1962,9 +1956,9 @@ real_t _File::get_real() const {
return f->get_real();
}
-PoolVector<uint8_t> _File::get_buffer(int p_length) const {
+Vector<uint8_t> _File::get_buffer(int p_length) const {
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
ERR_FAIL_COND_V_MSG(!f, data, "File must be opened before use.");
ERR_FAIL_COND_V_MSG(p_length < 0, data, "Length of buffer cannot be smaller than 0.");
@@ -1974,11 +1968,9 @@ PoolVector<uint8_t> _File::get_buffer(int p_length) const {
Error err = data.resize(p_length);
ERR_FAIL_COND_V_MSG(err != OK, data, "Can't resize data to " + itos(p_length) + " elements.");
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
int len = f->get_buffer(&w[0], p_length);
- ERR_FAIL_COND_V(len < 0, PoolVector<uint8_t>());
-
- w.release();
+ ERR_FAIL_COND_V(len < 0, Vector<uint8_t>());
if (len < p_length)
data.resize(p_length);
@@ -2126,7 +2118,7 @@ void _File::store_csv_line(const Vector<String> &p_values, const String &p_delim
f->store_csv_line(p_values, p_delim);
}
-void _File::store_buffer(const PoolVector<uint8_t> &p_buffer) {
+void _File::store_buffer(const Vector<uint8_t> &p_buffer) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
@@ -2134,7 +2126,7 @@ void _File::store_buffer(const PoolVector<uint8_t> &p_buffer) {
if (len == 0)
return;
- PoolVector<uint8_t>::Read r = p_buffer.read();
+ const uint8_t *r = p_buffer.ptr();
f->store_buffer(&r[0], len);
}
@@ -2151,13 +2143,12 @@ void _File::store_var(const Variant &p_var, bool p_full_objects) {
Error err = encode_variant(p_var, NULL, len, p_full_objects);
ERR_FAIL_COND_MSG(err != OK, "Error when trying to encode Variant.");
- PoolVector<uint8_t> buff;
+ Vector<uint8_t> buff;
buff.resize(len);
- PoolVector<uint8_t>::Write w = buff.write();
+ uint8_t *w = buff.ptrw();
err = encode_variant(p_var, &w[0], len, p_full_objects);
ERR_FAIL_COND_MSG(err != OK, "Error when trying to encode Variant.");
- w.release();
store_32(len);
store_buffer(buff);
@@ -2167,10 +2158,10 @@ Variant _File::get_var(bool p_allow_objects) const {
ERR_FAIL_COND_V_MSG(!f, Variant(), "File must be opened before use.");
uint32_t len = get_32();
- PoolVector<uint8_t> buff = get_buffer(len);
+ Vector<uint8_t> buff = get_buffer(len);
ERR_FAIL_COND_V((uint32_t)buff.size() != len, Variant());
- PoolVector<uint8_t>::Read r = buff.read();
+ const uint8_t *r = buff.ptr();
Variant v;
Error err = decode_variant(v, &r[0], len, NULL, p_allow_objects);
@@ -2465,9 +2456,9 @@ String _Marshalls::variant_to_base64(const Variant &p_var, bool p_full_objects)
Error err = encode_variant(p_var, NULL, len, p_full_objects);
ERR_FAIL_COND_V_MSG(err != OK, "", "Error when trying to encode Variant.");
- PoolVector<uint8_t> buff;
+ Vector<uint8_t> buff;
buff.resize(len);
- PoolVector<uint8_t>::Write w = buff.write();
+ uint8_t *w = buff.ptrw();
err = encode_variant(p_var, &w[0], len, p_full_objects);
ERR_FAIL_COND_V_MSG(err != OK, "", "Error when trying to encode Variant.");
@@ -2483,9 +2474,9 @@ Variant _Marshalls::base64_to_variant(const String &p_str, bool p_allow_objects)
int strlen = p_str.length();
CharString cstr = p_str.ascii();
- PoolVector<uint8_t> buf;
+ Vector<uint8_t> buf;
buf.resize(strlen / 4 * 3 + 1);
- PoolVector<uint8_t>::Write w = buf.write();
+ uint8_t *w = buf.ptrw();
size_t len = 0;
ERR_FAIL_COND_V(CryptoCore::b64_decode(&w[0], buf.size(), &len, (unsigned char *)cstr.get_data(), strlen) != OK, Variant());
@@ -2497,25 +2488,25 @@ Variant _Marshalls::base64_to_variant(const String &p_str, bool p_allow_objects)
return v;
};
-String _Marshalls::raw_to_base64(const PoolVector<uint8_t> &p_arr) {
+String _Marshalls::raw_to_base64(const Vector<uint8_t> &p_arr) {
- String ret = CryptoCore::b64_encode_str(p_arr.read().ptr(), p_arr.size());
+ String ret = CryptoCore::b64_encode_str(p_arr.ptr(), p_arr.size());
ERR_FAIL_COND_V(ret == "", ret);
return ret;
};
-PoolVector<uint8_t> _Marshalls::base64_to_raw(const String &p_str) {
+Vector<uint8_t> _Marshalls::base64_to_raw(const String &p_str) {
int strlen = p_str.length();
CharString cstr = p_str.ascii();
size_t arr_len = 0;
- PoolVector<uint8_t> buf;
+ Vector<uint8_t> buf;
{
buf.resize(strlen / 4 * 3 + 1);
- PoolVector<uint8_t>::Write w = buf.write();
+ uint8_t *w = buf.ptrw();
- ERR_FAIL_COND_V(CryptoCore::b64_decode(&w[0], buf.size(), &arr_len, (unsigned char *)cstr.get_data(), strlen) != OK, PoolVector<uint8_t>());
+ ERR_FAIL_COND_V(CryptoCore::b64_decode(&w[0], buf.size(), &arr_len, (unsigned char *)cstr.get_data(), strlen) != OK, Vector<uint8_t>());
}
buf.resize(arr_len);
@@ -2535,9 +2526,9 @@ String _Marshalls::base64_to_utf8(const String &p_str) {
int strlen = p_str.length();
CharString cstr = p_str.ascii();
- PoolVector<uint8_t> buf;
+ Vector<uint8_t> buf;
buf.resize(strlen / 4 * 3 + 1 + 1);
- PoolVector<uint8_t>::Write w = buf.write();
+ uint8_t *w = buf.ptrw();
size_t len = 0;
ERR_FAIL_COND_V(CryptoCore::b64_decode(&w[0], buf.size(), &len, (unsigned char *)cstr.get_data(), strlen) != OK, String());
@@ -2746,12 +2737,12 @@ _Thread::~_Thread() {
/////////////////////////////////////
-PoolStringArray _ClassDB::get_class_list() const {
+PackedStringArray _ClassDB::get_class_list() const {
List<StringName> classes;
ClassDB::get_class_list(&classes);
- PoolStringArray ret;
+ PackedStringArray ret;
ret.resize(classes.size());
int idx = 0;
for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
@@ -2760,12 +2751,12 @@ PoolStringArray _ClassDB::get_class_list() const {
return ret;
}
-PoolStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class) const {
+PackedStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class) const {
List<StringName> classes;
ClassDB::get_inheriters_from_class(p_class, &classes);
- PoolStringArray ret;
+ PackedStringArray ret;
ret.resize(classes.size());
int idx = 0;
for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
@@ -2883,12 +2874,12 @@ Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const
return ret;
}
-PoolStringArray _ClassDB::get_integer_constant_list(const StringName &p_class, bool p_no_inheritance) const {
+PackedStringArray _ClassDB::get_integer_constant_list(const StringName &p_class, bool p_no_inheritance) const {
List<String> constants;
ClassDB::get_integer_constant_list(p_class, &constants, p_no_inheritance);
- PoolStringArray ret;
+ PackedStringArray ret;
ret.resize(constants.size());
int idx = 0;
for (List<String>::Element *E = constants.front(); E; E = E->next()) {
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 39bed791d0..342c43802e 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -52,9 +52,9 @@ public:
static _ResourceLoader *get_singleton() { return singleton; }
Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, const String &p_type_hint = "");
RES load(const String &p_path, const String &p_type_hint = "", bool p_no_cache = false);
- PoolVector<String> get_recognized_extensions_for_type(const String &p_type);
+ Vector<String> get_recognized_extensions_for_type(const String &p_type);
void set_abort_on_missing_resources(bool p_abort);
- PoolStringArray get_dependencies(const String &p_path);
+ PackedStringArray get_dependencies(const String &p_path);
bool has_cached(const String &p_path);
bool exists(const String &p_path, const String &p_type_hint = "");
@@ -83,7 +83,7 @@ public:
static _ResourceSaver *get_singleton() { return singleton; }
Error save(const String &p_path, const RES &p_resource, SaverFlags p_flags);
- PoolVector<String> get_recognized_extensions(const RES &p_resource);
+ Vector<String> get_recognized_extensions(const RES &p_resource);
_ResourceSaver();
};
@@ -157,7 +157,7 @@ public:
virtual int get_audio_driver_count() const;
virtual String get_audio_driver_name(int p_driver) const;
- virtual PoolStringArray get_connected_midi_inputs();
+ virtual PackedStringArray get_connected_midi_inputs();
virtual void open_midi_inputs();
virtual void close_midi_inputs();
@@ -276,7 +276,6 @@ public:
uint64_t get_static_memory_usage() const;
uint64_t get_static_memory_peak_usage() const;
- uint64_t get_dynamic_memory_usage() const;
void delay_usec(uint32_t p_usec) const;
void delay_msec(uint32_t p_msec) const;
@@ -366,13 +365,13 @@ protected:
public:
static _Geometry *get_singleton();
- PoolVector<Plane> build_box_planes(const Vector3 &p_extents);
- PoolVector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
- PoolVector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
+ Vector<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);
+ Vector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
Variant segment_intersects_segment_2d(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b);
Variant line_intersects_line_2d(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b);
- PoolVector<Vector2> get_closest_points_between_segments_2d(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
- PoolVector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
+ Vector<Vector2> get_closest_points_between_segments_2d(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
+ Vector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
Vector2 get_closest_point_to_segment_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
Vector2 get_closest_point_to_segment_uncapped_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
@@ -381,9 +380,9 @@ public:
Variant segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
bool point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const;
- PoolVector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
- PoolVector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
- PoolVector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes);
+ Vector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
+ Vector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
+ Vector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes);
bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
int get_uv84_normal_bit(const Vector3 &p_vector);
@@ -490,7 +489,7 @@ public:
Variant get_var(bool p_allow_objects = false) const;
- PoolVector<uint8_t> get_buffer(int p_length) const; // Get an array of bytes.
+ Vector<uint8_t> get_buffer(int p_length) const; // Get an array of bytes.
String get_line() const;
Vector<String> get_csv_line(const String &p_delim = ",") const;
String get_as_text() const;
@@ -523,7 +522,7 @@ public:
virtual void store_pascal_string(const String &p_string);
virtual String get_pascal_string();
- void store_buffer(const PoolVector<uint8_t> &p_buffer); // Store an array of bytes.
+ void store_buffer(const Vector<uint8_t> &p_buffer); // Store an array of bytes.
void store_var(const Variant &p_var, bool p_full_objects = false);
@@ -597,8 +596,8 @@ public:
String variant_to_base64(const Variant &p_var, bool p_full_objects = false);
Variant base64_to_variant(const String &p_str, bool p_allow_objects = false);
- String raw_to_base64(const PoolVector<uint8_t> &p_arr);
- PoolVector<uint8_t> base64_to_raw(const String &p_str);
+ String raw_to_base64(const Vector<uint8_t> &p_arr);
+ Vector<uint8_t> base64_to_raw(const String &p_str);
String utf8_to_base64(const String &p_str);
String base64_to_utf8(const String &p_str);
@@ -680,8 +679,8 @@ protected:
static void _bind_methods();
public:
- PoolStringArray get_class_list() const;
- PoolStringArray get_inheriters_from_class(const StringName &p_class) const;
+ PackedStringArray get_class_list() const;
+ PackedStringArray get_inheriters_from_class(const StringName &p_class) const;
StringName get_parent_class(const StringName &p_class) const;
bool class_exists(const StringName &p_class) const;
bool is_parent_class(const StringName &p_class, const StringName &p_inherits) const;
@@ -700,7 +699,7 @@ public:
Array get_method_list(StringName p_class, bool p_no_inheritance = false) const;
- PoolStringArray get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
+ PackedStringArray get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
bool has_integer_constant(const StringName &p_class, const StringName &p_name) const;
int get_integer_constant(const StringName &p_class, const StringName &p_name) const;
StringName get_category(const StringName &p_node) const;
diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp
index 69b4ec292f..ea84ded3b4 100644
--- a/core/compressed_translation.cpp
+++ b/core/compressed_translation.cpp
@@ -141,8 +141,8 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
hash_table.resize(size);
bucket_table.resize(bucket_table_size);
- PoolVector<int>::Write htwb = hash_table.write();
- PoolVector<int>::Write btwb = bucket_table.write();
+ int *htwb = hash_table.ptrw();
+ int *btwb = bucket_table.ptrw();
uint32_t *htw = (uint32_t *)&htwb[0];
uint32_t *btw = (uint32_t *)&btwb[0];
@@ -174,7 +174,7 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
}
strings.resize(total_compression_size);
- PoolVector<uint8_t>::Write cw = strings.write();
+ uint8_t *cw = strings.ptrw();
for (int i = 0; i < compressed.size(); i++) {
memcpy(&cw[compressed[i].offset], compressed[i].compressed.get_data(), compressed[i].compressed.size());
@@ -228,11 +228,11 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
CharString str = p_src_text.operator String().utf8();
uint32_t h = hash(0, str.get_data());
- PoolVector<int>::Read htr = hash_table.read();
+ const int *htr = hash_table.ptr();
const uint32_t *htptr = (const uint32_t *)&htr[0];
- PoolVector<int>::Read btr = bucket_table.read();
+ const int *btr = bucket_table.ptr();
const uint32_t *btptr = (const uint32_t *)&btr[0];
- PoolVector<uint8_t>::Read sr = strings.read();
+ const uint8_t *sr = strings.ptr();
const char *sptr = (const char *)&sr[0];
uint32_t p = htptr[h % htsize];
@@ -279,9 +279,9 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
void PHashTranslation::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back(PropertyInfo(Variant::POOL_INT_ARRAY, "hash_table"));
- p_list->push_back(PropertyInfo(Variant::POOL_INT_ARRAY, "bucket_table"));
- p_list->push_back(PropertyInfo(Variant::POOL_BYTE_ARRAY, "strings"));
+ p_list->push_back(PropertyInfo(Variant::PACKED_INT_ARRAY, "hash_table"));
+ p_list->push_back(PropertyInfo(Variant::PACKED_INT_ARRAY, "bucket_table"));
+ p_list->push_back(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "strings"));
p_list->push_back(PropertyInfo(Variant::OBJECT, "load_from", PROPERTY_HINT_RESOURCE_TYPE, "Translation", PROPERTY_USAGE_EDITOR));
}
void PHashTranslation::_bind_methods() {
diff --git a/core/compressed_translation.h b/core/compressed_translation.h
index a72be739a1..d599240dfe 100644
--- a/core/compressed_translation.h
+++ b/core/compressed_translation.h
@@ -43,9 +43,9 @@ class PHashTranslation : public Translation {
//of catching untranslated strings
//load/store friendly types
- PoolVector<int> hash_table;
- PoolVector<int> bucket_table;
- PoolVector<uint8_t> strings;
+ Vector<int> hash_table;
+ Vector<int> bucket_table;
+ Vector<uint8_t> strings;
struct Bucket {
diff --git a/core/crypto/crypto.cpp b/core/crypto/crypto.cpp
index 3bee34f8e4..3711b26e47 100644
--- a/core/crypto/crypto.cpp
+++ b/core/crypto/crypto.cpp
@@ -82,8 +82,8 @@ void Crypto::_bind_methods() {
ClassDB::bind_method(D_METHOD("generate_self_signed_certificate", "key", "issuer_name", "not_before", "not_after"), &Crypto::generate_self_signed_certificate, DEFVAL("CN=myserver,O=myorganisation,C=IT"), DEFVAL("20140101000000"), DEFVAL("20340101000000"));
}
-PoolByteArray Crypto::generate_random_bytes(int p_bytes) {
- ERR_FAIL_V_MSG(PoolByteArray(), "generate_random_bytes is not available when mbedtls module is disabled.");
+PackedByteArray Crypto::generate_random_bytes(int p_bytes) {
+ ERR_FAIL_V_MSG(PackedByteArray(), "generate_random_bytes is not available when mbedtls module is disabled.");
}
Ref<CryptoKey> Crypto::generate_rsa(int p_bytes) {
diff --git a/core/crypto/crypto.h b/core/crypto/crypto.h
index adc36255b6..babd0bc4eb 100644
--- a/core/crypto/crypto.h
+++ b/core/crypto/crypto.h
@@ -76,7 +76,7 @@ public:
static Crypto *create();
static void load_default_certificates(String p_path);
- virtual PoolByteArray generate_random_bytes(int p_bytes);
+ virtual PackedByteArray generate_random_bytes(int p_bytes);
virtual Ref<CryptoKey> generate_rsa(int p_bytes);
virtual Ref<X509Certificate> generate_self_signed_certificate(Ref<CryptoKey> p_key, String p_issuer_name, String p_not_before, String p_not_after);
diff --git a/core/crypto/crypto_core.cpp b/core/crypto/crypto_core.cpp
index dec52d8ca4..ec25ee0d38 100644
--- a/core/crypto/crypto_core.cpp
+++ b/core/crypto/crypto_core.cpp
@@ -148,9 +148,9 @@ Error CryptoCore::AESContext::decrypt_ecb(const uint8_t p_src[16], uint8_t r_dst
// CryptoCore
String CryptoCore::b64_encode_str(const uint8_t *p_src, int p_src_len) {
int b64len = p_src_len / 3 * 4 + 4 + 1;
- PoolVector<uint8_t> b64buff;
+ Vector<uint8_t> b64buff;
b64buff.resize(b64len);
- PoolVector<uint8_t>::Write w64 = b64buff.write();
+ uint8_t *w64 = b64buff.ptrw();
size_t strlen = 0;
int ret = b64_encode(&w64[0], b64len, &strlen, p_src, p_src_len);
w64[strlen] = 0;
diff --git a/core/crypto/hashing_context.cpp b/core/crypto/hashing_context.cpp
index 7bee8f1200..a4d8a93c8a 100644
--- a/core/crypto/hashing_context.cpp
+++ b/core/crypto/hashing_context.cpp
@@ -47,11 +47,11 @@ Error HashingContext::start(HashType p_type) {
return ERR_UNAVAILABLE;
}
-Error HashingContext::update(PoolByteArray p_chunk) {
+Error HashingContext::update(PackedByteArray p_chunk) {
ERR_FAIL_COND_V(ctx == NULL, ERR_UNCONFIGURED);
size_t len = p_chunk.size();
ERR_FAIL_COND_V(len == 0, FAILED);
- PoolByteArray::Read r = p_chunk.read();
+ const uint8_t *r = p_chunk.ptr();
switch (type) {
case HASH_MD5:
return ((CryptoCore::MD5Context *)ctx)->update(&r[0], len);
@@ -63,26 +63,26 @@ Error HashingContext::update(PoolByteArray p_chunk) {
return ERR_UNAVAILABLE;
}
-PoolByteArray HashingContext::finish() {
- ERR_FAIL_COND_V(ctx == NULL, PoolByteArray());
- PoolByteArray out;
+PackedByteArray HashingContext::finish() {
+ ERR_FAIL_COND_V(ctx == NULL, PackedByteArray());
+ PackedByteArray out;
Error err = FAILED;
switch (type) {
case HASH_MD5:
out.resize(16);
- err = ((CryptoCore::MD5Context *)ctx)->finish(out.write().ptr());
+ err = ((CryptoCore::MD5Context *)ctx)->finish(out.ptrw());
break;
case HASH_SHA1:
out.resize(20);
- err = ((CryptoCore::SHA1Context *)ctx)->finish(out.write().ptr());
+ err = ((CryptoCore::SHA1Context *)ctx)->finish(out.ptrw());
break;
case HASH_SHA256:
out.resize(32);
- err = ((CryptoCore::SHA256Context *)ctx)->finish(out.write().ptr());
+ err = ((CryptoCore::SHA256Context *)ctx)->finish(out.ptrw());
break;
}
_delete_ctx();
- ERR_FAIL_COND_V(err != OK, PoolByteArray());
+ ERR_FAIL_COND_V(err != OK, PackedByteArray());
return out;
}
diff --git a/core/crypto/hashing_context.h b/core/crypto/hashing_context.h
index af6ed3aa0b..230ba7ee85 100644
--- a/core/crypto/hashing_context.h
+++ b/core/crypto/hashing_context.h
@@ -54,8 +54,8 @@ protected:
public:
Error start(HashType p_type);
- Error update(PoolByteArray p_chunk);
- PoolByteArray finish();
+ Error update(PackedByteArray p_chunk);
+ PackedByteArray finish();
HashingContext();
~HashingContext();
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index e48556c064..94713b4ee6 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -611,13 +611,13 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_OBJECT", Variant::OBJECT);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_DICTIONARY", Variant::DICTIONARY); // 20
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_ARRAY", Variant::ARRAY);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RAW_ARRAY", Variant::POOL_BYTE_ARRAY);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT_ARRAY", Variant::POOL_INT_ARRAY);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_REAL_ARRAY", Variant::POOL_REAL_ARRAY);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING_ARRAY", Variant::POOL_STRING_ARRAY);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2_ARRAY", Variant::POOL_VECTOR2_ARRAY); // 25
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR3_ARRAY", Variant::POOL_VECTOR3_ARRAY);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR_ARRAY", Variant::POOL_COLOR_ARRAY);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RAW_ARRAY", Variant::PACKED_BYTE_ARRAY);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT_ARRAY", Variant::PACKED_INT_ARRAY);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_REAL_ARRAY", Variant::PACKED_REAL_ARRAY);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING_ARRAY", Variant::PACKED_STRING_ARRAY);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2_ARRAY", Variant::PACKED_VECTOR2_ARRAY); // 25
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR3_ARRAY", Variant::PACKED_VECTOR3_ARRAY);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR_ARRAY", Variant::PACKED_COLOR_ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_MAX", Variant::VARIANT_MAX);
//comparison
diff --git a/core/image.cpp b/core/image.cpp
index d9f84621a3..a188447f90 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -444,8 +444,6 @@ void Image::convert(Format p_new_format) {
if (p_new_format == format)
return;
- ERR_FAIL_COND_MSG(write_lock.ptr(), "Cannot convert image when it is locked.");
-
if (format > FORMAT_RGBE9995 || p_new_format > FORMAT_RGBE9995) {
ERR_FAIL_MSG("Cannot convert to <-> from compressed formats. Use compress() and decompress() instead.");
@@ -454,8 +452,6 @@ void Image::convert(Format p_new_format) {
//use put/set pixel which is slower but works with non byte formats
Image new_img(width, height, 0, p_new_format);
- lock();
- new_img.lock();
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
@@ -464,9 +460,6 @@ void Image::convert(Format p_new_format) {
}
}
- unlock();
- new_img.unlock();
-
if (has_mipmaps()) {
new_img.generate_mipmaps();
}
@@ -478,11 +471,8 @@ void Image::convert(Format p_new_format) {
Image new_img(width, height, 0, p_new_format);
- PoolVector<uint8_t>::Read r = data.read();
- PoolVector<uint8_t>::Write w = new_img.data.write();
-
- const uint8_t *rptr = r.ptr();
- uint8_t *wptr = w.ptr();
+ const uint8_t *rptr = data.ptr();
+ uint8_t *wptr = new_img.data.ptrw();
int conversion_type = format | p_new_format << 8;
@@ -520,9 +510,6 @@ void Image::convert(Format p_new_format) {
case FORMAT_RGBA8 | (FORMAT_RGB8 << 8): _convert<3, true, 3, false, false, false>(width, height, rptr, wptr); break;
}
- r.release();
- w.release();
-
bool gen_mipmaps = mipmaps;
_copy_internals_from(new_img);
@@ -906,7 +893,6 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
ERR_FAIL_COND_MSG(data.size() == 0, "Cannot resize image before creating it, use create() or create_from_data() first.");
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot resize in compressed or custom image formats.");
- ERR_FAIL_COND_MSG(write_lock.ptr(), "Cannot resize image when it is locked.");
bool mipmap_aware = p_interpolation == INTERPOLATE_TRILINEAR /* || p_interpolation == INTERPOLATE_TRICUBIC */;
@@ -948,11 +934,11 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
}
// --
- PoolVector<uint8_t>::Read r = data.read();
- const unsigned char *r_ptr = r.ptr();
+ const uint8_t *r = data.ptr();
+ const unsigned char *r_ptr = r;
- PoolVector<uint8_t>::Write w = dst.data.write();
- unsigned char *w_ptr = w.ptr();
+ uint8_t *w = dst.data.ptrw();
+ unsigned char *w_ptr = w;
switch (p_interpolation) {
@@ -1017,8 +1003,8 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
_get_mipmap_offset_and_size(mip2, offs, src_width, src_height);
src_ptr = r_ptr + offs;
// Switch to write to the second destination image
- w = dst2.data.write();
- w_ptr = w.ptr();
+ w = dst2.data.ptrw();
+ w_ptr = w;
}
}
@@ -1048,8 +1034,8 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
if (interpolate_mipmaps) {
// Switch to read again from the first scaled mipmap to overlay it over the second
- r = dst.data.read();
- _overlay(r.ptr(), w.ptr(), mip1_weight, p_width, p_height, get_format_pixel_size(format));
+ r = dst.data.ptr();
+ _overlay(r, w, mip1_weight, p_width, p_height, get_format_pixel_size(format));
}
} break;
@@ -1105,9 +1091,6 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
} break;
}
- r.release();
- w.release();
-
if (interpolate_mipmaps) {
dst._copy_internals_from(dst2);
}
@@ -1142,8 +1125,8 @@ void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
Image dst(p_width, p_height, 0, format);
{
- PoolVector<uint8_t>::Read r = data.read();
- PoolVector<uint8_t>::Write w = dst.data.write();
+ const uint8_t *r = data.ptr();
+ uint8_t *w = dst.data.ptrw();
int m_h = p_y + p_height;
int m_w = p_x + p_width;
@@ -1155,10 +1138,10 @@ void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
for (uint32_t i = 0; i < pixel_size; i++)
pdata[i] = 0;
} else {
- _get_pixelb(x, y, pixel_size, r.ptr(), pdata);
+ _get_pixelb(x, y, pixel_size, r, pdata);
}
- dst._put_pixelb(x - p_x, y - p_y, pixel_size, w.ptr(), pdata);
+ dst._put_pixelb(x - p_x, y - p_y, pixel_size, w, pdata);
}
}
}
@@ -1183,7 +1166,7 @@ void Image::flip_y() {
}
{
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
uint8_t up[16];
uint8_t down[16];
uint32_t pixel_size = get_format_pixel_size(format);
@@ -1192,11 +1175,11 @@ void Image::flip_y() {
for (int x = 0; x < width; x++) {
- _get_pixelb(x, y, pixel_size, w.ptr(), up);
- _get_pixelb(x, height - y - 1, pixel_size, w.ptr(), down);
+ _get_pixelb(x, y, pixel_size, w, up);
+ _get_pixelb(x, height - y - 1, pixel_size, w, down);
- _put_pixelb(x, height - y - 1, pixel_size, w.ptr(), up);
- _put_pixelb(x, y, pixel_size, w.ptr(), down);
+ _put_pixelb(x, height - y - 1, pixel_size, w, up);
+ _put_pixelb(x, y, pixel_size, w, down);
}
}
}
@@ -1216,7 +1199,7 @@ void Image::flip_x() {
}
{
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
uint8_t up[16];
uint8_t down[16];
uint32_t pixel_size = get_format_pixel_size(format);
@@ -1225,11 +1208,11 @@ void Image::flip_x() {
for (int x = 0; x < width / 2; x++) {
- _get_pixelb(x, y, pixel_size, w.ptr(), up);
- _get_pixelb(width - x - 1, y, pixel_size, w.ptr(), down);
+ _get_pixelb(x, y, pixel_size, w, up);
+ _get_pixelb(width - x - 1, y, pixel_size, w, down);
- _put_pixelb(width - x - 1, y, pixel_size, w.ptr(), up);
- _put_pixelb(x, y, pixel_size, w.ptr(), down);
+ _put_pixelb(width - x - 1, y, pixel_size, w, up);
+ _put_pixelb(x, y, pixel_size, w, down);
}
}
}
@@ -1348,16 +1331,16 @@ void Image::expand_x2_hq2x() {
if (current != FORMAT_RGBA8)
convert(FORMAT_RGBA8);
- PoolVector<uint8_t> dest;
+ Vector<uint8_t> dest;
dest.resize(width * 2 * height * 2 * 4);
{
- PoolVector<uint8_t>::Read r = data.read();
- PoolVector<uint8_t>::Write w = dest.write();
+ const uint8_t *r = data.ptr();
+ uint8_t *w = dest.ptrw();
- ERR_FAIL_COND(!r.ptr());
+ ERR_FAIL_COND(!r);
- hq2x_resize((const uint32_t *)r.ptr(), width, height, (uint32_t *)w.ptr());
+ hq2x_resize((const uint32_t *)r, width, height, (uint32_t *)w);
}
width *= 2;
@@ -1381,7 +1364,7 @@ void Image::shrink_x2() {
if (mipmaps) {
//just use the lower mipmap as base and copy all
- PoolVector<uint8_t> new_img;
+ Vector<uint8_t> new_img;
int ofs = get_mipmap_offset(1);
@@ -1390,10 +1373,10 @@ void Image::shrink_x2() {
ERR_FAIL_COND(new_img.size() == 0);
{
- PoolVector<uint8_t>::Write w = new_img.write();
- PoolVector<uint8_t>::Read r = data.read();
+ uint8_t *w = new_img.ptrw();
+ const uint8_t *r = data.ptr();
- copymem(w.ptr(), &r[ofs], new_size);
+ copymem(w, &r[ofs], new_size);
}
width = MAX(width / 2, 1);
@@ -1402,7 +1385,7 @@ void Image::shrink_x2() {
} else {
- PoolVector<uint8_t> new_img;
+ Vector<uint8_t> new_img;
ERR_FAIL_COND(!_can_modify(format));
int ps = get_format_pixel_size(format);
@@ -1411,29 +1394,29 @@ void Image::shrink_x2() {
ERR_FAIL_COND(data.size() == 0);
{
- PoolVector<uint8_t>::Write w = new_img.write();
- PoolVector<uint8_t>::Read r = data.read();
+ uint8_t *w = new_img.ptrw();
+ const uint8_t *r = data.ptr();
switch (format) {
case FORMAT_L8:
- case FORMAT_R8: _generate_po2_mipmap<uint8_t, 1, false, Image::average_4_uint8, Image::renormalize_uint8>(r.ptr(), w.ptr(), width, height); break;
- case FORMAT_LA8: _generate_po2_mipmap<uint8_t, 2, false, Image::average_4_uint8, Image::renormalize_uint8>(r.ptr(), w.ptr(), width, height); break;
- case FORMAT_RG8: _generate_po2_mipmap<uint8_t, 2, false, Image::average_4_uint8, Image::renormalize_uint8>(r.ptr(), w.ptr(), width, height); break;
- case FORMAT_RGB8: _generate_po2_mipmap<uint8_t, 3, false, Image::average_4_uint8, Image::renormalize_uint8>(r.ptr(), w.ptr(), width, height); break;
- case FORMAT_RGBA8: _generate_po2_mipmap<uint8_t, 4, false, Image::average_4_uint8, Image::renormalize_uint8>(r.ptr(), w.ptr(), width, height); break;
-
- case FORMAT_RF: _generate_po2_mipmap<float, 1, false, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(r.ptr()), reinterpret_cast<float *>(w.ptr()), width, height); break;
- case FORMAT_RGF: _generate_po2_mipmap<float, 2, false, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(r.ptr()), reinterpret_cast<float *>(w.ptr()), width, height); break;
- case FORMAT_RGBF: _generate_po2_mipmap<float, 3, false, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(r.ptr()), reinterpret_cast<float *>(w.ptr()), width, height); break;
- case FORMAT_RGBAF: _generate_po2_mipmap<float, 4, false, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(r.ptr()), reinterpret_cast<float *>(w.ptr()), width, height); break;
-
- case FORMAT_RH: _generate_po2_mipmap<uint16_t, 1, false, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(r.ptr()), reinterpret_cast<uint16_t *>(w.ptr()), width, height); break;
- case FORMAT_RGH: _generate_po2_mipmap<uint16_t, 2, false, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(r.ptr()), reinterpret_cast<uint16_t *>(w.ptr()), width, height); break;
- case FORMAT_RGBH: _generate_po2_mipmap<uint16_t, 3, false, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(r.ptr()), reinterpret_cast<uint16_t *>(w.ptr()), width, height); break;
- case FORMAT_RGBAH: _generate_po2_mipmap<uint16_t, 4, false, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(r.ptr()), reinterpret_cast<uint16_t *>(w.ptr()), width, height); break;
-
- case FORMAT_RGBE9995: _generate_po2_mipmap<uint32_t, 1, false, Image::average_4_rgbe9995, Image::renormalize_rgbe9995>(reinterpret_cast<const uint32_t *>(r.ptr()), reinterpret_cast<uint32_t *>(w.ptr()), width, height); break;
+ case FORMAT_R8: _generate_po2_mipmap<uint8_t, 1, false, Image::average_4_uint8, Image::renormalize_uint8>(r, w, width, height); break;
+ case FORMAT_LA8: _generate_po2_mipmap<uint8_t, 2, false, Image::average_4_uint8, Image::renormalize_uint8>(r, w, width, height); break;
+ case FORMAT_RG8: _generate_po2_mipmap<uint8_t, 2, false, Image::average_4_uint8, Image::renormalize_uint8>(r, w, width, height); break;
+ case FORMAT_RGB8: _generate_po2_mipmap<uint8_t, 3, false, Image::average_4_uint8, Image::renormalize_uint8>(r, w, width, height); break;
+ case FORMAT_RGBA8: _generate_po2_mipmap<uint8_t, 4, false, Image::average_4_uint8, Image::renormalize_uint8>(r, w, width, height); break;
+
+ case FORMAT_RF: _generate_po2_mipmap<float, 1, false, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(r), reinterpret_cast<float *>(w), width, height); break;
+ case FORMAT_RGF: _generate_po2_mipmap<float, 2, false, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(r), reinterpret_cast<float *>(w), width, height); break;
+ case FORMAT_RGBF: _generate_po2_mipmap<float, 3, false, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(r), reinterpret_cast<float *>(w), width, height); break;
+ case FORMAT_RGBAF: _generate_po2_mipmap<float, 4, false, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(r), reinterpret_cast<float *>(w), width, height); break;
+
+ case FORMAT_RH: _generate_po2_mipmap<uint16_t, 1, false, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(r), reinterpret_cast<uint16_t *>(w), width, height); break;
+ case FORMAT_RGH: _generate_po2_mipmap<uint16_t, 2, false, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(r), reinterpret_cast<uint16_t *>(w), width, height); break;
+ case FORMAT_RGBH: _generate_po2_mipmap<uint16_t, 3, false, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(r), reinterpret_cast<uint16_t *>(w), width, height); break;
+ case FORMAT_RGBAH: _generate_po2_mipmap<uint16_t, 4, false, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(r), reinterpret_cast<uint16_t *>(w), width, height); break;
+
+ case FORMAT_RGBE9995: _generate_po2_mipmap<uint32_t, 1, false, Image::average_4_rgbe9995, Image::renormalize_rgbe9995>(reinterpret_cast<const uint32_t *>(r), reinterpret_cast<uint32_t *>(w), width, height); break;
default: {
}
}
@@ -1452,8 +1435,6 @@ void Image::normalize() {
clear_mipmaps();
}
- lock();
-
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
@@ -1468,8 +1449,6 @@ void Image::normalize() {
}
}
- unlock();
-
if (used_mipmaps) {
generate_mipmaps(true);
}
@@ -1487,7 +1466,7 @@ Error Image::generate_mipmaps(bool p_renormalize) {
data.resize(size);
- PoolVector<uint8_t>::Write wp = data.write();
+ uint8_t *wp = data.ptrw();
int prev_ofs = 0;
int prev_h = height;
@@ -1599,7 +1578,6 @@ Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, con
normal_sat = normal_sat_vec.ptrw();
//create summed area table
- nm->lock();
for (int y = 0; y < normal_h; y++) {
double line_sum[3] = { 0, 0, 0 };
@@ -1642,9 +1620,7 @@ Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, con
_get_dst_image_size(width, height, format, mmcount);
- lock();
-
- uint8_t *base_ptr = write_lock.ptr();
+ uint8_t *base_ptr = data.ptrw();
for (int i = 1; i <= mmcount; i++) {
@@ -1759,11 +1735,13 @@ Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, con
{
int size = get_mipmap_byte_size(i);
print_line("size for mimpap " + itos(i) + ": " + itos(size));
- PoolVector<uint8_t> imgdata;
+ Vector<uint8_t> imgdata;
imgdata.resize(size);
- PoolVector<uint8_t>::Write wr = imgdata.write();
+
+
+ uint8_t* wr = imgdata.ptrw();
copymem(wr.ptr(), ptr, size);
- wr = PoolVector<uint8_t>::Write();
+ wr = uint8_t*();
Ref<Image> im;
im.instance();
im->create(w, h, false, format, imgdata);
@@ -1772,9 +1750,6 @@ Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, con
#endif
}
- unlock();
- nm->unlock();
-
return OK;
}
@@ -1798,7 +1773,7 @@ bool Image::empty() const {
return (data.size() == 0);
}
-PoolVector<uint8_t> Image::get_data() const {
+Vector<uint8_t> Image::get_data() const {
return data;
}
@@ -1812,9 +1787,10 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_forma
int mm = 0;
int size = _get_dst_image_size(p_width, p_height, p_format, mm, p_use_mipmaps ? -1 : 0);
data.resize(size);
+
{
- PoolVector<uint8_t>::Write w = data.write();
- zeromem(w.ptr(), size);
+ uint8_t *w = data.ptrw();
+ zeromem(w, size);
}
width = p_width;
@@ -1823,7 +1799,7 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_forma
format = p_format;
}
-void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const PoolVector<uint8_t> &p_data) {
+void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const Vector<uint8_t> &p_data) {
ERR_FAIL_INDEX(p_width - 1, MAX_WIDTH);
ERR_FAIL_INDEX(p_height - 1, MAX_HEIGHT);
@@ -1838,6 +1814,7 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_forma
width = p_width;
format = p_format;
data = p_data;
+
mipmaps = p_use_mipmaps;
}
@@ -1862,7 +1839,7 @@ void Image::create(const char **p_xpm) {
HashMap<String, Color> colormap;
int colormap_size = 0;
uint32_t pixel_size = 0;
- PoolVector<uint8_t>::Write w;
+ uint8_t *w;
while (status != DONE) {
@@ -1953,7 +1930,7 @@ void Image::create(const char **p_xpm) {
status = READING_PIXELS;
create(size_width, size_height, 0, has_alpha ? FORMAT_RGBA8 : FORMAT_RGB8);
- w = data.write();
+ w = data.ptrw();
pixel_size = has_alpha ? 4 : 3;
}
} break;
@@ -1972,7 +1949,7 @@ void Image::create(const char **p_xpm) {
for (uint32_t i = 0; i < pixel_size; i++) {
pixel[i] = CLAMP((*colorptr)[i] * 255, 0, 255);
}
- _put_pixelb(x, y, pixel_size, w.ptr(), pixel);
+ _put_pixelb(x, y, pixel_size, w, pixel);
}
if (y == (size_height - 1))
@@ -2024,8 +2001,8 @@ bool Image::is_invisible() const {
int w, h;
_get_mipmap_offset_and_size(1, len, w, h);
- PoolVector<uint8_t>::Read r = data.read();
- const unsigned char *data_ptr = r.ptr();
+ const uint8_t *r = data.ptr();
+ const unsigned char *data_ptr = r;
bool detected = false;
@@ -2069,8 +2046,8 @@ Image::AlphaMode Image::detect_alpha() const {
int w, h;
_get_mipmap_offset_and_size(1, len, w, h);
- PoolVector<uint8_t>::Read r = data.read();
- const unsigned char *data_ptr = r.ptr();
+ const uint8_t *r = data.ptr();
+ const unsigned char *data_ptr = r;
bool bit = false;
bool detected = false;
@@ -2126,9 +2103,9 @@ Error Image::save_png(const String &p_path) const {
return save_png_func(p_path, Ref<Image>((Image *)this));
}
-PoolVector<uint8_t> Image::save_png_to_buffer() const {
+Vector<uint8_t> Image::save_png_to_buffer() const {
if (save_png_buffer_func == NULL) {
- return PoolVector<uint8_t>();
+ return Vector<uint8_t>();
}
return save_png_buffer_func(Ref<Image>((Image *)this));
@@ -2266,7 +2243,7 @@ Image::Image(int p_width, int p_height, bool p_use_mipmaps, Format p_format) {
create(p_width, p_height, p_use_mipmaps, p_format);
}
-Image::Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const PoolVector<uint8_t> &p_data) {
+Image::Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const Vector<uint8_t> &p_data) {
width = 0;
height = 0;
@@ -2286,7 +2263,6 @@ Rect2 Image::get_used_rect() const {
if (len == 0)
return Rect2();
- const_cast<Image *>(this)->lock();
int minx = 0xFFFFFF, miny = 0xFFFFFFF;
int maxx = -1, maxy = -1;
for (int j = 0; j < height; j++) {
@@ -2305,8 +2281,6 @@ Rect2 Image::get_used_rect() const {
}
}
- const_cast<Image *>(this)->unlock();
-
if (maxx == -1)
return Rect2();
else
@@ -2343,11 +2317,11 @@ void Image::blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Po
Point2 src_underscan = Point2(MIN(0, p_src_rect.position.x), MIN(0, p_src_rect.position.y));
Rect2i dest_rect = Rect2i(0, 0, width, height).clip(Rect2i(p_dest - src_underscan, clipped_src_rect.size));
- PoolVector<uint8_t>::Write wp = data.write();
- uint8_t *dst_data_ptr = wp.ptr();
+ uint8_t *wp = data.ptrw();
+ uint8_t *dst_data_ptr = wp;
- PoolVector<uint8_t>::Read rp = p_src->data.read();
- const uint8_t *src_data_ptr = rp.ptr();
+ const uint8_t *rp = p_src->data.ptr();
+ const uint8_t *src_data_ptr = rp;
int pixel_size = get_format_pixel_size(format);
@@ -2398,16 +2372,15 @@ void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, co
Point2 src_underscan = Point2(MIN(0, p_src_rect.position.x), MIN(0, p_src_rect.position.y));
Rect2i dest_rect = Rect2i(0, 0, width, height).clip(Rect2i(p_dest - src_underscan, clipped_src_rect.size));
- PoolVector<uint8_t>::Write wp = data.write();
- uint8_t *dst_data_ptr = wp.ptr();
+ uint8_t *wp = data.ptrw();
+ uint8_t *dst_data_ptr = wp;
- PoolVector<uint8_t>::Read rp = p_src->data.read();
- const uint8_t *src_data_ptr = rp.ptr();
+ const uint8_t *rp = p_src->data.ptr();
+ const uint8_t *src_data_ptr = rp;
int pixel_size = get_format_pixel_size(format);
Ref<Image> msk = p_mask;
- msk->lock();
for (int i = 0; i < dest_rect.size.y; i++) {
@@ -2430,8 +2403,6 @@ void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, co
}
}
}
-
- msk->unlock();
}
void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest) {
@@ -2456,9 +2427,7 @@ void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const P
Point2 src_underscan = Point2(MIN(0, p_src_rect.position.x), MIN(0, p_src_rect.position.y));
Rect2i dest_rect = Rect2i(0, 0, width, height).clip(Rect2i(p_dest - src_underscan, clipped_src_rect.size));
- lock();
Ref<Image> img = p_src;
- img->lock();
for (int i = 0; i < dest_rect.size.y; i++) {
@@ -2479,9 +2448,6 @@ void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const P
set_pixel(dst_x, dst_y, dc);
}
}
-
- img->unlock();
- unlock();
}
void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest) {
@@ -2511,11 +2477,8 @@ void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, c
Point2 src_underscan = Point2(MIN(0, p_src_rect.position.x), MIN(0, p_src_rect.position.y));
Rect2i dest_rect = Rect2i(0, 0, width, height).clip(Rect2i(p_dest - src_underscan, clipped_src_rect.size));
- lock();
Ref<Image> img = p_src;
Ref<Image> msk = p_mask;
- img->lock();
- msk->lock();
for (int i = 0; i < dest_rect.size.y; i++) {
@@ -2542,19 +2505,13 @@ void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, c
}
}
}
-
- msk->unlock();
- img->unlock();
- unlock();
}
void Image::fill(const Color &c) {
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot fill in compressed or custom image formats.");
- lock();
-
- PoolVector<uint8_t>::Write wp = data.write();
- uint8_t *dst_data_ptr = wp.ptr();
+ uint8_t *wp = data.ptrw();
+ uint8_t *dst_data_ptr = wp;
int pixel_size = get_format_pixel_size(format);
@@ -2572,8 +2529,6 @@ void Image::fill(const Color &c) {
}
}
}
-
- unlock();
}
ImageMemLoadFunc Image::_png_mem_loader_func = NULL;
@@ -2592,12 +2547,12 @@ void (*Image::_image_decompress_bptc)(Image *) = NULL;
void (*Image::_image_decompress_etc1)(Image *) = NULL;
void (*Image::_image_decompress_etc2)(Image *) = NULL;
-PoolVector<uint8_t> (*Image::lossy_packer)(const Ref<Image> &, float) = NULL;
-Ref<Image> (*Image::lossy_unpacker)(const PoolVector<uint8_t> &) = NULL;
-PoolVector<uint8_t> (*Image::lossless_packer)(const Ref<Image> &) = NULL;
-Ref<Image> (*Image::lossless_unpacker)(const PoolVector<uint8_t> &) = NULL;
-PoolVector<uint8_t> (*Image::basis_universal_packer)(const Ref<Image> &, Image::UsedChannels) = NULL;
-Ref<Image> (*Image::basis_universal_unpacker)(const PoolVector<uint8_t> &) = NULL;
+Vector<uint8_t> (*Image::lossy_packer)(const Ref<Image> &, float) = NULL;
+Ref<Image> (*Image::lossy_unpacker)(const Vector<uint8_t> &) = NULL;
+Vector<uint8_t> (*Image::lossless_packer)(const Ref<Image> &) = NULL;
+Ref<Image> (*Image::lossless_unpacker)(const Vector<uint8_t> &) = NULL;
+Vector<uint8_t> (*Image::basis_universal_packer)(const Ref<Image> &, Image::UsedChannels) = NULL;
+Ref<Image> (*Image::basis_universal_unpacker)(const Vector<uint8_t> &) = NULL;
void Image::_set_data(const Dictionary &p_data) {
@@ -2611,7 +2566,7 @@ void Image::_set_data(const Dictionary &p_data) {
int dheight = p_data["height"];
String dformat = p_data["format"];
bool dmipmaps = p_data["mipmaps"];
- PoolVector<uint8_t> ddata = p_data["data"];
+ Vector<uint8_t> ddata = p_data["data"];
Format ddformat = FORMAT_MAX;
for (int i = 0; i < FORMAT_MAX; i++) {
if (dformat == get_format_name(Format(i))) {
@@ -2636,22 +2591,11 @@ Dictionary Image::_get_data() const {
return d;
}
-void Image::lock() {
-
- ERR_FAIL_COND(data.size() == 0);
- write_lock = data.write();
-}
-
-void Image::unlock() {
-
- write_lock.release();
-}
-
Color Image::get_pixelv(const Point2 &p_src) const {
return get_pixel(p_src.x, p_src.y);
}
-Color Image::_get_color_at_ofs(uint8_t *ptr, uint32_t ofs) const {
+Color Image::_get_color_at_ofs(const uint8_t *ptr, uint32_t ofs) const {
switch (format) {
case FORMAT_L8: {
@@ -2873,18 +2817,13 @@ void Image::_set_color_at_ofs(uint8_t *ptr, uint32_t ofs, const Color &p_color)
}
Color Image::get_pixel(int p_x, int p_y) const {
-
- uint8_t *ptr = write_lock.ptr();
#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V_MSG(!ptr, Color(), "Image must be locked with 'lock()' before using get_pixel().");
-
ERR_FAIL_INDEX_V(p_x, width, Color());
ERR_FAIL_INDEX_V(p_y, height, Color());
-
#endif
uint32_t ofs = p_y * width + p_x;
- return _get_color_at_ofs(ptr, ofs);
+ return _get_color_at_ofs(data.ptr(), ofs);
}
void Image::set_pixelv(const Point2 &p_dst, const Color &p_color) {
@@ -2892,18 +2831,13 @@ void Image::set_pixelv(const Point2 &p_dst, const Color &p_color) {
}
void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
-
- uint8_t *ptr = write_lock.ptr();
#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_MSG(!ptr, "Image must be locked with 'lock()' before using set_pixel().");
-
ERR_FAIL_INDEX(p_x, width);
ERR_FAIL_INDEX(p_y, height);
-
#endif
uint32_t ofs = p_y * width + p_x;
- _set_color_at_ofs(ptr, ofs, p_color);
+ _set_color_at_ofs(data.ptrw(), ofs, p_color);
}
Image::UsedChannels Image::detect_used_channels(CompressSource p_source) {
@@ -2911,7 +2845,7 @@ Image::UsedChannels Image::detect_used_channels(CompressSource p_source) {
ERR_FAIL_COND_V(data.size() == 0, USED_CHANNELS_RGBA);
ERR_FAIL_COND_V(is_compressed(), USED_CHANNELS_RGBA);
bool r = false, g = false, b = false, a = false, c = false;
- lock();
+
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
@@ -2932,8 +2866,6 @@ Image::UsedChannels Image::detect_used_channels(CompressSource p_source) {
}
}
- unlock();
-
UsedChannels used_channels;
if (!c && !a)
@@ -3036,8 +2968,6 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_data", "data"), &Image::_set_data);
ClassDB::bind_method(D_METHOD("_get_data"), &Image::_get_data);
- ClassDB::bind_method(D_METHOD("lock"), &Image::lock);
- ClassDB::bind_method(D_METHOD("unlock"), &Image::unlock);
ClassDB::bind_method(D_METHOD("get_pixelv", "src"), &Image::get_pixelv);
ClassDB::bind_method(D_METHOD("get_pixel", "x", "y"), &Image::get_pixel);
ClassDB::bind_method(D_METHOD("set_pixelv", "dst", "color"), &Image::set_pixelv);
@@ -3137,8 +3067,7 @@ void Image::normalmap_to_xy() {
{
int len = data.size() / 4;
- PoolVector<uint8_t>::Write wp = data.write();
- unsigned char *data_ptr = wp.ptr();
+ uint8_t *data_ptr = data.ptrw();
for (int i = 0; i < len; i++) {
@@ -3162,19 +3091,12 @@ Ref<Image> Image::rgbe_to_srgb() {
new_image.instance();
new_image->create(width, height, 0, Image::FORMAT_RGB8);
- lock();
-
- new_image->lock();
-
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
new_image->set_pixel(col, row, get_pixel(col, row).to_srgb());
}
}
- unlock();
- new_image->unlock();
-
if (has_mipmaps()) {
new_image->generate_mipmaps();
}
@@ -3187,12 +3109,13 @@ Ref<Image> Image::get_image_from_mipmap(int p_mipamp) const {
int ofs, size, w, h;
get_mipmap_offset_size_and_dimensions(p_mipamp, ofs, size, w, h);
- PoolVector<uint8_t> new_data;
+ Vector<uint8_t> new_data;
new_data.resize(size);
+
{
- PoolVector<uint8_t>::Write wr = new_data.write();
- PoolVector<uint8_t>::Read rd = data.read();
- copymem(wr.ptr(), rd.ptr() + ofs, size);
+ uint8_t *wr = new_data.ptrw();
+ const uint8_t *rd = data.ptr();
+ copymem(wr, rd + ofs, size);
}
Ref<Image> image;
@@ -3201,6 +3124,7 @@ Ref<Image> Image::get_image_from_mipmap(int p_mipamp) const {
image->height = h;
image->format = format;
image->data = new_data;
+
image->mipmaps = false;
return image;
}
@@ -3209,17 +3133,17 @@ void Image::bumpmap_to_normalmap(float bump_scale) {
ERR_FAIL_COND(!_can_modify(format));
convert(Image::FORMAT_RF);
- PoolVector<uint8_t> result_image; //rgba output
+ Vector<uint8_t> result_image; //rgba output
result_image.resize(width * height * 4);
{
- PoolVector<uint8_t>::Read rp = data.read();
- PoolVector<uint8_t>::Write wp = result_image.write();
+ const uint8_t *rp = data.ptr();
+ uint8_t *wp = result_image.ptrw();
- ERR_FAIL_COND(!rp.ptr());
+ ERR_FAIL_COND(!rp);
- unsigned char *write_ptr = wp.ptr();
- float *read_ptr = (float *)rp.ptr();
+ unsigned char *write_ptr = wp;
+ float *read_ptr = (float *)rp;
for (int ty = 0; ty < height; ty++) {
int py = ty + 1;
@@ -3260,8 +3184,7 @@ void Image::srgb_to_linear() {
if (format == FORMAT_RGBA8) {
int len = data.size() / 4;
- PoolVector<uint8_t>::Write wp = data.write();
- unsigned char *data_ptr = wp.ptr();
+ uint8_t *data_ptr = data.ptrw();
for (int i = 0; i < len; i++) {
@@ -3273,8 +3196,7 @@ void Image::srgb_to_linear() {
} else if (format == FORMAT_RGB8) {
int len = data.size() / 3;
- PoolVector<uint8_t>::Write wp = data.write();
- unsigned char *data_ptr = wp.ptr();
+ uint8_t *data_ptr = data.ptrw();
for (int i = 0; i < len; i++) {
@@ -3293,8 +3215,7 @@ void Image::premultiply_alpha() {
if (format != FORMAT_RGBA8)
return; //not needed
- PoolVector<uint8_t>::Write wp = data.write();
- unsigned char *data_ptr = wp.ptr();
+ uint8_t *data_ptr = data.ptrw();
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
@@ -3316,12 +3237,10 @@ void Image::fix_alpha_edges() {
if (format != FORMAT_RGBA8)
return; //not needed
- PoolVector<uint8_t> dcopy = data;
- PoolVector<uint8_t>::Read rp = dcopy.read();
- const uint8_t *srcptr = rp.ptr();
+ Vector<uint8_t> dcopy = data;
+ const uint8_t *srcptr = dcopy.ptr();
- PoolVector<uint8_t>::Write wp = data.write();
- unsigned char *data_ptr = wp.ptr();
+ uint8_t *data_ptr = data.ptrw();
const int max_radius = 4;
const int alpha_threshold = 20;
@@ -3381,15 +3300,15 @@ String Image::get_format_name(Format p_format) {
return format_names[p_format];
}
-Error Image::load_png_from_buffer(const PoolVector<uint8_t> &p_array) {
+Error Image::load_png_from_buffer(const Vector<uint8_t> &p_array) {
return _load_from_buffer(p_array, _png_mem_loader_func);
}
-Error Image::load_jpg_from_buffer(const PoolVector<uint8_t> &p_array) {
+Error Image::load_jpg_from_buffer(const Vector<uint8_t> &p_array) {
return _load_from_buffer(p_array, _jpg_mem_loader_func);
}
-Error Image::load_webp_from_buffer(const PoolVector<uint8_t> &p_array) {
+Error Image::load_webp_from_buffer(const Vector<uint8_t> &p_array) {
return _load_from_buffer(p_array, _webp_mem_loader_func);
}
@@ -3398,7 +3317,7 @@ void Image::convert_rg_to_ra_rgba8() {
ERR_FAIL_COND(!data.size());
int s = data.size();
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
for (int i = 0; i < s; i += 4) {
w[i + 3] = w[i + 1];
w[i + 1] = 0;
@@ -3410,7 +3329,7 @@ void Image::convert_ra_rgba8_to_rg() {
ERR_FAIL_COND(!data.size());
int s = data.size();
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
for (int i = 0; i < s; i += 4) {
w[i + 1] = w[i + 3];
w[i + 2] = 0;
@@ -3418,15 +3337,15 @@ void Image::convert_ra_rgba8_to_rg() {
}
}
-Error Image::_load_from_buffer(const PoolVector<uint8_t> &p_array, ImageMemLoadFunc p_loader) {
+Error Image::_load_from_buffer(const Vector<uint8_t> &p_array, ImageMemLoadFunc p_loader) {
int buffer_size = p_array.size();
ERR_FAIL_COND_V(buffer_size == 0, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(!p_loader, ERR_INVALID_PARAMETER);
- PoolVector<uint8_t>::Read r = p_array.read();
+ const uint8_t *r = p_array.ptr();
- Ref<Image> image = p_loader(r.ptr(), buffer_size);
+ Ref<Image> image = p_loader(r, buffer_size);
ERR_FAIL_COND_V(!image.is_valid(), ERR_PARSE_ERROR);
copy_internals_from(image);
@@ -3516,8 +3435,4 @@ Image::Image() {
}
Image::~Image() {
-
- if (write_lock.ptr()) {
- unlock();
- }
}
diff --git a/core/image.h b/core/image.h
index 1cc22420d5..4dc4bf1328 100644
--- a/core/image.h
+++ b/core/image.h
@@ -33,7 +33,7 @@
#include "core/color.h"
#include "core/math/rect2.h"
-#include "core/pool_vector.h"
+
#include "core/resource.h"
/**
@@ -47,7 +47,7 @@
class Image;
typedef Error (*SavePNGFunc)(const String &p_path, const Ref<Image> &p_img);
-typedef PoolVector<uint8_t> (*SavePNGBufferFunc)(const Ref<Image> &p_img);
+typedef Vector<uint8_t> (*SavePNGBufferFunc)(const Ref<Image> &p_img);
typedef Ref<Image> (*ImageMemLoadFunc)(const uint8_t *p_png, int p_size);
typedef Error (*SaveEXRFunc)(const String &p_path, const Ref<Image> &p_img, bool p_grayscale);
@@ -150,16 +150,14 @@ public:
static void (*_image_decompress_etc1)(Image *);
static void (*_image_decompress_etc2)(Image *);
- static PoolVector<uint8_t> (*lossy_packer)(const Ref<Image> &p_image, float p_quality);
- static Ref<Image> (*lossy_unpacker)(const PoolVector<uint8_t> &p_buffer);
- static PoolVector<uint8_t> (*lossless_packer)(const Ref<Image> &p_image);
- static Ref<Image> (*lossless_unpacker)(const PoolVector<uint8_t> &p_buffer);
- static PoolVector<uint8_t> (*basis_universal_packer)(const Ref<Image> &p_image, UsedChannels p_channels);
- static Ref<Image> (*basis_universal_unpacker)(const PoolVector<uint8_t> &p_buffer);
-
- PoolVector<uint8_t>::Write write_lock;
+ static Vector<uint8_t> (*lossy_packer)(const Ref<Image> &p_image, float p_quality);
+ static Ref<Image> (*lossy_unpacker)(const Vector<uint8_t> &p_buffer);
+ static Vector<uint8_t> (*lossless_packer)(const Ref<Image> &p_image);
+ static Ref<Image> (*lossless_unpacker)(const Vector<uint8_t> &p_buffer);
+ static Vector<uint8_t> (*basis_universal_packer)(const Ref<Image> &p_image, UsedChannels p_channels);
+ static Ref<Image> (*basis_universal_unpacker)(const Vector<uint8_t> &p_buffer);
- _FORCE_INLINE_ Color _get_color_at_ofs(uint8_t *ptr, uint32_t ofs) const;
+ _FORCE_INLINE_ Color _get_color_at_ofs(const uint8_t *ptr, uint32_t ofs) const;
_FORCE_INLINE_ void _set_color_at_ofs(uint8_t *ptr, uint32_t ofs, const Color &p_color);
protected:
@@ -170,12 +168,12 @@ private:
create(p_width, p_height, p_use_mipmaps, p_format);
}
- void _create_from_data(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const PoolVector<uint8_t> &p_data) {
+ void _create_from_data(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const Vector<uint8_t> &p_data) {
create(p_width, p_height, p_use_mipmaps, p_format, p_data);
}
Format format;
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
int width, height;
bool mipmaps;
@@ -198,7 +196,7 @@ private:
void _set_data(const Dictionary &p_data);
Dictionary _get_data() const;
- Error _load_from_buffer(const PoolVector<uint8_t> &p_array, ImageMemLoadFunc p_loader);
+ Error _load_from_buffer(const Vector<uint8_t> &p_array, ImageMemLoadFunc p_loader);
static void average_4_uint8(uint8_t &p_out, const uint8_t &p_a, const uint8_t &p_b, const uint8_t &p_c, const uint8_t &p_d);
static void average_4_float(float &p_out, const float &p_a, const float &p_b, const float &p_c, const float &p_d);
@@ -270,7 +268,7 @@ public:
* Create a new image of a given size and format. Current image will be lost
*/
void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format);
- void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const PoolVector<uint8_t> &p_data);
+ void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const Vector<uint8_t> &p_data);
void create(const char **p_xpm);
/**
@@ -278,11 +276,11 @@ public:
*/
bool empty() const;
- PoolVector<uint8_t> get_data() const;
+ Vector<uint8_t> get_data() const;
Error load(const String &p_path);
Error save_png(const String &p_path) const;
- PoolVector<uint8_t> save_png_to_buffer() const;
+ Vector<uint8_t> save_png_to_buffer() const;
Error save_exr(const String &p_path, bool p_grayscale) const;
/**
@@ -296,7 +294,7 @@ public:
/**
* import an image of a specific size and format from a pointer
*/
- Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const PoolVector<uint8_t> &p_data);
+ Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const Vector<uint8_t> &p_data);
enum AlphaMode {
ALPHA_NONE,
@@ -358,9 +356,9 @@ public:
static void set_compress_bptc_func(void (*p_compress_func)(Image *, float, UsedChannels));
static String get_format_name(Format p_format);
- Error load_png_from_buffer(const PoolVector<uint8_t> &p_array);
- Error load_jpg_from_buffer(const PoolVector<uint8_t> &p_array);
- Error load_webp_from_buffer(const PoolVector<uint8_t> &p_array);
+ Error load_png_from_buffer(const Vector<uint8_t> &p_array);
+ Error load_jpg_from_buffer(const Vector<uint8_t> &p_array);
+ Error load_webp_from_buffer(const Vector<uint8_t> &p_array);
void convert_rg_to_ra_rgba8();
void convert_ra_rgba8_to_rg();
@@ -370,9 +368,6 @@ public:
virtual Ref<Resource> duplicate(bool p_subresources = false) const;
- void lock();
- void unlock();
-
UsedChannels detect_used_channels(CompressSource p_source = COMPRESS_SOURCE_GENERIC);
void optimize_channels();
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index 5968972143..b44ac16a87 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -34,11 +34,11 @@
#include "core/os/keyboard.h"
#include "core/variant_parser.h"
-PoolStringArray ConfigFile::_get_sections() const {
+PackedStringArray ConfigFile::_get_sections() const {
List<String> s;
get_sections(&s);
- PoolStringArray arr;
+ PackedStringArray arr;
arr.resize(s.size());
int idx = 0;
for (const List<String>::Element *E = s.front(); E; E = E->next()) {
@@ -49,11 +49,11 @@ PoolStringArray ConfigFile::_get_sections() const {
return arr;
}
-PoolStringArray ConfigFile::_get_section_keys(const String &p_section) const {
+PackedStringArray ConfigFile::_get_section_keys(const String &p_section) const {
List<String> s;
get_section_keys(p_section, &s);
- PoolStringArray arr;
+ PackedStringArray arr;
arr.resize(s.size());
int idx = 0;
for (const List<String>::Element *E = s.front(); E; E = E->next()) {
diff --git a/core/io/config_file.h b/core/io/config_file.h
index 2d61ef6afe..150fd24693 100644
--- a/core/io/config_file.h
+++ b/core/io/config_file.h
@@ -42,8 +42,8 @@ class ConfigFile : public Reference {
OrderedHashMap<String, OrderedHashMap<String, Variant> > values;
- PoolStringArray _get_sections() const;
- PoolStringArray _get_section_keys(const String &p_section) const;
+ PackedStringArray _get_sections() const;
+ PackedStringArray _get_section_keys(const String &p_section) const;
Error _internal_load(const String &p_path, FileAccess *f);
Error _internal_save(FileAccess *file);
diff --git a/core/io/file_access_buffered.cpp b/core/io/file_access_buffered.cpp
index 6ac065a19b..ab0fb3943c 100644
--- a/core/io/file_access_buffered.cpp
+++ b/core/io/file_access_buffered.cpp
@@ -113,7 +113,7 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
int size = (cache.buffer.size() - (file.offset - cache.offset));
size = size - (size % 4);
- //PoolVector<uint8_t>::Read read = cache.buffer.read();
+ //const uint8_t* read = cache.buffer.ptr();
//memcpy(p_dest, read.ptr() + (file.offset - cache.offset), size);
memcpy(p_dest, cache.buffer.ptr() + (file.offset - cache.offset), size);
p_dest += size;
@@ -145,7 +145,7 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
}
int r = MIN(left, to_read);
- //PoolVector<uint8_t>::Read read = cache.buffer.read();
+ //const uint8_t* read = cache.buffer.ptr();
//memcpy(p_dest+total_read, &read.ptr()[file.offset - cache.offset], r);
memcpy(p_dest + total_read, cache.buffer.ptr() + (file.offset - cache.offset), r);
diff --git a/core/io/file_access_buffered.h b/core/io/file_access_buffered.h
index 5e2939c1a2..a6177c20be 100644
--- a/core/io/file_access_buffered.h
+++ b/core/io/file_access_buffered.h
@@ -32,7 +32,7 @@
#define FILE_ACCESS_BUFFERED_H
#include "core/os/file_access.h"
-#include "core/pool_vector.h"
+
#include "core/ustring.h"
class FileAccessBuffered : public FileAccess {
diff --git a/core/io/file_access_buffered_fa.h b/core/io/file_access_buffered_fa.h
index c17652080c..6ec77d503b 100644
--- a/core/io/file_access_buffered_fa.h
+++ b/core/io/file_access_buffered_fa.h
@@ -54,8 +54,8 @@ class FileAccessBufferedFA : public FileAccessBuffered {
cache.offset = p_offset;
cache.buffer.resize(p_size);
- // on PoolVector
- //PoolVector<uint8_t>::Write write = cache.buffer.write();
+ // on Vector
+ //uint8_t* write = cache.buffer.ptrw();
//f.get_buffer(write.ptrw(), p_size);
// on vector
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 541bd3a7c8..ce7025de35 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -110,7 +110,7 @@ Ref<StreamPeer> HTTPClient::get_connection() const {
return connection;
}
-Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const PoolVector<uint8_t> &p_body) {
+Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const Vector<uint8_t> &p_body) {
ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(!p_url.begins_with("/"), ERR_INVALID_PARAMETER);
@@ -152,10 +152,10 @@ Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector
request += "\r\n";
CharString cs = request.utf8();
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
data.resize(cs.length());
{
- PoolVector<uint8_t>::Write data_write = data.write();
+ uint8_t *data_write = data.ptrw();
for (int i = 0; i < cs.length(); i++) {
data_write[i] = cs[i];
}
@@ -163,7 +163,7 @@ Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector
data.append_array(p_body);
- PoolVector<uint8_t>::Read r = data.read();
+ const uint8_t *r = data.ptr();
Error err = connection->put_data(&r[0], data.size());
if (err) {
@@ -517,11 +517,11 @@ int HTTPClient::get_response_body_length() const {
return body_size;
}
-PoolByteArray HTTPClient::read_response_body_chunk() {
+PackedByteArray HTTPClient::read_response_body_chunk() {
- ERR_FAIL_COND_V(status != STATUS_BODY, PoolByteArray());
+ ERR_FAIL_COND_V(status != STATUS_BODY, PackedByteArray());
- PoolByteArray ret;
+ PackedByteArray ret;
Error err = OK;
if (chunked) {
@@ -622,8 +622,8 @@ PoolByteArray HTTPClient::read_response_body_chunk() {
}
ret.resize(chunk.size() - 2);
- PoolByteArray::Write w = ret.write();
- copymem(w.ptr(), chunk.ptr(), chunk.size() - 2);
+ uint8_t *w = ret.ptrw();
+ copymem(w, chunk.ptr(), chunk.size() - 2);
chunk.clear();
}
@@ -639,8 +639,8 @@ PoolByteArray HTTPClient::read_response_body_chunk() {
while (to_read > 0) {
int rec = 0;
{
- PoolByteArray::Write w = ret.write();
- err = _get_http_data(w.ptr() + _offset, to_read, rec);
+ uint8_t *w = ret.ptrw();
+ err = _get_http_data(w + _offset, to_read, rec);
}
if (rec <= 0) { // Ended up reading less
ret.resize(_offset);
@@ -801,11 +801,11 @@ Dictionary HTTPClient::_get_response_headers_as_dictionary() {
return ret;
}
-PoolStringArray HTTPClient::_get_response_headers() {
+PackedStringArray HTTPClient::_get_response_headers() {
List<String> rh;
get_response_headers(&rh);
- PoolStringArray ret;
+ PackedStringArray ret;
ret.resize(rh.size());
int idx = 0;
for (const List<String>::Element *E = rh.front(); E; E = E->next()) {
diff --git a/core/io/http_client.h b/core/io/http_client.h
index 3796eb992c..03ba20f8dd 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -191,7 +191,7 @@ private:
#include "platform/javascript/http_client.h.inc"
#endif
- PoolStringArray _get_response_headers();
+ PackedStringArray _get_response_headers();
Dictionary _get_response_headers_as_dictionary();
static void _bind_methods();
@@ -202,7 +202,7 @@ public:
void set_connection(const Ref<StreamPeer> &p_connection);
Ref<StreamPeer> get_connection() const;
- Error request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const PoolVector<uint8_t> &p_body);
+ Error request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const Vector<uint8_t> &p_body);
Error request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body = String());
void close();
@@ -215,7 +215,7 @@ public:
Error get_response_headers(List<String> *r_response);
int get_response_body_length() const;
- PoolByteArray read_response_body_chunk(); // Can't get body as partial text because of most encodings UTF8, gzip, etc.
+ PackedByteArray read_response_body_chunk(); // Can't get body as partial text because of most encodings UTF8, gzip, etc.
void set_blocking_mode(bool p_enable); // Useful mostly if running in a thread
bool is_blocking_mode_enabled() const;
diff --git a/core/io/json.cpp b/core/io/json.cpp
index 144e4bdc3b..08a147032f 100644
--- a/core/io/json.cpp
+++ b/core/io/json.cpp
@@ -71,9 +71,9 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_
case Variant::BOOL: return p_var.operator bool() ? "true" : "false";
case Variant::INT: return itos(p_var);
case Variant::REAL: return rtos(p_var);
- case Variant::POOL_INT_ARRAY:
- case Variant::POOL_REAL_ARRAY:
- case Variant::POOL_STRING_ARRAY:
+ case Variant::PACKED_INT_ARRAY:
+ case Variant::PACKED_REAL_ARRAY:
+ case Variant::PACKED_STRING_ARRAY:
case Variant::ARRAY: {
String s = "[";
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 17edc4982c..6548faac9f 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -535,7 +535,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
// arrays
- case Variant::POOL_BYTE_ARRAY: {
+ case Variant::PACKED_BYTE_ARRAY: {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
@@ -543,11 +543,11 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
len -= 4;
ERR_FAIL_COND_V(count < 0 || count > len, ERR_INVALID_DATA);
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
if (count) {
data.resize(count);
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
for (int32_t i = 0; i < count; i++) {
w[i] = buf[i];
@@ -563,7 +563,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
}
} break;
- case Variant::POOL_INT_ARRAY: {
+ case Variant::PACKED_INT_ARRAY: {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
@@ -572,12 +572,12 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
ERR_FAIL_MUL_OF(count, 4, ERR_INVALID_DATA);
ERR_FAIL_COND_V(count < 0 || count * 4 > len, ERR_INVALID_DATA);
- PoolVector<int> data;
+ Vector<int> data;
if (count) {
//const int*rbuf=(const int*)buf;
data.resize(count);
- PoolVector<int>::Write w = data.write();
+ int *w = data.ptrw();
for (int32_t i = 0; i < count; i++) {
w[i] = decode_uint32(&buf[i * 4]);
@@ -589,7 +589,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
}
} break;
- case Variant::POOL_REAL_ARRAY: {
+ case Variant::PACKED_REAL_ARRAY: {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
@@ -598,12 +598,12 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
ERR_FAIL_MUL_OF(count, 4, ERR_INVALID_DATA);
ERR_FAIL_COND_V(count < 0 || count * 4 > len, ERR_INVALID_DATA);
- PoolVector<float> data;
+ Vector<float> data;
if (count) {
//const float*rbuf=(const float*)buf;
data.resize(count);
- PoolVector<float>::Write w = data.write();
+ float *w = data.ptrw();
for (int32_t i = 0; i < count; i++) {
w[i] = decode_float(&buf[i * 4]);
@@ -616,12 +616,12 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
}
} break;
- case Variant::POOL_STRING_ARRAY: {
+ case Variant::PACKED_STRING_ARRAY: {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
- PoolVector<String> strings;
+ Vector<String> strings;
buf += 4;
len -= 4;
@@ -642,7 +642,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
r_variant = strings;
} break;
- case Variant::POOL_VECTOR2_ARRAY: {
+ case Variant::PACKED_VECTOR2_ARRAY: {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
@@ -651,7 +651,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
ERR_FAIL_MUL_OF(count, 4 * 2, ERR_INVALID_DATA);
ERR_FAIL_COND_V(count < 0 || count * 4 * 2 > len, ERR_INVALID_DATA);
- PoolVector<Vector2> varray;
+ Vector<Vector2> varray;
if (r_len) {
(*r_len) += 4;
@@ -659,7 +659,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (count) {
varray.resize(count);
- PoolVector<Vector2>::Write w = varray.write();
+ Vector2 *w = varray.ptrw();
for (int32_t i = 0; i < count; i++) {
@@ -676,7 +676,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
r_variant = varray;
} break;
- case Variant::POOL_VECTOR3_ARRAY: {
+ case Variant::PACKED_VECTOR3_ARRAY: {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
@@ -686,7 +686,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
ERR_FAIL_MUL_OF(count, 4 * 3, ERR_INVALID_DATA);
ERR_FAIL_COND_V(count < 0 || count * 4 * 3 > len, ERR_INVALID_DATA);
- PoolVector<Vector3> varray;
+ Vector<Vector3> varray;
if (r_len) {
(*r_len) += 4;
@@ -694,7 +694,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (count) {
varray.resize(count);
- PoolVector<Vector3>::Write w = varray.write();
+ Vector3 *w = varray.ptrw();
for (int32_t i = 0; i < count; i++) {
@@ -712,7 +712,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
r_variant = varray;
} break;
- case Variant::POOL_COLOR_ARRAY: {
+ case Variant::PACKED_COLOR_ARRAY: {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
@@ -722,7 +722,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
ERR_FAIL_MUL_OF(count, 4 * 4, ERR_INVALID_DATA);
ERR_FAIL_COND_V(count < 0 || count * 4 * 4 > len, ERR_INVALID_DATA);
- PoolVector<Color> carray;
+ Vector<Color> carray;
if (r_len) {
(*r_len) += 4;
@@ -730,7 +730,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (count) {
carray.resize(count);
- PoolVector<Color>::Write w = carray.write();
+ Color *w = carray.ptrw();
for (int32_t i = 0; i < count; i++) {
@@ -1207,16 +1207,16 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
// arrays
- case Variant::POOL_BYTE_ARRAY: {
+ case Variant::PACKED_BYTE_ARRAY: {
- PoolVector<uint8_t> data = p_variant;
+ Vector<uint8_t> data = p_variant;
int datalen = data.size();
int datasize = sizeof(uint8_t);
if (buf) {
encode_uint32(datalen, buf);
buf += 4;
- PoolVector<uint8_t>::Read r = data.read();
+ const uint8_t *r = data.ptr();
copymem(buf, &r[0], datalen * datasize);
buf += datalen * datasize;
}
@@ -1229,16 +1229,16 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
}
} break;
- case Variant::POOL_INT_ARRAY: {
+ case Variant::PACKED_INT_ARRAY: {
- PoolVector<int> data = p_variant;
+ Vector<int> data = p_variant;
int datalen = data.size();
int datasize = sizeof(int32_t);
if (buf) {
encode_uint32(datalen, buf);
buf += 4;
- PoolVector<int>::Read r = data.read();
+ const int *r = data.ptr();
for (int i = 0; i < datalen; i++)
encode_uint32(r[i], &buf[i * datasize]);
}
@@ -1246,16 +1246,16 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4 + datalen * datasize;
} break;
- case Variant::POOL_REAL_ARRAY: {
+ case Variant::PACKED_REAL_ARRAY: {
- PoolVector<real_t> data = p_variant;
+ Vector<real_t> data = p_variant;
int datalen = data.size();
int datasize = sizeof(real_t);
if (buf) {
encode_uint32(datalen, buf);
buf += 4;
- PoolVector<real_t>::Read r = data.read();
+ const real_t *r = data.ptr();
for (int i = 0; i < datalen; i++)
encode_float(r[i], &buf[i * datasize]);
}
@@ -1263,9 +1263,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4 + datalen * datasize;
} break;
- case Variant::POOL_STRING_ARRAY: {
+ case Variant::PACKED_STRING_ARRAY: {
- PoolVector<String> data = p_variant;
+ Vector<String> data = p_variant;
int len = data.size();
if (buf) {
@@ -1295,9 +1295,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
}
} break;
- case Variant::POOL_VECTOR2_ARRAY: {
+ case Variant::PACKED_VECTOR2_ARRAY: {
- PoolVector<Vector2> data = p_variant;
+ Vector<Vector2> data = p_variant;
int len = data.size();
if (buf) {
@@ -1322,9 +1322,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4 * 2 * len;
} break;
- case Variant::POOL_VECTOR3_ARRAY: {
+ case Variant::PACKED_VECTOR3_ARRAY: {
- PoolVector<Vector3> data = p_variant;
+ Vector<Vector3> data = p_variant;
int len = data.size();
if (buf) {
@@ -1350,9 +1350,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4 * 3 * len;
} break;
- case Variant::POOL_COLOR_ARRAY: {
+ case Variant::PACKED_COLOR_ARRAY: {
- PoolVector<Color> data = p_variant;
+ Vector<Color> data = p_variant;
int len = data.size();
if (buf) {
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp
index 3f66e00021..abe629ecba 100644
--- a/core/io/multiplayer_api.cpp
+++ b/core/io/multiplayer_api.cpp
@@ -1087,14 +1087,14 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const
_send_rpc(p_node, p_peer_id, p_unreliable, true, p_property, &vptr, 1);
}
-Error MultiplayerAPI::send_bytes(PoolVector<uint8_t> p_data, int p_to, NetworkedMultiplayerPeer::TransferMode p_mode) {
+Error MultiplayerAPI::send_bytes(Vector<uint8_t> p_data, int p_to, NetworkedMultiplayerPeer::TransferMode p_mode) {
ERR_FAIL_COND_V_MSG(p_data.size() < 1, ERR_INVALID_DATA, "Trying to send an empty raw packet.");
ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), ERR_UNCONFIGURED, "Trying to send a raw packet while no network peer is active.");
ERR_FAIL_COND_V_MSG(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED, "Trying to send a raw packet via a network peer which is not connected.");
MAKE_ROOM(p_data.size() + 1);
- PoolVector<uint8_t>::Read r = p_data.read();
+ const uint8_t *r = p_data.ptr();
packet_cache.write[0] = NETWORK_COMMAND_RAW;
memcpy(&packet_cache.write[1], &r[0], p_data.size());
@@ -1108,11 +1108,11 @@ void MultiplayerAPI::_process_raw(int p_from, const uint8_t *p_packet, int p_pac
ERR_FAIL_COND_MSG(p_packet_len < 2, "Invalid packet received. Size too small.");
- PoolVector<uint8_t> out;
+ Vector<uint8_t> out;
int len = p_packet_len - 1;
out.resize(len);
{
- PoolVector<uint8_t>::Write w = out.write();
+ uint8_t *w = out.ptrw();
memcpy(&w[0], &p_packet[1], len);
}
emit_signal("network_peer_packet", p_from, out);
@@ -1284,7 +1284,7 @@ void MultiplayerAPI::_bind_methods() {
ADD_SIGNAL(MethodInfo("network_peer_connected", PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("network_peer_disconnected", PropertyInfo(Variant::INT, "id")));
- ADD_SIGNAL(MethodInfo("network_peer_packet", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::POOL_BYTE_ARRAY, "packet")));
+ ADD_SIGNAL(MethodInfo("network_peer_packet", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::PACKED_BYTE_ARRAY, "packet")));
ADD_SIGNAL(MethodInfo("connected_to_server"));
ADD_SIGNAL(MethodInfo("connection_failed"));
ADD_SIGNAL(MethodInfo("server_disconnected"));
diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h
index 8748dba03c..a706a0e450 100644
--- a/core/io/multiplayer_api.h
+++ b/core/io/multiplayer_api.h
@@ -145,7 +145,7 @@ public:
void set_root_node(Node *p_node);
void set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_peer);
Ref<NetworkedMultiplayerPeer> get_network_peer() const;
- Error send_bytes(PoolVector<uint8_t> p_data, int p_to = NetworkedMultiplayerPeer::TARGET_PEER_BROADCAST, NetworkedMultiplayerPeer::TransferMode p_mode = NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
+ Error send_bytes(Vector<uint8_t> p_data, int p_to = NetworkedMultiplayerPeer::TARGET_PEER_BROADCAST, NetworkedMultiplayerPeer::TransferMode p_mode = NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
// Called by Node.rpc
void rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount);
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 81d7b86161..2f5c493c2c 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -53,7 +53,7 @@ int PacketPeer::get_encode_buffer_max_size() const {
return encode_buffer_max_size;
}
-Error PacketPeer::get_packet_buffer(PoolVector<uint8_t> &r_buffer) {
+Error PacketPeer::get_packet_buffer(Vector<uint8_t> &r_buffer) {
const uint8_t *buffer;
int buffer_size;
@@ -65,20 +65,20 @@ Error PacketPeer::get_packet_buffer(PoolVector<uint8_t> &r_buffer) {
if (buffer_size == 0)
return OK;
- PoolVector<uint8_t>::Write w = r_buffer.write();
+ uint8_t *w = r_buffer.ptrw();
for (int i = 0; i < buffer_size; i++)
w[i] = buffer[i];
return OK;
}
-Error PacketPeer::put_packet_buffer(const PoolVector<uint8_t> &p_buffer) {
+Error PacketPeer::put_packet_buffer(const Vector<uint8_t> &p_buffer) {
int len = p_buffer.size();
if (len == 0)
return OK;
- PoolVector<uint8_t>::Read r = p_buffer.read();
+ const uint8_t *r = p_buffer.ptr();
return put_packet(&r[0], len);
}
@@ -110,11 +110,11 @@ Error PacketPeer::put_var(const Variant &p_packet, bool p_full_objects) {
encode_buffer.resize(next_power_of_2(len));
}
- PoolVector<uint8_t>::Write w = encode_buffer.write();
- err = encode_variant(p_packet, w.ptr(), len, p_full_objects);
+ uint8_t *w = encode_buffer.ptrw();
+ err = encode_variant(p_packet, w, len, p_full_objects);
ERR_FAIL_COND_V_MSG(err != OK, err, "Error when trying to encode Variant.");
- return put_packet(w.ptr(), len);
+ return put_packet(w, len);
}
Variant PacketPeer::_bnd_get_var(bool p_allow_objects) {
@@ -125,12 +125,12 @@ Variant PacketPeer::_bnd_get_var(bool p_allow_objects) {
return var;
}
-Error PacketPeer::_put_packet(const PoolVector<uint8_t> &p_buffer) {
+Error PacketPeer::_put_packet(const Vector<uint8_t> &p_buffer) {
return put_packet_buffer(p_buffer);
}
-PoolVector<uint8_t> PacketPeer::_get_packet() {
+Vector<uint8_t> PacketPeer::_get_packet() {
- PoolVector<uint8_t> raw;
+ Vector<uint8_t> raw;
last_get_error = get_packet_buffer(raw);
return raw;
}
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index bee69f5ca9..62144259cc 100644
--- a/core/io/packet_peer.h
+++ b/core/io/packet_peer.h
@@ -43,14 +43,14 @@ class PacketPeer : public Reference {
static void _bind_methods();
- Error _put_packet(const PoolVector<uint8_t> &p_buffer);
- PoolVector<uint8_t> _get_packet();
+ Error _put_packet(const Vector<uint8_t> &p_buffer);
+ Vector<uint8_t> _get_packet();
Error _get_packet_error() const;
mutable Error last_get_error;
int encode_buffer_max_size;
- PoolVector<uint8_t> encode_buffer;
+ Vector<uint8_t> encode_buffer;
public:
virtual int get_available_packet_count() const = 0;
@@ -61,8 +61,8 @@ public:
/* helpers / binders */
- virtual Error get_packet_buffer(PoolVector<uint8_t> &r_buffer);
- virtual Error put_packet_buffer(const PoolVector<uint8_t> &p_buffer);
+ virtual Error get_packet_buffer(Vector<uint8_t> &r_buffer);
+ virtual Error put_packet_buffer(const Vector<uint8_t> &p_buffer);
virtual Error get_var(Variant &r_variant, bool p_allow_objects = false);
virtual Error put_var(const Variant &p_packet, bool p_full_objects = false);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 02ae5788fc..d4c1fd2e9b 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -398,12 +398,12 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
uint32_t len = f->get_32();
- PoolVector<uint8_t> array;
+ Vector<uint8_t> array;
array.resize(len);
- PoolVector<uint8_t>::Write w = array.write();
- f->get_buffer(w.ptr(), len);
+ uint8_t *w = array.ptrw();
+ f->get_buffer(w, len);
_advance_padding(len);
- w.release();
+
r_v = array;
} break;
@@ -411,10 +411,10 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
uint32_t len = f->get_32();
- PoolVector<int> array;
+ Vector<int> array;
array.resize(len);
- PoolVector<int>::Write w = array.write();
- f->get_buffer((uint8_t *)w.ptr(), len * 4);
+ int *w = array.ptrw();
+ f->get_buffer((uint8_t *)w, len * 4);
#ifdef BIG_ENDIAN_ENABLED
{
uint32_t *ptr = (uint32_t *)w.ptr();
@@ -425,17 +425,17 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
}
#endif
- w.release();
+
r_v = array;
} break;
case VARIANT_REAL_ARRAY: {
uint32_t len = f->get_32();
- PoolVector<real_t> array;
+ Vector<real_t> array;
array.resize(len);
- PoolVector<real_t>::Write w = array.write();
- f->get_buffer((uint8_t *)w.ptr(), len * sizeof(real_t));
+ real_t *w = array.ptrw();
+ f->get_buffer((uint8_t *)w, len * sizeof(real_t));
#ifdef BIG_ENDIAN_ENABLED
{
uint32_t *ptr = (uint32_t *)w.ptr();
@@ -447,18 +447,17 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
#endif
- w.release();
r_v = array;
} break;
case VARIANT_STRING_ARRAY: {
uint32_t len = f->get_32();
- PoolVector<String> array;
+ Vector<String> array;
array.resize(len);
- PoolVector<String>::Write w = array.write();
+ String *w = array.ptrw();
for (uint32_t i = 0; i < len; i++)
w[i] = get_unicode_string();
- w.release();
+
r_v = array;
} break;
@@ -466,11 +465,11 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
uint32_t len = f->get_32();
- PoolVector<Vector2> array;
+ Vector<Vector2> array;
array.resize(len);
- PoolVector<Vector2>::Write w = array.write();
+ Vector2 *w = array.ptrw();
if (sizeof(Vector2) == 8) {
- f->get_buffer((uint8_t *)w.ptr(), len * sizeof(real_t) * 2);
+ f->get_buffer((uint8_t *)w, len * sizeof(real_t) * 2);
#ifdef BIG_ENDIAN_ENABLED
{
uint32_t *ptr = (uint32_t *)w.ptr();
@@ -485,7 +484,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
} else {
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Vector2 size is NOT 8!");
}
- w.release();
+
r_v = array;
} break;
@@ -493,11 +492,11 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
uint32_t len = f->get_32();
- PoolVector<Vector3> array;
+ Vector<Vector3> array;
array.resize(len);
- PoolVector<Vector3>::Write w = array.write();
+ Vector3 *w = array.ptrw();
if (sizeof(Vector3) == 12) {
- f->get_buffer((uint8_t *)w.ptr(), len * sizeof(real_t) * 3);
+ f->get_buffer((uint8_t *)w, len * sizeof(real_t) * 3);
#ifdef BIG_ENDIAN_ENABLED
{
uint32_t *ptr = (uint32_t *)w.ptr();
@@ -512,7 +511,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
} else {
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Vector3 size is NOT 12!");
}
- w.release();
+
r_v = array;
} break;
@@ -520,11 +519,11 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
uint32_t len = f->get_32();
- PoolVector<Color> array;
+ Vector<Color> array;
array.resize(len);
- PoolVector<Color>::Write w = array.write();
+ Color *w = array.ptrw();
if (sizeof(Color) == 16) {
- f->get_buffer((uint8_t *)w.ptr(), len * sizeof(real_t) * 4);
+ f->get_buffer((uint8_t *)w, len * sizeof(real_t) * 4);
#ifdef BIG_ENDIAN_ENABLED
{
uint32_t *ptr = (uint32_t *)w.ptr();
@@ -539,7 +538,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
} else {
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Color size is NOT 16!");
}
- w.release();
+
r_v = array;
} break;
default: {
@@ -1473,59 +1472,59 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
}
} break;
- case Variant::POOL_BYTE_ARRAY: {
+ case Variant::PACKED_BYTE_ARRAY: {
f->store_32(VARIANT_RAW_ARRAY);
- PoolVector<uint8_t> arr = p_property;
+ Vector<uint8_t> arr = p_property;
int len = arr.size();
f->store_32(len);
- PoolVector<uint8_t>::Read r = arr.read();
- f->store_buffer(r.ptr(), len);
+ const uint8_t *r = arr.ptr();
+ f->store_buffer(r, len);
_pad_buffer(f, len);
} break;
- case Variant::POOL_INT_ARRAY: {
+ case Variant::PACKED_INT_ARRAY: {
f->store_32(VARIANT_INT_ARRAY);
- PoolVector<int> arr = p_property;
+ Vector<int> arr = p_property;
int len = arr.size();
f->store_32(len);
- PoolVector<int>::Read r = arr.read();
+ const int *r = arr.ptr();
for (int i = 0; i < len; i++)
f->store_32(r[i]);
} break;
- case Variant::POOL_REAL_ARRAY: {
+ case Variant::PACKED_REAL_ARRAY: {
f->store_32(VARIANT_REAL_ARRAY);
- PoolVector<real_t> arr = p_property;
+ Vector<real_t> arr = p_property;
int len = arr.size();
f->store_32(len);
- PoolVector<real_t>::Read r = arr.read();
+ const real_t *r = arr.ptr();
for (int i = 0; i < len; i++) {
f->store_real(r[i]);
}
} break;
- case Variant::POOL_STRING_ARRAY: {
+ case Variant::PACKED_STRING_ARRAY: {
f->store_32(VARIANT_STRING_ARRAY);
- PoolVector<String> arr = p_property;
+ Vector<String> arr = p_property;
int len = arr.size();
f->store_32(len);
- PoolVector<String>::Read r = arr.read();
+ const String *r = arr.ptr();
for (int i = 0; i < len; i++) {
save_unicode_string(f, r[i]);
}
} break;
- case Variant::POOL_VECTOR3_ARRAY: {
+ case Variant::PACKED_VECTOR3_ARRAY: {
f->store_32(VARIANT_VECTOR3_ARRAY);
- PoolVector<Vector3> arr = p_property;
+ Vector<Vector3> arr = p_property;
int len = arr.size();
f->store_32(len);
- PoolVector<Vector3>::Read r = arr.read();
+ const Vector3 *r = arr.ptr();
for (int i = 0; i < len; i++) {
f->store_real(r[i].x);
f->store_real(r[i].y);
@@ -1533,26 +1532,26 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
}
} break;
- case Variant::POOL_VECTOR2_ARRAY: {
+ case Variant::PACKED_VECTOR2_ARRAY: {
f->store_32(VARIANT_VECTOR2_ARRAY);
- PoolVector<Vector2> arr = p_property;
+ Vector<Vector2> arr = p_property;
int len = arr.size();
f->store_32(len);
- PoolVector<Vector2>::Read r = arr.read();
+ const Vector2 *r = arr.ptr();
for (int i = 0; i < len; i++) {
f->store_real(r[i].x);
f->store_real(r[i].y);
}
} break;
- case Variant::POOL_COLOR_ARRAY: {
+ case Variant::PACKED_COLOR_ARRAY: {
f->store_32(VARIANT_COLOR_ARRAY);
- PoolVector<Color> arr = p_property;
+ Vector<Color> arr = p_property;
int len = arr.size();
f->store_32(len);
- PoolVector<Color>::Read r = arr.read();
+ const Color *r = arr.ptr();
for (int i = 0; i < len; i++) {
f->store_real(r[i].r);
f->store_real(r[i].g);
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 6877f816e1..1d5d8f9280 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -157,10 +157,10 @@ bool ResourceFormatLoader::exists(const String &p_path) const {
void ResourceFormatLoader::get_recognized_extensions(List<String> *p_extensions) const {
if (get_script_instance() && get_script_instance()->has_method("get_recognized_extensions")) {
- PoolStringArray exts = get_script_instance()->call("get_recognized_extensions");
+ PackedStringArray exts = get_script_instance()->call("get_recognized_extensions");
{
- PoolStringArray::Read r = exts.read();
+ const String *r = exts.ptr();
for (int i = 0; i < exts.size(); ++i) {
p_extensions->push_back(r[i]);
}
@@ -212,10 +212,10 @@ RES ResourceFormatLoader::load(const String &p_path, const String &p_original_pa
void ResourceFormatLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
if (get_script_instance() && get_script_instance()->has_method("get_dependencies")) {
- PoolStringArray deps = get_script_instance()->call("get_dependencies", p_path, p_add_types);
+ PackedStringArray deps = get_script_instance()->call("get_dependencies", p_path, p_add_types);
{
- PoolStringArray::Read r = deps.read();
+ const String *r = deps.ptr();
for (int i = 0; i < deps.size(); ++i) {
p_dependencies->push_back(r[i]);
}
@@ -247,7 +247,7 @@ void ResourceFormatLoader::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), info);
}
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::POOL_STRING_ARRAY, "get_recognized_extensions"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::PACKED_STRING_ARRAY, "get_recognized_extensions"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles_type", PropertyInfo(Variant::STRING, "typename")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_resource_type", PropertyInfo(Variant::STRING, "path")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_dependencies", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "add_types")));
@@ -743,7 +743,7 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
if (translation_remaps.has(p_path)) {
// translation_remaps has the following format:
- // { "res://path.png": PoolStringArray( "res://path-ru.png:ru", "res://path-de.png:de" ) }
+ // { "res://path.png": PackedStringArray( "res://path-ru.png:ru", "res://path-de.png:de" ) }
// To find the path of the remapped resource, we extract the locale name after
// the last ':' to match the project locale.
@@ -905,10 +905,10 @@ void ResourceLoader::load_path_remaps() {
if (!ProjectSettings::get_singleton()->has_setting("path_remap/remapped_paths"))
return;
- PoolVector<String> remaps = ProjectSettings::get_singleton()->get("path_remap/remapped_paths");
+ Vector<String> remaps = ProjectSettings::get_singleton()->get("path_remap/remapped_paths");
int rc = remaps.size();
ERR_FAIL_COND(rc & 1); //must be even
- PoolVector<String>::Read r = remaps.read();
+ const String *r = remaps.ptr();
for (int i = 0; i < rc; i += 2) {
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 685d21107f..740aaf5cfa 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -61,10 +61,10 @@ bool ResourceFormatSaver::recognize(const RES &p_resource) const {
void ResourceFormatSaver::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
if (get_script_instance() && get_script_instance()->has_method("get_recognized_extensions")) {
- PoolStringArray exts = get_script_instance()->call("get_recognized_extensions", p_resource);
+ PackedStringArray exts = get_script_instance()->call("get_recognized_extensions", p_resource);
{
- PoolStringArray::Read r = exts.read();
+ const String *r = exts.ptr();
for (int i = 0; i < exts.size(); ++i) {
p_extensions->push_back(r[i]);
}
@@ -81,7 +81,7 @@ void ResourceFormatSaver::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "save", arg0, arg1, arg2));
}
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::POOL_STRING_ARRAY, "get_recognized_extensions", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::PACKED_STRING_ARRAY, "get_recognized_extensions", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "recognize", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
}
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index dee82de691..3c695c18fc 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -32,16 +32,16 @@
#include "core/io/marshalls.h"
-Error StreamPeer::_put_data(const PoolVector<uint8_t> &p_data) {
+Error StreamPeer::_put_data(const Vector<uint8_t> &p_data) {
int len = p_data.size();
if (len == 0)
return OK;
- PoolVector<uint8_t>::Read r = p_data.read();
+ const uint8_t *r = p_data.ptr();
return put_data(&r[0], len);
}
-Array StreamPeer::_put_partial_data(const PoolVector<uint8_t> &p_data) {
+Array StreamPeer::_put_partial_data(const Vector<uint8_t> &p_data) {
Array ret;
@@ -52,7 +52,7 @@ Array StreamPeer::_put_partial_data(const PoolVector<uint8_t> &p_data) {
return ret;
}
- PoolVector<uint8_t>::Read r = p_data.read();
+ const uint8_t *r = p_data.ptr();
int sent;
Error err = put_partial_data(&r[0], len, sent);
@@ -68,18 +68,18 @@ Array StreamPeer::_get_data(int p_bytes) {
Array ret;
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
data.resize(p_bytes);
if (data.size() != p_bytes) {
ret.push_back(ERR_OUT_OF_MEMORY);
- ret.push_back(PoolVector<uint8_t>());
+ ret.push_back(Vector<uint8_t>());
return ret;
}
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
Error err = get_data(&w[0], p_bytes);
- w.release();
+
ret.push_back(err);
ret.push_back(data);
return ret;
@@ -89,19 +89,18 @@ Array StreamPeer::_get_partial_data(int p_bytes) {
Array ret;
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
data.resize(p_bytes);
if (data.size() != p_bytes) {
ret.push_back(ERR_OUT_OF_MEMORY);
- ret.push_back(PoolVector<uint8_t>());
+ ret.push_back(Vector<uint8_t>());
return ret;
}
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
int received;
Error err = get_partial_data(&w[0], p_bytes, received);
- w.release();
if (err != OK) {
data.resize(0);
@@ -431,7 +430,7 @@ void StreamPeerBuffer::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear"), &StreamPeerBuffer::clear);
ClassDB::bind_method(D_METHOD("duplicate"), &StreamPeerBuffer::duplicate);
- ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data_array"), "set_data_array", "get_data_array");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data_array"), "set_data_array", "get_data_array");
}
Error StreamPeerBuffer::put_data(const uint8_t *p_data, int p_bytes) {
@@ -443,7 +442,7 @@ Error StreamPeerBuffer::put_data(const uint8_t *p_data, int p_bytes) {
data.resize(pointer + p_bytes);
}
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
copymem(&w[pointer], p_data, p_bytes);
pointer += p_bytes;
@@ -478,8 +477,8 @@ Error StreamPeerBuffer::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_
r_received = p_bytes;
}
- PoolVector<uint8_t>::Read r = data.read();
- copymem(p_buffer, r.ptr() + pointer, r_received);
+ const uint8_t *r = data.ptr();
+ copymem(p_buffer, r + pointer, r_received);
pointer += r_received;
// FIXME: return what? OK or ERR_*
@@ -513,13 +512,13 @@ void StreamPeerBuffer::resize(int p_size) {
data.resize(p_size);
}
-void StreamPeerBuffer::set_data_array(const PoolVector<uint8_t> &p_data) {
+void StreamPeerBuffer::set_data_array(const Vector<uint8_t> &p_data) {
data = p_data;
pointer = 0;
}
-PoolVector<uint8_t> StreamPeerBuffer::get_data_array() const {
+Vector<uint8_t> StreamPeerBuffer::get_data_array() const {
return data;
}
diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h
index d6ce7ddc16..9358a2c07c 100644
--- a/core/io/stream_peer.h
+++ b/core/io/stream_peer.h
@@ -41,8 +41,8 @@ protected:
static void _bind_methods();
//bind helpers
- Error _put_data(const PoolVector<uint8_t> &p_data);
- Array _put_partial_data(const PoolVector<uint8_t> &p_data);
+ Error _put_data(const Vector<uint8_t> &p_data);
+ Array _put_partial_data(const Vector<uint8_t> &p_data);
Array _get_data(int p_bytes);
Array _get_partial_data(int p_bytes);
@@ -96,7 +96,7 @@ class StreamPeerBuffer : public StreamPeer {
GDCLASS(StreamPeerBuffer, StreamPeer);
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
int pointer;
protected:
@@ -116,8 +116,8 @@ public:
int get_position() const;
void resize(int p_size);
- void set_data_array(const PoolVector<uint8_t> &p_data);
- PoolVector<uint8_t> get_data_array() const;
+ void set_data_array(const Vector<uint8_t> &p_data);
+ Vector<uint8_t> get_data_array() const;
void clear();
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 73f190a330..b26903e45a 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -235,13 +235,13 @@ Array AStar::get_points() {
return point_list;
}
-PoolVector<int> AStar::get_point_connections(int p_id) {
+Vector<int> AStar::get_point_connections(int p_id) {
Point *p;
bool p_exists = points.lookup(p_id, p);
- ERR_FAIL_COND_V(!p_exists, PoolVector<int>());
+ ERR_FAIL_COND_V(!p_exists, Vector<int>());
- PoolVector<int> point_list;
+ Vector<int> point_list;
for (OAHashMap<int, Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) {
point_list.push_back((*it.key));
@@ -431,18 +431,18 @@ float AStar::_compute_cost(int p_from_id, int p_to_id) {
return from_point->pos.distance_to(to_point->pos);
}
-PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
+Vector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
Point *a;
bool from_exists = points.lookup(p_from_id, a);
- ERR_FAIL_COND_V(!from_exists, PoolVector<Vector3>());
+ ERR_FAIL_COND_V(!from_exists, Vector<Vector3>());
Point *b;
bool to_exists = points.lookup(p_to_id, b);
- ERR_FAIL_COND_V(!to_exists, PoolVector<Vector3>());
+ ERR_FAIL_COND_V(!to_exists, Vector<Vector3>());
if (a == b) {
- PoolVector<Vector3> ret;
+ Vector<Vector3> ret;
ret.push_back(a->pos);
return ret;
}
@@ -451,7 +451,7 @@ PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
Point *end_point = b;
bool found_route = _solve(begin_point, end_point);
- if (!found_route) return PoolVector<Vector3>();
+ if (!found_route) return Vector<Vector3>();
Point *p = end_point;
int pc = 1; // Begin point
@@ -460,11 +460,11 @@ PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
p = p->prev_point;
}
- PoolVector<Vector3> path;
+ Vector<Vector3> path;
path.resize(pc);
{
- PoolVector<Vector3>::Write w = path.write();
+ Vector3 *w = path.ptrw();
Point *p2 = end_point;
int idx = pc - 1;
@@ -479,18 +479,18 @@ PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
return path;
}
-PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
+Vector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
Point *a;
bool from_exists = points.lookup(p_from_id, a);
- ERR_FAIL_COND_V(!from_exists, PoolVector<int>());
+ ERR_FAIL_COND_V(!from_exists, Vector<int>());
Point *b;
bool to_exists = points.lookup(p_to_id, b);
- ERR_FAIL_COND_V(!to_exists, PoolVector<int>());
+ ERR_FAIL_COND_V(!to_exists, Vector<int>());
if (a == b) {
- PoolVector<int> ret;
+ Vector<int> ret;
ret.push_back(a->id);
return ret;
}
@@ -499,7 +499,7 @@ PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
Point *end_point = b;
bool found_route = _solve(begin_point, end_point);
- if (!found_route) return PoolVector<int>();
+ if (!found_route) return Vector<int>();
Point *p = end_point;
int pc = 1; // Begin point
@@ -508,11 +508,11 @@ PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
p = p->prev_point;
}
- PoolVector<int> path;
+ Vector<int> path;
path.resize(pc);
{
- PoolVector<int>::Write w = path.write();
+ int *w = path.ptrw();
p = end_point;
int idx = pc - 1;
@@ -624,7 +624,7 @@ bool AStar2D::has_point(int p_id) const {
return astar.has_point(p_id);
}
-PoolVector<int> AStar2D::get_point_connections(int p_id) {
+Vector<int> AStar2D::get_point_connections(int p_id) {
return astar.get_point_connections(p_id);
}
@@ -677,15 +677,15 @@ Vector2 AStar2D::get_closest_position_in_segment(const Vector2 &p_point) const {
return Vector2(p.x, p.y);
}
-PoolVector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) {
+Vector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) {
- PoolVector3Array pv = astar.get_point_path(p_from_id, p_to_id);
+ PackedVector3Array pv = astar.get_point_path(p_from_id, p_to_id);
int size = pv.size();
- PoolVector2Array path;
+ PackedVector2Array path;
path.resize(size);
{
- PoolVector<Vector3>::Read r = pv.read();
- PoolVector<Vector2>::Write w = path.write();
+ const Vector3 *r = pv.ptr();
+ Vector2 *w = path.ptrw();
for (int i = 0; i < size; i++) {
Vector3 p = r[i];
w[i] = Vector2(p.x, p.y);
@@ -694,7 +694,7 @@ PoolVector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) {
return path;
}
-PoolVector<int> AStar2D::get_id_path(int p_from_id, int p_to_id) {
+Vector<int> AStar2D::get_id_path(int p_from_id, int p_to_id) {
return astar.get_id_path(p_from_id, p_to_id);
}
diff --git a/core/math/a_star.h b/core/math/a_star.h
index 0b10976932..bfcf0c09d3 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -137,7 +137,7 @@ public:
void set_point_weight_scale(int p_id, real_t p_weight_scale);
void remove_point(int p_id);
bool has_point(int p_id) const;
- PoolVector<int> get_point_connections(int p_id);
+ Vector<int> get_point_connections(int p_id);
Array get_points();
void set_point_disabled(int p_id, bool p_disabled = true);
@@ -155,8 +155,8 @@ public:
int get_closest_point(const Vector3 &p_point, bool p_include_disabled = false) const;
Vector3 get_closest_position_in_segment(const Vector3 &p_point) const;
- PoolVector<Vector3> get_point_path(int p_from_id, int p_to_id);
- PoolVector<int> get_id_path(int p_from_id, int p_to_id);
+ Vector<Vector3> get_point_path(int p_from_id, int p_to_id);
+ Vector<int> get_id_path(int p_from_id, int p_to_id);
AStar();
~AStar();
@@ -179,7 +179,7 @@ public:
void set_point_weight_scale(int p_id, real_t p_weight_scale);
void remove_point(int p_id);
bool has_point(int p_id) const;
- PoolVector<int> get_point_connections(int p_id);
+ Vector<int> get_point_connections(int p_id);
Array get_points();
void set_point_disabled(int p_id, bool p_disabled = true);
@@ -197,8 +197,8 @@ public:
int get_closest_point(const Vector2 &p_point, bool p_include_disabled = false) const;
Vector2 get_closest_position_in_segment(const Vector2 &p_point) const;
- PoolVector<Vector2> get_point_path(int p_from_id, int p_to_id);
- PoolVector<int> get_id_path(int p_from_id, int p_to_id);
+ Vector<Vector2> get_point_path(int p_from_id, int p_to_id);
+ Vector<int> get_id_path(int p_from_id, int p_to_id);
AStar2D();
~AStar2D();
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
deleted file mode 100644
index 7ad907db97..0000000000
--- a/core/math/bsp_tree.cpp
+++ /dev/null
@@ -1,581 +0,0 @@
-/*************************************************************************/
-/* bsp_tree.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "bsp_tree.h"
-
-#include "core/error_macros.h"
-#include "core/print_string.h"
-
-void BSP_Tree::from_aabb(const AABB &p_aabb) {
-
- planes.clear();
-
- for (int i = 0; i < 3; i++) {
-
- Vector3 n;
- n[i] = 1;
- planes.push_back(Plane(n, p_aabb.position[i] + p_aabb.size[i]));
- planes.push_back(Plane(-n, -p_aabb.position[i]));
- }
-
- nodes.clear();
-
- for (int i = 0; i < 6; i++) {
-
- Node n;
- n.plane = i;
- n.under = (i == 0) ? UNDER_LEAF : i - 1;
- n.over = OVER_LEAF;
- nodes.push_back(n);
- }
-
- aabb = p_aabb;
- error_radius = 0;
-}
-
-Vector<BSP_Tree::Node> BSP_Tree::get_nodes() const {
-
- return nodes;
-}
-Vector<Plane> BSP_Tree::get_planes() const {
-
- return planes;
-}
-
-AABB BSP_Tree::get_aabb() const {
-
- return aabb;
-}
-
-int BSP_Tree::_get_points_inside(int p_node, const Vector3 *p_points, int *p_indices, const Vector3 &p_center, const Vector3 &p_half_extents, int p_indices_count) const {
-
- const Node *node = &nodes[p_node];
- const Plane &p = planes[node->plane];
-
- Vector3 min(
- (p.normal.x > 0) ? -p_half_extents.x : p_half_extents.x,
- (p.normal.y > 0) ? -p_half_extents.y : p_half_extents.y,
- (p.normal.z > 0) ? -p_half_extents.z : p_half_extents.z);
- Vector3 max = -min;
- max += p_center;
- min += p_center;
-
- real_t dist_min = p.distance_to(min);
- real_t dist_max = p.distance_to(max);
-
- if ((dist_min * dist_max) < CMP_EPSILON) { //intersection, test point by point
-
- int under_count = 0;
-
- //sort points, so the are under first, over last
- for (int i = 0; i < p_indices_count; i++) {
-
- int index = p_indices[i];
-
- if (p.is_point_over(p_points[index])) {
-
- // kind of slow (but cache friendly), should try something else,
- // but this is a corner case most of the time
-
- for (int j = index; j < p_indices_count - 1; j++)
- p_indices[j] = p_indices[j + 1];
-
- p_indices[p_indices_count - 1] = index;
-
- } else {
- under_count++;
- }
- }
-
- int total = 0;
-
- if (under_count > 0) {
- if (node->under == UNDER_LEAF) {
- total += under_count;
- } else {
- total += _get_points_inside(node->under, p_points, p_indices, p_center, p_half_extents, under_count);
- }
- }
-
- if (under_count != p_indices_count) {
- if (node->over == OVER_LEAF) {
- //total+=0 //if they are over an OVER_LEAF, they are outside the model
- } else {
- total += _get_points_inside(node->over, p_points, &p_indices[under_count], p_center, p_half_extents, p_indices_count - under_count);
- }
- }
-
- return total;
-
- } else if (dist_min > 0) { //all points over plane
-
- if (node->over == OVER_LEAF) {
-
- return 0; // all these points are not visible
- }
-
- return _get_points_inside(node->over, p_points, p_indices, p_center, p_half_extents, p_indices_count);
- } else { //all points behind plane
-
- if (node->under == UNDER_LEAF) {
-
- return p_indices_count; // all these points are visible
- }
- return _get_points_inside(node->under, p_points, p_indices, p_center, p_half_extents, p_indices_count);
- }
-}
-
-int BSP_Tree::get_points_inside(const Vector3 *p_points, int p_point_count) const {
-
- if (nodes.size() == 0)
- return 0;
-
-#if 1
- //this version is easier to debug, and and MUCH faster in real world cases
-
- int pass_count = 0;
- const Node *nodesptr = &nodes[0];
- const Plane *planesptr = &planes[0];
- int node_count = nodes.size();
-
- if (node_count == 0) // no nodes!
- return 0;
-
- for (int i = 0; i < p_point_count; i++) {
-
- const Vector3 &point = p_points[i];
- if (!aabb.has_point(point)) {
- continue;
- }
-
- int idx = node_count - 1;
-
- bool pass = false;
-
- while (true) {
-
- if (idx == OVER_LEAF) {
- pass = false;
- break;
- } else if (idx == UNDER_LEAF) {
- pass = true;
- break;
- }
-
-#ifdef DEBUG_ENABLED
- int plane_count = planes.size();
- uint16_t plane = nodesptr[idx].plane;
- ERR_FAIL_UNSIGNED_INDEX_V(plane, plane_count, 0);
-#endif
-
- idx = planesptr[nodesptr[idx].plane].is_point_over(point) ? nodes[idx].over : nodes[idx].under;
-
-#ifdef DEBUG_ENABLED
-
- ERR_FAIL_COND_V(idx < MAX_NODES && idx >= node_count, 0);
-#endif
- }
-
- if (pass)
- pass_count++;
- }
-
- return pass_count;
-
-#else
- //this version scales better but it's slower for real world cases
-
- int *indices = (int *)alloca(p_point_count * sizeof(int));
- AABB bounds;
-
- for (int i = 0; i < p_point_count; i++) {
-
- indices[i] = i;
- if (i == 0)
- bounds.pos = p_points[i];
- else
- bounds.expand_to(p_points[i]);
- }
-
- Vector3 half_extents = bounds.size / 2.0;
- return _get_points_inside(nodes.size() + 1, p_points, indices, bounds.pos + half_extents, half_extents, p_point_count);
-#endif
-}
-
-bool BSP_Tree::point_is_inside(const Vector3 &p_point) const {
-
- if (!aabb.has_point(p_point)) {
- return false;
- }
-
- int node_count = nodes.size();
-
- if (node_count == 0) // no nodes!
- return false;
-
- const Node *nodesptr = &nodes[0];
- const Plane *planesptr = &planes[0];
-
- int idx = node_count - 1;
-
- while (true) {
-
- if (idx == OVER_LEAF) {
- return false;
- }
- if (idx == UNDER_LEAF) {
-
- return true;
- }
-
-#ifdef DEBUG_ENABLED
- int plane_count = planes.size();
- uint16_t plane = nodesptr[idx].plane;
- ERR_FAIL_UNSIGNED_INDEX_V(plane, plane_count, false);
-#endif
-
- bool over = planesptr[nodesptr[idx].plane].is_point_over(p_point);
-
- idx = over ? nodes[idx].over : nodes[idx].under;
-
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V(idx < MAX_NODES && idx >= node_count, false);
-#endif
- }
-}
-
-static int _bsp_find_best_half_plane(const Face3 *p_faces, const Vector<int> &p_indices, real_t p_tolerance) {
-
- int ic = p_indices.size();
- const int *indices = p_indices.ptr();
-
- int best_plane = -1;
- real_t best_plane_cost = 1e20;
-
- // Loop to find the polygon that best divides the set.
-
- for (int i = 0; i < ic; i++) {
-
- const Face3 &f = p_faces[indices[i]];
- Plane p = f.get_plane();
-
- int num_over = 0, num_under = 0, num_spanning = 0;
-
- for (int j = 0; j < ic; j++) {
-
- if (i == j)
- continue;
-
- const Face3 &g = p_faces[indices[j]];
- int over = 0, under = 0;
-
- for (int k = 0; k < 3; k++) {
-
- real_t d = p.distance_to(g.vertex[j]);
-
- if (Math::abs(d) > p_tolerance) {
-
- if (d > 0)
- over++;
- else
- under++;
- }
- }
-
- if (over && under)
- num_spanning++;
- else if (over)
- num_over++;
- else
- num_under++;
- }
-
- //real_t split_cost = num_spanning / (real_t) face_count;
- real_t relation = Math::abs(num_over - num_under) / (real_t)ic;
-
- // being honest, i never found a way to add split cost to the mix in a meaninguful way
- // in this engine, also, will likely be ignored anyway
-
- real_t plane_cost = /*split_cost +*/ relation;
-
- //printf("plane %i, %i over, %i under, %i spanning, cost is %g\n",i,num_over,num_under,num_spanning,plane_cost);
- if (plane_cost < best_plane_cost) {
-
- best_plane = i;
- best_plane_cost = plane_cost;
- }
- }
-
- return best_plane;
-}
-
-static int _bsp_create_node(const Face3 *p_faces, const Vector<int> &p_indices, Vector<Plane> &p_planes, Vector<BSP_Tree::Node> &p_nodes, real_t p_tolerance) {
-
- ERR_FAIL_COND_V(p_nodes.size() == BSP_Tree::MAX_NODES, -1);
-
- // should not reach here
- ERR_FAIL_COND_V(p_indices.size() == 0, -1);
-
- int ic = p_indices.size();
- const int *indices = p_indices.ptr();
-
- int divisor_idx = _bsp_find_best_half_plane(p_faces, p_indices, p_tolerance);
-
- // returned error
- ERR_FAIL_COND_V(divisor_idx < 0, -1);
-
- Vector<int> faces_over;
- Vector<int> faces_under;
-
- Plane divisor_plane = p_faces[indices[divisor_idx]].get_plane();
-
- for (int i = 0; i < ic; i++) {
-
- if (i == divisor_idx)
- continue;
-
- const Face3 &f = p_faces[indices[i]];
-
- /*
- if (f.get_plane().is_equal_approx(divisor_plane))
- continue;
- */
-
- int over_count = 0;
- int under_count = 0;
-
- for (int j = 0; j < 3; j++) {
-
- real_t d = divisor_plane.distance_to(f.vertex[j]);
- if (Math::abs(d) > p_tolerance) {
-
- if (d > 0)
- over_count++;
- else
- under_count++;
- }
- }
-
- if (over_count)
- faces_over.push_back(indices[i]);
- if (under_count)
- faces_under.push_back(indices[i]);
- }
-
- uint16_t over_idx = BSP_Tree::OVER_LEAF, under_idx = BSP_Tree::UNDER_LEAF;
-
- if (faces_over.size() > 0) { //have facess above?
-
- int idx = _bsp_create_node(p_faces, faces_over, p_planes, p_nodes, p_tolerance);
- if (idx >= 0)
- over_idx = idx;
- }
-
- if (faces_under.size() > 0) { //have facess above?
-
- int idx = _bsp_create_node(p_faces, faces_under, p_planes, p_nodes, p_tolerance);
- if (idx >= 0)
- under_idx = idx;
- }
-
- /* Create the node */
-
- // find existing divisor plane
- int divisor_plane_idx = -1;
-
- for (int i = 0; i < p_planes.size(); i++) {
-
- if (p_planes[i].is_equal_approx(divisor_plane)) {
- divisor_plane_idx = i;
- break;
- }
- }
-
- if (divisor_plane_idx == -1) {
-
- ERR_FAIL_COND_V(p_planes.size() == BSP_Tree::MAX_PLANES, -1);
- divisor_plane_idx = p_planes.size();
- p_planes.push_back(divisor_plane);
- }
-
- BSP_Tree::Node node;
- node.plane = divisor_plane_idx;
- node.under = under_idx;
- node.over = over_idx;
-
- p_nodes.push_back(node);
-
- return p_nodes.size() - 1;
-}
-
-BSP_Tree::operator Variant() const {
-
- Dictionary d;
- d["error_radius"] = error_radius;
-
- Vector<real_t> plane_values;
- plane_values.resize(planes.size() * 4);
-
- for (int i = 0; i < planes.size(); i++) {
-
- plane_values.write[i * 4 + 0] = planes[i].normal.x;
- plane_values.write[i * 4 + 1] = planes[i].normal.y;
- plane_values.write[i * 4 + 2] = planes[i].normal.z;
- plane_values.write[i * 4 + 3] = planes[i].d;
- }
-
- d["planes"] = plane_values;
-
- PoolVector<int> dst_nodes;
- dst_nodes.resize(nodes.size() * 3);
-
- for (int i = 0; i < nodes.size(); i++) {
-
- dst_nodes.set(i * 3 + 0, nodes[i].over);
- dst_nodes.set(i * 3 + 1, nodes[i].under);
- dst_nodes.set(i * 3 + 2, nodes[i].plane);
- }
-
- d["nodes"] = dst_nodes;
- d["aabb"] = aabb;
-
- return Variant(d);
-}
-
-BSP_Tree::BSP_Tree() {
-}
-
-BSP_Tree::BSP_Tree(const Variant &p_variant) {
-
- Dictionary d = p_variant;
- ERR_FAIL_COND(!d.has("nodes"));
- ERR_FAIL_COND(!d.has("planes"));
- ERR_FAIL_COND(!d.has("aabb"));
- ERR_FAIL_COND(!d.has("error_radius"));
-
- PoolVector<int> src_nodes = d["nodes"];
- ERR_FAIL_COND(src_nodes.size() % 3);
-
- if (d["planes"].get_type() == Variant::POOL_REAL_ARRAY) {
-
- PoolVector<real_t> src_planes = d["planes"];
- int plane_count = src_planes.size();
- ERR_FAIL_COND(plane_count % 4);
- planes.resize(plane_count / 4);
-
- if (plane_count) {
- PoolVector<real_t>::Read r = src_planes.read();
- for (int i = 0; i < plane_count / 4; i++) {
-
- planes.write[i].normal.x = r[i * 4 + 0];
- planes.write[i].normal.y = r[i * 4 + 1];
- planes.write[i].normal.z = r[i * 4 + 2];
- planes.write[i].d = r[i * 4 + 3];
- }
- }
-
- } else {
-
- planes = d["planes"];
- }
-
- error_radius = d["error"];
- aabb = d["aabb"];
-
- //int node_count = src_nodes.size();
- nodes.resize(src_nodes.size() / 3);
-
- PoolVector<int>::Read r = src_nodes.read();
-
- for (int i = 0; i < nodes.size(); i++) {
-
- nodes.write[i].over = r[i * 3 + 0];
- nodes.write[i].under = r[i * 3 + 1];
- nodes.write[i].plane = r[i * 3 + 2];
- }
-}
-
-BSP_Tree::BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius) {
-
- // compute aabb
-
- int face_count = p_faces.size();
- PoolVector<Face3>::Read faces_r = p_faces.read();
- const Face3 *facesptr = faces_r.ptr();
-
- bool first = true;
-
- Vector<int> indices;
-
- for (int i = 0; i < face_count; i++) {
-
- const Face3 &f = facesptr[i];
-
- if (f.is_degenerate())
- continue;
-
- for (int j = 0; j < 3; j++) {
-
- if (first) {
-
- aabb.position = f.vertex[0];
- first = false;
- } else {
-
- aabb.expand_to(f.vertex[j]);
- }
- }
-
- indices.push_back(i);
- }
-
- ERR_FAIL_COND(aabb.has_no_area());
-
- int top = _bsp_create_node(faces_r.ptr(), indices, planes, nodes, aabb.get_longest_axis_size() * 0.0001);
-
- if (top < 0) {
-
- nodes.clear();
- planes.clear();
- ERR_FAIL_COND(top < 0);
- }
-
- error_radius = p_error_radius;
-}
-
-BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB &p_aabb, real_t p_error_radius) :
- nodes(p_nodes),
- planes(p_planes),
- aabb(p_aabb),
- error_radius(p_error_radius) {
-}
-
-BSP_Tree::~BSP_Tree() {
-}
diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h
deleted file mode 100644
index 1c8ea380ff..0000000000
--- a/core/math/bsp_tree.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*************************************************************************/
-/* bsp_tree.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef BSP_TREE_H
-#define BSP_TREE_H
-
-#include "core/math/aabb.h"
-#include "core/math/face3.h"
-#include "core/math/plane.h"
-#include "core/method_ptrcall.h"
-#include "core/pool_vector.h"
-#include "core/variant.h"
-#include "core/vector.h"
-
-class BSP_Tree {
-public:
- enum {
-
- UNDER_LEAF = 0xFFFF,
- OVER_LEAF = 0xFFFE,
- MAX_NODES = 0xFFFE,
- MAX_PLANES = (1 << 16)
- };
-
- struct Node {
-
- uint16_t plane;
- uint16_t under;
- uint16_t over;
- };
-
-private:
- // thanks to the properties of Vector,
- // this class can be assigned and passed around between threads
- // with no cost.
-
- Vector<Node> nodes;
- Vector<Plane> planes;
- AABB aabb;
- real_t error_radius;
-
- int _get_points_inside(int p_node, const Vector3 *p_points, int *p_indices, const Vector3 &p_center, const Vector3 &p_half_extents, int p_indices_count) const;
-
- template <class T>
- bool _test_convex(const Node *p_nodes, const Plane *p_planes, int p_current, const T &p_convex) const;
-
-public:
- bool is_empty() const { return nodes.size() == 0; }
- Vector<Node> get_nodes() const;
- Vector<Plane> get_planes() const;
- AABB get_aabb() const;
-
- bool point_is_inside(const Vector3 &p_point) const;
- int get_points_inside(const Vector3 *p_points, int p_point_count) const;
- template <class T>
- bool convex_is_inside(const T &p_convex) const;
-
- operator Variant() const;
-
- void from_aabb(const AABB &p_aabb);
-
- BSP_Tree();
- BSP_Tree(const Variant &p_variant);
- BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius = 0);
- BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB &p_aabb, real_t p_error_radius = 0);
- ~BSP_Tree();
-};
-
-template <class T>
-bool BSP_Tree::_test_convex(const Node *p_nodes, const Plane *p_planes, int p_current, const T &p_convex) const {
-
- if (p_current == UNDER_LEAF)
- return true;
- else if (p_current == OVER_LEAF)
- return false;
-
- bool collided = false;
- const Node &n = p_nodes[p_current];
-
- const Plane &p = p_planes[n.plane];
-
- real_t min, max;
- p_convex.project_range(p.normal, min, max);
-
- bool go_under = min < p.d;
- bool go_over = max >= p.d;
-
- if (go_under && _test_convex(p_nodes, p_planes, n.under, p_convex))
- collided = true;
- if (go_over && _test_convex(p_nodes, p_planes, n.over, p_convex))
- collided = true;
-
- return collided;
-}
-
-template <class T>
-bool BSP_Tree::convex_is_inside(const T &p_convex) const {
-
- int node_count = nodes.size();
- if (node_count == 0)
- return false;
- const Node *nodes = &this->nodes[0];
- const Plane *planes = &this->planes[0];
-
- return _test_convex(nodes, planes, node_count - 1, p_convex);
-}
-
-#ifdef PTRCALL_ENABLED
-
-template <>
-struct PtrToArg<BSP_Tree> {
- _FORCE_INLINE_ static BSP_Tree convert(const void *p_ptr) {
- BSP_Tree s(Variant(*reinterpret_cast<const Dictionary *>(p_ptr)));
- return s;
- }
- _FORCE_INLINE_ static void encode(BSP_Tree p_val, void *p_ptr) {
- Dictionary *d = reinterpret_cast<Dictionary *>(p_ptr);
- *d = Variant(p_val);
- }
-};
-
-template <>
-struct PtrToArg<const BSP_Tree &> {
- _FORCE_INLINE_ static BSP_Tree convert(const void *p_ptr) {
- BSP_Tree s(Variant(*reinterpret_cast<const Dictionary *>(p_ptr)));
- return s;
- }
-};
-
-#endif
-
-#endif
diff --git a/core/math/expression.cpp b/core/math/expression.cpp
index 2fda7a27d5..c7229ef688 100644
--- a/core/math/expression.cpp
+++ b/core/math/expression.cpp
@@ -757,7 +757,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
} break;
case VAR_TO_BYTES: {
- PoolByteArray barr;
+ PackedByteArray barr;
bool full_objects = *p_inputs[1];
int len;
Error err = encode_variant(*p_inputs[0], NULL, len, full_objects);
@@ -771,32 +771,32 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
barr.resize(len);
{
- PoolByteArray::Write w = barr.write();
- encode_variant(*p_inputs[0], w.ptr(), len, full_objects);
+ uint8_t *w = barr.ptrw();
+ encode_variant(*p_inputs[0], w, len, full_objects);
}
*r_return = barr;
} break;
case BYTES_TO_VAR: {
- if (p_inputs[0]->get_type() != Variant::POOL_BYTE_ARRAY) {
+ if (p_inputs[0]->get_type() != Variant::PACKED_BYTE_ARRAY) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::POOL_BYTE_ARRAY;
+ r_error.expected = Variant::PACKED_BYTE_ARRAY;
return;
}
- PoolByteArray varr = *p_inputs[0];
+ PackedByteArray varr = *p_inputs[0];
bool allow_objects = *p_inputs[1];
Variant ret;
{
- PoolByteArray::Read r = varr.read();
- Error err = decode_variant(ret, r.ptr(), varr.size(), NULL, allow_objects);
+ const uint8_t *r = varr.ptr();
+ Error err = decode_variant(ret, r, varr.size(), NULL, allow_objects);
if (err != OK) {
r_error_str = RTR("Not enough bytes for decoding bytes, or invalid format.");
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::POOL_BYTE_ARRAY;
+ r_error.expected = Variant::PACKED_BYTE_ARRAY;
return;
}
}
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index 7eb48290a8..69c7abfd30 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -214,23 +214,19 @@ static bool _group_face(_FaceClassify *p_faces, int len, int p_index, int p_grou
return true;
}
-PoolVector<PoolVector<Face3> > Geometry::separate_objects(PoolVector<Face3> p_array) {
+Vector<Vector<Face3> > Geometry::separate_objects(Vector<Face3> p_array) {
- PoolVector<PoolVector<Face3> > objects;
+ Vector<Vector<Face3> > objects;
int len = p_array.size();
- PoolVector<Face3>::Read r = p_array.read();
+ const Face3 *arrayptr = p_array.ptr();
- const Face3 *arrayptr = r.ptr();
-
- PoolVector<_FaceClassify> fc;
+ Vector<_FaceClassify> fc;
fc.resize(len);
- PoolVector<_FaceClassify>::Write fcw = fc.write();
-
- _FaceClassify *_fcptr = fcw.ptr();
+ _FaceClassify *_fcptr = fc.ptrw();
for (int i = 0; i < len; i++) {
@@ -239,7 +235,7 @@ PoolVector<PoolVector<Face3> > Geometry::separate_objects(PoolVector<Face3> p_ar
bool error = _connect_faces(_fcptr, len, -1);
- ERR_FAIL_COND_V_MSG(error, PoolVector<PoolVector<Face3> >(), "Invalid geometry.");
+ ERR_FAIL_COND_V_MSG(error, Vector<Vector<Face3> >(), "Invalid geometry.");
// Group connected faces in separate objects.
@@ -263,8 +259,7 @@ PoolVector<PoolVector<Face3> > Geometry::separate_objects(PoolVector<Face3> p_ar
if (group >= 0) {
objects.resize(group);
- PoolVector<PoolVector<Face3> >::Write obw = objects.write();
- PoolVector<Face3> *group_faces = obw.ptr();
+ Vector<Face3> *group_faces = objects.ptrw();
for (int i = 0; i < len; i++) {
if (!_fcptr[i].valid)
@@ -470,7 +465,7 @@ static inline void _mark_outside(uint8_t ***p_cell_status, int x, int y, int z,
}
}
-static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z, PoolVector<Face3> &p_faces) {
+static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z, Vector<Face3> &p_faces) {
ERR_FAIL_INDEX(x, len_x);
ERR_FAIL_INDEX(y, len_y);
@@ -530,14 +525,13 @@ static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, i
}
}
-PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_error) {
+Vector<Face3> Geometry::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
#define _MIN_SIZE 1.0
#define _MAX_LENGTH 20
int face_count = p_array.size();
- PoolVector<Face3>::Read facesr = p_array.read();
- const Face3 *faces = facesr.ptr();
+ const Face3 *faces = p_array.ptr();
AABB global_aabb;
@@ -638,7 +632,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
// Build faces for the inside-outside cell divisors.
- PoolVector<Face3> wrapped_faces;
+ Vector<Face3> wrapped_faces;
for (int i = 0; i < div_x; i++) {
@@ -654,8 +648,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
// Transform face vertices to global coords.
int wrapped_faces_count = wrapped_faces.size();
- PoolVector<Face3>::Write wrapped_facesw = wrapped_faces.write();
- Face3 *wrapped_faces_ptr = wrapped_facesw.ptr();
+ Face3 *wrapped_faces_ptr = wrapped_faces.ptrw();
for (int i = 0; i < wrapped_faces_count; i++) {
@@ -720,7 +713,7 @@ Vector<Vector<Vector2> > Geometry::decompose_polygon_in_convex(Vector<Point2> po
return decomp;
}
-Geometry::MeshData Geometry::build_convex_mesh(const PoolVector<Plane> &p_planes) {
+Geometry::MeshData Geometry::build_convex_mesh(const Vector<Plane> &p_planes) {
MeshData mesh;
@@ -859,9 +852,9 @@ Geometry::MeshData Geometry::build_convex_mesh(const PoolVector<Plane> &p_planes
return mesh;
}
-PoolVector<Plane> Geometry::build_box_planes(const Vector3 &p_extents) {
+Vector<Plane> Geometry::build_box_planes(const Vector3 &p_extents) {
- PoolVector<Plane> planes;
+ Vector<Plane> planes;
planes.push_back(Plane(Vector3(1, 0, 0), p_extents.x));
planes.push_back(Plane(Vector3(-1, 0, 0), p_extents.x));
@@ -873,9 +866,9 @@ PoolVector<Plane> Geometry::build_box_planes(const Vector3 &p_extents) {
return planes;
}
-PoolVector<Plane> Geometry::build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis) {
+Vector<Plane> Geometry::build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis) {
- PoolVector<Plane> planes;
+ Vector<Plane> planes;
for (int i = 0; i < p_sides; i++) {
@@ -895,9 +888,9 @@ PoolVector<Plane> Geometry::build_cylinder_planes(real_t p_radius, real_t p_heig
return planes;
}
-PoolVector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats, int p_lons, Vector3::Axis p_axis) {
+Vector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats, int p_lons, Vector3::Axis p_axis) {
- PoolVector<Plane> planes;
+ Vector<Plane> planes;
Vector3 axis;
axis[p_axis] = 1.0;
@@ -928,9 +921,9 @@ PoolVector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats, int
return planes;
}
-PoolVector<Plane> Geometry::build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
+Vector<Plane> Geometry::build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
- PoolVector<Plane> planes;
+ Vector<Plane> planes;
Vector3 axis;
axis[p_axis] = 1.0;
diff --git a/core/math/geometry.h b/core/math/geometry.h
index b9193242bc..a94d00bf77 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -37,7 +37,7 @@
#include "core/math/triangulate.h"
#include "core/math/vector3.h"
#include "core/object.h"
-#include "core/pool_vector.h"
+
#include "core/print_string.h"
#include "core/vector.h"
@@ -899,10 +899,10 @@ public:
return (intersections & 1);
}
- static PoolVector<PoolVector<Face3> > separate_objects(PoolVector<Face3> p_array);
+ static Vector<Vector<Face3> > separate_objects(Vector<Face3> p_array);
// Create a "wrap" that encloses the given geometry.
- static PoolVector<Face3> wrap_geometry(PoolVector<Face3> p_array, real_t *p_error = NULL);
+ static Vector<Face3> wrap_geometry(Vector<Face3> p_array, real_t *p_error = NULL);
struct MeshData {
@@ -1006,11 +1006,11 @@ public:
}
static Vector<Vector<Vector2> > decompose_polygon_in_convex(Vector<Point2> polygon);
- static MeshData build_convex_mesh(const PoolVector<Plane> &p_planes);
- static PoolVector<Plane> build_sphere_planes(real_t p_radius, int p_lats, int p_lons, Vector3::Axis p_axis = Vector3::AXIS_Z);
- static PoolVector<Plane> build_box_planes(const Vector3 &p_extents);
- static PoolVector<Plane> build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
- static PoolVector<Plane> build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
+ static MeshData build_convex_mesh(const Vector<Plane> &p_planes);
+ static Vector<Plane> build_sphere_planes(real_t p_radius, int p_lats, int p_lons, Vector3::Axis p_axis = Vector3::AXIS_Z);
+ static Vector<Plane> build_box_planes(const Vector3 &p_extents);
+ static Vector<Plane> build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
+ static Vector<Plane> build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
static void make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size);
diff --git a/core/math/transform.h b/core/math/transform.h
index ad397d9c09..c6e3be4c70 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -34,7 +34,6 @@
#include "core/math/aabb.h"
#include "core/math/basis.h"
#include "core/math/plane.h"
-#include "core/pool_vector.h"
class Transform {
public:
@@ -84,8 +83,8 @@ public:
_FORCE_INLINE_ AABB xform(const AABB &p_aabb) const;
_FORCE_INLINE_ AABB xform_inv(const AABB &p_aabb) const;
- _FORCE_INLINE_ PoolVector<Vector3> xform(const PoolVector<Vector3> &p_array) const;
- _FORCE_INLINE_ PoolVector<Vector3> xform_inv(const PoolVector<Vector3> &p_array) const;
+ _FORCE_INLINE_ Vector<Vector3> xform(const Vector<Vector3> &p_array) const;
+ _FORCE_INLINE_ Vector<Vector3> xform_inv(const Vector<Vector3> &p_array) const;
void operator*=(const Transform &p_transform);
Transform operator*(const Transform &p_transform) const;
@@ -210,13 +209,13 @@ _FORCE_INLINE_ AABB Transform::xform_inv(const AABB &p_aabb) const {
return ret;
}
-PoolVector<Vector3> Transform::xform(const PoolVector<Vector3> &p_array) const {
+Vector<Vector3> Transform::xform(const Vector<Vector3> &p_array) const {
- PoolVector<Vector3> array;
+ Vector<Vector3> array;
array.resize(p_array.size());
- PoolVector<Vector3>::Read r = p_array.read();
- PoolVector<Vector3>::Write w = array.write();
+ const Vector3 *r = p_array.ptr();
+ Vector3 *w = array.ptrw();
for (int i = 0; i < p_array.size(); ++i) {
w[i] = xform(r[i]);
@@ -224,13 +223,13 @@ PoolVector<Vector3> Transform::xform(const PoolVector<Vector3> &p_array) const {
return array;
}
-PoolVector<Vector3> Transform::xform_inv(const PoolVector<Vector3> &p_array) const {
+Vector<Vector3> Transform::xform_inv(const Vector<Vector3> &p_array) const {
- PoolVector<Vector3> array;
+ Vector<Vector3> array;
array.resize(p_array.size());
- PoolVector<Vector3>::Read r = p_array.read();
- PoolVector<Vector3>::Write w = array.write();
+ const Vector3 *r = p_array.ptr();
+ Vector3 *w = array.ptrw();
for (int i = 0; i < p_array.size(); ++i) {
w[i] = xform_inv(r[i]);
diff --git a/core/math/transform_2d.h b/core/math/transform_2d.h
index 367f697ccf..fa43762aa4 100644
--- a/core/math/transform_2d.h
+++ b/core/math/transform_2d.h
@@ -32,7 +32,6 @@
#define TRANSFORM_2D_H
#include "core/math/rect2.h" // also includes vector2, math_funcs, and ustring
-#include "core/pool_vector.h"
struct Transform2D {
// Warning #1: basis of Transform2D is stored differently from Basis. In terms of elements array, the basis matrix looks like "on paper":
@@ -112,8 +111,8 @@ struct Transform2D {
_FORCE_INLINE_ Vector2 xform_inv(const Vector2 &p_vec) const;
_FORCE_INLINE_ Rect2 xform(const Rect2 &p_rect) const;
_FORCE_INLINE_ Rect2 xform_inv(const Rect2 &p_rect) const;
- _FORCE_INLINE_ PoolVector<Vector2> xform(const PoolVector<Vector2> &p_array) const;
- _FORCE_INLINE_ PoolVector<Vector2> xform_inv(const PoolVector<Vector2> &p_array) const;
+ _FORCE_INLINE_ Vector<Vector2> xform(const Vector<Vector2> &p_array) const;
+ _FORCE_INLINE_ Vector<Vector2> xform_inv(const Vector<Vector2> &p_array) const;
operator String() const;
@@ -203,13 +202,13 @@ Rect2 Transform2D::xform_inv(const Rect2 &p_rect) const {
return new_rect;
}
-PoolVector<Vector2> Transform2D::xform(const PoolVector<Vector2> &p_array) const {
+Vector<Vector2> Transform2D::xform(const Vector<Vector2> &p_array) const {
- PoolVector<Vector2> array;
+ Vector<Vector2> array;
array.resize(p_array.size());
- PoolVector<Vector2>::Read r = p_array.read();
- PoolVector<Vector2>::Write w = array.write();
+ const Vector2 *r = p_array.ptr();
+ Vector2 *w = array.ptrw();
for (int i = 0; i < p_array.size(); ++i) {
w[i] = xform(r[i]);
@@ -217,13 +216,13 @@ PoolVector<Vector2> Transform2D::xform(const PoolVector<Vector2> &p_array) const
return array;
}
-PoolVector<Vector2> Transform2D::xform_inv(const PoolVector<Vector2> &p_array) const {
+Vector<Vector2> Transform2D::xform_inv(const Vector<Vector2> &p_array) const {
- PoolVector<Vector2> array;
+ Vector<Vector2> array;
array.resize(p_array.size());
- PoolVector<Vector2>::Read r = p_array.read();
- PoolVector<Vector2>::Write w = array.write();
+ const Vector2 *r = p_array.ptr();
+ Vector2 *w = array.ptrw();
for (int i = 0; i < p_array.size(); ++i) {
w[i] = xform_inv(r[i]);
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index 53d4ea0a96..01d38cf24e 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -89,7 +89,7 @@ int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, in
return index;
}
-void TriangleMesh::get_indices(PoolVector<int> *r_triangles_indices) const {
+void TriangleMesh::get_indices(Vector<int> *r_triangles_indices) const {
if (!valid)
return;
@@ -97,10 +97,10 @@ void TriangleMesh::get_indices(PoolVector<int> *r_triangles_indices) const {
const int triangles_num = triangles.size();
// Parse vertices indices
- PoolVector<Triangle>::Read triangles_read = triangles.read();
+ const Triangle *triangles_read = triangles.ptr();
r_triangles_indices->resize(triangles_num * 3);
- PoolVector<int>::Write r_indices_write = r_triangles_indices->write();
+ int *r_indices_write = r_triangles_indices->ptrw();
for (int i = 0; i < triangles_num; ++i) {
r_indices_write[3 * i + 0] = triangles_read[i].indices[0];
@@ -109,7 +109,7 @@ void TriangleMesh::get_indices(PoolVector<int> *r_triangles_indices) const {
}
}
-void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
+void TriangleMesh::create(const Vector<Vector3> &p_faces) {
valid = false;
@@ -119,7 +119,7 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
triangles.resize(fc);
bvh.resize(fc * 3); //will never be larger than this (todo make better)
- PoolVector<BVH>::Write bw = bvh.write();
+ BVH *bw = bvh.ptrw();
{
@@ -127,8 +127,8 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
//except for the Set for repeated triangles, everything
//goes in-place.
- PoolVector<Vector3>::Read r = p_faces.read();
- PoolVector<Triangle>::Write w = triangles.write();
+ const Vector3 *r = p_faces.ptr();
+ Triangle *w = triangles.ptrw();
Map<Vector3, int> db;
for (int i = 0; i < fc; i++) {
@@ -164,15 +164,15 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
}
vertices.resize(db.size());
- PoolVector<Vector3>::Write vw = vertices.write();
+ Vector3 *vw = vertices.ptrw();
for (Map<Vector3, int>::Element *E = db.front(); E; E = E->next()) {
vw[E->get()] = E->key();
}
}
- PoolVector<BVH *> bwptrs;
+ Vector<BVH *> bwptrs;
bwptrs.resize(fc);
- PoolVector<BVH *>::Write bwp = bwptrs.write();
+ BVH **bwp = bwptrs.ptrw();
for (int i = 0; i < fc; i++) {
bwp[i] = &bw[i];
@@ -180,9 +180,8 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
max_depth = 0;
int max_alloc = fc;
- _create_bvh(bw.ptr(), bwp.ptr(), 0, fc, 1, max_depth, max_alloc);
+ _create_bvh(bw, bwp, 0, fc, 1, max_depth, max_alloc);
- bw.release(); //clearup
bvh.resize(max_alloc); //resize back
valid = true;
@@ -208,13 +207,11 @@ Vector3 TriangleMesh::get_area_normal(const AABB &p_aabb) const {
int level = 0;
- PoolVector<Triangle>::Read trianglesr = triangles.read();
- PoolVector<Vector3>::Read verticesr = vertices.read();
- PoolVector<BVH>::Read bvhr = bvh.read();
+ const Triangle *triangleptr = triangles.ptr();
+ // const Vector3 *verticesr = vertices.ptr();
+ const BVH *bvhptr = bvh.ptr();
- const Triangle *triangleptr = trianglesr.ptr();
int pos = bvh.size() - 1;
- const BVH *bvhptr = bvhr.ptr();
stack[0] = pos;
while (true) {
@@ -304,14 +301,11 @@ bool TriangleMesh::intersect_segment(const Vector3 &p_begin, const Vector3 &p_en
int level = 0;
- PoolVector<Triangle>::Read trianglesr = triangles.read();
- PoolVector<Vector3>::Read verticesr = vertices.read();
- PoolVector<BVH>::Read bvhr = bvh.read();
+ const Triangle *triangleptr = triangles.ptr();
+ const Vector3 *vertexptr = vertices.ptr();
+ const BVH *bvhptr = bvh.ptr();
- const Triangle *triangleptr = trianglesr.ptr();
- const Vector3 *vertexptr = verticesr.ptr();
int pos = bvh.size() - 1;
- const BVH *bvhptr = bvhr.ptr();
stack[0] = pos;
while (true) {
@@ -419,14 +413,11 @@ bool TriangleMesh::intersect_ray(const Vector3 &p_begin, const Vector3 &p_dir, V
int level = 0;
- PoolVector<Triangle>::Read trianglesr = triangles.read();
- PoolVector<Vector3>::Read verticesr = vertices.read();
- PoolVector<BVH>::Read bvhr = bvh.read();
+ const Triangle *triangleptr = triangles.ptr();
+ const Vector3 *vertexptr = vertices.ptr();
+ const BVH *bvhptr = bvh.ptr();
- const Triangle *triangleptr = trianglesr.ptr();
- const Vector3 *vertexptr = verticesr.ptr();
int pos = bvh.size() - 1;
- const BVH *bvhptr = bvhr.ptr();
stack[0] = pos;
while (true) {
@@ -529,14 +520,11 @@ bool TriangleMesh::intersect_convex_shape(const Plane *p_planes, int p_plane_cou
int level = 0;
- PoolVector<Triangle>::Read trianglesr = triangles.read();
- PoolVector<Vector3>::Read verticesr = vertices.read();
- PoolVector<BVH>::Read bvhr = bvh.read();
+ const Triangle *triangleptr = triangles.ptr();
+ const Vector3 *vertexptr = vertices.ptr();
+ const BVH *bvhptr = bvh.ptr();
- const Triangle *triangleptr = trianglesr.ptr();
- const Vector3 *vertexptr = verticesr.ptr();
int pos = bvh.size() - 1;
- const BVH *bvhptr = bvhr.ptr();
stack[0] = pos;
while (true) {
@@ -645,16 +633,13 @@ bool TriangleMesh::inside_convex_shape(const Plane *p_planes, int p_plane_count,
int level = 0;
- PoolVector<Triangle>::Read trianglesr = triangles.read();
- PoolVector<Vector3>::Read verticesr = vertices.read();
- PoolVector<BVH>::Read bvhr = bvh.read();
+ const Triangle *triangleptr = triangles.ptr();
+ const Vector3 *vertexptr = vertices.ptr();
+ const BVH *bvhptr = bvh.ptr();
Transform scale(Basis().scaled(p_scale));
- const Triangle *triangleptr = trianglesr.ptr();
- const Vector3 *vertexptr = verticesr.ptr();
int pos = bvh.size() - 1;
- const BVH *bvhptr = bvhr.ptr();
stack[0] = pos;
while (true) {
@@ -732,18 +717,18 @@ bool TriangleMesh::is_valid() const {
return valid;
}
-PoolVector<Face3> TriangleMesh::get_faces() const {
+Vector<Face3> TriangleMesh::get_faces() const {
if (!valid)
- return PoolVector<Face3>();
+ return Vector<Face3>();
- PoolVector<Face3> faces;
+ Vector<Face3> faces;
int ts = triangles.size();
faces.resize(triangles.size());
- PoolVector<Face3>::Write w = faces.write();
- PoolVector<Triangle>::Read r = triangles.read();
- PoolVector<Vector3>::Read rv = vertices.read();
+ Face3 *w = faces.ptrw();
+ const Triangle *r = triangles.ptr();
+ const Vector3 *rv = vertices.ptr();
for (int i = 0; i < ts; i++) {
for (int j = 0; j < 3; j++) {
@@ -751,7 +736,6 @@ PoolVector<Face3> TriangleMesh::get_faces() const {
}
}
- w.release();
return faces;
}
diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h
index 575a78b0b5..fdbfb90465 100644
--- a/core/math/triangle_mesh.h
+++ b/core/math/triangle_mesh.h
@@ -44,8 +44,8 @@ class TriangleMesh : public Reference {
int indices[3];
};
- PoolVector<Triangle> triangles;
- PoolVector<Vector3> vertices;
+ Vector<Triangle> triangles;
+ Vector<Vector3> vertices;
struct BVH {
@@ -82,7 +82,7 @@ class TriangleMesh : public Reference {
int _create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, int p_depth, int &max_depth, int &max_alloc);
- PoolVector<BVH> bvh;
+ Vector<BVH> bvh;
int max_depth;
bool valid;
@@ -93,13 +93,13 @@ public:
bool intersect_convex_shape(const Plane *p_planes, int p_plane_count) const;
bool inside_convex_shape(const Plane *p_planes, int p_plane_count, Vector3 p_scale = Vector3(1, 1, 1)) const;
Vector3 get_area_normal(const AABB &p_aabb) const;
- PoolVector<Face3> get_faces() const;
+ Vector<Face3> get_faces() const;
- PoolVector<Triangle> get_triangles() const { return triangles; }
- PoolVector<Vector3> get_vertices() const { return vertices; }
- void get_indices(PoolVector<int> *r_triangles_indices) const;
+ Vector<Triangle> get_triangles() const { return triangles; }
+ Vector<Vector3> get_vertices() const { return vertices; }
+ void get_indices(Vector<int> *r_triangles_indices) const;
- void create(const PoolVector<Vector3> &p_faces);
+ void create(const Vector<Vector3> &p_faces);
TriangleMesh();
};
diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h
index 118970de80..6ccf41229f 100644
--- a/core/method_ptrcall.h
+++ b/core/method_ptrcall.h
@@ -129,13 +129,13 @@ MAKE_PTRARG(NodePath);
MAKE_PTRARG(RID);
MAKE_PTRARG(Dictionary);
MAKE_PTRARG(Array);
-MAKE_PTRARG(PoolByteArray);
-MAKE_PTRARG(PoolIntArray);
-MAKE_PTRARG(PoolRealArray);
-MAKE_PTRARG(PoolStringArray);
-MAKE_PTRARG(PoolVector2Array);
-MAKE_PTRARG(PoolVector3Array);
-MAKE_PTRARG(PoolColorArray);
+MAKE_PTRARG(PackedByteArray);
+MAKE_PTRARG(PackedIntArray);
+MAKE_PTRARG(PackedRealArray);
+MAKE_PTRARG(PackedStringArray);
+MAKE_PTRARG(PackedVector2Array);
+MAKE_PTRARG(PackedVector3Array);
+MAKE_PTRARG(PackedColorArray);
MAKE_PTRARG_BY_REFERENCE(Variant);
//this is for Object
@@ -185,95 +185,96 @@ struct PtrToArg<ObjectID> {
//this is for the special cases used by Variant
-#define MAKE_VECARG(m_type) \
- template <> \
- struct PtrToArg<Vector<m_type> > { \
- _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
- const PoolVector<m_type> *dvs = reinterpret_cast<const PoolVector<m_type> *>(p_ptr); \
- Vector<m_type> ret; \
- int len = dvs->size(); \
- ret.resize(len); \
- { \
- PoolVector<m_type>::Read r = dvs->read(); \
- for (int i = 0; i < len; i++) { \
- ret.write[i] = r[i]; \
- } \
- } \
- return ret; \
- } \
- _FORCE_INLINE_ static void encode(Vector<m_type> p_vec, void *p_ptr) { \
- PoolVector<m_type> *dv = reinterpret_cast<PoolVector<m_type> *>(p_ptr); \
- int len = p_vec.size(); \
- dv->resize(len); \
- { \
- PoolVector<m_type>::Write w = dv->write(); \
- for (int i = 0; i < len; i++) { \
- w[i] = p_vec[i]; \
- } \
- } \
- } \
- }; \
- template <> \
- struct PtrToArg<const Vector<m_type> &> { \
- _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
- const PoolVector<m_type> *dvs = reinterpret_cast<const PoolVector<m_type> *>(p_ptr); \
- Vector<m_type> ret; \
- int len = dvs->size(); \
- ret.resize(len); \
- { \
- PoolVector<m_type>::Read r = dvs->read(); \
- for (int i = 0; i < len; i++) { \
- ret.write[i] = r[i]; \
- } \
- } \
- return ret; \
- } \
+#define MAKE_VECARG(m_type) \
+ template <> \
+ struct PtrToArg<Vector<m_type> > { \
+ _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
+ const Vector<m_type> *dvs = reinterpret_cast<const Vector<m_type> *>(p_ptr); \
+ Vector<m_type> ret; \
+ int len = dvs->size(); \
+ ret.resize(len); \
+ { \
+ const m_type *r = dvs->ptr(); \
+ for (int i = 0; i < len; i++) { \
+ ret.write[i] = r[i]; \
+ } \
+ } \
+ return ret; \
+ } \
+ _FORCE_INLINE_ static void encode(Vector<m_type> p_vec, void *p_ptr) { \
+ Vector<m_type> *dv = reinterpret_cast<Vector<m_type> *>(p_ptr); \
+ int len = p_vec.size(); \
+ dv->resize(len); \
+ { \
+ m_type *w = dv->ptrw(); \
+ for (int i = 0; i < len; i++) { \
+ w[i] = p_vec[i]; \
+ } \
+ } \
+ } \
+ }; \
+ template <> \
+ struct PtrToArg<const Vector<m_type> &> { \
+ _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
+ const Vector<m_type> *dvs = reinterpret_cast<const Vector<m_type> *>(p_ptr); \
+ Vector<m_type> ret; \
+ int len = dvs->size(); \
+ ret.resize(len); \
+ { \
+ const m_type *r = dvs->ptr(); \
+ for (int i = 0; i < len; i++) { \
+ ret.write[i] = r[i]; \
+ } \
+ } \
+ return ret; \
+ } \
}
-#define MAKE_VECARG_ALT(m_type, m_type_alt) \
- template <> \
- struct PtrToArg<Vector<m_type_alt> > { \
- _FORCE_INLINE_ static Vector<m_type_alt> convert(const void *p_ptr) { \
- const PoolVector<m_type> *dvs = reinterpret_cast<const PoolVector<m_type> *>(p_ptr); \
- Vector<m_type_alt> ret; \
- int len = dvs->size(); \
- ret.resize(len); \
- { \
- PoolVector<m_type>::Read r = dvs->read(); \
- for (int i = 0; i < len; i++) { \
- ret.write[i] = r[i]; \
- } \
- } \
- return ret; \
- } \
- _FORCE_INLINE_ static void encode(Vector<m_type_alt> p_vec, void *p_ptr) { \
- PoolVector<m_type> *dv = reinterpret_cast<PoolVector<m_type> *>(p_ptr); \
- int len = p_vec.size(); \
- dv->resize(len); \
- { \
- PoolVector<m_type>::Write w = dv->write(); \
- for (int i = 0; i < len; i++) { \
- w[i] = p_vec[i]; \
- } \
- } \
- } \
- }; \
- template <> \
- struct PtrToArg<const Vector<m_type_alt> &> { \
- _FORCE_INLINE_ static Vector<m_type_alt> convert(const void *p_ptr) { \
- const PoolVector<m_type> *dvs = reinterpret_cast<const PoolVector<m_type> *>(p_ptr); \
- Vector<m_type_alt> ret; \
- int len = dvs->size(); \
- ret.resize(len); \
- { \
- PoolVector<m_type>::Read r = dvs->read(); \
- for (int i = 0; i < len; i++) { \
- ret.write[i] = r[i]; \
- } \
- } \
- return ret; \
- } \
+#define MAKE_VECARG_ALT(m_type, m_type_alt) \
+ template <> \
+ struct PtrToArg<Vector<m_type_alt> > { \
+ _FORCE_INLINE_ static Vector<m_type_alt> convert(const void *p_ptr) { \
+ const Vector<m_type> *dvs = reinterpret_cast<const Vector<m_type> *>(p_ptr); \
+ Vector<m_type_alt> ret; \
+ int len = dvs->size(); \
+ ret.resize(len); \
+ { \
+ const m_type *r = dvs->ptr(); \
+ for (int i = 0; i < len; i++) { \
+ ret.write[i] = r[i]; \
+ } \
+ } \
+ return ret; \
+ } \
+ _FORCE_INLINE_ static void encode(Vector<m_type_alt> p_vec, void *p_ptr) { \
+ Vector<m_type> *dv = reinterpret_cast<Vector<m_type> *>(p_ptr); \
+ int len = p_vec.size(); \
+ dv->resize(len); \
+ { \
+ m_type *w = dv->ptrw(); \
+ for (int i = 0; i < len; i++) { \
+ w[i] = p_vec[i]; \
+ } \
+ } \
+ } \
+ }; \
+ template <> \
+ struct PtrToArg<const Vector<m_type_alt> &> { \
+ _FORCE_INLINE_ static Vector<m_type_alt> convert(const void *p_ptr) { \
+ const Vector<m_type> *dvs = reinterpret_cast<const Vector<m_type> *>(p_ptr); \
+ Vector<m_type_alt> ret; \
+ int len = dvs->size(); \
+ ret.resize(len); \
+ { \
+ const m_type *r = dvs->ptr(); \
+ for (int i = 0; i < len; i++) { \
+ ret.write[i] = r[i]; \
+ } \
+ } \
+ return ret; \
+ } \
}
+/*
MAKE_VECARG(String);
MAKE_VECARG(uint8_t);
MAKE_VECARG(int);
@@ -281,6 +282,7 @@ MAKE_VECARG(float);
MAKE_VECARG(Vector2);
MAKE_VECARG(Vector3);
MAKE_VECARG(Color);
+*/
MAKE_VECARG_ALT(String, StringName);
//for stuff that gets converted to Array vectors
@@ -324,52 +326,52 @@ MAKE_VECARR(Variant);
MAKE_VECARR(RID);
MAKE_VECARR(Plane);
-#define MAKE_DVECARR(m_type) \
- template <> \
- struct PtrToArg<PoolVector<m_type> > { \
- _FORCE_INLINE_ static PoolVector<m_type> convert(const void *p_ptr) { \
- const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
- PoolVector<m_type> ret; \
- int len = arr->size(); \
- ret.resize(len); \
- { \
- PoolVector<m_type>::Write w = ret.write(); \
- for (int i = 0; i < len; i++) { \
- w[i] = (*arr)[i]; \
- } \
- } \
- return ret; \
- } \
- _FORCE_INLINE_ static void encode(PoolVector<m_type> p_vec, void *p_ptr) { \
- Array *arr = reinterpret_cast<Array *>(p_ptr); \
- int len = p_vec.size(); \
- arr->resize(len); \
- { \
- PoolVector<m_type>::Read r = p_vec.read(); \
- for (int i = 0; i < len; i++) { \
- (*arr)[i] = r[i]; \
- } \
- } \
- } \
- }; \
- template <> \
- struct PtrToArg<const PoolVector<m_type> &> { \
- _FORCE_INLINE_ static PoolVector<m_type> convert(const void *p_ptr) { \
- const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
- PoolVector<m_type> ret; \
- int len = arr->size(); \
- ret.resize(len); \
- { \
- PoolVector<m_type>::Write w = ret.write(); \
- for (int i = 0; i < len; i++) { \
- w[i] = (*arr)[i]; \
- } \
- } \
- return ret; \
- } \
+#define MAKE_DVECARR(m_type) \
+ template <> \
+ struct PtrToArg<Vector<m_type> > { \
+ _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
+ const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
+ Vector<m_type> ret; \
+ int len = arr->size(); \
+ ret.resize(len); \
+ { \
+ m_type *w = ret.ptrw(); \
+ for (int i = 0; i < len; i++) { \
+ w[i] = (*arr)[i]; \
+ } \
+ } \
+ return ret; \
+ } \
+ _FORCE_INLINE_ static void encode(Vector<m_type> p_vec, void *p_ptr) { \
+ Array *arr = reinterpret_cast<Array *>(p_ptr); \
+ int len = p_vec.size(); \
+ arr->resize(len); \
+ { \
+ const m_type *r = p_vec.ptr(); \
+ for (int i = 0; i < len; i++) { \
+ (*arr)[i] = r[i]; \
+ } \
+ } \
+ } \
+ }; \
+ template <> \
+ struct PtrToArg<const Vector<m_type> &> { \
+ _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
+ const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
+ Vector<m_type> ret; \
+ int len = arr->size(); \
+ ret.resize(len); \
+ { \
+ m_type *w = ret.ptrw(); \
+ for (int i = 0; i < len; i++) { \
+ w[i] = (*arr)[i]; \
+ } \
+ } \
+ return ret; \
+ } \
}
-MAKE_DVECARR(Plane);
+//MAKE_DVECARR(Plane);
//for special case StringName
#define MAKE_STRINGCONV(m_type) \
@@ -418,15 +420,15 @@ MAKE_STRINGCONV(StringName);
MAKE_STRINGCONV_BY_REFERENCE(IP_Address);
template <>
-struct PtrToArg<PoolVector<Face3> > {
- _FORCE_INLINE_ static PoolVector<Face3> convert(const void *p_ptr) {
- const PoolVector<Vector3> *dvs = reinterpret_cast<const PoolVector<Vector3> *>(p_ptr);
- PoolVector<Face3> ret;
+struct PtrToArg<Vector<Face3> > {
+ _FORCE_INLINE_ static Vector<Face3> convert(const void *p_ptr) {
+ const Vector<Vector3> *dvs = reinterpret_cast<const Vector<Vector3> *>(p_ptr);
+ Vector<Face3> ret;
int len = dvs->size() / 3;
ret.resize(len);
{
- PoolVector<Vector3>::Read r = dvs->read();
- PoolVector<Face3>::Write w = ret.write();
+ const Vector3 *r = dvs->ptr();
+ Face3 *w = ret.ptrw();
for (int i = 0; i < len; i++) {
w[i].vertex[0] = r[i * 3 + 0];
w[i].vertex[1] = r[i * 3 + 1];
@@ -435,13 +437,13 @@ struct PtrToArg<PoolVector<Face3> > {
}
return ret;
}
- _FORCE_INLINE_ static void encode(PoolVector<Face3> p_vec, void *p_ptr) {
- PoolVector<Vector3> *arr = reinterpret_cast<PoolVector<Vector3> *>(p_ptr);
+ _FORCE_INLINE_ static void encode(Vector<Face3> p_vec, void *p_ptr) {
+ Vector<Vector3> *arr = reinterpret_cast<Vector<Vector3> *>(p_ptr);
int len = p_vec.size();
arr->resize(len * 3);
{
- PoolVector<Face3>::Read r = p_vec.read();
- PoolVector<Vector3>::Write w = arr->write();
+ const Face3 *r = p_vec.ptr();
+ Vector3 *w = arr->ptrw();
for (int i = 0; i < len; i++) {
w[i * 3 + 0] = r[i].vertex[0];
w[i * 3 + 1] = r[i].vertex[1];
@@ -451,15 +453,15 @@ struct PtrToArg<PoolVector<Face3> > {
}
};
template <>
-struct PtrToArg<const PoolVector<Face3> &> {
- _FORCE_INLINE_ static PoolVector<Face3> convert(const void *p_ptr) {
- const PoolVector<Vector3> *dvs = reinterpret_cast<const PoolVector<Vector3> *>(p_ptr);
- PoolVector<Face3> ret;
+struct PtrToArg<const Vector<Face3> &> {
+ _FORCE_INLINE_ static Vector<Face3> convert(const void *p_ptr) {
+ const Vector<Vector3> *dvs = reinterpret_cast<const Vector<Vector3> *>(p_ptr);
+ Vector<Face3> ret;
int len = dvs->size() / 3;
ret.resize(len);
{
- PoolVector<Vector3>::Read r = dvs->read();
- PoolVector<Face3>::Write w = ret.write();
+ const Vector3 *r = dvs->ptr();
+ Face3 *w = ret.ptrw();
for (int i = 0; i < len; i++) {
w[i].vertex[0] = r[i * 3 + 0];
w[i].vertex[1] = r[i * 3 + 1];
diff --git a/core/object.cpp b/core/object.cpp
index 9a5cfe5c22..0a7a46a7d2 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1075,9 +1075,9 @@ Array Object::_get_method_list_bind() const {
return ret;
}
-PoolVector<String> Object::_get_meta_list_bind() const {
+Vector<String> Object::_get_meta_list_bind() const {
- PoolVector<String> _metaret;
+ Vector<String> _metaret;
List<Variant> keys;
metadata.get_key_list(&keys);
diff --git a/core/object.h b/core/object.h
index 6a229afaea..afbdbda814 100644
--- a/core/object.h
+++ b/core/object.h
@@ -563,7 +563,7 @@ protected:
return &_class_name;
}
- PoolVector<String> _get_meta_list_bind() const;
+ Vector<String> _get_meta_list_bind() const;
Array _get_property_list_bind() const;
Array _get_method_list_bind() const;
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 2917351a2f..30cfaa7617 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -408,17 +408,17 @@ int FileAccess::get_buffer(uint8_t *p_dst, int p_length) const {
}
String FileAccess::get_as_utf8_string() const {
- PoolVector<uint8_t> sourcef;
+ Vector<uint8_t> sourcef;
int len = get_len();
sourcef.resize(len + 1);
- PoolVector<uint8_t>::Write w = sourcef.write();
- int r = get_buffer(w.ptr(), len);
+ uint8_t *w = sourcef.ptrw();
+ int r = get_buffer(w, len);
ERR_FAIL_COND_V(r != len, String());
w[len] = 0;
String s;
- if (s.parse_utf8((const char *)w.ptr())) {
+ if (s.parse_utf8((const char *)w)) {
return String();
}
return s;
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 6020c4b219..61bcb7dd32 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -46,7 +46,7 @@ void MainLoop::_bind_methods() {
BIND_VMETHOD(MethodInfo("_initialize"));
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_iteration", PropertyInfo(Variant::REAL, "delta")));
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_idle", PropertyInfo(Variant::REAL, "delta")));
- BIND_VMETHOD(MethodInfo("_drop_files", PropertyInfo(Variant::POOL_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "from_screen")));
+ BIND_VMETHOD(MethodInfo("_drop_files", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "from_screen")));
BIND_VMETHOD(MethodInfo("_finalize"));
BIND_VMETHOD(MethodInfo("_global_menu_action", PropertyInfo(Variant::NIL, "id"), PropertyInfo(Variant::NIL, "meta")));
diff --git a/core/os/memory.h b/core/os/memory.h
index e45f97e0c8..207149b57e 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -143,7 +143,7 @@ T *memnew_arr_template(size_t p_elements, const char *p_descr = "") {
if (p_elements == 0)
return 0;
/** overloading operator new[] cannot be done , because it may not return the real allocated address (it may pad the 'element count' before the actual array). Because of that, it must be done by hand. This is the
- same strategy used by std::vector, and the PoolVector class, so it should be safe.*/
+ same strategy used by std::vector, and the Vector class, so it should be safe.*/
size_t len = sizeof(T) * p_elements;
uint64_t *mem = (uint64_t *)Memory::alloc_static(len, true);
diff --git a/core/os/midi_driver.cpp b/core/os/midi_driver.cpp
index 3e020a1585..6ebec50ff0 100644
--- a/core/os/midi_driver.cpp
+++ b/core/os/midi_driver.cpp
@@ -121,9 +121,9 @@ void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_
id->parse_input_event(event);
}
-PoolStringArray MIDIDriver::get_connected_inputs() {
+PackedStringArray MIDIDriver::get_connected_inputs() {
- PoolStringArray list;
+ PackedStringArray list;
return list;
}
diff --git a/core/os/midi_driver.h b/core/os/midi_driver.h
index 26dbdce151..4f53feb43e 100644
--- a/core/os/midi_driver.h
+++ b/core/os/midi_driver.h
@@ -50,7 +50,7 @@ public:
virtual Error open() = 0;
virtual void close() = 0;
- virtual PoolStringArray get_connected_inputs();
+ virtual PackedStringArray get_connected_inputs();
static void receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_t length);
diff --git a/core/os/os.cpp b/core/os/os.cpp
index d1b6ccab54..9a65d537ac 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -416,10 +416,6 @@ uint64_t OS::get_static_memory_usage() const {
return Memory::get_mem_usage();
}
-uint64_t OS::get_dynamic_memory_usage() const {
-
- return MemoryPool::total_memory;
-}
uint64_t OS::get_static_memory_peak_usage() const {
@@ -712,12 +708,12 @@ List<String> OS::get_restart_on_exit_arguments() const {
return restart_commandline;
}
-PoolStringArray OS::get_connected_midi_inputs() {
+PackedStringArray OS::get_connected_midi_inputs() {
if (MIDIDriver::get_singleton())
return MIDIDriver::get_singleton()->get_connected_inputs();
- PoolStringArray list;
+ PackedStringArray list;
return list;
}
diff --git a/core/os/os.h b/core/os/os.h
index e4661e4583..77391c3a8b 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -185,7 +185,7 @@ public:
virtual int get_audio_driver_count() const;
virtual const char *get_audio_driver_name(int p_driver) const;
- virtual PoolStringArray get_connected_midi_inputs();
+ virtual PackedStringArray get_connected_midi_inputs();
virtual void open_midi_inputs();
virtual void close_midi_inputs();
@@ -390,7 +390,6 @@ public:
virtual uint64_t get_static_memory_usage() const;
virtual uint64_t get_static_memory_peak_usage() const;
- virtual uint64_t get_dynamic_memory_usage() const;
virtual uint64_t get_free_static_memory() const;
RenderThreadMode get_render_thread_mode() const { return _render_thread_mode; }
diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp
index f8f51c4c75..ae5f89e870 100644
--- a/core/packed_data_container.cpp
+++ b/core/packed_data_container.cpp
@@ -80,20 +80,20 @@ Variant PackedDataContainer::_iter_get_ofs(const Variant &p_iter, uint32_t p_off
if (pos < 0 || pos >= size)
return Variant();
- PoolVector<uint8_t>::Read rd = data.read();
+ const uint8_t *rd = data.ptr();
const uint8_t *r = &rd[p_offset];
uint32_t type = decode_uint32(r);
bool err = false;
if (type == TYPE_ARRAY) {
- uint32_t vpos = decode_uint32(rd.ptr() + p_offset + 8 + pos * 4);
- return _get_at_ofs(vpos, rd.ptr(), err);
+ uint32_t vpos = decode_uint32(rd + p_offset + 8 + pos * 4);
+ return _get_at_ofs(vpos, rd, err);
} else if (type == TYPE_DICT) {
- uint32_t vpos = decode_uint32(rd.ptr() + p_offset + 8 + pos * 12 + 4);
- return _get_at_ofs(vpos, rd.ptr(), err);
+ uint32_t vpos = decode_uint32(rd + p_offset + 8 + pos * 12 + 4);
+ return _get_at_ofs(vpos, rd, err);
} else {
ERR_FAIL_V(Variant());
}
@@ -127,7 +127,7 @@ Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, b
uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const {
- PoolVector<uint8_t>::Read rd = data.read();
+ const uint8_t *rd = data.ptr();
const uint8_t *r = &rd[p_ofs];
uint32_t type = decode_uint32(r);
@@ -136,8 +136,8 @@ uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const {
int PackedDataContainer::_size(uint32_t p_ofs) const {
- PoolVector<uint8_t>::Read rd = data.read();
- ERR_FAIL_COND_V(!rd.ptr(), 0);
+ const uint8_t *rd = data.ptr();
+ ERR_FAIL_COND_V(!rd, 0);
const uint8_t *r = &rd[p_ofs];
uint32_t type = decode_uint32(r);
@@ -157,7 +157,7 @@ int PackedDataContainer::_size(uint32_t p_ofs) const {
Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, bool &err) const {
- PoolVector<uint8_t>::Read rd = data.read();
+ const uint8_t *rd = data.ptr();
const uint8_t *r = &rd[p_ofs];
uint32_t type = decode_uint32(r);
@@ -172,7 +172,7 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
return Variant();
}
uint32_t ofs = decode_uint32(r + 8 + 4 * idx);
- return _get_at_ofs(ofs, rd.ptr(), err);
+ return _get_at_ofs(ofs, rd, err);
} else {
err = true;
@@ -188,12 +188,12 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
for (uint32_t i = 0; i < len; i++) {
uint32_t khash = decode_uint32(r + 8 + i * 12 + 0);
if (khash == hash) {
- Variant key = _get_at_ofs(decode_uint32(r + 8 + i * 12 + 4), rd.ptr(), err);
+ Variant key = _get_at_ofs(decode_uint32(r + 8 + i * 12 + 4), rd, err);
if (err)
return Variant();
if (key == p_key) {
//key matches, return value
- return _get_at_ofs(decode_uint32(r + 8 + i * 12 + 8), rd.ptr(), err);
+ return _get_at_ofs(decode_uint32(r + 8 + i * 12 + 8), rd, err);
}
found = true;
} else {
@@ -240,13 +240,13 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
case Variant::AABB:
case Variant::BASIS:
case Variant::TRANSFORM:
- case Variant::POOL_BYTE_ARRAY:
- case Variant::POOL_INT_ARRAY:
- case Variant::POOL_REAL_ARRAY:
- case Variant::POOL_STRING_ARRAY:
- case Variant::POOL_VECTOR2_ARRAY:
- case Variant::POOL_VECTOR3_ARRAY:
- case Variant::POOL_COLOR_ARRAY:
+ case Variant::PACKED_BYTE_ARRAY:
+ case Variant::PACKED_INT_ARRAY:
+ case Variant::PACKED_REAL_ARRAY:
+ case Variant::PACKED_STRING_ARRAY:
+ case Variant::PACKED_VECTOR2_ARRAY:
+ case Variant::PACKED_VECTOR3_ARRAY:
+ case Variant::PACKED_COLOR_ARRAY:
case Variant::NODE_PATH: {
uint32_t pos = tmpdata.size();
@@ -335,19 +335,19 @@ Error PackedDataContainer::pack(const Variant &p_data) {
_pack(p_data, tmpdata, string_cache);
datalen = tmpdata.size();
data.resize(tmpdata.size());
- PoolVector<uint8_t>::Write w = data.write();
- copymem(w.ptr(), tmpdata.ptr(), tmpdata.size());
+ uint8_t *w = data.ptrw();
+ copymem(w, tmpdata.ptr(), tmpdata.size());
return OK;
}
-void PackedDataContainer::_set_data(const PoolVector<uint8_t> &p_data) {
+void PackedDataContainer::_set_data(const Vector<uint8_t> &p_data) {
data = p_data;
datalen = data.size();
}
-PoolVector<uint8_t> PackedDataContainer::_get_data() const {
+Vector<uint8_t> PackedDataContainer::_get_data() const {
return data;
}
@@ -375,7 +375,7 @@ void PackedDataContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("pack", "value"), &PackedDataContainer::pack);
ClassDB::bind_method(D_METHOD("size"), &PackedDataContainer::size);
- ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "__data__"), "_set_data", "_get_data");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "__data__"), "_set_data", "_get_data");
}
PackedDataContainer::PackedDataContainer() {
diff --git a/core/packed_data_container.h b/core/packed_data_container.h
index b534169077..852fdcd0d3 100644
--- a/core/packed_data_container.h
+++ b/core/packed_data_container.h
@@ -48,7 +48,7 @@ class PackedDataContainer : public Resource {
bool operator<(const DictKey &p_key) const { return hash < p_key.hash; }
};
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
int datalen;
uint32_t _pack(const Variant &p_data, Vector<uint8_t> &tmpdata, Map<String, uint32_t> &string_cache);
@@ -68,8 +68,8 @@ class PackedDataContainer : public Resource {
int _size(uint32_t p_ofs) const;
protected:
- void _set_data(const PoolVector<uint8_t> &p_data);
- PoolVector<uint8_t> _get_data() const;
+ void _set_data(const Vector<uint8_t> &p_data);
+ Vector<uint8_t> _get_data() const;
static void _bind_methods();
public:
diff --git a/core/pool_vector.cpp b/core/pool_vector.cpp
deleted file mode 100644
index d8d53f07e9..0000000000
--- a/core/pool_vector.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*************************************************************************/
-/* pool_vector.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "pool_vector.h"
-
-Mutex *pool_vector_lock = NULL;
-
-PoolAllocator *MemoryPool::memory_pool = NULL;
-uint8_t *MemoryPool::pool_memory = NULL;
-size_t *MemoryPool::pool_size = NULL;
-
-MemoryPool::Alloc *MemoryPool::allocs = NULL;
-MemoryPool::Alloc *MemoryPool::free_list = NULL;
-uint32_t MemoryPool::alloc_count = 0;
-uint32_t MemoryPool::allocs_used = 0;
-Mutex *MemoryPool::alloc_mutex = NULL;
-
-size_t MemoryPool::total_memory = 0;
-size_t MemoryPool::max_memory = 0;
-
-void MemoryPool::setup(uint32_t p_max_allocs) {
-
- allocs = memnew_arr(Alloc, p_max_allocs);
- alloc_count = p_max_allocs;
- allocs_used = 0;
-
- for (uint32_t i = 0; i < alloc_count - 1; i++) {
-
- allocs[i].free_list = &allocs[i + 1];
- }
-
- free_list = &allocs[0];
-
- alloc_mutex = Mutex::create();
-}
-
-void MemoryPool::cleanup() {
-
- memdelete_arr(allocs);
- memdelete(alloc_mutex);
-
- ERR_FAIL_COND_MSG(allocs_used > 0, "There are still MemoryPool allocs in use at exit!");
-}
diff --git a/core/pool_vector.h b/core/pool_vector.h
deleted file mode 100644
index 01c40a237d..0000000000
--- a/core/pool_vector.h
+++ /dev/null
@@ -1,648 +0,0 @@
-/*************************************************************************/
-/* pool_vector.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef POOL_VECTOR_H
-#define POOL_VECTOR_H
-
-#include "core/os/copymem.h"
-#include "core/os/memory.h"
-#include "core/os/rw_lock.h"
-#include "core/pool_allocator.h"
-#include "core/safe_refcount.h"
-#include "core/ustring.h"
-
-struct MemoryPool {
-
- //avoid accessing these directly, must be public for template access
-
- static PoolAllocator *memory_pool;
- static uint8_t *pool_memory;
- static size_t *pool_size;
-
- struct Alloc {
-
- SafeRefCount refcount;
- uint32_t lock;
- void *mem;
- PoolAllocator::ID pool_id;
- size_t size;
-
- Alloc *free_list;
-
- Alloc() :
- lock(0),
- mem(NULL),
- pool_id(POOL_ALLOCATOR_INVALID_ID),
- size(0),
- free_list(NULL) {
- }
- };
-
- static Alloc *allocs;
- static Alloc *free_list;
- static uint32_t alloc_count;
- static uint32_t allocs_used;
- static Mutex *alloc_mutex;
- static size_t total_memory;
- static size_t max_memory;
-
- static void setup(uint32_t p_max_allocs = (1 << 16));
- static void cleanup();
-};
-
-template <class T>
-class PoolVector {
-
- MemoryPool::Alloc *alloc;
-
- void _copy_on_write() {
-
- if (!alloc)
- return;
-
- // ERR_FAIL_COND(alloc->lock>0); should not be illegal to lock this for copy on write, as it's a copy on write after all
-
- // Refcount should not be zero, otherwise it's a misuse of COW
- if (alloc->refcount.get() == 1)
- return; //nothing to do
-
- //must allocate something
-
- MemoryPool::alloc_mutex->lock();
- if (MemoryPool::allocs_used == MemoryPool::alloc_count) {
- MemoryPool::alloc_mutex->unlock();
- ERR_FAIL_MSG("All memory pool allocations are in use, can't COW.");
- }
-
- MemoryPool::Alloc *old_alloc = alloc;
-
- //take one from the free list
- alloc = MemoryPool::free_list;
- MemoryPool::free_list = alloc->free_list;
- //increment the used counter
- MemoryPool::allocs_used++;
-
- //copy the alloc data
- alloc->size = old_alloc->size;
- alloc->refcount.init();
- alloc->pool_id = POOL_ALLOCATOR_INVALID_ID;
- alloc->lock = 0;
-
-#ifdef DEBUG_ENABLED
- MemoryPool::total_memory += alloc->size;
- if (MemoryPool::total_memory > MemoryPool::max_memory) {
- MemoryPool::max_memory = MemoryPool::total_memory;
- }
-#endif
-
- MemoryPool::alloc_mutex->unlock();
-
- if (MemoryPool::memory_pool) {
-
- } else {
- alloc->mem = memalloc(alloc->size);
- }
-
- {
- Write w;
- w._ref(alloc);
- Read r;
- r._ref(old_alloc);
-
- int cur_elements = alloc->size / sizeof(T);
- T *dst = (T *)w.ptr();
- const T *src = (const T *)r.ptr();
- for (int i = 0; i < cur_elements; i++) {
- memnew_placement(&dst[i], T(src[i]));
- }
- }
-
- if (old_alloc->refcount.unref()) {
- //this should never happen but..
-
-#ifdef DEBUG_ENABLED
- MemoryPool::alloc_mutex->lock();
- MemoryPool::total_memory -= old_alloc->size;
- MemoryPool::alloc_mutex->unlock();
-#endif
-
- {
- Write w;
- w._ref(old_alloc);
-
- int cur_elements = old_alloc->size / sizeof(T);
- T *elems = (T *)w.ptr();
- for (int i = 0; i < cur_elements; i++) {
- elems[i].~T();
- }
- }
-
- if (MemoryPool::memory_pool) {
- //resize memory pool
- //if none, create
- //if some resize
- } else {
-
- memfree(old_alloc->mem);
- old_alloc->mem = NULL;
- old_alloc->size = 0;
-
- MemoryPool::alloc_mutex->lock();
- old_alloc->free_list = MemoryPool::free_list;
- MemoryPool::free_list = old_alloc;
- MemoryPool::allocs_used--;
- MemoryPool::alloc_mutex->unlock();
- }
- }
- }
-
- void _reference(const PoolVector &p_pool_vector) {
-
- if (alloc == p_pool_vector.alloc)
- return;
-
- _unreference();
-
- if (!p_pool_vector.alloc) {
- return;
- }
-
- if (p_pool_vector.alloc->refcount.ref()) {
- alloc = p_pool_vector.alloc;
- }
- }
-
- void _unreference() {
-
- if (!alloc)
- return;
-
- if (!alloc->refcount.unref()) {
- alloc = NULL;
- return;
- }
-
- //must be disposed!
-
- {
- int cur_elements = alloc->size / sizeof(T);
-
- // Don't use write() here because it could otherwise provoke COW,
- // which is not desirable here because we are destroying the last reference anyways
- Write w;
- // Reference to still prevent other threads from touching the alloc
- w._ref(alloc);
-
- for (int i = 0; i < cur_elements; i++) {
-
- w[i].~T();
- }
- }
-
-#ifdef DEBUG_ENABLED
- MemoryPool::alloc_mutex->lock();
- MemoryPool::total_memory -= alloc->size;
- MemoryPool::alloc_mutex->unlock();
-#endif
-
- if (MemoryPool::memory_pool) {
- //resize memory pool
- //if none, create
- //if some resize
- } else {
-
- memfree(alloc->mem);
- alloc->mem = NULL;
- alloc->size = 0;
-
- MemoryPool::alloc_mutex->lock();
- alloc->free_list = MemoryPool::free_list;
- MemoryPool::free_list = alloc;
- MemoryPool::allocs_used--;
- MemoryPool::alloc_mutex->unlock();
- }
-
- alloc = NULL;
- }
-
-public:
- class Access {
- friend class PoolVector;
-
- protected:
- MemoryPool::Alloc *alloc;
- T *mem;
-
- _FORCE_INLINE_ void _ref(MemoryPool::Alloc *p_alloc) {
- alloc = p_alloc;
- if (alloc) {
- if (atomic_increment(&alloc->lock) == 1) {
- if (MemoryPool::memory_pool) {
- //lock it and get mem
- }
- }
-
- mem = (T *)alloc->mem;
- }
- }
-
- _FORCE_INLINE_ void _unref() {
-
- if (alloc) {
- if (atomic_decrement(&alloc->lock) == 0) {
- if (MemoryPool::memory_pool) {
- //put mem back
- }
- }
-
- mem = NULL;
- alloc = NULL;
- }
- }
-
- Access() {
- alloc = NULL;
- mem = NULL;
- }
-
- public:
- virtual ~Access() {
- _unref();
- }
-
- void release() {
- _unref();
- }
- };
-
- class Read : public Access {
- public:
- _FORCE_INLINE_ const T &operator[](int p_index) const { return this->mem[p_index]; }
- _FORCE_INLINE_ const T *ptr() const { return this->mem; }
-
- void operator=(const Read &p_read) {
- if (this->alloc == p_read.alloc)
- return;
- this->_unref();
- this->_ref(p_read.alloc);
- }
-
- Read(const Read &p_read) {
- this->_ref(p_read.alloc);
- }
-
- Read() {}
- };
-
- class Write : public Access {
- public:
- _FORCE_INLINE_ T &operator[](int p_index) const { return this->mem[p_index]; }
- _FORCE_INLINE_ T *ptr() const { return this->mem; }
-
- void operator=(const Write &p_read) {
- if (this->alloc == p_read.alloc)
- return;
- this->_unref();
- this->_ref(p_read.alloc);
- }
-
- Write(const Write &p_read) {
- this->_ref(p_read.alloc);
- }
-
- Write() {}
- };
-
- Read read() const {
-
- Read r;
- if (alloc) {
- r._ref(alloc);
- }
- return r;
- }
- Write write() {
-
- Write w;
- if (alloc) {
- _copy_on_write(); //make sure there is only one being acessed
- w._ref(alloc);
- }
- return w;
- }
-
- template <class MC>
- void fill_with(const MC &p_mc) {
-
- int c = p_mc.size();
- resize(c);
- Write w = write();
- int idx = 0;
- for (const typename MC::Element *E = p_mc.front(); E; E = E->next()) {
-
- w[idx++] = E->get();
- }
- }
-
- void remove(int p_index) {
-
- int s = size();
- ERR_FAIL_INDEX(p_index, s);
- Write w = write();
- for (int i = p_index; i < s - 1; i++) {
-
- w[i] = w[i + 1];
- };
- w = Write();
- resize(s - 1);
- }
-
- inline int size() const;
- inline bool empty() const;
- T get(int p_index) const;
- void set(int p_index, const T &p_val);
- void push_back(const T &p_val);
- void append(const T &p_val) { push_back(p_val); }
- void append_array(const PoolVector<T> &p_arr) {
- int ds = p_arr.size();
- if (ds == 0)
- return;
- int bs = size();
- resize(bs + ds);
- Write w = write();
- Read r = p_arr.read();
- for (int i = 0; i < ds; i++)
- w[bs + i] = r[i];
- }
-
- PoolVector<T> subarray(int p_from, int p_to) {
-
- if (p_from < 0) {
- p_from = size() + p_from;
- }
- if (p_to < 0) {
- p_to = size() + p_to;
- }
-
- ERR_FAIL_INDEX_V(p_from, size(), PoolVector<T>());
- ERR_FAIL_INDEX_V(p_to, size(), PoolVector<T>());
-
- PoolVector<T> slice;
- int span = 1 + p_to - p_from;
- slice.resize(span);
- Read r = read();
- Write w = slice.write();
- for (int i = 0; i < span; ++i) {
- w[i] = r[p_from + i];
- }
-
- return slice;
- }
-
- Error insert(int p_pos, const T &p_val) {
-
- int s = size();
- ERR_FAIL_INDEX_V(p_pos, s + 1, ERR_INVALID_PARAMETER);
- resize(s + 1);
- {
- Write w = write();
- for (int i = s; i > p_pos; i--)
- w[i] = w[i - 1];
- w[p_pos] = p_val;
- }
-
- return OK;
- }
-
- String join(String delimiter) {
- String rs = "";
- int s = size();
- Read r = read();
- for (int i = 0; i < s; i++) {
- rs += r[i] + delimiter;
- }
- rs.erase(rs.length() - delimiter.length(), delimiter.length());
- return rs;
- }
-
- bool is_locked() const { return alloc && alloc->lock > 0; }
-
- inline T operator[](int p_index) const;
-
- Error resize(int p_size);
-
- void invert();
-
- void operator=(const PoolVector &p_pool_vector) { _reference(p_pool_vector); }
- PoolVector() { alloc = NULL; }
- PoolVector(const PoolVector &p_pool_vector) {
- alloc = NULL;
- _reference(p_pool_vector);
- }
- ~PoolVector() { _unreference(); }
-};
-
-template <class T>
-int PoolVector<T>::size() const {
-
- return alloc ? alloc->size / sizeof(T) : 0;
-}
-
-template <class T>
-bool PoolVector<T>::empty() const {
-
- return alloc ? alloc->size == 0 : true;
-}
-
-template <class T>
-T PoolVector<T>::get(int p_index) const {
-
- return operator[](p_index);
-}
-
-template <class T>
-void PoolVector<T>::set(int p_index, const T &p_val) {
-
- ERR_FAIL_INDEX(p_index, size());
-
- Write w = write();
- w[p_index] = p_val;
-}
-
-template <class T>
-void PoolVector<T>::push_back(const T &p_val) {
-
- resize(size() + 1);
- set(size() - 1, p_val);
-}
-
-template <class T>
-T PoolVector<T>::operator[](int p_index) const {
-
- CRASH_BAD_INDEX(p_index, size());
-
- Read r = read();
- return r[p_index];
-}
-
-template <class T>
-Error PoolVector<T>::resize(int p_size) {
-
- ERR_FAIL_COND_V_MSG(p_size < 0, ERR_INVALID_PARAMETER, "Size of PoolVector cannot be negative.");
-
- if (alloc == NULL) {
-
- if (p_size == 0)
- return OK; //nothing to do here
-
- //must allocate something
- MemoryPool::alloc_mutex->lock();
- if (MemoryPool::allocs_used == MemoryPool::alloc_count) {
- MemoryPool::alloc_mutex->unlock();
- ERR_FAIL_V_MSG(ERR_OUT_OF_MEMORY, "All memory pool allocations are in use.");
- }
-
- //take one from the free list
- alloc = MemoryPool::free_list;
- MemoryPool::free_list = alloc->free_list;
- //increment the used counter
- MemoryPool::allocs_used++;
-
- //cleanup the alloc
- alloc->size = 0;
- alloc->refcount.init();
- alloc->pool_id = POOL_ALLOCATOR_INVALID_ID;
- MemoryPool::alloc_mutex->unlock();
-
- } else {
-
- ERR_FAIL_COND_V_MSG(alloc->lock > 0, ERR_LOCKED, "Can't resize PoolVector if locked."); //can't resize if locked!
- }
-
- size_t new_size = sizeof(T) * p_size;
-
- if (alloc->size == new_size)
- return OK; //nothing to do
-
- if (p_size == 0) {
- _unreference();
- return OK;
- }
-
- _copy_on_write(); // make it unique
-
-#ifdef DEBUG_ENABLED
- MemoryPool::alloc_mutex->lock();
- MemoryPool::total_memory -= alloc->size;
- MemoryPool::total_memory += new_size;
- if (MemoryPool::total_memory > MemoryPool::max_memory) {
- MemoryPool::max_memory = MemoryPool::total_memory;
- }
- MemoryPool::alloc_mutex->unlock();
-#endif
-
- int cur_elements = alloc->size / sizeof(T);
-
- if (p_size > cur_elements) {
-
- if (MemoryPool::memory_pool) {
- //resize memory pool
- //if none, create
- //if some resize
- } else {
-
- if (alloc->size == 0) {
- alloc->mem = memalloc(new_size);
- } else {
- alloc->mem = memrealloc(alloc->mem, new_size);
- }
- }
-
- alloc->size = new_size;
-
- Write w = write();
-
- for (int i = cur_elements; i < p_size; i++) {
-
- memnew_placement(&w[i], T);
- }
-
- } else {
-
- {
- Write w = write();
- for (int i = p_size; i < cur_elements; i++) {
-
- w[i].~T();
- }
- }
-
- if (MemoryPool::memory_pool) {
- //resize memory pool
- //if none, create
- //if some resize
- } else {
-
- if (new_size == 0) {
- memfree(alloc->mem);
- alloc->mem = NULL;
- alloc->size = 0;
-
- MemoryPool::alloc_mutex->lock();
- alloc->free_list = MemoryPool::free_list;
- MemoryPool::free_list = alloc;
- MemoryPool::allocs_used--;
- MemoryPool::alloc_mutex->unlock();
-
- } else {
- alloc->mem = memrealloc(alloc->mem, new_size);
- alloc->size = new_size;
- }
- }
- }
-
- return OK;
-}
-
-template <class T>
-void PoolVector<T>::invert() {
- T temp;
- Write w = write();
- int s = size();
- int half_s = s / 2;
-
- for (int i = 0; i < half_s; i++) {
- temp = w[i];
- w[i] = w[s - i - 1];
- w[s - i - 1] = temp;
- }
-}
-
-#endif // POOL_VECTOR_H
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index 59d7e82850..90487bda0d 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -1023,14 +1023,14 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF("audio/default_bus_layout", "res://default_bus_layout.tres");
custom_prop_info["audio/default_bus_layout"] = PropertyInfo(Variant::STRING, "audio/default_bus_layout", PROPERTY_HINT_FILE, "*.tres");
- PoolStringArray extensions = PoolStringArray();
+ PackedStringArray extensions = PackedStringArray();
extensions.push_back("gd");
if (Engine::get_singleton()->has_singleton("GodotSharp"))
extensions.push_back("cs");
extensions.push_back("shader");
GLOBAL_DEF("editor/search_in_file_extensions", extensions);
- custom_prop_info["editor/search_in_file_extensions"] = PropertyInfo(Variant::POOL_STRING_ARRAY, "editor/search_in_file_extensions");
+ custom_prop_info["editor/search_in_file_extensions"] = PropertyInfo(Variant::PACKED_STRING_ARRAY, "editor/search_in_file_extensions");
GLOBAL_DEF("editor/script_templates_search_path", "res://script_templates");
custom_prop_info["editor/script_templates_search_path"] = PropertyInfo(Variant::STRING, "editor/script_templates_search_path", PROPERTY_HINT_DIR);
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 91d9289563..82f9e847e3 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -98,7 +98,6 @@ void register_core_types() {
ObjectDB::setup();
ResourceCache::setup();
- MemoryPool::setup();
_global_mutex = Mutex::create();
@@ -316,6 +315,4 @@ void unregister_core_types() {
memdelete(_global_mutex);
_global_mutex = NULL; //still needed at a few places
};
-
- MemoryPool::cleanup();
}
diff --git a/core/script_language.h b/core/script_language.h
index 788f5d6976..2209f78fe4 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -313,7 +313,7 @@ public:
virtual bool supports_builtin_mode() const = 0;
virtual bool can_inherit_from_file() { return false; }
virtual int find_function(const String &p_function, const String &p_code) const = 0;
- virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const = 0;
+ virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const = 0;
virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; }
virtual bool overrides_external_editor() { return false; }
diff --git a/core/translation.cpp b/core/translation.cpp
index cf76de1c9e..17c23b86cd 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -794,9 +794,9 @@ static const char *locale_renames[][2] = {
///////////////////////////////////////////////
-PoolVector<String> Translation::_get_messages() const {
+Vector<String> Translation::_get_messages() const {
- PoolVector<String> msgs;
+ Vector<String> msgs;
msgs.resize(translation_map.size() * 2);
int idx = 0;
for (const Map<StringName, StringName>::Element *E = translation_map.front(); E; E = E->next()) {
@@ -809,9 +809,9 @@ PoolVector<String> Translation::_get_messages() const {
return msgs;
}
-PoolVector<String> Translation::_get_message_list() const {
+Vector<String> Translation::_get_message_list() const {
- PoolVector<String> msgs;
+ Vector<String> msgs;
msgs.resize(translation_map.size());
int idx = 0;
for (const Map<StringName, StringName>::Element *E = translation_map.front(); E; E = E->next()) {
@@ -823,12 +823,12 @@ PoolVector<String> Translation::_get_message_list() const {
return msgs;
}
-void Translation::_set_messages(const PoolVector<String> &p_messages) {
+void Translation::_set_messages(const Vector<String> &p_messages) {
int msg_count = p_messages.size();
ERR_FAIL_COND(msg_count % 2);
- PoolVector<String>::Read r = p_messages.read();
+ const String *r = p_messages.ptr();
for (int i = 0; i < msg_count; i += 2) {
@@ -898,7 +898,7 @@ void Translation::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_messages"), &Translation::_set_messages);
ClassDB::bind_method(D_METHOD("_get_messages"), &Translation::_get_messages);
- ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "messages", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_messages", "_get_messages");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_STRING_ARRAY, "messages", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_messages", "_get_messages");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "locale"), "set_locale", "get_locale");
}
@@ -1146,12 +1146,12 @@ TranslationServer *TranslationServer::singleton = NULL;
bool TranslationServer::_load_translations(const String &p_from) {
if (ProjectSettings::get_singleton()->has_setting(p_from)) {
- PoolVector<String> translations = ProjectSettings::get_singleton()->get(p_from);
+ Vector<String> translations = ProjectSettings::get_singleton()->get(p_from);
int tcount = translations.size();
if (tcount) {
- PoolVector<String>::Read r = translations.read();
+ const String *r = translations.ptr();
for (int i = 0; i < tcount; i++) {
diff --git a/core/translation.h b/core/translation.h
index 8f56b7271d..0448ea56c5 100644
--- a/core/translation.h
+++ b/core/translation.h
@@ -42,10 +42,10 @@ class Translation : public Resource {
String locale;
Map<StringName, StringName> translation_map;
- PoolVector<String> _get_message_list() const;
+ Vector<String> _get_message_list() const;
- PoolVector<String> _get_messages() const;
- void _set_messages(const PoolVector<String> &p_messages);
+ Vector<String> _get_messages() const;
+ void _set_messages(const Vector<String> &p_messages);
protected:
static void _bind_methods();
diff --git a/core/type_info.h b/core/type_info.h
index 9ca6d7fe73..379735fd67 100644
--- a/core/type_info.h
+++ b/core/type_info.h
@@ -155,20 +155,17 @@ MAKE_TYPE_INFO(NodePath, Variant::NODE_PATH)
MAKE_TYPE_INFO(RID, Variant::_RID)
MAKE_TYPE_INFO(Dictionary, Variant::DICTIONARY)
MAKE_TYPE_INFO(Array, Variant::ARRAY)
-MAKE_TYPE_INFO(PoolByteArray, Variant::POOL_BYTE_ARRAY)
-MAKE_TYPE_INFO(PoolIntArray, Variant::POOL_INT_ARRAY)
-MAKE_TYPE_INFO(PoolRealArray, Variant::POOL_REAL_ARRAY)
-MAKE_TYPE_INFO(PoolStringArray, Variant::POOL_STRING_ARRAY)
-MAKE_TYPE_INFO(PoolVector2Array, Variant::POOL_VECTOR2_ARRAY)
-MAKE_TYPE_INFO(PoolVector3Array, Variant::POOL_VECTOR3_ARRAY)
-MAKE_TYPE_INFO(PoolColorArray, Variant::POOL_COLOR_ARRAY)
+MAKE_TYPE_INFO(PackedByteArray, Variant::PACKED_BYTE_ARRAY)
+MAKE_TYPE_INFO(PackedIntArray, Variant::PACKED_INT_ARRAY)
+MAKE_TYPE_INFO(PackedRealArray, Variant::PACKED_REAL_ARRAY)
+MAKE_TYPE_INFO(PackedStringArray, Variant::PACKED_STRING_ARRAY)
+MAKE_TYPE_INFO(PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY)
+MAKE_TYPE_INFO(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY)
+MAKE_TYPE_INFO(PackedColorArray, Variant::PACKED_COLOR_ARRAY)
MAKE_TYPE_INFO(StringName, Variant::STRING)
MAKE_TYPE_INFO(IP_Address, Variant::STRING)
-class BSP_Tree;
-MAKE_TYPE_INFO(BSP_Tree, Variant::DICTIONARY)
-
//objectID
template <>
struct GetTypeInfo<ObjectID> {
@@ -216,21 +213,25 @@ struct GetTypeInfo<const Variant &> {
} \
};
-MAKE_TEMPLATE_TYPE_INFO(Vector, uint8_t, Variant::POOL_BYTE_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, int, Variant::POOL_INT_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, float, Variant::POOL_REAL_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, String, Variant::POOL_STRING_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, Vector2, Variant::POOL_VECTOR2_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, Vector3, Variant::POOL_VECTOR3_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, Color, Variant::POOL_COLOR_ARRAY)
-
MAKE_TEMPLATE_TYPE_INFO(Vector, Variant, Variant::ARRAY)
MAKE_TEMPLATE_TYPE_INFO(Vector, RID, Variant::ARRAY)
MAKE_TEMPLATE_TYPE_INFO(Vector, Plane, Variant::ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, StringName, Variant::POOL_STRING_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, Face3, Variant::PACKED_VECTOR3_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, StringName, Variant::PACKED_STRING_ARRAY)
+
+/*
+MAKE_TEMPLATE_TYPE_INFO(Vector, uint8_t, Variant::PACKED_BYTE_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, int, Variant::PACKED_INT_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, float, Variant::PACKED_REAL_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, String, Variant::PACKED_STRING_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, Vector2, Variant::PACKED_VECTOR2_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, Vector3, Variant::PACKED_VECTOR3_ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, Color, Variant::PACKED_COLOR_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(PoolVector, Plane, Variant::ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(PoolVector, Face3, Variant::POOL_VECTOR3_ARRAY)
+
+MAKE_TEMPLATE_TYPE_INFO(Vector, Plane, Variant::ARRAY)
+MAKE_TEMPLATE_TYPE_INFO(Vector, Face3, Variant::PACKED_VECTOR3_ARRAY)
+*/
template <typename T>
struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::value>::type> {
diff --git a/core/variant.cpp b/core/variant.cpp
index c2ffe3721f..b849a83cb4 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -145,38 +145,38 @@ String Variant::get_type_name(Variant::Type p_type) {
} break;
// arrays
- case POOL_BYTE_ARRAY: {
+ case PACKED_BYTE_ARRAY: {
- return "PoolByteArray";
+ return "PackedByteArray";
} break;
- case POOL_INT_ARRAY: {
+ case PACKED_INT_ARRAY: {
- return "PoolIntArray";
+ return "PackedIntArray";
} break;
- case POOL_REAL_ARRAY: {
+ case PACKED_REAL_ARRAY: {
- return "PoolRealArray";
+ return "PackedRealArray";
} break;
- case POOL_STRING_ARRAY: {
+ case PACKED_STRING_ARRAY: {
- return "PoolStringArray";
+ return "PackedStringArray";
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
- return "PoolVector2Array";
+ return "PackedVector2Array";
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
- return "PoolVector3Array";
+ return "PackedVector3Array";
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
- return "PoolColorArray";
+ return "PackedColorArray";
} break;
default: {
@@ -329,20 +329,20 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
case ARRAY: {
static const Type valid[] = {
- POOL_BYTE_ARRAY,
- POOL_INT_ARRAY,
- POOL_STRING_ARRAY,
- POOL_REAL_ARRAY,
- POOL_COLOR_ARRAY,
- POOL_VECTOR2_ARRAY,
- POOL_VECTOR3_ARRAY,
+ PACKED_BYTE_ARRAY,
+ PACKED_INT_ARRAY,
+ PACKED_STRING_ARRAY,
+ PACKED_REAL_ARRAY,
+ PACKED_COLOR_ARRAY,
+ PACKED_VECTOR2_ARRAY,
+ PACKED_VECTOR3_ARRAY,
NIL
};
valid_types = valid;
} break;
// arrays
- case POOL_BYTE_ARRAY: {
+ case PACKED_BYTE_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -351,7 +351,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
- case POOL_INT_ARRAY: {
+ case PACKED_INT_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -359,7 +359,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
};
valid_types = valid;
} break;
- case POOL_REAL_ARRAY: {
+ case PACKED_REAL_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -368,7 +368,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
- case POOL_STRING_ARRAY: {
+ case PACKED_STRING_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -376,7 +376,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
};
valid_types = valid;
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -385,7 +385,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -394,7 +394,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -576,20 +576,20 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
case ARRAY: {
static const Type valid[] = {
- POOL_BYTE_ARRAY,
- POOL_INT_ARRAY,
- POOL_STRING_ARRAY,
- POOL_REAL_ARRAY,
- POOL_COLOR_ARRAY,
- POOL_VECTOR2_ARRAY,
- POOL_VECTOR3_ARRAY,
+ PACKED_BYTE_ARRAY,
+ PACKED_INT_ARRAY,
+ PACKED_STRING_ARRAY,
+ PACKED_REAL_ARRAY,
+ PACKED_COLOR_ARRAY,
+ PACKED_VECTOR2_ARRAY,
+ PACKED_VECTOR3_ARRAY,
NIL
};
valid_types = valid;
} break;
// arrays
- case POOL_BYTE_ARRAY: {
+ case PACKED_BYTE_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -598,7 +598,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
- case POOL_INT_ARRAY: {
+ case PACKED_INT_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -606,7 +606,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
};
valid_types = valid;
} break;
- case POOL_REAL_ARRAY: {
+ case PACKED_REAL_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -615,7 +615,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
- case POOL_STRING_ARRAY: {
+ case PACKED_STRING_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -623,7 +623,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
};
valid_types = valid;
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -632,7 +632,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -641,7 +641,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -809,39 +809,39 @@ bool Variant::is_zero() const {
} break;
// arrays
- case POOL_BYTE_ARRAY: {
+ case PACKED_BYTE_ARRAY: {
- return reinterpret_cast<const PoolVector<uint8_t> *>(_data._mem)->size() == 0;
+ return reinterpret_cast<const Vector<uint8_t> *>(_data._mem)->size() == 0;
} break;
- case POOL_INT_ARRAY: {
+ case PACKED_INT_ARRAY: {
- return reinterpret_cast<const PoolVector<int> *>(_data._mem)->size() == 0;
+ return reinterpret_cast<const Vector<int> *>(_data._mem)->size() == 0;
} break;
- case POOL_REAL_ARRAY: {
+ case PACKED_REAL_ARRAY: {
- return reinterpret_cast<const PoolVector<real_t> *>(_data._mem)->size() == 0;
+ return reinterpret_cast<const Vector<real_t> *>(_data._mem)->size() == 0;
} break;
- case POOL_STRING_ARRAY: {
+ case PACKED_STRING_ARRAY: {
- return reinterpret_cast<const PoolVector<String> *>(_data._mem)->size() == 0;
+ return reinterpret_cast<const Vector<String> *>(_data._mem)->size() == 0;
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
- return reinterpret_cast<const PoolVector<Vector2> *>(_data._mem)->size() == 0;
+ return reinterpret_cast<const Vector<Vector2> *>(_data._mem)->size() == 0;
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
- return reinterpret_cast<const PoolVector<Vector3> *>(_data._mem)->size() == 0;
+ return reinterpret_cast<const Vector<Vector3> *>(_data._mem)->size() == 0;
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
- return reinterpret_cast<const PoolVector<Color> *>(_data._mem)->size() == 0;
+ return reinterpret_cast<const Vector<Color> *>(_data._mem)->size() == 0;
} break;
default: {
@@ -1039,39 +1039,39 @@ void Variant::reference(const Variant &p_variant) {
} break;
// arrays
- case POOL_BYTE_ARRAY: {
+ case PACKED_BYTE_ARRAY: {
- memnew_placement(_data._mem, PoolVector<uint8_t>(*reinterpret_cast<const PoolVector<uint8_t> *>(p_variant._data._mem)));
+ memnew_placement(_data._mem, Vector<uint8_t>(*reinterpret_cast<const Vector<uint8_t> *>(p_variant._data._mem)));
} break;
- case POOL_INT_ARRAY: {
+ case PACKED_INT_ARRAY: {
- memnew_placement(_data._mem, PoolVector<int>(*reinterpret_cast<const PoolVector<int> *>(p_variant._data._mem)));
+ memnew_placement(_data._mem, Vector<int>(*reinterpret_cast<const Vector<int> *>(p_variant._data._mem)));
} break;
- case POOL_REAL_ARRAY: {
+ case PACKED_REAL_ARRAY: {
- memnew_placement(_data._mem, PoolVector<real_t>(*reinterpret_cast<const PoolVector<real_t> *>(p_variant._data._mem)));
+ memnew_placement(_data._mem, Vector<real_t>(*reinterpret_cast<const Vector<real_t> *>(p_variant._data._mem)));
} break;
- case POOL_STRING_ARRAY: {
+ case PACKED_STRING_ARRAY: {
- memnew_placement(_data._mem, PoolVector<String>(*reinterpret_cast<const PoolVector<String> *>(p_variant._data._mem)));
+ memnew_placement(_data._mem, Vector<String>(*reinterpret_cast<const Vector<String> *>(p_variant._data._mem)));
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
- memnew_placement(_data._mem, PoolVector<Vector2>(*reinterpret_cast<const PoolVector<Vector2> *>(p_variant._data._mem)));
+ memnew_placement(_data._mem, Vector<Vector2>(*reinterpret_cast<const Vector<Vector2> *>(p_variant._data._mem)));
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
- memnew_placement(_data._mem, PoolVector<Vector3>(*reinterpret_cast<const PoolVector<Vector3> *>(p_variant._data._mem)));
+ memnew_placement(_data._mem, Vector<Vector3>(*reinterpret_cast<const Vector<Vector3> *>(p_variant._data._mem)));
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
- memnew_placement(_data._mem, PoolVector<Color>(*reinterpret_cast<const PoolVector<Color> *>(p_variant._data._mem)));
+ memnew_placement(_data._mem, Vector<Color>(*reinterpret_cast<const Vector<Color> *>(p_variant._data._mem)));
} break;
default: {
@@ -1158,33 +1158,33 @@ void Variant::clear() {
reinterpret_cast<Array *>(_data._mem)->~Array();
} break;
// arrays
- case POOL_BYTE_ARRAY: {
+ case PACKED_BYTE_ARRAY: {
- reinterpret_cast<PoolVector<uint8_t> *>(_data._mem)->~PoolVector<uint8_t>();
+ reinterpret_cast<Vector<uint8_t> *>(_data._mem)->~Vector<uint8_t>();
} break;
- case POOL_INT_ARRAY: {
+ case PACKED_INT_ARRAY: {
- reinterpret_cast<PoolVector<int> *>(_data._mem)->~PoolVector<int>();
+ reinterpret_cast<Vector<int> *>(_data._mem)->~Vector<int>();
} break;
- case POOL_REAL_ARRAY: {
+ case PACKED_REAL_ARRAY: {
- reinterpret_cast<PoolVector<real_t> *>(_data._mem)->~PoolVector<real_t>();
+ reinterpret_cast<Vector<real_t> *>(_data._mem)->~Vector<real_t>();
} break;
- case POOL_STRING_ARRAY: {
+ case PACKED_STRING_ARRAY: {
- reinterpret_cast<PoolVector<String> *>(_data._mem)->~PoolVector<String>();
+ reinterpret_cast<Vector<String> *>(_data._mem)->~Vector<String>();
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
- reinterpret_cast<PoolVector<Vector2> *>(_data._mem)->~PoolVector<Vector2>();
+ reinterpret_cast<Vector<Vector2> *>(_data._mem)->~Vector<Vector2>();
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
- reinterpret_cast<PoolVector<Vector3> *>(_data._mem)->~PoolVector<Vector3>();
+ reinterpret_cast<Vector<Vector3> *>(_data._mem)->~Vector<Vector3>();
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
- reinterpret_cast<PoolVector<Color> *>(_data._mem)->~PoolVector<Color>();
+ reinterpret_cast<Vector<Color> *>(_data._mem)->~Vector<Color>();
} break;
default: {
} /* not needed */
@@ -1529,9 +1529,9 @@ String Variant::stringify(List<const void *> &stack) const {
return str;
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
- PoolVector<Vector2> vec = operator PoolVector<Vector2>();
+ Vector<Vector2> vec = operator Vector<Vector2>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
@@ -1542,9 +1542,9 @@ String Variant::stringify(List<const void *> &stack) const {
str += "]";
return str;
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
- PoolVector<Vector3> vec = operator PoolVector<Vector3>();
+ Vector<Vector3> vec = operator Vector<Vector3>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
@@ -1555,9 +1555,9 @@ String Variant::stringify(List<const void *> &stack) const {
str += "]";
return str;
} break;
- case POOL_STRING_ARRAY: {
+ case PACKED_STRING_ARRAY: {
- PoolVector<String> vec = operator PoolVector<String>();
+ Vector<String> vec = operator Vector<String>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
@@ -1568,9 +1568,9 @@ String Variant::stringify(List<const void *> &stack) const {
str += "]";
return str;
} break;
- case POOL_INT_ARRAY: {
+ case PACKED_INT_ARRAY: {
- PoolVector<int> vec = operator PoolVector<int>();
+ Vector<int> vec = operator Vector<int>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
@@ -1581,9 +1581,9 @@ String Variant::stringify(List<const void *> &stack) const {
str += "]";
return str;
} break;
- case POOL_REAL_ARRAY: {
+ case PACKED_REAL_ARRAY: {
- PoolVector<real_t> vec = operator PoolVector<real_t>();
+ Vector<real_t> vec = operator Vector<real_t>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
@@ -1858,26 +1858,26 @@ inline DA _convert_array_from_variant(const Variant &p_variant) {
case Variant::ARRAY: {
return _convert_array<DA, Array>(p_variant.operator Array());
}
- case Variant::POOL_BYTE_ARRAY: {
- return _convert_array<DA, PoolVector<uint8_t> >(p_variant.operator PoolVector<uint8_t>());
+ case Variant::PACKED_BYTE_ARRAY: {
+ return _convert_array<DA, Vector<uint8_t> >(p_variant.operator Vector<uint8_t>());
}
- case Variant::POOL_INT_ARRAY: {
- return _convert_array<DA, PoolVector<int> >(p_variant.operator PoolVector<int>());
+ case Variant::PACKED_INT_ARRAY: {
+ return _convert_array<DA, Vector<int> >(p_variant.operator Vector<int>());
}
- case Variant::POOL_REAL_ARRAY: {
- return _convert_array<DA, PoolVector<real_t> >(p_variant.operator PoolVector<real_t>());
+ case Variant::PACKED_REAL_ARRAY: {
+ return _convert_array<DA, Vector<real_t> >(p_variant.operator Vector<real_t>());
}
- case Variant::POOL_STRING_ARRAY: {
- return _convert_array<DA, PoolVector<String> >(p_variant.operator PoolVector<String>());
+ case Variant::PACKED_STRING_ARRAY: {
+ return _convert_array<DA, Vector<String> >(p_variant.operator Vector<String>());
}
- case Variant::POOL_VECTOR2_ARRAY: {
- return _convert_array<DA, PoolVector<Vector2> >(p_variant.operator PoolVector<Vector2>());
+ case Variant::PACKED_VECTOR2_ARRAY: {
+ return _convert_array<DA, Vector<Vector2> >(p_variant.operator Vector<Vector2>());
}
- case Variant::POOL_VECTOR3_ARRAY: {
- return _convert_array<DA, PoolVector<Vector3> >(p_variant.operator PoolVector<Vector3>());
+ case Variant::PACKED_VECTOR3_ARRAY: {
+ return _convert_array<DA, Vector<Vector3> >(p_variant.operator Vector<Vector3>());
}
- case Variant::POOL_COLOR_ARRAY: {
- return _convert_array<DA, PoolVector<Color> >(p_variant.operator PoolVector<Color>());
+ case Variant::PACKED_COLOR_ARRAY: {
+ return _convert_array<DA, Vector<Color> >(p_variant.operator Vector<Color>());
}
default: {
return DA();
@@ -1893,56 +1893,56 @@ Variant::operator Array() const {
return _convert_array_from_variant<Array>(*this);
}
-Variant::operator PoolVector<uint8_t>() const {
+Variant::operator Vector<uint8_t>() const {
- if (type == POOL_BYTE_ARRAY)
- return *reinterpret_cast<const PoolVector<uint8_t> *>(_data._mem);
+ if (type == PACKED_BYTE_ARRAY)
+ return *reinterpret_cast<const Vector<uint8_t> *>(_data._mem);
else
- return _convert_array_from_variant<PoolVector<uint8_t> >(*this);
+ return _convert_array_from_variant<Vector<uint8_t> >(*this);
}
-Variant::operator PoolVector<int>() const {
+Variant::operator Vector<int>() const {
- if (type == POOL_INT_ARRAY)
- return *reinterpret_cast<const PoolVector<int> *>(_data._mem);
+ if (type == PACKED_INT_ARRAY)
+ return *reinterpret_cast<const Vector<int> *>(_data._mem);
else
- return _convert_array_from_variant<PoolVector<int> >(*this);
+ return _convert_array_from_variant<Vector<int> >(*this);
}
-Variant::operator PoolVector<real_t>() const {
+Variant::operator Vector<real_t>() const {
- if (type == POOL_REAL_ARRAY)
- return *reinterpret_cast<const PoolVector<real_t> *>(_data._mem);
+ if (type == PACKED_REAL_ARRAY)
+ return *reinterpret_cast<const Vector<real_t> *>(_data._mem);
else
- return _convert_array_from_variant<PoolVector<real_t> >(*this);
+ return _convert_array_from_variant<Vector<real_t> >(*this);
}
-Variant::operator PoolVector<String>() const {
+Variant::operator Vector<String>() const {
- if (type == POOL_STRING_ARRAY)
- return *reinterpret_cast<const PoolVector<String> *>(_data._mem);
+ if (type == PACKED_STRING_ARRAY)
+ return *reinterpret_cast<const Vector<String> *>(_data._mem);
else
- return _convert_array_from_variant<PoolVector<String> >(*this);
+ return _convert_array_from_variant<Vector<String> >(*this);
}
-Variant::operator PoolVector<Vector3>() const {
+Variant::operator Vector<Vector3>() const {
- if (type == POOL_VECTOR3_ARRAY)
- return *reinterpret_cast<const PoolVector<Vector3> *>(_data._mem);
+ if (type == PACKED_VECTOR3_ARRAY)
+ return *reinterpret_cast<const Vector<Vector3> *>(_data._mem);
else
- return _convert_array_from_variant<PoolVector<Vector3> >(*this);
+ return _convert_array_from_variant<Vector<Vector3> >(*this);
}
-Variant::operator PoolVector<Vector2>() const {
+Variant::operator Vector<Vector2>() const {
- if (type == POOL_VECTOR2_ARRAY)
- return *reinterpret_cast<const PoolVector<Vector2> *>(_data._mem);
+ if (type == PACKED_VECTOR2_ARRAY)
+ return *reinterpret_cast<const Vector<Vector2> *>(_data._mem);
else
- return _convert_array_from_variant<PoolVector<Vector2> >(*this);
+ return _convert_array_from_variant<Vector<Vector2> >(*this);
}
-Variant::operator PoolVector<Color>() const {
+Variant::operator Vector<Color>() const {
- if (type == POOL_COLOR_ARRAY)
- return *reinterpret_cast<const PoolVector<Color> *>(_data._mem);
+ if (type == PACKED_COLOR_ARRAY)
+ return *reinterpret_cast<const Vector<Color> *>(_data._mem);
else
- return _convert_array_from_variant<PoolVector<Color> >(*this);
+ return _convert_array_from_variant<Vector<Color> >(*this);
}
/* helpers */
@@ -1957,33 +1957,16 @@ Variant::operator Vector<RID>() const {
return rids;
}
-Variant::operator Vector<Vector2>() const {
-
- PoolVector<Vector2> from = operator PoolVector<Vector2>();
- Vector<Vector2> to;
- int len = from.size();
- if (len == 0)
- return Vector<Vector2>();
- to.resize(len);
- PoolVector<Vector2>::Read r = from.read();
- Vector2 *w = to.ptrw();
- for (int i = 0; i < len; i++) {
-
- w[i] = r[i];
- }
- return to;
-}
-
-Variant::operator PoolVector<Plane>() const {
+Variant::operator Vector<Plane>() const {
Array va = operator Array();
- PoolVector<Plane> planes;
+ Vector<Plane> planes;
int va_size = va.size();
if (va_size == 0)
return planes;
planes.resize(va_size);
- PoolVector<Plane>::Write w = planes.write();
+ Plane *w = planes.ptrw();
for (int i = 0; i < va_size; i++)
w[i] = va[i];
@@ -1991,17 +1974,17 @@ Variant::operator PoolVector<Plane>() const {
return planes;
}
-Variant::operator PoolVector<Face3>() const {
+Variant::operator Vector<Face3>() const {
- PoolVector<Vector3> va = operator PoolVector<Vector3>();
- PoolVector<Face3> faces;
+ Vector<Vector3> va = operator Vector<Vector3>();
+ Vector<Face3> faces;
int va_size = va.size();
if (va_size == 0)
return faces;
faces.resize(va_size / 3);
- PoolVector<Face3>::Write w = faces.write();
- PoolVector<Vector3>::Read r = va.read();
+ Face3 *w = faces.ptrw();
+ const Vector3 *r = va.ptr();
for (int i = 0; i < va_size; i++)
w[i / 3].vertex[i % 3] = r[i];
@@ -2009,87 +1992,24 @@ Variant::operator PoolVector<Face3>() const {
return faces;
}
-Variant::operator Vector<Plane>() const {
+Variant::operator Vector<Variant>() const {
Array va = operator Array();
- Vector<Plane> planes;
+ Vector<Variant> variants;
int va_size = va.size();
if (va_size == 0)
- return planes;
-
- planes.resize(va_size);
+ return variants;
+ variants.resize(va_size);
+ Variant *w = variants.ptrw();
for (int i = 0; i < va_size; i++)
- planes.write[i] = va[i];
+ w[i] = variants[i];
- return planes;
-}
-
-Variant::operator Vector<Variant>() const {
-
- Array from = operator Array();
- Vector<Variant> to;
- int len = from.size();
- to.resize(len);
- for (int i = 0; i < len; i++) {
-
- to.write[i] = from[i];
- }
- return to;
-}
-
-Variant::operator Vector<uint8_t>() const {
-
- PoolVector<uint8_t> from = operator PoolVector<uint8_t>();
- Vector<uint8_t> to;
- int len = from.size();
- to.resize(len);
- for (int i = 0; i < len; i++) {
-
- to.write[i] = from[i];
- }
- return to;
-}
-Variant::operator Vector<int>() const {
-
- PoolVector<int> from = operator PoolVector<int>();
- Vector<int> to;
- int len = from.size();
- to.resize(len);
- for (int i = 0; i < len; i++) {
-
- to.write[i] = from[i];
- }
- return to;
-}
-Variant::operator Vector<real_t>() const {
-
- PoolVector<real_t> from = operator PoolVector<real_t>();
- Vector<real_t> to;
- int len = from.size();
- to.resize(len);
- for (int i = 0; i < len; i++) {
-
- to.write[i] = from[i];
- }
- return to;
-}
-
-Variant::operator Vector<String>() const {
-
- PoolVector<String> from = operator PoolVector<String>();
- Vector<String> to;
- int len = from.size();
- to.resize(len);
- for (int i = 0; i < len; i++) {
-
- to.write[i] = from[i];
- }
- return to;
+ return variants;
}
Variant::operator Vector<StringName>() const {
- PoolVector<String> from = operator PoolVector<String>();
+ Vector<String> from = operator Vector<String>();
Vector<StringName> to;
int len = from.size();
to.resize(len);
@@ -2100,39 +2020,6 @@ Variant::operator Vector<StringName>() const {
return to;
}
-Variant::operator Vector<Vector3>() const {
-
- PoolVector<Vector3> from = operator PoolVector<Vector3>();
- Vector<Vector3> to;
- int len = from.size();
- if (len == 0)
- return Vector<Vector3>();
- to.resize(len);
- PoolVector<Vector3>::Read r = from.read();
- Vector3 *w = to.ptrw();
- for (int i = 0; i < len; i++) {
-
- w[i] = r[i];
- }
- return to;
-}
-Variant::operator Vector<Color>() const {
-
- PoolVector<Color> from = operator PoolVector<Color>();
- Vector<Color> to;
- int len = from.size();
- if (len == 0)
- return Vector<Color>();
- to.resize(len);
- PoolVector<Color>::Read r = from.read();
- Color *w = to.ptrw();
- for (int i = 0; i < len; i++) {
-
- w[i] = r[i];
- }
- return to;
-}
-
Variant::operator Margin() const {
return (Margin) operator int();
@@ -2144,9 +2031,9 @@ Variant::operator Orientation() const {
Variant::operator IP_Address() const {
- if (type == POOL_REAL_ARRAY || type == POOL_INT_ARRAY || type == POOL_BYTE_ARRAY) {
+ if (type == PACKED_REAL_ARRAY || type == PACKED_INT_ARRAY || type == PACKED_BYTE_ARRAY) {
- PoolVector<int> addr = operator PoolVector<int>();
+ Vector<int> addr = operator Vector<int>();
if (addr.size() == 4) {
return IP_Address(addr.get(0), addr.get(1), addr.get(2), addr.get(3));
}
@@ -2368,20 +2255,6 @@ Variant::Variant(const Array &p_array) {
memnew_placement(_data._mem, Array(p_array));
}
-Variant::Variant(const PoolVector<Plane> &p_array) {
-
- type = ARRAY;
-
- Array *plane_array = memnew_placement(_data._mem, Array);
-
- plane_array->resize(p_array.size());
-
- for (int i = 0; i < p_array.size(); i++) {
-
- plane_array->operator[](i) = Variant(p_array[i]);
- }
-}
-
Variant::Variant(const Vector<Plane> &p_array) {
type = ARRAY;
@@ -2410,68 +2283,52 @@ Variant::Variant(const Vector<RID> &p_array) {
}
}
-Variant::Variant(const Vector<Vector2> &p_array) {
-
- type = NIL;
- PoolVector<Vector2> v;
- int len = p_array.size();
- if (len > 0) {
- v.resize(len);
- PoolVector<Vector2>::Write w = v.write();
- const Vector2 *r = p_array.ptr();
+Variant::Variant(const Vector<uint8_t> &p_raw_array) {
- for (int i = 0; i < len; i++)
- w[i] = r[i];
- }
- *this = v;
-}
-
-Variant::Variant(const PoolVector<uint8_t> &p_raw_array) {
-
- type = POOL_BYTE_ARRAY;
- memnew_placement(_data._mem, PoolVector<uint8_t>(p_raw_array));
+ type = PACKED_BYTE_ARRAY;
+ memnew_placement(_data._mem, Vector<uint8_t>(p_raw_array));
}
-Variant::Variant(const PoolVector<int> &p_int_array) {
+Variant::Variant(const Vector<int> &p_int_array) {
- type = POOL_INT_ARRAY;
- memnew_placement(_data._mem, PoolVector<int>(p_int_array));
+ type = PACKED_INT_ARRAY;
+ memnew_placement(_data._mem, Vector<int>(p_int_array));
}
-Variant::Variant(const PoolVector<real_t> &p_real_array) {
+Variant::Variant(const Vector<real_t> &p_real_array) {
- type = POOL_REAL_ARRAY;
- memnew_placement(_data._mem, PoolVector<real_t>(p_real_array));
+ type = PACKED_REAL_ARRAY;
+ memnew_placement(_data._mem, Vector<real_t>(p_real_array));
}
-Variant::Variant(const PoolVector<String> &p_string_array) {
+Variant::Variant(const Vector<String> &p_string_array) {
- type = POOL_STRING_ARRAY;
- memnew_placement(_data._mem, PoolVector<String>(p_string_array));
+ type = PACKED_STRING_ARRAY;
+ memnew_placement(_data._mem, Vector<String>(p_string_array));
}
-Variant::Variant(const PoolVector<Vector3> &p_vector3_array) {
+Variant::Variant(const Vector<Vector3> &p_vector3_array) {
- type = POOL_VECTOR3_ARRAY;
- memnew_placement(_data._mem, PoolVector<Vector3>(p_vector3_array));
+ type = PACKED_VECTOR3_ARRAY;
+ memnew_placement(_data._mem, Vector<Vector3>(p_vector3_array));
}
-Variant::Variant(const PoolVector<Vector2> &p_vector2_array) {
+Variant::Variant(const Vector<Vector2> &p_vector2_array) {
- type = POOL_VECTOR2_ARRAY;
- memnew_placement(_data._mem, PoolVector<Vector2>(p_vector2_array));
+ type = PACKED_VECTOR2_ARRAY;
+ memnew_placement(_data._mem, Vector<Vector2>(p_vector2_array));
}
-Variant::Variant(const PoolVector<Color> &p_color_array) {
+Variant::Variant(const Vector<Color> &p_color_array) {
- type = POOL_COLOR_ARRAY;
- memnew_placement(_data._mem, PoolVector<Color>(p_color_array));
+ type = PACKED_COLOR_ARRAY;
+ memnew_placement(_data._mem, Vector<Color>(p_color_array));
}
-Variant::Variant(const PoolVector<Face3> &p_face_array) {
+Variant::Variant(const Vector<Face3> &p_face_array) {
- PoolVector<Vector3> vertices;
+ Vector<Vector3> vertices;
int face_count = p_face_array.size();
vertices.resize(face_count * 3);
if (face_count) {
- PoolVector<Face3>::Read r = p_face_array.read();
- PoolVector<Vector3>::Write w = vertices.write();
+ const Face3 *r = p_face_array.ptr();
+ Vector3 *w = vertices.ptrw();
for (int i = 0; i < face_count; i++) {
@@ -2486,93 +2343,20 @@ Variant::Variant(const PoolVector<Face3> &p_face_array) {
}
/* helpers */
-
Variant::Variant(const Vector<Variant> &p_array) {
-
- type = NIL;
- Array v;
- int len = p_array.size();
- v.resize(len);
- for (int i = 0; i < len; i++)
- v.set(i, p_array[i]);
- *this = v;
-}
-
-Variant::Variant(const Vector<uint8_t> &p_array) {
-
- type = NIL;
- PoolVector<uint8_t> v;
- int len = p_array.size();
- v.resize(len);
- for (int i = 0; i < len; i++)
- v.set(i, p_array[i]);
- *this = v;
-}
-
-Variant::Variant(const Vector<int> &p_array) {
-
- type = NIL;
- PoolVector<int> v;
- int len = p_array.size();
- v.resize(len);
- for (int i = 0; i < len; i++)
- v.set(i, p_array[i]);
- *this = v;
-}
-
-Variant::Variant(const Vector<real_t> &p_array) {
-
type = NIL;
- PoolVector<real_t> v;
- int len = p_array.size();
- v.resize(len);
- for (int i = 0; i < len; i++)
- v.set(i, p_array[i]);
- *this = v;
-}
-
-Variant::Variant(const Vector<String> &p_array) {
-
- type = NIL;
- PoolVector<String> v;
- int len = p_array.size();
- v.resize(len);
- for (int i = 0; i < len; i++)
- v.set(i, p_array[i]);
- *this = v;
-}
-
-Variant::Variant(const Vector<StringName> &p_array) {
-
- type = NIL;
- PoolVector<String> v;
- int len = p_array.size();
- v.resize(len);
- for (int i = 0; i < len; i++)
- v.set(i, p_array[i]);
- *this = v;
-}
-
-Variant::Variant(const Vector<Vector3> &p_array) {
-
- type = NIL;
- PoolVector<Vector3> v;
- int len = p_array.size();
- if (len > 0) {
- v.resize(len);
- PoolVector<Vector3>::Write w = v.write();
- const Vector3 *r = p_array.ptr();
-
- for (int i = 0; i < len; i++)
- w[i] = r[i];
+ Array arr;
+ arr.resize(p_array.size());
+ for (int i = 0; i < p_array.size(); i++) {
+ arr[i] = p_array[i];
}
- *this = v;
+ *this = arr;
}
-Variant::Variant(const Vector<Color> &p_array) {
+Variant::Variant(const Vector<StringName> &p_array) {
type = NIL;
- PoolVector<Color> v;
+ Vector<String> v;
int len = p_array.size();
v.resize(len);
for (int i = 0; i < len; i++)
@@ -2699,33 +2483,33 @@ void Variant::operator=(const Variant &p_variant) {
} break;
// arrays
- case POOL_BYTE_ARRAY: {
+ case PACKED_BYTE_ARRAY: {
- *reinterpret_cast<PoolVector<uint8_t> *>(_data._mem) = *reinterpret_cast<const PoolVector<uint8_t> *>(p_variant._data._mem);
+ *reinterpret_cast<Vector<uint8_t> *>(_data._mem) = *reinterpret_cast<const Vector<uint8_t> *>(p_variant._data._mem);
} break;
- case POOL_INT_ARRAY: {
+ case PACKED_INT_ARRAY: {
- *reinterpret_cast<PoolVector<int> *>(_data._mem) = *reinterpret_cast<const PoolVector<int> *>(p_variant._data._mem);
+ *reinterpret_cast<Vector<int> *>(_data._mem) = *reinterpret_cast<const Vector<int> *>(p_variant._data._mem);
} break;
- case POOL_REAL_ARRAY: {
+ case PACKED_REAL_ARRAY: {
- *reinterpret_cast<PoolVector<real_t> *>(_data._mem) = *reinterpret_cast<const PoolVector<real_t> *>(p_variant._data._mem);
+ *reinterpret_cast<Vector<real_t> *>(_data._mem) = *reinterpret_cast<const Vector<real_t> *>(p_variant._data._mem);
} break;
- case POOL_STRING_ARRAY: {
+ case PACKED_STRING_ARRAY: {
- *reinterpret_cast<PoolVector<String> *>(_data._mem) = *reinterpret_cast<const PoolVector<String> *>(p_variant._data._mem);
+ *reinterpret_cast<Vector<String> *>(_data._mem) = *reinterpret_cast<const Vector<String> *>(p_variant._data._mem);
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
- *reinterpret_cast<PoolVector<Vector2> *>(_data._mem) = *reinterpret_cast<const PoolVector<Vector2> *>(p_variant._data._mem);
+ *reinterpret_cast<Vector<Vector2> *>(_data._mem) = *reinterpret_cast<const Vector<Vector2> *>(p_variant._data._mem);
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
- *reinterpret_cast<PoolVector<Vector3> *>(_data._mem) = *reinterpret_cast<const PoolVector<Vector3> *>(p_variant._data._mem);
+ *reinterpret_cast<Vector<Vector3> *>(_data._mem) = *reinterpret_cast<const Vector<Vector3> *>(p_variant._data._mem);
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
- *reinterpret_cast<PoolVector<Color> *>(_data._mem) = *reinterpret_cast<const PoolVector<Color> *>(p_variant._data._mem);
+ *reinterpret_cast<Vector<Color> *>(_data._mem) = *reinterpret_cast<const Vector<Color> *>(p_variant._data._mem);
} break;
default: {
}
@@ -2898,51 +2682,51 @@ uint32_t Variant::hash() const {
return arr.hash();
} break;
- case POOL_BYTE_ARRAY: {
+ case PACKED_BYTE_ARRAY: {
- const PoolVector<uint8_t> &arr = *reinterpret_cast<const PoolVector<uint8_t> *>(_data._mem);
+ const Vector<uint8_t> &arr = *reinterpret_cast<const Vector<uint8_t> *>(_data._mem);
int len = arr.size();
if (likely(len)) {
- PoolVector<uint8_t>::Read r = arr.read();
+ const uint8_t *r = arr.ptr();
return hash_djb2_buffer((uint8_t *)&r[0], len);
} else {
return hash_djb2_one_64(0);
}
} break;
- case POOL_INT_ARRAY: {
+ case PACKED_INT_ARRAY: {
- const PoolVector<int> &arr = *reinterpret_cast<const PoolVector<int> *>(_data._mem);
+ const Vector<int> &arr = *reinterpret_cast<const Vector<int> *>(_data._mem);
int len = arr.size();
if (likely(len)) {
- PoolVector<int>::Read r = arr.read();
+ const int *r = arr.ptr();
return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(int));
} else {
return hash_djb2_one_64(0);
}
} break;
- case POOL_REAL_ARRAY: {
+ case PACKED_REAL_ARRAY: {
- const PoolVector<real_t> &arr = *reinterpret_cast<const PoolVector<real_t> *>(_data._mem);
+ const Vector<real_t> &arr = *reinterpret_cast<const Vector<real_t> *>(_data._mem);
int len = arr.size();
if (likely(len)) {
- PoolVector<real_t>::Read r = arr.read();
+ const real_t *r = arr.ptr();
return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(real_t));
} else {
return hash_djb2_one_float(0.0);
}
} break;
- case POOL_STRING_ARRAY: {
+ case PACKED_STRING_ARRAY: {
uint32_t hash = 5831;
- const PoolVector<String> &arr = *reinterpret_cast<const PoolVector<String> *>(_data._mem);
+ const Vector<String> &arr = *reinterpret_cast<const Vector<String> *>(_data._mem);
int len = arr.size();
if (likely(len)) {
- PoolVector<String>::Read r = arr.read();
+ const String *r = arr.ptr();
for (int i = 0; i < len; i++) {
hash = hash_djb2_one_32(r[i].hash(), hash);
@@ -2951,14 +2735,14 @@ uint32_t Variant::hash() const {
return hash;
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
uint32_t hash = 5831;
- const PoolVector<Vector2> &arr = *reinterpret_cast<const PoolVector<Vector2> *>(_data._mem);
+ const Vector<Vector2> &arr = *reinterpret_cast<const Vector<Vector2> *>(_data._mem);
int len = arr.size();
if (likely(len)) {
- PoolVector<Vector2>::Read r = arr.read();
+ const Vector2 *r = arr.ptr();
for (int i = 0; i < len; i++) {
hash = hash_djb2_one_float(r[i].x, hash);
@@ -2968,14 +2752,14 @@ uint32_t Variant::hash() const {
return hash;
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
uint32_t hash = 5831;
- const PoolVector<Vector3> &arr = *reinterpret_cast<const PoolVector<Vector3> *>(_data._mem);
+ const Vector<Vector3> &arr = *reinterpret_cast<const Vector<Vector3> *>(_data._mem);
int len = arr.size();
if (likely(len)) {
- PoolVector<Vector3>::Read r = arr.read();
+ const Vector3 *r = arr.ptr();
for (int i = 0; i < len; i++) {
hash = hash_djb2_one_float(r[i].x, hash);
@@ -2986,14 +2770,14 @@ uint32_t Variant::hash() const {
return hash;
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
uint32_t hash = 5831;
- const PoolVector<Color> &arr = *reinterpret_cast<const PoolVector<Color> *>(_data._mem);
+ const Vector<Color> &arr = *reinterpret_cast<const Vector<Color> *>(_data._mem);
int len = arr.size();
if (likely(len)) {
- PoolVector<Color>::Read r = arr.read();
+ const Color *r = arr.ptr();
for (int i = 0; i < len; i++) {
hash = hash_djb2_one_float(r[i].r, hash);
@@ -3036,21 +2820,21 @@ uint32_t Variant::hash() const {
(hash_compare_scalar((p_lhs).b, (p_rhs).b)) && \
(hash_compare_scalar((p_lhs).a, (p_rhs).a))
-#define hash_compare_pool_array(p_lhs, p_rhs, p_type, p_compare_func) \
- const PoolVector<p_type> &l = *reinterpret_cast<const PoolVector<p_type> *>(p_lhs); \
- const PoolVector<p_type> &r = *reinterpret_cast<const PoolVector<p_type> *>(p_rhs); \
- \
- if (l.size() != r.size()) \
- return false; \
- \
- PoolVector<p_type>::Read lr = l.read(); \
- PoolVector<p_type>::Read rr = r.read(); \
- \
- for (int i = 0; i < l.size(); ++i) { \
- if (!p_compare_func((lr[i]), (rr[i]))) \
- return false; \
- } \
- \
+#define hash_compare_pool_array(p_lhs, p_rhs, p_type, p_compare_func) \
+ const Vector<p_type> &l = *reinterpret_cast<const Vector<p_type> *>(p_lhs); \
+ const Vector<p_type> &r = *reinterpret_cast<const Vector<p_type> *>(p_rhs); \
+ \
+ if (l.size() != r.size()) \
+ return false; \
+ \
+ const p_type *lr = l.ptr(); \
+ const p_type *rr = r.ptr(); \
+ \
+ for (int i = 0; i < l.size(); ++i) { \
+ if (!p_compare_func((lr[i]), (rr[i]))) \
+ return false; \
+ } \
+ \
return true
bool Variant::hash_compare(const Variant &p_variant) const {
@@ -3166,19 +2950,19 @@ bool Variant::hash_compare(const Variant &p_variant) const {
return true;
} break;
- case POOL_REAL_ARRAY: {
+ case PACKED_REAL_ARRAY: {
hash_compare_pool_array(_data._mem, p_variant._data._mem, real_t, hash_compare_scalar);
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector2, hash_compare_vector2);
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector3, hash_compare_vector3);
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
hash_compare_pool_array(_data._mem, p_variant._data._mem, Color, hash_compare_color);
} break;
diff --git a/core/variant.h b/core/variant.h
index bb3840932d..51f23b4b49 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -45,7 +45,7 @@
#include "core/math/vector3.h"
#include "core/node_path.h"
#include "core/object_id.h"
-#include "core/pool_vector.h"
+
#include "core/rid.h"
#include "core/ustring.h"
@@ -56,13 +56,13 @@ class Control; // helper
struct PropertyInfo;
struct MethodInfo;
-typedef PoolVector<uint8_t> PoolByteArray;
-typedef PoolVector<int> PoolIntArray;
-typedef PoolVector<real_t> PoolRealArray;
-typedef PoolVector<String> PoolStringArray;
-typedef PoolVector<Vector2> PoolVector2Array;
-typedef PoolVector<Vector3> PoolVector3Array;
-typedef PoolVector<Color> PoolColorArray;
+typedef Vector<uint8_t> PackedByteArray;
+typedef Vector<int> PackedIntArray;
+typedef Vector<real_t> PackedRealArray;
+typedef Vector<String> PackedStringArray;
+typedef Vector<Vector2> PackedVector2Array;
+typedef Vector<Vector3> PackedVector3Array;
+typedef Vector<Color> PackedColorArray;
// Temporary workaround until c++11 alignas()
#ifdef __GNUC__
@@ -105,13 +105,13 @@ public:
ARRAY,
// arrays
- POOL_BYTE_ARRAY, // 20
- POOL_INT_ARRAY,
- POOL_REAL_ARRAY,
- POOL_STRING_ARRAY,
- POOL_VECTOR2_ARRAY,
- POOL_VECTOR3_ARRAY, // 25
- POOL_COLOR_ARRAY,
+ PACKED_BYTE_ARRAY, // 20
+ PACKED_INT_ARRAY,
+ PACKED_REAL_ARRAY,
+ PACKED_STRING_ARRAY,
+ PACKED_VECTOR2_ARRAY,
+ PACKED_VECTOR3_ARRAY, // 25
+ PACKED_COLOR_ARRAY,
VARIANT_MAX
@@ -205,27 +205,19 @@ public:
operator Dictionary() const;
operator Array() const;
- operator PoolVector<uint8_t>() const;
- operator PoolVector<int>() const;
- operator PoolVector<real_t>() const;
- operator PoolVector<String>() const;
- operator PoolVector<Vector3>() const;
- operator PoolVector<Color>() const;
- operator PoolVector<Plane>() const;
- operator PoolVector<Face3>() const;
-
- operator Vector<Variant>() const;
operator Vector<uint8_t>() const;
operator Vector<int>() const;
operator Vector<real_t>() const;
operator Vector<String>() const;
- operator Vector<StringName>() const;
operator Vector<Vector3>() const;
operator Vector<Color>() const;
+ operator Vector<Plane>() const;
+ operator Vector<Face3>() const;
+
+ operator Vector<Variant>() const;
+ operator Vector<StringName>() const;
operator Vector<RID>() const;
operator Vector<Vector2>() const;
- operator PoolVector<Vector2>() const;
- operator Vector<Plane>() const;
// some core type enums to convert to
operator Margin() const;
@@ -273,27 +265,19 @@ public:
Variant(const Dictionary &p_dictionary);
Variant(const Array &p_array);
- Variant(const PoolVector<Plane> &p_array); // helper
- Variant(const PoolVector<uint8_t> &p_raw_array);
- Variant(const PoolVector<int> &p_int_array);
- Variant(const PoolVector<real_t> &p_real_array);
- Variant(const PoolVector<String> &p_string_array);
- Variant(const PoolVector<Vector3> &p_vector3_array);
- Variant(const PoolVector<Color> &p_color_array);
- Variant(const PoolVector<Face3> &p_face_array);
+ Variant(const Vector<Plane> &p_array); // helper
+ Variant(const Vector<uint8_t> &p_raw_array);
+ Variant(const Vector<int> &p_int_array);
+ Variant(const Vector<real_t> &p_real_array);
+ Variant(const Vector<String> &p_string_array);
+ Variant(const Vector<Vector3> &p_vector3_array);
+ Variant(const Vector<Color> &p_color_array);
+ Variant(const Vector<Face3> &p_face_array);
Variant(const Vector<Variant> &p_array);
- Variant(const Vector<uint8_t> &p_array);
- Variant(const Vector<int> &p_array);
- Variant(const Vector<real_t> &p_array);
- Variant(const Vector<String> &p_array);
Variant(const Vector<StringName> &p_array);
- Variant(const Vector<Vector3> &p_array);
- Variant(const Vector<Color> &p_array);
- Variant(const Vector<Plane> &p_array); // helper
Variant(const Vector<RID> &p_array); // helper
Variant(const Vector<Vector2> &p_array); // helper
- Variant(const PoolVector<Vector2> &p_vector2_array); // helper
Variant(const IP_Address &p_address);
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index ac995d1c78..6506da58d4 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -317,17 +317,16 @@ struct _VariantCall {
String *s = reinterpret_cast<String *>(p_self._data._mem);
if (s->empty()) {
- r_ret = PoolByteArray();
+ r_ret = PackedByteArray();
return;
}
CharString charstr = s->ascii();
- PoolByteArray retval;
+ PackedByteArray retval;
size_t len = charstr.length();
retval.resize(len);
- PoolByteArray::Write w = retval.write();
- copymem(w.ptr(), charstr.ptr(), len);
- w.release();
+ uint8_t *w = retval.ptrw();
+ copymem(w, charstr.ptr(), len);
r_ret = retval;
}
@@ -336,17 +335,16 @@ struct _VariantCall {
String *s = reinterpret_cast<String *>(p_self._data._mem);
if (s->empty()) {
- r_ret = PoolByteArray();
+ r_ret = PackedByteArray();
return;
}
CharString charstr = s->utf8();
- PoolByteArray retval;
+ PackedByteArray retval;
size_t len = charstr.length();
retval.resize(len);
- PoolByteArray::Write w = retval.write();
- copymem(w.ptr(), charstr.ptr(), len);
- w.release();
+ uint8_t *w = retval.ptrw();
+ copymem(w, charstr.ptr(), len);
r_ret = retval;
}
@@ -554,15 +552,15 @@ struct _VariantCall {
VCALL_LOCALMEM0R(Array, max);
VCALL_LOCALMEM0R(Array, min);
- static void _call_PoolByteArray_get_string_from_ascii(Variant &r_ret, Variant &p_self, const Variant **p_args) {
+ static void _call_PackedByteArray_get_string_from_ascii(Variant &r_ret, Variant &p_self, const Variant **p_args) {
- PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
+ PackedByteArray *ba = reinterpret_cast<PackedByteArray *>(p_self._data._mem);
String s;
if (ba->size() > 0) {
- PoolByteArray::Read r = ba->read();
+ const uint8_t *r = ba->ptr();
CharString cs;
cs.resize(ba->size() + 1);
- copymem(cs.ptrw(), r.ptr(), ba->size());
+ copymem(cs.ptrw(), r, ba->size());
cs[ba->size()] = 0;
s = cs.get_data();
@@ -570,26 +568,26 @@ struct _VariantCall {
r_ret = s;
}
- static void _call_PoolByteArray_get_string_from_utf8(Variant &r_ret, Variant &p_self, const Variant **p_args) {
+ static void _call_PackedByteArray_get_string_from_utf8(Variant &r_ret, Variant &p_self, const Variant **p_args) {
- PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
+ PackedByteArray *ba = reinterpret_cast<PackedByteArray *>(p_self._data._mem);
String s;
if (ba->size() > 0) {
- PoolByteArray::Read r = ba->read();
- s.parse_utf8((const char *)r.ptr(), ba->size());
+ const uint8_t *r = ba->ptr();
+ s.parse_utf8((const char *)r, ba->size());
}
r_ret = s;
}
- static void _call_PoolByteArray_compress(Variant &r_ret, Variant &p_self, const Variant **p_args) {
+ static void _call_PackedByteArray_compress(Variant &r_ret, Variant &p_self, const Variant **p_args) {
- PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
- PoolByteArray compressed;
+ PackedByteArray *ba = reinterpret_cast<PackedByteArray *>(p_self._data._mem);
+ PackedByteArray compressed;
if (ba->size() > 0) {
Compression::Mode mode = (Compression::Mode)(int)(*p_args[0]);
compressed.resize(Compression::get_max_compressed_buffer_size(ba->size(), mode));
- int result = Compression::compress(compressed.write().ptr(), ba->read().ptr(), ba->size(), mode);
+ int result = Compression::compress(compressed.ptrw(), ba->ptr(), ba->size(), mode);
result = result >= 0 ? result : 0;
compressed.resize(result);
@@ -597,10 +595,10 @@ struct _VariantCall {
r_ret = compressed;
}
- static void _call_PoolByteArray_decompress(Variant &r_ret, Variant &p_self, const Variant **p_args) {
+ static void _call_PackedByteArray_decompress(Variant &r_ret, Variant &p_self, const Variant **p_args) {
- PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
- PoolByteArray decompressed;
+ PackedByteArray *ba = reinterpret_cast<PackedByteArray *>(p_self._data._mem);
+ PackedByteArray decompressed;
Compression::Mode mode = (Compression::Mode)(int)(*p_args[1]);
int buffer_size = (int)(*p_args[0]);
@@ -611,7 +609,7 @@ struct _VariantCall {
}
decompressed.resize(buffer_size);
- int result = Compression::decompress(decompressed.write().ptr(), buffer_size, ba->read().ptr(), ba->size(), mode);
+ int result = Compression::decompress(decompressed.ptrw(), buffer_size, ba->ptr(), ba->size(), mode);
result = result >= 0 ? result : 0;
decompressed.resize(result);
@@ -619,102 +617,101 @@ struct _VariantCall {
r_ret = decompressed;
}
- static void _call_PoolByteArray_hex_encode(Variant &r_ret, Variant &p_self, const Variant **p_args) {
- PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
+ static void _call_PackedByteArray_hex_encode(Variant &r_ret, Variant &p_self, const Variant **p_args) {
+ PackedByteArray *ba = reinterpret_cast<PackedByteArray *>(p_self._data._mem);
if (ba->size() == 0) {
r_ret = String();
return;
}
- PoolByteArray::Read r = ba->read();
+ const uint8_t *r = ba->ptr();
String s = String::hex_encode_buffer(&r[0], ba->size());
r_ret = s;
}
- VCALL_LOCALMEM0R(PoolByteArray, size);
- VCALL_LOCALMEM0R(PoolByteArray, empty);
- VCALL_LOCALMEM2(PoolByteArray, set);
- VCALL_LOCALMEM1R(PoolByteArray, get);
- VCALL_LOCALMEM1(PoolByteArray, push_back);
- VCALL_LOCALMEM1(PoolByteArray, resize);
- VCALL_LOCALMEM2R(PoolByteArray, insert);
- VCALL_LOCALMEM1(PoolByteArray, remove);
- VCALL_LOCALMEM1(PoolByteArray, append);
- VCALL_LOCALMEM1(PoolByteArray, append_array);
- VCALL_LOCALMEM0(PoolByteArray, invert);
- VCALL_LOCALMEM2R(PoolByteArray, subarray);
-
- VCALL_LOCALMEM0R(PoolIntArray, size);
- VCALL_LOCALMEM0R(PoolIntArray, empty);
- VCALL_LOCALMEM2(PoolIntArray, set);
- VCALL_LOCALMEM1R(PoolIntArray, get);
- VCALL_LOCALMEM1(PoolIntArray, push_back);
- VCALL_LOCALMEM1(PoolIntArray, resize);
- VCALL_LOCALMEM2R(PoolIntArray, insert);
- VCALL_LOCALMEM1(PoolIntArray, remove);
- VCALL_LOCALMEM1(PoolIntArray, append);
- VCALL_LOCALMEM1(PoolIntArray, append_array);
- VCALL_LOCALMEM0(PoolIntArray, invert);
-
- VCALL_LOCALMEM0R(PoolRealArray, size);
- VCALL_LOCALMEM0R(PoolRealArray, empty);
- VCALL_LOCALMEM2(PoolRealArray, set);
- VCALL_LOCALMEM1R(PoolRealArray, get);
- VCALL_LOCALMEM1(PoolRealArray, push_back);
- VCALL_LOCALMEM1(PoolRealArray, resize);
- VCALL_LOCALMEM2R(PoolRealArray, insert);
- VCALL_LOCALMEM1(PoolRealArray, remove);
- VCALL_LOCALMEM1(PoolRealArray, append);
- VCALL_LOCALMEM1(PoolRealArray, append_array);
- VCALL_LOCALMEM0(PoolRealArray, invert);
-
- VCALL_LOCALMEM0R(PoolStringArray, size);
- VCALL_LOCALMEM0R(PoolStringArray, empty);
- VCALL_LOCALMEM2(PoolStringArray, set);
- VCALL_LOCALMEM1R(PoolStringArray, get);
- VCALL_LOCALMEM1(PoolStringArray, push_back);
- VCALL_LOCALMEM1(PoolStringArray, resize);
- VCALL_LOCALMEM2R(PoolStringArray, insert);
- VCALL_LOCALMEM1(PoolStringArray, remove);
- VCALL_LOCALMEM1(PoolStringArray, append);
- VCALL_LOCALMEM1(PoolStringArray, append_array);
- VCALL_LOCALMEM0(PoolStringArray, invert);
- VCALL_LOCALMEM1R(PoolStringArray, join);
-
- VCALL_LOCALMEM0R(PoolVector2Array, size);
- VCALL_LOCALMEM0R(PoolVector2Array, empty);
- VCALL_LOCALMEM2(PoolVector2Array, set);
- VCALL_LOCALMEM1R(PoolVector2Array, get);
- VCALL_LOCALMEM1(PoolVector2Array, push_back);
- VCALL_LOCALMEM1(PoolVector2Array, resize);
- VCALL_LOCALMEM2R(PoolVector2Array, insert);
- VCALL_LOCALMEM1(PoolVector2Array, remove);
- VCALL_LOCALMEM1(PoolVector2Array, append);
- VCALL_LOCALMEM1(PoolVector2Array, append_array);
- VCALL_LOCALMEM0(PoolVector2Array, invert);
-
- VCALL_LOCALMEM0R(PoolVector3Array, size);
- VCALL_LOCALMEM0R(PoolVector3Array, empty);
- VCALL_LOCALMEM2(PoolVector3Array, set);
- VCALL_LOCALMEM1R(PoolVector3Array, get);
- VCALL_LOCALMEM1(PoolVector3Array, push_back);
- VCALL_LOCALMEM1(PoolVector3Array, resize);
- VCALL_LOCALMEM2R(PoolVector3Array, insert);
- VCALL_LOCALMEM1(PoolVector3Array, remove);
- VCALL_LOCALMEM1(PoolVector3Array, append);
- VCALL_LOCALMEM1(PoolVector3Array, append_array);
- VCALL_LOCALMEM0(PoolVector3Array, invert);
-
- VCALL_LOCALMEM0R(PoolColorArray, size);
- VCALL_LOCALMEM0R(PoolColorArray, empty);
- VCALL_LOCALMEM2(PoolColorArray, set);
- VCALL_LOCALMEM1R(PoolColorArray, get);
- VCALL_LOCALMEM1(PoolColorArray, push_back);
- VCALL_LOCALMEM1(PoolColorArray, resize);
- VCALL_LOCALMEM2R(PoolColorArray, insert);
- VCALL_LOCALMEM1(PoolColorArray, remove);
- VCALL_LOCALMEM1(PoolColorArray, append);
- VCALL_LOCALMEM1(PoolColorArray, append_array);
- VCALL_LOCALMEM0(PoolColorArray, invert);
+ VCALL_LOCALMEM0R(PackedByteArray, size);
+ VCALL_LOCALMEM0R(PackedByteArray, empty);
+ VCALL_LOCALMEM2(PackedByteArray, set);
+ VCALL_LOCALMEM1R(PackedByteArray, get);
+ VCALL_LOCALMEM1(PackedByteArray, push_back);
+ VCALL_LOCALMEM1(PackedByteArray, resize);
+ VCALL_LOCALMEM2R(PackedByteArray, insert);
+ VCALL_LOCALMEM1(PackedByteArray, remove);
+ VCALL_LOCALMEM1(PackedByteArray, append);
+ VCALL_LOCALMEM1(PackedByteArray, append_array);
+ VCALL_LOCALMEM0(PackedByteArray, invert);
+ VCALL_LOCALMEM2R(PackedByteArray, subarray);
+
+ VCALL_LOCALMEM0R(PackedIntArray, size);
+ VCALL_LOCALMEM0R(PackedIntArray, empty);
+ VCALL_LOCALMEM2(PackedIntArray, set);
+ VCALL_LOCALMEM1R(PackedIntArray, get);
+ VCALL_LOCALMEM1(PackedIntArray, push_back);
+ VCALL_LOCALMEM1(PackedIntArray, resize);
+ VCALL_LOCALMEM2R(PackedIntArray, insert);
+ VCALL_LOCALMEM1(PackedIntArray, remove);
+ VCALL_LOCALMEM1(PackedIntArray, append);
+ VCALL_LOCALMEM1(PackedIntArray, append_array);
+ VCALL_LOCALMEM0(PackedIntArray, invert);
+
+ VCALL_LOCALMEM0R(PackedRealArray, size);
+ VCALL_LOCALMEM0R(PackedRealArray, empty);
+ VCALL_LOCALMEM2(PackedRealArray, set);
+ VCALL_LOCALMEM1R(PackedRealArray, get);
+ VCALL_LOCALMEM1(PackedRealArray, push_back);
+ VCALL_LOCALMEM1(PackedRealArray, resize);
+ VCALL_LOCALMEM2R(PackedRealArray, insert);
+ VCALL_LOCALMEM1(PackedRealArray, remove);
+ VCALL_LOCALMEM1(PackedRealArray, append);
+ VCALL_LOCALMEM1(PackedRealArray, append_array);
+ VCALL_LOCALMEM0(PackedRealArray, invert);
+
+ VCALL_LOCALMEM0R(PackedStringArray, size);
+ VCALL_LOCALMEM0R(PackedStringArray, empty);
+ VCALL_LOCALMEM2(PackedStringArray, set);
+ VCALL_LOCALMEM1R(PackedStringArray, get);
+ VCALL_LOCALMEM1(PackedStringArray, push_back);
+ VCALL_LOCALMEM1(PackedStringArray, resize);
+ VCALL_LOCALMEM2R(PackedStringArray, insert);
+ VCALL_LOCALMEM1(PackedStringArray, remove);
+ VCALL_LOCALMEM1(PackedStringArray, append);
+ VCALL_LOCALMEM1(PackedStringArray, append_array);
+ VCALL_LOCALMEM0(PackedStringArray, invert);
+
+ VCALL_LOCALMEM0R(PackedVector2Array, size);
+ VCALL_LOCALMEM0R(PackedVector2Array, empty);
+ VCALL_LOCALMEM2(PackedVector2Array, set);
+ VCALL_LOCALMEM1R(PackedVector2Array, get);
+ VCALL_LOCALMEM1(PackedVector2Array, push_back);
+ VCALL_LOCALMEM1(PackedVector2Array, resize);
+ VCALL_LOCALMEM2R(PackedVector2Array, insert);
+ VCALL_LOCALMEM1(PackedVector2Array, remove);
+ VCALL_LOCALMEM1(PackedVector2Array, append);
+ VCALL_LOCALMEM1(PackedVector2Array, append_array);
+ VCALL_LOCALMEM0(PackedVector2Array, invert);
+
+ VCALL_LOCALMEM0R(PackedVector3Array, size);
+ VCALL_LOCALMEM0R(PackedVector3Array, empty);
+ VCALL_LOCALMEM2(PackedVector3Array, set);
+ VCALL_LOCALMEM1R(PackedVector3Array, get);
+ VCALL_LOCALMEM1(PackedVector3Array, push_back);
+ VCALL_LOCALMEM1(PackedVector3Array, resize);
+ VCALL_LOCALMEM2R(PackedVector3Array, insert);
+ VCALL_LOCALMEM1(PackedVector3Array, remove);
+ VCALL_LOCALMEM1(PackedVector3Array, append);
+ VCALL_LOCALMEM1(PackedVector3Array, append_array);
+ VCALL_LOCALMEM0(PackedVector3Array, invert);
+
+ VCALL_LOCALMEM0R(PackedColorArray, size);
+ VCALL_LOCALMEM0R(PackedColorArray, empty);
+ VCALL_LOCALMEM2(PackedColorArray, set);
+ VCALL_LOCALMEM1R(PackedColorArray, get);
+ VCALL_LOCALMEM1(PackedColorArray, push_back);
+ VCALL_LOCALMEM1(PackedColorArray, resize);
+ VCALL_LOCALMEM2R(PackedColorArray, insert);
+ VCALL_LOCALMEM1(PackedColorArray, remove);
+ VCALL_LOCALMEM1(PackedColorArray, append);
+ VCALL_LOCALMEM1(PackedColorArray, append_array);
+ VCALL_LOCALMEM0(PackedColorArray, invert);
#define VCALL_PTR0(m_type, m_method) \
static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(); }
@@ -781,7 +778,7 @@ struct _VariantCall {
case Variant::VECTOR2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform(p_args[0]->operator Vector2()); return;
case Variant::RECT2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform(p_args[0]->operator Rect2()); return;
- case Variant::POOL_VECTOR2_ARRAY: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform(p_args[0]->operator PoolVector2Array()); return;
+ case Variant::PACKED_VECTOR2_ARRAY: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform(p_args[0]->operator PackedVector2Array()); return;
default: r_ret = Variant();
}
}
@@ -792,7 +789,7 @@ struct _VariantCall {
case Variant::VECTOR2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector2()); return;
case Variant::RECT2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Rect2()); return;
- case Variant::POOL_VECTOR2_ARRAY: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform_inv(p_args[0]->operator PoolVector2Array()); return;
+ case Variant::PACKED_VECTOR2_ARRAY: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform_inv(p_args[0]->operator PackedVector2Array()); return;
default: r_ret = Variant();
}
}
@@ -850,7 +847,7 @@ struct _VariantCall {
case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Vector3()); return;
case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Plane()); return;
case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator ::AABB()); return;
- case Variant::POOL_VECTOR3_ARRAY: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator ::PoolVector3Array()); return;
+ case Variant::PACKED_VECTOR3_ARRAY: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator ::PackedVector3Array()); return;
default: r_ret = Variant();
}
}
@@ -862,7 +859,7 @@ struct _VariantCall {
case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector3()); return;
case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Plane()); return;
case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator ::AABB()); return;
- case Variant::POOL_VECTOR3_ARRAY: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator ::PoolVector3Array()); return;
+ case Variant::PACKED_VECTOR3_ARRAY: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator ::PackedVector3Array()); return;
default: r_ret = Variant();
}
}
@@ -1172,14 +1169,14 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
case DICTIONARY: return Dictionary();
case ARRAY:
return Array(); // 20
- case POOL_BYTE_ARRAY: return PoolByteArray();
- case POOL_INT_ARRAY: return PoolIntArray();
- case POOL_REAL_ARRAY: return PoolRealArray();
- case POOL_STRING_ARRAY: return PoolStringArray();
- case POOL_VECTOR2_ARRAY:
- return PoolVector2Array(); // 25
- case POOL_VECTOR3_ARRAY: return PoolVector3Array();
- case POOL_COLOR_ARRAY: return PoolColorArray();
+ case PACKED_BYTE_ARRAY: return PackedByteArray();
+ case PACKED_INT_ARRAY: return PackedIntArray();
+ case PACKED_REAL_ARRAY: return PackedRealArray();
+ case PACKED_STRING_ARRAY: return PackedStringArray();
+ case PACKED_VECTOR2_ARRAY:
+ return PackedVector2Array(); // 25
+ case PACKED_VECTOR3_ARRAY: return PackedVector3Array();
+ case PACKED_COLOR_ARRAY: return PackedColorArray();
default: return Variant();
}
@@ -1229,14 +1226,14 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
return p_args[0]->operator Array(); // 20
// arrays
- case POOL_BYTE_ARRAY: return (PoolByteArray(*p_args[0]));
- case POOL_INT_ARRAY: return (PoolIntArray(*p_args[0]));
- case POOL_REAL_ARRAY: return (PoolRealArray(*p_args[0]));
- case POOL_STRING_ARRAY: return (PoolStringArray(*p_args[0]));
- case POOL_VECTOR2_ARRAY:
- return (PoolVector2Array(*p_args[0])); // 25
- case POOL_VECTOR3_ARRAY: return (PoolVector3Array(*p_args[0]));
- case POOL_COLOR_ARRAY: return (PoolColorArray(*p_args[0]));
+ case PACKED_BYTE_ARRAY: return (PackedByteArray(*p_args[0]));
+ case PACKED_INT_ARRAY: return (PackedIntArray(*p_args[0]));
+ case PACKED_REAL_ARRAY: return (PackedRealArray(*p_args[0]));
+ case PACKED_STRING_ARRAY: return (PackedStringArray(*p_args[0]));
+ case PACKED_VECTOR2_ARRAY:
+ return (PackedVector2Array(*p_args[0])); // 25
+ case PACKED_VECTOR3_ARRAY: return (PackedVector3Array(*p_args[0]));
+ case PACKED_COLOR_ARRAY: return (PackedColorArray(*p_args[0]));
default: return Variant();
}
} else if (p_argcount >= 1) {
@@ -1543,7 +1540,7 @@ void register_variant_methods() {
ADDFUNC1R(STRING, BOOL, String, ends_with, STRING, "text", varray());
ADDFUNC1R(STRING, BOOL, String, is_subsequence_of, STRING, "text", varray());
ADDFUNC1R(STRING, BOOL, String, is_subsequence_ofi, STRING, "text", varray());
- ADDFUNC0R(STRING, POOL_STRING_ARRAY, String, bigrams, varray());
+ ADDFUNC0R(STRING, PACKED_STRING_ARRAY, String, bigrams, varray());
ADDFUNC1R(STRING, REAL, String, similarity, STRING, "text", varray());
ADDFUNC2R(STRING, STRING, String, format, NIL, "values", STRING, "placeholder", varray("{_}"));
@@ -1552,9 +1549,9 @@ void register_variant_methods() {
ADDFUNC1R(STRING, STRING, String, repeat, INT, "count", varray());
ADDFUNC2R(STRING, STRING, String, insert, INT, "position", STRING, "what", varray());
ADDFUNC0R(STRING, STRING, String, capitalize, varray());
- ADDFUNC3R(STRING, POOL_STRING_ARRAY, String, split, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0));
- ADDFUNC3R(STRING, POOL_STRING_ARRAY, String, rsplit, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0));
- ADDFUNC2R(STRING, POOL_REAL_ARRAY, String, split_floats, STRING, "delimiter", BOOL, "allow_empty", varray(true));
+ ADDFUNC3R(STRING, PACKED_STRING_ARRAY, String, split, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0));
+ ADDFUNC3R(STRING, PACKED_STRING_ARRAY, String, rsplit, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0));
+ ADDFUNC2R(STRING, PACKED_REAL_ARRAY, String, split_floats, STRING, "delimiter", BOOL, "allow_empty", varray(true));
ADDFUNC0R(STRING, STRING, String, to_upper, varray());
ADDFUNC0R(STRING, STRING, String, to_lower, varray());
@@ -1575,9 +1572,9 @@ void register_variant_methods() {
ADDFUNC0R(STRING, STRING, String, md5_text, varray());
ADDFUNC0R(STRING, STRING, String, sha1_text, varray());
ADDFUNC0R(STRING, STRING, String, sha256_text, varray());
- ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, md5_buffer, varray());
- ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, sha1_buffer, varray());
- ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, sha256_buffer, varray());
+ ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, md5_buffer, varray());
+ ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, sha1_buffer, varray());
+ ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, sha256_buffer, varray());
ADDFUNC0R(STRING, BOOL, String, empty, varray());
ADDFUNC1R(STRING, STRING, String, humanize_size, INT, "size", varray());
ADDFUNC0R(STRING, BOOL, String, is_abs_path, varray());
@@ -1608,8 +1605,8 @@ void register_variant_methods() {
ADDFUNC1R(STRING, STRING, String, trim_prefix, STRING, "prefix", varray());
ADDFUNC1R(STRING, STRING, String, trim_suffix, STRING, "suffix", varray());
- ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, to_ascii, varray());
- ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, to_utf8, varray());
+ ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, to_ascii, varray());
+ ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, to_utf8, varray());
ADDFUNC0R(VECTOR2, REAL, Vector2, angle, varray());
ADDFUNC1R(VECTOR2, REAL, Vector2, angle_to, VECTOR2, "to", varray());
@@ -1790,90 +1787,89 @@ void register_variant_methods() {
ADDFUNC0R(ARRAY, NIL, Array, max, varray());
ADDFUNC0R(ARRAY, NIL, Array, min, varray());
- ADDFUNC0R(POOL_BYTE_ARRAY, INT, PoolByteArray, size, varray());
- ADDFUNC0R(POOL_BYTE_ARRAY, BOOL, PoolByteArray, empty, varray());
- ADDFUNC2(POOL_BYTE_ARRAY, NIL, PoolByteArray, set, INT, "idx", INT, "byte", varray());
- ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, push_back, INT, "byte", varray());
- ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, append, INT, "byte", varray());
- ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, append_array, POOL_BYTE_ARRAY, "array", varray());
- ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, remove, INT, "idx", varray());
- ADDFUNC2R(POOL_BYTE_ARRAY, INT, PoolByteArray, insert, INT, "idx", INT, "byte", varray());
- ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, resize, INT, "idx", varray());
- ADDFUNC0(POOL_BYTE_ARRAY, NIL, PoolByteArray, invert, varray());
- ADDFUNC2R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, subarray, INT, "from", INT, "to", varray());
-
- ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_ascii, varray());
- ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_utf8, varray());
- ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, hex_encode, varray());
- ADDFUNC1R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, compress, INT, "compression_mode", varray(0));
- ADDFUNC2R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, decompress, INT, "buffer_size", INT, "compression_mode", varray(0));
-
- ADDFUNC0R(POOL_INT_ARRAY, INT, PoolIntArray, size, varray());
- ADDFUNC0R(POOL_INT_ARRAY, BOOL, PoolIntArray, empty, varray());
- ADDFUNC2(POOL_INT_ARRAY, NIL, PoolIntArray, set, INT, "idx", INT, "integer", varray());
- ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, push_back, INT, "integer", varray());
- ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, append, INT, "integer", varray());
- ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, append_array, POOL_INT_ARRAY, "array", varray());
- ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, remove, INT, "idx", varray());
- ADDFUNC2R(POOL_INT_ARRAY, INT, PoolIntArray, insert, INT, "idx", INT, "integer", varray());
- ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, resize, INT, "idx", varray());
- ADDFUNC0(POOL_INT_ARRAY, NIL, PoolIntArray, invert, varray());
-
- ADDFUNC0R(POOL_REAL_ARRAY, INT, PoolRealArray, size, varray());
- ADDFUNC0R(POOL_REAL_ARRAY, BOOL, PoolRealArray, empty, varray());
- ADDFUNC2(POOL_REAL_ARRAY, NIL, PoolRealArray, set, INT, "idx", REAL, "value", varray());
- ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, push_back, REAL, "value", varray());
- ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, append, REAL, "value", varray());
- ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, append_array, POOL_REAL_ARRAY, "array", varray());
- ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, remove, INT, "idx", varray());
- ADDFUNC2R(POOL_REAL_ARRAY, INT, PoolRealArray, insert, INT, "idx", REAL, "value", varray());
- ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, resize, INT, "idx", varray());
- ADDFUNC0(POOL_REAL_ARRAY, NIL, PoolRealArray, invert, varray());
-
- ADDFUNC0R(POOL_STRING_ARRAY, INT, PoolStringArray, size, varray());
- ADDFUNC0R(POOL_STRING_ARRAY, BOOL, PoolStringArray, empty, varray());
- ADDFUNC2(POOL_STRING_ARRAY, NIL, PoolStringArray, set, INT, "idx", STRING, "string", varray());
- ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, push_back, STRING, "string", varray());
- ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, append, STRING, "string", varray());
- ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, append_array, POOL_STRING_ARRAY, "array", varray());
- ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, remove, INT, "idx", varray());
- ADDFUNC2R(POOL_STRING_ARRAY, INT, PoolStringArray, insert, INT, "idx", STRING, "string", varray());
- ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, resize, INT, "idx", varray());
- ADDFUNC0(POOL_STRING_ARRAY, NIL, PoolStringArray, invert, varray());
- ADDFUNC1(POOL_STRING_ARRAY, STRING, PoolStringArray, join, STRING, "delimiter", varray());
-
- ADDFUNC0R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, size, varray());
- ADDFUNC0R(POOL_VECTOR2_ARRAY, BOOL, PoolVector2Array, empty, varray());
- ADDFUNC2(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, set, INT, "idx", VECTOR2, "vector2", varray());
- ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, push_back, VECTOR2, "vector2", varray());
- ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, append, VECTOR2, "vector2", varray());
- ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, append_array, POOL_VECTOR2_ARRAY, "array", varray());
- ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, remove, INT, "idx", varray());
- ADDFUNC2R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, insert, INT, "idx", VECTOR2, "vector2", varray());
- ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, resize, INT, "idx", varray());
- ADDFUNC0(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, invert, varray());
-
- ADDFUNC0R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, size, varray());
- ADDFUNC0R(POOL_VECTOR3_ARRAY, BOOL, PoolVector3Array, empty, varray());
- ADDFUNC2(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, set, INT, "idx", VECTOR3, "vector3", varray());
- ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, push_back, VECTOR3, "vector3", varray());
- ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, append, VECTOR3, "vector3", varray());
- ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, append_array, POOL_VECTOR3_ARRAY, "array", varray());
- ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, remove, INT, "idx", varray());
- ADDFUNC2R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, insert, INT, "idx", VECTOR3, "vector3", varray());
- ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, resize, INT, "idx", varray());
- ADDFUNC0(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, invert, varray());
-
- ADDFUNC0R(POOL_COLOR_ARRAY, INT, PoolColorArray, size, varray());
- ADDFUNC0R(POOL_COLOR_ARRAY, BOOL, PoolColorArray, empty, varray());
- ADDFUNC2(POOL_COLOR_ARRAY, NIL, PoolColorArray, set, INT, "idx", COLOR, "color", varray());
- ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, push_back, COLOR, "color", varray());
- ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, append, COLOR, "color", varray());
- ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, append_array, POOL_COLOR_ARRAY, "array", varray());
- ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, remove, INT, "idx", varray());
- ADDFUNC2R(POOL_COLOR_ARRAY, INT, PoolColorArray, insert, INT, "idx", COLOR, "color", varray());
- ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, resize, INT, "idx", varray());
- ADDFUNC0(POOL_COLOR_ARRAY, NIL, PoolColorArray, invert, varray());
+ ADDFUNC0R(PACKED_BYTE_ARRAY, INT, PackedByteArray, size, varray());
+ ADDFUNC0R(PACKED_BYTE_ARRAY, BOOL, PackedByteArray, empty, varray());
+ ADDFUNC2(PACKED_BYTE_ARRAY, NIL, PackedByteArray, set, INT, "idx", INT, "byte", varray());
+ ADDFUNC1(PACKED_BYTE_ARRAY, NIL, PackedByteArray, push_back, INT, "byte", varray());
+ ADDFUNC1(PACKED_BYTE_ARRAY, NIL, PackedByteArray, append, INT, "byte", varray());
+ ADDFUNC1(PACKED_BYTE_ARRAY, NIL, PackedByteArray, append_array, PACKED_BYTE_ARRAY, "array", varray());
+ ADDFUNC1(PACKED_BYTE_ARRAY, NIL, PackedByteArray, remove, INT, "idx", varray());
+ ADDFUNC2R(PACKED_BYTE_ARRAY, INT, PackedByteArray, insert, INT, "idx", INT, "byte", varray());
+ ADDFUNC1(PACKED_BYTE_ARRAY, NIL, PackedByteArray, resize, INT, "idx", varray());
+ ADDFUNC0(PACKED_BYTE_ARRAY, NIL, PackedByteArray, invert, varray());
+ ADDFUNC2R(PACKED_BYTE_ARRAY, PACKED_BYTE_ARRAY, PackedByteArray, subarray, INT, "from", INT, "to", varray());
+
+ ADDFUNC0R(PACKED_BYTE_ARRAY, STRING, PackedByteArray, get_string_from_ascii, varray());
+ ADDFUNC0R(PACKED_BYTE_ARRAY, STRING, PackedByteArray, get_string_from_utf8, varray());
+ ADDFUNC0R(PACKED_BYTE_ARRAY, STRING, PackedByteArray, hex_encode, varray());
+ ADDFUNC1R(PACKED_BYTE_ARRAY, PACKED_BYTE_ARRAY, PackedByteArray, compress, INT, "compression_mode", varray(0));
+ ADDFUNC2R(PACKED_BYTE_ARRAY, PACKED_BYTE_ARRAY, PackedByteArray, decompress, INT, "buffer_size", INT, "compression_mode", varray(0));
+
+ ADDFUNC0R(PACKED_INT_ARRAY, INT, PackedIntArray, size, varray());
+ ADDFUNC0R(PACKED_INT_ARRAY, BOOL, PackedIntArray, empty, varray());
+ ADDFUNC2(PACKED_INT_ARRAY, NIL, PackedIntArray, set, INT, "idx", INT, "integer", varray());
+ ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, push_back, INT, "integer", varray());
+ ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, append, INT, "integer", varray());
+ ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, append_array, PACKED_INT_ARRAY, "array", varray());
+ ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, remove, INT, "idx", varray());
+ ADDFUNC2R(PACKED_INT_ARRAY, INT, PackedIntArray, insert, INT, "idx", INT, "integer", varray());
+ ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, resize, INT, "idx", varray());
+ ADDFUNC0(PACKED_INT_ARRAY, NIL, PackedIntArray, invert, varray());
+
+ ADDFUNC0R(PACKED_REAL_ARRAY, INT, PackedRealArray, size, varray());
+ ADDFUNC0R(PACKED_REAL_ARRAY, BOOL, PackedRealArray, empty, varray());
+ ADDFUNC2(PACKED_REAL_ARRAY, NIL, PackedRealArray, set, INT, "idx", REAL, "value", varray());
+ ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, push_back, REAL, "value", varray());
+ ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, append, REAL, "value", varray());
+ ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, append_array, PACKED_REAL_ARRAY, "array", varray());
+ ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, remove, INT, "idx", varray());
+ ADDFUNC2R(PACKED_REAL_ARRAY, INT, PackedRealArray, insert, INT, "idx", REAL, "value", varray());
+ ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, resize, INT, "idx", varray());
+ ADDFUNC0(PACKED_REAL_ARRAY, NIL, PackedRealArray, invert, varray());
+
+ ADDFUNC0R(PACKED_STRING_ARRAY, INT, PackedStringArray, size, varray());
+ ADDFUNC0R(PACKED_STRING_ARRAY, BOOL, PackedStringArray, empty, varray());
+ ADDFUNC2(PACKED_STRING_ARRAY, NIL, PackedStringArray, set, INT, "idx", STRING, "string", varray());
+ ADDFUNC1(PACKED_STRING_ARRAY, NIL, PackedStringArray, push_back, STRING, "string", varray());
+ ADDFUNC1(PACKED_STRING_ARRAY, NIL, PackedStringArray, append, STRING, "string", varray());
+ ADDFUNC1(PACKED_STRING_ARRAY, NIL, PackedStringArray, append_array, PACKED_STRING_ARRAY, "array", varray());
+ ADDFUNC1(PACKED_STRING_ARRAY, NIL, PackedStringArray, remove, INT, "idx", varray());
+ ADDFUNC2R(PACKED_STRING_ARRAY, INT, PackedStringArray, insert, INT, "idx", STRING, "string", varray());
+ ADDFUNC1(PACKED_STRING_ARRAY, NIL, PackedStringArray, resize, INT, "idx", varray());
+ ADDFUNC0(PACKED_STRING_ARRAY, NIL, PackedStringArray, invert, varray());
+
+ ADDFUNC0R(PACKED_VECTOR2_ARRAY, INT, PackedVector2Array, size, varray());
+ ADDFUNC0R(PACKED_VECTOR2_ARRAY, BOOL, PackedVector2Array, empty, varray());
+ ADDFUNC2(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, set, INT, "idx", VECTOR2, "vector2", varray());
+ ADDFUNC1(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, push_back, VECTOR2, "vector2", varray());
+ ADDFUNC1(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, append, VECTOR2, "vector2", varray());
+ ADDFUNC1(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, append_array, PACKED_VECTOR2_ARRAY, "array", varray());
+ ADDFUNC1(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, remove, INT, "idx", varray());
+ ADDFUNC2R(PACKED_VECTOR2_ARRAY, INT, PackedVector2Array, insert, INT, "idx", VECTOR2, "vector2", varray());
+ ADDFUNC1(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, resize, INT, "idx", varray());
+ ADDFUNC0(PACKED_VECTOR2_ARRAY, NIL, PackedVector2Array, invert, varray());
+
+ ADDFUNC0R(PACKED_VECTOR3_ARRAY, INT, PackedVector3Array, size, varray());
+ ADDFUNC0R(PACKED_VECTOR3_ARRAY, BOOL, PackedVector3Array, empty, varray());
+ ADDFUNC2(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, set, INT, "idx", VECTOR3, "vector3", varray());
+ ADDFUNC1(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, push_back, VECTOR3, "vector3", varray());
+ ADDFUNC1(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, append, VECTOR3, "vector3", varray());
+ ADDFUNC1(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, append_array, PACKED_VECTOR3_ARRAY, "array", varray());
+ ADDFUNC1(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, remove, INT, "idx", varray());
+ ADDFUNC2R(PACKED_VECTOR3_ARRAY, INT, PackedVector3Array, insert, INT, "idx", VECTOR3, "vector3", varray());
+ ADDFUNC1(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, resize, INT, "idx", varray());
+ ADDFUNC0(PACKED_VECTOR3_ARRAY, NIL, PackedVector3Array, invert, varray());
+
+ ADDFUNC0R(PACKED_COLOR_ARRAY, INT, PackedColorArray, size, varray());
+ ADDFUNC0R(PACKED_COLOR_ARRAY, BOOL, PackedColorArray, empty, varray());
+ ADDFUNC2(PACKED_COLOR_ARRAY, NIL, PackedColorArray, set, INT, "idx", COLOR, "color", varray());
+ ADDFUNC1(PACKED_COLOR_ARRAY, NIL, PackedColorArray, push_back, COLOR, "color", varray());
+ ADDFUNC1(PACKED_COLOR_ARRAY, NIL, PackedColorArray, append, COLOR, "color", varray());
+ ADDFUNC1(PACKED_COLOR_ARRAY, NIL, PackedColorArray, append_array, PACKED_COLOR_ARRAY, "array", varray());
+ ADDFUNC1(PACKED_COLOR_ARRAY, NIL, PackedColorArray, remove, INT, "idx", varray());
+ ADDFUNC2R(PACKED_COLOR_ARRAY, INT, PackedColorArray, insert, INT, "idx", COLOR, "color", varray());
+ ADDFUNC1(PACKED_COLOR_ARRAY, NIL, PackedColorArray, resize, INT, "idx", varray());
+ ADDFUNC0(PACKED_COLOR_ARRAY, NIL, PackedColorArray, invert, varray());
//pointerbased
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index c7a52b0347..566c87dac1 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -38,33 +38,33 @@
CASE_TYPE(PREFIX, OP, INT) \
CASE_TYPE_ALL_BUT_INT(PREFIX, OP)
-#define CASE_TYPE_ALL_BUT_INT(PREFIX, OP) \
- CASE_TYPE(PREFIX, OP, NIL) \
- CASE_TYPE(PREFIX, OP, BOOL) \
- CASE_TYPE(PREFIX, OP, REAL) \
- CASE_TYPE(PREFIX, OP, STRING) \
- CASE_TYPE(PREFIX, OP, VECTOR2) \
- CASE_TYPE(PREFIX, OP, RECT2) \
- CASE_TYPE(PREFIX, OP, VECTOR3) \
- CASE_TYPE(PREFIX, OP, TRANSFORM2D) \
- CASE_TYPE(PREFIX, OP, PLANE) \
- CASE_TYPE(PREFIX, OP, QUAT) \
- CASE_TYPE(PREFIX, OP, AABB) \
- CASE_TYPE(PREFIX, OP, BASIS) \
- CASE_TYPE(PREFIX, OP, TRANSFORM) \
- CASE_TYPE(PREFIX, OP, COLOR) \
- CASE_TYPE(PREFIX, OP, NODE_PATH) \
- CASE_TYPE(PREFIX, OP, _RID) \
- CASE_TYPE(PREFIX, OP, OBJECT) \
- CASE_TYPE(PREFIX, OP, DICTIONARY) \
- CASE_TYPE(PREFIX, OP, ARRAY) \
- CASE_TYPE(PREFIX, OP, POOL_BYTE_ARRAY) \
- CASE_TYPE(PREFIX, OP, POOL_INT_ARRAY) \
- CASE_TYPE(PREFIX, OP, POOL_REAL_ARRAY) \
- CASE_TYPE(PREFIX, OP, POOL_STRING_ARRAY) \
- CASE_TYPE(PREFIX, OP, POOL_VECTOR2_ARRAY) \
- CASE_TYPE(PREFIX, OP, POOL_VECTOR3_ARRAY) \
- CASE_TYPE(PREFIX, OP, POOL_COLOR_ARRAY)
+#define CASE_TYPE_ALL_BUT_INT(PREFIX, OP) \
+ CASE_TYPE(PREFIX, OP, NIL) \
+ CASE_TYPE(PREFIX, OP, BOOL) \
+ CASE_TYPE(PREFIX, OP, REAL) \
+ CASE_TYPE(PREFIX, OP, STRING) \
+ CASE_TYPE(PREFIX, OP, VECTOR2) \
+ CASE_TYPE(PREFIX, OP, RECT2) \
+ CASE_TYPE(PREFIX, OP, VECTOR3) \
+ CASE_TYPE(PREFIX, OP, TRANSFORM2D) \
+ CASE_TYPE(PREFIX, OP, PLANE) \
+ CASE_TYPE(PREFIX, OP, QUAT) \
+ CASE_TYPE(PREFIX, OP, AABB) \
+ CASE_TYPE(PREFIX, OP, BASIS) \
+ CASE_TYPE(PREFIX, OP, TRANSFORM) \
+ CASE_TYPE(PREFIX, OP, COLOR) \
+ CASE_TYPE(PREFIX, OP, NODE_PATH) \
+ CASE_TYPE(PREFIX, OP, _RID) \
+ CASE_TYPE(PREFIX, OP, OBJECT) \
+ CASE_TYPE(PREFIX, OP, DICTIONARY) \
+ CASE_TYPE(PREFIX, OP, ARRAY) \
+ CASE_TYPE(PREFIX, OP, PACKED_BYTE_ARRAY) \
+ CASE_TYPE(PREFIX, OP, PACKED_INT_ARRAY) \
+ CASE_TYPE(PREFIX, OP, PACKED_REAL_ARRAY) \
+ CASE_TYPE(PREFIX, OP, PACKED_STRING_ARRAY) \
+ CASE_TYPE(PREFIX, OP, PACKED_VECTOR2_ARRAY) \
+ CASE_TYPE(PREFIX, OP, PACKED_VECTOR3_ARRAY) \
+ CASE_TYPE(PREFIX, OP, PACKED_COLOR_ARRAY)
#ifdef __GNUC__
#define TYPE(PREFIX, OP, TYPE) &&PREFIX##_##OP##_##TYPE
@@ -91,13 +91,13 @@
TYPE(PREFIX, OP, OBJECT), \
TYPE(PREFIX, OP, DICTIONARY), \
TYPE(PREFIX, OP, ARRAY), \
- TYPE(PREFIX, OP, POOL_BYTE_ARRAY), \
- TYPE(PREFIX, OP, POOL_INT_ARRAY), \
- TYPE(PREFIX, OP, POOL_REAL_ARRAY), \
- TYPE(PREFIX, OP, POOL_STRING_ARRAY), \
- TYPE(PREFIX, OP, POOL_VECTOR2_ARRAY), \
- TYPE(PREFIX, OP, POOL_VECTOR3_ARRAY), \
- TYPE(PREFIX, OP, POOL_COLOR_ARRAY), \
+ TYPE(PREFIX, OP, PACKED_BYTE_ARRAY), \
+ TYPE(PREFIX, OP, PACKED_INT_ARRAY), \
+ TYPE(PREFIX, OP, PACKED_REAL_ARRAY), \
+ TYPE(PREFIX, OP, PACKED_STRING_ARRAY), \
+ TYPE(PREFIX, OP, PACKED_VECTOR2_ARRAY), \
+ TYPE(PREFIX, OP, PACKED_VECTOR3_ARRAY), \
+ TYPE(PREFIX, OP, PACKED_COLOR_ARRAY), \
}
/* clang-format on */
@@ -357,16 +357,16 @@ bool Variant::booleanize() const {
if (p_a.type != p_b.type) \
_RETURN_FAIL \
\
- const PoolVector<m_type> &array_a = *reinterpret_cast<const PoolVector<m_type> *>(p_a._data._mem); \
- const PoolVector<m_type> &array_b = *reinterpret_cast<const PoolVector<m_type> *>(p_b._data._mem); \
+ const Vector<m_type> &array_a = *reinterpret_cast<const Vector<m_type> *>(p_a._data._mem); \
+ const Vector<m_type> &array_b = *reinterpret_cast<const Vector<m_type> *>(p_b._data._mem); \
\
int a_len = array_a.size(); \
if (a_len m_opa array_b.size()) { \
_RETURN(m_ret_s); \
} else { \
\
- PoolVector<m_type>::Read ra = array_a.read(); \
- PoolVector<m_type>::Read rb = array_b.read(); \
+ const m_type *ra = array_a.ptr(); \
+ const m_type *rb = array_b.ptr(); \
\
for (int i = 0; i < a_len; i++) { \
if (ra[i] m_opb rb[i]) \
@@ -376,16 +376,16 @@ bool Variant::booleanize() const {
_RETURN(m_ret_def); \
}
-#define DEFAULT_OP_ARRAY_ADD(m_prefix, m_op_name, m_name, m_type) \
- CASE_TYPE(m_prefix, m_op_name, m_name) { \
- if (p_a.type != p_b.type) \
- _RETURN_FAIL; \
- \
- const PoolVector<m_type> &array_a = *reinterpret_cast<const PoolVector<m_type> *>(p_a._data._mem); \
- const PoolVector<m_type> &array_b = *reinterpret_cast<const PoolVector<m_type> *>(p_b._data._mem); \
- PoolVector<m_type> sum = array_a; \
- sum.append_array(array_b); \
- _RETURN(sum); \
+#define DEFAULT_OP_ARRAY_ADD(m_prefix, m_op_name, m_name, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ if (p_a.type != p_b.type) \
+ _RETURN_FAIL; \
+ \
+ const Vector<m_type> &array_a = *reinterpret_cast<const Vector<m_type> *>(p_a._data._mem); \
+ const Vector<m_type> &array_b = *reinterpret_cast<const Vector<m_type> *>(p_b._data._mem); \
+ Vector<m_type> sum = array_a; \
+ sum.append_array(array_b); \
+ _RETURN(sum); \
}
void Variant::evaluate(const Operator &p_op, const Variant &p_a,
@@ -473,13 +473,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_STR_NULL(math, OP_EQUAL, NODE_PATH, ==, NodePath);
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, _RID, ==, RID);
- DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_REAL_ARRAY, real_t);
- DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_STRING_ARRAY, String);
- DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_VECTOR2_ARRAY, Vector2);
- DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_VECTOR3_ARRAY, Vector3);
- DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, POOL_COLOR_ARRAY, Color);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_BYTE_ARRAY, uint8_t);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_INT_ARRAY, int);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_STRING_ARRAY, String);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_VECTOR2_ARRAY, Vector2);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_VECTOR3_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_COLOR_ARRAY, Color);
}
SWITCH_OP(math, OP_NOT_EQUAL, p_a.type) {
@@ -563,13 +563,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_STR_NULL(math, OP_NOT_EQUAL, NODE_PATH, !=, NodePath);
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, _RID, !=, RID);
- DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_REAL_ARRAY, real_t);
- DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_STRING_ARRAY, String);
- DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_VECTOR2_ARRAY, Vector2);
- DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_VECTOR3_ARRAY, Vector3);
- DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, POOL_COLOR_ARRAY, Color);
+ DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_BYTE_ARRAY, uint8_t);
+ DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_INT_ARRAY, int);
+ DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_STRING_ARRAY, String);
+ DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_VECTOR2_ARRAY, Vector2);
+ DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_VECTOR3_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_COLOR_ARRAY, Color);
}
SWITCH_OP(math, OP_LESS, p_a.type) {
@@ -617,13 +617,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR2, <, Vector2);
DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR3, <, Vector3);
DEFAULT_OP_LOCALMEM(math, OP_LESS, _RID, <, RID);
- DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_REAL_ARRAY, real_t);
- DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_STRING_ARRAY, String);
- DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_VECTOR2_ARRAY, Vector3);
- DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_VECTOR3_ARRAY, Vector3);
- DEFAULT_OP_ARRAY_LT(math, OP_LESS, POOL_COLOR_ARRAY, Color);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_BYTE_ARRAY, uint8_t);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_INT_ARRAY, int);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_STRING_ARRAY, String);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_VECTOR2_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_VECTOR3_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_COLOR_ARRAY, Color);
CASE_TYPE(math, OP_LESS, NIL)
CASE_TYPE(math, OP_LESS, RECT2)
@@ -666,13 +666,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_LESS_EQUAL, NODE_PATH)
CASE_TYPE(math, OP_LESS_EQUAL, DICTIONARY)
CASE_TYPE(math, OP_LESS_EQUAL, ARRAY)
- CASE_TYPE(math, OP_LESS_EQUAL, POOL_BYTE_ARRAY);
- CASE_TYPE(math, OP_LESS_EQUAL, POOL_INT_ARRAY);
- CASE_TYPE(math, OP_LESS_EQUAL, POOL_REAL_ARRAY);
- CASE_TYPE(math, OP_LESS_EQUAL, POOL_STRING_ARRAY);
- CASE_TYPE(math, OP_LESS_EQUAL, POOL_VECTOR2_ARRAY);
- CASE_TYPE(math, OP_LESS_EQUAL, POOL_VECTOR3_ARRAY);
- CASE_TYPE(math, OP_LESS_EQUAL, POOL_COLOR_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, PACKED_BYTE_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, PACKED_INT_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, PACKED_REAL_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, PACKED_STRING_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, PACKED_VECTOR2_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, PACKED_VECTOR3_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, PACKED_COLOR_ARRAY);
_RETURN_FAIL;
}
@@ -721,13 +721,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR2, <, Vector2);
DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR3, <, Vector3);
DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, _RID, <, RID);
- DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_REAL_ARRAY, real_t);
- DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_STRING_ARRAY, String);
- DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_VECTOR2_ARRAY, Vector3);
- DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_VECTOR3_ARRAY, Vector3);
- DEFAULT_OP_ARRAY_GT(math, OP_GREATER, POOL_COLOR_ARRAY, Color);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_BYTE_ARRAY, uint8_t);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_INT_ARRAY, int);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_STRING_ARRAY, String);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_VECTOR2_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_VECTOR3_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_COLOR_ARRAY, Color);
CASE_TYPE(math, OP_GREATER, NIL)
CASE_TYPE(math, OP_GREATER, RECT2)
@@ -770,13 +770,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_GREATER_EQUAL, NODE_PATH)
CASE_TYPE(math, OP_GREATER_EQUAL, DICTIONARY)
CASE_TYPE(math, OP_GREATER_EQUAL, ARRAY)
- CASE_TYPE(math, OP_GREATER_EQUAL, POOL_BYTE_ARRAY);
- CASE_TYPE(math, OP_GREATER_EQUAL, POOL_INT_ARRAY);
- CASE_TYPE(math, OP_GREATER_EQUAL, POOL_REAL_ARRAY);
- CASE_TYPE(math, OP_GREATER_EQUAL, POOL_STRING_ARRAY);
- CASE_TYPE(math, OP_GREATER_EQUAL, POOL_VECTOR2_ARRAY);
- CASE_TYPE(math, OP_GREATER_EQUAL, POOL_VECTOR3_ARRAY);
- CASE_TYPE(math, OP_GREATER_EQUAL, POOL_COLOR_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_BYTE_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_INT_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_REAL_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_STRING_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_VECTOR2_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_VECTOR3_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_COLOR_ARRAY);
_RETURN_FAIL;
}
@@ -806,13 +806,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_LOCALMEM(math, OP_ADD, QUAT, +, Quat);
DEFAULT_OP_LOCALMEM(math, OP_ADD, COLOR, +, Color);
- DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_REAL_ARRAY, real_t);
- DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_STRING_ARRAY, String);
- DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_VECTOR2_ARRAY, Vector2);
- DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_VECTOR3_ARRAY, Vector3);
- DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_COLOR_ARRAY, Color);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_BYTE_ARRAY, uint8_t);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_INT_ARRAY, int);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_STRING_ARRAY, String);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_VECTOR2_ARRAY, Vector2);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_VECTOR3_ARRAY, Vector3);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_COLOR_ARRAY, Color);
CASE_TYPE(math, OP_ADD, NIL)
CASE_TYPE(math, OP_ADD, BOOL)
@@ -851,13 +851,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_SUBTRACT, OBJECT)
CASE_TYPE(math, OP_SUBTRACT, DICTIONARY)
CASE_TYPE(math, OP_SUBTRACT, ARRAY)
- CASE_TYPE(math, OP_SUBTRACT, POOL_BYTE_ARRAY);
- CASE_TYPE(math, OP_SUBTRACT, POOL_INT_ARRAY);
- CASE_TYPE(math, OP_SUBTRACT, POOL_REAL_ARRAY);
- CASE_TYPE(math, OP_SUBTRACT, POOL_STRING_ARRAY);
- CASE_TYPE(math, OP_SUBTRACT, POOL_VECTOR2_ARRAY);
- CASE_TYPE(math, OP_SUBTRACT, POOL_VECTOR3_ARRAY);
- CASE_TYPE(math, OP_SUBTRACT, POOL_COLOR_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, PACKED_BYTE_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, PACKED_INT_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, PACKED_REAL_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, PACKED_STRING_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, PACKED_VECTOR2_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, PACKED_VECTOR3_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, PACKED_COLOR_ARRAY);
_RETURN_FAIL;
}
@@ -930,13 +930,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_MULTIPLY, OBJECT)
CASE_TYPE(math, OP_MULTIPLY, DICTIONARY)
CASE_TYPE(math, OP_MULTIPLY, ARRAY)
- CASE_TYPE(math, OP_MULTIPLY, POOL_BYTE_ARRAY);
- CASE_TYPE(math, OP_MULTIPLY, POOL_INT_ARRAY);
- CASE_TYPE(math, OP_MULTIPLY, POOL_REAL_ARRAY);
- CASE_TYPE(math, OP_MULTIPLY, POOL_STRING_ARRAY);
- CASE_TYPE(math, OP_MULTIPLY, POOL_VECTOR2_ARRAY);
- CASE_TYPE(math, OP_MULTIPLY, POOL_VECTOR3_ARRAY);
- CASE_TYPE(math, OP_MULTIPLY, POOL_COLOR_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, PACKED_BYTE_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, PACKED_INT_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, PACKED_REAL_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, PACKED_STRING_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, PACKED_VECTOR2_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, PACKED_VECTOR3_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, PACKED_COLOR_ARRAY);
_RETURN_FAIL;
}
@@ -973,13 +973,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_DIVIDE, OBJECT)
CASE_TYPE(math, OP_DIVIDE, DICTIONARY)
CASE_TYPE(math, OP_DIVIDE, ARRAY)
- CASE_TYPE(math, OP_DIVIDE, POOL_BYTE_ARRAY);
- CASE_TYPE(math, OP_DIVIDE, POOL_INT_ARRAY);
- CASE_TYPE(math, OP_DIVIDE, POOL_REAL_ARRAY);
- CASE_TYPE(math, OP_DIVIDE, POOL_STRING_ARRAY);
- CASE_TYPE(math, OP_DIVIDE, POOL_VECTOR2_ARRAY);
- CASE_TYPE(math, OP_DIVIDE, POOL_VECTOR3_ARRAY);
- CASE_TYPE(math, OP_DIVIDE, POOL_COLOR_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, PACKED_BYTE_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, PACKED_INT_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, PACKED_REAL_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, PACKED_STRING_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, PACKED_VECTOR2_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, PACKED_VECTOR3_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, PACKED_COLOR_ARRAY);
_RETURN_FAIL;
}
@@ -1005,13 +1005,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_POSITIVE, OBJECT)
CASE_TYPE(math, OP_POSITIVE, DICTIONARY)
CASE_TYPE(math, OP_POSITIVE, ARRAY)
- CASE_TYPE(math, OP_POSITIVE, POOL_BYTE_ARRAY)
- CASE_TYPE(math, OP_POSITIVE, POOL_INT_ARRAY)
- CASE_TYPE(math, OP_POSITIVE, POOL_REAL_ARRAY)
- CASE_TYPE(math, OP_POSITIVE, POOL_STRING_ARRAY)
- CASE_TYPE(math, OP_POSITIVE, POOL_VECTOR2_ARRAY)
- CASE_TYPE(math, OP_POSITIVE, POOL_VECTOR3_ARRAY)
- CASE_TYPE(math, OP_POSITIVE, POOL_COLOR_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, PACKED_BYTE_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, PACKED_INT_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, PACKED_REAL_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, PACKED_STRING_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, PACKED_VECTOR2_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, PACKED_VECTOR3_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, PACKED_COLOR_ARRAY)
_RETURN_FAIL;
}
@@ -1038,13 +1038,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_NEGATE, OBJECT)
CASE_TYPE(math, OP_NEGATE, DICTIONARY)
CASE_TYPE(math, OP_NEGATE, ARRAY)
- CASE_TYPE(math, OP_NEGATE, POOL_BYTE_ARRAY)
- CASE_TYPE(math, OP_NEGATE, POOL_INT_ARRAY)
- CASE_TYPE(math, OP_NEGATE, POOL_REAL_ARRAY)
- CASE_TYPE(math, OP_NEGATE, POOL_STRING_ARRAY)
- CASE_TYPE(math, OP_NEGATE, POOL_VECTOR2_ARRAY)
- CASE_TYPE(math, OP_NEGATE, POOL_VECTOR3_ARRAY)
- CASE_TYPE(math, OP_NEGATE, POOL_COLOR_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, PACKED_BYTE_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, PACKED_INT_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, PACKED_REAL_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, PACKED_STRING_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, PACKED_VECTOR2_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, PACKED_VECTOR3_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, PACKED_COLOR_ARRAY)
_RETURN_FAIL;
}
@@ -1098,13 +1098,13 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_MODULE, OBJECT)
CASE_TYPE(math, OP_MODULE, DICTIONARY)
CASE_TYPE(math, OP_MODULE, ARRAY)
- CASE_TYPE(math, OP_MODULE, POOL_BYTE_ARRAY)
- CASE_TYPE(math, OP_MODULE, POOL_INT_ARRAY)
- CASE_TYPE(math, OP_MODULE, POOL_REAL_ARRAY)
- CASE_TYPE(math, OP_MODULE, POOL_STRING_ARRAY)
- CASE_TYPE(math, OP_MODULE, POOL_VECTOR2_ARRAY)
- CASE_TYPE(math, OP_MODULE, POOL_VECTOR3_ARRAY)
- CASE_TYPE(math, OP_MODULE, POOL_COLOR_ARRAY)
+ CASE_TYPE(math, OP_MODULE, PACKED_BYTE_ARRAY)
+ CASE_TYPE(math, OP_MODULE, PACKED_INT_ARRAY)
+ CASE_TYPE(math, OP_MODULE, PACKED_REAL_ARRAY)
+ CASE_TYPE(math, OP_MODULE, PACKED_STRING_ARRAY)
+ CASE_TYPE(math, OP_MODULE, PACKED_VECTOR2_ARRAY)
+ CASE_TYPE(math, OP_MODULE, PACKED_VECTOR3_ARRAY)
+ CASE_TYPE(math, OP_MODULE, PACKED_COLOR_ARRAY)
_RETURN_FAIL;
}
@@ -1725,10 +1725,10 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
} break;
#define DEFAULT_OP_DVECTOR_SET(m_name, dv_type, skip_cond) \
- DEFAULT_OP_ARRAY_CMD(m_name, PoolVector<dv_type>, if (skip_cond) return;, arr->set(index, p_value); return )
+ DEFAULT_OP_ARRAY_CMD(m_name, Vector<dv_type>, if (skip_cond) return;, arr->set(index, p_value); return )
#define DEFAULT_OP_DVECTOR_GET(m_name, dv_type) \
- DEFAULT_OP_ARRAY_CMD(m_name, const PoolVector<dv_type>, ;, return arr->get(index))
+ DEFAULT_OP_ARRAY_CMD(m_name, const Vector<dv_type>, ;, return arr->get(index))
void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) {
@@ -2197,13 +2197,13 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
return;
} break;
DEFAULT_OP_ARRAY_CMD(ARRAY, Array, ;, (*arr)[index] = p_value; return ) // 20
- DEFAULT_OP_DVECTOR_SET(POOL_BYTE_ARRAY, uint8_t, p_value.type != Variant::REAL && p_value.type != Variant::INT)
- DEFAULT_OP_DVECTOR_SET(POOL_INT_ARRAY, int, p_value.type != Variant::REAL && p_value.type != Variant::INT)
- DEFAULT_OP_DVECTOR_SET(POOL_REAL_ARRAY, real_t, p_value.type != Variant::REAL && p_value.type != Variant::INT)
- DEFAULT_OP_DVECTOR_SET(POOL_STRING_ARRAY, String, p_value.type != Variant::STRING)
- DEFAULT_OP_DVECTOR_SET(POOL_VECTOR2_ARRAY, Vector2, p_value.type != Variant::VECTOR2) // 25
- DEFAULT_OP_DVECTOR_SET(POOL_VECTOR3_ARRAY, Vector3, p_value.type != Variant::VECTOR3)
- DEFAULT_OP_DVECTOR_SET(POOL_COLOR_ARRAY, Color, p_value.type != Variant::COLOR)
+ DEFAULT_OP_DVECTOR_SET(PACKED_BYTE_ARRAY, uint8_t, p_value.type != Variant::REAL && p_value.type != Variant::INT)
+ DEFAULT_OP_DVECTOR_SET(PACKED_INT_ARRAY, int, p_value.type != Variant::REAL && p_value.type != Variant::INT)
+ DEFAULT_OP_DVECTOR_SET(PACKED_REAL_ARRAY, real_t, p_value.type != Variant::REAL && p_value.type != Variant::INT)
+ DEFAULT_OP_DVECTOR_SET(PACKED_STRING_ARRAY, String, p_value.type != Variant::STRING)
+ DEFAULT_OP_DVECTOR_SET(PACKED_VECTOR2_ARRAY, Vector2, p_value.type != Variant::VECTOR2) // 25
+ DEFAULT_OP_DVECTOR_SET(PACKED_VECTOR3_ARRAY, Vector3, p_value.type != Variant::VECTOR3)
+ DEFAULT_OP_DVECTOR_SET(PACKED_COLOR_ARRAY, Color, p_value.type != Variant::COLOR)
default:
return;
}
@@ -2569,13 +2569,13 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
} break;
DEFAULT_OP_ARRAY_CMD(ARRAY, const Array, ;, return (*arr)[index]) // 20
- DEFAULT_OP_DVECTOR_GET(POOL_BYTE_ARRAY, uint8_t)
- DEFAULT_OP_DVECTOR_GET(POOL_INT_ARRAY, int)
- DEFAULT_OP_DVECTOR_GET(POOL_REAL_ARRAY, real_t)
- DEFAULT_OP_DVECTOR_GET(POOL_STRING_ARRAY, String)
- DEFAULT_OP_DVECTOR_GET(POOL_VECTOR2_ARRAY, Vector2) // 25
- DEFAULT_OP_DVECTOR_GET(POOL_VECTOR3_ARRAY, Vector3)
- DEFAULT_OP_DVECTOR_GET(POOL_COLOR_ARRAY, Color)
+ DEFAULT_OP_DVECTOR_GET(PACKED_BYTE_ARRAY, uint8_t)
+ DEFAULT_OP_DVECTOR_GET(PACKED_INT_ARRAY, int)
+ DEFAULT_OP_DVECTOR_GET(PACKED_REAL_ARRAY, real_t)
+ DEFAULT_OP_DVECTOR_GET(PACKED_STRING_ARRAY, String)
+ DEFAULT_OP_DVECTOR_GET(PACKED_VECTOR2_ARRAY, Vector2) // 25
+ DEFAULT_OP_DVECTOR_GET(PACKED_VECTOR3_ARRAY, Vector3)
+ DEFAULT_OP_DVECTOR_GET(PACKED_COLOR_ARRAY, Color)
default:
return Variant();
}
@@ -2651,14 +2651,14 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
return false;
} break;
- case POOL_BYTE_ARRAY: {
+ case PACKED_BYTE_ARRAY: {
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
int index = p_index;
- const PoolVector<uint8_t> *arr = reinterpret_cast<const PoolVector<uint8_t> *>(_data._mem);
+ const Vector<uint8_t> *arr = reinterpret_cast<const Vector<uint8_t> *>(_data._mem);
int l = arr->size();
if (l) {
- PoolVector<uint8_t>::Read r = arr->read();
+ const uint8_t *r = arr->ptr();
for (int i = 0; i < l; i++) {
if (r[i] == index)
return true;
@@ -2669,14 +2669,14 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
}
} break;
- case POOL_INT_ARRAY: {
+ case PACKED_INT_ARRAY: {
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
int index = p_index;
- const PoolVector<int> *arr = reinterpret_cast<const PoolVector<int> *>(_data._mem);
+ const Vector<int> *arr = reinterpret_cast<const Vector<int> *>(_data._mem);
int l = arr->size();
if (l) {
- PoolVector<int>::Read r = arr->read();
+ const int *r = arr->ptr();
for (int i = 0; i < l; i++) {
if (r[i] == index)
return true;
@@ -2686,15 +2686,15 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
return false;
}
} break;
- case POOL_REAL_ARRAY: {
+ case PACKED_REAL_ARRAY: {
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
real_t index = p_index;
- const PoolVector<real_t> *arr = reinterpret_cast<const PoolVector<real_t> *>(_data._mem);
+ const Vector<real_t> *arr = reinterpret_cast<const Vector<real_t> *>(_data._mem);
int l = arr->size();
if (l) {
- PoolVector<real_t>::Read r = arr->read();
+ const real_t *r = arr->ptr();
for (int i = 0; i < l; i++) {
if (r[i] == index)
return true;
@@ -2705,15 +2705,15 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
}
} break;
- case POOL_STRING_ARRAY: {
+ case PACKED_STRING_ARRAY: {
if (p_index.get_type() == Variant::STRING) {
String index = p_index;
- const PoolVector<String> *arr = reinterpret_cast<const PoolVector<String> *>(_data._mem);
+ const Vector<String> *arr = reinterpret_cast<const Vector<String> *>(_data._mem);
int l = arr->size();
if (l) {
- PoolVector<String>::Read r = arr->read();
+ const String *r = arr->ptr();
for (int i = 0; i < l; i++) {
if (r[i] == index)
return true;
@@ -2724,15 +2724,15 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
}
} break; //25
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
if (p_index.get_type() == Variant::VECTOR2) {
Vector2 index = p_index;
- const PoolVector<Vector2> *arr = reinterpret_cast<const PoolVector<Vector2> *>(_data._mem);
+ const Vector<Vector2> *arr = reinterpret_cast<const Vector<Vector2> *>(_data._mem);
int l = arr->size();
if (l) {
- PoolVector<Vector2>::Read r = arr->read();
+ const Vector2 *r = arr->ptr();
for (int i = 0; i < l; i++) {
if (r[i] == index)
return true;
@@ -2743,15 +2743,15 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
}
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
if (p_index.get_type() == Variant::VECTOR3) {
Vector3 index = p_index;
- const PoolVector<Vector3> *arr = reinterpret_cast<const PoolVector<Vector3> *>(_data._mem);
+ const Vector<Vector3> *arr = reinterpret_cast<const Vector<Vector3> *>(_data._mem);
int l = arr->size();
if (l) {
- PoolVector<Vector3>::Read r = arr->read();
+ const Vector3 *r = arr->ptr();
for (int i = 0; i < l; i++) {
if (r[i] == index)
return true;
@@ -2762,16 +2762,16 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
}
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
if (p_index.get_type() == Variant::COLOR) {
Color index = p_index;
- const PoolVector<Color> *arr = reinterpret_cast<const PoolVector<Color> *>(_data._mem);
+ const Vector<Color> *arr = reinterpret_cast<const Vector<Color> *>(_data._mem);
int l = arr->size();
if (l) {
- PoolVector<Color>::Read r = arr->read();
+ const Color *r = arr->ptr();
for (int i = 0; i < l; i++) {
if (r[i] == index)
return true;
@@ -2902,13 +2902,13 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
}
} break;
case ARRAY: // 20
- case POOL_BYTE_ARRAY:
- case POOL_INT_ARRAY:
- case POOL_REAL_ARRAY:
- case POOL_STRING_ARRAY:
- case POOL_VECTOR2_ARRAY: // 25
- case POOL_VECTOR3_ARRAY:
- case POOL_COLOR_ARRAY: {
+ case PACKED_BYTE_ARRAY:
+ case PACKED_INT_ARRAY:
+ case PACKED_REAL_ARRAY:
+ case PACKED_STRING_ARRAY:
+ case PACKED_VECTOR2_ARRAY: // 25
+ case PACKED_VECTOR3_ARRAY:
+ case PACKED_COLOR_ARRAY: {
//nothing
} break;
@@ -3012,56 +3012,56 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
r_iter = 0;
return true;
} break;
- case POOL_BYTE_ARRAY: {
- const PoolVector<uint8_t> *arr = reinterpret_cast<const PoolVector<uint8_t> *>(_data._mem);
+ case PACKED_BYTE_ARRAY: {
+ const Vector<uint8_t> *arr = reinterpret_cast<const Vector<uint8_t> *>(_data._mem);
if (arr->size() == 0)
return false;
r_iter = 0;
return true;
} break;
- case POOL_INT_ARRAY: {
- const PoolVector<int> *arr = reinterpret_cast<const PoolVector<int> *>(_data._mem);
+ case PACKED_INT_ARRAY: {
+ const Vector<int> *arr = reinterpret_cast<const Vector<int> *>(_data._mem);
if (arr->size() == 0)
return false;
r_iter = 0;
return true;
} break;
- case POOL_REAL_ARRAY: {
- const PoolVector<real_t> *arr = reinterpret_cast<const PoolVector<real_t> *>(_data._mem);
+ case PACKED_REAL_ARRAY: {
+ const Vector<real_t> *arr = reinterpret_cast<const Vector<real_t> *>(_data._mem);
if (arr->size() == 0)
return false;
r_iter = 0;
return true;
} break;
- case POOL_STRING_ARRAY: {
- const PoolVector<String> *arr = reinterpret_cast<const PoolVector<String> *>(_data._mem);
+ case PACKED_STRING_ARRAY: {
+ const Vector<String> *arr = reinterpret_cast<const Vector<String> *>(_data._mem);
if (arr->size() == 0)
return false;
r_iter = 0;
return true;
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
- const PoolVector<Vector2> *arr = reinterpret_cast<const PoolVector<Vector2> *>(_data._mem);
+ const Vector<Vector2> *arr = reinterpret_cast<const Vector<Vector2> *>(_data._mem);
if (arr->size() == 0)
return false;
r_iter = 0;
return true;
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
- const PoolVector<Vector3> *arr = reinterpret_cast<const PoolVector<Vector3> *>(_data._mem);
+ const Vector<Vector3> *arr = reinterpret_cast<const Vector<Vector3> *>(_data._mem);
if (arr->size() == 0)
return false;
r_iter = 0;
return true;
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
- const PoolVector<Color> *arr = reinterpret_cast<const PoolVector<Color> *>(_data._mem);
+ const Vector<Color> *arr = reinterpret_cast<const Vector<Color> *>(_data._mem);
if (arr->size() == 0)
return false;
r_iter = 0;
@@ -3187,8 +3187,8 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
r_iter = idx;
return true;
} break;
- case POOL_BYTE_ARRAY: {
- const PoolVector<uint8_t> *arr = reinterpret_cast<const PoolVector<uint8_t> *>(_data._mem);
+ case PACKED_BYTE_ARRAY: {
+ const Vector<uint8_t> *arr = reinterpret_cast<const Vector<uint8_t> *>(_data._mem);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3197,8 +3197,8 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
return true;
} break;
- case POOL_INT_ARRAY: {
- const PoolVector<int> *arr = reinterpret_cast<const PoolVector<int> *>(_data._mem);
+ case PACKED_INT_ARRAY: {
+ const Vector<int> *arr = reinterpret_cast<const Vector<int> *>(_data._mem);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3207,8 +3207,8 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
return true;
} break;
- case POOL_REAL_ARRAY: {
- const PoolVector<real_t> *arr = reinterpret_cast<const PoolVector<real_t> *>(_data._mem);
+ case PACKED_REAL_ARRAY: {
+ const Vector<real_t> *arr = reinterpret_cast<const Vector<real_t> *>(_data._mem);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3217,8 +3217,8 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
return true;
} break;
- case POOL_STRING_ARRAY: {
- const PoolVector<String> *arr = reinterpret_cast<const PoolVector<String> *>(_data._mem);
+ case PACKED_STRING_ARRAY: {
+ const Vector<String> *arr = reinterpret_cast<const Vector<String> *>(_data._mem);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3226,9 +3226,9 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
r_iter = idx;
return true;
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
- const PoolVector<Vector2> *arr = reinterpret_cast<const PoolVector<Vector2> *>(_data._mem);
+ const Vector<Vector2> *arr = reinterpret_cast<const Vector<Vector2> *>(_data._mem);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3236,9 +3236,9 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
r_iter = idx;
return true;
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
- const PoolVector<Vector3> *arr = reinterpret_cast<const PoolVector<Vector3> *>(_data._mem);
+ const Vector<Vector3> *arr = reinterpret_cast<const Vector<Vector3> *>(_data._mem);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3246,9 +3246,9 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
r_iter = idx;
return true;
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
- const PoolVector<Color> *arr = reinterpret_cast<const PoolVector<Color> *>(_data._mem);
+ const Vector<Color> *arr = reinterpret_cast<const Vector<Color> *>(_data._mem);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3334,8 +3334,8 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
#endif
return arr->get(idx);
} break;
- case POOL_BYTE_ARRAY: {
- const PoolVector<uint8_t> *arr = reinterpret_cast<const PoolVector<uint8_t> *>(_data._mem);
+ case PACKED_BYTE_ARRAY: {
+ const Vector<uint8_t> *arr = reinterpret_cast<const Vector<uint8_t> *>(_data._mem);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3345,8 +3345,8 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
#endif
return arr->get(idx);
} break;
- case POOL_INT_ARRAY: {
- const PoolVector<int> *arr = reinterpret_cast<const PoolVector<int> *>(_data._mem);
+ case PACKED_INT_ARRAY: {
+ const Vector<int> *arr = reinterpret_cast<const Vector<int> *>(_data._mem);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3356,8 +3356,8 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
#endif
return arr->get(idx);
} break;
- case POOL_REAL_ARRAY: {
- const PoolVector<real_t> *arr = reinterpret_cast<const PoolVector<real_t> *>(_data._mem);
+ case PACKED_REAL_ARRAY: {
+ const Vector<real_t> *arr = reinterpret_cast<const Vector<real_t> *>(_data._mem);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3367,8 +3367,8 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
#endif
return arr->get(idx);
} break;
- case POOL_STRING_ARRAY: {
- const PoolVector<String> *arr = reinterpret_cast<const PoolVector<String> *>(_data._mem);
+ case PACKED_STRING_ARRAY: {
+ const Vector<String> *arr = reinterpret_cast<const Vector<String> *>(_data._mem);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3378,9 +3378,9 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
#endif
return arr->get(idx);
} break;
- case POOL_VECTOR2_ARRAY: {
+ case PACKED_VECTOR2_ARRAY: {
- const PoolVector<Vector2> *arr = reinterpret_cast<const PoolVector<Vector2> *>(_data._mem);
+ const Vector<Vector2> *arr = reinterpret_cast<const Vector<Vector2> *>(_data._mem);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3390,9 +3390,9 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
#endif
return arr->get(idx);
} break;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
- const PoolVector<Vector3> *arr = reinterpret_cast<const PoolVector<Vector3> *>(_data._mem);
+ const Vector<Vector3> *arr = reinterpret_cast<const Vector<Vector3> *>(_data._mem);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3402,9 +3402,9 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
#endif
return arr->get(idx);
} break;
- case POOL_COLOR_ARRAY: {
+ case PACKED_COLOR_ARRAY: {
- const PoolVector<Color> *arr = reinterpret_cast<const PoolVector<Color> *>(_data._mem);
+ const Vector<Color> *arr = reinterpret_cast<const Vector<Color> *>(_data._mem);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3658,25 +3658,25 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
r_dst = a;
}
return;
- case POOL_BYTE_ARRAY: {
+ case PACKED_BYTE_ARRAY: {
r_dst = a;
}
return;
- case POOL_INT_ARRAY: {
- const PoolVector<int> *arr_a = reinterpret_cast<const PoolVector<int> *>(a._data._mem);
- const PoolVector<int> *arr_b = reinterpret_cast<const PoolVector<int> *>(b._data._mem);
+ case PACKED_INT_ARRAY: {
+ const Vector<int> *arr_a = reinterpret_cast<const Vector<int> *>(a._data._mem);
+ const Vector<int> *arr_b = reinterpret_cast<const Vector<int> *>(b._data._mem);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
r_dst = a;
} else {
- PoolVector<int> v;
+ Vector<int> v;
v.resize(sz);
{
- PoolVector<int>::Write vw = v.write();
- PoolVector<int>::Read ar = arr_a->read();
- PoolVector<int>::Read br = arr_b->read();
+ int *vw = v.ptrw();
+ const int *ar = arr_a->ptr();
+ const int *br = arr_b->ptr();
Variant va;
for (int i = 0; i < sz; i++) {
@@ -3688,21 +3688,21 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
}
}
return;
- case POOL_REAL_ARRAY: {
- const PoolVector<real_t> *arr_a = reinterpret_cast<const PoolVector<real_t> *>(a._data._mem);
- const PoolVector<real_t> *arr_b = reinterpret_cast<const PoolVector<real_t> *>(b._data._mem);
+ case PACKED_REAL_ARRAY: {
+ const Vector<real_t> *arr_a = reinterpret_cast<const Vector<real_t> *>(a._data._mem);
+ const Vector<real_t> *arr_b = reinterpret_cast<const Vector<real_t> *>(b._data._mem);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
r_dst = a;
} else {
- PoolVector<real_t> v;
+ Vector<real_t> v;
v.resize(sz);
{
- PoolVector<real_t>::Write vw = v.write();
- PoolVector<real_t>::Read ar = arr_a->read();
- PoolVector<real_t>::Read br = arr_b->read();
+ real_t *vw = v.ptrw();
+ const real_t *ar = arr_a->ptr();
+ const real_t *br = arr_b->ptr();
Variant va;
for (int i = 0; i < sz; i++) {
@@ -3714,25 +3714,25 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
}
}
return;
- case POOL_STRING_ARRAY: {
+ case PACKED_STRING_ARRAY: {
r_dst = a;
}
return;
- case POOL_VECTOR2_ARRAY: {
- const PoolVector<Vector2> *arr_a = reinterpret_cast<const PoolVector<Vector2> *>(a._data._mem);
- const PoolVector<Vector2> *arr_b = reinterpret_cast<const PoolVector<Vector2> *>(b._data._mem);
+ case PACKED_VECTOR2_ARRAY: {
+ const Vector<Vector2> *arr_a = reinterpret_cast<const Vector<Vector2> *>(a._data._mem);
+ const Vector<Vector2> *arr_b = reinterpret_cast<const Vector<Vector2> *>(b._data._mem);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
r_dst = a;
} else {
- PoolVector<Vector2> v;
+ Vector<Vector2> v;
v.resize(sz);
{
- PoolVector<Vector2>::Write vw = v.write();
- PoolVector<Vector2>::Read ar = arr_a->read();
- PoolVector<Vector2>::Read br = arr_b->read();
+ Vector2 *vw = v.ptrw();
+ const Vector2 *ar = arr_a->ptr();
+ const Vector2 *br = arr_b->ptr();
for (int i = 0; i < sz; i++) {
vw[i] = ar[i].linear_interpolate(br[i], c);
@@ -3742,22 +3742,22 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
}
}
return;
- case POOL_VECTOR3_ARRAY: {
+ case PACKED_VECTOR3_ARRAY: {
- const PoolVector<Vector3> *arr_a = reinterpret_cast<const PoolVector<Vector3> *>(a._data._mem);
- const PoolVector<Vector3> *arr_b = reinterpret_cast<const PoolVector<Vector3> *>(b._data._mem);
+ const Vector<Vector3> *arr_a = reinterpret_cast<const Vector<Vector3> *>(a._data._mem);
+ const Vector<Vector3> *arr_b = reinterpret_cast<const Vector<Vector3> *>(b._data._mem);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
r_dst = a;
} else {
- PoolVector<Vector3> v;
+ Vector<Vector3> v;
v.resize(sz);
{
- PoolVector<Vector3>::Write vw = v.write();
- PoolVector<Vector3>::Read ar = arr_a->read();
- PoolVector<Vector3>::Read br = arr_b->read();
+ Vector3 *vw = v.ptrw();
+ const Vector3 *ar = arr_a->ptr();
+ const Vector3 *br = arr_b->ptr();
for (int i = 0; i < sz; i++) {
vw[i] = ar[i].linear_interpolate(br[i], c);
@@ -3767,21 +3767,21 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
}
}
return;
- case POOL_COLOR_ARRAY: {
- const PoolVector<Color> *arr_a = reinterpret_cast<const PoolVector<Color> *>(a._data._mem);
- const PoolVector<Color> *arr_b = reinterpret_cast<const PoolVector<Color> *>(b._data._mem);
+ case PACKED_COLOR_ARRAY: {
+ const Vector<Color> *arr_a = reinterpret_cast<const Vector<Color> *>(a._data._mem);
+ const Vector<Color> *arr_b = reinterpret_cast<const Vector<Color> *>(b._data._mem);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
r_dst = a;
} else {
- PoolVector<Color> v;
+ Vector<Color> v;
v.resize(sz);
{
- PoolVector<Color>::Write vw = v.write();
- PoolVector<Color>::Read ar = arr_a->read();
- PoolVector<Color>::Read br = arr_b->read();
+ Color *vw = v.ptrw();
+ const Color *ar = arr_a->ptr();
+ const Color *br = arr_b->ptr();
for (int i = 0; i < sz; i++) {
vw[i] = ar[i].linear_interpolate(br[i], c);
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index 996b25308e..f036e00ed5 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -861,18 +861,18 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
}
- } else if (id == "PoolByteArray" || id == "ByteArray") {
+ } else if (id == "PackedByteArray" || id == "PoolByteArray" || id == "ByteArray") {
Vector<uint8_t> args;
Error err = _parse_construct<uint8_t>(p_stream, args, line, r_err_str);
if (err)
return err;
- PoolVector<uint8_t> arr;
+ Vector<uint8_t> arr;
{
int len = args.size();
arr.resize(len);
- PoolVector<uint8_t>::Write w = arr.write();
+ uint8_t *w = arr.ptrw();
for (int i = 0; i < len; i++) {
w[i] = args[i];
}
@@ -882,18 +882,18 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return OK;
- } else if (id == "PoolIntArray" || id == "IntArray") {
+ } else if (id == "PackedIntArray" || id == "PoolIntArray" || id == "IntArray") {
Vector<int> args;
Error err = _parse_construct<int>(p_stream, args, line, r_err_str);
if (err)
return err;
- PoolVector<int> arr;
+ Vector<int> arr;
{
int len = args.size();
arr.resize(len);
- PoolVector<int>::Write w = arr.write();
+ int *w = arr.ptrw();
for (int i = 0; i < len; i++) {
w[i] = int(args[i]);
}
@@ -903,18 +903,18 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return OK;
- } else if (id == "PoolRealArray" || id == "FloatArray") {
+ } else if (id == "PackedRealArray" || id == "PoolRealArray" || id == "FloatArray") {
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
if (err)
return err;
- PoolVector<float> arr;
+ Vector<float> arr;
{
int len = args.size();
arr.resize(len);
- PoolVector<float>::Write w = arr.write();
+ float *w = arr.ptrw();
for (int i = 0; i < len; i++) {
w[i] = args[i];
}
@@ -923,7 +923,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = arr;
return OK;
- } else if (id == "PoolStringArray" || id == "StringArray") {
+ } else if (id == "PackedStringArray" || id == "PoolStringArray" || id == "StringArray") {
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_OPEN) {
@@ -960,11 +960,11 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
cs.push_back(token.value);
}
- PoolVector<String> arr;
+ Vector<String> arr;
{
int len = cs.size();
arr.resize(len);
- PoolVector<String>::Write w = arr.write();
+ String *w = arr.ptrw();
for (int i = 0; i < len; i++) {
w[i] = cs[i];
}
@@ -974,18 +974,18 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return OK;
- } else if (id == "PoolVector2Array" || id == "Vector2Array") {
+ } else if (id == "PackedVector2Array" || id == "PoolVector2Array" || id == "Vector2Array") {
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
if (err)
return err;
- PoolVector<Vector2> arr;
+ Vector<Vector2> arr;
{
int len = args.size() / 2;
arr.resize(len);
- PoolVector<Vector2>::Write w = arr.write();
+ Vector2 *w = arr.ptrw();
for (int i = 0; i < len; i++) {
w[i] = Vector2(args[i * 2 + 0], args[i * 2 + 1]);
}
@@ -995,18 +995,18 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return OK;
- } else if (id == "PoolVector3Array" || id == "Vector3Array") {
+ } else if (id == "PackedVector3Array" || id == "PoolVector3Array" || id == "Vector3Array") {
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
if (err)
return err;
- PoolVector<Vector3> arr;
+ Vector<Vector3> arr;
{
int len = args.size() / 3;
arr.resize(len);
- PoolVector<Vector3>::Write w = arr.write();
+ Vector3 *w = arr.ptrw();
for (int i = 0; i < len; i++) {
w[i] = Vector3(args[i * 3 + 0], args[i * 3 + 1], args[i * 3 + 2]);
}
@@ -1016,18 +1016,18 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return OK;
- } else if (id == "PoolColorArray" || id == "ColorArray") {
+ } else if (id == "PackedColorArray" || id == "PoolColorArray" || id == "ColorArray") {
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
if (err)
return err;
- PoolVector<Color> arr;
+ Vector<Color> arr;
{
int len = args.size() / 4;
arr.resize(len);
- PoolVector<Color>::Write w = arr.write();
+ Color *w = arr.ptrw();
for (int i = 0; i < len; i++) {
w[i] = Color(args[i * 4 + 0], args[i * 4 + 1], args[i * 4 + 2], args[i * 4 + 3]);
}
@@ -1609,14 +1609,14 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
- case Variant::POOL_BYTE_ARRAY: {
+ case Variant::PACKED_BYTE_ARRAY: {
- p_store_string_func(p_store_string_ud, "PoolByteArray( ");
+ p_store_string_func(p_store_string_ud, "PackedByteArray( ");
String s;
- PoolVector<uint8_t> data = p_variant;
+ Vector<uint8_t> data = p_variant;
int len = data.size();
- PoolVector<uint8_t>::Read r = data.read();
- const uint8_t *ptr = r.ptr();
+ const uint8_t *ptr = data.ptr();
+
for (int i = 0; i < len; i++) {
if (i > 0)
@@ -1628,13 +1628,12 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, " )");
} break;
- case Variant::POOL_INT_ARRAY: {
+ case Variant::PACKED_INT_ARRAY: {
- p_store_string_func(p_store_string_ud, "PoolIntArray( ");
- PoolVector<int> data = p_variant;
+ p_store_string_func(p_store_string_ud, "PackedIntArray( ");
+ Vector<int> data = p_variant;
int len = data.size();
- PoolVector<int>::Read r = data.read();
- const int *ptr = r.ptr();
+ const int *ptr = data.ptr();
for (int i = 0; i < len; i++) {
@@ -1647,13 +1646,12 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, " )");
} break;
- case Variant::POOL_REAL_ARRAY: {
+ case Variant::PACKED_REAL_ARRAY: {
- p_store_string_func(p_store_string_ud, "PoolRealArray( ");
- PoolVector<real_t> data = p_variant;
+ p_store_string_func(p_store_string_ud, "PackedRealArray( ");
+ Vector<real_t> data = p_variant;
int len = data.size();
- PoolVector<real_t>::Read r = data.read();
- const real_t *ptr = r.ptr();
+ const real_t *ptr = data.ptr();
for (int i = 0; i < len; i++) {
@@ -1665,13 +1663,13 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, " )");
} break;
- case Variant::POOL_STRING_ARRAY: {
+ case Variant::PACKED_STRING_ARRAY: {
- p_store_string_func(p_store_string_ud, "PoolStringArray( ");
- PoolVector<String> data = p_variant;
+ p_store_string_func(p_store_string_ud, "PackedStringArray( ");
+ Vector<String> data = p_variant;
int len = data.size();
- PoolVector<String>::Read r = data.read();
- const String *ptr = r.ptr();
+ const String *ptr = data.ptr();
+
String s;
//write_string("\n");
@@ -1686,13 +1684,12 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, " )");
} break;
- case Variant::POOL_VECTOR2_ARRAY: {
+ case Variant::PACKED_VECTOR2_ARRAY: {
- p_store_string_func(p_store_string_ud, "PoolVector2Array( ");
- PoolVector<Vector2> data = p_variant;
+ p_store_string_func(p_store_string_ud, "PackedVector2Array( ");
+ Vector<Vector2> data = p_variant;
int len = data.size();
- PoolVector<Vector2>::Read r = data.read();
- const Vector2 *ptr = r.ptr();
+ const Vector2 *ptr = data.ptr();
for (int i = 0; i < len; i++) {
@@ -1704,13 +1701,12 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, " )");
} break;
- case Variant::POOL_VECTOR3_ARRAY: {
+ case Variant::PACKED_VECTOR3_ARRAY: {
- p_store_string_func(p_store_string_ud, "PoolVector3Array( ");
- PoolVector<Vector3> data = p_variant;
+ p_store_string_func(p_store_string_ud, "PackedVector3Array( ");
+ Vector<Vector3> data = p_variant;
int len = data.size();
- PoolVector<Vector3>::Read r = data.read();
- const Vector3 *ptr = r.ptr();
+ const Vector3 *ptr = data.ptr();
for (int i = 0; i < len; i++) {
@@ -1722,14 +1718,13 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, " )");
} break;
- case Variant::POOL_COLOR_ARRAY: {
+ case Variant::PACKED_COLOR_ARRAY: {
- p_store_string_func(p_store_string_ud, "PoolColorArray( ");
+ p_store_string_func(p_store_string_ud, "PackedColorArray( ");
- PoolVector<Color> data = p_variant;
+ Vector<Color> data = p_variant;
int len = data.size();
- PoolVector<Color>::Read r = data.read();
- const Color *ptr = r.ptr();
+ const Color *ptr = data.ptr();
for (int i = 0; i < len; i++) {
diff --git a/core/vector.h b/core/vector.h
index 44add2c4d7..d3476679ff 100644
--- a/core/vector.h
+++ b/core/vector.h
@@ -34,7 +34,7 @@
/**
* @class Vector
* @author Juan Linietsky
- * Vector container. Regular Vector Container. Use with care and for smaller arrays when possible. Use PoolVector for large arrays.
+ * Vector container. Regular Vector Container. Use with care and for smaller arrays when possible. Use Vector for large arrays.
*/
#include "core/cowdata.h"
@@ -64,12 +64,13 @@ private:
public:
bool push_back(T p_elem);
+ _FORCE_INLINE_ bool append(const T &p_elem) { return push_back(p_elem); } //alias
void remove(int p_index) { _cowdata.remove(p_index); }
void erase(const T &p_val) {
int idx = find(p_val);
if (idx >= 0) remove(idx);
- };
+ }
void invert();
_FORCE_INLINE_ T *ptrw() { return _cowdata.ptrw(); }
@@ -123,6 +124,30 @@ public:
return *this;
}
+ Vector<T> subarray(int p_from, int p_to) const {
+
+ if (p_from < 0) {
+ p_from = size() + p_from;
+ }
+ if (p_to < 0) {
+ p_to = size() + p_to;
+ }
+
+ ERR_FAIL_INDEX_V(p_from, size(), Vector<T>());
+ ERR_FAIL_INDEX_V(p_to, size(), Vector<T>());
+
+ Vector<T> slice;
+ int span = 1 + p_to - p_from;
+ slice.resize(span);
+ const T *r = ptr();
+ T *w = slice.ptrw();
+ for (int i = 0; i < span; ++i) {
+ w[i] = r[p_from + i];
+ }
+
+ return slice;
+ }
+
_FORCE_INLINE_ ~Vector() {}
};