PoolVector is gone, replaced by Vector

Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are
sugar for `Vector<Type>`.
This commit is contained in:
Juan Linietsky 2020-02-17 18:06:54 -03:00 committed by Juan Linietsky
parent fb8c93c10b
commit 3205a92ad8
406 changed files with 5314 additions and 8271 deletions

View File

@ -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()) {

View File

@ -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;

View File

@ -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() {

View File

@ -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 {

View File

@ -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) {

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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();

View File

@ -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

View File

@ -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_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.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_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.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_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.ptr()), reinterpret_cast<uint32_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), 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();
}
}

View File

@ -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);
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);
PoolVector<uint8_t>::Write write_lock;
_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();

View File

@ -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()) {

View File

@ -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);

View File

@ -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);

View File

@ -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 {

View File

@ -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

View File

@ -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()) {

View File

@ -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;

View File

@ -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 = "[";

View File

@ -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) {

View File

@ -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"));

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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) {

View File

@ -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")));
}

View File

@ -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;
}

View File

@ -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();

View File

@ -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);
}

View File

@ -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();

View File

@ -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() {
}

View File

@ -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

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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]);

View File

@ -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]);

View File

@ -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;
}

View File

@ -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();
};

View File

@ -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];

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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")));

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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; }

View File

@ -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() {

View File

@ -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:

View File

@ -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!");
}

View File

@ -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

View File

@ -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);

View File

@ -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();
}

View File

@ -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; }

View File

@ -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++) {

View File

@ -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();

View File

@ -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(PoolVector, Plane, Variant::ARRAY)
MAKE_TEMPLATE_TYPE_INFO(PoolVector, Face3, Variant::POOL_VECTOR3_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(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> {

File diff suppressed because it is too large Load Diff

View File

@ -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);

View File

@ -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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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_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

View File

@ -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);

View File

@ -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,32 +1609,13 @@ 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();
for (int i = 0; i < len; i++) {
if (i > 0)
p_store_string_func(p_store_string_ud, ", ");
p_store_string_func(p_store_string_ud, itos(ptr[i]));
}
p_store_string_func(p_store_string_ud, " )");
} break;
case Variant::POOL_INT_ARRAY: {
p_store_string_func(p_store_string_ud, "PoolIntArray( ");
PoolVector<int> data = p_variant;
int len = data.size();
PoolVector<int>::Read r = data.read();
const int *ptr = r.ptr();
const uint8_t *ptr = data.ptr();
for (int i = 0; i < len; i++) {
@ -1647,13 +1628,30 @@ 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_INT_ARRAY: {
p_store_string_func(p_store_string_ud, "PoolRealArray( ");
PoolVector<real_t> data = p_variant;
p_store_string_func(p_store_string_ud, "PackedIntArray( ");
Vector<int> data = p_variant;
int len = data.size();
PoolVector<real_t>::Read r = data.read();
const real_t *ptr = r.ptr();
const int *ptr = data.ptr();
for (int i = 0; i < len; i++) {
if (i > 0)
p_store_string_func(p_store_string_ud, ", ");
p_store_string_func(p_store_string_ud, itos(ptr[i]));
}
p_store_string_func(p_store_string_ud, " )");
} break;
case Variant::PACKED_REAL_ARRAY: {
p_store_string_func(p_store_string_ud, "PackedRealArray( ");
Vector<real_t> data = p_variant;
int len = data.size();
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++) {

View File

@ -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() {}
};

View File

@ -189,9 +189,9 @@ void MIDIDriverALSAMidi::unlock() const {
mutex->unlock();
}
PoolStringArray MIDIDriverALSAMidi::get_connected_inputs() {
PackedStringArray MIDIDriverALSAMidi::get_connected_inputs() {
PoolStringArray list;
PackedStringArray list;
lock();
for (int i = 0; i < connected_inputs.size(); i++) {

View File

@ -59,7 +59,7 @@ public:
virtual Error open();
virtual void close();
virtual PoolStringArray get_connected_inputs();
virtual PackedStringArray get_connected_inputs();
MIDIDriverALSAMidi();
virtual ~MIDIDriverALSAMidi();

View File

@ -93,9 +93,9 @@ void MIDIDriverCoreMidi::close() {
}
}
PoolStringArray MIDIDriverCoreMidi::get_connected_inputs() {
PackedStringArray MIDIDriverCoreMidi::get_connected_inputs() {
PoolStringArray list;
PackedStringArray list;
for (int i = 0; i < connected_sources.size(); i++) {
MIDIEndpointRef source = connected_sources[i];

View File

@ -52,7 +52,7 @@ public:
virtual Error open();
virtual void close();
PoolStringArray get_connected_inputs();
PackedStringArray get_connected_inputs();
MIDIDriverCoreMidi();
virtual ~MIDIDriverCoreMidi();

View File

@ -134,12 +134,12 @@ public:
struct DummySurface {
uint32_t format;
VS::PrimitiveType primitive;
PoolVector<uint8_t> array;
Vector<uint8_t> array;
int vertex_count;
PoolVector<uint8_t> index_array;
Vector<uint8_t> index_array;
int index_count;
AABB aabb;
Vector<PoolVector<uint8_t> > blend_shapes;
Vector<Vector<uint8_t> > blend_shapes;
Vector<AABB> bone_aabbs;
};
@ -295,7 +295,7 @@ public:
return mesh_owner.make_rid(mesh);
}
void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) {
void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes = Vector<Vector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) {
DummyMesh *m = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!m);
@ -334,7 +334,7 @@ public:
return m->blend_shape_mode;
}
void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) {}
void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {}
void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) {}
RID mesh_surface_get_material(RID p_mesh, int p_surface) const { return RID(); }
@ -352,15 +352,15 @@ public:
return m->surfaces[p_surface].index_count;
}
PoolVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const {
Vector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const {
DummyMesh *m = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!m, PoolVector<uint8_t>());
ERR_FAIL_COND_V(!m, Vector<uint8_t>());
return m->surfaces[p_surface].array;
}
PoolVector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const {
Vector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const {
DummyMesh *m = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!m, PoolVector<uint8_t>());
ERR_FAIL_COND_V(!m, Vector<uint8_t>());
return m->surfaces[p_surface].index_array;
}
@ -384,9 +384,9 @@ public:
return m->surfaces[p_surface].aabb;
}
Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const {
Vector<Vector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const {
DummyMesh *m = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!m, Vector<PoolVector<uint8_t> >());
ERR_FAIL_COND_V(!m, Vector<Vector<uint8_t> >());
return m->surfaces[p_surface].blend_shapes;
}
@ -436,7 +436,7 @@ public:
Color multimesh_instance_get_color(RID p_multimesh, int p_index) const { return Color(); }
Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const { return Color(); }
void multimesh_set_as_bulk_array(RID p_multimesh, const PoolVector<float> &p_array) {}
void multimesh_set_as_bulk_array(RID p_multimesh, const Vector<float> &p_array) {}
void multimesh_set_visible_instances(RID p_multimesh, int p_visible) {}
int multimesh_get_visible_instances(RID p_multimesh) const { return 0; }
@ -555,9 +555,9 @@ public:
void gi_probe_set_to_cell_xform(RID p_probe, const Transform &p_xform) {}
Transform gi_probe_get_to_cell_xform(RID p_probe) const { return Transform(); }
void gi_probe_set_dynamic_data(RID p_probe, const PoolVector<int> &p_data) {}
PoolVector<int> gi_probe_get_dynamic_data(RID p_probe) const {
PoolVector<int> p;
void gi_probe_set_dynamic_data(RID p_probe, const Vector<int> &p_data) {}
Vector<int> gi_probe_get_dynamic_data(RID p_probe) const {
Vector<int> p;
return p;
}
@ -620,7 +620,7 @@ public:
struct LightmapCapture : public Instantiable {
PoolVector<LightmapCaptureOctree> octree;
Vector<LightmapCaptureOctree> octree;
AABB bounds;
Transform cell_xform;
int cell_subdiv;
@ -634,15 +634,15 @@ public:
mutable RID_PtrOwner<LightmapCapture> lightmap_capture_data_owner;
void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds) {}
AABB lightmap_capture_get_bounds(RID p_capture) const { return AABB(); }
void lightmap_capture_set_octree(RID p_capture, const PoolVector<uint8_t> &p_octree) {}
void lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree) {}
RID lightmap_capture_create() {
LightmapCapture *capture = memnew(LightmapCapture);
return lightmap_capture_data_owner.make_rid(capture);
}
PoolVector<uint8_t> lightmap_capture_get_octree(RID p_capture) const {
Vector<uint8_t> lightmap_capture_get_octree(RID p_capture) const {
const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND_V(!capture, PoolVector<uint8_t>());
return PoolVector<uint8_t>();
ERR_FAIL_COND_V(!capture, Vector<uint8_t>());
return Vector<uint8_t>();
}
void lightmap_capture_set_octree_cell_transform(RID p_capture, const Transform &p_xform) {}
Transform lightmap_capture_get_octree_cell_transform(RID p_capture) const { return Transform(); }
@ -650,7 +650,7 @@ public:
int lightmap_capture_get_octree_cell_subdiv(RID p_capture) const { return 0; }
void lightmap_capture_set_energy(RID p_capture, float p_energy) {}
float lightmap_capture_get_energy(RID p_capture) const { return 0.0; }
const PoolVector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const {
const Vector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const {
const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND_V(!capture, NULL);
return &capture->octree;
@ -711,7 +711,7 @@ public:
/* LIGHT SHADOW MAPPING */
RID canvas_light_occluder_create() { return RID(); }
void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {}
void canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines) {}
VS::InstanceType get_base_type(RID p_rid) const {
if (mesh_owner.owns(p_rid)) {

View File

@ -43,7 +43,7 @@ RES ResourceFormatDummyTexture::load(const String &p_path, const String &p_origi
Image::Format fmt = Image::FORMAT_RGB8;
int rowsize = 3 * width;
PoolVector<uint8_t> dstbuff;
Vector<uint8_t> dstbuff;
dstbuff.resize(rowsize * height);

View File

@ -1500,7 +1500,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
//use transform buffer workflow
ERR_FAIL_COND(p_skeleton->use_2d);
PoolVector<float> &transform_buffer = storage->resources.skeleton_transform_cpu_buffer;
Vector<float> &transform_buffer = storage->resources.skeleton_transform_cpu_buffer;
if (!s->attribs[VS::ARRAY_BONES].enabled || !s->attribs[VS::ARRAY_WEIGHTS].enabled) {
break; // the whole instance has a skeleton, but this surface is not affected by it.
@ -1517,10 +1517,10 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
const size_t bone_weight_stride = s->attribs[VS::ARRAY_WEIGHTS].stride;
{
PoolVector<float>::Write write = transform_buffer.write();
float *write = transform_buffer.ptrw();
float *buffer = write.ptr();
PoolVector<uint8_t>::Read vertex_array_read = s->data.read();
const uint8_t *vertex_array_read = s->data.ptr();
const uint8_t *vertex_data = vertex_array_read.ptr();
for (int i = 0; i < s->array_len; i++) {

View File

@ -750,7 +750,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
}
texture->data_size = img->get_data().size();
PoolVector<uint8_t>::Read read = img->get_data().read();
const uint8_t *read = img->get_data().ptr();
ERR_FAIL_COND(!read.ptr());
glActiveTexture(GL_TEXTURE0);
@ -888,12 +888,12 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer)
bool compressed;
_get_gl_image_and_format(Ref<Image>(), texture->format, texture->flags, real_format, gl_format, gl_internal_format, gl_type, compressed, false);
PoolVector<uint8_t> data;
Vector<uint8_t> data;
int data_size = Image::get_image_data_size(texture->alloc_width, texture->alloc_height, real_format, texture->mipmaps > 1);
data.resize(data_size * 2); //add some memory at the end, just in case for buggy drivers
PoolVector<uint8_t>::Write wb = data.write();
uint8_t *wb = data.ptrw();
glActiveTexture(GL_TEXTURE0);
@ -930,12 +930,12 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer)
bool compressed;
_get_gl_image_and_format(Ref<Image>(), texture->format, texture->flags, real_format, gl_format, gl_internal_format, gl_type, compressed, texture->resize_to_po2);
PoolVector<uint8_t> data;
Vector<uint8_t> data;
int data_size = Image::get_image_data_size(texture->alloc_width, texture->alloc_height, Image::FORMAT_RGBA8, false);
data.resize(data_size * 2); //add some memory at the end, just in case for buggy drivers
PoolVector<uint8_t>::Write wb = data.write();
uint8_t *wb = data.ptrw();
GLuint temp_framebuffer;
glGenFramebuffers(1, &temp_framebuffer);
@ -1681,7 +1681,7 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
case ShaderLanguage::TYPE_UVEC3:
case ShaderLanguage::TYPE_IVEC4:
case ShaderLanguage::TYPE_UVEC4: {
pi.type = Variant::POOL_INT_ARRAY;
pi.type = Variant::PACKED_INT_ARRAY;
} break;
case ShaderLanguage::TYPE_FLOAT: {
@ -2081,7 +2081,7 @@ RID RasterizerStorageGLES2::mesh_create() {
return mesh_owner.make_rid(mesh);
}
static PoolVector<uint8_t> _unpack_half_floats(const PoolVector<uint8_t> &array, uint32_t &format, int p_vertices) {
static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_t &format, int p_vertices) {
uint32_t p_format = format;
@ -2223,11 +2223,11 @@ static PoolVector<uint8_t> _unpack_half_floats(const PoolVector<uint8_t> &array,
dst_stride += dst_size[i];
}
PoolVector<uint8_t> ret;
Vector<uint8_t> ret;
ret.resize(p_vertices * dst_stride);
PoolVector<uint8_t>::Read r = array.read();
PoolVector<uint8_t>::Write w = ret.write();
const uint8_t *r = array.ptr();
uint8_t *w = ret.ptrw();
int src_offset = 0;
int dst_offset = 0;
@ -2270,7 +2270,7 @@ static PoolVector<uint8_t> _unpack_half_floats(const PoolVector<uint8_t> &array,
return ret;
}
void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) {
void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
@ -2457,18 +2457,18 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
}
//validate sizes
PoolVector<uint8_t> array = p_array;
Vector<uint8_t> array = p_array;
int array_size = stride * p_vertex_count;
int index_array_size = 0;
if (array.size() != array_size && array.size() + p_vertex_count * 2 == array_size) {
//old format, convert
array = PoolVector<uint8_t>();
array = Vector<uint8_t>();
array.resize(p_array.size() + p_vertex_count * 2);
PoolVector<uint8_t>::Write w = array.write();
PoolVector<uint8_t>::Read r = p_array.read();
uint8_t *w = array.ptrw();
const uint8_t *r = p_array.ptr();
uint16_t *w16 = (uint16_t *)w.ptr();
const uint16_t *r16 = (uint16_t *)r.ptr();
@ -2492,7 +2492,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
if (!config.support_half_float_vertices && uses_half_float) {
uint32_t new_format = p_format;
PoolVector<uint8_t> unpacked_array = _unpack_half_floats(array, new_format, p_vertex_count);
Vector<uint8_t> unpacked_array = _unpack_half_floats(array, new_format, p_vertex_count);
mesh_add_surface(p_mesh, new_format, p_primitive, unpacked_array, p_vertex_count, p_index_array, p_index_count, p_aabb, p_blend_shapes, p_bone_aabbs);
return; //do not go any further, above function used unpacked stuff will be used instead.
@ -2549,7 +2549,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
// Okay, now the OpenGL stuff, wheeeeey \o/
{
PoolVector<uint8_t>::Read vr = array.read();
const uint8_t *vr = array.ptr();
glGenBuffers(1, &surface->vertex_id);
glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id);
@ -2558,7 +2558,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
glBindBuffer(GL_ARRAY_BUFFER, 0);
if (p_format & VS::ARRAY_FORMAT_INDEX) {
PoolVector<uint8_t>::Read ir = p_index_array.read();
const uint8_t *ir = p_index_array.ptr();
glGenBuffers(1, &surface->index_id);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, surface->index_id);
@ -2578,7 +2578,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
Surface::BlendShape mt;
PoolVector<uint8_t>::Read vr = p_blend_shapes[i].read();
const uint8_t *vr = p_blend_shapes[i].ptr();
surface->total_data_size += array_size;
@ -2628,7 +2628,7 @@ VS::BlendShapeMode RasterizerStorageGLES2::mesh_get_blend_shape_mode(RID p_mesh)
return mesh->blend_shape_mode;
}
void RasterizerStorageGLES2::mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) {
void RasterizerStorageGLES2::mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
@ -2637,7 +2637,7 @@ void RasterizerStorageGLES2::mesh_surface_update_region(RID p_mesh, int p_surfac
int total_size = p_data.size();
ERR_FAIL_COND(p_offset + total_size > mesh->surfaces[p_surface]->array_byte_size);
PoolVector<uint8_t>::Read r = p_data.read();
const uint8_t *r = p_data.ptr();
glBindBuffer(GL_ARRAY_BUFFER, mesh->surfaces[p_surface]->vertex_id);
glBufferSubData(GL_ARRAY_BUFFER, p_offset, total_size, r.ptr());
@ -2689,11 +2689,11 @@ int RasterizerStorageGLES2::mesh_surface_get_array_index_len(RID p_mesh, int p_s
return mesh->surfaces[p_surface]->index_array_len;
}
PoolVector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_array(RID p_mesh, int p_surface) const {
Vector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_array(RID p_mesh, int p_surface) const {
const Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, PoolVector<uint8_t>());
ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), PoolVector<uint8_t>());
ERR_FAIL_COND_V(!mesh, Vector<uint8_t>());
ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<uint8_t>());
Surface *surface = mesh->surfaces[p_surface];
#ifndef TOOLS_ENABLED
@ -2702,10 +2702,10 @@ PoolVector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_array(RID p_mesh, i
return surface->data;
}
PoolVector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_index_array(RID p_mesh, int p_surface) const {
Vector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_index_array(RID p_mesh, int p_surface) const {
const Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, PoolVector<uint8_t>());
ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), PoolVector<uint8_t>());
ERR_FAIL_COND_V(!mesh, Vector<uint8_t>());
ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<uint8_t>());
Surface *surface = mesh->surfaces[p_surface];
@ -2737,10 +2737,10 @@ AABB RasterizerStorageGLES2::mesh_surface_get_aabb(RID p_mesh, int p_surface) co
return mesh->surfaces[p_surface]->aabb;
}
Vector<PoolVector<uint8_t> > RasterizerStorageGLES2::mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const {
Vector<Vector<uint8_t> > RasterizerStorageGLES2::mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const {
const Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, Vector<PoolVector<uint8_t> >());
ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<PoolVector<uint8_t> >());
ERR_FAIL_COND_V(!mesh, Vector<Vector<uint8_t> >());
ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<Vector<uint8_t> >());
#ifndef TOOLS_ENABLED
ERR_PRINT("OpenGL ES 2.0 does not allow retrieving mesh array data");
#endif
@ -3332,7 +3332,7 @@ Color RasterizerStorageGLES2::multimesh_instance_get_custom_data(RID p_multimesh
return Color();
}
void RasterizerStorageGLES2::multimesh_set_as_bulk_array(RID p_multimesh, const PoolVector<float> &p_array) {
void RasterizerStorageGLES2::multimesh_set_as_bulk_array(RID p_multimesh, const Vector<float> &p_array) {
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_COND(!multimesh->data.ptr());
@ -3341,7 +3341,7 @@ void RasterizerStorageGLES2::multimesh_set_as_bulk_array(RID p_multimesh, const
ERR_FAIL_COND(dsize != p_array.size());
PoolVector<float>::Read r = p_array.read();
const float *r = p_array.ptr();
ERR_FAIL_COND(!r.ptr());
copymem(multimesh->data.ptrw(), r.ptr(), dsize * sizeof(float));
@ -3767,7 +3767,7 @@ void RasterizerStorageGLES2::skeleton_set_base_transform_2d(RID p_skeleton, cons
skeleton->base_transform_2d = p_base_transform;
}
void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const PoolVector<float> &p_data, size_t p_size) {
void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const Vector<float> &p_data, size_t p_size) {
glBindBuffer(GL_ARRAY_BUFFER, resources.skeleton_transform_buffer);
@ -3776,9 +3776,9 @@ void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const PoolVector<
resources.skeleton_transform_buffer_size = p_size;
glBufferData(GL_ARRAY_BUFFER, p_size * sizeof(float), p_data.read().ptr(), GL_DYNAMIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, p_size * sizeof(float), p_data.ptr(), GL_DYNAMIC_DRAW);
} else {
glBufferSubData(GL_ARRAY_BUFFER, 0, p_size * sizeof(float), p_data.read().ptr());
glBufferSubData(GL_ARRAY_BUFFER, 0, p_size * sizeof(float), p_data.ptr());
}
glBindBuffer(GL_ARRAY_BUFFER, 0);
@ -4298,11 +4298,11 @@ Transform RasterizerStorageGLES2::gi_probe_get_to_cell_xform(RID p_probe) const
return Transform();
}
void RasterizerStorageGLES2::gi_probe_set_dynamic_data(RID p_probe, const PoolVector<int> &p_data) {
void RasterizerStorageGLES2::gi_probe_set_dynamic_data(RID p_probe, const Vector<int> &p_data) {
}
PoolVector<int> RasterizerStorageGLES2::gi_probe_get_dynamic_data(RID p_probe) const {
return PoolVector<int>();
Vector<int> RasterizerStorageGLES2::gi_probe_get_dynamic_data(RID p_probe) const {
return Vector<int>();
}
void RasterizerStorageGLES2::gi_probe_set_dynamic_range(RID p_probe, int p_range) {
@ -4389,7 +4389,7 @@ AABB RasterizerStorageGLES2::lightmap_capture_get_bounds(RID p_capture) const {
ERR_FAIL_COND_V(!capture, AABB());
return capture->bounds;
}
void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const PoolVector<uint8_t> &p_octree) {
void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree) {
LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND(!capture);
@ -4398,25 +4398,25 @@ void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Po
capture->octree.resize(p_octree.size() / sizeof(LightmapCaptureOctree));
if (p_octree.size()) {
PoolVector<LightmapCaptureOctree>::Write w = capture->octree.write();
PoolVector<uint8_t>::Read r = p_octree.read();
LightmapCaptureOctree *w = capture->octree.ptrw();
const uint8_t *r = p_octree.ptr();
copymem(w.ptr(), r.ptr(), p_octree.size());
}
capture->instance_change_notify(true, false);
}
PoolVector<uint8_t> RasterizerStorageGLES2::lightmap_capture_get_octree(RID p_capture) const {
Vector<uint8_t> RasterizerStorageGLES2::lightmap_capture_get_octree(RID p_capture) const {
const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND_V(!capture, PoolVector<uint8_t>());
ERR_FAIL_COND_V(!capture, Vector<uint8_t>());
if (capture->octree.size() == 0)
return PoolVector<uint8_t>();
return Vector<uint8_t>();
PoolVector<uint8_t> ret;
Vector<uint8_t> ret;
ret.resize(capture->octree.size() * sizeof(LightmapCaptureOctree));
{
PoolVector<LightmapCaptureOctree>::Read r = capture->octree.read();
PoolVector<uint8_t>::Write w = ret.write();
const LightmapCaptureOctree *r = capture->octree.ptr();
uint8_t *w = ret.ptrw();
copymem(w.ptr(), r.ptr(), ret.size());
}
@ -4461,7 +4461,7 @@ float RasterizerStorageGLES2::lightmap_capture_get_energy(RID p_capture) const {
return capture->energy;
}
const PoolVector<RasterizerStorage::LightmapCaptureOctree> *RasterizerStorageGLES2::lightmap_capture_get_octree_ptr(RID p_capture) const {
const Vector<RasterizerStorage::LightmapCaptureOctree> *RasterizerStorageGLES2::lightmap_capture_get_octree_ptr(RID p_capture) const {
const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND_V(!capture, NULL);
return &capture->octree;
@ -5449,7 +5449,7 @@ RID RasterizerStorageGLES2::canvas_light_occluder_create() {
return canvas_occluder_owner.make_rid(co);
}
void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {
void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines) {
CanvasOccluder *co = canvas_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!co);
@ -5470,17 +5470,17 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder,
if (p_lines.size()) {
PoolVector<float> geometry;
PoolVector<uint16_t> indices;
Vector<float> geometry;
Vector<uint16_t> indices;
int lc = p_lines.size();
geometry.resize(lc * 6);
indices.resize(lc * 3);
PoolVector<float>::Write vw = geometry.write();
PoolVector<uint16_t>::Write iw = indices.write();
float *vw = geometry.ptrw();
uint16_t *iw = indices.ptrw();
PoolVector<Vector2>::Read lr = p_lines.read();
const Vector2 *lr = p_lines.ptr();
const int POLY_HEIGHT = 16384;

View File

@ -31,7 +31,6 @@
#ifndef RASTERIZERSTORAGEGLES2_H
#define RASTERIZERSTORAGEGLES2_H
#include "core/pool_vector.h"
#include "core/self_list.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/shader_language.h"
@ -125,7 +124,7 @@ public:
size_t skeleton_transform_buffer_size;
GLuint skeleton_transform_buffer;
PoolVector<float> skeleton_transform_cpu_buffer;
Vector<float> skeleton_transform_cpu_buffer;
} resources;
@ -649,9 +648,9 @@ public:
bool active;
PoolVector<uint8_t> data;
PoolVector<uint8_t> index_data;
Vector<PoolVector<uint8_t> > blend_shape_data;
Vector<uint8_t> data;
Vector<uint8_t> index_data;
Vector<Vector<uint8_t> > blend_shape_data;
int total_data_size;
@ -703,7 +702,7 @@ public:
virtual RID mesh_create();
virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>());
virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes = Vector<Vector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>());
virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount);
virtual int mesh_get_blend_shape_count(RID p_mesh) const;
@ -711,7 +710,7 @@ public:
virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode);
virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const;
virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data);
virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data);
virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material);
virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const;
@ -719,14 +718,14 @@ public:
virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const;
virtual int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const;
virtual PoolVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const;
virtual PoolVector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const;
virtual Vector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const;
virtual Vector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const;
virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const;
virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const;
virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const;
virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const;
virtual Vector<Vector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const;
virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const;
virtual void mesh_remove_surface(RID p_mesh, int p_surface);
@ -803,7 +802,7 @@ public:
virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const;
virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const;
virtual void multimesh_set_as_bulk_array(RID p_multimesh, const PoolVector<float> &p_array);
virtual void multimesh_set_as_bulk_array(RID p_multimesh, const Vector<float> &p_array);
virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible);
virtual int multimesh_get_visible_instances(RID p_multimesh) const;
@ -902,7 +901,7 @@ public:
virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const;
virtual void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform);
void _update_skeleton_transform_buffer(const PoolVector<float> &p_data, size_t p_size);
void _update_skeleton_transform_buffer(const Vector<float> &p_data, size_t p_size);
/* Light API */
@ -1030,8 +1029,8 @@ public:
virtual void gi_probe_set_to_cell_xform(RID p_probe, const Transform &p_xform);
virtual Transform gi_probe_get_to_cell_xform(RID p_probe) const;
virtual void gi_probe_set_dynamic_data(RID p_probe, const PoolVector<int> &p_data);
virtual PoolVector<int> gi_probe_get_dynamic_data(RID p_probe) const;
virtual void gi_probe_set_dynamic_data(RID p_probe, const Vector<int> &p_data);
virtual Vector<int> gi_probe_get_dynamic_data(RID p_probe) const;
virtual void gi_probe_set_dynamic_range(RID p_probe, int p_range);
virtual int gi_probe_get_dynamic_range(RID p_probe) const;
@ -1064,7 +1063,7 @@ public:
struct LightmapCapture : public Instantiable {
PoolVector<LightmapCaptureOctree> octree;
Vector<LightmapCaptureOctree> octree;
AABB bounds;
Transform cell_xform;
int cell_subdiv;
@ -1080,15 +1079,15 @@ public:
virtual RID lightmap_capture_create();
virtual void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds);
virtual AABB lightmap_capture_get_bounds(RID p_capture) const;
virtual void lightmap_capture_set_octree(RID p_capture, const PoolVector<uint8_t> &p_octree);
virtual PoolVector<uint8_t> lightmap_capture_get_octree(RID p_capture) const;
virtual void lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree);
virtual Vector<uint8_t> lightmap_capture_get_octree(RID p_capture) const;
virtual void lightmap_capture_set_octree_cell_transform(RID p_capture, const Transform &p_xform);
virtual Transform lightmap_capture_get_octree_cell_transform(RID p_capture) const;
virtual void lightmap_capture_set_octree_cell_subdiv(RID p_capture, int p_subdiv);
virtual int lightmap_capture_get_octree_cell_subdiv(RID p_capture) const;
virtual void lightmap_capture_set_energy(RID p_capture, float p_energy);
virtual float lightmap_capture_get_energy(RID p_capture) const;
virtual const PoolVector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const;
virtual const Vector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const;
/* PARTICLES */
void update_particles();
@ -1271,14 +1270,14 @@ public:
GLuint vertex_id; // 0 means, unconfigured
GLuint index_id; // 0 means, unconfigured
PoolVector<Vector2> lines;
Vector<Vector2> lines;
int len;
};
RID_PtrOwner<CanvasOccluder> canvas_occluder_owner;
virtual RID canvas_light_occluder_create();
virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines);
virtual void canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines);
virtual VS::InstanceType get_base_type(RID p_rid) const;

View File

@ -39,19 +39,19 @@
Error ImageLoaderPNG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
const size_t buffer_size = f->get_len();
PoolVector<uint8_t> file_buffer;
Vector<uint8_t> file_buffer;
Error err = file_buffer.resize(buffer_size);
if (err) {
f->close();
return err;
}
{
PoolVector<uint8_t>::Write writer = file_buffer.write();
f->get_buffer(writer.ptr(), buffer_size);
uint8_t *writer = file_buffer.ptrw();
f->get_buffer(writer, buffer_size);
f->close();
}
PoolVector<uint8_t>::Read reader = file_buffer.read();
return PNGDriverCommon::png_to_image(reader.ptr(), buffer_size, p_image);
const uint8_t *reader = file_buffer.ptr();
return PNGDriverCommon::png_to_image(reader, buffer_size, p_image);
}
void ImageLoaderPNG::get_recognized_extensions(List<String> *p_extensions) const {
@ -70,34 +70,34 @@ Ref<Image> ImageLoaderPNG::load_mem_png(const uint8_t *p_png, int p_size) {
return img;
}
Ref<Image> ImageLoaderPNG::lossless_unpack_png(const PoolVector<uint8_t> &p_data) {
Ref<Image> ImageLoaderPNG::lossless_unpack_png(const Vector<uint8_t> &p_data) {
const int len = p_data.size();
ERR_FAIL_COND_V(len < 4, Ref<Image>());
PoolVector<uint8_t>::Read r = p_data.read();
const uint8_t *r = p_data.ptr();
ERR_FAIL_COND_V(r[0] != 'P' || r[1] != 'N' || r[2] != 'G' || r[3] != ' ', Ref<Image>());
return load_mem_png(&r[4], len - 4);
}
PoolVector<uint8_t> ImageLoaderPNG::lossless_pack_png(const Ref<Image> &p_image) {
Vector<uint8_t> ImageLoaderPNG::lossless_pack_png(const Ref<Image> &p_image) {
PoolVector<uint8_t> out_buffer;
Vector<uint8_t> out_buffer;
// add Godot's own "PNG " prefix
if (out_buffer.resize(4) != OK) {
ERR_FAIL_V(PoolVector<uint8_t>());
ERR_FAIL_V(Vector<uint8_t>());
}
// scope for writer lifetime
{
// must be closed before call to image_to_png
PoolVector<uint8_t>::Write writer = out_buffer.write();
copymem(writer.ptr(), "PNG ", 4);
uint8_t *writer = out_buffer.ptrw();
copymem(writer, "PNG ", 4);
}
Error err = PNGDriverCommon::image_to_png(p_image, out_buffer);
if (err) {
ERR_FAIL_V(PoolVector<uint8_t>());
ERR_FAIL_V(Vector<uint8_t>());
}
return out_buffer;

View File

@ -35,8 +35,8 @@
class ImageLoaderPNG : public ImageFormatLoader {
private:
static PoolVector<uint8_t> lossless_pack_png(const Ref<Image> &p_image);
static Ref<Image> lossless_unpack_png(const PoolVector<uint8_t> &p_data);
static Vector<uint8_t> lossless_pack_png(const Ref<Image> &p_image);
static Ref<Image> lossless_unpack_png(const Vector<uint8_t> &p_data);
static Ref<Image> load_mem_png(const uint8_t *p_png, int p_size);
public:

View File

@ -101,16 +101,16 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
}
const png_uint_32 stride = PNG_IMAGE_ROW_STRIDE(png_img);
PoolVector<uint8_t> buffer;
Vector<uint8_t> buffer;
Error err = buffer.resize(PNG_IMAGE_BUFFER_SIZE(png_img, stride));
if (err) {
png_image_free(&png_img); // only required when we return before finish_read
return err;
}
PoolVector<uint8_t>::Write writer = buffer.write();
uint8_t *writer = buffer.ptrw();
// read image data to buffer and release libpng resources
success = png_image_finish_read(&png_img, NULL, writer.ptr(), stride, NULL);
success = png_image_finish_read(&png_img, NULL, writer, stride, NULL);
ERR_FAIL_COND_V_MSG(check_error(png_img), ERR_FILE_CORRUPT, png_img.message);
ERR_FAIL_COND_V(!success, ERR_FILE_CORRUPT);
@ -120,7 +120,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
return OK;
}
Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer) {
Ref<Image> source_image = p_image->duplicate();
@ -158,8 +158,8 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
}
}
const PoolVector<uint8_t> image_data = source_image->get_data();
const PoolVector<uint8_t>::Read reader = image_data.read();
const Vector<uint8_t> image_data = source_image->get_data();
const uint8_t *reader = image_data.ptr();
// we may be passed a buffer with existing content we're expected to append to
const int buffer_offset = p_buffer.size();
@ -173,9 +173,9 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
Error err = p_buffer.resize(buffer_offset + png_size_estimate);
ERR_FAIL_COND_V(err, err);
PoolVector<uint8_t>::Write writer = p_buffer.write();
uint8_t *writer = p_buffer.ptrw();
success = png_image_write_to_memory(&png_img, &writer[buffer_offset],
&compressed_size, 0, reader.ptr(), 0, NULL);
&compressed_size, 0, reader, 0, NULL);
ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message);
}
if (!success) {
@ -187,9 +187,9 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
Error err = p_buffer.resize(buffer_offset + compressed_size);
ERR_FAIL_COND_V(err, err);
PoolVector<uint8_t>::Write writer = p_buffer.write();
uint8_t *writer = p_buffer.ptrw();
success = png_image_write_to_memory(&png_img, &writer[buffer_offset],
&compressed_size, 0, reader.ptr(), 0, NULL);
&compressed_size, 0, reader, 0, NULL);
ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message);
ERR_FAIL_COND_V(!success, FAILED);
}

View File

@ -32,7 +32,6 @@
#define PNG_DRIVER_COMMON_H
#include "core/image.h"
#include "core/pool_vector.h"
namespace PNGDriverCommon {
@ -41,7 +40,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image);
// Append p_image, as a png, to p_buffer.
// Contents of p_buffer is unspecified if error returned.
Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer);
Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer);
} // namespace PNGDriverCommon

View File

@ -51,15 +51,15 @@ Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32
Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img) {
PoolVector<uint8_t> buffer;
Vector<uint8_t> buffer;
Error err = PNGDriverCommon::image_to_png(p_img, buffer);
ERR_FAIL_COND_V_MSG(err, err, "Can't convert image to PNG.");
FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
ERR_FAIL_COND_V_MSG(err, err, vformat("Can't save PNG at path: '%s'.", p_path));
PoolVector<uint8_t>::Read reader = buffer.read();
const uint8_t *reader = buffer.ptr();
file->store_buffer(reader.ptr(), buffer.size());
file->store_buffer(reader, buffer.size());
if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) {
memdelete(file);
return ERR_CANT_CREATE;
@ -71,11 +71,11 @@ Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img
return OK;
}
PoolVector<uint8_t> ResourceSaverPNG::save_image_to_buffer(const Ref<Image> &p_img) {
Vector<uint8_t> ResourceSaverPNG::save_image_to_buffer(const Ref<Image> &p_img) {
PoolVector<uint8_t> buffer;
Vector<uint8_t> buffer;
Error err = PNGDriverCommon::image_to_png(p_img, buffer);
ERR_FAIL_COND_V_MSG(err, PoolVector<uint8_t>(), "Can't convert image to PNG.");
ERR_FAIL_COND_V_MSG(err, Vector<uint8_t>(), "Can't convert image to PNG.");
return buffer;
}

View File

@ -37,7 +37,7 @@
class ResourceSaverPNG : public ResourceFormatSaver {
public:
static Error save_image(const String &p_path, const Ref<Image> &p_img);
static PoolVector<uint8_t> save_image_to_buffer(const Ref<Image> &p_img);
static Vector<uint8_t> save_image_to_buffer(const Ref<Image> &p_img);
virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
virtual bool recognize(const RES &p_resource) const;

View File

@ -1557,7 +1557,7 @@ void RenderingDeviceVulkan::_buffer_memory_barrier(VkBuffer buffer, uint64_t p_f
/**** TEXTURE ****/
/*****************/
RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<PoolVector<uint8_t> > &p_data) {
RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t> > &p_data) {
_THREAD_SAFE_METHOD_
@ -2077,7 +2077,7 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p
return id;
}
Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, const PoolVector<uint8_t> &p_data, bool p_sync_with_draw) {
Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data, bool p_sync_with_draw) {
_THREAD_SAFE_METHOD_
@ -2121,7 +2121,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
uint32_t region_size = texture_upload_region_size_px;
PoolVector<uint8_t>::Read r = p_data.read();
const uint8_t *r = p_data.ptr();
VkCommandBuffer command_buffer = p_sync_with_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer;
@ -2153,7 +2153,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
uint32_t depth;
uint32_t image_total = get_image_format_required_size(texture->format, texture->width, texture->height, texture->depth, mm_i + 1, &width, &height, &depth);
const uint8_t *read_ptr_mipmap = r.ptr() + mipmap_offset;
const uint8_t *read_ptr_mipmap = r + mipmap_offset;
image_size = image_total - mipmap_offset;
for (uint32_t z = 0; z < depth; z++) { //for 3D textures, depth may be > 0
@ -2288,12 +2288,12 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
return OK;
}
PoolVector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex, VkImage p_image, VmaAllocation p_allocation, uint32_t p_layer, bool p_2d) {
Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex, VkImage p_image, VmaAllocation p_allocation, uint32_t p_layer, bool p_2d) {
uint32_t width, height, depth;
uint32_t image_size = get_image_format_required_size(tex->format, tex->width, tex->height, p_2d ? 1 : tex->depth, tex->mipmaps, &width, &height, &depth);
PoolVector<uint8_t> image_data;
Vector<uint8_t> image_data;
image_data.resize(image_size);
void *img_mem;
@ -2305,14 +2305,14 @@ PoolVector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture
uint32_t pixel_size = get_image_format_pixel_size(tex->format);
{
PoolVector<uint8_t>::Write w = image_data.write();
uint8_t *w = image_data.ptrw();
uint32_t mipmap_offset = 0;
for (uint32_t mm_i = 0; mm_i < tex->mipmaps; mm_i++) {
uint32_t image_total = get_image_format_required_size(tex->format, tex->width, tex->height, p_2d ? 1 : tex->depth, mm_i + 1, &width, &height, &depth);
uint8_t *write_ptr_mipmap = w.ptr() + mipmap_offset;
uint8_t *write_ptr_mipmap = w + mipmap_offset;
image_size = image_total - mipmap_offset;
VkImageSubresource image_sub_resorce;
@ -2355,23 +2355,23 @@ PoolVector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture
return image_data;
}
PoolVector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t p_layer) {
Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t p_layer) {
_THREAD_SAFE_METHOD_
Texture *tex = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!tex, PoolVector<uint8_t>());
ERR_FAIL_COND_V(!tex, Vector<uint8_t>());
ERR_FAIL_COND_V_MSG(tex->bound, PoolVector<uint8_t>(),
ERR_FAIL_COND_V_MSG(tex->bound, Vector<uint8_t>(),
"Texture can't be retrieved while a render pass that uses it is being created. Ensure render pass is finalized (and that it was created with RENDER_PASS_CONTENTS_FINISH) to unbind this texture.");
ERR_FAIL_COND_V_MSG(!(tex->usage_flags & TEXTURE_USAGE_CAN_COPY_FROM_BIT), PoolVector<uint8_t>(),
ERR_FAIL_COND_V_MSG(!(tex->usage_flags & TEXTURE_USAGE_CAN_COPY_FROM_BIT), Vector<uint8_t>(),
"Texture requires the TEXTURE_USAGE_CAN_COPY_FROM_BIT in order to be retrieved.");
uint32_t layer_count = tex->layers;
if (tex->type == TEXTURE_TYPE_CUBE || tex->type == TEXTURE_TYPE_CUBE_ARRAY) {
layer_count *= 6;
}
ERR_FAIL_COND_V(p_layer >= layer_count, PoolVector<uint8_t>());
ERR_FAIL_COND_V(p_layer >= layer_count, Vector<uint8_t>());
if (tex->usage_flags & TEXTURE_USAGE_CPU_READ_BIT) {
//does not need anything fancy, map and read.
@ -2469,15 +2469,15 @@ PoolVector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint3
void *buffer_mem;
VkResult vkerr = vmaMapMemory(allocator, tmp_buffer.allocation, &buffer_mem);
if (vkerr) {
ERR_FAIL_V(PoolVector<uint8_t>());
ERR_FAIL_V(Vector<uint8_t>());
}
PoolVector<uint8_t> buffer_data;
Vector<uint8_t> buffer_data;
{
buffer_data.resize(buffer_size);
PoolVector<uint8_t>::Write w = buffer_data.write();
copymem(w.ptr(), buffer_mem, buffer_size);
uint8_t *w = buffer_data.ptrw();
copymem(w, buffer_mem, buffer_size);
}
vmaUnmapMemory(allocator, tmp_buffer.allocation);
@ -3135,7 +3135,7 @@ RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) {
/**** VERTEX ARRAY ****/
/**********************/
RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data) {
RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data) {
_THREAD_SAFE_METHOD_
@ -3145,8 +3145,8 @@ RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const Poo
_buffer_allocate(&buffer, p_size_bytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VMA_MEMORY_USAGE_GPU_ONLY);
if (p_data.size()) {
uint64_t data_size = p_data.size();
PoolVector<uint8_t>::Read r = p_data.read();
_buffer_update(&buffer, 0, r.ptr(), data_size);
const uint8_t *r = p_data.ptr();
_buffer_update(&buffer, 0, r, data_size);
_buffer_memory_barrier(buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_INPUT_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT, false);
}
@ -3263,7 +3263,7 @@ RID RenderingDeviceVulkan::vertex_array_create(uint32_t p_vertex_count, VertexFo
return id;
}
RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBufferFormat p_format, const PoolVector<uint8_t> &p_data, bool p_use_restart_indices) {
RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBufferFormat p_format, const Vector<uint8_t> &p_data, bool p_use_restart_indices) {
_THREAD_SAFE_METHOD_
@ -3279,9 +3279,9 @@ RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBuff
index_buffer.max_index = 0;
ERR_FAIL_COND_V_MSG((uint32_t)p_data.size() != size_bytes, RID(),
"Default index buffer initializer array size (" + itos(p_data.size()) + ") does not match format required size (" + itos(size_bytes) + ").");
PoolVector<uint8_t>::Read r = p_data.read();
const uint8_t *r = p_data.ptr();
if (p_format == INDEX_BUFFER_FORMAT_UINT16) {
const uint16_t *index16 = (const uint16_t *)r.ptr();
const uint16_t *index16 = (const uint16_t *)r;
for (uint32_t i = 0; i < p_index_count; i++) {
if (p_use_restart_indices && index16[i] == 0xFFFF) {
continue; //restart index, ingnore
@ -3289,7 +3289,7 @@ RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBuff
index_buffer.max_index = MAX(index16[i], index_buffer.max_index);
}
} else {
const uint32_t *index32 = (const uint32_t *)r.ptr();
const uint32_t *index32 = (const uint32_t *)r;
for (uint32_t i = 0; i < p_index_count; i++) {
if (p_use_restart_indices && index32[i] == 0xFFFFFFFF) {
continue; //restart index, ingnore
@ -3306,8 +3306,8 @@ RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBuff
_buffer_allocate(&index_buffer, size_bytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT, VMA_MEMORY_USAGE_GPU_ONLY);
if (p_data.size()) {
uint64_t data_size = p_data.size();
PoolVector<uint8_t>::Read r = p_data.read();
_buffer_update(&index_buffer, 0, r.ptr(), data_size);
const uint8_t *r = p_data.ptr();
_buffer_update(&index_buffer, 0, r, data_size);
_buffer_memory_barrier(index_buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_INPUT_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_INDEX_READ_BIT, false);
}
return index_buffer_owner.make_rid(index_buffer);
@ -3606,8 +3606,8 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
{
SpvReflectShaderModule module;
PoolVector<uint8_t>::Read spirv = p_stages[i].spir_v.read();
SpvReflectResult result = spvReflectCreateShaderModule(p_stages[i].spir_v.size(), spirv.ptr(), &module);
const uint8_t *spirv = p_stages[i].spir_v.ptr();
SpvReflectResult result = spvReflectCreateShaderModule(p_stages[i].spir_v.size(), spirv, &module);
ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(),
"Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed parsing shader.");
@ -3872,9 +3872,9 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
shader_module_create_info.pNext = NULL;
shader_module_create_info.flags = 0;
shader_module_create_info.codeSize = p_stages[i].spir_v.size();
PoolVector<uint8_t>::Read r = p_stages[i].spir_v.read();
const uint8_t *r = p_stages[i].spir_v.ptr();
shader_module_create_info.pCode = (const uint32_t *)r.ptr();
shader_module_create_info.pCode = (const uint32_t *)r;
VkShaderModule module;
VkResult res = vkCreateShaderModule(device, &shader_module_create_info, NULL, &module);
@ -4016,7 +4016,7 @@ uint32_t RenderingDeviceVulkan::shader_get_vertex_input_attribute_mask(RID p_sha
/**** UNIFORMS ****/
/******************/
RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data) {
RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data) {
_THREAD_SAFE_METHOD_
@ -4027,14 +4027,14 @@ RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const Po
ERR_FAIL_COND_V(err != OK, RID());
if (p_data.size()) {
uint64_t data_size = p_data.size();
PoolVector<uint8_t>::Read r = p_data.read();
_buffer_update(&buffer, 0, r.ptr(), data_size);
const uint8_t *r = p_data.ptr();
_buffer_update(&buffer, 0, r, data_size);
_buffer_memory_barrier(buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_UNIFORM_READ_BIT, false);
}
return uniform_buffer_owner.make_rid(buffer);
}
RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data) {
RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data) {
_THREAD_SAFE_METHOD_
@ -4046,14 +4046,14 @@ RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const Po
if (p_data.size()) {
uint64_t data_size = p_data.size();
PoolVector<uint8_t>::Read r = p_data.read();
_buffer_update(&buffer, 0, r.ptr(), data_size);
const uint8_t *r = p_data.ptr();
_buffer_update(&buffer, 0, r, data_size);
_buffer_memory_barrier(buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, false);
}
return storage_buffer_owner.make_rid(buffer);
}
RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const PoolVector<uint8_t> &p_data) {
RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const Vector<uint8_t> &p_data) {
_THREAD_SAFE_METHOD_
@ -4069,8 +4069,8 @@ RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataF
if (p_data.size()) {
uint64_t data_size = p_data.size();
PoolVector<uint8_t>::Read r = p_data.read();
_buffer_update(&texture_buffer.buffer, 0, r.ptr(), data_size);
const uint8_t *r = p_data.ptr();
_buffer_update(&texture_buffer.buffer, 0, r, data_size);
_buffer_memory_barrier(texture_buffer.buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, false);
}
@ -4689,7 +4689,7 @@ Error RenderingDeviceVulkan::buffer_update(RID p_buffer, uint32_t p_offset, uint
return err;
}
PoolVector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
_THREAD_SAFE_METHOD_
@ -4703,7 +4703,7 @@ PoolVector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
} else if (storage_buffer_owner.owns(p_buffer)) {
buffer = storage_buffer_owner.getornull(p_buffer);
} else {
ERR_FAIL_V_MSG(PoolVector<uint8_t>(), "Buffer is either invalid or this type of buffer can't be retrieved. Only Index and Vertex buffers allow retrieving.");
ERR_FAIL_V_MSG(Vector<uint8_t>(), "Buffer is either invalid or this type of buffer can't be retrieved. Only Index and Vertex buffers allow retrieving.");
}
VkCommandBuffer command_buffer = frames[frame].setup_command_buffer;
@ -4720,15 +4720,15 @@ PoolVector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
void *buffer_mem;
VkResult vkerr = vmaMapMemory(allocator, tmp_buffer.allocation, &buffer_mem);
if (vkerr) {
ERR_FAIL_V(PoolVector<uint8_t>());
ERR_FAIL_V(Vector<uint8_t>());
}
PoolVector<uint8_t> buffer_data;
Vector<uint8_t> buffer_data;
{
buffer_data.resize(buffer->size);
PoolVector<uint8_t>::Write w = buffer_data.write();
copymem(w.ptr(), buffer_mem, buffer->size);
uint8_t *w = buffer_data.ptrw();
copymem(w, buffer_mem, buffer->size);
}
vmaUnmapMemory(allocator, tmp_buffer.allocation);

View File

@ -150,7 +150,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
RID_Owner<Texture, true> texture_owner;
uint32_t texture_upload_region_size_px;
PoolVector<uint8_t> _texture_get_data_from_image(Texture *tex, VkImage p_image, VmaAllocation p_allocation, uint32_t p_layer, bool p_2d = false);
Vector<uint8_t> _texture_get_data_from_image(Texture *tex, VkImage p_image, VmaAllocation p_allocation, uint32_t p_layer, bool p_2d = false);
/*****************/
/**** SAMPLER ****/
@ -966,12 +966,12 @@ class RenderingDeviceVulkan : public RenderingDevice {
void _free_rids(T &p_owner, const char *p_type);
public:
virtual RID texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<PoolVector<uint8_t> > &p_data = Vector<PoolVector<uint8_t> >());
virtual RID texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t> > &p_data = Vector<Vector<uint8_t> >());
virtual RID texture_create_shared(const TextureView &p_view, RID p_with_texture);
virtual RID texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, TextureSliceType p_slice_type = TEXTURE_SLICE_2D);
virtual Error texture_update(RID p_texture, uint32_t p_layer, const PoolVector<uint8_t> &p_data, bool p_sync_with_draw = false);
virtual PoolVector<uint8_t> texture_get_data(RID p_texture, uint32_t p_layer);
virtual Error texture_update(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data, bool p_sync_with_draw = false);
virtual Vector<uint8_t> texture_get_data(RID p_texture, uint32_t p_layer);
virtual bool texture_is_format_supported_for_usage(DataFormat p_format, uint32_t p_usage) const;
virtual bool texture_is_shared(RID p_texture);
@ -1001,13 +1001,13 @@ public:
/**** VERTEX ARRAY ****/
/**********************/
virtual RID vertex_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>());
virtual RID vertex_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data = Vector<uint8_t>());
// Internally reference counted, this ID is warranted to be unique for the same description, but needs to be freed as many times as it was allocated
virtual VertexFormatID vertex_format_create(const Vector<VertexDescription> &p_vertex_formats);
virtual RID vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const Vector<RID> &p_src_buffers);
virtual RID index_buffer_create(uint32_t p_size_indices, IndexBufferFormat p_format, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>(), bool p_use_restart_indices = false);
virtual RID index_buffer_create(uint32_t p_size_indices, IndexBufferFormat p_format, const Vector<uint8_t> &p_data = Vector<uint8_t>(), bool p_use_restart_indices = false);
virtual RID index_array_create(RID p_index_buffer, uint32_t p_index_offset, uint32_t p_index_count);
@ -1022,15 +1022,15 @@ public:
/**** UNIFORM ****/
/*****************/
virtual RID uniform_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>());
virtual RID storage_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>());
virtual RID texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>());
virtual RID uniform_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data = Vector<uint8_t>());
virtual RID storage_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data = Vector<uint8_t>());
virtual RID texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const Vector<uint8_t> &p_data = Vector<uint8_t>());
virtual RID uniform_set_create(const Vector<Uniform> &p_uniforms, RID p_shader, uint32_t p_shader_set);
virtual bool uniform_set_is_valid(RID p_uniform_set);
virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const void *p_data, bool p_sync_with_draw = false); //works for any buffer
virtual PoolVector<uint8_t> buffer_get_data(RID p_buffer);
virtual Vector<uint8_t> buffer_get_data(RID p_buffer);
/*************************/
/**** RENDER PIPELINE ****/

View File

@ -66,9 +66,9 @@ Error MIDIDriverWinMidi::open() {
return OK;
}
PoolStringArray MIDIDriverWinMidi::get_connected_inputs() {
PackedStringArray MIDIDriverWinMidi::get_connected_inputs() {
PoolStringArray list;
PackedStringArray list;
for (int i = 0; i < connected_sources.size(); i++) {
HMIDIIN midi_in = connected_sources[i];

View File

@ -51,7 +51,7 @@ public:
virtual Error open();
virtual void close();
virtual PoolStringArray get_connected_inputs();
virtual PackedStringArray get_connected_inputs();
MIDIDriverWinMidi();
virtual ~MIDIDriverWinMidi();

View File

@ -555,12 +555,12 @@ void ConnectionsDock::_make_or_edit_connection() {
add_script_function = !found_inherited_function;
}
PoolStringArray script_function_args;
PackedStringArray script_function_args;
if (add_script_function) {
// Pick up args here before "it" is deleted by update_tree.
script_function_args = it->get_metadata(0).operator Dictionary()["args"];
for (int i = 0; i < cToMake.binds.size(); i++) {
script_function_args.append("extra_arg_" + itos(i) + ":" + Variant::get_type_name(cToMake.binds[i].get_type()));
script_function_args.push_back("extra_arg_" + itos(i) + ":" + Variant::get_type_name(cToMake.binds[i].get_type()));
}
}
@ -943,7 +943,7 @@ void ConnectionsDock::update_tree() {
StringName signal_name = mi.name;
String signaldesc = "(";
PoolStringArray argnames;
PackedStringArray argnames;
if (mi.arguments.size()) {
for (int i = 0; i < mi.arguments.size(); i++) {

View File

@ -184,12 +184,12 @@ void DocDump::dump(const String &p_file) {
case Variant::AABB:
case Variant::BASIS:
case Variant::COLOR:
case Variant::POOL_BYTE_ARRAY:
case Variant::POOL_INT_ARRAY:
case Variant::POOL_REAL_ARRAY:
case Variant::POOL_STRING_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_VECTOR3_ARRAY:
case Variant::PACKED_COLOR_ARRAY:
default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")";
break;
case Variant::OBJECT:

View File

@ -521,7 +521,7 @@ Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control
if (autoload_cache.size() <= 1)
return false;
PoolStringArray autoloads;
PackedStringArray autoloads;
TreeItem *next = tree->get_next_selected(NULL);
@ -612,7 +612,7 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &
}
Dictionary drop_data = p_data;
PoolStringArray autoloads = drop_data["autoloads"];
PackedStringArray autoloads = drop_data["autoloads"];
Vector<int> orders;
orders.resize(autoload_cache.size());

View File

@ -582,14 +582,14 @@ String EditorExportPlugin::get_ios_cpp_code() const {
return ios_cpp_code;
}
void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const PoolVector<String> &p_features) {
void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features) {
if (get_script_instance()) {
get_script_instance()->call("_export_file", p_path, p_type, p_features);
}
}
void EditorExportPlugin::_export_begin_script(const PoolVector<String> &p_features, bool p_debug, const String &p_path, int p_flags) {
void EditorExportPlugin::_export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags) {
if (get_script_instance()) {
get_script_instance()->call("_export_begin", p_features, p_debug, p_path, p_flags);
@ -625,8 +625,8 @@ void EditorExportPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_ios_cpp_code", "code"), &EditorExportPlugin::add_ios_cpp_code);
ClassDB::bind_method(D_METHOD("skip"), &EditorExportPlugin::skip);
BIND_VMETHOD(MethodInfo("_export_file", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "type"), PropertyInfo(Variant::POOL_STRING_ARRAY, "features")));
BIND_VMETHOD(MethodInfo("_export_begin", PropertyInfo(Variant::POOL_STRING_ARRAY, "features"), PropertyInfo(Variant::BOOL, "is_debug"), PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::INT, "flags")));
BIND_VMETHOD(MethodInfo("_export_file", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "type"), PropertyInfo(Variant::PACKED_STRING_ARRAY, "features")));
BIND_VMETHOD(MethodInfo("_export_begin", PropertyInfo(Variant::PACKED_STRING_ARRAY, "features"), PropertyInfo(Variant::BOOL, "is_debug"), PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::INT, "flags")));
BIND_VMETHOD(MethodInfo("_export_end"));
}
@ -731,7 +731,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
FeatureContainers feature_containers = get_feature_containers(p_preset);
Set<String> &features = feature_containers.features;
PoolVector<String> &features_pv = feature_containers.features_pv;
Vector<String> &features_pv = feature_containers.features_pv;
//store everything in the export medium
int idx = 0;

View File

@ -188,7 +188,7 @@ private:
struct FeatureContainers {
Set<String> features;
PoolVector<String> features_pv;
Vector<String> features_pv;
};
void _export_find_resources(EditorFileSystemDirectory *p_dir, Set<String> &p_paths);
@ -310,8 +310,8 @@ class EditorExportPlugin : public Reference {
ios_cpp_code = "";
}
void _export_file_script(const String &p_path, const String &p_type, const PoolVector<String> &p_features);
void _export_begin_script(const PoolVector<String> &p_features, bool p_debug, const String &p_path, int p_flags);
void _export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features);
void _export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags);
void _export_end_script();
protected:

View File

@ -347,7 +347,7 @@ void EditorFileDialog::_action_pressed() {
String fbase = dir_access->get_current_dir();
PoolVector<String> files;
Vector<String> files;
for (int i = 0; i < item_list->get_item_count(); i++) {
if (item_list->is_selected(i))
files.push_back(fbase.plus_file(item_list->get_item_text(i)));
@ -1419,7 +1419,7 @@ void EditorFileDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("invalidate"), &EditorFileDialog::invalidate);
ADD_SIGNAL(MethodInfo("file_selected", PropertyInfo(Variant::STRING, "path")));
ADD_SIGNAL(MethodInfo("files_selected", PropertyInfo(Variant::POOL_STRING_ARRAY, "paths")));
ADD_SIGNAL(MethodInfo("files_selected", PropertyInfo(Variant::PACKED_STRING_ARRAY, "paths")));
ADD_SIGNAL(MethodInfo("dir_selected", PropertyInfo(Variant::STRING, "dir")));
ADD_PROPERTY(PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"), "set_access", "get_access");

View File

@ -2100,8 +2100,8 @@ void EditorFileSystem::_bind_methods() {
ADD_SIGNAL(MethodInfo("filesystem_changed"));
ADD_SIGNAL(MethodInfo("sources_changed", PropertyInfo(Variant::BOOL, "exist")));
ADD_SIGNAL(MethodInfo("resources_reimported", PropertyInfo(Variant::POOL_STRING_ARRAY, "resources")));
ADD_SIGNAL(MethodInfo("resources_reload", PropertyInfo(Variant::POOL_STRING_ARRAY, "resources")));
ADD_SIGNAL(MethodInfo("resources_reimported", PropertyInfo(Variant::PACKED_STRING_ARRAY, "resources")));
ADD_SIGNAL(MethodInfo("resources_reload", PropertyInfo(Variant::PACKED_STRING_ARRAY, "resources")));
}
void EditorFileSystem::_update_extensions() {

View File

@ -34,12 +34,12 @@
#include "editor_inspector.h"
#include "editor_settings.h"
PoolVector<String> EditorFolding::_get_unfolds(const Object *p_object) {
Vector<String> EditorFolding::_get_unfolds(const Object *p_object) {
PoolVector<String> sections;
Vector<String> sections;
sections.resize(p_object->editor_get_section_folding().size());
if (sections.size()) {
PoolVector<String>::Write w = sections.write();
String *w = sections.ptrw();
int idx = 0;
for (const Set<String>::Element *E = p_object->editor_get_section_folding().front(); E; E = E->next()) {
w[idx++] = E->get();
@ -52,7 +52,7 @@ PoolVector<String> EditorFolding::_get_unfolds(const Object *p_object) {
void EditorFolding::save_resource_folding(const RES &p_resource, const String &p_path) {
Ref<ConfigFile> config;
config.instance();
PoolVector<String> unfolds = _get_unfolds(p_resource.ptr());
Vector<String> unfolds = _get_unfolds(p_resource.ptr());
config->set_value("folding", "sections_unfolded", unfolds);
String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg";
@ -60,10 +60,10 @@ void EditorFolding::save_resource_folding(const RES &p_resource, const String &p
config->save(file);
}
void EditorFolding::_set_unfolds(Object *p_object, const PoolVector<String> &p_unfolds) {
void EditorFolding::_set_unfolds(Object *p_object, const Vector<String> &p_unfolds) {
int uc = p_unfolds.size();
PoolVector<String>::Read r = p_unfolds.read();
const String *r = p_unfolds.ptr();
p_object->editor_clear_section_folding();
for (int i = 0; i < uc; i++) {
p_object->editor_set_section_unfold(r[i], true);
@ -82,7 +82,7 @@ void EditorFolding::load_resource_folding(RES p_resource, const String &p_path)
return;
}
PoolVector<String> unfolds;
Vector<String> unfolds;
if (config->has_section_key("folding", "sections_unfolded")) {
unfolds = config->get_value("folding", "sections_unfolded");
@ -103,7 +103,7 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p
if (p_node->is_displayed_folded()) {
nodes_folded.push_back(p_root->get_path_to(p_node));
}
PoolVector<String> unfolds = _get_unfolds(p_node);
Vector<String> unfolds = _get_unfolds(p_node);
if (unfolds.size()) {
p_folds.push_back(p_root->get_path_to(p_node));
@ -118,7 +118,7 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p
RES res = p_node->get(E->get().name);
if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) {
PoolVector<String> res_unfolds = _get_unfolds(res.ptr());
Vector<String> res_unfolds = _get_unfolds(res.ptr());
resource_folds.push_back(res->get_path());
resource_folds.push_back(res_unfolds);
resources.insert(res);
@ -184,7 +184,7 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
for (int i = 0; i < unfolds.size(); i += 2) {
NodePath path2 = unfolds[i];
PoolVector<String> un = unfolds[i + 1];
Vector<String> un = unfolds[i + 1];
Node *node = p_scene->get_node_or_null(path2);
if (!node) {
continue;
@ -202,7 +202,7 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
continue;
}
PoolVector<String> unfolds2 = res_unfolds[i + 1];
Vector<String> unfolds2 = res_unfolds[i + 1];
_set_unfolds(res.ptr(), unfolds2);
}

View File

@ -35,8 +35,8 @@
class EditorFolding {
PoolVector<String> _get_unfolds(const Object *p_object);
void _set_unfolds(Object *p_object, const PoolVector<String> &p_unfolds);
Vector<String> _get_unfolds(const Object *p_object);
void _set_unfolds(Object *p_object, const Vector<String> &p_unfolds);
void _fill_folds(const Node *p_root, const Node *p_node, Array &p_folds, Array &resource_folds, Array &nodes_folded, Set<RES> &resources);

View File

@ -829,7 +829,7 @@ void EditorProperty::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_red"), "set_draw_red", "is_draw_red");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keying"), "set_keying", "is_keying");
ADD_SIGNAL(MethodInfo("property_changed", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT)));
ADD_SIGNAL(MethodInfo("multiple_properties_changed", PropertyInfo(Variant::POOL_STRING_ARRAY, "properties"), PropertyInfo(Variant::ARRAY, "value")));
ADD_SIGNAL(MethodInfo("multiple_properties_changed", PropertyInfo(Variant::PACKED_STRING_ARRAY, "properties"), PropertyInfo(Variant::ARRAY, "value")));
ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property")));
ADD_SIGNAL(MethodInfo("property_keyed_with_value", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT)));
ADD_SIGNAL(MethodInfo("property_checked", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::STRING, "bool")));

View File

@ -547,7 +547,7 @@ void EditorNode::_on_plugin_ready(Object *p_script, const String &p_activate_nam
push_item(script.operator->());
}
void EditorNode::_resources_changed(const PoolVector<String> &p_resources) {
void EditorNode::_resources_changed(const Vector<String> &p_resources) {
List<Ref<Resource> > changed;
@ -3052,7 +3052,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled,
String addon_path = String("res://addons").plus_file(p_addon).plus_file("plugin.cfg");
if (!DirAccess::exists(addon_path.get_base_dir())) {
ProjectSettings *ps = ProjectSettings::get_singleton();
PoolStringArray enabled_plugins = ps->get("editor_plugins/enabled");
PackedStringArray enabled_plugins = ps->get("editor_plugins/enabled");
for (int i = 0; i < enabled_plugins.size(); ++i) {
if (enabled_plugins.get(i) == p_addon) {
enabled_plugins.remove(i);
@ -5519,7 +5519,7 @@ void EditorNode::_bind_methods() {
ADD_SIGNAL(MethodInfo("pause_pressed"));
ADD_SIGNAL(MethodInfo("stop_pressed"));
ADD_SIGNAL(MethodInfo("request_help_search"));
ADD_SIGNAL(MethodInfo("script_add_function_request", PropertyInfo(Variant::OBJECT, "obj"), PropertyInfo(Variant::STRING, "function"), PropertyInfo(Variant::POOL_STRING_ARRAY, "args")));
ADD_SIGNAL(MethodInfo("script_add_function_request", PropertyInfo(Variant::OBJECT, "obj"), PropertyInfo(Variant::STRING, "function"), PropertyInfo(Variant::PACKED_STRING_ARRAY, "args")));
ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "obj")));
}

View File

@ -639,7 +639,7 @@ private:
static void _resource_saved(RES p_resource, const String &p_path);
static void _resource_loaded(RES p_resource, const String &p_path);
void _resources_changed(const PoolVector<String> &p_resources);
void _resources_changed(const Vector<String> &p_resources);
void _feature_profile_changed();
bool _is_class_editor_disabled_by_feature_profile(const StringName &p_class);

View File

@ -688,7 +688,7 @@ void EditorPlugin::apply_changes() {
void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
if (get_script_instance() && get_script_instance()->has_method("get_breakpoints")) {
PoolStringArray arr = get_script_instance()->call("get_breakpoints");
PackedStringArray arr = get_script_instance()->call("get_breakpoints");
for (int i = 0; i < arr.size(); i++)
p_breakpoints->push_back(arr[i]);
}
@ -743,8 +743,8 @@ void EditorPlugin::remove_scene_import_plugin(const Ref<EditorSceneImporter> &p_
ResourceImporterScene::get_singleton()->remove_importer(p_importer);
}
int find(const PoolStringArray &a, const String &v) {
PoolStringArray::Read r = a.read();
int find(const PackedStringArray &a, const String &v) {
const String *r = a.ptr();
for (int j = 0; j < a.size(); ++j) {
if (r[j] == v) {
return j;
@ -872,7 +872,7 @@ void EditorPlugin::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), MethodInfo("clear"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("save_external_data"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("apply_changes"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::POOL_STRING_ARRAY, "get_breakpoints"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::PACKED_STRING_ARRAY, "get_breakpoints"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "build"));

View File

@ -175,7 +175,7 @@ void EditorProfiler::_update_plot() {
graph_image.resize(desired_len);
}
PoolVector<uint8_t>::Write wr = graph_image.write();
uint8_t *wr = graph_image.ptrw();
const Color background_color = get_color("dark_color_2", "Editor");
// Clear the previous frame and set the background color.
@ -342,8 +342,6 @@ void EditorProfiler::_update_plot() {
}
}
wr.release();
Ref<Image> img;
img.instance();
img->create(w, h, 0, Image::FORMAT_RGBA8, graph_image);

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