Memory pool vectors (DVector) have been enormously simplified in code, and renamed to PoolVector
This commit is contained in:
parent
2a38a5eaa8
commit
2ab83e1abb
257 changed files with 2818 additions and 3130 deletions
|
@ -477,17 +477,34 @@ uint32_t ihash3( uint32_t a)
|
||||||
|
|
||||||
MainLoop* test() {
|
MainLoop* test() {
|
||||||
|
|
||||||
Matrix3 m;
|
|
||||||
m.rotate(Vector3(0,1,0),Math_PI*0.5);
|
|
||||||
|
|
||||||
print_line(m.scaled(Vector3(0.5,1,1)));
|
print_line("Dvectors: "+itos(MemoryPool::allocs_used));
|
||||||
Matrix3 s;
|
print_line("Mem used: "+itos(MemoryPool::total_memory));
|
||||||
s.scale(Vector3(0.5,1.0,1.0));
|
print_line("MAx mem used: "+itos(MemoryPool::max_memory));
|
||||||
|
|
||||||
print_line(m * s);
|
PoolVector<int> ints;
|
||||||
|
ints.resize(20);
|
||||||
|
|
||||||
|
{
|
||||||
|
PoolVector<int>::Write w;
|
||||||
|
w = ints.write();
|
||||||
|
for(int i=0;i<ints.size();i++) {
|
||||||
|
w[i]=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PoolVector<int> posho = ints;
|
||||||
|
|
||||||
|
{
|
||||||
|
PoolVector<int>::Read r = posho.read();
|
||||||
|
for(int i=0;i<posho.size();i++) {
|
||||||
|
print_line(itos(i)+" : " +itos(r[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_line("later Dvectors: "+itos(MemoryPool::allocs_used));
|
||||||
|
print_line("later Mem used: "+itos(MemoryPool::total_memory));
|
||||||
|
print_line("Mlater Ax mem used: "+itos(MemoryPool::max_memory));
|
||||||
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -718,8 +735,8 @@ MainLoop* test() {
|
||||||
print_line(String("res://..").simplify_path());
|
print_line(String("res://..").simplify_path());
|
||||||
|
|
||||||
|
|
||||||
DVector<uint8_t> a;
|
PoolVector<uint8_t> a;
|
||||||
DVector<uint8_t> b;
|
PoolVector<uint8_t> b;
|
||||||
|
|
||||||
a.resize(20);
|
a.resize(20);
|
||||||
b=a;
|
b=a;
|
||||||
|
|
|
@ -146,7 +146,7 @@ protected:
|
||||||
|
|
||||||
/* BOX SHAPE */
|
/* BOX SHAPE */
|
||||||
|
|
||||||
DVector<Plane> box_planes = Geometry::build_box_planes(Vector3(0.5,0.5,0.5));
|
PoolVector<Plane> box_planes = Geometry::build_box_planes(Vector3(0.5,0.5,0.5));
|
||||||
RID box_mesh = vs->mesh_create();
|
RID box_mesh = vs->mesh_create();
|
||||||
Geometry::MeshData box_data = Geometry::build_convex_mesh(box_planes);
|
Geometry::MeshData box_data = Geometry::build_convex_mesh(box_planes);
|
||||||
vs->mesh_add_surface_from_mesh_data(box_mesh,box_data);
|
vs->mesh_add_surface_from_mesh_data(box_mesh,box_data);
|
||||||
|
@ -159,7 +159,7 @@ protected:
|
||||||
|
|
||||||
/* CAPSULE SHAPE */
|
/* CAPSULE SHAPE */
|
||||||
|
|
||||||
DVector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5,0.7,12,Vector3::AXIS_Z);
|
PoolVector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5,0.7,12,Vector3::AXIS_Z);
|
||||||
|
|
||||||
RID capsule_mesh = vs->mesh_create();
|
RID capsule_mesh = vs->mesh_create();
|
||||||
Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
|
Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
|
||||||
|
@ -176,7 +176,7 @@ protected:
|
||||||
|
|
||||||
/* CONVEX SHAPE */
|
/* CONVEX SHAPE */
|
||||||
|
|
||||||
DVector<Plane> convex_planes = Geometry::build_cylinder_planes(0.5,0.7,5,Vector3::AXIS_Z);
|
PoolVector<Plane> convex_planes = Geometry::build_cylinder_planes(0.5,0.7,5,Vector3::AXIS_Z);
|
||||||
|
|
||||||
RID convex_mesh = vs->mesh_create();
|
RID convex_mesh = vs->mesh_create();
|
||||||
Geometry::MeshData convex_data = Geometry::build_convex_mesh(convex_planes);
|
Geometry::MeshData convex_data = Geometry::build_convex_mesh(convex_planes);
|
||||||
|
@ -534,7 +534,7 @@ public:
|
||||||
PhysicsServer * ps = PhysicsServer::get_singleton();
|
PhysicsServer * ps = PhysicsServer::get_singleton();
|
||||||
|
|
||||||
|
|
||||||
DVector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5,1,12,5,Vector3::AXIS_Y);
|
PoolVector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5,1,12,5,Vector3::AXIS_Y);
|
||||||
|
|
||||||
RID capsule_mesh = vs->mesh_create();
|
RID capsule_mesh = vs->mesh_create();
|
||||||
Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
|
Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
|
||||||
|
|
|
@ -74,7 +74,7 @@ class TestPhysics2DMainLoop : public MainLoop {
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
DVector<uint8_t> pixels;
|
PoolVector<uint8_t> pixels;
|
||||||
pixels.resize(32*2*2);
|
pixels.resize(32*2*2);
|
||||||
for(int i=0;i<2;i++) {
|
for(int i=0;i<2;i++) {
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class TestPhysics2DMainLoop : public MainLoop {
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
DVector<uint8_t> pixels;
|
PoolVector<uint8_t> pixels;
|
||||||
pixels.resize(32*32*2);
|
pixels.resize(32*32*2);
|
||||||
for(int i=0;i<32;i++) {
|
for(int i=0;i<32;i++) {
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class TestPhysics2DMainLoop : public MainLoop {
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
DVector<uint8_t> pixels;
|
PoolVector<uint8_t> pixels;
|
||||||
pixels.resize(32*32*2);
|
pixels.resize(32*32*2);
|
||||||
for(int i=0;i<32;i++) {
|
for(int i=0;i<32;i++) {
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ class TestPhysics2DMainLoop : public MainLoop {
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
DVector<uint8_t> pixels;
|
PoolVector<uint8_t> pixels;
|
||||||
pixels.resize(32*64*2);
|
pixels.resize(32*64*2);
|
||||||
for(int i=0;i<64;i++) {
|
for(int i=0;i<64;i++) {
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ class TestPhysics2DMainLoop : public MainLoop {
|
||||||
|
|
||||||
RID convex_polygon_shape = ps->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON);
|
RID convex_polygon_shape = ps->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON);
|
||||||
|
|
||||||
DVector<Vector2> arr;
|
PoolVector<Vector2> arr;
|
||||||
Point2 sb(32,32);
|
Point2 sb(32,32);
|
||||||
arr.push_back(Point2(20,3)-sb);
|
arr.push_back(Point2(20,3)-sb);
|
||||||
arr.push_back(Point2(58,23)-sb);
|
arr.push_back(Point2(58,23)-sb);
|
||||||
|
|
|
@ -87,7 +87,7 @@ public:
|
||||||
Vector<Vector3> vts;
|
Vector<Vector3> vts;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
DVector<Plane> sp = Geometry::build_sphere_planes(2,5,5);
|
PoolVector<Plane> sp = Geometry::build_sphere_planes(2,5,5);
|
||||||
Geometry::MeshData md2 = Geometry::build_convex_mesh(sp);
|
Geometry::MeshData md2 = Geometry::build_convex_mesh(sp);
|
||||||
vts=md2.vertices;
|
vts=md2.vertices;
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -69,11 +69,11 @@ RES _ResourceLoader::load(const String &p_path,const String& p_type_hint, bool p
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<String> _ResourceLoader::get_recognized_extensions_for_type(const String& p_type) {
|
PoolVector<String> _ResourceLoader::get_recognized_extensions_for_type(const String& p_type) {
|
||||||
|
|
||||||
List<String> exts;
|
List<String> exts;
|
||||||
ResourceLoader::get_recognized_extensions_for_type(p_type,&exts);
|
ResourceLoader::get_recognized_extensions_for_type(p_type,&exts);
|
||||||
DVector<String> ret;
|
PoolVector<String> ret;
|
||||||
for(List<String>::Element *E=exts.front();E;E=E->next()) {
|
for(List<String>::Element *E=exts.front();E;E=E->next()) {
|
||||||
|
|
||||||
ret.push_back(E->get());
|
ret.push_back(E->get());
|
||||||
|
@ -135,12 +135,12 @@ Error _ResourceSaver::save(const String &p_path,const RES& p_resource, uint32_t
|
||||||
return ResourceSaver::save(p_path,p_resource, p_flags);
|
return ResourceSaver::save(p_path,p_resource, p_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<String> _ResourceSaver::get_recognized_extensions(const RES& p_resource) {
|
PoolVector<String> _ResourceSaver::get_recognized_extensions(const RES& p_resource) {
|
||||||
|
|
||||||
ERR_FAIL_COND_V(p_resource.is_null(),DVector<String>());
|
ERR_FAIL_COND_V(p_resource.is_null(),PoolVector<String>());
|
||||||
List<String> exts;
|
List<String> exts;
|
||||||
ResourceSaver::get_recognized_extensions(p_resource,&exts);
|
ResourceSaver::get_recognized_extensions(p_resource,&exts);
|
||||||
DVector<String> ret;
|
PoolVector<String> ret;
|
||||||
for(List<String>::Element *E=exts.front();E;E=E->next()) {
|
for(List<String>::Element *E=exts.front();E;E=E->next()) {
|
||||||
|
|
||||||
ret.push_back(E->get());
|
ret.push_back(E->get());
|
||||||
|
@ -1232,16 +1232,16 @@ _Geometry *_Geometry::get_singleton() {
|
||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<Plane> _Geometry::build_box_planes(const Vector3& p_extents) {
|
PoolVector<Plane> _Geometry::build_box_planes(const Vector3& p_extents) {
|
||||||
|
|
||||||
return Geometry::build_box_planes(p_extents);
|
return Geometry::build_box_planes(p_extents);
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<Plane> _Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
|
PoolVector<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);
|
return Geometry::build_cylinder_planes(p_radius,p_height,p_sides,p_axis);
|
||||||
}
|
}
|
||||||
DVector<Plane> _Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
|
PoolVector<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);
|
return Geometry::build_capsule_planes(p_radius,p_height,p_sides,p_lats,p_axis);
|
||||||
}
|
}
|
||||||
|
@ -1262,22 +1262,22 @@ Variant _Geometry::segment_intersects_segment_2d(const Vector2& p_from_a,const V
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
DVector<Vector2> _Geometry::get_closest_points_between_segments_2d( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2) {
|
PoolVector<Vector2> _Geometry::get_closest_points_between_segments_2d( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2) {
|
||||||
|
|
||||||
Vector2 r1, r2;
|
Vector2 r1, r2;
|
||||||
Geometry::get_closest_points_between_segments(p1,q1,p2,q2,r1,r2);
|
Geometry::get_closest_points_between_segments(p1,q1,p2,q2,r1,r2);
|
||||||
DVector<Vector2> r;
|
PoolVector<Vector2> r;
|
||||||
r.resize(2);
|
r.resize(2);
|
||||||
r.set(0,r1);
|
r.set(0,r1);
|
||||||
r.set(1,r2);
|
r.set(1,r2);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<Vector3> _Geometry::get_closest_points_between_segments(const Vector3& p1,const Vector3& p2,const Vector3& q1,const Vector3& q2) {
|
PoolVector<Vector3> _Geometry::get_closest_points_between_segments(const Vector3& p1,const Vector3& p2,const Vector3& q1,const Vector3& q2) {
|
||||||
|
|
||||||
Vector3 r1, r2;
|
Vector3 r1, r2;
|
||||||
Geometry::get_closest_points_between_segments(p1,p2,q1,q2,r1,r2);
|
Geometry::get_closest_points_between_segments(p1,p2,q1,q2,r1,r2);
|
||||||
DVector<Vector3> r;
|
PoolVector<Vector3> r;
|
||||||
r.resize(2);
|
r.resize(2);
|
||||||
r.set(0,r1);
|
r.set(0,r1);
|
||||||
r.set(1,r2);
|
r.set(1,r2);
|
||||||
|
@ -1314,9 +1314,9 @@ bool _Geometry::point_is_inside_triangle(const Vector2& s, const Vector2& a, con
|
||||||
return Geometry::is_point_in_triangle(s,a,b,c);
|
return Geometry::is_point_in_triangle(s,a,b,c);
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<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> _Geometry::segment_intersects_sphere( const Vector3& p_from, const Vector3& p_to, const Vector3& p_sphere_pos,real_t p_sphere_radius) {
|
||||||
|
|
||||||
DVector<Vector3> r;
|
PoolVector<Vector3> r;
|
||||||
Vector3 res,norm;
|
Vector3 res,norm;
|
||||||
if (!Geometry::segment_intersects_sphere(p_from,p_to,p_sphere_pos,p_sphere_radius,&res,&norm))
|
if (!Geometry::segment_intersects_sphere(p_from,p_to,p_sphere_pos,p_sphere_radius,&res,&norm))
|
||||||
return r;
|
return r;
|
||||||
|
@ -1326,9 +1326,9 @@ DVector<Vector3> _Geometry::segment_intersects_sphere( const Vector3& p_from, co
|
||||||
r.set(1,norm);
|
r.set(1,norm);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
DVector<Vector3> _Geometry::segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, float p_height,float p_radius) {
|
PoolVector<Vector3> _Geometry::segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, float p_height,float p_radius) {
|
||||||
|
|
||||||
DVector<Vector3> r;
|
PoolVector<Vector3> r;
|
||||||
Vector3 res,norm;
|
Vector3 res,norm;
|
||||||
if (!Geometry::segment_intersects_cylinder(p_from,p_to,p_height,p_radius,&res,&norm))
|
if (!Geometry::segment_intersects_cylinder(p_from,p_to,p_height,p_radius,&res,&norm))
|
||||||
return r;
|
return r;
|
||||||
|
@ -1339,9 +1339,9 @@ DVector<Vector3> _Geometry::segment_intersects_cylinder( const Vector3& p_from,
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
}
|
}
|
||||||
DVector<Vector3> _Geometry::segment_intersects_convex(const Vector3& p_from, const Vector3& p_to,const Vector<Plane>& p_planes) {
|
PoolVector<Vector3> _Geometry::segment_intersects_convex(const Vector3& p_from, const Vector3& p_to,const Vector<Plane>& p_planes) {
|
||||||
|
|
||||||
DVector<Vector3> r;
|
PoolVector<Vector3> r;
|
||||||
Vector3 res,norm;
|
Vector3 res,norm;
|
||||||
if (!Geometry::segment_intersects_convex(p_from,p_to,p_planes.ptr(),p_planes.size(),&res,&norm))
|
if (!Geometry::segment_intersects_convex(p_from,p_to,p_planes.ptr(),p_planes.size(),&res,&norm))
|
||||||
return r;
|
return r;
|
||||||
|
@ -1566,9 +1566,9 @@ real_t _File::get_real() const{
|
||||||
return f->get_real();
|
return f->get_real();
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t> _File::get_buffer(int p_length) const{
|
PoolVector<uint8_t> _File::get_buffer(int p_length) const{
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
ERR_FAIL_COND_V(!f,data);
|
ERR_FAIL_COND_V(!f,data);
|
||||||
|
|
||||||
ERR_FAIL_COND_V(p_length<0,data);
|
ERR_FAIL_COND_V(p_length<0,data);
|
||||||
|
@ -1576,11 +1576,11 @@ DVector<uint8_t> _File::get_buffer(int p_length) const{
|
||||||
return data;
|
return data;
|
||||||
Error err = data.resize(p_length);
|
Error err = data.resize(p_length);
|
||||||
ERR_FAIL_COND_V(err!=OK,data);
|
ERR_FAIL_COND_V(err!=OK,data);
|
||||||
DVector<uint8_t>::Write w = data.write();
|
PoolVector<uint8_t>::Write w = data.write();
|
||||||
int len = f->get_buffer(&w[0],p_length);
|
int len = f->get_buffer(&w[0],p_length);
|
||||||
ERR_FAIL_COND_V( len < 0 , DVector<uint8_t>());
|
ERR_FAIL_COND_V( len < 0 , PoolVector<uint8_t>());
|
||||||
|
|
||||||
w = DVector<uint8_t>::Write();
|
w = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
if (len < p_length)
|
if (len < p_length)
|
||||||
data.resize(p_length);
|
data.resize(p_length);
|
||||||
|
@ -1735,7 +1735,7 @@ void _File::store_line(const String& p_string){
|
||||||
f->store_line(p_string);
|
f->store_line(p_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _File::store_buffer(const DVector<uint8_t>& p_buffer){
|
void _File::store_buffer(const PoolVector<uint8_t>& p_buffer){
|
||||||
|
|
||||||
ERR_FAIL_COND(!f);
|
ERR_FAIL_COND(!f);
|
||||||
|
|
||||||
|
@ -1743,7 +1743,7 @@ void _File::store_buffer(const DVector<uint8_t>& p_buffer){
|
||||||
if (len==0)
|
if (len==0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = p_buffer.read();
|
PoolVector<uint8_t>::Read r = p_buffer.read();
|
||||||
|
|
||||||
f->store_buffer(&r[0],len);
|
f->store_buffer(&r[0],len);
|
||||||
}
|
}
|
||||||
|
@ -1762,13 +1762,13 @@ void _File::store_var(const Variant& p_var) {
|
||||||
Error err = encode_variant(p_var,NULL,len);
|
Error err = encode_variant(p_var,NULL,len);
|
||||||
ERR_FAIL_COND( err != OK );
|
ERR_FAIL_COND( err != OK );
|
||||||
|
|
||||||
DVector<uint8_t> buff;
|
PoolVector<uint8_t> buff;
|
||||||
buff.resize(len);
|
buff.resize(len);
|
||||||
DVector<uint8_t>::Write w = buff.write();
|
PoolVector<uint8_t>::Write w = buff.write();
|
||||||
|
|
||||||
err = encode_variant(p_var,&w[0],len);
|
err = encode_variant(p_var,&w[0],len);
|
||||||
ERR_FAIL_COND( err != OK );
|
ERR_FAIL_COND( err != OK );
|
||||||
w=DVector<uint8_t>::Write();
|
w=PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
store_32(len);
|
store_32(len);
|
||||||
store_buffer(buff);
|
store_buffer(buff);
|
||||||
|
@ -1778,10 +1778,10 @@ Variant _File::get_var() const {
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!f,Variant());
|
ERR_FAIL_COND_V(!f,Variant());
|
||||||
uint32_t len = get_32();
|
uint32_t len = get_32();
|
||||||
DVector<uint8_t> buff = get_buffer(len);
|
PoolVector<uint8_t> buff = get_buffer(len);
|
||||||
ERR_FAIL_COND_V(buff.size() != len, Variant());
|
ERR_FAIL_COND_V(buff.size() != len, Variant());
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = buff.read();
|
PoolVector<uint8_t>::Read r = buff.read();
|
||||||
|
|
||||||
Variant v;
|
Variant v;
|
||||||
Error err = decode_variant(v,&r[0],len);
|
Error err = decode_variant(v,&r[0],len);
|
||||||
|
@ -2056,17 +2056,17 @@ String _Marshalls::variant_to_base64(const Variant& p_var) {
|
||||||
Error err = encode_variant(p_var,NULL,len);
|
Error err = encode_variant(p_var,NULL,len);
|
||||||
ERR_FAIL_COND_V( err != OK, "" );
|
ERR_FAIL_COND_V( err != OK, "" );
|
||||||
|
|
||||||
DVector<uint8_t> buff;
|
PoolVector<uint8_t> buff;
|
||||||
buff.resize(len);
|
buff.resize(len);
|
||||||
DVector<uint8_t>::Write w = buff.write();
|
PoolVector<uint8_t>::Write w = buff.write();
|
||||||
|
|
||||||
err = encode_variant(p_var,&w[0],len);
|
err = encode_variant(p_var,&w[0],len);
|
||||||
ERR_FAIL_COND_V( err != OK, "" );
|
ERR_FAIL_COND_V( err != OK, "" );
|
||||||
|
|
||||||
int b64len = len / 3 * 4 + 4 + 1;
|
int b64len = len / 3 * 4 + 4 + 1;
|
||||||
DVector<uint8_t> b64buff;
|
PoolVector<uint8_t> b64buff;
|
||||||
b64buff.resize(b64len);
|
b64buff.resize(b64len);
|
||||||
DVector<uint8_t>::Write w64 = b64buff.write();
|
PoolVector<uint8_t>::Write w64 = b64buff.write();
|
||||||
|
|
||||||
int strlen = base64_encode((char*)(&w64[0]), (char*)(&w[0]), len);
|
int strlen = base64_encode((char*)(&w64[0]), (char*)(&w[0]), len);
|
||||||
//OS::get_singleton()->print("len is %i, vector size is %i\n", b64len, strlen);
|
//OS::get_singleton()->print("len is %i, vector size is %i\n", b64len, strlen);
|
||||||
|
@ -2081,9 +2081,9 @@ Variant _Marshalls::base64_to_variant(const String& p_str) {
|
||||||
int strlen = p_str.length();
|
int strlen = p_str.length();
|
||||||
CharString cstr = p_str.ascii();
|
CharString cstr = p_str.ascii();
|
||||||
|
|
||||||
DVector<uint8_t> buf;
|
PoolVector<uint8_t> buf;
|
||||||
buf.resize(strlen / 4 * 3 + 1);
|
buf.resize(strlen / 4 * 3 + 1);
|
||||||
DVector<uint8_t>::Write w = buf.write();
|
PoolVector<uint8_t>::Write w = buf.write();
|
||||||
|
|
||||||
int len = base64_decode((char*)(&w[0]), (char*)cstr.get_data(), strlen);
|
int len = base64_decode((char*)(&w[0]), (char*)cstr.get_data(), strlen);
|
||||||
|
|
||||||
|
@ -2094,15 +2094,15 @@ Variant _Marshalls::base64_to_variant(const String& p_str) {
|
||||||
return v;
|
return v;
|
||||||
};
|
};
|
||||||
|
|
||||||
String _Marshalls::raw_to_base64(const DVector<uint8_t> &p_arr) {
|
String _Marshalls::raw_to_base64(const PoolVector<uint8_t> &p_arr) {
|
||||||
|
|
||||||
int len = p_arr.size();
|
int len = p_arr.size();
|
||||||
DVector<uint8_t>::Read r = p_arr.read();
|
PoolVector<uint8_t>::Read r = p_arr.read();
|
||||||
|
|
||||||
int b64len = len / 3 * 4 + 4 + 1;
|
int b64len = len / 3 * 4 + 4 + 1;
|
||||||
DVector<uint8_t> b64buff;
|
PoolVector<uint8_t> b64buff;
|
||||||
b64buff.resize(b64len);
|
b64buff.resize(b64len);
|
||||||
DVector<uint8_t>::Write w64 = b64buff.write();
|
PoolVector<uint8_t>::Write w64 = b64buff.write();
|
||||||
|
|
||||||
int strlen = base64_encode((char*)(&w64[0]), (char*)(&r[0]), len);
|
int strlen = base64_encode((char*)(&w64[0]), (char*)(&r[0]), len);
|
||||||
w64[strlen] = 0;
|
w64[strlen] = 0;
|
||||||
|
@ -2111,22 +2111,22 @@ String _Marshalls::raw_to_base64(const DVector<uint8_t> &p_arr) {
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
DVector<uint8_t> _Marshalls::base64_to_raw(const String &p_str) {
|
PoolVector<uint8_t> _Marshalls::base64_to_raw(const String &p_str) {
|
||||||
|
|
||||||
int strlen = p_str.length();
|
int strlen = p_str.length();
|
||||||
CharString cstr = p_str.ascii();
|
CharString cstr = p_str.ascii();
|
||||||
|
|
||||||
int arr_len;
|
int arr_len;
|
||||||
DVector<uint8_t> buf;
|
PoolVector<uint8_t> buf;
|
||||||
{
|
{
|
||||||
buf.resize(strlen / 4 * 3 + 1);
|
buf.resize(strlen / 4 * 3 + 1);
|
||||||
DVector<uint8_t>::Write w = buf.write();
|
PoolVector<uint8_t>::Write w = buf.write();
|
||||||
|
|
||||||
arr_len = base64_decode((char*)(&w[0]), (char*)cstr.get_data(), strlen);
|
arr_len = base64_decode((char*)(&w[0]), (char*)cstr.get_data(), strlen);
|
||||||
};
|
};
|
||||||
buf.resize(arr_len);
|
buf.resize(arr_len);
|
||||||
|
|
||||||
// conversion from DVector<uint8_t> to raw array?
|
// conversion from PoolVector<uint8_t> to raw array?
|
||||||
return buf;
|
return buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2136,9 +2136,9 @@ String _Marshalls::utf8_to_base64(const String& p_str) {
|
||||||
int len = cstr.length();
|
int len = cstr.length();
|
||||||
|
|
||||||
int b64len = len / 3 * 4 + 4 + 1;
|
int b64len = len / 3 * 4 + 4 + 1;
|
||||||
DVector<uint8_t> b64buff;
|
PoolVector<uint8_t> b64buff;
|
||||||
b64buff.resize(b64len);
|
b64buff.resize(b64len);
|
||||||
DVector<uint8_t>::Write w64 = b64buff.write();
|
PoolVector<uint8_t>::Write w64 = b64buff.write();
|
||||||
|
|
||||||
int strlen = base64_encode((char*)(&w64[0]), (char*)cstr.get_data(), len);
|
int strlen = base64_encode((char*)(&w64[0]), (char*)cstr.get_data(), len);
|
||||||
|
|
||||||
|
@ -2153,9 +2153,9 @@ String _Marshalls::base64_to_utf8(const String& p_str) {
|
||||||
int strlen = p_str.length();
|
int strlen = p_str.length();
|
||||||
CharString cstr = p_str.ascii();
|
CharString cstr = p_str.ascii();
|
||||||
|
|
||||||
DVector<uint8_t> buf;
|
PoolVector<uint8_t> buf;
|
||||||
buf.resize(strlen / 4 * 3 + 1 + 1);
|
buf.resize(strlen / 4 * 3 + 1 + 1);
|
||||||
DVector<uint8_t>::Write w = buf.write();
|
PoolVector<uint8_t>::Write w = buf.write();
|
||||||
|
|
||||||
int len = base64_decode((char*)(&w[0]), (char*)cstr.get_data(), strlen);
|
int len = base64_decode((char*)(&w[0]), (char*)cstr.get_data(), strlen);
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
static _ResourceLoader *get_singleton() { return singleton; }
|
static _ResourceLoader *get_singleton() { return singleton; }
|
||||||
Ref<ResourceInteractiveLoader> load_interactive(const String& p_path,const String& p_type_hint="");
|
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);
|
RES load(const String &p_path,const String& p_type_hint="", bool p_no_cache = false);
|
||||||
DVector<String> get_recognized_extensions_for_type(const String& p_type);
|
PoolVector<String> get_recognized_extensions_for_type(const String& p_type);
|
||||||
void set_abort_on_missing_resources(bool p_abort);
|
void set_abort_on_missing_resources(bool p_abort);
|
||||||
StringArray get_dependencies(const String& p_path);
|
StringArray get_dependencies(const String& p_path);
|
||||||
bool has(const String& p_path);
|
bool has(const String& p_path);
|
||||||
|
@ -81,7 +81,7 @@ public:
|
||||||
static _ResourceSaver *get_singleton() { return singleton; }
|
static _ResourceSaver *get_singleton() { return singleton; }
|
||||||
|
|
||||||
Error save(const String &p_path,const RES& p_resource, uint32_t p_flags);
|
Error save(const String &p_path,const RES& p_resource, uint32_t p_flags);
|
||||||
DVector<String> get_recognized_extensions(const RES& p_resource);
|
PoolVector<String> get_recognized_extensions(const RES& p_resource);
|
||||||
|
|
||||||
|
|
||||||
_ResourceSaver();
|
_ResourceSaver();
|
||||||
|
@ -342,20 +342,20 @@ protected:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static _Geometry *get_singleton();
|
static _Geometry *get_singleton();
|
||||||
DVector<Plane> build_box_planes(const Vector3& p_extents);
|
PoolVector<Plane> build_box_planes(const Vector3& p_extents);
|
||||||
DVector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z);
|
PoolVector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z);
|
||||||
DVector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, 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);
|
||||||
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 segment_intersects_segment_2d(const Vector2& p_from_a,const Vector2& p_to_a,const Vector2& p_from_b,const Vector2& p_to_b);
|
||||||
DVector<Vector2> get_closest_points_between_segments_2d( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2);
|
PoolVector<Vector2> get_closest_points_between_segments_2d( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2);
|
||||||
DVector<Vector3> get_closest_points_between_segments(const Vector3& p1,const Vector3& p2,const Vector3& q1,const Vector3& q2);
|
PoolVector<Vector3> get_closest_points_between_segments(const Vector3& p1,const Vector3& p2,const Vector3& q1,const Vector3& q2);
|
||||||
Vector3 get_closest_point_to_segment(const Vector3& p_point, const Vector3& p_a,const Vector3& p_b);
|
Vector3 get_closest_point_to_segment(const Vector3& p_point, const Vector3& p_a,const Vector3& p_b);
|
||||||
Variant ray_intersects_triangle( const Vector3& p_from, const Vector3& p_dir, const Vector3& p_v0,const Vector3& p_v1,const Vector3& p_v2);
|
Variant ray_intersects_triangle( const Vector3& p_from, const Vector3& p_dir, const Vector3& p_v0,const Vector3& p_v1,const Vector3& p_v2);
|
||||||
Variant segment_intersects_triangle( const Vector3& p_from, const Vector3& p_to, const Vector3& p_v0,const Vector3& p_v1,const Vector3& p_v2);
|
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;
|
bool point_is_inside_triangle(const Vector2& s, const Vector2& a, const Vector2& b, const Vector2& c) const;
|
||||||
|
|
||||||
DVector<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_sphere( const Vector3& p_from, const Vector3& p_to, const Vector3& p_sphere_pos,real_t p_sphere_radius);
|
||||||
DVector<Vector3> segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, float p_height,float p_radius);
|
PoolVector<Vector3> segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, float p_height,float p_radius);
|
||||||
DVector<Vector3> segment_intersects_convex(const Vector3& p_from, const Vector3& p_to,const Vector<Plane>& p_planes);
|
PoolVector<Vector3> segment_intersects_convex(const Vector3& p_from, const Vector3& p_to,const Vector<Plane>& p_planes);
|
||||||
real_t segment_intersects_circle(const Vector2& p_from, const Vector2& p_to, 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);
|
int get_uv84_normal_bit(const Vector3& p_vector);
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ public:
|
||||||
|
|
||||||
Variant get_var() const;
|
Variant get_var() const;
|
||||||
|
|
||||||
DVector<uint8_t> get_buffer(int p_length) const; ///< get an array of bytes
|
PoolVector<uint8_t> get_buffer(int p_length) const; ///< get an array of bytes
|
||||||
String get_line() const;
|
String get_line() const;
|
||||||
String get_as_text() const;
|
String get_as_text() const;
|
||||||
String get_md5(const String& p_path) const;
|
String get_md5(const String& p_path) const;
|
||||||
|
@ -447,7 +447,7 @@ public:
|
||||||
Vector<String> get_csv_line(String delim=",") const;
|
Vector<String> get_csv_line(String delim=",") const;
|
||||||
|
|
||||||
|
|
||||||
void store_buffer(const DVector<uint8_t>& p_buffer); ///< store an array of bytes
|
void store_buffer(const PoolVector<uint8_t>& p_buffer); ///< store an array of bytes
|
||||||
|
|
||||||
void store_var(const Variant& p_var);
|
void store_var(const Variant& p_var);
|
||||||
|
|
||||||
|
@ -517,8 +517,8 @@ public:
|
||||||
String variant_to_base64(const Variant& p_var);
|
String variant_to_base64(const Variant& p_var);
|
||||||
Variant base64_to_variant(const String& p_str);
|
Variant base64_to_variant(const String& p_str);
|
||||||
|
|
||||||
String raw_to_base64(const DVector<uint8_t>& p_arr);
|
String raw_to_base64(const PoolVector<uint8_t>& p_arr);
|
||||||
DVector<uint8_t> base64_to_raw(const String& p_str);
|
PoolVector<uint8_t> base64_to_raw(const String& p_str);
|
||||||
|
|
||||||
String utf8_to_base64(const String& p_str);
|
String utf8_to_base64(const String& p_str);
|
||||||
String base64_to_utf8(const String& p_str);
|
String base64_to_utf8(const String& p_str);
|
||||||
|
|
|
@ -356,8 +356,8 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
|
||||||
hash_table.resize(size);
|
hash_table.resize(size);
|
||||||
bucket_table.resize(bucket_table_size);
|
bucket_table.resize(bucket_table_size);
|
||||||
|
|
||||||
DVector<int>::Write htwb = hash_table.write();
|
PoolVector<int>::Write htwb = hash_table.write();
|
||||||
DVector<int>::Write btwb = bucket_table.write();
|
PoolVector<int>::Write btwb = bucket_table.write();
|
||||||
|
|
||||||
uint32_t *htw = (uint32_t*)&htwb[0];
|
uint32_t *htw = (uint32_t*)&htwb[0];
|
||||||
uint32_t *btw = (uint32_t*)&btwb[0];
|
uint32_t *btw = (uint32_t*)&btwb[0];
|
||||||
|
@ -392,7 +392,7 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
|
||||||
print_line("total collisions: "+itos(collisions));
|
print_line("total collisions: "+itos(collisions));
|
||||||
|
|
||||||
strings.resize(total_compression_size);
|
strings.resize(total_compression_size);
|
||||||
DVector<uint8_t>::Write cw = strings.write();
|
PoolVector<uint8_t>::Write cw = strings.write();
|
||||||
|
|
||||||
for(int i=0;i<compressed.size();i++) {
|
for(int i=0;i<compressed.size();i++) {
|
||||||
memcpy(&cw[compressed[i].offset],compressed[i].compressed.get_data(),compressed[i].compressed.size());
|
memcpy(&cw[compressed[i].offset],compressed[i].compressed.get_data(),compressed[i].compressed.size());
|
||||||
|
@ -454,11 +454,11 @@ StringName PHashTranslation::get_message(const StringName& p_src_text) const {
|
||||||
uint32_t h = hash(0,str.get_data());
|
uint32_t h = hash(0,str.get_data());
|
||||||
|
|
||||||
|
|
||||||
DVector<int>::Read htr = hash_table.read();
|
PoolVector<int>::Read htr = hash_table.read();
|
||||||
const uint32_t *htptr = (const uint32_t*)&htr[0];
|
const uint32_t *htptr = (const uint32_t*)&htr[0];
|
||||||
DVector<int>::Read btr = bucket_table.read();
|
PoolVector<int>::Read btr = bucket_table.read();
|
||||||
const uint32_t *btptr = (const uint32_t*)&btr[0];
|
const uint32_t *btptr = (const uint32_t*)&btr[0];
|
||||||
DVector<uint8_t>::Read sr = strings.read();
|
PoolVector<uint8_t>::Read sr = strings.read();
|
||||||
const char *sptr= (const char*)&sr[0];
|
const char *sptr= (const char*)&sr[0];
|
||||||
|
|
||||||
uint32_t p = htptr[ h % htsize];
|
uint32_t p = htptr[ h % htsize];
|
||||||
|
|
|
@ -42,9 +42,9 @@ class PHashTranslation : public Translation {
|
||||||
//of catching untranslated strings
|
//of catching untranslated strings
|
||||||
|
|
||||||
//load/store friendly types
|
//load/store friendly types
|
||||||
DVector<int> hash_table;
|
PoolVector<int> hash_table;
|
||||||
DVector<int> bucket_table;
|
PoolVector<int> bucket_table;
|
||||||
DVector<uint8_t> strings;
|
PoolVector<uint8_t> strings;
|
||||||
|
|
||||||
|
|
||||||
struct Bucket {
|
struct Bucket {
|
||||||
|
|
|
@ -30,3 +30,44 @@
|
||||||
|
|
||||||
Mutex* dvector_lock=NULL;
|
Mutex* dvector_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_EXPLAINC("There are still MemoryPool allocs in use at exit!");
|
||||||
|
ERR_FAIL_COND(allocs_used>0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
550
core/dvector.h
550
core/dvector.h
|
@ -30,6 +30,46 @@
|
||||||
#define DVECTOR_H
|
#define DVECTOR_H
|
||||||
|
|
||||||
#include "os/memory.h"
|
#include "os/memory.h"
|
||||||
|
#include "os/copymem.h"
|
||||||
|
#include "pool_allocator.h"
|
||||||
|
#include "safe_refcount.h"
|
||||||
|
#include "os/rw_lock.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() { mem=NULL; lock=0; 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();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,182 +77,274 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
extern Mutex* dvector_lock;
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class DVector {
|
class PoolVector {
|
||||||
|
|
||||||
mutable MID mem;
|
MemoryPool::Alloc *alloc;
|
||||||
|
|
||||||
|
|
||||||
void copy_on_write() {
|
void _copy_on_write() {
|
||||||
|
|
||||||
if (!mem.is_valid())
|
|
||||||
|
if (!alloc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (dvector_lock)
|
ERR_FAIL_COND(alloc->lock>0);
|
||||||
dvector_lock->lock();
|
|
||||||
|
|
||||||
MID_Lock lock( mem );
|
if (alloc->refcount.get()==1)
|
||||||
|
return; //nothing to do
|
||||||
|
|
||||||
|
|
||||||
if ( *(int*)lock.data() == 1 ) {
|
//must allocate something
|
||||||
// one reference, means no refcount changes
|
|
||||||
if (dvector_lock)
|
MemoryPool::alloc_mutex->lock();
|
||||||
dvector_lock->unlock();
|
if (MemoryPool::allocs_used==MemoryPool::alloc_count) {
|
||||||
return;
|
MemoryPool::alloc_mutex->unlock();
|
||||||
|
ERR_EXPLAINC("All memory pool allocations are in use, can't COW.");
|
||||||
|
ERR_FAIL();
|
||||||
}
|
}
|
||||||
|
|
||||||
MID new_mem= dynalloc( mem.get_size() );
|
MemoryPool::Alloc *old_alloc = alloc;
|
||||||
|
|
||||||
if (!new_mem.is_valid()) {
|
//take one from the free list
|
||||||
|
alloc = MemoryPool::free_list;
|
||||||
|
MemoryPool::free_list = alloc->free_list;
|
||||||
|
//increment the used counter
|
||||||
|
MemoryPool::allocs_used++;
|
||||||
|
|
||||||
if (dvector_lock)
|
//copy the alloc data
|
||||||
dvector_lock->unlock();
|
alloc->size=old_alloc->size;
|
||||||
ERR_FAIL_COND( new_mem.is_valid() ); // out of memory
|
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 );
|
||||||
|
copymem( alloc->mem, old_alloc->mem, alloc->size );
|
||||||
}
|
}
|
||||||
|
|
||||||
MID_Lock dst_lock( new_mem );
|
if (old_alloc->refcount.unref()) {
|
||||||
|
//this should never happen but..
|
||||||
|
|
||||||
int *rc = (int*)dst_lock.data();
|
#ifdef DEBUG_ENABLED
|
||||||
|
MemoryPool::alloc_mutex->lock();
|
||||||
*rc=1;
|
MemoryPool::total_memory-=old_alloc->size;
|
||||||
|
MemoryPool::alloc_mutex->unlock();
|
||||||
T * dst = (T*)(rc + 1 );
|
#endif
|
||||||
|
|
||||||
T * src =(T*) ((int*)lock.data() + 1 );
|
|
||||||
|
|
||||||
int count = (mem.get_size() - sizeof(int)) / sizeof(T);
|
|
||||||
|
|
||||||
for (int i=0;i<count;i++) {
|
|
||||||
|
|
||||||
memnew_placement( &dst[i], T(src[i]) );
|
|
||||||
}
|
|
||||||
|
|
||||||
(*(int*)lock.data())--;
|
|
||||||
|
|
||||||
// unlock all
|
|
||||||
dst_lock=MID_Lock();
|
|
||||||
lock=MID_Lock();
|
|
||||||
|
|
||||||
mem=new_mem;
|
|
||||||
|
|
||||||
if (dvector_lock)
|
|
||||||
dvector_lock->unlock();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void reference( const DVector& p_dvector ) {
|
|
||||||
|
|
||||||
unreference();
|
|
||||||
|
|
||||||
if (dvector_lock)
|
|
||||||
dvector_lock->lock();
|
|
||||||
|
|
||||||
if (!p_dvector.mem.is_valid()) {
|
|
||||||
|
|
||||||
if (dvector_lock)
|
|
||||||
dvector_lock->unlock();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MID_Lock lock(p_dvector.mem);
|
|
||||||
|
|
||||||
int * rc = (int*)lock.data();
|
|
||||||
(*rc)++;
|
|
||||||
|
|
||||||
lock = MID_Lock();
|
|
||||||
mem=p_dvector.mem;
|
|
||||||
|
|
||||||
if (dvector_lock)
|
|
||||||
dvector_lock->unlock();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void unreference() {
|
if (MemoryPool::memory_pool) {
|
||||||
|
//resize memory pool
|
||||||
|
//if none, create
|
||||||
|
//if some resize
|
||||||
|
} else {
|
||||||
|
|
||||||
if (dvector_lock)
|
memfree( old_alloc->mem );
|
||||||
dvector_lock->lock();
|
old_alloc->mem=NULL;
|
||||||
|
old_alloc->size=0;
|
||||||
|
|
||||||
if (!mem.is_valid()) {
|
|
||||||
|
|
||||||
if (dvector_lock)
|
MemoryPool::alloc_mutex->lock();
|
||||||
dvector_lock->unlock();
|
old_alloc->free_list=MemoryPool::free_list;
|
||||||
return;
|
MemoryPool::free_list=old_alloc;
|
||||||
}
|
MemoryPool::allocs_used--;
|
||||||
|
MemoryPool::alloc_mutex->unlock();
|
||||||
MID_Lock lock(mem);
|
|
||||||
|
|
||||||
int * rc = (int*)lock.data();
|
|
||||||
(*rc)--;
|
|
||||||
|
|
||||||
if (*rc==0) {
|
|
||||||
// no one else using it, destruct
|
|
||||||
|
|
||||||
T * t= (T*)(rc+1);
|
|
||||||
int count = (mem.get_size() - sizeof(int)) / sizeof(T);
|
|
||||||
|
|
||||||
for (int i=0;i<count;i++) {
|
|
||||||
|
|
||||||
t[i].~T();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
lock = MID_Lock();
|
void _reference( const PoolVector& p_dvector ) {
|
||||||
|
|
||||||
mem = MID ();
|
if (alloc==p_dvector.alloc)
|
||||||
|
return;
|
||||||
|
|
||||||
if (dvector_lock)
|
_unreference();
|
||||||
dvector_lock->unlock();
|
|
||||||
|
|
||||||
|
if (!p_dvector.alloc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_dvector.alloc->refcount.ref()) {
|
||||||
|
alloc=p_dvector.alloc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void _unreference() {
|
||||||
|
|
||||||
|
if (!alloc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!alloc->refcount.unref()) {
|
||||||
|
alloc=NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//must be disposed!
|
||||||
|
|
||||||
|
{
|
||||||
|
int cur_elements = alloc->size/sizeof(T);
|
||||||
|
Write w;
|
||||||
|
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:
|
public:
|
||||||
|
|
||||||
class Read {
|
class Access {
|
||||||
friend class DVector;
|
friend class PoolVector;
|
||||||
MID_Lock lock;
|
protected:
|
||||||
const T * mem;
|
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:
|
public:
|
||||||
|
virtual ~Access() {
|
||||||
_FORCE_INLINE_ const T& operator[](int p_index) const { return mem[p_index]; }
|
_unref();
|
||||||
_FORCE_INLINE_ const T *ptr() const { return mem; }
|
}
|
||||||
|
|
||||||
Read() { mem=NULL; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Write {
|
class Read : public Access {
|
||||||
friend class DVector;
|
|
||||||
MID_Lock lock;
|
|
||||||
T * mem;
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
_FORCE_INLINE_ T& operator[](int p_index) { return mem[p_index]; }
|
_FORCE_INLINE_ const T& operator[](int p_index) const { return this->mem[p_index]; }
|
||||||
_FORCE_INLINE_ T *ptr() { return mem; }
|
_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() {}
|
||||||
|
|
||||||
Write() { mem=NULL; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Read read() const {
|
Read read() const {
|
||||||
|
|
||||||
Read r;
|
Read r;
|
||||||
if (mem.is_valid()) {
|
if (alloc) {
|
||||||
r.lock = MID_Lock( mem );
|
r._ref(alloc);
|
||||||
r.mem = (const T*)((int*)r.lock.data()+1);
|
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
}
|
}
|
||||||
Write write() {
|
Write write() {
|
||||||
|
|
||||||
Write w;
|
Write w;
|
||||||
if (mem.is_valid()) {
|
if (alloc) {
|
||||||
copy_on_write();
|
_copy_on_write(); //make sure there is only one being acessed
|
||||||
w.lock = MID_Lock( mem );
|
w._ref(alloc);
|
||||||
w.mem = (T*)((int*)w.lock.data()+1);
|
|
||||||
}
|
}
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
@ -250,7 +382,7 @@ public:
|
||||||
void set(int p_index, const T& p_val);
|
void set(int p_index, const T& p_val);
|
||||||
void push_back(const T& p_val);
|
void push_back(const T& p_val);
|
||||||
void append(const T& p_val) { push_back(p_val); }
|
void append(const T& p_val) { push_back(p_val); }
|
||||||
void append_array(const DVector<T>& p_arr) {
|
void append_array(const PoolVector<T>& p_arr) {
|
||||||
int ds = p_arr.size();
|
int ds = p_arr.size();
|
||||||
if (ds==0)
|
if (ds==0)
|
||||||
return;
|
return;
|
||||||
|
@ -262,7 +394,7 @@ public:
|
||||||
w[bs+i]=r[i];
|
w[bs+i]=r[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<T> subarray(int p_from, int p_to) {
|
PoolVector<T> subarray(int p_from, int p_to) {
|
||||||
|
|
||||||
if (p_from<0) {
|
if (p_from<0) {
|
||||||
p_from=size()+p_from;
|
p_from=size()+p_from;
|
||||||
|
@ -271,15 +403,15 @@ public:
|
||||||
p_to=size()+p_to;
|
p_to=size()+p_to;
|
||||||
}
|
}
|
||||||
if (p_from<0 || p_from>=size()) {
|
if (p_from<0 || p_from>=size()) {
|
||||||
DVector<T>& aux=*((DVector<T>*)0); // nullreturn
|
PoolVector<T>& aux=*((PoolVector<T>*)0); // nullreturn
|
||||||
ERR_FAIL_COND_V(p_from<0 || p_from>=size(),aux)
|
ERR_FAIL_COND_V(p_from<0 || p_from>=size(),aux)
|
||||||
}
|
}
|
||||||
if (p_to<0 || p_to>=size()) {
|
if (p_to<0 || p_to>=size()) {
|
||||||
DVector<T>& aux=*((DVector<T>*)0); // nullreturn
|
PoolVector<T>& aux=*((PoolVector<T>*)0); // nullreturn
|
||||||
ERR_FAIL_COND_V(p_to<0 || p_to>=size(),aux)
|
ERR_FAIL_COND_V(p_to<0 || p_to>=size(),aux)
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<T> slice;
|
PoolVector<T> slice;
|
||||||
int span=1 + p_to - p_from;
|
int span=1 + p_to - p_from;
|
||||||
slice.resize(span);
|
slice.resize(span);
|
||||||
Read r = read();
|
Read r = read();
|
||||||
|
@ -307,7 +439,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool is_locked() const { return mem.is_locked(); }
|
bool is_locked() const { return alloc && alloc->lock>0; }
|
||||||
|
|
||||||
inline const T operator[](int p_index) const;
|
inline const T operator[](int p_index) const;
|
||||||
|
|
||||||
|
@ -315,27 +447,27 @@ public:
|
||||||
|
|
||||||
void invert();
|
void invert();
|
||||||
|
|
||||||
void operator=(const DVector& p_dvector) { reference(p_dvector); }
|
void operator=(const PoolVector& p_dvector) { _reference(p_dvector); }
|
||||||
DVector() {}
|
PoolVector() { alloc=NULL; }
|
||||||
DVector(const DVector& p_dvector) { reference(p_dvector); }
|
PoolVector(const PoolVector& p_dvector) { alloc=NULL; _reference(p_dvector); }
|
||||||
~DVector() { unreference(); }
|
~PoolVector() { _unreference(); }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
int DVector<T>::size() const {
|
int PoolVector<T>::size() const {
|
||||||
|
|
||||||
return mem.is_valid() ? ((mem.get_size() - sizeof(int)) / sizeof(T) ) : 0;
|
return alloc ? alloc->size/sizeof(T) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T DVector<T>::get(int p_index) const {
|
T PoolVector<T>::get(int p_index) const {
|
||||||
|
|
||||||
return operator[](p_index);
|
return operator[](p_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void DVector<T>::set(int p_index, const T& p_val) {
|
void PoolVector<T>::set(int p_index, const T& p_val) {
|
||||||
|
|
||||||
if (p_index<0 || p_index>=size()) {
|
if (p_index<0 || p_index>=size()) {
|
||||||
ERR_FAIL_COND(p_index<0 || p_index>=size());
|
ERR_FAIL_COND(p_index<0 || p_index>=size());
|
||||||
|
@ -346,14 +478,14 @@ void DVector<T>::set(int p_index, const T& p_val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void DVector<T>::push_back(const T& p_val) {
|
void PoolVector<T>::push_back(const T& p_val) {
|
||||||
|
|
||||||
resize( size() + 1 );
|
resize( size() + 1 );
|
||||||
set( size() -1, p_val );
|
set( size() -1, p_val );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
const T DVector<T>::operator[](int p_index) const {
|
const T PoolVector<T>::operator[](int p_index) const {
|
||||||
|
|
||||||
if (p_index<0 || p_index>=size()) {
|
if (p_index<0 || p_index>=size()) {
|
||||||
T& aux=*((T*)0); //nullreturn
|
T& aux=*((T*)0); //nullreturn
|
||||||
|
@ -367,94 +499,130 @@ const T DVector<T>::operator[](int p_index) const {
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Error DVector<T>::resize(int p_size) {
|
Error PoolVector<T>::resize(int p_size) {
|
||||||
|
|
||||||
if (dvector_lock)
|
|
||||||
dvector_lock->lock();
|
|
||||||
|
|
||||||
bool same = p_size==size();
|
if (alloc==NULL) {
|
||||||
|
|
||||||
if (dvector_lock)
|
if (p_size==0)
|
||||||
dvector_lock->unlock();
|
return OK; //nothing to do here
|
||||||
// no further locking is necesary because we are supposed to own the only copy of this (using copy on write)
|
|
||||||
|
|
||||||
if (same)
|
//must allocate something
|
||||||
return OK;
|
MemoryPool::alloc_mutex->lock();
|
||||||
|
if (MemoryPool::allocs_used==MemoryPool::alloc_count) {
|
||||||
|
MemoryPool::alloc_mutex->unlock();
|
||||||
|
ERR_EXPLAINC("All memory pool allocations are in use.");
|
||||||
|
ERR_FAIL_V(ERR_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
//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( alloc->lock>0, ERR_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 ) {
|
if (p_size == 0 ) {
|
||||||
|
_unreference();
|
||||||
unreference();
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_copy_on_write(); // make it unique
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
ERR_FAIL_COND_V( mem.is_locked(), ERR_LOCKED ); // if after copy on write, memory is locked, fail.
|
|
||||||
|
|
||||||
if (p_size > size() ) {
|
int cur_elements = alloc->size / sizeof(T);
|
||||||
|
|
||||||
int oldsize=size();
|
if (p_size > cur_elements ) {
|
||||||
|
|
||||||
MID_Lock lock;
|
|
||||||
|
|
||||||
if (oldsize==0) {
|
|
||||||
|
|
||||||
mem = dynalloc( p_size * sizeof(T) + sizeof(int) );
|
|
||||||
lock=MID_Lock(mem);
|
|
||||||
int *rc = ((int*)lock.data());
|
|
||||||
*rc=1;
|
|
||||||
|
|
||||||
|
if (MemoryPool::memory_pool) {
|
||||||
|
//resize memory pool
|
||||||
|
//if none, create
|
||||||
|
//if some resize
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (dynrealloc( mem, p_size * sizeof(T) + sizeof(int) )!=OK ) {
|
if (alloc->size==0) {
|
||||||
|
alloc->mem = memalloc( new_size );
|
||||||
ERR_FAIL_V(ERR_OUT_OF_MEMORY); // out of memory
|
} else {
|
||||||
|
alloc->mem = memrealloc( alloc->mem, new_size );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lock=MID_Lock(mem);
|
alloc->size=new_size;
|
||||||
|
|
||||||
|
Write w = write();
|
||||||
|
|
||||||
|
for (int i=cur_elements;i<p_size;i++) {
|
||||||
|
|
||||||
|
memnew_placement(&w[i], T );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
T *t = (T*)((int*)lock.data() + 1);
|
|
||||||
|
|
||||||
for (int i=oldsize;i<p_size;i++) {
|
|
||||||
|
|
||||||
memnew_placement(&t[i], T );
|
|
||||||
}
|
|
||||||
|
|
||||||
lock = MID_Lock(); // clear
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
int oldsize=size();
|
{
|
||||||
|
Write w;
|
||||||
|
for (int i=p_size;i<cur_elements;i++) {
|
||||||
|
|
||||||
MID_Lock lock(mem);
|
w[i].~T();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
T *t = (T*)((int*)lock.data() + 1);
|
|
||||||
|
|
||||||
for (int i=p_size;i<oldsize;i++) {
|
|
||||||
|
|
||||||
t[i].~T();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lock = MID_Lock(); // clear
|
if (MemoryPool::memory_pool) {
|
||||||
|
//resize memory pool
|
||||||
|
//if none, create
|
||||||
|
//if some resize
|
||||||
|
} else {
|
||||||
|
|
||||||
if (dynrealloc( mem, p_size * sizeof(T) + sizeof(int) )!=OK ) {
|
if (new_size==0) {
|
||||||
|
memfree( alloc->mem );
|
||||||
|
alloc->mem=NULL;
|
||||||
|
alloc->size=0;
|
||||||
|
|
||||||
ERR_FAIL_V(ERR_OUT_OF_MEMORY); // wtf error
|
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;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void DVector<T>::invert() {
|
void PoolVector<T>::invert() {
|
||||||
T temp;
|
T temp;
|
||||||
Write w = write();
|
Write w = write();
|
||||||
int s = size();
|
int s = size();
|
||||||
|
|
|
@ -691,9 +691,9 @@ static Variant _decode_variant(const String& p_string) {
|
||||||
|
|
||||||
String data=params[4];
|
String data=params[4];
|
||||||
int datasize=data.length()/2;
|
int datasize=data.length()/2;
|
||||||
DVector<uint8_t> pixels;
|
PoolVector<uint8_t> pixels;
|
||||||
pixels.resize(datasize);
|
pixels.resize(datasize);
|
||||||
DVector<uint8_t>::Write wb = pixels.write();
|
PoolVector<uint8_t>::Write wb = pixels.write();
|
||||||
const CharType *cptr=data.c_str();
|
const CharType *cptr=data.c_str();
|
||||||
|
|
||||||
int idx=0;
|
int idx=0;
|
||||||
|
@ -720,7 +720,7 @@ static Variant _decode_variant(const String& p_string) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wb = DVector<uint8_t>::Write();
|
wb = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
return Image(w,h,mipmaps,imgformat,pixels);
|
return Image(w,h,mipmaps,imgformat,pixels);
|
||||||
}
|
}
|
||||||
|
@ -992,9 +992,9 @@ static String _encode_variant(const Variant& p_variant) {
|
||||||
str+=itos(img.has_mipmaps())+", ";
|
str+=itos(img.has_mipmaps())+", ";
|
||||||
str+=itos(img.get_width())+", ";
|
str+=itos(img.get_width())+", ";
|
||||||
str+=itos(img.get_height())+", ";
|
str+=itos(img.get_height())+", ";
|
||||||
DVector<uint8_t> data = img.get_data();
|
PoolVector<uint8_t> data = img.get_data();
|
||||||
int ds=data.size();
|
int ds=data.size();
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
for(int i=0;i<ds;i++) {
|
for(int i=0;i<ds;i++) {
|
||||||
uint8_t byte = r[i];
|
uint8_t byte = r[i];
|
||||||
const char hex[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
const char hex[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
||||||
|
|
100
core/image.cpp
100
core/image.cpp
|
@ -365,8 +365,8 @@ void Image::convert( Format p_new_format ){
|
||||||
|
|
||||||
// int len=data.size();
|
// int len=data.size();
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
DVector<uint8_t>::Write w = new_img.data.write();
|
PoolVector<uint8_t>::Write w = new_img.data.write();
|
||||||
|
|
||||||
const uint8_t *rptr = r.ptr();
|
const uint8_t *rptr = r.ptr();
|
||||||
uint8_t *wptr = w.ptr();
|
uint8_t *wptr = w.ptr();
|
||||||
|
@ -409,8 +409,8 @@ void Image::convert( Format p_new_format ){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
r = DVector<uint8_t>::Read();
|
r = PoolVector<uint8_t>::Read();
|
||||||
w = DVector<uint8_t>::Write();
|
w = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
bool gen_mipmaps=mipmaps;
|
bool gen_mipmaps=mipmaps;
|
||||||
|
|
||||||
|
@ -651,10 +651,10 @@ void Image::resize( int p_width, int p_height, Interpolation p_interpolation ) {
|
||||||
|
|
||||||
Image dst( p_width, p_height, 0, format );
|
Image dst( p_width, p_height, 0, format );
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
const unsigned char*r_ptr=r.ptr();
|
const unsigned char*r_ptr=r.ptr();
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = dst.data.write();
|
PoolVector<uint8_t>::Write w = dst.data.write();
|
||||||
unsigned char*w_ptr=w.ptr();
|
unsigned char*w_ptr=w.ptr();
|
||||||
|
|
||||||
|
|
||||||
|
@ -693,8 +693,8 @@ void Image::resize( int p_width, int p_height, Interpolation p_interpolation ) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r = DVector<uint8_t>::Read();
|
r = PoolVector<uint8_t>::Read();
|
||||||
w = DVector<uint8_t>::Write();
|
w = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
if (mipmaps>0)
|
if (mipmaps>0)
|
||||||
dst.generate_mipmaps();
|
dst.generate_mipmaps();
|
||||||
|
@ -725,8 +725,8 @@ void Image::crop( int p_width, int p_height ) {
|
||||||
Image dst( p_width, p_height,0, format );
|
Image dst( p_width, p_height,0, format );
|
||||||
|
|
||||||
{
|
{
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
DVector<uint8_t>::Write w = dst.data.write();
|
PoolVector<uint8_t>::Write w = dst.data.write();
|
||||||
|
|
||||||
for (int y=0;y<p_height;y++) {
|
for (int y=0;y<p_height;y++) {
|
||||||
|
|
||||||
|
@ -767,7 +767,7 @@ void Image::flip_y() {
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
DVector<uint8_t>::Write w = data.write();
|
PoolVector<uint8_t>::Write w = data.write();
|
||||||
uint8_t up[16];
|
uint8_t up[16];
|
||||||
uint8_t down[16];
|
uint8_t down[16];
|
||||||
uint32_t pixel_size = get_format_pixel_size(format);
|
uint32_t pixel_size = get_format_pixel_size(format);
|
||||||
|
@ -806,7 +806,7 @@ void Image::flip_x() {
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
DVector<uint8_t>::Write w = data.write();
|
PoolVector<uint8_t>::Write w = data.write();
|
||||||
uint8_t up[16];
|
uint8_t up[16];
|
||||||
uint8_t down[16];
|
uint8_t down[16];
|
||||||
uint32_t pixel_size = get_format_pixel_size(format);
|
uint32_t pixel_size = get_format_pixel_size(format);
|
||||||
|
@ -925,12 +925,12 @@ void Image::expand_x2_hq2x() {
|
||||||
if (current!=FORMAT_RGBA8)
|
if (current!=FORMAT_RGBA8)
|
||||||
convert(FORMAT_RGBA8);
|
convert(FORMAT_RGBA8);
|
||||||
|
|
||||||
DVector<uint8_t> dest;
|
PoolVector<uint8_t> dest;
|
||||||
dest.resize(width*2*height*2*4);
|
dest.resize(width*2*height*2*4);
|
||||||
|
|
||||||
{
|
{
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
DVector<uint8_t>::Write w = dest.write();
|
PoolVector<uint8_t>::Write w = dest.write();
|
||||||
|
|
||||||
hq2x_resize((const uint32_t*)r.ptr(),width,height,(uint32_t*)w.ptr());
|
hq2x_resize((const uint32_t*)r.ptr(),width,height,(uint32_t*)w.ptr());
|
||||||
|
|
||||||
|
@ -959,7 +959,7 @@ void Image::shrink_x2() {
|
||||||
if (mipmaps) {
|
if (mipmaps) {
|
||||||
|
|
||||||
//just use the lower mipmap as base and copy all
|
//just use the lower mipmap as base and copy all
|
||||||
DVector<uint8_t> new_img;
|
PoolVector<uint8_t> new_img;
|
||||||
|
|
||||||
int ofs = get_mipmap_offset(1);
|
int ofs = get_mipmap_offset(1);
|
||||||
|
|
||||||
|
@ -968,8 +968,8 @@ void Image::shrink_x2() {
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
DVector<uint8_t>::Write w=new_img.write();
|
PoolVector<uint8_t>::Write w=new_img.write();
|
||||||
DVector<uint8_t>::Read r=data.read();
|
PoolVector<uint8_t>::Read r=data.read();
|
||||||
|
|
||||||
copymem(w.ptr(),&r[ofs],new_size);
|
copymem(w.ptr(),&r[ofs],new_size);
|
||||||
}
|
}
|
||||||
|
@ -980,15 +980,15 @@ void Image::shrink_x2() {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
DVector<uint8_t> new_img;
|
PoolVector<uint8_t> new_img;
|
||||||
|
|
||||||
ERR_FAIL_COND( !_can_modify(format) );
|
ERR_FAIL_COND( !_can_modify(format) );
|
||||||
int ps = get_format_pixel_size(format);
|
int ps = get_format_pixel_size(format);
|
||||||
new_img.resize((width/2)*(height/2)*ps);
|
new_img.resize((width/2)*(height/2)*ps);
|
||||||
|
|
||||||
{
|
{
|
||||||
DVector<uint8_t>::Write w=new_img.write();
|
PoolVector<uint8_t>::Write w=new_img.write();
|
||||||
DVector<uint8_t>::Read r=data.read();
|
PoolVector<uint8_t>::Read r=data.read();
|
||||||
|
|
||||||
switch(format) {
|
switch(format) {
|
||||||
|
|
||||||
|
@ -1027,7 +1027,7 @@ Error Image::generate_mipmaps(bool p_keep_existing) {
|
||||||
|
|
||||||
data.resize(size);
|
data.resize(size);
|
||||||
|
|
||||||
DVector<uint8_t>::Write wp=data.write();
|
PoolVector<uint8_t>::Write wp=data.write();
|
||||||
|
|
||||||
if (nearest_power_of_2(width)==uint32_t(width) && nearest_power_of_2(height)==uint32_t(height)) {
|
if (nearest_power_of_2(width)==uint32_t(width) && nearest_power_of_2(height)==uint32_t(height)) {
|
||||||
//use fast code for powers of 2
|
//use fast code for powers of 2
|
||||||
|
@ -1122,7 +1122,7 @@ bool Image::empty() const {
|
||||||
return (data.size()==0);
|
return (data.size()==0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t> Image::get_data() const {
|
PoolVector<uint8_t> Image::get_data() const {
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -1134,7 +1134,7 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps,Format p_format
|
||||||
int size = _get_dst_image_size(p_width,p_height,p_format,mm,p_use_mipmaps?-1:0);
|
int size = _get_dst_image_size(p_width,p_height,p_format,mm,p_use_mipmaps?-1:0);
|
||||||
data.resize( size );
|
data.resize( size );
|
||||||
{
|
{
|
||||||
DVector<uint8_t>::Write w= data.write();
|
PoolVector<uint8_t>::Write w= data.write();
|
||||||
zeromem(w.ptr(),size);
|
zeromem(w.ptr(),size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1146,7 +1146,7 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps,Format p_format
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const DVector<uint8_t>& p_data) {
|
void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const PoolVector<uint8_t>& p_data) {
|
||||||
|
|
||||||
ERR_FAIL_INDEX(p_width-1,MAX_WIDTH);
|
ERR_FAIL_INDEX(p_width-1,MAX_WIDTH);
|
||||||
ERR_FAIL_INDEX(p_height-1,MAX_HEIGHT);
|
ERR_FAIL_INDEX(p_height-1,MAX_HEIGHT);
|
||||||
|
@ -1188,7 +1188,7 @@ void Image::create( const char ** p_xpm ) {
|
||||||
HashMap<String,Color> colormap;
|
HashMap<String,Color> colormap;
|
||||||
int colormap_size;
|
int colormap_size;
|
||||||
uint32_t pixel_size;
|
uint32_t pixel_size;
|
||||||
DVector<uint8_t>::Write w;
|
PoolVector<uint8_t>::Write w;
|
||||||
|
|
||||||
while (status!=DONE) {
|
while (status!=DONE) {
|
||||||
|
|
||||||
|
@ -1355,7 +1355,7 @@ bool Image::is_invisible() const {
|
||||||
int w,h;
|
int w,h;
|
||||||
_get_mipmap_offset_and_size(1,len,w,h);
|
_get_mipmap_offset_and_size(1,len,w,h);
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
const unsigned char *data_ptr=r.ptr();
|
const unsigned char *data_ptr=r.ptr();
|
||||||
|
|
||||||
bool detected=false;
|
bool detected=false;
|
||||||
|
@ -1401,7 +1401,7 @@ Image::AlphaMode Image::detect_alpha() const {
|
||||||
int w,h;
|
int w,h;
|
||||||
_get_mipmap_offset_and_size(1,len,w,h);
|
_get_mipmap_offset_and_size(1,len,w,h);
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
const unsigned char *data_ptr=r.ptr();
|
const unsigned char *data_ptr=r.ptr();
|
||||||
|
|
||||||
bool bit=false;
|
bool bit=false;
|
||||||
|
@ -1459,8 +1459,8 @@ bool Image::operator==(const Image& p_image) const {
|
||||||
|
|
||||||
if (data.size() == 0 && p_image.data.size() == 0)
|
if (data.size() == 0 && p_image.data.size() == 0)
|
||||||
return true;
|
return true;
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
DVector<uint8_t>::Read pr = p_image.data.read();
|
PoolVector<uint8_t>::Read pr = p_image.data.read();
|
||||||
|
|
||||||
return r.ptr() == pr.ptr();
|
return r.ptr() == pr.ptr();
|
||||||
}
|
}
|
||||||
|
@ -1502,11 +1502,11 @@ Error Image::_decompress_bc() {
|
||||||
int mm;
|
int mm;
|
||||||
int size = _get_dst_image_size(wd,ht,FORMAT_RGBA8,mm);
|
int size = _get_dst_image_size(wd,ht,FORMAT_RGBA8,mm);
|
||||||
|
|
||||||
DVector<uint8_t> newdata;
|
PoolVector<uint8_t> newdata;
|
||||||
newdata.resize(size);
|
newdata.resize(size);
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = newdata.write();
|
PoolVector<uint8_t>::Write w = newdata.write();
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
|
|
||||||
int rofs=0;
|
int rofs=0;
|
||||||
int wofs=0;
|
int wofs=0;
|
||||||
|
@ -1814,8 +1814,8 @@ Error Image::_decompress_bc() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w=DVector<uint8_t>::Write();
|
w=PoolVector<uint8_t>::Write();
|
||||||
r=DVector<uint8_t>::Read();
|
r=PoolVector<uint8_t>::Read();
|
||||||
|
|
||||||
data=newdata;
|
data=newdata;
|
||||||
format=FORMAT_RGBA8;
|
format=FORMAT_RGBA8;
|
||||||
|
@ -1927,7 +1927,7 @@ Image::Image(int p_width, int p_height,bool p_use_mipmaps, Format p_format) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const DVector<uint8_t>& p_data) {
|
Image::Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const PoolVector<uint8_t>& p_data) {
|
||||||
|
|
||||||
width=0;
|
width=0;
|
||||||
height=0;
|
height=0;
|
||||||
|
@ -1950,7 +1950,7 @@ Rect2 Image::get_used_rect() const {
|
||||||
return Rect2();
|
return Rect2();
|
||||||
|
|
||||||
//int data_size = len;
|
//int data_size = len;
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
const unsigned char *rptr=r.ptr();
|
const unsigned char *rptr=r.ptr();
|
||||||
|
|
||||||
int ps = format==FORMAT_LA8?2:4;
|
int ps = format==FORMAT_LA8?2:4;
|
||||||
|
@ -2005,10 +2005,10 @@ void Image::blit_rect(const Image& p_src, const Rect2& p_src_rect,const Point2&
|
||||||
return;
|
return;
|
||||||
Rect2i src_rect( p_src_rect.pos + ( local_src_rect.pos - p_dest), local_src_rect.size );
|
Rect2i src_rect( p_src_rect.pos + ( local_src_rect.pos - p_dest), local_src_rect.size );
|
||||||
|
|
||||||
DVector<uint8_t>::Write wp = data.write();
|
PoolVector<uint8_t>::Write wp = data.write();
|
||||||
uint8_t *dst_data_ptr=wp.ptr();
|
uint8_t *dst_data_ptr=wp.ptr();
|
||||||
|
|
||||||
DVector<uint8_t>::Read rp = p_src.data.read();
|
PoolVector<uint8_t>::Read rp = p_src.data.read();
|
||||||
const uint8_t *src_data_ptr=rp.ptr();
|
const uint8_t *src_data_ptr=rp.ptr();
|
||||||
|
|
||||||
int pixel_size=get_format_pixel_size(format);
|
int pixel_size=get_format_pixel_size(format);
|
||||||
|
@ -2049,10 +2049,10 @@ void (*Image::_image_decompress_bc)(Image *)=NULL;
|
||||||
void (*Image::_image_decompress_etc)(Image *)=NULL;
|
void (*Image::_image_decompress_etc)(Image *)=NULL;
|
||||||
void (*Image::_image_decompress_etc2)(Image *)=NULL;
|
void (*Image::_image_decompress_etc2)(Image *)=NULL;
|
||||||
|
|
||||||
DVector<uint8_t> (*Image::lossy_packer)(const Image& ,float )=NULL;
|
PoolVector<uint8_t> (*Image::lossy_packer)(const Image& ,float )=NULL;
|
||||||
Image (*Image::lossy_unpacker)(const DVector<uint8_t>& )=NULL;
|
Image (*Image::lossy_unpacker)(const PoolVector<uint8_t>& )=NULL;
|
||||||
DVector<uint8_t> (*Image::lossless_packer)(const Image& )=NULL;
|
PoolVector<uint8_t> (*Image::lossless_packer)(const Image& )=NULL;
|
||||||
Image (*Image::lossless_unpacker)(const DVector<uint8_t>& )=NULL;
|
Image (*Image::lossless_unpacker)(const PoolVector<uint8_t>& )=NULL;
|
||||||
|
|
||||||
void Image::set_compress_bc_func(void (*p_compress_func)(Image *)) {
|
void Image::set_compress_bc_func(void (*p_compress_func)(Image *)) {
|
||||||
|
|
||||||
|
@ -2067,7 +2067,7 @@ void Image::normalmap_to_xy() {
|
||||||
|
|
||||||
{
|
{
|
||||||
int len = data.size()/4;
|
int len = data.size()/4;
|
||||||
DVector<uint8_t>::Write wp = data.write();
|
PoolVector<uint8_t>::Write wp = data.write();
|
||||||
unsigned char *data_ptr=wp.ptr();
|
unsigned char *data_ptr=wp.ptr();
|
||||||
|
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
|
@ -2094,7 +2094,7 @@ void Image::srgb_to_linear() {
|
||||||
if (format==FORMAT_RGBA8) {
|
if (format==FORMAT_RGBA8) {
|
||||||
|
|
||||||
int len = data.size()/4;
|
int len = data.size()/4;
|
||||||
DVector<uint8_t>::Write wp = data.write();
|
PoolVector<uint8_t>::Write wp = data.write();
|
||||||
unsigned char *data_ptr=wp.ptr();
|
unsigned char *data_ptr=wp.ptr();
|
||||||
|
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
|
@ -2107,7 +2107,7 @@ void Image::srgb_to_linear() {
|
||||||
} else if (format==FORMAT_RGB8) {
|
} else if (format==FORMAT_RGB8) {
|
||||||
|
|
||||||
int len = data.size()/3;
|
int len = data.size()/3;
|
||||||
DVector<uint8_t>::Write wp = data.write();
|
PoolVector<uint8_t>::Write wp = data.write();
|
||||||
unsigned char *data_ptr=wp.ptr();
|
unsigned char *data_ptr=wp.ptr();
|
||||||
|
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
|
@ -2128,7 +2128,7 @@ void Image::premultiply_alpha() {
|
||||||
if (format!=FORMAT_RGBA8)
|
if (format!=FORMAT_RGBA8)
|
||||||
return; //not needed
|
return; //not needed
|
||||||
|
|
||||||
DVector<uint8_t>::Write wp = data.write();
|
PoolVector<uint8_t>::Write wp = data.write();
|
||||||
unsigned char *data_ptr=wp.ptr();
|
unsigned char *data_ptr=wp.ptr();
|
||||||
|
|
||||||
|
|
||||||
|
@ -2152,11 +2152,11 @@ void Image::fix_alpha_edges() {
|
||||||
if (format!=FORMAT_RGBA8)
|
if (format!=FORMAT_RGBA8)
|
||||||
return; //not needed
|
return; //not needed
|
||||||
|
|
||||||
DVector<uint8_t> dcopy = data;
|
PoolVector<uint8_t> dcopy = data;
|
||||||
DVector<uint8_t>::Read rp = data.read();
|
PoolVector<uint8_t>::Read rp = data.read();
|
||||||
const uint8_t *srcptr=rp.ptr();
|
const uint8_t *srcptr=rp.ptr();
|
||||||
|
|
||||||
DVector<uint8_t>::Write wp = data.write();
|
PoolVector<uint8_t>::Write wp = data.write();
|
||||||
unsigned char *data_ptr=wp.ptr();
|
unsigned char *data_ptr=wp.ptr();
|
||||||
|
|
||||||
const int max_radius=4;
|
const int max_radius=4;
|
||||||
|
|
16
core/image.h
16
core/image.h
|
@ -123,14 +123,14 @@ public:
|
||||||
|
|
||||||
Error _decompress_bc();
|
Error _decompress_bc();
|
||||||
|
|
||||||
static DVector<uint8_t> (*lossy_packer)(const Image& p_image,float p_quality);
|
static PoolVector<uint8_t> (*lossy_packer)(const Image& p_image,float p_quality);
|
||||||
static Image (*lossy_unpacker)(const DVector<uint8_t>& p_buffer);
|
static Image (*lossy_unpacker)(const PoolVector<uint8_t>& p_buffer);
|
||||||
static DVector<uint8_t> (*lossless_packer)(const Image& p_image);
|
static PoolVector<uint8_t> (*lossless_packer)(const Image& p_image);
|
||||||
static Image (*lossless_unpacker)(const DVector<uint8_t>& p_buffer);
|
static Image (*lossless_unpacker)(const PoolVector<uint8_t>& p_buffer);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Format format;
|
Format format;
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
int width,height;
|
int width,height;
|
||||||
bool mipmaps;
|
bool mipmaps;
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ public:
|
||||||
* Create a new image of a given size and format. Current image will be lost
|
* 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);
|
||||||
void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const DVector<uint8_t>& p_data);
|
void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const PoolVector<uint8_t>& p_data);
|
||||||
|
|
||||||
void create( const char ** p_xpm );
|
void create( const char ** p_xpm );
|
||||||
/**
|
/**
|
||||||
|
@ -214,7 +214,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
|
|
||||||
DVector<uint8_t> get_data() const;
|
PoolVector<uint8_t> get_data() const;
|
||||||
|
|
||||||
Error load(const String& p_path);
|
Error load(const String& p_path);
|
||||||
Error save_png(const String& p_path);
|
Error save_png(const String& p_path);
|
||||||
|
@ -230,7 +230,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* import an image of a specific size and format from a pointer
|
* 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 DVector<uint8_t>& p_data);
|
Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const PoolVector<uint8_t>& p_data);
|
||||||
|
|
||||||
enum AlphaMode {
|
enum AlphaMode {
|
||||||
ALPHA_NONE,
|
ALPHA_NONE,
|
||||||
|
|
|
@ -117,7 +117,7 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest,int p_elements) const {
|
||||||
|
|
||||||
int size = (cache.buffer.size() - (file.offset - cache.offset));
|
int size = (cache.buffer.size() - (file.offset - cache.offset));
|
||||||
size = size - (size % 4);
|
size = size - (size % 4);
|
||||||
//DVector<uint8_t>::Read read = cache.buffer.read();
|
//PoolVector<uint8_t>::Read read = cache.buffer.read();
|
||||||
//memcpy(p_dest, read.ptr() + (file.offset - cache.offset), size);
|
//memcpy(p_dest, read.ptr() + (file.offset - cache.offset), size);
|
||||||
memcpy(p_dest, cache.buffer.ptr() + (file.offset - cache.offset), size);
|
memcpy(p_dest, cache.buffer.ptr() + (file.offset - cache.offset), size);
|
||||||
p_dest += size;
|
p_dest += size;
|
||||||
|
@ -152,7 +152,7 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest,int p_elements) const {
|
||||||
};
|
};
|
||||||
|
|
||||||
int r = MIN(left, to_read);
|
int r = MIN(left, to_read);
|
||||||
//DVector<uint8_t>::Read read = cache.buffer.read();
|
//PoolVector<uint8_t>::Read read = cache.buffer.read();
|
||||||
//memcpy(p_dest+total_read, &read.ptr()[file.offset - cache.offset], r);
|
//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);
|
memcpy(p_dest+total_read, cache.buffer.ptr() + (file.offset - cache.offset), r);
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class FileAccessBufferedFA : public FileAccessBuffered {
|
||||||
cache.buffer.resize(p_size);
|
cache.buffer.resize(p_size);
|
||||||
|
|
||||||
// on dvector
|
// on dvector
|
||||||
//DVector<uint8_t>::Write write = cache.buffer.write();
|
//PoolVector<uint8_t>::Write write = cache.buffer.write();
|
||||||
//f.get_buffer(write.ptr(), p_size);
|
//f.get_buffer(write.ptr(), p_size);
|
||||||
|
|
||||||
// on vector
|
// on vector
|
||||||
|
|
|
@ -87,7 +87,7 @@ Ref<StreamPeer> HTTPClient::get_connection() const {
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error HTTPClient::request_raw( Method p_method, const String& p_url, const Vector<String>& p_headers,const DVector<uint8_t>& p_body) {
|
Error HTTPClient::request_raw( Method p_method, const String& p_url, const Vector<String>& p_headers,const PoolVector<uint8_t>& p_body) {
|
||||||
|
|
||||||
ERR_FAIL_INDEX_V(p_method,METHOD_MAX,ERR_INVALID_PARAMETER);
|
ERR_FAIL_INDEX_V(p_method,METHOD_MAX,ERR_INVALID_PARAMETER);
|
||||||
ERR_FAIL_COND_V(status!=STATUS_CONNECTED,ERR_INVALID_PARAMETER);
|
ERR_FAIL_COND_V(status!=STATUS_CONNECTED,ERR_INVALID_PARAMETER);
|
||||||
|
@ -120,7 +120,7 @@ Error HTTPClient::request_raw( Method p_method, const String& p_url, const Vecto
|
||||||
request+="\r\n";
|
request+="\r\n";
|
||||||
CharString cs=request.utf8();
|
CharString cs=request.utf8();
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
|
|
||||||
//Maybe this goes faster somehow?
|
//Maybe this goes faster somehow?
|
||||||
for(int i=0;i<cs.length();i++) {
|
for(int i=0;i<cs.length();i++) {
|
||||||
|
@ -128,7 +128,7 @@ Error HTTPClient::request_raw( Method p_method, const String& p_url, const Vecto
|
||||||
}
|
}
|
||||||
data.append_array( p_body );
|
data.append_array( p_body );
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
Error err = connection->put_data(&r[0], data.size());
|
Error err = connection->put_data(&r[0], data.size());
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
@ -172,7 +172,7 @@ public:
|
||||||
void set_connection(const Ref<StreamPeer>& p_connection);
|
void set_connection(const Ref<StreamPeer>& p_connection);
|
||||||
Ref<StreamPeer> get_connection() const;
|
Ref<StreamPeer> get_connection() const;
|
||||||
|
|
||||||
Error request_raw( Method p_method, const String& p_url, const Vector<String>& p_headers,const DVector<uint8_t>& p_body);
|
Error request_raw( Method p_method, const String& p_url, const Vector<String>& p_headers,const PoolVector<uint8_t>& p_body);
|
||||||
Error request( Method p_method, const String& p_url, const Vector<String>& p_headers,const String& p_body=String());
|
Error request( Method p_method, const String& p_url, const Vector<String>& p_headers,const String& p_body=String());
|
||||||
Error send_body_text(const String& p_body);
|
Error send_body_text(const String& p_body);
|
||||||
Error send_body_data(const ByteArray& p_body);
|
Error send_body_data(const ByteArray& p_body);
|
||||||
|
|
|
@ -272,11 +272,11 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
|
||||||
if (datalen>0) {
|
if (datalen>0) {
|
||||||
len-=5*4;
|
len-=5*4;
|
||||||
ERR_FAIL_COND_V( len < datalen, ERR_INVALID_DATA );
|
ERR_FAIL_COND_V( len < datalen, ERR_INVALID_DATA );
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
data.resize(datalen);
|
data.resize(datalen);
|
||||||
DVector<uint8_t>::Write wr = data.write();
|
PoolVector<uint8_t>::Write wr = data.write();
|
||||||
copymem(&wr[0],&buf[20],datalen);
|
copymem(&wr[0],&buf[20],datalen);
|
||||||
wr = DVector<uint8_t>::Write();
|
wr = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -537,17 +537,17 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
|
||||||
ERR_FAIL_COND_V((int)count>len,ERR_INVALID_DATA);
|
ERR_FAIL_COND_V((int)count>len,ERR_INVALID_DATA);
|
||||||
|
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
data.resize(count);
|
data.resize(count);
|
||||||
DVector<uint8_t>::Write w = data.write();
|
PoolVector<uint8_t>::Write w = data.write();
|
||||||
for(int i=0;i<count;i++) {
|
for(int i=0;i<count;i++) {
|
||||||
|
|
||||||
w[i]=buf[i];
|
w[i]=buf[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
w = DVector<uint8_t>::Write();
|
w = PoolVector<uint8_t>::Write();
|
||||||
}
|
}
|
||||||
|
|
||||||
r_variant=data;
|
r_variant=data;
|
||||||
|
@ -569,18 +569,18 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
|
||||||
len-=4;
|
len-=4;
|
||||||
ERR_FAIL_COND_V((int)count*4>len,ERR_INVALID_DATA);
|
ERR_FAIL_COND_V((int)count*4>len,ERR_INVALID_DATA);
|
||||||
|
|
||||||
DVector<int> data;
|
PoolVector<int> data;
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
//const int*rbuf=(const int*)buf;
|
//const int*rbuf=(const int*)buf;
|
||||||
data.resize(count);
|
data.resize(count);
|
||||||
DVector<int>::Write w = data.write();
|
PoolVector<int>::Write w = data.write();
|
||||||
for(int i=0;i<count;i++) {
|
for(int i=0;i<count;i++) {
|
||||||
|
|
||||||
w[i]=decode_uint32(&buf[i*4]);
|
w[i]=decode_uint32(&buf[i*4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
w = DVector<int>::Write();
|
w = PoolVector<int>::Write();
|
||||||
}
|
}
|
||||||
r_variant=Variant(data);
|
r_variant=Variant(data);
|
||||||
if (r_len) {
|
if (r_len) {
|
||||||
|
@ -596,18 +596,18 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
|
||||||
len-=4;
|
len-=4;
|
||||||
ERR_FAIL_COND_V((int)count*4>len,ERR_INVALID_DATA);
|
ERR_FAIL_COND_V((int)count*4>len,ERR_INVALID_DATA);
|
||||||
|
|
||||||
DVector<float> data;
|
PoolVector<float> data;
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
//const float*rbuf=(const float*)buf;
|
//const float*rbuf=(const float*)buf;
|
||||||
data.resize(count);
|
data.resize(count);
|
||||||
DVector<float>::Write w = data.write();
|
PoolVector<float>::Write w = data.write();
|
||||||
for(int i=0;i<count;i++) {
|
for(int i=0;i<count;i++) {
|
||||||
|
|
||||||
w[i]=decode_float(&buf[i*4]);
|
w[i]=decode_float(&buf[i*4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
w = DVector<float>::Write();
|
w = PoolVector<float>::Write();
|
||||||
}
|
}
|
||||||
r_variant=data;
|
r_variant=data;
|
||||||
|
|
||||||
|
@ -623,7 +623,7 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
|
||||||
uint32_t count = decode_uint32(buf);
|
uint32_t count = decode_uint32(buf);
|
||||||
ERR_FAIL_COND_V(count<0,ERR_INVALID_DATA);
|
ERR_FAIL_COND_V(count<0,ERR_INVALID_DATA);
|
||||||
|
|
||||||
DVector<String> strings;
|
PoolVector<String> strings;
|
||||||
buf+=4;
|
buf+=4;
|
||||||
len-=4;
|
len-=4;
|
||||||
|
|
||||||
|
@ -676,7 +676,7 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
|
||||||
len-=4;
|
len-=4;
|
||||||
|
|
||||||
ERR_FAIL_COND_V((int)count*4*2>len,ERR_INVALID_DATA);
|
ERR_FAIL_COND_V((int)count*4*2>len,ERR_INVALID_DATA);
|
||||||
DVector<Vector2> varray;
|
PoolVector<Vector2> varray;
|
||||||
|
|
||||||
if (r_len) {
|
if (r_len) {
|
||||||
(*r_len)+=4;
|
(*r_len)+=4;
|
||||||
|
@ -684,7 +684,7 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
varray.resize(count);
|
varray.resize(count);
|
||||||
DVector<Vector2>::Write w = varray.write();
|
PoolVector<Vector2>::Write w = varray.write();
|
||||||
|
|
||||||
for(int i=0;i<(int)count;i++) {
|
for(int i=0;i<(int)count;i++) {
|
||||||
|
|
||||||
|
@ -714,7 +714,7 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
|
||||||
len-=4;
|
len-=4;
|
||||||
|
|
||||||
ERR_FAIL_COND_V((int)count*4*3>len,ERR_INVALID_DATA);
|
ERR_FAIL_COND_V((int)count*4*3>len,ERR_INVALID_DATA);
|
||||||
DVector<Vector3> varray;
|
PoolVector<Vector3> varray;
|
||||||
|
|
||||||
if (r_len) {
|
if (r_len) {
|
||||||
(*r_len)+=4;
|
(*r_len)+=4;
|
||||||
|
@ -722,7 +722,7 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
varray.resize(count);
|
varray.resize(count);
|
||||||
DVector<Vector3>::Write w = varray.write();
|
PoolVector<Vector3>::Write w = varray.write();
|
||||||
|
|
||||||
for(int i=0;i<(int)count;i++) {
|
for(int i=0;i<(int)count;i++) {
|
||||||
|
|
||||||
|
@ -753,7 +753,7 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
|
||||||
len-=4;
|
len-=4;
|
||||||
|
|
||||||
ERR_FAIL_COND_V((int)count*4*4>len,ERR_INVALID_DATA);
|
ERR_FAIL_COND_V((int)count*4*4>len,ERR_INVALID_DATA);
|
||||||
DVector<Color> carray;
|
PoolVector<Color> carray;
|
||||||
|
|
||||||
if (r_len) {
|
if (r_len) {
|
||||||
(*r_len)+=4;
|
(*r_len)+=4;
|
||||||
|
@ -761,7 +761,7 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
carray.resize(count);
|
carray.resize(count);
|
||||||
DVector<Color>::Write w = carray.write();
|
PoolVector<Color>::Write w = carray.write();
|
||||||
|
|
||||||
for(int i=0;i<(int)count;i++) {
|
for(int i=0;i<(int)count;i++) {
|
||||||
|
|
||||||
|
@ -1055,7 +1055,7 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) {
|
||||||
case Variant::IMAGE: {
|
case Variant::IMAGE: {
|
||||||
|
|
||||||
Image image = p_variant;
|
Image image = p_variant;
|
||||||
DVector<uint8_t> data=image.get_data();
|
PoolVector<uint8_t> data=image.get_data();
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
|
|
||||||
|
@ -1065,7 +1065,7 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) {
|
||||||
encode_uint32(image.get_height(),&buf[12]);
|
encode_uint32(image.get_height(),&buf[12]);
|
||||||
int ds=data.size();
|
int ds=data.size();
|
||||||
encode_uint32(ds,&buf[16]);
|
encode_uint32(ds,&buf[16]);
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
copymem(&buf[20],&r[0],ds);
|
copymem(&buf[20],&r[0],ds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1234,14 +1234,14 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) {
|
||||||
// arrays
|
// arrays
|
||||||
case Variant::RAW_ARRAY: {
|
case Variant::RAW_ARRAY: {
|
||||||
|
|
||||||
DVector<uint8_t> data = p_variant;
|
PoolVector<uint8_t> data = p_variant;
|
||||||
int datalen=data.size();
|
int datalen=data.size();
|
||||||
int datasize=sizeof(uint8_t);
|
int datasize=sizeof(uint8_t);
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
encode_uint32(datalen,buf);
|
encode_uint32(datalen,buf);
|
||||||
buf+=4;
|
buf+=4;
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
copymem(buf,&r[0],datalen*datasize);
|
copymem(buf,&r[0],datalen*datasize);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1253,14 +1253,14 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) {
|
||||||
} break;
|
} break;
|
||||||
case Variant::INT_ARRAY: {
|
case Variant::INT_ARRAY: {
|
||||||
|
|
||||||
DVector<int> data = p_variant;
|
PoolVector<int> data = p_variant;
|
||||||
int datalen=data.size();
|
int datalen=data.size();
|
||||||
int datasize=sizeof(int32_t);
|
int datasize=sizeof(int32_t);
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
encode_uint32(datalen,buf);
|
encode_uint32(datalen,buf);
|
||||||
buf+=4;
|
buf+=4;
|
||||||
DVector<int>::Read r = data.read();
|
PoolVector<int>::Read r = data.read();
|
||||||
for(int i=0;i<datalen;i++)
|
for(int i=0;i<datalen;i++)
|
||||||
encode_uint32(r[i],&buf[i*datasize]);
|
encode_uint32(r[i],&buf[i*datasize]);
|
||||||
|
|
||||||
|
@ -1271,14 +1271,14 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) {
|
||||||
} break;
|
} break;
|
||||||
case Variant::REAL_ARRAY: {
|
case Variant::REAL_ARRAY: {
|
||||||
|
|
||||||
DVector<real_t> data = p_variant;
|
PoolVector<real_t> data = p_variant;
|
||||||
int datalen=data.size();
|
int datalen=data.size();
|
||||||
int datasize=sizeof(real_t);
|
int datasize=sizeof(real_t);
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
encode_uint32(datalen,buf);
|
encode_uint32(datalen,buf);
|
||||||
buf+=4;
|
buf+=4;
|
||||||
DVector<real_t>::Read r = data.read();
|
PoolVector<real_t>::Read r = data.read();
|
||||||
for(int i=0;i<datalen;i++)
|
for(int i=0;i<datalen;i++)
|
||||||
encode_float(r[i],&buf[i*datasize]);
|
encode_float(r[i],&buf[i*datasize]);
|
||||||
|
|
||||||
|
@ -1290,7 +1290,7 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) {
|
||||||
case Variant::STRING_ARRAY: {
|
case Variant::STRING_ARRAY: {
|
||||||
|
|
||||||
|
|
||||||
DVector<String> data = p_variant;
|
PoolVector<String> data = p_variant;
|
||||||
int len=data.size();
|
int len=data.size();
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
|
@ -1323,7 +1323,7 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) {
|
||||||
} break;
|
} break;
|
||||||
case Variant::VECTOR2_ARRAY: {
|
case Variant::VECTOR2_ARRAY: {
|
||||||
|
|
||||||
DVector<Vector2> data = p_variant;
|
PoolVector<Vector2> data = p_variant;
|
||||||
int len=data.size();
|
int len=data.size();
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
|
@ -1351,7 +1351,7 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) {
|
||||||
} break;
|
} break;
|
||||||
case Variant::VECTOR3_ARRAY: {
|
case Variant::VECTOR3_ARRAY: {
|
||||||
|
|
||||||
DVector<Vector3> data = p_variant;
|
PoolVector<Vector3> data = p_variant;
|
||||||
int len=data.size();
|
int len=data.size();
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
|
@ -1380,7 +1380,7 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) {
|
||||||
} break;
|
} break;
|
||||||
case Variant::COLOR_ARRAY: {
|
case Variant::COLOR_ARRAY: {
|
||||||
|
|
||||||
DVector<Color> data = p_variant;
|
PoolVector<Color> data = p_variant;
|
||||||
int len=data.size();
|
int len=data.size();
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ PacketPeer::PacketPeer() {
|
||||||
last_get_error=OK;
|
last_get_error=OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error PacketPeer::get_packet_buffer(DVector<uint8_t> &r_buffer) const {
|
Error PacketPeer::get_packet_buffer(PoolVector<uint8_t> &r_buffer) const {
|
||||||
|
|
||||||
const uint8_t *buffer;
|
const uint8_t *buffer;
|
||||||
int buffer_size;
|
int buffer_size;
|
||||||
|
@ -51,7 +51,7 @@ Error PacketPeer::get_packet_buffer(DVector<uint8_t> &r_buffer) const {
|
||||||
if (buffer_size==0)
|
if (buffer_size==0)
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = r_buffer.write();
|
PoolVector<uint8_t>::Write w = r_buffer.write();
|
||||||
for(int i=0;i<buffer_size;i++)
|
for(int i=0;i<buffer_size;i++)
|
||||||
w[i]=buffer[i];
|
w[i]=buffer[i];
|
||||||
|
|
||||||
|
@ -59,13 +59,13 @@ Error PacketPeer::get_packet_buffer(DVector<uint8_t> &r_buffer) const {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Error PacketPeer::put_packet_buffer(const DVector<uint8_t> &p_buffer) {
|
Error PacketPeer::put_packet_buffer(const PoolVector<uint8_t> &p_buffer) {
|
||||||
|
|
||||||
int len = p_buffer.size();
|
int len = p_buffer.size();
|
||||||
if (len==0)
|
if (len==0)
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = p_buffer.read();
|
PoolVector<uint8_t>::Read r = p_buffer.read();
|
||||||
return put_packet(&r[0],len);
|
return put_packet(&r[0],len);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -108,12 +108,12 @@ Variant PacketPeer::_bnd_get_var() const {
|
||||||
return var;
|
return var;
|
||||||
};
|
};
|
||||||
|
|
||||||
Error PacketPeer::_put_packet(const DVector<uint8_t> &p_buffer) {
|
Error PacketPeer::_put_packet(const PoolVector<uint8_t> &p_buffer) {
|
||||||
return put_packet_buffer(p_buffer);
|
return put_packet_buffer(p_buffer);
|
||||||
}
|
}
|
||||||
DVector<uint8_t> PacketPeer::_get_packet() const {
|
PoolVector<uint8_t> PacketPeer::_get_packet() const {
|
||||||
|
|
||||||
DVector<uint8_t> raw;
|
PoolVector<uint8_t> raw;
|
||||||
last_get_error=get_packet_buffer(raw);
|
last_get_error=get_packet_buffer(raw);
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,8 @@ class PacketPeer : public Reference {
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
|
||||||
Error _put_packet(const DVector<uint8_t> &p_buffer);
|
Error _put_packet(const PoolVector<uint8_t> &p_buffer);
|
||||||
DVector<uint8_t> _get_packet() const;
|
PoolVector<uint8_t> _get_packet() const;
|
||||||
Error _get_packet_error() const;
|
Error _get_packet_error() const;
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ public:
|
||||||
|
|
||||||
/* helpers / binders */
|
/* helpers / binders */
|
||||||
|
|
||||||
virtual Error get_packet_buffer(DVector<uint8_t> &r_buffer) const;
|
virtual Error get_packet_buffer(PoolVector<uint8_t> &r_buffer) const;
|
||||||
virtual Error put_packet_buffer(const DVector<uint8_t> &p_buffer);
|
virtual Error put_packet_buffer(const PoolVector<uint8_t> &p_buffer);
|
||||||
|
|
||||||
virtual Error get_var(Variant &r_variant) const;
|
virtual Error get_var(Variant &r_variant) const;
|
||||||
virtual Error put_var(const Variant& p_packet);
|
virtual Error put_var(const Variant& p_packet);
|
||||||
|
|
|
@ -264,22 +264,22 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
|
||||||
|
|
||||||
uint32_t datalen = f->get_32();
|
uint32_t datalen = f->get_32();
|
||||||
|
|
||||||
DVector<uint8_t> imgdata;
|
PoolVector<uint8_t> imgdata;
|
||||||
imgdata.resize(datalen);
|
imgdata.resize(datalen);
|
||||||
DVector<uint8_t>::Write w = imgdata.write();
|
PoolVector<uint8_t>::Write w = imgdata.write();
|
||||||
f->get_buffer(w.ptr(),datalen);
|
f->get_buffer(w.ptr(),datalen);
|
||||||
_advance_padding(datalen);
|
_advance_padding(datalen);
|
||||||
w=DVector<uint8_t>::Write();
|
w=PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
r_v=Image(width,height,mipmaps,fmt,imgdata);
|
r_v=Image(width,height,mipmaps,fmt,imgdata);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//compressed
|
//compressed
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
data.resize(f->get_32());
|
data.resize(f->get_32());
|
||||||
DVector<uint8_t>::Write w = data.write();
|
PoolVector<uint8_t>::Write w = data.write();
|
||||||
f->get_buffer(w.ptr(),data.size());
|
f->get_buffer(w.ptr(),data.size());
|
||||||
w = DVector<uint8_t>::Write();
|
w = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
Image img;
|
Image img;
|
||||||
|
|
||||||
|
@ -448,12 +448,12 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
|
||||||
|
|
||||||
uint32_t len = f->get_32();
|
uint32_t len = f->get_32();
|
||||||
|
|
||||||
DVector<uint8_t> array;
|
PoolVector<uint8_t> array;
|
||||||
array.resize(len);
|
array.resize(len);
|
||||||
DVector<uint8_t>::Write w = array.write();
|
PoolVector<uint8_t>::Write w = array.write();
|
||||||
f->get_buffer(w.ptr(),len);
|
f->get_buffer(w.ptr(),len);
|
||||||
_advance_padding(len);
|
_advance_padding(len);
|
||||||
w=DVector<uint8_t>::Write();
|
w=PoolVector<uint8_t>::Write();
|
||||||
r_v=array;
|
r_v=array;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
@ -461,9 +461,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
|
||||||
|
|
||||||
uint32_t len = f->get_32();
|
uint32_t len = f->get_32();
|
||||||
|
|
||||||
DVector<int> array;
|
PoolVector<int> array;
|
||||||
array.resize(len);
|
array.resize(len);
|
||||||
DVector<int>::Write w = array.write();
|
PoolVector<int>::Write w = array.write();
|
||||||
f->get_buffer((uint8_t*)w.ptr(),len*4);
|
f->get_buffer((uint8_t*)w.ptr(),len*4);
|
||||||
#ifdef BIG_ENDIAN_ENABLED
|
#ifdef BIG_ENDIAN_ENABLED
|
||||||
{
|
{
|
||||||
|
@ -475,16 +475,16 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
w=DVector<int>::Write();
|
w=PoolVector<int>::Write();
|
||||||
r_v=array;
|
r_v=array;
|
||||||
} break;
|
} break;
|
||||||
case VARIANT_REAL_ARRAY: {
|
case VARIANT_REAL_ARRAY: {
|
||||||
|
|
||||||
uint32_t len = f->get_32();
|
uint32_t len = f->get_32();
|
||||||
|
|
||||||
DVector<real_t> array;
|
PoolVector<real_t> array;
|
||||||
array.resize(len);
|
array.resize(len);
|
||||||
DVector<real_t>::Write w = array.write();
|
PoolVector<real_t>::Write w = array.write();
|
||||||
f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t));
|
f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t));
|
||||||
#ifdef BIG_ENDIAN_ENABLED
|
#ifdef BIG_ENDIAN_ENABLED
|
||||||
{
|
{
|
||||||
|
@ -497,18 +497,18 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
w=DVector<real_t>::Write();
|
w=PoolVector<real_t>::Write();
|
||||||
r_v=array;
|
r_v=array;
|
||||||
} break;
|
} break;
|
||||||
case VARIANT_STRING_ARRAY: {
|
case VARIANT_STRING_ARRAY: {
|
||||||
|
|
||||||
uint32_t len = f->get_32();
|
uint32_t len = f->get_32();
|
||||||
DVector<String> array;
|
PoolVector<String> array;
|
||||||
array.resize(len);
|
array.resize(len);
|
||||||
DVector<String>::Write w = array.write();
|
PoolVector<String>::Write w = array.write();
|
||||||
for(uint32_t i=0;i<len;i++)
|
for(uint32_t i=0;i<len;i++)
|
||||||
w[i]=get_unicode_string();
|
w[i]=get_unicode_string();
|
||||||
w=DVector<String>::Write();
|
w=PoolVector<String>::Write();
|
||||||
r_v=array;
|
r_v=array;
|
||||||
|
|
||||||
|
|
||||||
|
@ -517,9 +517,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
|
||||||
|
|
||||||
uint32_t len = f->get_32();
|
uint32_t len = f->get_32();
|
||||||
|
|
||||||
DVector<Vector2> array;
|
PoolVector<Vector2> array;
|
||||||
array.resize(len);
|
array.resize(len);
|
||||||
DVector<Vector2>::Write w = array.write();
|
PoolVector<Vector2>::Write w = array.write();
|
||||||
if (sizeof(Vector2)==8) {
|
if (sizeof(Vector2)==8) {
|
||||||
f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)*2);
|
f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)*2);
|
||||||
#ifdef BIG_ENDIAN_ENABLED
|
#ifdef BIG_ENDIAN_ENABLED
|
||||||
|
@ -537,7 +537,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
|
||||||
ERR_EXPLAIN("Vector2 size is NOT 8!");
|
ERR_EXPLAIN("Vector2 size is NOT 8!");
|
||||||
ERR_FAIL_V(ERR_UNAVAILABLE);
|
ERR_FAIL_V(ERR_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
w=DVector<Vector2>::Write();
|
w=PoolVector<Vector2>::Write();
|
||||||
r_v=array;
|
r_v=array;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
@ -545,9 +545,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
|
||||||
|
|
||||||
uint32_t len = f->get_32();
|
uint32_t len = f->get_32();
|
||||||
|
|
||||||
DVector<Vector3> array;
|
PoolVector<Vector3> array;
|
||||||
array.resize(len);
|
array.resize(len);
|
||||||
DVector<Vector3>::Write w = array.write();
|
PoolVector<Vector3>::Write w = array.write();
|
||||||
if (sizeof(Vector3)==12) {
|
if (sizeof(Vector3)==12) {
|
||||||
f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)*3);
|
f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)*3);
|
||||||
#ifdef BIG_ENDIAN_ENABLED
|
#ifdef BIG_ENDIAN_ENABLED
|
||||||
|
@ -565,7 +565,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
|
||||||
ERR_EXPLAIN("Vector3 size is NOT 12!");
|
ERR_EXPLAIN("Vector3 size is NOT 12!");
|
||||||
ERR_FAIL_V(ERR_UNAVAILABLE);
|
ERR_FAIL_V(ERR_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
w=DVector<Vector3>::Write();
|
w=PoolVector<Vector3>::Write();
|
||||||
r_v=array;
|
r_v=array;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
@ -573,9 +573,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
|
||||||
|
|
||||||
uint32_t len = f->get_32();
|
uint32_t len = f->get_32();
|
||||||
|
|
||||||
DVector<Color> array;
|
PoolVector<Color> array;
|
||||||
array.resize(len);
|
array.resize(len);
|
||||||
DVector<Color>::Write w = array.write();
|
PoolVector<Color>::Write w = array.write();
|
||||||
if (sizeof(Color)==16) {
|
if (sizeof(Color)==16) {
|
||||||
f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)*4);
|
f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)*4);
|
||||||
#ifdef BIG_ENDIAN_ENABLED
|
#ifdef BIG_ENDIAN_ENABLED
|
||||||
|
@ -593,7 +593,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
|
||||||
ERR_EXPLAIN("Color size is NOT 16!");
|
ERR_EXPLAIN("Color size is NOT 16!");
|
||||||
ERR_FAIL_V(ERR_UNAVAILABLE);
|
ERR_FAIL_V(ERR_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
w=DVector<Color>::Write();
|
w=PoolVector<Color>::Write();
|
||||||
r_v=array;
|
r_v=array;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -1587,12 +1587,12 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
|
||||||
|
|
||||||
int dlen = val.get_data().size();
|
int dlen = val.get_data().size();
|
||||||
f->store_32(dlen);
|
f->store_32(dlen);
|
||||||
DVector<uint8_t>::Read r = val.get_data().read();
|
PoolVector<uint8_t>::Read r = val.get_data().read();
|
||||||
f->store_buffer(r.ptr(),dlen);
|
f->store_buffer(r.ptr(),dlen);
|
||||||
_pad_buffer(dlen);
|
_pad_buffer(dlen);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
if (encoding==IMAGE_ENCODING_LOSSY) {
|
if (encoding==IMAGE_ENCODING_LOSSY) {
|
||||||
data=Image::lossy_packer(val,quality);
|
data=Image::lossy_packer(val,quality);
|
||||||
|
|
||||||
|
@ -1604,7 +1604,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
|
||||||
int ds=data.size();
|
int ds=data.size();
|
||||||
f->store_32(ds);
|
f->store_32(ds);
|
||||||
if (ds>0) {
|
if (ds>0) {
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
f->store_buffer(r.ptr(),ds);
|
f->store_buffer(r.ptr(),ds);
|
||||||
|
|
||||||
_pad_buffer(ds);
|
_pad_buffer(ds);
|
||||||
|
@ -1703,10 +1703,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
|
||||||
case Variant::RAW_ARRAY: {
|
case Variant::RAW_ARRAY: {
|
||||||
|
|
||||||
f->store_32(VARIANT_RAW_ARRAY);
|
f->store_32(VARIANT_RAW_ARRAY);
|
||||||
DVector<uint8_t> arr = p_property;
|
PoolVector<uint8_t> arr = p_property;
|
||||||
int len=arr.size();
|
int len=arr.size();
|
||||||
f->store_32(len);
|
f->store_32(len);
|
||||||
DVector<uint8_t>::Read r = arr.read();
|
PoolVector<uint8_t>::Read r = arr.read();
|
||||||
f->store_buffer(r.ptr(),len);
|
f->store_buffer(r.ptr(),len);
|
||||||
_pad_buffer(len);
|
_pad_buffer(len);
|
||||||
|
|
||||||
|
@ -1714,10 +1714,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
|
||||||
case Variant::INT_ARRAY: {
|
case Variant::INT_ARRAY: {
|
||||||
|
|
||||||
f->store_32(VARIANT_INT_ARRAY);
|
f->store_32(VARIANT_INT_ARRAY);
|
||||||
DVector<int> arr = p_property;
|
PoolVector<int> arr = p_property;
|
||||||
int len=arr.size();
|
int len=arr.size();
|
||||||
f->store_32(len);
|
f->store_32(len);
|
||||||
DVector<int>::Read r = arr.read();
|
PoolVector<int>::Read r = arr.read();
|
||||||
for(int i=0;i<len;i++)
|
for(int i=0;i<len;i++)
|
||||||
f->store_32(r[i]);
|
f->store_32(r[i]);
|
||||||
|
|
||||||
|
@ -1725,10 +1725,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
|
||||||
case Variant::REAL_ARRAY: {
|
case Variant::REAL_ARRAY: {
|
||||||
|
|
||||||
f->store_32(VARIANT_REAL_ARRAY);
|
f->store_32(VARIANT_REAL_ARRAY);
|
||||||
DVector<real_t> arr = p_property;
|
PoolVector<real_t> arr = p_property;
|
||||||
int len=arr.size();
|
int len=arr.size();
|
||||||
f->store_32(len);
|
f->store_32(len);
|
||||||
DVector<real_t>::Read r = arr.read();
|
PoolVector<real_t>::Read r = arr.read();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
f->store_real(r[i]);
|
f->store_real(r[i]);
|
||||||
}
|
}
|
||||||
|
@ -1737,10 +1737,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
|
||||||
case Variant::STRING_ARRAY: {
|
case Variant::STRING_ARRAY: {
|
||||||
|
|
||||||
f->store_32(VARIANT_STRING_ARRAY);
|
f->store_32(VARIANT_STRING_ARRAY);
|
||||||
DVector<String> arr = p_property;
|
PoolVector<String> arr = p_property;
|
||||||
int len=arr.size();
|
int len=arr.size();
|
||||||
f->store_32(len);
|
f->store_32(len);
|
||||||
DVector<String>::Read r = arr.read();
|
PoolVector<String>::Read r = arr.read();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
save_unicode_string(r[i]);
|
save_unicode_string(r[i]);
|
||||||
}
|
}
|
||||||
|
@ -1749,10 +1749,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
|
||||||
case Variant::VECTOR3_ARRAY: {
|
case Variant::VECTOR3_ARRAY: {
|
||||||
|
|
||||||
f->store_32(VARIANT_VECTOR3_ARRAY);
|
f->store_32(VARIANT_VECTOR3_ARRAY);
|
||||||
DVector<Vector3> arr = p_property;
|
PoolVector<Vector3> arr = p_property;
|
||||||
int len=arr.size();
|
int len=arr.size();
|
||||||
f->store_32(len);
|
f->store_32(len);
|
||||||
DVector<Vector3>::Read r = arr.read();
|
PoolVector<Vector3>::Read r = arr.read();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
f->store_real(r[i].x);
|
f->store_real(r[i].x);
|
||||||
f->store_real(r[i].y);
|
f->store_real(r[i].y);
|
||||||
|
@ -1763,10 +1763,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
|
||||||
case Variant::VECTOR2_ARRAY: {
|
case Variant::VECTOR2_ARRAY: {
|
||||||
|
|
||||||
f->store_32(VARIANT_VECTOR2_ARRAY);
|
f->store_32(VARIANT_VECTOR2_ARRAY);
|
||||||
DVector<Vector2> arr = p_property;
|
PoolVector<Vector2> arr = p_property;
|
||||||
int len=arr.size();
|
int len=arr.size();
|
||||||
f->store_32(len);
|
f->store_32(len);
|
||||||
DVector<Vector2>::Read r = arr.read();
|
PoolVector<Vector2>::Read r = arr.read();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
f->store_real(r[i].x);
|
f->store_real(r[i].x);
|
||||||
f->store_real(r[i].y);
|
f->store_real(r[i].y);
|
||||||
|
@ -1776,10 +1776,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
|
||||||
case Variant::COLOR_ARRAY: {
|
case Variant::COLOR_ARRAY: {
|
||||||
|
|
||||||
f->store_32(VARIANT_COLOR_ARRAY);
|
f->store_32(VARIANT_COLOR_ARRAY);
|
||||||
DVector<Color> arr = p_property;
|
PoolVector<Color> arr = p_property;
|
||||||
int len=arr.size();
|
int len=arr.size();
|
||||||
f->store_32(len);
|
f->store_32(len);
|
||||||
DVector<Color>::Read r = arr.read();
|
PoolVector<Color>::Read r = arr.read();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
f->store_real(r[i].r);
|
f->store_real(r[i].r);
|
||||||
f->store_real(r[i].g);
|
f->store_real(r[i].g);
|
||||||
|
|
|
@ -623,9 +623,9 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
return OK;
|
return OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
DVector<uint8_t> pixels;
|
PoolVector<uint8_t> pixels;
|
||||||
pixels.resize(datasize);
|
pixels.resize(datasize);
|
||||||
DVector<uint8_t>::Write wb = pixels.write();
|
PoolVector<uint8_t>::Write wb = pixels.write();
|
||||||
|
|
||||||
int idx=0;
|
int idx=0;
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
|
@ -652,7 +652,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
}
|
}
|
||||||
ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
|
ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
|
||||||
|
|
||||||
wb=DVector<uint8_t>::Write();
|
wb=PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
r_v=Image(w,h,mipmaps,imgformat,pixels);
|
r_v=Image(w,h,mipmaps,imgformat,pixels);
|
||||||
String sdfsdfg;
|
String sdfsdfg;
|
||||||
|
@ -672,9 +672,9 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
}
|
}
|
||||||
int len=tag->args["len"].to_int();
|
int len=tag->args["len"].to_int();
|
||||||
|
|
||||||
DVector<uint8_t> bytes;
|
PoolVector<uint8_t> bytes;
|
||||||
bytes.resize(len);
|
bytes.resize(len);
|
||||||
DVector<uint8_t>::Write w=bytes.write();
|
PoolVector<uint8_t>::Write w=bytes.write();
|
||||||
uint8_t *bytesptr=w.ptr();
|
uint8_t *bytesptr=w.ptr();
|
||||||
int idx=0;
|
int idx=0;
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
|
@ -700,7 +700,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
|
|
||||||
ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
|
ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
|
||||||
|
|
||||||
w=DVector<uint8_t>::Write();
|
w=PoolVector<uint8_t>::Write();
|
||||||
r_v=bytes;
|
r_v=bytes;
|
||||||
String sdfsdfg;
|
String sdfsdfg;
|
||||||
Error err=parse_property_data(sdfsdfg);
|
Error err=parse_property_data(sdfsdfg);
|
||||||
|
@ -717,9 +717,9 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
}
|
}
|
||||||
int len=tag->args["len"].to_int();
|
int len=tag->args["len"].to_int();
|
||||||
|
|
||||||
DVector<int> ints;
|
PoolVector<int> ints;
|
||||||
ints.resize(len);
|
ints.resize(len);
|
||||||
DVector<int>::Write w=ints.write();
|
PoolVector<int>::Write w=ints.write();
|
||||||
int *intsptr=w.ptr();
|
int *intsptr=w.ptr();
|
||||||
int idx=0;
|
int idx=0;
|
||||||
String str;
|
String str;
|
||||||
|
@ -770,7 +770,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
w=DVector<int>::Write();
|
w=PoolVector<int>::Write();
|
||||||
|
|
||||||
r_v=ints;
|
r_v=ints;
|
||||||
Error err=goto_end_of_tag();
|
Error err=goto_end_of_tag();
|
||||||
|
@ -786,9 +786,9 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
}
|
}
|
||||||
int len=tag->args["len"].to_int();;
|
int len=tag->args["len"].to_int();;
|
||||||
|
|
||||||
DVector<real_t> reals;
|
PoolVector<real_t> reals;
|
||||||
reals.resize(len);
|
reals.resize(len);
|
||||||
DVector<real_t>::Write w=reals.write();
|
PoolVector<real_t>::Write w=reals.write();
|
||||||
real_t *realsptr=w.ptr();
|
real_t *realsptr=w.ptr();
|
||||||
int idx=0;
|
int idx=0;
|
||||||
String str;
|
String str;
|
||||||
|
@ -845,7 +845,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
w=DVector<real_t>::Write();
|
w=PoolVector<real_t>::Write();
|
||||||
r_v=reals;
|
r_v=reals;
|
||||||
|
|
||||||
Error err=goto_end_of_tag();
|
Error err=goto_end_of_tag();
|
||||||
|
@ -861,9 +861,9 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
}
|
}
|
||||||
int len=tag->args["len"].to_int();
|
int len=tag->args["len"].to_int();
|
||||||
|
|
||||||
DVector<String> strings;
|
PoolVector<String> strings;
|
||||||
strings.resize(len);
|
strings.resize(len);
|
||||||
DVector<String>::Write w=strings.write();
|
PoolVector<String>::Write w=strings.write();
|
||||||
String *stringsptr=w.ptr();
|
String *stringsptr=w.ptr();
|
||||||
int idx=0;
|
int idx=0;
|
||||||
String str;
|
String str;
|
||||||
|
@ -903,7 +903,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
cs.push_back(c);
|
cs.push_back(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w=DVector<String>::Write();
|
w=PoolVector<String>::Write();
|
||||||
r_v=strings;
|
r_v=strings;
|
||||||
String sdfsdfg;
|
String sdfsdfg;
|
||||||
Error err=parse_property_data(sdfsdfg);
|
Error err=parse_property_data(sdfsdfg);
|
||||||
|
@ -923,7 +923,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
|
|
||||||
StringArray array;
|
StringArray array;
|
||||||
array.resize(len);
|
array.resize(len);
|
||||||
DVector<String>::Write w = array.write();
|
PoolVector<String>::Write w = array.write();
|
||||||
|
|
||||||
Error err;
|
Error err;
|
||||||
Variant v;
|
Variant v;
|
||||||
|
@ -964,9 +964,9 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
}
|
}
|
||||||
int len=tag->args["len"].to_int();;
|
int len=tag->args["len"].to_int();;
|
||||||
|
|
||||||
DVector<Vector3> vectors;
|
PoolVector<Vector3> vectors;
|
||||||
vectors.resize(len);
|
vectors.resize(len);
|
||||||
DVector<Vector3>::Write w=vectors.write();
|
PoolVector<Vector3>::Write w=vectors.write();
|
||||||
Vector3 *vectorsptr=w.ptr();
|
Vector3 *vectorsptr=w.ptr();
|
||||||
int idx=0;
|
int idx=0;
|
||||||
int subidx=0;
|
int subidx=0;
|
||||||
|
@ -1041,7 +1041,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
// double time_taken = (OS::get_singleton()->get_ticks_usec() - tbegin)/1000000.0;
|
// double time_taken = (OS::get_singleton()->get_ticks_usec() - tbegin)/1000000.0;
|
||||||
|
|
||||||
|
|
||||||
w=DVector<Vector3>::Write();
|
w=PoolVector<Vector3>::Write();
|
||||||
r_v=vectors;
|
r_v=vectors;
|
||||||
String sdfsdfg;
|
String sdfsdfg;
|
||||||
Error err=goto_end_of_tag();
|
Error err=goto_end_of_tag();
|
||||||
|
@ -1058,9 +1058,9 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
}
|
}
|
||||||
int len=tag->args["len"].to_int();;
|
int len=tag->args["len"].to_int();;
|
||||||
|
|
||||||
DVector<Vector2> vectors;
|
PoolVector<Vector2> vectors;
|
||||||
vectors.resize(len);
|
vectors.resize(len);
|
||||||
DVector<Vector2>::Write w=vectors.write();
|
PoolVector<Vector2>::Write w=vectors.write();
|
||||||
Vector2 *vectorsptr=w.ptr();
|
Vector2 *vectorsptr=w.ptr();
|
||||||
int idx=0;
|
int idx=0;
|
||||||
int subidx=0;
|
int subidx=0;
|
||||||
|
@ -1135,7 +1135,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
// double time_taken = (OS::get_singleton()->get_ticks_usec() - tbegin)/1000000.0;
|
// double time_taken = (OS::get_singleton()->get_ticks_usec() - tbegin)/1000000.0;
|
||||||
|
|
||||||
|
|
||||||
w=DVector<Vector2>::Write();
|
w=PoolVector<Vector2>::Write();
|
||||||
r_v=vectors;
|
r_v=vectors;
|
||||||
String sdfsdfg;
|
String sdfsdfg;
|
||||||
Error err=goto_end_of_tag();
|
Error err=goto_end_of_tag();
|
||||||
|
@ -1152,9 +1152,9 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
}
|
}
|
||||||
int len=tag->args["len"].to_int();;
|
int len=tag->args["len"].to_int();;
|
||||||
|
|
||||||
DVector<Color> colors;
|
PoolVector<Color> colors;
|
||||||
colors.resize(len);
|
colors.resize(len);
|
||||||
DVector<Color>::Write w=colors.write();
|
PoolVector<Color>::Write w=colors.write();
|
||||||
Color *colorsptr=w.ptr();
|
Color *colorsptr=w.ptr();
|
||||||
int idx=0;
|
int idx=0;
|
||||||
int subidx=0;
|
int subidx=0;
|
||||||
|
@ -1194,7 +1194,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
|
||||||
str+=c;
|
str+=c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w=DVector<Color>::Write();
|
w=PoolVector<Color>::Write();
|
||||||
r_v=colors;
|
r_v=colors;
|
||||||
String sdfsdfg;
|
String sdfsdfg;
|
||||||
Error err=parse_property_data(sdfsdfg);
|
Error err=parse_property_data(sdfsdfg);
|
||||||
|
@ -2248,13 +2248,13 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V
|
||||||
case Variant::DICTIONARY: type="dictionary"; params="shared=\""+String(p_property.is_shared()?"true":"false")+"\""; oneliner=false; break;
|
case Variant::DICTIONARY: type="dictionary"; params="shared=\""+String(p_property.is_shared()?"true":"false")+"\""; oneliner=false; break;
|
||||||
case Variant::ARRAY: type="array"; params="len=\""+itos(p_property.operator Array().size())+"\" shared=\""+String(p_property.is_shared()?"true":"false")+"\""; oneliner=false; break;
|
case Variant::ARRAY: type="array"; params="len=\""+itos(p_property.operator Array().size())+"\" shared=\""+String(p_property.is_shared()?"true":"false")+"\""; oneliner=false; break;
|
||||||
|
|
||||||
case Variant::RAW_ARRAY: type="raw_array"; params="len=\""+itos(p_property.operator DVector < uint8_t >().size())+"\""; break;
|
case Variant::RAW_ARRAY: type="raw_array"; params="len=\""+itos(p_property.operator PoolVector < uint8_t >().size())+"\""; break;
|
||||||
case Variant::INT_ARRAY: type="int_array"; params="len=\""+itos(p_property.operator DVector < int >().size())+"\""; break;
|
case Variant::INT_ARRAY: type="int_array"; params="len=\""+itos(p_property.operator PoolVector < int >().size())+"\""; break;
|
||||||
case Variant::REAL_ARRAY: type="real_array"; params="len=\""+itos(p_property.operator DVector < real_t >().size())+"\""; break;
|
case Variant::REAL_ARRAY: type="real_array"; params="len=\""+itos(p_property.operator PoolVector < real_t >().size())+"\""; break;
|
||||||
case Variant::STRING_ARRAY: oneliner=false; type="string_array"; params="len=\""+itos(p_property.operator DVector < String >().size())+"\""; break;
|
case Variant::STRING_ARRAY: oneliner=false; type="string_array"; params="len=\""+itos(p_property.operator PoolVector < String >().size())+"\""; break;
|
||||||
case Variant::VECTOR2_ARRAY: type="vector2_array"; params="len=\""+itos(p_property.operator DVector < Vector2 >().size())+"\""; break;
|
case Variant::VECTOR2_ARRAY: type="vector2_array"; params="len=\""+itos(p_property.operator PoolVector < Vector2 >().size())+"\""; break;
|
||||||
case Variant::VECTOR3_ARRAY: type="vector3_array"; params="len=\""+itos(p_property.operator DVector < Vector3 >().size())+"\""; break;
|
case Variant::VECTOR3_ARRAY: type="vector3_array"; params="len=\""+itos(p_property.operator PoolVector < Vector3 >().size())+"\""; break;
|
||||||
case Variant::COLOR_ARRAY: type="color_array"; params="len=\""+itos(p_property.operator DVector < Color >().size())+"\""; break;
|
case Variant::COLOR_ARRAY: type="color_array"; params="len=\""+itos(p_property.operator PoolVector < Color >().size())+"\""; break;
|
||||||
default: {
|
default: {
|
||||||
|
|
||||||
ERR_PRINT("Unknown Variant type.");
|
ERR_PRINT("Unknown Variant type.");
|
||||||
|
@ -2403,9 +2403,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V
|
||||||
|
|
||||||
String s;
|
String s;
|
||||||
Image img = p_property;
|
Image img = p_property;
|
||||||
DVector<uint8_t> data = img.get_data();
|
PoolVector<uint8_t> data = img.get_data();
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
const uint8_t *ptr=r.ptr();;
|
const uint8_t *ptr=r.ptr();;
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
|
|
||||||
|
@ -2487,9 +2487,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V
|
||||||
case Variant::RAW_ARRAY: {
|
case Variant::RAW_ARRAY: {
|
||||||
|
|
||||||
String s;
|
String s;
|
||||||
DVector<uint8_t> data = p_property;
|
PoolVector<uint8_t> data = p_property;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
const uint8_t *ptr=r.ptr();;
|
const uint8_t *ptr=r.ptr();;
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
|
|
||||||
|
@ -2504,9 +2504,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V
|
||||||
} break;
|
} break;
|
||||||
case Variant::INT_ARRAY: {
|
case Variant::INT_ARRAY: {
|
||||||
|
|
||||||
DVector<int> data = p_property;
|
PoolVector<int> data = p_property;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<int>::Read r = data.read();
|
PoolVector<int>::Read r = data.read();
|
||||||
const int *ptr=r.ptr();;
|
const int *ptr=r.ptr();;
|
||||||
write_tabs();
|
write_tabs();
|
||||||
|
|
||||||
|
@ -2523,9 +2523,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V
|
||||||
} break;
|
} break;
|
||||||
case Variant::REAL_ARRAY: {
|
case Variant::REAL_ARRAY: {
|
||||||
|
|
||||||
DVector<real_t> data = p_property;
|
PoolVector<real_t> data = p_property;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<real_t>::Read r = data.read();
|
PoolVector<real_t>::Read r = data.read();
|
||||||
const real_t *ptr=r.ptr();;
|
const real_t *ptr=r.ptr();;
|
||||||
write_tabs();
|
write_tabs();
|
||||||
String cm=", " ;
|
String cm=", " ;
|
||||||
|
@ -2541,9 +2541,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V
|
||||||
} break;
|
} break;
|
||||||
case Variant::STRING_ARRAY: {
|
case Variant::STRING_ARRAY: {
|
||||||
|
|
||||||
DVector<String> data = p_property;
|
PoolVector<String> data = p_property;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<String>::Read r = data.read();
|
PoolVector<String>::Read r = data.read();
|
||||||
const String *ptr=r.ptr();;
|
const String *ptr=r.ptr();;
|
||||||
String s;
|
String s;
|
||||||
//write_string("\n");
|
//write_string("\n");
|
||||||
|
@ -2560,9 +2560,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V
|
||||||
} break;
|
} break;
|
||||||
case Variant::VECTOR2_ARRAY: {
|
case Variant::VECTOR2_ARRAY: {
|
||||||
|
|
||||||
DVector<Vector2> data = p_property;
|
PoolVector<Vector2> data = p_property;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<Vector2>::Read r = data.read();
|
PoolVector<Vector2>::Read r = data.read();
|
||||||
const Vector2 *ptr=r.ptr();;
|
const Vector2 *ptr=r.ptr();;
|
||||||
write_tabs();
|
write_tabs();
|
||||||
|
|
||||||
|
@ -2579,9 +2579,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V
|
||||||
} break;
|
} break;
|
||||||
case Variant::VECTOR3_ARRAY: {
|
case Variant::VECTOR3_ARRAY: {
|
||||||
|
|
||||||
DVector<Vector3> data = p_property;
|
PoolVector<Vector3> data = p_property;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<Vector3>::Read r = data.read();
|
PoolVector<Vector3>::Read r = data.read();
|
||||||
const Vector3 *ptr=r.ptr();;
|
const Vector3 *ptr=r.ptr();;
|
||||||
write_tabs();
|
write_tabs();
|
||||||
|
|
||||||
|
@ -2599,9 +2599,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V
|
||||||
} break;
|
} break;
|
||||||
case Variant::COLOR_ARRAY: {
|
case Variant::COLOR_ARRAY: {
|
||||||
|
|
||||||
DVector<Color> data = p_property;
|
PoolVector<Color> data = p_property;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<Color>::Read r = data.read();
|
PoolVector<Color>::Read r = data.read();
|
||||||
const Color *ptr=r.ptr();;
|
const Color *ptr=r.ptr();;
|
||||||
write_tabs();
|
write_tabs();
|
||||||
|
|
||||||
|
|
|
@ -29,16 +29,16 @@
|
||||||
#include "stream_peer.h"
|
#include "stream_peer.h"
|
||||||
#include "io/marshalls.h"
|
#include "io/marshalls.h"
|
||||||
|
|
||||||
Error StreamPeer::_put_data(const DVector<uint8_t>& p_data) {
|
Error StreamPeer::_put_data(const PoolVector<uint8_t>& p_data) {
|
||||||
|
|
||||||
int len = p_data.size();
|
int len = p_data.size();
|
||||||
if (len==0)
|
if (len==0)
|
||||||
return OK;
|
return OK;
|
||||||
DVector<uint8_t>::Read r = p_data.read();
|
PoolVector<uint8_t>::Read r = p_data.read();
|
||||||
return put_data(&r[0],len);
|
return put_data(&r[0],len);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array StreamPeer::_put_partial_data(const DVector<uint8_t>& p_data) {
|
Array StreamPeer::_put_partial_data(const PoolVector<uint8_t>& p_data) {
|
||||||
|
|
||||||
Array ret;
|
Array ret;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ Array StreamPeer::_put_partial_data(const DVector<uint8_t>& p_data) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = p_data.read();
|
PoolVector<uint8_t>::Read r = p_data.read();
|
||||||
int sent;
|
int sent;
|
||||||
Error err = put_partial_data(&r[0],len,sent);
|
Error err = put_partial_data(&r[0],len,sent);
|
||||||
|
|
||||||
|
@ -66,18 +66,18 @@ Array StreamPeer::_get_data(int p_bytes) {
|
||||||
|
|
||||||
Array ret;
|
Array ret;
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
data.resize(p_bytes);
|
data.resize(p_bytes);
|
||||||
if (data.size()!=p_bytes) {
|
if (data.size()!=p_bytes) {
|
||||||
|
|
||||||
ret.push_back(ERR_OUT_OF_MEMORY);
|
ret.push_back(ERR_OUT_OF_MEMORY);
|
||||||
ret.push_back(DVector<uint8_t>());
|
ret.push_back(PoolVector<uint8_t>());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = data.write();
|
PoolVector<uint8_t>::Write w = data.write();
|
||||||
Error err = get_data(&w[0],p_bytes);
|
Error err = get_data(&w[0],p_bytes);
|
||||||
w = DVector<uint8_t>::Write();
|
w = PoolVector<uint8_t>::Write();
|
||||||
ret.push_back(err);
|
ret.push_back(err);
|
||||||
ret.push_back(data);
|
ret.push_back(data);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -88,19 +88,19 @@ Array StreamPeer::_get_partial_data(int p_bytes) {
|
||||||
|
|
||||||
Array ret;
|
Array ret;
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
data.resize(p_bytes);
|
data.resize(p_bytes);
|
||||||
if (data.size()!=p_bytes) {
|
if (data.size()!=p_bytes) {
|
||||||
|
|
||||||
ret.push_back(ERR_OUT_OF_MEMORY);
|
ret.push_back(ERR_OUT_OF_MEMORY);
|
||||||
ret.push_back(DVector<uint8_t>());
|
ret.push_back(PoolVector<uint8_t>());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = data.write();
|
PoolVector<uint8_t>::Write w = data.write();
|
||||||
int received;
|
int received;
|
||||||
Error err = get_partial_data(&w[0],p_bytes,received);
|
Error err = get_partial_data(&w[0],p_bytes,received);
|
||||||
w = DVector<uint8_t>::Write();
|
w = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
if (err!=OK) {
|
if (err!=OK) {
|
||||||
data.resize(0);
|
data.resize(0);
|
||||||
|
@ -454,7 +454,7 @@ Error StreamPeerBuffer::put_data(const uint8_t* p_data,int p_bytes) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = data.write();
|
PoolVector<uint8_t>::Write w = data.write();
|
||||||
copymem(&w[pointer],p_data,p_bytes);
|
copymem(&w[pointer],p_data,p_bytes);
|
||||||
|
|
||||||
pointer+=p_bytes;
|
pointer+=p_bytes;
|
||||||
|
@ -490,7 +490,7 @@ Error StreamPeerBuffer::get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_r
|
||||||
r_received=p_bytes;
|
r_received=p_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
copymem(p_buffer,r.ptr(),r_received);
|
copymem(p_buffer,r.ptr(),r_received);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,13 +520,13 @@ void StreamPeerBuffer::resize(int p_size){
|
||||||
data.resize(p_size);
|
data.resize(p_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamPeerBuffer::set_data_array(const DVector<uint8_t> & p_data){
|
void StreamPeerBuffer::set_data_array(const PoolVector<uint8_t> & p_data){
|
||||||
|
|
||||||
data=p_data;
|
data=p_data;
|
||||||
pointer=0;
|
pointer=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t> StreamPeerBuffer::get_data_array() const{
|
PoolVector<uint8_t> StreamPeerBuffer::get_data_array() const{
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
//bind helpers
|
//bind helpers
|
||||||
Error _put_data(const DVector<uint8_t>& p_data);
|
Error _put_data(const PoolVector<uint8_t>& p_data);
|
||||||
Array _put_partial_data(const DVector<uint8_t>& p_data);
|
Array _put_partial_data(const PoolVector<uint8_t>& p_data);
|
||||||
|
|
||||||
Array _get_data(int p_bytes);
|
Array _get_data(int p_bytes);
|
||||||
Array _get_partial_data(int p_bytes);
|
Array _get_partial_data(int p_bytes);
|
||||||
|
@ -96,7 +96,7 @@ class StreamPeerBuffer : public StreamPeer {
|
||||||
|
|
||||||
GDCLASS(StreamPeerBuffer,StreamPeer);
|
GDCLASS(StreamPeerBuffer,StreamPeer);
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
int pointer;
|
int pointer;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -116,8 +116,8 @@ public:
|
||||||
void resize(int p_size);
|
void resize(int p_size);
|
||||||
|
|
||||||
|
|
||||||
void set_data_array(const DVector<uint8_t> & p_data);
|
void set_data_array(const PoolVector<uint8_t> & p_data);
|
||||||
DVector<uint8_t> get_data_array() const;
|
PoolVector<uint8_t> get_data_array() const;
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ TCP_Server* TCP_Server::create() {
|
||||||
return _create();
|
return _create();
|
||||||
}
|
}
|
||||||
|
|
||||||
Error TCP_Server::_listen(uint16_t p_port, DVector<String> p_accepted_hosts) {
|
Error TCP_Server::_listen(uint16_t p_port, PoolVector<String> p_accepted_hosts) {
|
||||||
|
|
||||||
List<String> hosts;
|
List<String> hosts;
|
||||||
for(int i=0;i<p_accepted_hosts.size();i++)
|
for(int i=0;i<p_accepted_hosts.size();i++)
|
||||||
|
@ -62,7 +62,7 @@ void TCP_Server::set_ip_type(IP::Type p_type) {
|
||||||
void TCP_Server::_bind_methods() {
|
void TCP_Server::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method(_MD("set_ip_type","ip_type"),&TCP_Server::set_ip_type);
|
ClassDB::bind_method(_MD("set_ip_type","ip_type"),&TCP_Server::set_ip_type);
|
||||||
ClassDB::bind_method(_MD("listen","port","accepted_hosts"),&TCP_Server::_listen,DEFVAL(DVector<String>()));
|
ClassDB::bind_method(_MD("listen","port","accepted_hosts"),&TCP_Server::_listen,DEFVAL(PoolVector<String>()));
|
||||||
ClassDB::bind_method(_MD("is_connection_available"),&TCP_Server::is_connection_available);
|
ClassDB::bind_method(_MD("is_connection_available"),&TCP_Server::is_connection_available);
|
||||||
ClassDB::bind_method(_MD("take_connection"),&TCP_Server::take_connection);
|
ClassDB::bind_method(_MD("take_connection"),&TCP_Server::take_connection);
|
||||||
ClassDB::bind_method(_MD("stop"),&TCP_Server::stop);
|
ClassDB::bind_method(_MD("stop"),&TCP_Server::stop);
|
||||||
|
|
|
@ -43,7 +43,7 @@ protected:
|
||||||
static TCP_Server* (*_create)();
|
static TCP_Server* (*_create)();
|
||||||
|
|
||||||
//bind helper
|
//bind helper
|
||||||
Error _listen(uint16_t p_port, DVector<String> p_accepted_hosts=DVector<String>());
|
Error _listen(uint16_t p_port, PoolVector<String> p_accepted_hosts=PoolVector<String>());
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -295,10 +295,10 @@ bool AStar::_solve(Point* begin_point, Point* end_point) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
|
PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!points.has(p_from_id),DVector<Vector3>());
|
ERR_FAIL_COND_V(!points.has(p_from_id),PoolVector<Vector3>());
|
||||||
ERR_FAIL_COND_V(!points.has(p_to_id),DVector<Vector3>());
|
ERR_FAIL_COND_V(!points.has(p_to_id),PoolVector<Vector3>());
|
||||||
|
|
||||||
|
|
||||||
pass++;
|
pass++;
|
||||||
|
@ -307,7 +307,7 @@ DVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
|
||||||
Point* b = points[p_to_id];
|
Point* b = points[p_to_id];
|
||||||
|
|
||||||
if (a==b) {
|
if (a==b) {
|
||||||
DVector<Vector3> ret;
|
PoolVector<Vector3> ret;
|
||||||
ret.push_back(a->pos);
|
ret.push_back(a->pos);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ DVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
|
||||||
bool found_route=_solve(begin_point,end_point);
|
bool found_route=_solve(begin_point,end_point);
|
||||||
|
|
||||||
if (!found_route)
|
if (!found_route)
|
||||||
return DVector<Vector3>();
|
return PoolVector<Vector3>();
|
||||||
|
|
||||||
//midpoints
|
//midpoints
|
||||||
Point *p=end_point;
|
Point *p=end_point;
|
||||||
|
@ -329,11 +329,11 @@ DVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
|
||||||
p=p->prev_point;
|
p=p->prev_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<Vector3> path;
|
PoolVector<Vector3> path;
|
||||||
path.resize(pc);
|
path.resize(pc);
|
||||||
|
|
||||||
{
|
{
|
||||||
DVector<Vector3>::Write w = path.write();
|
PoolVector<Vector3>::Write w = path.write();
|
||||||
|
|
||||||
Point *p=end_point;
|
Point *p=end_point;
|
||||||
int idx=pc-1;
|
int idx=pc-1;
|
||||||
|
@ -351,10 +351,10 @@ DVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
|
PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!points.has(p_from_id),DVector<int>());
|
ERR_FAIL_COND_V(!points.has(p_from_id),PoolVector<int>());
|
||||||
ERR_FAIL_COND_V(!points.has(p_to_id),DVector<int>());
|
ERR_FAIL_COND_V(!points.has(p_to_id),PoolVector<int>());
|
||||||
|
|
||||||
|
|
||||||
pass++;
|
pass++;
|
||||||
|
@ -363,7 +363,7 @@ DVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
|
||||||
Point* b = points[p_to_id];
|
Point* b = points[p_to_id];
|
||||||
|
|
||||||
if (a==b) {
|
if (a==b) {
|
||||||
DVector<int> ret;
|
PoolVector<int> ret;
|
||||||
ret.push_back(a->id);
|
ret.push_back(a->id);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -375,7 +375,7 @@ DVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
|
||||||
bool found_route=_solve(begin_point,end_point);
|
bool found_route=_solve(begin_point,end_point);
|
||||||
|
|
||||||
if (!found_route)
|
if (!found_route)
|
||||||
return DVector<int>();
|
return PoolVector<int>();
|
||||||
|
|
||||||
//midpoints
|
//midpoints
|
||||||
Point *p=end_point;
|
Point *p=end_point;
|
||||||
|
@ -385,11 +385,11 @@ DVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
|
||||||
p=p->prev_point;
|
p=p->prev_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<int> path;
|
PoolVector<int> path;
|
||||||
path.resize(pc);
|
path.resize(pc);
|
||||||
|
|
||||||
{
|
{
|
||||||
DVector<int>::Write w = path.write();
|
PoolVector<int>::Write w = path.write();
|
||||||
|
|
||||||
p=end_point;
|
p=end_point;
|
||||||
int idx=pc-1;
|
int idx=pc-1;
|
||||||
|
|
|
@ -113,8 +113,8 @@ public:
|
||||||
int get_closest_point(const Vector3& p_point) const;
|
int get_closest_point(const Vector3& p_point) const;
|
||||||
Vector3 get_closest_pos_in_segment(const Vector3& p_point) const;
|
Vector3 get_closest_pos_in_segment(const Vector3& p_point) const;
|
||||||
|
|
||||||
DVector<Vector3> get_point_path(int p_from_id, int p_to_id);
|
PoolVector<Vector3> get_point_path(int p_from_id, int p_to_id);
|
||||||
DVector<int> get_id_path(int p_from_id, int p_to_id);
|
PoolVector<int> get_id_path(int p_from_id, int p_to_id);
|
||||||
|
|
||||||
AStar();
|
AStar();
|
||||||
~AStar();
|
~AStar();
|
||||||
|
|
|
@ -484,7 +484,7 @@ BSP_Tree::operator Variant() const {
|
||||||
|
|
||||||
d["planes"]=plane_values;
|
d["planes"]=plane_values;
|
||||||
|
|
||||||
DVector<int> dst_nodes;
|
PoolVector<int> dst_nodes;
|
||||||
dst_nodes.resize(nodes.size()*3);
|
dst_nodes.resize(nodes.size()*3);
|
||||||
|
|
||||||
for(int i=0;i<nodes.size();i++) {
|
for(int i=0;i<nodes.size();i++) {
|
||||||
|
@ -514,19 +514,19 @@ BSP_Tree::BSP_Tree(const Variant& p_variant) {
|
||||||
ERR_FAIL_COND(!d.has("aabb"));
|
ERR_FAIL_COND(!d.has("aabb"));
|
||||||
ERR_FAIL_COND(!d.has("error_radius"));
|
ERR_FAIL_COND(!d.has("error_radius"));
|
||||||
|
|
||||||
DVector<int> src_nodes = d["nodes"];
|
PoolVector<int> src_nodes = d["nodes"];
|
||||||
ERR_FAIL_COND(src_nodes.size()%3);
|
ERR_FAIL_COND(src_nodes.size()%3);
|
||||||
|
|
||||||
|
|
||||||
if (d["planes"].get_type()==Variant::REAL_ARRAY) {
|
if (d["planes"].get_type()==Variant::REAL_ARRAY) {
|
||||||
|
|
||||||
DVector<float> src_planes=d["planes"];
|
PoolVector<float> src_planes=d["planes"];
|
||||||
int plane_count=src_planes.size();
|
int plane_count=src_planes.size();
|
||||||
ERR_FAIL_COND(plane_count%4);
|
ERR_FAIL_COND(plane_count%4);
|
||||||
planes.resize(plane_count/4);
|
planes.resize(plane_count/4);
|
||||||
|
|
||||||
if (plane_count) {
|
if (plane_count) {
|
||||||
DVector<float>::Read r = src_planes.read();
|
PoolVector<float>::Read r = src_planes.read();
|
||||||
for(int i=0;i<plane_count/4;i++) {
|
for(int i=0;i<plane_count/4;i++) {
|
||||||
|
|
||||||
planes[i].normal.x=r[i*4+0];
|
planes[i].normal.x=r[i*4+0];
|
||||||
|
@ -549,7 +549,7 @@ BSP_Tree::BSP_Tree(const Variant& p_variant) {
|
||||||
// int node_count = src_nodes.size();
|
// int node_count = src_nodes.size();
|
||||||
nodes.resize(src_nodes.size()/3);
|
nodes.resize(src_nodes.size()/3);
|
||||||
|
|
||||||
DVector<int>::Read r = src_nodes.read();
|
PoolVector<int>::Read r = src_nodes.read();
|
||||||
|
|
||||||
for(int i=0;i<nodes.size();i++) {
|
for(int i=0;i<nodes.size();i++) {
|
||||||
|
|
||||||
|
@ -560,12 +560,12 @@ BSP_Tree::BSP_Tree(const Variant& p_variant) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BSP_Tree::BSP_Tree(const DVector<Face3>& p_faces,float p_error_radius) {
|
BSP_Tree::BSP_Tree(const PoolVector<Face3>& p_faces,float p_error_radius) {
|
||||||
|
|
||||||
// compute aabb
|
// compute aabb
|
||||||
|
|
||||||
int face_count=p_faces.size();
|
int face_count=p_faces.size();
|
||||||
DVector<Face3>::Read faces_r=p_faces.read();
|
PoolVector<Face3>::Read faces_r=p_faces.read();
|
||||||
const Face3 *facesptr = faces_r.ptr();
|
const Face3 *facesptr = faces_r.ptr();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
|
|
||||||
BSP_Tree();
|
BSP_Tree();
|
||||||
BSP_Tree(const Variant& p_variant);
|
BSP_Tree(const Variant& p_variant);
|
||||||
BSP_Tree(const DVector<Face3>& p_faces,float p_error_radius=0);
|
BSP_Tree(const PoolVector<Face3>& p_faces,float p_error_radius=0);
|
||||||
BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB& p_aabb,float p_error_radius=0);
|
BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB& p_aabb,float p_error_radius=0);
|
||||||
~BSP_Tree();
|
~BSP_Tree();
|
||||||
|
|
||||||
|
|
|
@ -204,21 +204,21 @@ static bool _group_face(_FaceClassify *p_faces, int len, int p_index,int p_group
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DVector< DVector< Face3 > > Geometry::separate_objects( DVector< Face3 > p_array ) {
|
PoolVector< PoolVector< Face3 > > Geometry::separate_objects( PoolVector< Face3 > p_array ) {
|
||||||
|
|
||||||
DVector< DVector< Face3 > > objects;
|
PoolVector< PoolVector< Face3 > > objects;
|
||||||
|
|
||||||
int len = p_array.size();
|
int len = p_array.size();
|
||||||
|
|
||||||
DVector<Face3>::Read r=p_array.read();
|
PoolVector<Face3>::Read r=p_array.read();
|
||||||
|
|
||||||
const Face3* arrayptr = r.ptr();
|
const Face3* arrayptr = r.ptr();
|
||||||
|
|
||||||
DVector< _FaceClassify> fc;
|
PoolVector< _FaceClassify> fc;
|
||||||
|
|
||||||
fc.resize( len );
|
fc.resize( len );
|
||||||
|
|
||||||
DVector< _FaceClassify >::Write fcw=fc.write();
|
PoolVector< _FaceClassify >::Write fcw=fc.write();
|
||||||
|
|
||||||
_FaceClassify * _fcptr = fcw.ptr();
|
_FaceClassify * _fcptr = fcw.ptr();
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ DVector< DVector< Face3 > > Geometry::separate_objects( DVector< Face3 > p_array
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
||||||
ERR_FAIL_COND_V(error, DVector< DVector< Face3 > >() ); // invalid geometry
|
ERR_FAIL_COND_V(error, PoolVector< PoolVector< Face3 > >() ); // invalid geometry
|
||||||
}
|
}
|
||||||
|
|
||||||
/* group connected faces in separate objects */
|
/* group connected faces in separate objects */
|
||||||
|
@ -257,8 +257,8 @@ DVector< DVector< Face3 > > Geometry::separate_objects( DVector< Face3 > p_array
|
||||||
if (group>=0) {
|
if (group>=0) {
|
||||||
|
|
||||||
objects.resize(group);
|
objects.resize(group);
|
||||||
DVector< DVector<Face3> >::Write obw=objects.write();
|
PoolVector< PoolVector<Face3> >::Write obw=objects.write();
|
||||||
DVector< Face3 > *group_faces = obw.ptr();
|
PoolVector< Face3 > *group_faces = obw.ptr();
|
||||||
|
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
if (!_fcptr[i].valid)
|
if (!_fcptr[i].valid)
|
||||||
|
@ -487,7 +487,7 @@ static inline void _mark_outside(uint8_t*** p_cell_status,int x,int y,int z,int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,DVector<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,PoolVector<Face3>& p_faces) {
|
||||||
|
|
||||||
ERR_FAIL_INDEX(x,len_x);
|
ERR_FAIL_INDEX(x,len_x);
|
||||||
ERR_FAIL_INDEX(y,len_y);
|
ERR_FAIL_INDEX(y,len_y);
|
||||||
|
@ -580,13 +580,13 @@ static inline void _build_faces(uint8_t*** p_cell_status,int x,int y,int z,int l
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_error ) {
|
PoolVector< Face3 > Geometry::wrap_geometry( PoolVector< Face3 > p_array,float *p_error ) {
|
||||||
|
|
||||||
#define _MIN_SIZE 1.0
|
#define _MIN_SIZE 1.0
|
||||||
#define _MAX_LENGTH 20
|
#define _MAX_LENGTH 20
|
||||||
|
|
||||||
int face_count=p_array.size();
|
int face_count=p_array.size();
|
||||||
DVector<Face3>::Read facesr=p_array.read();
|
PoolVector<Face3>::Read facesr=p_array.read();
|
||||||
const Face3 *faces = facesr.ptr();
|
const Face3 *faces = facesr.ptr();
|
||||||
|
|
||||||
AABB global_aabb;
|
AABB global_aabb;
|
||||||
|
@ -696,7 +696,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
|
||||||
|
|
||||||
//print_line("Wrapper (3/6): Building Faces");
|
//print_line("Wrapper (3/6): Building Faces");
|
||||||
|
|
||||||
DVector<Face3> wrapped_faces;
|
PoolVector<Face3> wrapped_faces;
|
||||||
|
|
||||||
for (int i=0;i<div_x;i++) {
|
for (int i=0;i<div_x;i++) {
|
||||||
|
|
||||||
|
@ -714,7 +714,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
|
||||||
// transform face vertices to global coords
|
// transform face vertices to global coords
|
||||||
|
|
||||||
int wrapped_faces_count=wrapped_faces.size();
|
int wrapped_faces_count=wrapped_faces.size();
|
||||||
DVector<Face3>::Write wrapped_facesw=wrapped_faces.write();
|
PoolVector<Face3>::Write wrapped_facesw=wrapped_faces.write();
|
||||||
Face3* wrapped_faces_ptr=wrapped_facesw.ptr();
|
Face3* wrapped_faces_ptr=wrapped_facesw.ptr();
|
||||||
|
|
||||||
for(int i=0;i<wrapped_faces_count;i++) {
|
for(int i=0;i<wrapped_faces_count;i++) {
|
||||||
|
@ -748,7 +748,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
|
||||||
return wrapped_faces;
|
return wrapped_faces;
|
||||||
}
|
}
|
||||||
|
|
||||||
Geometry::MeshData Geometry::build_convex_mesh(const DVector<Plane> &p_planes) {
|
Geometry::MeshData Geometry::build_convex_mesh(const PoolVector<Plane> &p_planes) {
|
||||||
|
|
||||||
MeshData mesh;
|
MeshData mesh;
|
||||||
|
|
||||||
|
@ -896,9 +896,9 @@ Geometry::MeshData Geometry::build_convex_mesh(const DVector<Plane> &p_planes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DVector<Plane> Geometry::build_box_planes(const Vector3& p_extents) {
|
PoolVector<Plane> Geometry::build_box_planes(const Vector3& p_extents) {
|
||||||
|
|
||||||
DVector<Plane> planes;
|
PoolVector<Plane> planes;
|
||||||
|
|
||||||
planes.push_back( Plane( Vector3(1,0,0), p_extents.x ) );
|
planes.push_back( Plane( Vector3(1,0,0), p_extents.x ) );
|
||||||
planes.push_back( Plane( Vector3(-1,0,0), p_extents.x ) );
|
planes.push_back( Plane( Vector3(-1,0,0), p_extents.x ) );
|
||||||
|
@ -910,9 +910,9 @@ DVector<Plane> Geometry::build_box_planes(const Vector3& p_extents) {
|
||||||
return planes;
|
return planes;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<Plane> Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
|
PoolVector<Plane> Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
|
||||||
|
|
||||||
DVector<Plane> planes;
|
PoolVector<Plane> planes;
|
||||||
|
|
||||||
for (int i=0;i<p_sides;i++) {
|
for (int i=0;i<p_sides;i++) {
|
||||||
|
|
||||||
|
@ -933,10 +933,10 @@ DVector<Plane> Geometry::build_cylinder_planes(float p_radius, float p_height, i
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<Plane> Geometry::build_sphere_planes(float p_radius, int p_lats,int p_lons, Vector3::Axis p_axis) {
|
PoolVector<Plane> Geometry::build_sphere_planes(float p_radius, int p_lats,int p_lons, Vector3::Axis p_axis) {
|
||||||
|
|
||||||
|
|
||||||
DVector<Plane> planes;
|
PoolVector<Plane> planes;
|
||||||
|
|
||||||
Vector3 axis;
|
Vector3 axis;
|
||||||
axis[p_axis]=1.0;
|
axis[p_axis]=1.0;
|
||||||
|
@ -969,9 +969,9 @@ DVector<Plane> Geometry::build_sphere_planes(float p_radius, int p_lats,int p_lo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<Plane> Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
|
PoolVector<Plane> Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
|
||||||
|
|
||||||
DVector<Plane> planes;
|
PoolVector<Plane> planes;
|
||||||
|
|
||||||
Vector3 axis;
|
Vector3 axis;
|
||||||
axis[p_axis]=1.0;
|
axis[p_axis]=1.0;
|
||||||
|
|
|
@ -808,9 +808,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static DVector< DVector< Face3 > > separate_objects( DVector< Face3 > p_array );
|
static PoolVector< PoolVector< Face3 > > separate_objects( PoolVector< Face3 > p_array );
|
||||||
|
|
||||||
static DVector< Face3 > wrap_geometry( DVector< Face3 > p_array, float *p_error=NULL ); ///< create a "wrap" that encloses the given geometry
|
static PoolVector< Face3 > wrap_geometry( PoolVector< Face3 > p_array, float *p_error=NULL ); ///< create a "wrap" that encloses the given geometry
|
||||||
|
|
||||||
|
|
||||||
struct MeshData {
|
struct MeshData {
|
||||||
|
@ -919,11 +919,11 @@ public:
|
||||||
return H;
|
return H;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MeshData build_convex_mesh(const DVector<Plane> &p_planes);
|
static MeshData build_convex_mesh(const PoolVector<Plane> &p_planes);
|
||||||
static DVector<Plane> build_sphere_planes(float p_radius, int p_lats, int p_lons, Vector3::Axis p_axis=Vector3::AXIS_Z);
|
static PoolVector<Plane> build_sphere_planes(float p_radius, int p_lats, int p_lons, Vector3::Axis p_axis=Vector3::AXIS_Z);
|
||||||
static DVector<Plane> build_box_planes(const Vector3& p_extents);
|
static PoolVector<Plane> build_box_planes(const Vector3& p_extents);
|
||||||
static DVector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z);
|
static PoolVector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z);
|
||||||
static DVector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis=Vector3::AXIS_Z);
|
static PoolVector<Plane> build_capsule_planes(float p_radius, float 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);
|
static void make_atlas(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, Size2i& r_size);
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ int TriangleMesh::_create_bvh(BVH*p_bvh,BVH** p_bb,int p_from,int p_size,int p_d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TriangleMesh::create(const DVector<Vector3>& p_faces) {
|
void TriangleMesh::create(const PoolVector<Vector3>& p_faces) {
|
||||||
|
|
||||||
valid=false;
|
valid=false;
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ void TriangleMesh::create(const DVector<Vector3>& p_faces) {
|
||||||
triangles.resize(fc);
|
triangles.resize(fc);
|
||||||
|
|
||||||
bvh.resize(fc*3); //will never be larger than this (todo make better)
|
bvh.resize(fc*3); //will never be larger than this (todo make better)
|
||||||
DVector<BVH>::Write bw = bvh.write();
|
PoolVector<BVH>::Write bw = bvh.write();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -112,8 +112,8 @@ void TriangleMesh::create(const DVector<Vector3>& p_faces) {
|
||||||
//except for the Set for repeated triangles, everything
|
//except for the Set for repeated triangles, everything
|
||||||
//goes in-place.
|
//goes in-place.
|
||||||
|
|
||||||
DVector<Vector3>::Read r = p_faces.read();
|
PoolVector<Vector3>::Read r = p_faces.read();
|
||||||
DVector<Triangle>::Write w = triangles.write();
|
PoolVector<Triangle>::Write w = triangles.write();
|
||||||
Map<Vector3,int> db;
|
Map<Vector3,int> db;
|
||||||
|
|
||||||
for(int i=0;i<fc;i++) {
|
for(int i=0;i<fc;i++) {
|
||||||
|
@ -149,16 +149,16 @@ void TriangleMesh::create(const DVector<Vector3>& p_faces) {
|
||||||
}
|
}
|
||||||
|
|
||||||
vertices.resize(db.size());
|
vertices.resize(db.size());
|
||||||
DVector<Vector3>::Write vw = vertices.write();
|
PoolVector<Vector3>::Write vw = vertices.write();
|
||||||
for (Map<Vector3,int>::Element *E=db.front();E;E=E->next()) {
|
for (Map<Vector3,int>::Element *E=db.front();E;E=E->next()) {
|
||||||
vw[E->get()]=E->key();
|
vw[E->get()]=E->key();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<BVH*> bwptrs;
|
PoolVector<BVH*> bwptrs;
|
||||||
bwptrs.resize(fc);
|
bwptrs.resize(fc);
|
||||||
DVector<BVH*>::Write bwp = bwptrs.write();
|
PoolVector<BVH*>::Write bwp = bwptrs.write();
|
||||||
for(int i=0;i<fc;i++) {
|
for(int i=0;i<fc;i++) {
|
||||||
|
|
||||||
bwp[i]=&bw[i];
|
bwp[i]=&bw[i];
|
||||||
|
@ -168,7 +168,7 @@ void TriangleMesh::create(const DVector<Vector3>& p_faces) {
|
||||||
int max_alloc=fc;
|
int max_alloc=fc;
|
||||||
int max=_create_bvh(bw.ptr(),bwp.ptr(),0,fc,1,max_depth,max_alloc);
|
int max=_create_bvh(bw.ptr(),bwp.ptr(),0,fc,1,max_depth,max_alloc);
|
||||||
|
|
||||||
bw=DVector<BVH>::Write(); //clearup
|
bw=PoolVector<BVH>::Write(); //clearup
|
||||||
bvh.resize(max_alloc); //resize back
|
bvh.resize(max_alloc); //resize back
|
||||||
|
|
||||||
valid=true;
|
valid=true;
|
||||||
|
@ -197,9 +197,9 @@ Vector3 TriangleMesh::get_area_normal(const AABB& p_aabb) const {
|
||||||
|
|
||||||
int level=0;
|
int level=0;
|
||||||
|
|
||||||
DVector<Triangle>::Read trianglesr = triangles.read();
|
PoolVector<Triangle>::Read trianglesr = triangles.read();
|
||||||
DVector<Vector3>::Read verticesr=vertices.read();
|
PoolVector<Vector3>::Read verticesr=vertices.read();
|
||||||
DVector<BVH>::Read bvhr=bvh.read();
|
PoolVector<BVH>::Read bvhr=bvh.read();
|
||||||
|
|
||||||
const Triangle *triangleptr=trianglesr.ptr();
|
const Triangle *triangleptr=trianglesr.ptr();
|
||||||
int pos=bvh.size()-1;
|
int pos=bvh.size()-1;
|
||||||
|
@ -299,9 +299,9 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end
|
||||||
|
|
||||||
int level=0;
|
int level=0;
|
||||||
|
|
||||||
DVector<Triangle>::Read trianglesr = triangles.read();
|
PoolVector<Triangle>::Read trianglesr = triangles.read();
|
||||||
DVector<Vector3>::Read verticesr=vertices.read();
|
PoolVector<Vector3>::Read verticesr=vertices.read();
|
||||||
DVector<BVH>::Read bvhr=bvh.read();
|
PoolVector<BVH>::Read bvhr=bvh.read();
|
||||||
|
|
||||||
const Triangle *triangleptr=trianglesr.ptr();
|
const Triangle *triangleptr=trianglesr.ptr();
|
||||||
const Vector3 *vertexptr=verticesr.ptr();
|
const Vector3 *vertexptr=verticesr.ptr();
|
||||||
|
@ -422,9 +422,9 @@ bool TriangleMesh::intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vec
|
||||||
|
|
||||||
int level=0;
|
int level=0;
|
||||||
|
|
||||||
DVector<Triangle>::Read trianglesr = triangles.read();
|
PoolVector<Triangle>::Read trianglesr = triangles.read();
|
||||||
DVector<Vector3>::Read verticesr=vertices.read();
|
PoolVector<Vector3>::Read verticesr=vertices.read();
|
||||||
DVector<BVH>::Read bvhr=bvh.read();
|
PoolVector<BVH>::Read bvhr=bvh.read();
|
||||||
|
|
||||||
const Triangle *triangleptr=trianglesr.ptr();
|
const Triangle *triangleptr=trianglesr.ptr();
|
||||||
const Vector3 *vertexptr=verticesr.ptr();
|
const Vector3 *vertexptr=verticesr.ptr();
|
||||||
|
@ -524,18 +524,18 @@ bool TriangleMesh::is_valid() const {
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<Face3> TriangleMesh::get_faces() const {
|
PoolVector<Face3> TriangleMesh::get_faces() const {
|
||||||
|
|
||||||
if (!valid)
|
if (!valid)
|
||||||
return DVector<Face3>();
|
return PoolVector<Face3>();
|
||||||
|
|
||||||
DVector<Face3> faces;
|
PoolVector<Face3> faces;
|
||||||
int ts = triangles.size();
|
int ts = triangles.size();
|
||||||
faces.resize(triangles.size());
|
faces.resize(triangles.size());
|
||||||
|
|
||||||
DVector<Face3>::Write w=faces.write();
|
PoolVector<Face3>::Write w=faces.write();
|
||||||
DVector<Triangle>::Read r = triangles.read();
|
PoolVector<Triangle>::Read r = triangles.read();
|
||||||
DVector<Vector3>::Read rv = vertices.read();
|
PoolVector<Vector3>::Read rv = vertices.read();
|
||||||
|
|
||||||
for(int i=0;i<ts;i++) {
|
for(int i=0;i<ts;i++) {
|
||||||
for(int j=0;j<3;j++) {
|
for(int j=0;j<3;j++) {
|
||||||
|
@ -543,7 +543,7 @@ DVector<Face3> TriangleMesh::get_faces() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w = DVector<Face3>::Write();
|
w = PoolVector<Face3>::Write();
|
||||||
return faces;
|
return faces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ class TriangleMesh : public Reference {
|
||||||
int indices[3];
|
int indices[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
DVector<Triangle> triangles;
|
PoolVector<Triangle> triangles;
|
||||||
DVector<Vector3> vertices;
|
PoolVector<Vector3> vertices;
|
||||||
|
|
||||||
struct BVH {
|
struct BVH {
|
||||||
|
|
||||||
|
@ -79,7 +79,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);
|
int _create_bvh(BVH*p_bvh,BVH** p_bb,int p_from,int p_size,int p_depth,int&max_depth,int&max_alloc);
|
||||||
|
|
||||||
DVector<BVH> bvh;
|
PoolVector<BVH> bvh;
|
||||||
int max_depth;
|
int max_depth;
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
||||||
|
@ -89,10 +89,10 @@ public:
|
||||||
bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_point, Vector3 &r_normal) const;
|
bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_point, Vector3 &r_normal) const;
|
||||||
bool intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vector3 &r_point, Vector3 &r_normal) const;
|
bool intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vector3 &r_point, Vector3 &r_normal) const;
|
||||||
Vector3 get_area_normal(const AABB& p_aabb) const;
|
Vector3 get_area_normal(const AABB& p_aabb) const;
|
||||||
DVector<Face3> get_faces() const;
|
PoolVector<Face3> get_faces() const;
|
||||||
|
|
||||||
|
|
||||||
void create(const DVector<Vector3>& p_faces);
|
void create(const PoolVector<Vector3>& p_faces);
|
||||||
TriangleMesh();
|
TriangleMesh();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -133,12 +133,12 @@ struct PtrToArg< const T* > {
|
||||||
template<>\
|
template<>\
|
||||||
struct PtrToArg<Vector<m_type> > {\
|
struct PtrToArg<Vector<m_type> > {\
|
||||||
_FORCE_INLINE_ static Vector<m_type> convert(const void* p_ptr) {\
|
_FORCE_INLINE_ static Vector<m_type> convert(const void* p_ptr) {\
|
||||||
const DVector<m_type> *dvs = reinterpret_cast<const DVector<m_type> *>(p_ptr);\
|
const PoolVector<m_type> *dvs = reinterpret_cast<const PoolVector<m_type> *>(p_ptr);\
|
||||||
Vector<m_type> ret;\
|
Vector<m_type> ret;\
|
||||||
int len = dvs->size();\
|
int len = dvs->size();\
|
||||||
ret.resize(len);\
|
ret.resize(len);\
|
||||||
{\
|
{\
|
||||||
DVector<m_type>::Read r=dvs->read();\
|
PoolVector<m_type>::Read r=dvs->read();\
|
||||||
for(int i=0;i<len;i++) {\
|
for(int i=0;i<len;i++) {\
|
||||||
ret[i]=r[i];\
|
ret[i]=r[i];\
|
||||||
}\
|
}\
|
||||||
|
@ -146,11 +146,11 @@ struct PtrToArg<Vector<m_type> > {\
|
||||||
return ret;\
|
return ret;\
|
||||||
}\
|
}\
|
||||||
_FORCE_INLINE_ static void encode(Vector<m_type> p_vec, void* p_ptr) {\
|
_FORCE_INLINE_ static void encode(Vector<m_type> p_vec, void* p_ptr) {\
|
||||||
DVector<m_type> *dv = reinterpret_cast<DVector<m_type> *>(p_ptr);\
|
PoolVector<m_type> *dv = reinterpret_cast<PoolVector<m_type> *>(p_ptr);\
|
||||||
int len=p_vec.size();\
|
int len=p_vec.size();\
|
||||||
dv->resize(len);\
|
dv->resize(len);\
|
||||||
{\
|
{\
|
||||||
DVector<m_type>::Write w=dv->write();\
|
PoolVector<m_type>::Write w=dv->write();\
|
||||||
for(int i=0;i<len;i++) {\
|
for(int i=0;i<len;i++) {\
|
||||||
w[i]=p_vec[i];\
|
w[i]=p_vec[i];\
|
||||||
}\
|
}\
|
||||||
|
@ -160,12 +160,12 @@ struct PtrToArg<Vector<m_type> > {\
|
||||||
template<>\
|
template<>\
|
||||||
struct PtrToArg<const Vector<m_type>& > {\
|
struct PtrToArg<const Vector<m_type>& > {\
|
||||||
_FORCE_INLINE_ static Vector<m_type> convert(const void* p_ptr) {\
|
_FORCE_INLINE_ static Vector<m_type> convert(const void* p_ptr) {\
|
||||||
const DVector<m_type> *dvs = reinterpret_cast<const DVector<m_type> *>(p_ptr);\
|
const PoolVector<m_type> *dvs = reinterpret_cast<const PoolVector<m_type> *>(p_ptr);\
|
||||||
Vector<m_type> ret;\
|
Vector<m_type> ret;\
|
||||||
int len = dvs->size();\
|
int len = dvs->size();\
|
||||||
ret.resize(len);\
|
ret.resize(len);\
|
||||||
{\
|
{\
|
||||||
DVector<m_type>::Read r=dvs->read();\
|
PoolVector<m_type>::Read r=dvs->read();\
|
||||||
for(int i=0;i<len;i++) {\
|
for(int i=0;i<len;i++) {\
|
||||||
ret[i]=r[i];\
|
ret[i]=r[i];\
|
||||||
}\
|
}\
|
||||||
|
@ -226,26 +226,26 @@ MAKE_VECARR(Plane);
|
||||||
|
|
||||||
#define MAKE_DVECARR(m_type) \
|
#define MAKE_DVECARR(m_type) \
|
||||||
template<>\
|
template<>\
|
||||||
struct PtrToArg<DVector<m_type> > {\
|
struct PtrToArg<PoolVector<m_type> > {\
|
||||||
_FORCE_INLINE_ static DVector<m_type> convert(const void* p_ptr) {\
|
_FORCE_INLINE_ static PoolVector<m_type> convert(const void* p_ptr) {\
|
||||||
const Array *arr = reinterpret_cast<const Array *>(p_ptr);\
|
const Array *arr = reinterpret_cast<const Array *>(p_ptr);\
|
||||||
DVector<m_type> ret;\
|
PoolVector<m_type> ret;\
|
||||||
int len = arr->size();\
|
int len = arr->size();\
|
||||||
ret.resize(len);\
|
ret.resize(len);\
|
||||||
{\
|
{\
|
||||||
DVector<m_type>::Write w=ret.write();\
|
PoolVector<m_type>::Write w=ret.write();\
|
||||||
for(int i=0;i<len;i++) {\
|
for(int i=0;i<len;i++) {\
|
||||||
w[i]=(*arr)[i];\
|
w[i]=(*arr)[i];\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
return ret;\
|
return ret;\
|
||||||
}\
|
}\
|
||||||
_FORCE_INLINE_ static void encode(DVector<m_type> p_vec, void* p_ptr) {\
|
_FORCE_INLINE_ static void encode(PoolVector<m_type> p_vec, void* p_ptr) {\
|
||||||
Array *arr = reinterpret_cast<Array *>(p_ptr);\
|
Array *arr = reinterpret_cast<Array *>(p_ptr);\
|
||||||
int len = p_vec.size();\
|
int len = p_vec.size();\
|
||||||
arr->resize(len);\
|
arr->resize(len);\
|
||||||
{\
|
{\
|
||||||
DVector<m_type>::Read r=p_vec.read();\
|
PoolVector<m_type>::Read r=p_vec.read();\
|
||||||
for(int i=0;i<len;i++) {\
|
for(int i=0;i<len;i++) {\
|
||||||
(*arr)[i]=r[i];\
|
(*arr)[i]=r[i];\
|
||||||
}\
|
}\
|
||||||
|
@ -253,14 +253,14 @@ struct PtrToArg<DVector<m_type> > {\
|
||||||
} \
|
} \
|
||||||
};\
|
};\
|
||||||
template<>\
|
template<>\
|
||||||
struct PtrToArg<const DVector<m_type>& > {\
|
struct PtrToArg<const PoolVector<m_type>& > {\
|
||||||
_FORCE_INLINE_ static DVector<m_type> convert(const void* p_ptr) {\
|
_FORCE_INLINE_ static PoolVector<m_type> convert(const void* p_ptr) {\
|
||||||
const Array *arr = reinterpret_cast<const Array *>(p_ptr);\
|
const Array *arr = reinterpret_cast<const Array *>(p_ptr);\
|
||||||
DVector<m_type> ret;\
|
PoolVector<m_type> ret;\
|
||||||
int len = arr->size();\
|
int len = arr->size();\
|
||||||
ret.resize(len);\
|
ret.resize(len);\
|
||||||
{\
|
{\
|
||||||
DVector<m_type>::Write w=ret.write();\
|
PoolVector<m_type>::Write w=ret.write();\
|
||||||
for(int i=0;i<len;i++) {\
|
for(int i=0;i<len;i++) {\
|
||||||
w[i]=(*arr)[i];\
|
w[i]=(*arr)[i];\
|
||||||
}\
|
}\
|
||||||
|
@ -297,15 +297,15 @@ MAKE_STRINGCONV(StringName);
|
||||||
MAKE_STRINGCONV(IP_Address);
|
MAKE_STRINGCONV(IP_Address);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct PtrToArg<DVector<Face3> > {
|
struct PtrToArg<PoolVector<Face3> > {
|
||||||
_FORCE_INLINE_ static DVector<Face3> convert(const void* p_ptr) {
|
_FORCE_INLINE_ static PoolVector<Face3> convert(const void* p_ptr) {
|
||||||
const DVector<Vector3> *dvs = reinterpret_cast<const DVector<Vector3> *>(p_ptr);
|
const PoolVector<Vector3> *dvs = reinterpret_cast<const PoolVector<Vector3> *>(p_ptr);
|
||||||
DVector<Face3> ret;
|
PoolVector<Face3> ret;
|
||||||
int len = dvs->size()/3;
|
int len = dvs->size()/3;
|
||||||
ret.resize(len);
|
ret.resize(len);
|
||||||
{
|
{
|
||||||
DVector<Vector3>::Read r=dvs->read();
|
PoolVector<Vector3>::Read r=dvs->read();
|
||||||
DVector<Face3>::Write w=ret.write();
|
PoolVector<Face3>::Write w=ret.write();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
w[i].vertex[0]=r[i*3+0];
|
w[i].vertex[0]=r[i*3+0];
|
||||||
w[i].vertex[1]=r[i*3+1];
|
w[i].vertex[1]=r[i*3+1];
|
||||||
|
@ -314,13 +314,13 @@ struct PtrToArg<DVector<Face3> > {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
_FORCE_INLINE_ static void encode(DVector<Face3> p_vec, void* p_ptr) {\
|
_FORCE_INLINE_ static void encode(PoolVector<Face3> p_vec, void* p_ptr) {\
|
||||||
DVector<Vector3> *arr = reinterpret_cast<DVector<Vector3> *>(p_ptr);\
|
PoolVector<Vector3> *arr = reinterpret_cast<PoolVector<Vector3> *>(p_ptr);\
|
||||||
int len = p_vec.size();\
|
int len = p_vec.size();\
|
||||||
arr->resize(len*3);\
|
arr->resize(len*3);\
|
||||||
{\
|
{\
|
||||||
DVector<Face3>::Read r=p_vec.read();\
|
PoolVector<Face3>::Read r=p_vec.read();\
|
||||||
DVector<Vector3>::Write w=arr->write();\
|
PoolVector<Vector3>::Write w=arr->write();\
|
||||||
for(int i=0;i<len;i++) {\
|
for(int i=0;i<len;i++) {\
|
||||||
w[i*3+0]=r[i].vertex[0];\
|
w[i*3+0]=r[i].vertex[0];\
|
||||||
w[i*3+1]=r[i].vertex[1];\
|
w[i*3+1]=r[i].vertex[1];\
|
||||||
|
@ -330,15 +330,15 @@ struct PtrToArg<DVector<Face3> > {
|
||||||
} \
|
} \
|
||||||
};
|
};
|
||||||
template<>
|
template<>
|
||||||
struct PtrToArg<const DVector<Face3>& > {
|
struct PtrToArg<const PoolVector<Face3>& > {
|
||||||
_FORCE_INLINE_ static DVector<Face3> convert(const void* p_ptr) {
|
_FORCE_INLINE_ static PoolVector<Face3> convert(const void* p_ptr) {
|
||||||
const DVector<Vector3> *dvs = reinterpret_cast<const DVector<Vector3> *>(p_ptr);
|
const PoolVector<Vector3> *dvs = reinterpret_cast<const PoolVector<Vector3> *>(p_ptr);
|
||||||
DVector<Face3> ret;
|
PoolVector<Face3> ret;
|
||||||
int len = dvs->size()/3;
|
int len = dvs->size()/3;
|
||||||
ret.resize(len);
|
ret.resize(len);
|
||||||
{
|
{
|
||||||
DVector<Vector3>::Read r=dvs->read();
|
PoolVector<Vector3>::Read r=dvs->read();
|
||||||
DVector<Face3>::Write w=ret.write();
|
PoolVector<Face3>::Write w=ret.write();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
w[i].vertex[0]=r[i*3+0];
|
w[i].vertex[0]=r[i*3+0];
|
||||||
w[i].vertex[1]=r[i*3+1];
|
w[i].vertex[1]=r[i*3+1];
|
||||||
|
|
|
@ -1112,9 +1112,9 @@ Array Object::_get_method_list_bind() const {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<String> Object::_get_meta_list_bind() const {
|
PoolVector<String> Object::_get_meta_list_bind() const {
|
||||||
|
|
||||||
DVector<String> _metaret;
|
PoolVector<String> _metaret;
|
||||||
|
|
||||||
List<Variant> keys;
|
List<Variant> keys;
|
||||||
metadata.get_key_list(&keys);
|
metadata.get_key_list(&keys);
|
||||||
|
@ -1942,27 +1942,37 @@ uint32_t ObjectDB::instance_counter=1;
|
||||||
HashMap<Object*,ObjectID,ObjectDB::ObjectPtrHash> ObjectDB::instance_checks;
|
HashMap<Object*,ObjectID,ObjectDB::ObjectPtrHash> ObjectDB::instance_checks;
|
||||||
uint32_t ObjectDB::add_instance(Object *p_object) {
|
uint32_t ObjectDB::add_instance(Object *p_object) {
|
||||||
|
|
||||||
GLOBAL_LOCK_FUNCTION;
|
|
||||||
ERR_FAIL_COND_V( p_object->get_instance_ID()!=0, 0 );
|
ERR_FAIL_COND_V( p_object->get_instance_ID()!=0, 0 );
|
||||||
|
|
||||||
|
rw_lock->write_lock();
|
||||||
instances[++instance_counter]=p_object;
|
instances[++instance_counter]=p_object;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
instance_checks[p_object]=instance_counter;
|
instance_checks[p_object]=instance_counter;
|
||||||
#endif
|
#endif
|
||||||
|
rw_lock->write_unlock();
|
||||||
|
|
||||||
return instance_counter;
|
return instance_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectDB::remove_instance(Object *p_object) {
|
void ObjectDB::remove_instance(Object *p_object) {
|
||||||
|
|
||||||
GLOBAL_LOCK_FUNCTION;
|
|
||||||
|
rw_lock->write_lock();
|
||||||
|
|
||||||
instances.erase( p_object->get_instance_ID() );
|
instances.erase( p_object->get_instance_ID() );
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
instance_checks.erase(p_object);
|
instance_checks.erase(p_object);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
rw_lock->write_unlock();
|
||||||
}
|
}
|
||||||
Object *ObjectDB::get_instance(uint32_t p_instance_ID) {
|
Object *ObjectDB::get_instance(uint32_t p_instance_ID) {
|
||||||
|
|
||||||
GLOBAL_LOCK_FUNCTION;
|
rw_lock->read_lock();
|
||||||
Object**obj=instances.getptr(p_instance_ID);
|
Object**obj=instances.getptr(p_instance_ID);
|
||||||
|
rw_lock->read_unlock();
|
||||||
|
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return NULL;
|
return NULL;
|
||||||
return *obj;
|
return *obj;
|
||||||
|
@ -1970,13 +1980,16 @@ Object *ObjectDB::get_instance(uint32_t p_instance_ID) {
|
||||||
|
|
||||||
void ObjectDB::debug_objects(DebugFunc p_func) {
|
void ObjectDB::debug_objects(DebugFunc p_func) {
|
||||||
|
|
||||||
GLOBAL_LOCK_FUNCTION;
|
rw_lock->read_lock();
|
||||||
|
|
||||||
const uint32_t *K=NULL;
|
const uint32_t *K=NULL;
|
||||||
while((K=instances.next(K))) {
|
while((K=instances.next(K))) {
|
||||||
|
|
||||||
p_func(instances[*K]);
|
p_func(instances[*K]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rw_lock->read_unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1987,15 +2000,26 @@ void Object::get_argument_options(const StringName& p_function,int p_idx,List<St
|
||||||
|
|
||||||
int ObjectDB::get_object_count() {
|
int ObjectDB::get_object_count() {
|
||||||
|
|
||||||
GLOBAL_LOCK_FUNCTION;
|
rw_lock->read_lock();
|
||||||
return instances.size();
|
int count =instances.size();
|
||||||
|
rw_lock->read_unlock();
|
||||||
|
|
||||||
|
return count;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
RWLock *ObjectDB::rw_lock=NULL;
|
||||||
|
|
||||||
|
|
||||||
|
void ObjectDB::setup() {
|
||||||
|
|
||||||
|
rw_lock = RWLock::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectDB::cleanup() {
|
void ObjectDB::cleanup() {
|
||||||
|
|
||||||
|
|
||||||
GLOBAL_LOCK_FUNCTION;
|
rw_lock->write_lock();
|
||||||
if (instances.size()) {
|
if (instances.size()) {
|
||||||
|
|
||||||
WARN_PRINT("ObjectDB Instances still exist!");
|
WARN_PRINT("ObjectDB Instances still exist!");
|
||||||
|
@ -2014,4 +2038,7 @@ void ObjectDB::cleanup() {
|
||||||
}
|
}
|
||||||
instances.clear();
|
instances.clear();
|
||||||
instance_checks.clear();
|
instance_checks.clear();
|
||||||
|
rw_lock->write_unlock();
|
||||||
|
|
||||||
|
memdelete(rw_lock);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "set.h"
|
#include "set.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "vmap.h"
|
#include "vmap.h"
|
||||||
|
#include "os/rw_lock.h"
|
||||||
|
|
||||||
#define VARIANT_ARG_LIST const Variant& p_arg1=Variant(),const Variant& p_arg2=Variant(),const Variant& p_arg3=Variant(),const Variant& p_arg4=Variant(),const Variant& p_arg5=Variant()
|
#define VARIANT_ARG_LIST const Variant& p_arg1=Variant(),const Variant& p_arg2=Variant(),const Variant& p_arg3=Variant(),const Variant& p_arg4=Variant(),const Variant& p_arg5=Variant()
|
||||||
#define VARIANT_ARG_PASS p_arg1,p_arg2,p_arg3,p_arg4,p_arg5
|
#define VARIANT_ARG_PASS p_arg1,p_arg2,p_arg3,p_arg4,p_arg5
|
||||||
|
@ -481,7 +482,7 @@ protected:
|
||||||
return &_class_name;
|
return &_class_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<String> _get_meta_list_bind() const;
|
PoolVector<String> _get_meta_list_bind() const;
|
||||||
Array _get_property_list_bind() const;
|
Array _get_property_list_bind() const;
|
||||||
Array _get_method_list_bind() const;
|
Array _get_method_list_bind() const;
|
||||||
|
|
||||||
|
@ -686,9 +687,14 @@ class ObjectDB {
|
||||||
friend class Object;
|
friend class Object;
|
||||||
friend void unregister_core_types();
|
friend void unregister_core_types();
|
||||||
|
|
||||||
|
|
||||||
|
static RWLock *rw_lock;
|
||||||
static void cleanup();
|
static void cleanup();
|
||||||
static uint32_t add_instance(Object *p_object);
|
static uint32_t add_instance(Object *p_object);
|
||||||
static void remove_instance(Object *p_object);
|
static void remove_instance(Object *p_object);
|
||||||
|
friend void register_core_types();
|
||||||
|
static void setup();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef void (*DebugFunc)(Object *p_obj);
|
typedef void (*DebugFunc)(Object *p_obj);
|
||||||
|
|
|
@ -31,11 +31,12 @@
|
||||||
|
|
||||||
#ifdef NO_THREADS
|
#ifdef NO_THREADS
|
||||||
|
|
||||||
#define OBJTYPE_LOCK
|
#define OBJTYPE_RLOCK
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define OBJTYPE_LOCK MutexLock _mutex_lock_(lock);
|
#define OBJTYPE_RLOCK RWLockRead _rw_lockr_(lock);
|
||||||
|
#define OBJTYPE_WLOCK RWLockWrite _rw_lockw_(lock);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -215,7 +216,7 @@ ClassDB::ClassInfo::~ClassInfo() {
|
||||||
|
|
||||||
bool ClassDB::is_parent_class(const StringName &p_class,const StringName& p_inherits) {
|
bool ClassDB::is_parent_class(const StringName &p_class,const StringName& p_inherits) {
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
StringName inherits=p_class;
|
StringName inherits=p_class;
|
||||||
|
|
||||||
|
@ -230,7 +231,7 @@ bool ClassDB::is_parent_class(const StringName &p_class,const StringName& p_inhe
|
||||||
}
|
}
|
||||||
void ClassDB::get_class_list( List<StringName> *p_classes) {
|
void ClassDB::get_class_list( List<StringName> *p_classes) {
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
const StringName *k=NULL;
|
const StringName *k=NULL;
|
||||||
|
|
||||||
|
@ -245,7 +246,7 @@ void ClassDB::get_class_list( List<StringName> *p_classes) {
|
||||||
|
|
||||||
void ClassDB::get_inheriters_from_class( const StringName& p_class,List<StringName> *p_classes) {
|
void ClassDB::get_inheriters_from_class( const StringName& p_class,List<StringName> *p_classes) {
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
const StringName *k=NULL;
|
const StringName *k=NULL;
|
||||||
|
|
||||||
|
@ -259,7 +260,7 @@ void ClassDB::get_inheriters_from_class( const StringName& p_class,List<StringNa
|
||||||
|
|
||||||
StringName ClassDB::get_parent_class(const StringName& p_class) {
|
StringName ClassDB::get_parent_class(const StringName& p_class) {
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
ClassInfo *ti = classes.getptr(p_class);
|
ClassInfo *ti = classes.getptr(p_class);
|
||||||
ERR_FAIL_COND_V(!ti,"");
|
ERR_FAIL_COND_V(!ti,"");
|
||||||
|
@ -268,7 +269,7 @@ StringName ClassDB::get_parent_class(const StringName& p_class) {
|
||||||
|
|
||||||
ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) {
|
ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) {
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
ClassInfo *ti = classes.getptr(p_class);
|
ClassInfo *ti = classes.getptr(p_class);
|
||||||
ERR_FAIL_COND_V(!ti,API_NONE);
|
ERR_FAIL_COND_V(!ti,API_NONE);
|
||||||
|
@ -277,6 +278,7 @@ ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) {
|
||||||
|
|
||||||
uint64_t ClassDB::get_api_hash(APIType p_api) {
|
uint64_t ClassDB::get_api_hash(APIType p_api) {
|
||||||
|
|
||||||
|
OBJTYPE_RLOCK;
|
||||||
#ifdef DEBUG_METHODS_ENABLED
|
#ifdef DEBUG_METHODS_ENABLED
|
||||||
|
|
||||||
uint64_t hash = hash_djb2_one_64(HashMapHahserDefault::hash(VERSION_FULL_NAME));
|
uint64_t hash = hash_djb2_one_64(HashMapHahserDefault::hash(VERSION_FULL_NAME));
|
||||||
|
@ -433,12 +435,13 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
|
||||||
|
|
||||||
bool ClassDB::class_exists(const StringName &p_class) {
|
bool ClassDB::class_exists(const StringName &p_class) {
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_RLOCK;
|
||||||
return classes.has(p_class);
|
return classes.has(p_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassDB::add_compatibility_class(const StringName& p_class,const StringName& p_fallback) {
|
void ClassDB::add_compatibility_class(const StringName& p_class,const StringName& p_fallback) {
|
||||||
|
|
||||||
|
OBJTYPE_WLOCK;
|
||||||
compat_classes[p_class]=p_fallback;
|
compat_classes[p_class]=p_fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +449,7 @@ Object *ClassDB::instance(const StringName &p_class) {
|
||||||
|
|
||||||
ClassInfo *ti;
|
ClassInfo *ti;
|
||||||
{
|
{
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_RLOCK;
|
||||||
ti=classes.getptr(p_class);
|
ti=classes.getptr(p_class);
|
||||||
if (!ti || ti->disabled || !ti->creation_func) {
|
if (!ti || ti->disabled || !ti->creation_func) {
|
||||||
if (compat_classes.has(p_class)) {
|
if (compat_classes.has(p_class)) {
|
||||||
|
@ -462,7 +465,7 @@ Object *ClassDB::instance(const StringName &p_class) {
|
||||||
}
|
}
|
||||||
bool ClassDB::can_instance(const StringName &p_class) {
|
bool ClassDB::can_instance(const StringName &p_class) {
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
ClassInfo *ti = classes.getptr(p_class);
|
ClassInfo *ti = classes.getptr(p_class);
|
||||||
ERR_FAIL_COND_V(!ti,false);
|
ERR_FAIL_COND_V(!ti,false);
|
||||||
|
@ -472,7 +475,7 @@ bool ClassDB::can_instance(const StringName &p_class) {
|
||||||
|
|
||||||
void ClassDB::_add_class2(const StringName& p_class, const StringName& p_inherits) {
|
void ClassDB::_add_class2(const StringName& p_class, const StringName& p_inherits) {
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_WLOCK;
|
||||||
|
|
||||||
StringName name = p_class;
|
StringName name = p_class;
|
||||||
|
|
||||||
|
@ -499,7 +502,7 @@ void ClassDB::_add_class2(const StringName& p_class, const StringName& p_inherit
|
||||||
void ClassDB::get_method_list(StringName p_class,List<MethodInfo> *p_methods,bool p_no_inheritance) {
|
void ClassDB::get_method_list(StringName p_class,List<MethodInfo> *p_methods,bool p_no_inheritance) {
|
||||||
|
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
|
|
||||||
|
@ -572,7 +575,7 @@ void ClassDB::get_method_list(StringName p_class,List<MethodInfo> *p_methods,boo
|
||||||
|
|
||||||
MethodBind *ClassDB::get_method(StringName p_class, StringName p_name) {
|
MethodBind *ClassDB::get_method(StringName p_class, StringName p_name) {
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
|
|
||||||
|
@ -589,7 +592,7 @@ MethodBind *ClassDB::get_method(StringName p_class, StringName p_name) {
|
||||||
|
|
||||||
void ClassDB::bind_integer_constant(const StringName& p_class, const StringName &p_name, int p_constant) {
|
void ClassDB::bind_integer_constant(const StringName& p_class, const StringName &p_name, int p_constant) {
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_WLOCK;
|
||||||
|
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
if (!type) {
|
if (!type) {
|
||||||
|
@ -611,7 +614,7 @@ void ClassDB::bind_integer_constant(const StringName& p_class, const StringName
|
||||||
|
|
||||||
void ClassDB::get_integer_constant_list(const StringName& p_class, List<String> *p_constants, bool p_no_inheritance) {
|
void ClassDB::get_integer_constant_list(const StringName& p_class, List<String> *p_constants, bool p_no_inheritance) {
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
|
|
||||||
|
@ -639,7 +642,7 @@ void ClassDB::get_integer_constant_list(const StringName& p_class, List<String>
|
||||||
|
|
||||||
int ClassDB::get_integer_constant(const StringName& p_class, const StringName &p_name, bool *p_success) {
|
int ClassDB::get_integer_constant(const StringName& p_class, const StringName &p_name, bool *p_success) {
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
|
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
|
@ -666,6 +669,8 @@ int ClassDB::get_integer_constant(const StringName& p_class, const StringName &p
|
||||||
|
|
||||||
void ClassDB::add_signal(StringName p_class,const MethodInfo& p_signal) {
|
void ClassDB::add_signal(StringName p_class,const MethodInfo& p_signal) {
|
||||||
|
|
||||||
|
OBJTYPE_WLOCK;
|
||||||
|
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
ERR_FAIL_COND(!type);
|
ERR_FAIL_COND(!type);
|
||||||
|
|
||||||
|
@ -688,6 +693,8 @@ void ClassDB::add_signal(StringName p_class,const MethodInfo& p_signal) {
|
||||||
|
|
||||||
void ClassDB::get_signal_list(StringName p_class,List<MethodInfo> *p_signals,bool p_no_inheritance) {
|
void ClassDB::get_signal_list(StringName p_class,List<MethodInfo> *p_signals,bool p_no_inheritance) {
|
||||||
|
|
||||||
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
ERR_FAIL_COND(!type);
|
ERR_FAIL_COND(!type);
|
||||||
|
|
||||||
|
@ -712,6 +719,7 @@ void ClassDB::get_signal_list(StringName p_class,List<MethodInfo> *p_signals,boo
|
||||||
|
|
||||||
bool ClassDB::has_signal(StringName p_class,StringName p_signal) {
|
bool ClassDB::has_signal(StringName p_class,StringName p_signal) {
|
||||||
|
|
||||||
|
OBJTYPE_RLOCK;
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
ClassInfo *check=type;
|
ClassInfo *check=type;
|
||||||
while(check) {
|
while(check) {
|
||||||
|
@ -725,6 +733,7 @@ bool ClassDB::has_signal(StringName p_class,StringName p_signal) {
|
||||||
|
|
||||||
bool ClassDB::get_signal(StringName p_class,StringName p_signal,MethodInfo *r_signal) {
|
bool ClassDB::get_signal(StringName p_class,StringName p_signal,MethodInfo *r_signal) {
|
||||||
|
|
||||||
|
OBJTYPE_RLOCK;
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
ClassInfo *check=type;
|
ClassInfo *check=type;
|
||||||
while(check) {
|
while(check) {
|
||||||
|
@ -743,6 +752,7 @@ bool ClassDB::get_signal(StringName p_class,StringName p_signal,MethodInfo *r_si
|
||||||
|
|
||||||
void ClassDB::add_property_group(StringName p_class,const String& p_name,const String& p_prefix) {
|
void ClassDB::add_property_group(StringName p_class,const String& p_name,const String& p_prefix) {
|
||||||
|
|
||||||
|
OBJTYPE_WLOCK;
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
ERR_FAIL_COND(!type);
|
ERR_FAIL_COND(!type);
|
||||||
|
|
||||||
|
@ -752,7 +762,13 @@ void ClassDB::add_property_group(StringName p_class,const String& p_name,const S
|
||||||
void ClassDB::add_property(StringName p_class,const PropertyInfo& p_pinfo, const StringName& p_setter, const StringName& p_getter, int p_index) {
|
void ClassDB::add_property(StringName p_class,const PropertyInfo& p_pinfo, const StringName& p_setter, const StringName& p_getter, int p_index) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
lock->read_lock();
|
||||||
|
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
|
|
||||||
|
lock->read_unlock();
|
||||||
|
|
||||||
ERR_FAIL_COND(!type);
|
ERR_FAIL_COND(!type);
|
||||||
|
|
||||||
MethodBind *mb_set=NULL;
|
MethodBind *mb_set=NULL;
|
||||||
|
@ -804,6 +820,9 @@ void ClassDB::add_property(StringName p_class,const PropertyInfo& p_pinfo, const
|
||||||
ERR_FAIL();
|
ERR_FAIL();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
OBJTYPE_WLOCK
|
||||||
|
|
||||||
type->property_list.push_back(p_pinfo);
|
type->property_list.push_back(p_pinfo);
|
||||||
|
|
||||||
PropertySetGet psg;
|
PropertySetGet psg;
|
||||||
|
@ -821,6 +840,8 @@ void ClassDB::add_property(StringName p_class,const PropertyInfo& p_pinfo, const
|
||||||
|
|
||||||
void ClassDB::get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance,const Object *p_validator) {
|
void ClassDB::get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance,const Object *p_validator) {
|
||||||
|
|
||||||
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
ClassInfo *check=type;
|
ClassInfo *check=type;
|
||||||
while(check) {
|
while(check) {
|
||||||
|
@ -846,6 +867,7 @@ void ClassDB::get_property_list(StringName p_class, List<PropertyInfo> *p_list,
|
||||||
bool ClassDB::set_property(Object* p_object,const StringName& p_property, const Variant& p_value,bool *r_valid) {
|
bool ClassDB::set_property(Object* p_object,const StringName& p_property, const Variant& p_value,bool *r_valid) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ClassInfo *type=classes.getptr(p_object->get_class_name());
|
ClassInfo *type=classes.getptr(p_object->get_class_name());
|
||||||
ClassInfo *check=type;
|
ClassInfo *check=type;
|
||||||
while(check) {
|
while(check) {
|
||||||
|
@ -1010,6 +1032,7 @@ bool ClassDB::has_property(const StringName& p_class, const StringName& p_proper
|
||||||
|
|
||||||
void ClassDB::set_method_flags(StringName p_class,StringName p_method,int p_flags) {
|
void ClassDB::set_method_flags(StringName p_class,StringName p_method,int p_flags) {
|
||||||
|
|
||||||
|
OBJTYPE_WLOCK;
|
||||||
ClassInfo *type=classes.getptr(p_class);
|
ClassInfo *type=classes.getptr(p_class);
|
||||||
ClassInfo *check=type;
|
ClassInfo *check=type;
|
||||||
ERR_FAIL_COND(!check);
|
ERR_FAIL_COND(!check);
|
||||||
|
@ -1070,7 +1093,7 @@ MethodBind* ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind , const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OBJTYPE_LOCK;
|
OBJTYPE_WLOCK;
|
||||||
ERR_FAIL_COND_V(!p_bind,NULL);
|
ERR_FAIL_COND_V(!p_bind,NULL);
|
||||||
p_bind->set_name(mdname);
|
p_bind->set_name(mdname);
|
||||||
|
|
||||||
|
@ -1114,6 +1137,8 @@ MethodBind* ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind , const
|
||||||
void ClassDB::add_virtual_method(const StringName& p_class, const MethodInfo& p_method , bool p_virtual) {
|
void ClassDB::add_virtual_method(const StringName& p_class, const MethodInfo& p_method , bool p_virtual) {
|
||||||
ERR_FAIL_COND(!classes.has(p_class));
|
ERR_FAIL_COND(!classes.has(p_class));
|
||||||
|
|
||||||
|
OBJTYPE_WLOCK;
|
||||||
|
|
||||||
#ifdef DEBUG_METHODS_ENABLED
|
#ifdef DEBUG_METHODS_ENABLED
|
||||||
MethodInfo mi=p_method;
|
MethodInfo mi=p_method;
|
||||||
if (p_virtual)
|
if (p_virtual)
|
||||||
|
@ -1149,12 +1174,16 @@ void ClassDB::get_virtual_methods(const StringName& p_class, List<MethodInfo> *
|
||||||
|
|
||||||
void ClassDB::set_class_enabled(StringName p_class,bool p_enable) {
|
void ClassDB::set_class_enabled(StringName p_class,bool p_enable) {
|
||||||
|
|
||||||
|
OBJTYPE_WLOCK;
|
||||||
|
|
||||||
ERR_FAIL_COND(!classes.has(p_class));
|
ERR_FAIL_COND(!classes.has(p_class));
|
||||||
classes[p_class].disabled=!p_enable;
|
classes[p_class].disabled=!p_enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClassDB::is_class_enabled(StringName p_class) {
|
bool ClassDB::is_class_enabled(StringName p_class) {
|
||||||
|
|
||||||
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
ClassInfo *ti=classes.getptr(p_class);
|
ClassInfo *ti=classes.getptr(p_class);
|
||||||
if (!ti || !ti->creation_func) {
|
if (!ti || !ti->creation_func) {
|
||||||
if (compat_classes.has(p_class)) {
|
if (compat_classes.has(p_class)) {
|
||||||
|
@ -1206,23 +1235,19 @@ void ClassDB::get_extensions_for_type(const StringName& p_class,List<String> *p_
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Mutex *ClassDB::lock=NULL;
|
RWLock *ClassDB::lock=NULL;
|
||||||
|
|
||||||
void ClassDB::init() {
|
void ClassDB::init() {
|
||||||
|
|
||||||
#ifndef NO_THREADS
|
#ifndef NO_THREADS
|
||||||
|
|
||||||
lock = Mutex::create();
|
lock = RWLock::create();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassDB::cleanup() {
|
void ClassDB::cleanup() {
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_THREADS
|
|
||||||
|
|
||||||
memdelete(lock);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//OBJTYPE_LOCK; hah not here
|
//OBJTYPE_LOCK; hah not here
|
||||||
|
|
||||||
|
@ -1241,6 +1266,12 @@ void ClassDB::cleanup() {
|
||||||
classes.clear();
|
classes.clear();
|
||||||
resource_base_extensions.clear();
|
resource_base_extensions.clear();
|
||||||
compat_classes.clear();
|
compat_classes.clear();
|
||||||
|
|
||||||
|
#ifndef NO_THREADS
|
||||||
|
|
||||||
|
memdelete(lock);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -156,7 +156,7 @@ public:
|
||||||
return memnew( T );
|
return memnew( T );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Mutex *lock;
|
static RWLock *lock;
|
||||||
static HashMap<StringName,ClassInfo,StringNameHasher> classes;
|
static HashMap<StringName,ClassInfo,StringNameHasher> classes;
|
||||||
static HashMap<StringName,StringName,StringNameHasher> resource_base_extensions;
|
static HashMap<StringName,StringName,StringNameHasher> resource_base_extensions;
|
||||||
static HashMap<StringName,StringName,StringNameHasher> compat_classes;
|
static HashMap<StringName,StringName,StringNameHasher> compat_classes;
|
||||||
|
|
|
@ -33,61 +33,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
MID::MID(MemoryPoolDynamic::ID p_id) {
|
|
||||||
|
|
||||||
data = (Data*)memalloc(sizeof(Data));
|
|
||||||
data->refcount.init();
|
|
||||||
data->id=p_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MID::unref() {
|
|
||||||
|
|
||||||
if (!data)
|
|
||||||
return;
|
|
||||||
if (data->refcount.unref()) {
|
|
||||||
|
|
||||||
if (data->id!=MemoryPoolDynamic::INVALID_ID)
|
|
||||||
MemoryPoolDynamic::get_singleton()->free(data->id);
|
|
||||||
memfree(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
data=NULL;
|
|
||||||
}
|
|
||||||
Error MID::_resize(size_t p_size) {
|
|
||||||
|
|
||||||
if (p_size==0 && (!data || data->id==MemoryPoolDynamic::INVALID_ID))
|
|
||||||
return OK;
|
|
||||||
if (p_size && !data) {
|
|
||||||
// create data because we'll need it
|
|
||||||
data = (Data*)memalloc(sizeof(Data));
|
|
||||||
ERR_FAIL_COND_V( !data,ERR_OUT_OF_MEMORY );
|
|
||||||
data->refcount.init();
|
|
||||||
data->id=MemoryPoolDynamic::INVALID_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_size==0 && data && data->id==MemoryPoolDynamic::INVALID_ID) {
|
|
||||||
|
|
||||||
MemoryPoolDynamic::get_singleton()->free(data->id);
|
|
||||||
data->id=MemoryPoolDynamic::INVALID_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_size>0) {
|
|
||||||
|
|
||||||
if (data->id==MemoryPoolDynamic::INVALID_ID) {
|
|
||||||
|
|
||||||
data->id=MemoryPoolDynamic::get_singleton()->alloc(p_size,"Unnamed MID");
|
|
||||||
ERR_FAIL_COND_V( data->id==MemoryPoolDynamic::INVALID_ID, ERR_OUT_OF_MEMORY );
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
MemoryPoolDynamic::get_singleton()->realloc(data->id,p_size);
|
|
||||||
ERR_FAIL_COND_V( data->id==MemoryPoolDynamic::INVALID_ID, ERR_OUT_OF_MEMORY );
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void * operator new(size_t p_size,const char *p_description) {
|
void * operator new(size_t p_size,const char *p_description) {
|
||||||
|
|
||||||
|
@ -242,34 +187,6 @@ size_t Memory::get_mem_max_usage(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MID Memory::alloc_dynamic(size_t p_bytes, const char *p_descr) {
|
|
||||||
|
|
||||||
MemoryPoolDynamic::ID id = MemoryPoolDynamic::get_singleton()->alloc(p_bytes,p_descr);
|
|
||||||
|
|
||||||
return MID(id);
|
|
||||||
}
|
|
||||||
Error Memory::realloc_dynamic(MID p_mid,size_t p_bytes) {
|
|
||||||
|
|
||||||
MemoryPoolDynamic::ID id = p_mid.data?p_mid.data->id:MemoryPoolDynamic::INVALID_ID;
|
|
||||||
|
|
||||||
if (id==MemoryPoolDynamic::INVALID_ID)
|
|
||||||
return ERR_INVALID_PARAMETER;
|
|
||||||
|
|
||||||
return MemoryPoolDynamic::get_singleton()->realloc(p_mid, p_bytes);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t Memory::get_dynamic_mem_available() {
|
|
||||||
|
|
||||||
return MemoryPoolDynamic::get_singleton()->get_available_mem();
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t Memory::get_dynamic_mem_usage() {
|
|
||||||
|
|
||||||
return MemoryPoolDynamic::get_singleton()->get_total_usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_GlobalNil::_GlobalNil() {
|
_GlobalNil::_GlobalNil() {
|
||||||
|
|
104
core/os/memory.h
104
core/os/memory.h
|
@ -31,8 +31,6 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "safe_refcount.h"
|
#include "safe_refcount.h"
|
||||||
#include "os/memory_pool_dynamic.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,88 +42,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class MID {
|
|
||||||
|
|
||||||
struct Data {
|
|
||||||
|
|
||||||
SafeRefCount refcount;
|
|
||||||
MemoryPoolDynamic::ID id;
|
|
||||||
};
|
|
||||||
|
|
||||||
mutable Data *data;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ref(Data *p_data) {
|
|
||||||
|
|
||||||
if (data==p_data)
|
|
||||||
return;
|
|
||||||
unref();
|
|
||||||
|
|
||||||
if (p_data && p_data->refcount.ref())
|
|
||||||
data=p_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend class MID_Lock;
|
|
||||||
|
|
||||||
inline void lock() {
|
|
||||||
|
|
||||||
if (data && data->id!=MemoryPoolDynamic::INVALID_ID)
|
|
||||||
MemoryPoolDynamic::get_singleton()->lock(data->id);
|
|
||||||
}
|
|
||||||
inline void unlock() {
|
|
||||||
|
|
||||||
if (data && data->id!=MemoryPoolDynamic::INVALID_ID)
|
|
||||||
MemoryPoolDynamic::get_singleton()->unlock(data->id);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void * get() {
|
|
||||||
|
|
||||||
if (data && data->id!=MemoryPoolDynamic::INVALID_ID)
|
|
||||||
return MemoryPoolDynamic::get_singleton()->get(data->id);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void unref();
|
|
||||||
Error _resize(size_t p_size);
|
|
||||||
|
|
||||||
friend class Memory;
|
|
||||||
|
|
||||||
MID(MemoryPoolDynamic::ID p_id);
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool is_valid() const { return data; }
|
|
||||||
operator bool() const { return data; }
|
|
||||||
|
|
||||||
|
|
||||||
size_t get_size() const { return (data && data->id!=MemoryPoolDynamic::INVALID_ID) ? MemoryPoolDynamic::get_singleton()->get_size(data->id) : 0; }
|
|
||||||
Error resize(size_t p_size) { return _resize(p_size); }
|
|
||||||
inline void operator=(const MID& p_mid) { ref( p_mid.data ); }
|
|
||||||
inline bool is_locked() const { return (data && data->id!=MemoryPoolDynamic::INVALID_ID) ? MemoryPoolDynamic::get_singleton()->is_locked(data->id) : false; }
|
|
||||||
inline MID(const MID& p_mid) { data=NULL; ref( p_mid.data ); }
|
|
||||||
inline MID() { data = NULL; }
|
|
||||||
~MID() { unref(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class MID_Lock {
|
|
||||||
|
|
||||||
MID mid;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void *data() { return mid.get(); }
|
|
||||||
|
|
||||||
void operator=(const MID_Lock& p_lock ) { mid.unlock(); mid = p_lock.mid; mid.lock(); }
|
|
||||||
inline MID_Lock(const MID& p_mid) { mid=p_mid; mid.lock(); }
|
|
||||||
inline MID_Lock(const MID_Lock& p_lock) { mid=p_lock.mid; mid.lock(); }
|
|
||||||
MID_Lock() {}
|
|
||||||
~MID_Lock() { mid.unlock(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Memory{
|
class Memory{
|
||||||
|
|
||||||
|
@ -148,12 +64,6 @@ public:
|
||||||
static size_t get_mem_max_usage();
|
static size_t get_mem_max_usage();
|
||||||
|
|
||||||
|
|
||||||
static MID alloc_dynamic(size_t p_bytes, const char *p_descr="");
|
|
||||||
static Error realloc_dynamic(MID p_mid,size_t p_bytes);
|
|
||||||
|
|
||||||
static size_t get_dynamic_mem_available();
|
|
||||||
static size_t get_dynamic_mem_usage();
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DefaultAllocator {
|
class DefaultAllocator {
|
||||||
|
@ -174,18 +84,6 @@ void * operator new(size_t p_size,void *p_pointer,size_t check, const char *p_de
|
||||||
#define memfree(m_size) Memory::free_static(m_size)
|
#define memfree(m_size) Memory::free_static(m_size)
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG_MEMORY_ENABLED
|
|
||||||
#define dynalloc(m_size) Memory::alloc_dynamic(m_size, __FILE__ ":" __STR(__LINE__) ", type: DYNAMIC")
|
|
||||||
#define dynrealloc(m_mem,m_size) m_mem.resize(m_size)
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define dynalloc(m_size) Memory::alloc_dynamic(m_size)
|
|
||||||
#define dynrealloc(m_mem,m_size) m_mem.resize(m_size)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
_ALWAYS_INLINE_ void postinitialize_handler(void *) {}
|
_ALWAYS_INLINE_ void postinitialize_handler(void *) {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -241,7 +139,7 @@ T* memnew_arr_template(size_t p_elements,const char *p_descr="") {
|
||||||
if (p_elements==0)
|
if (p_elements==0)
|
||||||
return 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
|
/** 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 DVector class, so it should be safe.*/
|
same strategy used by std::vector, and the PoolVector class, so it should be safe.*/
|
||||||
|
|
||||||
size_t len = sizeof(T) * p_elements;
|
size_t len = sizeof(T) * p_elements;
|
||||||
uint64_t *mem = (uint64_t*)Memory::alloc_static( len , true );
|
uint64_t *mem = (uint64_t*)Memory::alloc_static( len , true );
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*************************************************************************/
|
|
||||||
/* memory_pool_dynamic.cpp */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* http://www.godotengine.org */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* */
|
|
||||||
/* 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 "memory_pool_dynamic.h"
|
|
||||||
|
|
||||||
|
|
||||||
MemoryPoolDynamic* MemoryPoolDynamic::singleton=NULL;
|
|
||||||
|
|
||||||
|
|
||||||
MemoryPoolDynamic* MemoryPoolDynamic::get_singleton() {
|
|
||||||
|
|
||||||
return singleton;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MemoryPoolDynamic::MemoryPoolDynamic() {
|
|
||||||
|
|
||||||
ERR_FAIL_COND(singleton!=NULL);
|
|
||||||
singleton=this;
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryPoolDynamic::~MemoryPoolDynamic() {
|
|
||||||
|
|
||||||
singleton=NULL;
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
/*************************************************************************/
|
|
||||||
/* memory_pool_dynamic.h */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* http://www.godotengine.org */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* */
|
|
||||||
/* 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 MEMORY_POOL_DYNAMIC_H
|
|
||||||
#define MEMORY_POOL_DYNAMIC_H
|
|
||||||
|
|
||||||
#include "typedefs.h"
|
|
||||||
|
|
||||||
|
|
||||||
class MemoryPoolDynamic {
|
|
||||||
|
|
||||||
static MemoryPoolDynamic* singleton;
|
|
||||||
protected:
|
|
||||||
friend class Memory;
|
|
||||||
friend class MID;
|
|
||||||
|
|
||||||
enum {
|
|
||||||
|
|
||||||
INVALID_ID=0xFFFFFFFF
|
|
||||||
};
|
|
||||||
|
|
||||||
static MemoryPoolDynamic* get_singleton();
|
|
||||||
|
|
||||||
typedef uint64_t ID;
|
|
||||||
|
|
||||||
|
|
||||||
virtual ID alloc(size_t p_amount,const char* p_description)=0;
|
|
||||||
virtual void free(ID p_id)=0;
|
|
||||||
virtual Error realloc(ID p_id, size_t p_amount)=0;
|
|
||||||
virtual bool is_valid(ID p_id)=0;
|
|
||||||
virtual size_t get_size(ID p_id) const=0;
|
|
||||||
virtual const char* get_description(ID p_id) const=0;
|
|
||||||
|
|
||||||
virtual Error lock(ID p_id)=0;
|
|
||||||
virtual void * get(ID p_ID)=0;
|
|
||||||
virtual Error unlock(ID p_id)=0;
|
|
||||||
virtual bool is_locked(ID p_id) const=0;
|
|
||||||
|
|
||||||
virtual size_t get_available_mem() const=0;
|
|
||||||
virtual size_t get_total_usage() const=0;
|
|
||||||
|
|
||||||
MemoryPoolDynamic();
|
|
||||||
public:
|
|
||||||
virtual ~MemoryPoolDynamic();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,116 +0,0 @@
|
||||||
/*************************************************************************/
|
|
||||||
/* memory_pool_dynamic_prealloc.cpp */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* http://www.godotengine.org */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* */
|
|
||||||
/* 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 "memory_pool_dynamic_prealloc.h"
|
|
||||||
#include "os/memory.h"
|
|
||||||
|
|
||||||
#include "print_string.h"
|
|
||||||
MemoryPoolDynamicPrealloc::ID MemoryPoolDynamicPrealloc::alloc(size_t p_amount,const char* p_description) {
|
|
||||||
|
|
||||||
|
|
||||||
// print_line("dynpool - allocating: "+itos(p_amount));
|
|
||||||
ID id = pool_alloc->alloc(p_amount);
|
|
||||||
// print_line("dynpool - free: "+itos(pool_alloc->get_free_mem()));
|
|
||||||
return id;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void MemoryPoolDynamicPrealloc::free(ID p_id) {
|
|
||||||
|
|
||||||
pool_alloc->free(p_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
Error MemoryPoolDynamicPrealloc::realloc(ID p_id, size_t p_amount) {
|
|
||||||
|
|
||||||
return pool_alloc->resize(p_id,p_amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MemoryPoolDynamicPrealloc::is_valid(ID p_id) {
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t MemoryPoolDynamicPrealloc::get_size(ID p_id) const {
|
|
||||||
|
|
||||||
return pool_alloc->get_size(p_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* MemoryPoolDynamicPrealloc::get_description(ID p_id) const {
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
Error MemoryPoolDynamicPrealloc::lock(ID p_id) {
|
|
||||||
|
|
||||||
// print_line("lock: "+itos(p_id));
|
|
||||||
return pool_alloc->lock(p_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void * MemoryPoolDynamicPrealloc::get(ID p_ID) {
|
|
||||||
|
|
||||||
// print_line("get: "+itos(p_ID));
|
|
||||||
return pool_alloc->get(p_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
Error MemoryPoolDynamicPrealloc::unlock(ID p_id) {
|
|
||||||
|
|
||||||
// print_line("unlock: "+itos(p_id));
|
|
||||||
pool_alloc->unlock(p_id);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MemoryPoolDynamicPrealloc::is_locked(ID p_id) const {
|
|
||||||
|
|
||||||
return pool_alloc->is_locked(p_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
size_t MemoryPoolDynamicPrealloc::get_available_mem() const {
|
|
||||||
|
|
||||||
return pool_alloc->get_free_mem();
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t MemoryPoolDynamicPrealloc::get_total_usage() const {
|
|
||||||
|
|
||||||
return pool_alloc->get_used_mem();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MemoryPoolDynamicPrealloc::MemoryPoolDynamicPrealloc(void * p_mem,int p_size, int p_align, int p_max_entries) {
|
|
||||||
|
|
||||||
pool_alloc = memnew( PoolAllocator(p_mem,p_size,p_align,true,p_max_entries));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryPoolDynamicPrealloc::~MemoryPoolDynamicPrealloc() {
|
|
||||||
|
|
||||||
|
|
||||||
memdelete( pool_alloc );
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
/*************************************************************************/
|
|
||||||
/* memory_pool_dynamic_prealloc.h */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* http://www.godotengine.org */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* */
|
|
||||||
/* 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 MEMORY_POOL_DYNAMIC_PREALLOC_H
|
|
||||||
#define MEMORY_POOL_DYNAMIC_PREALLOC_H
|
|
||||||
|
|
||||||
#include "pool_allocator.h"
|
|
||||||
#include "core/os/memory_pool_dynamic.h"
|
|
||||||
|
|
||||||
class MemoryPoolDynamicPrealloc : public MemoryPoolDynamic {
|
|
||||||
|
|
||||||
PoolAllocator *pool_alloc;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual ID alloc(size_t p_amount,const char* p_description);
|
|
||||||
virtual void free(ID p_id);
|
|
||||||
virtual Error realloc(ID p_id, size_t p_amount);
|
|
||||||
virtual bool is_valid(ID p_id);
|
|
||||||
virtual size_t get_size(ID p_id) const;
|
|
||||||
virtual const char* get_description(ID p_id) const;
|
|
||||||
|
|
||||||
virtual Error lock(ID p_id);
|
|
||||||
virtual void * get(ID p_ID);
|
|
||||||
virtual Error unlock(ID p_id);
|
|
||||||
virtual bool is_locked(ID p_id) const;
|
|
||||||
|
|
||||||
virtual size_t get_available_mem() const;
|
|
||||||
virtual size_t get_total_usage() const;
|
|
||||||
|
|
||||||
MemoryPoolDynamicPrealloc(void * p_mem,int p_size, int p_align = 16, int p_max_entries=PoolAllocator::DEFAULT_MAX_ALLOCS);
|
|
||||||
~MemoryPoolDynamicPrealloc();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MEMORY_POOL_DYNAMIC_PREALLOC_H
|
|
|
@ -1,272 +0,0 @@
|
||||||
/*************************************************************************/
|
|
||||||
/* memory_pool_dynamic_static.cpp */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* http://www.godotengine.org */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* */
|
|
||||||
/* 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 "memory_pool_dynamic_static.h"
|
|
||||||
#include "os/memory.h"
|
|
||||||
#include "os/os.h"
|
|
||||||
#include "ustring.h"
|
|
||||||
#include "print_string.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
MemoryPoolDynamicStatic::Chunk *MemoryPoolDynamicStatic::get_chunk(ID p_id) {
|
|
||||||
|
|
||||||
uint64_t check = p_id/MAX_CHUNKS;
|
|
||||||
uint64_t idx = p_id%MAX_CHUNKS;
|
|
||||||
|
|
||||||
if (!chunk[idx].mem || chunk[idx].check!=check)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return &chunk[idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const MemoryPoolDynamicStatic::Chunk *MemoryPoolDynamicStatic::get_chunk(ID p_id) const {
|
|
||||||
|
|
||||||
uint64_t check = p_id/MAX_CHUNKS;
|
|
||||||
uint64_t idx = p_id%MAX_CHUNKS;
|
|
||||||
|
|
||||||
if (!chunk[idx].mem || chunk[idx].check!=check)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return &chunk[idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryPoolDynamic::ID MemoryPoolDynamicStatic::alloc(size_t p_amount,const char* p_description) {
|
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
|
||||||
|
|
||||||
int idx=-1;
|
|
||||||
|
|
||||||
for (int i=0;i<MAX_CHUNKS;i++) {
|
|
||||||
|
|
||||||
last_alloc++;
|
|
||||||
if (last_alloc>=MAX_CHUNKS)
|
|
||||||
last_alloc=0;
|
|
||||||
|
|
||||||
if ( !chunk[last_alloc].mem ) {
|
|
||||||
|
|
||||||
idx=last_alloc;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (idx==-1) {
|
|
||||||
ERR_EXPLAIN("Out of dynamic Memory IDs");
|
|
||||||
ERR_FAIL_V(INVALID_ID);
|
|
||||||
//return INVALID_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
//chunk[idx].mem = Memory::alloc_static(p_amount,p_description);
|
|
||||||
chunk[idx].mem = memalloc(p_amount);
|
|
||||||
if (!chunk[idx].mem)
|
|
||||||
return INVALID_ID;
|
|
||||||
|
|
||||||
chunk[idx].size=p_amount;
|
|
||||||
chunk[idx].check=++last_check;
|
|
||||||
chunk[idx].descr=p_description;
|
|
||||||
chunk[idx].lock=0;
|
|
||||||
|
|
||||||
total_usage+=p_amount;
|
|
||||||
if (total_usage>max_usage)
|
|
||||||
max_usage=total_usage;
|
|
||||||
|
|
||||||
ID id = chunk[idx].check*MAX_CHUNKS + (uint64_t)idx;
|
|
||||||
|
|
||||||
return id;
|
|
||||||
|
|
||||||
}
|
|
||||||
void MemoryPoolDynamicStatic::free(ID p_id) {
|
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
|
||||||
|
|
||||||
Chunk *c = get_chunk(p_id);
|
|
||||||
ERR_FAIL_COND(!c);
|
|
||||||
|
|
||||||
|
|
||||||
total_usage-=c->size;
|
|
||||||
memfree(c->mem);
|
|
||||||
|
|
||||||
c->mem=0;
|
|
||||||
|
|
||||||
if (c->lock>0) {
|
|
||||||
|
|
||||||
ERR_PRINT("Freed ID Still locked");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Error MemoryPoolDynamicStatic::realloc(ID p_id, size_t p_amount) {
|
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
|
||||||
|
|
||||||
Chunk *c = get_chunk(p_id);
|
|
||||||
ERR_FAIL_COND_V(!c,ERR_INVALID_PARAMETER);
|
|
||||||
ERR_FAIL_COND_V(c->lock > 0 , ERR_LOCKED );
|
|
||||||
|
|
||||||
|
|
||||||
void * new_mem = memrealloc(c->mem,p_amount);
|
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!new_mem,ERR_OUT_OF_MEMORY);
|
|
||||||
total_usage-=c->size;
|
|
||||||
c->mem=new_mem;
|
|
||||||
c->size=p_amount;
|
|
||||||
total_usage+=c->size;
|
|
||||||
if (total_usage>max_usage)
|
|
||||||
max_usage=total_usage;
|
|
||||||
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
bool MemoryPoolDynamicStatic::is_valid(ID p_id) {
|
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
|
||||||
|
|
||||||
Chunk *c = get_chunk(p_id);
|
|
||||||
|
|
||||||
return c!=NULL;
|
|
||||||
|
|
||||||
}
|
|
||||||
size_t MemoryPoolDynamicStatic::get_size(ID p_id) const {
|
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
|
||||||
|
|
||||||
const Chunk *c = get_chunk(p_id);
|
|
||||||
ERR_FAIL_COND_V(!c,0);
|
|
||||||
|
|
||||||
return c->size;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
const char* MemoryPoolDynamicStatic::get_description(ID p_id) const {
|
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
|
||||||
|
|
||||||
const Chunk *c = get_chunk(p_id);
|
|
||||||
ERR_FAIL_COND_V(!c,"");
|
|
||||||
|
|
||||||
return c->descr;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool MemoryPoolDynamicStatic::is_locked(ID p_id) const {
|
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
|
||||||
|
|
||||||
const Chunk *c = get_chunk(p_id);
|
|
||||||
ERR_FAIL_COND_V(!c,false);
|
|
||||||
|
|
||||||
return c->lock>0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Error MemoryPoolDynamicStatic::lock(ID p_id) {
|
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
|
||||||
|
|
||||||
Chunk *c = get_chunk(p_id);
|
|
||||||
ERR_FAIL_COND_V(!c,ERR_INVALID_PARAMETER);
|
|
||||||
|
|
||||||
c->lock++;
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
void * MemoryPoolDynamicStatic::get(ID p_id) {
|
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
|
||||||
|
|
||||||
const Chunk *c = get_chunk(p_id);
|
|
||||||
ERR_FAIL_COND_V(!c,NULL);
|
|
||||||
ERR_FAIL_COND_V( c->lock==0, NULL );
|
|
||||||
|
|
||||||
return c->mem;
|
|
||||||
}
|
|
||||||
Error MemoryPoolDynamicStatic::unlock(ID p_id) {
|
|
||||||
|
|
||||||
_THREAD_SAFE_METHOD_
|
|
||||||
|
|
||||||
Chunk *c = get_chunk(p_id);
|
|
||||||
ERR_FAIL_COND_V(!c,ERR_INVALID_PARAMETER);
|
|
||||||
|
|
||||||
ERR_FAIL_COND_V( c->lock<=0, ERR_INVALID_PARAMETER );
|
|
||||||
c->lock--;
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t MemoryPoolDynamicStatic::get_available_mem() const {
|
|
||||||
|
|
||||||
return Memory::get_mem_available();
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t MemoryPoolDynamicStatic::get_total_usage() const {
|
|
||||||
_THREAD_SAFE_METHOD_
|
|
||||||
|
|
||||||
return total_usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryPoolDynamicStatic::MemoryPoolDynamicStatic() {
|
|
||||||
|
|
||||||
last_check=1;
|
|
||||||
last_alloc=0;
|
|
||||||
total_usage=0;
|
|
||||||
max_usage=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryPoolDynamicStatic::~MemoryPoolDynamicStatic() {
|
|
||||||
|
|
||||||
#ifdef DEBUG_MEMORY_ENABLED
|
|
||||||
|
|
||||||
if (OS::get_singleton()->is_stdout_verbose()) {
|
|
||||||
|
|
||||||
if (total_usage>0) {
|
|
||||||
|
|
||||||
ERR_PRINT("DYNAMIC ALLOC: ** MEMORY LEAKS DETECTED **");
|
|
||||||
ERR_PRINT(String("DYNAMIC ALLOC: "+String::num(total_usage)+" bytes of memory in use at exit.").ascii().get_data());
|
|
||||||
|
|
||||||
ERR_PRINT("DYNAMIC ALLOC: Following is the list of leaked allocations:");
|
|
||||||
|
|
||||||
for (int i=0;i<MAX_CHUNKS;i++) {
|
|
||||||
|
|
||||||
if (chunk[i].mem) {
|
|
||||||
|
|
||||||
ERR_PRINT(String("\t"+String::num(chunk[i].size)+" bytes - "+String(chunk[i].descr)).ascii().get_data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ERR_PRINT("DYNAMIC ALLOC: End of Report.");
|
|
||||||
|
|
||||||
print_line("INFO: dynmem - max: "+itos(max_usage)+", "+itos(total_usage)+" leaked.");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
print_line("INFO: dynmem - max: "+itos(max_usage)+", no leaks.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
|
@ -1,86 +0,0 @@
|
||||||
/*************************************************************************/
|
|
||||||
/* memory_pool_dynamic_static.h */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* http://www.godotengine.org */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* */
|
|
||||||
/* 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 MEMORY_POOL_DYNAMIC_STATIC_H
|
|
||||||
#define MEMORY_POOL_DYNAMIC_STATIC_H
|
|
||||||
|
|
||||||
#include "os/memory_pool_dynamic.h"
|
|
||||||
#include "typedefs.h"
|
|
||||||
#include "os/thread_safe.h"
|
|
||||||
|
|
||||||
class MemoryPoolDynamicStatic : public MemoryPoolDynamic {
|
|
||||||
|
|
||||||
_THREAD_SAFE_CLASS_
|
|
||||||
|
|
||||||
enum {
|
|
||||||
MAX_CHUNKS=65536
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct Chunk {
|
|
||||||
|
|
||||||
uint64_t lock;
|
|
||||||
uint64_t check;
|
|
||||||
void *mem;
|
|
||||||
size_t size;
|
|
||||||
const char *descr;
|
|
||||||
|
|
||||||
Chunk() { mem=NULL; lock=0; check=0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
Chunk chunk[MAX_CHUNKS];
|
|
||||||
uint64_t last_check;
|
|
||||||
int last_alloc;
|
|
||||||
size_t total_usage;
|
|
||||||
size_t max_usage;
|
|
||||||
|
|
||||||
Chunk *get_chunk(ID p_id);
|
|
||||||
const Chunk *get_chunk(ID p_id) const;
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual ID alloc(size_t p_amount,const char* p_description);
|
|
||||||
virtual void free(ID p_id);
|
|
||||||
virtual Error realloc(ID p_id, size_t p_amount);
|
|
||||||
virtual bool is_valid(ID p_id);
|
|
||||||
virtual size_t get_size(ID p_id) const;
|
|
||||||
virtual const char* get_description(ID p_id) const;
|
|
||||||
|
|
||||||
virtual bool is_locked(ID p_id) const;
|
|
||||||
virtual Error lock(ID p_id);
|
|
||||||
virtual void * get(ID p_ID);
|
|
||||||
virtual Error unlock(ID p_id);
|
|
||||||
|
|
||||||
virtual size_t get_available_mem() const;
|
|
||||||
virtual size_t get_total_usage() const;
|
|
||||||
|
|
||||||
MemoryPoolDynamicStatic();
|
|
||||||
virtual ~MemoryPoolDynamicStatic();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -371,7 +371,7 @@ int OS::get_static_memory_usage() const {
|
||||||
}
|
}
|
||||||
int OS::get_dynamic_memory_usage() const{
|
int OS::get_dynamic_memory_usage() const{
|
||||||
|
|
||||||
return Memory::get_dynamic_mem_usage();
|
return MemoryPool::total_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OS::get_static_memory_peak_usage() const {
|
int OS::get_static_memory_peak_usage() const {
|
||||||
|
|
21
core/os/rw_lock.cpp
Normal file
21
core/os/rw_lock.cpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#include "rw_lock.h"
|
||||||
|
#include "error_macros.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
RWLock* (*RWLock::create_func)()=0;
|
||||||
|
|
||||||
|
RWLock *RWLock::create() {
|
||||||
|
|
||||||
|
ERR_FAIL_COND_V( !create_func, 0 );
|
||||||
|
|
||||||
|
return create_func();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RWLock::~RWLock() {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
46
core/os/rw_lock.h
Normal file
46
core/os/rw_lock.h
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#ifndef RWLOCK_H
|
||||||
|
#define RWLOCK_H
|
||||||
|
|
||||||
|
#include "error_list.h"
|
||||||
|
|
||||||
|
class RWLock {
|
||||||
|
protected:
|
||||||
|
static RWLock* (*create_func)();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void read_lock()=0; ///< Lock the rwlock, block if locked by someone else
|
||||||
|
virtual void read_unlock()=0; ///< Unlock the rwlock, let other threads continue
|
||||||
|
virtual Error read_try_lock()=0; ///< Attempt to lock the rwlock, OK on success, ERROR means it can't lock.
|
||||||
|
|
||||||
|
virtual void write_lock()=0; ///< Lock the rwlock, block if locked by someone else
|
||||||
|
virtual void write_unlock()=0; ///< Unlock the rwlock, let other thwrites continue
|
||||||
|
virtual Error write_try_lock()=0; ///< Attempt to lock the rwlock, OK on success, ERROR means it can't lock.
|
||||||
|
|
||||||
|
static RWLock * create(); ///< Create a rwlock
|
||||||
|
|
||||||
|
virtual ~RWLock();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class RWLockRead {
|
||||||
|
|
||||||
|
RWLock *lock;
|
||||||
|
public:
|
||||||
|
|
||||||
|
RWLockRead(RWLock* p_lock) { lock=p_lock; if (lock) lock->read_lock(); }
|
||||||
|
~RWLockRead() { if (lock) lock->read_unlock(); }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class RWLockWrite {
|
||||||
|
|
||||||
|
RWLock *lock;
|
||||||
|
public:
|
||||||
|
|
||||||
|
RWLockWrite(RWLock* p_lock) { lock=p_lock; if (lock) lock->write_lock(); }
|
||||||
|
~RWLockWrite() { if (lock) lock->write_unlock(); }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RWLOCK_H
|
|
@ -82,7 +82,7 @@ Variant PackedDataContainer::_iter_get_ofs(const Variant& p_iter,uint32_t p_offs
|
||||||
if (pos<0 || pos>=size)
|
if (pos<0 || pos>=size)
|
||||||
return Variant();
|
return Variant();
|
||||||
|
|
||||||
DVector<uint8_t>::Read rd=data.read();
|
PoolVector<uint8_t>::Read rd=data.read();
|
||||||
const uint8_t *r=&rd[p_offset];
|
const uint8_t *r=&rd[p_offset];
|
||||||
uint32_t type = decode_uint32(r);
|
uint32_t type = decode_uint32(r);
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs,const uint8_t *p_buf,boo
|
||||||
|
|
||||||
uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const {
|
uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const {
|
||||||
|
|
||||||
DVector<uint8_t>::Read rd=data.read();
|
PoolVector<uint8_t>::Read rd=data.read();
|
||||||
const uint8_t *r=&rd[p_ofs];
|
const uint8_t *r=&rd[p_ofs];
|
||||||
uint32_t type = decode_uint32(r);
|
uint32_t type = decode_uint32(r);
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const {
|
||||||
|
|
||||||
int PackedDataContainer::_size(uint32_t p_ofs) const {
|
int PackedDataContainer::_size(uint32_t p_ofs) const {
|
||||||
|
|
||||||
DVector<uint8_t>::Read rd=data.read();
|
PoolVector<uint8_t>::Read rd=data.read();
|
||||||
const uint8_t *r=&rd[p_ofs];
|
const uint8_t *r=&rd[p_ofs];
|
||||||
uint32_t type = decode_uint32(r);
|
uint32_t type = decode_uint32(r);
|
||||||
|
|
||||||
|
@ -160,7 +160,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 {
|
Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs,const Variant& p_key,bool &err) const {
|
||||||
|
|
||||||
DVector<uint8_t>::Read rd=data.read();
|
PoolVector<uint8_t>::Read rd=data.read();
|
||||||
const uint8_t *r=&rd[p_ofs];
|
const uint8_t *r=&rd[p_ofs];
|
||||||
uint32_t type = decode_uint32(r);
|
uint32_t type = decode_uint32(r);
|
||||||
|
|
||||||
|
@ -344,21 +344,21 @@ Error PackedDataContainer::pack(const Variant& p_data) {
|
||||||
_pack(p_data,tmpdata,string_cache);
|
_pack(p_data,tmpdata,string_cache);
|
||||||
datalen=tmpdata.size();
|
datalen=tmpdata.size();
|
||||||
data.resize(tmpdata.size());
|
data.resize(tmpdata.size());
|
||||||
DVector<uint8_t>::Write w = data.write();
|
PoolVector<uint8_t>::Write w = data.write();
|
||||||
copymem(w.ptr(),tmpdata.ptr(),tmpdata.size());
|
copymem(w.ptr(),tmpdata.ptr(),tmpdata.size());
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PackedDataContainer::_set_data(const DVector<uint8_t>& p_data) {
|
void PackedDataContainer::_set_data(const PoolVector<uint8_t>& p_data) {
|
||||||
|
|
||||||
data=p_data;
|
data=p_data;
|
||||||
datalen=data.size();
|
datalen=data.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t> PackedDataContainer::_get_data() const {
|
PoolVector<uint8_t> PackedDataContainer::_get_data() const {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ class PackedDataContainer : public Resource {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
int datalen;
|
int datalen;
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ friend class PackedDataContainerRef;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void _set_data(const DVector<uint8_t>& p_data);
|
void _set_data(const PoolVector<uint8_t>& p_data);
|
||||||
DVector<uint8_t> _get_data() const;
|
PoolVector<uint8_t> _get_data() const;
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -124,13 +124,13 @@ void PathRemap::clear_remaps() {
|
||||||
void PathRemap::load_remaps() {
|
void PathRemap::load_remaps() {
|
||||||
|
|
||||||
// default remaps first
|
// default remaps first
|
||||||
DVector<String> remaps = GlobalConfig::get_singleton()->get("remap/all");
|
PoolVector<String> remaps = GlobalConfig::get_singleton()->get("remap/all");
|
||||||
|
|
||||||
{
|
{
|
||||||
int rlen = remaps.size();
|
int rlen = remaps.size();
|
||||||
|
|
||||||
ERR_FAIL_COND( rlen%2 );
|
ERR_FAIL_COND( rlen%2 );
|
||||||
DVector<String>::Read r = remaps.read();
|
PoolVector<String>::Read r = remaps.read();
|
||||||
for(int i=0;i<rlen/2;i++) {
|
for(int i=0;i<rlen/2;i++) {
|
||||||
|
|
||||||
String from = r[i*2+0];
|
String from = r[i*2+0];
|
||||||
|
@ -147,7 +147,7 @@ void PathRemap::load_remaps() {
|
||||||
int rlen = remaps.size();
|
int rlen = remaps.size();
|
||||||
|
|
||||||
ERR_FAIL_COND( rlen%2 );
|
ERR_FAIL_COND( rlen%2 );
|
||||||
DVector<String>::Read r = remaps.read();
|
PoolVector<String>::Read r = remaps.read();
|
||||||
for(int i=0;i<rlen/2;i++) {
|
for(int i=0;i<rlen/2;i++) {
|
||||||
|
|
||||||
String from = r[i*2+0];
|
String from = r[i*2+0];
|
||||||
|
|
|
@ -85,6 +85,9 @@ extern void unregister_variant_methods();
|
||||||
|
|
||||||
void register_core_types() {
|
void register_core_types() {
|
||||||
|
|
||||||
|
ObjectDB::setup();
|
||||||
|
ResourceCache::setup();
|
||||||
|
MemoryPool::setup();
|
||||||
|
|
||||||
_global_mutex=Mutex::create();
|
_global_mutex=Mutex::create();
|
||||||
|
|
||||||
|
@ -241,4 +244,7 @@ void unregister_core_types() {
|
||||||
memdelete(_global_mutex);
|
memdelete(_global_mutex);
|
||||||
_global_mutex=NULL; //still needed at a few places
|
_global_mutex=NULL; //still needed at a few places
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MemoryPool::cleanup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,17 +164,31 @@ void Resource::set_path(const String& p_path, bool p_take_over) {
|
||||||
|
|
||||||
if (path_cache!="") {
|
if (path_cache!="") {
|
||||||
|
|
||||||
|
ResourceCache::lock->write_lock();
|
||||||
ResourceCache::resources.erase(path_cache);
|
ResourceCache::resources.erase(path_cache);
|
||||||
|
ResourceCache::lock->write_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
path_cache="";
|
path_cache="";
|
||||||
if (ResourceCache::resources.has( p_path )) {
|
|
||||||
|
ResourceCache::lock->read_lock();
|
||||||
|
bool has_path = ResourceCache::resources.has( p_path );
|
||||||
|
ResourceCache::lock->read_unlock();
|
||||||
|
|
||||||
|
if (has_path) {
|
||||||
if (p_take_over) {
|
if (p_take_over) {
|
||||||
|
|
||||||
|
ResourceCache::lock->write_lock();
|
||||||
ResourceCache::resources.get(p_path)->set_name("");
|
ResourceCache::resources.get(p_path)->set_name("");
|
||||||
|
ResourceCache::lock->write_unlock();
|
||||||
} else {
|
} else {
|
||||||
ERR_EXPLAIN("Another resource is loaded from path: "+p_path);
|
ERR_EXPLAIN("Another resource is loaded from path: "+p_path);
|
||||||
ERR_FAIL_COND( ResourceCache::resources.has( p_path ) );
|
|
||||||
|
ResourceCache::lock->read_lock();
|
||||||
|
bool exists = ResourceCache::resources.has( p_path );
|
||||||
|
ResourceCache::lock->read_unlock();
|
||||||
|
|
||||||
|
ERR_FAIL_COND( exists );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -182,7 +196,9 @@ void Resource::set_path(const String& p_path, bool p_take_over) {
|
||||||
|
|
||||||
if (path_cache!="") {
|
if (path_cache!="") {
|
||||||
|
|
||||||
|
ResourceCache::lock->write_lock();
|
||||||
ResourceCache::resources[path_cache]=this;;
|
ResourceCache::resources[path_cache]=this;;
|
||||||
|
ResourceCache::lock->write_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
_change_notify("resource/path");
|
_change_notify("resource/path");
|
||||||
|
@ -393,8 +409,11 @@ Resource::Resource() {
|
||||||
|
|
||||||
Resource::~Resource() {
|
Resource::~Resource() {
|
||||||
|
|
||||||
if (path_cache!="")
|
if (path_cache!="") {
|
||||||
|
ResourceCache::lock->write_lock();
|
||||||
ResourceCache::resources.erase(path_cache);
|
ResourceCache::resources.erase(path_cache);
|
||||||
|
ResourceCache::lock->write_unlock();
|
||||||
|
}
|
||||||
if (owners.size()) {
|
if (owners.size()) {
|
||||||
WARN_PRINT("Resource is still owned");
|
WARN_PRINT("Resource is still owned");
|
||||||
}
|
}
|
||||||
|
@ -402,18 +421,24 @@ Resource::~Resource() {
|
||||||
|
|
||||||
HashMap<String,Resource*> ResourceCache::resources;
|
HashMap<String,Resource*> ResourceCache::resources;
|
||||||
|
|
||||||
|
RWLock *ResourceCache::lock=NULL;
|
||||||
|
|
||||||
|
void ResourceCache::setup() {
|
||||||
|
|
||||||
|
lock = RWLock::create();
|
||||||
|
}
|
||||||
|
|
||||||
void ResourceCache::clear() {
|
void ResourceCache::clear() {
|
||||||
if (resources.size())
|
if (resources.size())
|
||||||
ERR_PRINT("Resources Still in use at Exit!");
|
ERR_PRINT("Resources Still in use at Exit!");
|
||||||
|
|
||||||
resources.clear();
|
resources.clear();
|
||||||
|
memdelete(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ResourceCache::reload_externals() {
|
void ResourceCache::reload_externals() {
|
||||||
|
|
||||||
GLOBAL_LOCK_FUNCTION
|
|
||||||
|
|
||||||
//const String *K=NULL;
|
//const String *K=NULL;
|
||||||
//while ((K=resources.next(K))) {
|
//while ((K=resources.next(K))) {
|
||||||
// resources[*K]->reload_external_data();
|
// resources[*K]->reload_external_data();
|
||||||
|
@ -423,15 +448,21 @@ void ResourceCache::reload_externals() {
|
||||||
|
|
||||||
bool ResourceCache::has(const String& p_path) {
|
bool ResourceCache::has(const String& p_path) {
|
||||||
|
|
||||||
GLOBAL_LOCK_FUNCTION
|
lock->read_lock();;
|
||||||
|
bool b = resources.has(p_path);
|
||||||
|
lock->read_unlock();;
|
||||||
|
|
||||||
return resources.has(p_path);
|
|
||||||
|
return b;
|
||||||
}
|
}
|
||||||
Resource *ResourceCache::get(const String& p_path) {
|
Resource *ResourceCache::get(const String& p_path) {
|
||||||
|
|
||||||
GLOBAL_LOCK_FUNCTION
|
lock->read_lock();
|
||||||
|
|
||||||
Resource **res = resources.getptr(p_path);
|
Resource **res = resources.getptr(p_path);
|
||||||
|
|
||||||
|
lock->read_unlock();
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -443,6 +474,7 @@ Resource *ResourceCache::get(const String& p_path) {
|
||||||
void ResourceCache::get_cached_resources(List<Ref<Resource> > *p_resources) {
|
void ResourceCache::get_cached_resources(List<Ref<Resource> > *p_resources) {
|
||||||
|
|
||||||
|
|
||||||
|
lock->read_lock();
|
||||||
const String* K=NULL;
|
const String* K=NULL;
|
||||||
while((K=resources.next(K))) {
|
while((K=resources.next(K))) {
|
||||||
|
|
||||||
|
@ -450,17 +482,22 @@ void ResourceCache::get_cached_resources(List<Ref<Resource> > *p_resources) {
|
||||||
p_resources->push_back( Ref<Resource>( r ));
|
p_resources->push_back( Ref<Resource>( r ));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
lock->read_unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ResourceCache::get_cached_resource_count() {
|
int ResourceCache::get_cached_resource_count() {
|
||||||
|
|
||||||
return resources.size();
|
lock->read_lock();
|
||||||
|
int rc = resources.size();
|
||||||
|
lock->read_unlock();
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceCache::dump(const char* p_file,bool p_short) {
|
void ResourceCache::dump(const char* p_file,bool p_short) {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
GLOBAL_LOCK_FUNCTION
|
lock->read_lock();
|
||||||
|
|
||||||
Map<String,int> type_count;
|
Map<String,int> type_count;
|
||||||
|
|
||||||
|
@ -500,5 +537,7 @@ void ResourceCache::dump(const char* p_file,bool p_short) {
|
||||||
memdelete(f);
|
memdelete(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lock->read_unlock();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,9 +165,12 @@ typedef Ref<Resource> RES;
|
||||||
|
|
||||||
class ResourceCache {
|
class ResourceCache {
|
||||||
friend class Resource;
|
friend class Resource;
|
||||||
|
static RWLock *lock;
|
||||||
static HashMap<String,Resource*> resources;
|
static HashMap<String,Resource*> resources;
|
||||||
friend void unregister_core_types();
|
friend void unregister_core_types();
|
||||||
static void clear();
|
static void clear();
|
||||||
|
friend void register_core_types();
|
||||||
|
static void setup();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void reload_externals();
|
static void reload_externals();
|
||||||
|
|
|
@ -76,6 +76,9 @@ uint32_t atomic_decrement( register uint32_t * pw ) {
|
||||||
return InterlockedDecrement( (LONG volatile*)pw );
|
return InterlockedDecrement( (LONG volatile*)pw );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t atomic_increment( register uint32_t * pw ) {
|
||||||
|
return InterlockedIncrement( (LONG volatile*)pw );
|
||||||
|
}
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
|
|
||||||
uint32_t atomic_conditional_increment( register uint32_t * pw ) {
|
uint32_t atomic_conditional_increment( register uint32_t * pw ) {
|
||||||
|
@ -95,6 +98,12 @@ uint32_t atomic_decrement( register uint32_t * pw ) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t atomic_increment( register uint32_t * pw ) {
|
||||||
|
|
||||||
|
return __sync_add_and_fetch(pw,1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
//no threads supported?
|
//no threads supported?
|
||||||
#error Must provide atomic functions for this platform or compiler!
|
#error Must provide atomic functions for this platform or compiler!
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
uint32_t atomic_conditional_increment( register uint32_t * counter );
|
uint32_t atomic_conditional_increment( register uint32_t * counter );
|
||||||
uint32_t atomic_decrement( register uint32_t * pw );
|
uint32_t atomic_decrement( register uint32_t * pw );
|
||||||
|
uint32_t atomic_increment( register uint32_t * pw );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,12 @@ StringName _scs_create(const char *p_chr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StringName::configured=false;
|
bool StringName::configured=false;
|
||||||
|
Mutex* StringName::lock=NULL;
|
||||||
|
|
||||||
void StringName::setup() {
|
void StringName::setup() {
|
||||||
|
|
||||||
|
lock = Mutex::create();
|
||||||
|
|
||||||
ERR_FAIL_COND(configured);
|
ERR_FAIL_COND(configured);
|
||||||
for(int i=0;i<STRING_TABLE_LEN;i++) {
|
for(int i=0;i<STRING_TABLE_LEN;i++) {
|
||||||
|
|
||||||
|
@ -54,7 +57,8 @@ void StringName::setup() {
|
||||||
|
|
||||||
void StringName::cleanup() {
|
void StringName::cleanup() {
|
||||||
|
|
||||||
_global_lock();
|
lock->lock();
|
||||||
|
|
||||||
int lost_strings=0;
|
int lost_strings=0;
|
||||||
for(int i=0;i<STRING_TABLE_LEN;i++) {
|
for(int i=0;i<STRING_TABLE_LEN;i++) {
|
||||||
|
|
||||||
|
@ -78,7 +82,9 @@ void StringName::cleanup() {
|
||||||
if (OS::get_singleton()->is_stdout_verbose() && lost_strings) {
|
if (OS::get_singleton()->is_stdout_verbose() && lost_strings) {
|
||||||
print_line("StringName: "+itos(lost_strings)+" unclaimed string names at exit.");
|
print_line("StringName: "+itos(lost_strings)+" unclaimed string names at exit.");
|
||||||
}
|
}
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
|
|
||||||
|
memdelete(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringName::unref() {
|
void StringName::unref() {
|
||||||
|
@ -87,7 +93,7 @@ void StringName::unref() {
|
||||||
|
|
||||||
if (_data && _data->refcount.unref()) {
|
if (_data && _data->refcount.unref()) {
|
||||||
|
|
||||||
_global_lock();
|
lock->lock();
|
||||||
|
|
||||||
if (_data->prev) {
|
if (_data->prev) {
|
||||||
_data->prev->next=_data->next;
|
_data->prev->next=_data->next;
|
||||||
|
@ -103,7 +109,7 @@ void StringName::unref() {
|
||||||
|
|
||||||
}
|
}
|
||||||
memdelete(_data);
|
memdelete(_data);
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
_data=NULL;
|
_data=NULL;
|
||||||
|
@ -186,7 +192,7 @@ StringName::StringName(const char *p_name) {
|
||||||
if (!p_name || p_name[0]==0)
|
if (!p_name || p_name[0]==0)
|
||||||
return; //empty, ignore
|
return; //empty, ignore
|
||||||
|
|
||||||
_global_lock();
|
lock->lock();
|
||||||
|
|
||||||
uint32_t hash = String::hash(p_name);
|
uint32_t hash = String::hash(p_name);
|
||||||
|
|
||||||
|
@ -206,7 +212,7 @@ StringName::StringName(const char *p_name) {
|
||||||
if (_data) {
|
if (_data) {
|
||||||
if (_data->refcount.ref()) {
|
if (_data->refcount.ref()) {
|
||||||
// exists
|
// exists
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -226,8 +232,7 @@ StringName::StringName(const char *p_name) {
|
||||||
_table[idx]=_data;
|
_table[idx]=_data;
|
||||||
|
|
||||||
|
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StringName::StringName(const StaticCString& p_static_string) {
|
StringName::StringName(const StaticCString& p_static_string) {
|
||||||
|
@ -238,7 +243,7 @@ StringName::StringName(const StaticCString& p_static_string) {
|
||||||
|
|
||||||
ERR_FAIL_COND( !p_static_string.ptr || !p_static_string.ptr[0]);
|
ERR_FAIL_COND( !p_static_string.ptr || !p_static_string.ptr[0]);
|
||||||
|
|
||||||
_global_lock();
|
lock->lock();
|
||||||
|
|
||||||
uint32_t hash = String::hash(p_static_string.ptr);
|
uint32_t hash = String::hash(p_static_string.ptr);
|
||||||
|
|
||||||
|
@ -258,7 +263,7 @@ StringName::StringName(const StaticCString& p_static_string) {
|
||||||
if (_data) {
|
if (_data) {
|
||||||
if (_data->refcount.ref()) {
|
if (_data->refcount.ref()) {
|
||||||
// exists
|
// exists
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -278,7 +283,8 @@ StringName::StringName(const StaticCString& p_static_string) {
|
||||||
_table[idx]=_data;
|
_table[idx]=_data;
|
||||||
|
|
||||||
|
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +298,7 @@ StringName::StringName(const String& p_name) {
|
||||||
if (p_name==String())
|
if (p_name==String())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_global_lock();
|
lock->lock();
|
||||||
|
|
||||||
uint32_t hash = p_name.hash();
|
uint32_t hash = p_name.hash();
|
||||||
|
|
||||||
|
@ -311,7 +317,7 @@ StringName::StringName(const String& p_name) {
|
||||||
if (_data) {
|
if (_data) {
|
||||||
if (_data->refcount.ref()) {
|
if (_data->refcount.ref()) {
|
||||||
// exists
|
// exists
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -332,7 +338,7 @@ StringName::StringName(const String& p_name) {
|
||||||
_table[idx]->prev=_data;
|
_table[idx]->prev=_data;
|
||||||
_table[idx]=_data;
|
_table[idx]=_data;
|
||||||
|
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,7 +350,7 @@ StringName StringName::search(const char *p_name) {
|
||||||
if (!p_name[0])
|
if (!p_name[0])
|
||||||
return StringName();
|
return StringName();
|
||||||
|
|
||||||
_global_lock();
|
lock->lock();
|
||||||
|
|
||||||
uint32_t hash = String::hash(p_name);
|
uint32_t hash = String::hash(p_name);
|
||||||
|
|
||||||
|
@ -361,12 +367,13 @@ StringName StringName::search(const char *p_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data && _data->refcount.ref()) {
|
if (_data && _data->refcount.ref()) {
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
|
|
||||||
return StringName(_data);
|
return StringName(_data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
return StringName(); //does not exist
|
return StringName(); //does not exist
|
||||||
|
|
||||||
|
|
||||||
|
@ -380,7 +387,7 @@ StringName StringName::search(const CharType *p_name) {
|
||||||
if (!p_name[0])
|
if (!p_name[0])
|
||||||
return StringName();
|
return StringName();
|
||||||
|
|
||||||
_global_lock();
|
lock->lock();
|
||||||
|
|
||||||
uint32_t hash = String::hash(p_name);
|
uint32_t hash = String::hash(p_name);
|
||||||
|
|
||||||
|
@ -397,12 +404,12 @@ StringName StringName::search(const CharType *p_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data && _data->refcount.ref()) {
|
if (_data && _data->refcount.ref()) {
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
return StringName(_data);
|
return StringName(_data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
return StringName(); //does not exist
|
return StringName(); //does not exist
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -410,7 +417,7 @@ StringName StringName::search(const String &p_name) {
|
||||||
|
|
||||||
ERR_FAIL_COND_V( p_name=="", StringName() );
|
ERR_FAIL_COND_V( p_name=="", StringName() );
|
||||||
|
|
||||||
_global_lock();
|
lock->lock();
|
||||||
|
|
||||||
uint32_t hash = p_name.hash();
|
uint32_t hash = p_name.hash();
|
||||||
|
|
||||||
|
@ -427,12 +434,12 @@ StringName StringName::search(const String &p_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data && _data->refcount.ref()) {
|
if (_data && _data->refcount.ref()) {
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
return StringName(_data);
|
return StringName(_data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_global_unlock();
|
lock->unlock();
|
||||||
return StringName(); //does not exist
|
return StringName(); //does not exist
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "hash_map.h"
|
#include "hash_map.h"
|
||||||
#include "ustring.h"
|
#include "ustring.h"
|
||||||
#include "safe_refcount.h"
|
#include "safe_refcount.h"
|
||||||
|
#include "os/mutex.h"
|
||||||
/**
|
/**
|
||||||
@author Juan Linietsky <reduzio@gmail.com>
|
@author Juan Linietsky <reduzio@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
@ -83,6 +83,7 @@ class StringName {
|
||||||
friend void register_core_types();
|
friend void register_core_types();
|
||||||
friend void unregister_core_types();
|
friend void unregister_core_types();
|
||||||
|
|
||||||
|
static Mutex *lock;
|
||||||
static void setup();
|
static void setup();
|
||||||
static void cleanup();
|
static void cleanup();
|
||||||
static bool configured;
|
static bool configured;
|
||||||
|
|
|
@ -799,9 +799,9 @@ static bool is_valid_locale(const String& p_locale) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<String> Translation::_get_messages() const {
|
PoolVector<String> Translation::_get_messages() const {
|
||||||
|
|
||||||
DVector<String> msgs;
|
PoolVector<String> msgs;
|
||||||
msgs.resize(translation_map.size()*2);
|
msgs.resize(translation_map.size()*2);
|
||||||
int idx=0;
|
int idx=0;
|
||||||
for (const Map<StringName, StringName>::Element *E=translation_map.front();E;E=E->next()) {
|
for (const Map<StringName, StringName>::Element *E=translation_map.front();E;E=E->next()) {
|
||||||
|
@ -814,9 +814,9 @@ DVector<String> Translation::_get_messages() const {
|
||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<String> Translation::_get_message_list() const {
|
PoolVector<String> Translation::_get_message_list() const {
|
||||||
|
|
||||||
DVector<String> msgs;
|
PoolVector<String> msgs;
|
||||||
msgs.resize(translation_map.size());
|
msgs.resize(translation_map.size());
|
||||||
int idx=0;
|
int idx=0;
|
||||||
for (const Map<StringName, StringName>::Element *E=translation_map.front();E;E=E->next()) {
|
for (const Map<StringName, StringName>::Element *E=translation_map.front();E;E=E->next()) {
|
||||||
|
@ -829,12 +829,12 @@ DVector<String> Translation::_get_message_list() const {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Translation::_set_messages(const DVector<String>& p_messages){
|
void Translation::_set_messages(const PoolVector<String>& p_messages){
|
||||||
|
|
||||||
int msg_count=p_messages.size();
|
int msg_count=p_messages.size();
|
||||||
ERR_FAIL_COND(msg_count%2);
|
ERR_FAIL_COND(msg_count%2);
|
||||||
|
|
||||||
DVector<String>::Read r = p_messages.read();
|
PoolVector<String>::Read r = p_messages.read();
|
||||||
|
|
||||||
for(int i=0;i<msg_count;i+=2) {
|
for(int i=0;i<msg_count;i+=2) {
|
||||||
|
|
||||||
|
@ -1048,12 +1048,12 @@ TranslationServer *TranslationServer::singleton=NULL;
|
||||||
bool TranslationServer::_load_translations(const String& p_from) {
|
bool TranslationServer::_load_translations(const String& p_from) {
|
||||||
|
|
||||||
if (GlobalConfig::get_singleton()->has(p_from)) {
|
if (GlobalConfig::get_singleton()->has(p_from)) {
|
||||||
DVector<String> translations=GlobalConfig::get_singleton()->get(p_from);
|
PoolVector<String> translations=GlobalConfig::get_singleton()->get(p_from);
|
||||||
|
|
||||||
int tcount=translations.size();
|
int tcount=translations.size();
|
||||||
|
|
||||||
if (tcount) {
|
if (tcount) {
|
||||||
DVector<String>::Read r = translations.read();
|
PoolVector<String>::Read r = translations.read();
|
||||||
|
|
||||||
for(int i=0;i<tcount;i++) {
|
for(int i=0;i<tcount;i++) {
|
||||||
|
|
||||||
|
|
|
@ -42,10 +42,10 @@ class Translation : public Resource {
|
||||||
String locale;
|
String locale;
|
||||||
Map<StringName, StringName> translation_map;
|
Map<StringName, StringName> translation_map;
|
||||||
|
|
||||||
DVector<String> _get_message_list() const;
|
PoolVector<String> _get_message_list() const;
|
||||||
|
|
||||||
DVector<String> _get_messages() const;
|
PoolVector<String> _get_messages() const;
|
||||||
void _set_messages(const DVector<String>& p_messages);
|
void _set_messages(const PoolVector<String>& p_messages);
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
|
234
core/variant.cpp
234
core/variant.cpp
|
@ -842,37 +842,37 @@ bool Variant::is_zero() const {
|
||||||
// arrays
|
// arrays
|
||||||
case RAW_ARRAY: {
|
case RAW_ARRAY: {
|
||||||
|
|
||||||
return reinterpret_cast<const DVector<uint8_t>*>(_data._mem)->size()==0;
|
return reinterpret_cast<const PoolVector<uint8_t>*>(_data._mem)->size()==0;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case INT_ARRAY: {
|
case INT_ARRAY: {
|
||||||
|
|
||||||
return reinterpret_cast<const DVector<int>*>(_data._mem)->size()==0;
|
return reinterpret_cast<const PoolVector<int>*>(_data._mem)->size()==0;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case REAL_ARRAY: {
|
case REAL_ARRAY: {
|
||||||
|
|
||||||
return reinterpret_cast<const DVector<real_t>*>(_data._mem)->size()==0;
|
return reinterpret_cast<const PoolVector<real_t>*>(_data._mem)->size()==0;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case STRING_ARRAY: {
|
case STRING_ARRAY: {
|
||||||
|
|
||||||
return reinterpret_cast<const DVector<String>*>(_data._mem)->size()==0;
|
return reinterpret_cast<const PoolVector<String>*>(_data._mem)->size()==0;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case VECTOR2_ARRAY: {
|
case VECTOR2_ARRAY: {
|
||||||
|
|
||||||
return reinterpret_cast<const DVector<Vector2>*>(_data._mem)->size()==0;
|
return reinterpret_cast<const PoolVector<Vector2>*>(_data._mem)->size()==0;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case VECTOR3_ARRAY: {
|
case VECTOR3_ARRAY: {
|
||||||
|
|
||||||
return reinterpret_cast<const DVector<Vector3>*>(_data._mem)->size()==0;
|
return reinterpret_cast<const PoolVector<Vector3>*>(_data._mem)->size()==0;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case COLOR_ARRAY: {
|
case COLOR_ARRAY: {
|
||||||
|
|
||||||
return reinterpret_cast<const DVector<Color>*>(_data._mem)->size()==0;
|
return reinterpret_cast<const PoolVector<Color>*>(_data._mem)->size()==0;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
default: {}
|
default: {}
|
||||||
|
@ -1070,37 +1070,37 @@ void Variant::reference(const Variant& p_variant) {
|
||||||
// arrays
|
// arrays
|
||||||
case RAW_ARRAY: {
|
case RAW_ARRAY: {
|
||||||
|
|
||||||
memnew_placement( _data._mem, DVector<uint8_t> ( *reinterpret_cast<const DVector<uint8_t>*>(p_variant._data._mem) ) );
|
memnew_placement( _data._mem, PoolVector<uint8_t> ( *reinterpret_cast<const PoolVector<uint8_t>*>(p_variant._data._mem) ) );
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case INT_ARRAY: {
|
case INT_ARRAY: {
|
||||||
|
|
||||||
memnew_placement( _data._mem, DVector<int> ( *reinterpret_cast<const DVector<int>*>(p_variant._data._mem) ) );
|
memnew_placement( _data._mem, PoolVector<int> ( *reinterpret_cast<const PoolVector<int>*>(p_variant._data._mem) ) );
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case REAL_ARRAY: {
|
case REAL_ARRAY: {
|
||||||
|
|
||||||
memnew_placement( _data._mem, DVector<real_t> ( *reinterpret_cast<const DVector<real_t>*>(p_variant._data._mem) ) );
|
memnew_placement( _data._mem, PoolVector<real_t> ( *reinterpret_cast<const PoolVector<real_t>*>(p_variant._data._mem) ) );
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case STRING_ARRAY: {
|
case STRING_ARRAY: {
|
||||||
|
|
||||||
memnew_placement( _data._mem, DVector<String> ( *reinterpret_cast<const DVector<String>*>(p_variant._data._mem) ) );
|
memnew_placement( _data._mem, PoolVector<String> ( *reinterpret_cast<const PoolVector<String>*>(p_variant._data._mem) ) );
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case VECTOR2_ARRAY: {
|
case VECTOR2_ARRAY: {
|
||||||
|
|
||||||
memnew_placement( _data._mem, DVector<Vector2> ( *reinterpret_cast<const DVector<Vector2>*>(p_variant._data._mem) ) );
|
memnew_placement( _data._mem, PoolVector<Vector2> ( *reinterpret_cast<const PoolVector<Vector2>*>(p_variant._data._mem) ) );
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case VECTOR3_ARRAY: {
|
case VECTOR3_ARRAY: {
|
||||||
|
|
||||||
memnew_placement( _data._mem, DVector<Vector3> ( *reinterpret_cast<const DVector<Vector3>*>(p_variant._data._mem) ) );
|
memnew_placement( _data._mem, PoolVector<Vector3> ( *reinterpret_cast<const PoolVector<Vector3>*>(p_variant._data._mem) ) );
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case COLOR_ARRAY: {
|
case COLOR_ARRAY: {
|
||||||
|
|
||||||
memnew_placement( _data._mem, DVector<Color> ( *reinterpret_cast<const DVector<Color>*>(p_variant._data._mem) ) );
|
memnew_placement( _data._mem, PoolVector<Color> ( *reinterpret_cast<const PoolVector<Color>*>(p_variant._data._mem) ) );
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
default: {}
|
default: {}
|
||||||
|
@ -1198,37 +1198,37 @@ void Variant::clear() {
|
||||||
// arrays
|
// arrays
|
||||||
case RAW_ARRAY: {
|
case RAW_ARRAY: {
|
||||||
|
|
||||||
reinterpret_cast< DVector<uint8_t>* >(_data._mem)->~DVector<uint8_t>();
|
reinterpret_cast< PoolVector<uint8_t>* >(_data._mem)->~PoolVector<uint8_t>();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case INT_ARRAY: {
|
case INT_ARRAY: {
|
||||||
|
|
||||||
reinterpret_cast< DVector<int>* >(_data._mem)->~DVector<int>();
|
reinterpret_cast< PoolVector<int>* >(_data._mem)->~PoolVector<int>();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case REAL_ARRAY: {
|
case REAL_ARRAY: {
|
||||||
|
|
||||||
reinterpret_cast< DVector<real_t>* >(_data._mem)->~DVector<real_t>();
|
reinterpret_cast< PoolVector<real_t>* >(_data._mem)->~PoolVector<real_t>();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case STRING_ARRAY: {
|
case STRING_ARRAY: {
|
||||||
|
|
||||||
reinterpret_cast< DVector<String>* >(_data._mem)->~DVector<String>();
|
reinterpret_cast< PoolVector<String>* >(_data._mem)->~PoolVector<String>();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case VECTOR2_ARRAY: {
|
case VECTOR2_ARRAY: {
|
||||||
|
|
||||||
reinterpret_cast< DVector<Vector2>* >(_data._mem)->~DVector<Vector2>();
|
reinterpret_cast< PoolVector<Vector2>* >(_data._mem)->~PoolVector<Vector2>();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case VECTOR3_ARRAY: {
|
case VECTOR3_ARRAY: {
|
||||||
|
|
||||||
reinterpret_cast< DVector<Vector3>* >(_data._mem)->~DVector<Vector3>();
|
reinterpret_cast< PoolVector<Vector3>* >(_data._mem)->~PoolVector<Vector3>();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case COLOR_ARRAY: {
|
case COLOR_ARRAY: {
|
||||||
|
|
||||||
reinterpret_cast< DVector<Color>* >(_data._mem)->~DVector<Color>();
|
reinterpret_cast< PoolVector<Color>* >(_data._mem)->~PoolVector<Color>();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
default: {} /* not needed */
|
default: {} /* not needed */
|
||||||
|
@ -1578,7 +1578,7 @@ Variant::operator String() const {
|
||||||
} break;
|
} break;
|
||||||
case VECTOR2_ARRAY: {
|
case VECTOR2_ARRAY: {
|
||||||
|
|
||||||
DVector<Vector2> vec = operator DVector<Vector2>();
|
PoolVector<Vector2> vec = operator PoolVector<Vector2>();
|
||||||
String str("[");
|
String str("[");
|
||||||
for(int i=0;i<vec.size();i++) {
|
for(int i=0;i<vec.size();i++) {
|
||||||
|
|
||||||
|
@ -1591,7 +1591,7 @@ Variant::operator String() const {
|
||||||
} break;
|
} break;
|
||||||
case VECTOR3_ARRAY: {
|
case VECTOR3_ARRAY: {
|
||||||
|
|
||||||
DVector<Vector3> vec = operator DVector<Vector3>();
|
PoolVector<Vector3> vec = operator PoolVector<Vector3>();
|
||||||
String str("[");
|
String str("[");
|
||||||
for(int i=0;i<vec.size();i++) {
|
for(int i=0;i<vec.size();i++) {
|
||||||
|
|
||||||
|
@ -1604,7 +1604,7 @@ Variant::operator String() const {
|
||||||
} break;
|
} break;
|
||||||
case STRING_ARRAY: {
|
case STRING_ARRAY: {
|
||||||
|
|
||||||
DVector<String> vec = operator DVector<String>();
|
PoolVector<String> vec = operator PoolVector<String>();
|
||||||
String str("[");
|
String str("[");
|
||||||
for(int i=0;i<vec.size();i++) {
|
for(int i=0;i<vec.size();i++) {
|
||||||
|
|
||||||
|
@ -1617,7 +1617,7 @@ Variant::operator String() const {
|
||||||
} break;
|
} break;
|
||||||
case INT_ARRAY: {
|
case INT_ARRAY: {
|
||||||
|
|
||||||
DVector<int> vec = operator DVector<int>();
|
PoolVector<int> vec = operator PoolVector<int>();
|
||||||
String str("[");
|
String str("[");
|
||||||
for(int i=0;i<vec.size();i++) {
|
for(int i=0;i<vec.size();i++) {
|
||||||
|
|
||||||
|
@ -1630,7 +1630,7 @@ Variant::operator String() const {
|
||||||
} break;
|
} break;
|
||||||
case REAL_ARRAY: {
|
case REAL_ARRAY: {
|
||||||
|
|
||||||
DVector<real_t> vec = operator DVector<real_t>();
|
PoolVector<real_t> vec = operator PoolVector<real_t>();
|
||||||
String str("[");
|
String str("[");
|
||||||
for(int i=0;i<vec.size();i++) {
|
for(int i=0;i<vec.size();i++) {
|
||||||
|
|
||||||
|
@ -1893,13 +1893,13 @@ inline DA _convert_array_from_variant(const Variant& p_variant) {
|
||||||
|
|
||||||
|
|
||||||
case Variant::ARRAY: { return _convert_array<DA,Array >( p_variant.operator Array () ); }
|
case Variant::ARRAY: { return _convert_array<DA,Array >( p_variant.operator Array () ); }
|
||||||
case Variant::RAW_ARRAY: { return _convert_array<DA,DVector<uint8_t> >( p_variant.operator DVector<uint8_t> () ); }
|
case Variant::RAW_ARRAY: { return _convert_array<DA,PoolVector<uint8_t> >( p_variant.operator PoolVector<uint8_t> () ); }
|
||||||
case Variant::INT_ARRAY: { return _convert_array<DA,DVector<int> >( p_variant.operator DVector<int> () ); }
|
case Variant::INT_ARRAY: { return _convert_array<DA,PoolVector<int> >( p_variant.operator PoolVector<int> () ); }
|
||||||
case Variant::REAL_ARRAY: { return _convert_array<DA,DVector<real_t> >( p_variant.operator DVector<real_t> () ); }
|
case Variant::REAL_ARRAY: { return _convert_array<DA,PoolVector<real_t> >( p_variant.operator PoolVector<real_t> () ); }
|
||||||
case Variant::STRING_ARRAY: { return _convert_array<DA,DVector<String> >( p_variant.operator DVector<String> () ); }
|
case Variant::STRING_ARRAY: { return _convert_array<DA,PoolVector<String> >( p_variant.operator PoolVector<String> () ); }
|
||||||
case Variant::VECTOR2_ARRAY: { return _convert_array<DA,DVector<Vector2> >( p_variant.operator DVector<Vector2> () ); }
|
case Variant::VECTOR2_ARRAY: { return _convert_array<DA,PoolVector<Vector2> >( p_variant.operator PoolVector<Vector2> () ); }
|
||||||
case Variant::VECTOR3_ARRAY: { return _convert_array<DA,DVector<Vector3> >( p_variant.operator DVector<Vector3> () ); }
|
case Variant::VECTOR3_ARRAY: { return _convert_array<DA,PoolVector<Vector3> >( p_variant.operator PoolVector<Vector3> () ); }
|
||||||
case Variant::COLOR_ARRAY: { return _convert_array<DA,DVector<Color> >( p_variant.operator DVector<Color>() ); }
|
case Variant::COLOR_ARRAY: { return _convert_array<DA,PoolVector<Color> >( p_variant.operator PoolVector<Color>() ); }
|
||||||
default: { return DA(); }
|
default: { return DA(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1914,64 +1914,64 @@ Variant::operator Array() const {
|
||||||
return _convert_array_from_variant<Array >(*this);
|
return _convert_array_from_variant<Array >(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator DVector<uint8_t>() const {
|
Variant::operator PoolVector<uint8_t>() const {
|
||||||
|
|
||||||
if (type==RAW_ARRAY)
|
if (type==RAW_ARRAY)
|
||||||
return *reinterpret_cast<const DVector<uint8_t>* >(_data._mem);
|
return *reinterpret_cast<const PoolVector<uint8_t>* >(_data._mem);
|
||||||
else
|
else
|
||||||
return _convert_array_from_variant<DVector<uint8_t> >(*this);
|
return _convert_array_from_variant<PoolVector<uint8_t> >(*this);
|
||||||
}
|
}
|
||||||
Variant::operator DVector<int>() const {
|
Variant::operator PoolVector<int>() const {
|
||||||
|
|
||||||
if (type==INT_ARRAY)
|
if (type==INT_ARRAY)
|
||||||
return *reinterpret_cast<const DVector<int>* >(_data._mem);
|
return *reinterpret_cast<const PoolVector<int>* >(_data._mem);
|
||||||
else
|
else
|
||||||
return _convert_array_from_variant<DVector<int> >(*this);
|
return _convert_array_from_variant<PoolVector<int> >(*this);
|
||||||
|
|
||||||
}
|
}
|
||||||
Variant::operator DVector<real_t>() const {
|
Variant::operator PoolVector<real_t>() const {
|
||||||
|
|
||||||
if (type==REAL_ARRAY)
|
if (type==REAL_ARRAY)
|
||||||
return *reinterpret_cast<const DVector<real_t>* >(_data._mem);
|
return *reinterpret_cast<const PoolVector<real_t>* >(_data._mem);
|
||||||
else
|
else
|
||||||
return _convert_array_from_variant<DVector<real_t> >(*this);
|
return _convert_array_from_variant<PoolVector<real_t> >(*this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator DVector<String>() const {
|
Variant::operator PoolVector<String>() const {
|
||||||
|
|
||||||
if (type==STRING_ARRAY)
|
if (type==STRING_ARRAY)
|
||||||
return *reinterpret_cast<const DVector<String>* >(_data._mem);
|
return *reinterpret_cast<const PoolVector<String>* >(_data._mem);
|
||||||
else
|
else
|
||||||
return _convert_array_from_variant<DVector<String> >(*this);
|
return _convert_array_from_variant<PoolVector<String> >(*this);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Variant::operator DVector<Vector3>() const {
|
Variant::operator PoolVector<Vector3>() const {
|
||||||
|
|
||||||
if (type==VECTOR3_ARRAY)
|
if (type==VECTOR3_ARRAY)
|
||||||
return *reinterpret_cast<const DVector<Vector3>* >(_data._mem);
|
return *reinterpret_cast<const PoolVector<Vector3>* >(_data._mem);
|
||||||
else
|
else
|
||||||
return _convert_array_from_variant<DVector<Vector3> >(*this);
|
return _convert_array_from_variant<PoolVector<Vector3> >(*this);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Variant::operator DVector<Vector2>() const {
|
Variant::operator PoolVector<Vector2>() const {
|
||||||
|
|
||||||
if (type==VECTOR2_ARRAY)
|
if (type==VECTOR2_ARRAY)
|
||||||
return *reinterpret_cast<const DVector<Vector2>* >(_data._mem);
|
return *reinterpret_cast<const PoolVector<Vector2>* >(_data._mem);
|
||||||
else
|
else
|
||||||
return _convert_array_from_variant<DVector<Vector2> >(*this);
|
return _convert_array_from_variant<PoolVector<Vector2> >(*this);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator DVector<Color>() const {
|
Variant::operator PoolVector<Color>() const {
|
||||||
|
|
||||||
if (type==COLOR_ARRAY)
|
if (type==COLOR_ARRAY)
|
||||||
return *reinterpret_cast<const DVector<Color>* >(_data._mem);
|
return *reinterpret_cast<const PoolVector<Color>* >(_data._mem);
|
||||||
else
|
else
|
||||||
return _convert_array_from_variant<DVector<Color> >(*this);
|
return _convert_array_from_variant<PoolVector<Color> >(*this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1990,13 +1990,13 @@ Variant::operator Vector<RID>() const {
|
||||||
|
|
||||||
Variant::operator Vector<Vector2>() const {
|
Variant::operator Vector<Vector2>() const {
|
||||||
|
|
||||||
DVector<Vector2> from=operator DVector<Vector2>();
|
PoolVector<Vector2> from=operator PoolVector<Vector2>();
|
||||||
Vector<Vector2> to;
|
Vector<Vector2> to;
|
||||||
int len=from.size();
|
int len=from.size();
|
||||||
if (len==0)
|
if (len==0)
|
||||||
return Vector<Vector2>();
|
return Vector<Vector2>();
|
||||||
to.resize(len);
|
to.resize(len);
|
||||||
DVector<Vector2>::Read r = from.read();
|
PoolVector<Vector2>::Read r = from.read();
|
||||||
Vector2 *w = &to[0];
|
Vector2 *w = &to[0];
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
|
|
||||||
|
@ -2005,16 +2005,16 @@ Variant::operator Vector<Vector2>() const {
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator DVector<Plane>() const {
|
Variant::operator PoolVector<Plane>() const {
|
||||||
|
|
||||||
Array va= operator Array();
|
Array va= operator Array();
|
||||||
DVector<Plane> planes;
|
PoolVector<Plane> planes;
|
||||||
int va_size=va.size();
|
int va_size=va.size();
|
||||||
if (va_size==0)
|
if (va_size==0)
|
||||||
return planes;
|
return planes;
|
||||||
|
|
||||||
planes.resize(va_size);
|
planes.resize(va_size);
|
||||||
DVector<Plane>::Write w = planes.write();
|
PoolVector<Plane>::Write w = planes.write();
|
||||||
|
|
||||||
for(int i=0;i<va_size;i++)
|
for(int i=0;i<va_size;i++)
|
||||||
w[i]=va[i];
|
w[i]=va[i];
|
||||||
|
@ -2022,17 +2022,17 @@ Variant::operator DVector<Plane>() const {
|
||||||
return planes;
|
return planes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator DVector<Face3>() const {
|
Variant::operator PoolVector<Face3>() const {
|
||||||
|
|
||||||
DVector<Vector3> va= operator DVector<Vector3>();
|
PoolVector<Vector3> va= operator PoolVector<Vector3>();
|
||||||
DVector<Face3> faces;
|
PoolVector<Face3> faces;
|
||||||
int va_size=va.size();
|
int va_size=va.size();
|
||||||
if (va_size==0)
|
if (va_size==0)
|
||||||
return faces;
|
return faces;
|
||||||
|
|
||||||
faces.resize(va_size/3);
|
faces.resize(va_size/3);
|
||||||
DVector<Face3>::Write w = faces.write();
|
PoolVector<Face3>::Write w = faces.write();
|
||||||
DVector<Vector3>::Read r = va.read();
|
PoolVector<Vector3>::Read r = va.read();
|
||||||
|
|
||||||
for(int i=0;i<va_size;i++)
|
for(int i=0;i<va_size;i++)
|
||||||
w[i/3].vertex[i%3]=r[i];
|
w[i/3].vertex[i%3]=r[i];
|
||||||
|
@ -2072,7 +2072,7 @@ Variant::operator Vector<Variant>() const {
|
||||||
|
|
||||||
Variant::operator Vector<uint8_t>() const {
|
Variant::operator Vector<uint8_t>() const {
|
||||||
|
|
||||||
DVector<uint8_t> from=operator DVector<uint8_t>();
|
PoolVector<uint8_t> from=operator PoolVector<uint8_t>();
|
||||||
Vector<uint8_t> to;
|
Vector<uint8_t> to;
|
||||||
int len=from.size();
|
int len=from.size();
|
||||||
to.resize(len);
|
to.resize(len);
|
||||||
|
@ -2084,7 +2084,7 @@ Variant::operator Vector<uint8_t>() const {
|
||||||
}
|
}
|
||||||
Variant::operator Vector<int>() const {
|
Variant::operator Vector<int>() const {
|
||||||
|
|
||||||
DVector<int> from=operator DVector<int>();
|
PoolVector<int> from=operator PoolVector<int>();
|
||||||
Vector<int> to;
|
Vector<int> to;
|
||||||
int len=from.size();
|
int len=from.size();
|
||||||
to.resize(len);
|
to.resize(len);
|
||||||
|
@ -2096,7 +2096,7 @@ Variant::operator Vector<int>() const {
|
||||||
}
|
}
|
||||||
Variant::operator Vector<real_t>() const {
|
Variant::operator Vector<real_t>() const {
|
||||||
|
|
||||||
DVector<real_t> from=operator DVector<real_t>();
|
PoolVector<real_t> from=operator PoolVector<real_t>();
|
||||||
Vector<real_t> to;
|
Vector<real_t> to;
|
||||||
int len=from.size();
|
int len=from.size();
|
||||||
to.resize(len);
|
to.resize(len);
|
||||||
|
@ -2109,7 +2109,7 @@ Variant::operator Vector<real_t>() const {
|
||||||
|
|
||||||
Variant::operator Vector<String>() const {
|
Variant::operator Vector<String>() const {
|
||||||
|
|
||||||
DVector<String> from=operator DVector<String>();
|
PoolVector<String> from=operator PoolVector<String>();
|
||||||
Vector<String> to;
|
Vector<String> to;
|
||||||
int len=from.size();
|
int len=from.size();
|
||||||
to.resize(len);
|
to.resize(len);
|
||||||
|
@ -2122,13 +2122,13 @@ Variant::operator Vector<String>() const {
|
||||||
}
|
}
|
||||||
Variant::operator Vector<Vector3>() const {
|
Variant::operator Vector<Vector3>() const {
|
||||||
|
|
||||||
DVector<Vector3> from=operator DVector<Vector3>();
|
PoolVector<Vector3> from=operator PoolVector<Vector3>();
|
||||||
Vector<Vector3> to;
|
Vector<Vector3> to;
|
||||||
int len=from.size();
|
int len=from.size();
|
||||||
if (len==0)
|
if (len==0)
|
||||||
return Vector<Vector3>();
|
return Vector<Vector3>();
|
||||||
to.resize(len);
|
to.resize(len);
|
||||||
DVector<Vector3>::Read r = from.read();
|
PoolVector<Vector3>::Read r = from.read();
|
||||||
Vector3 *w = &to[0];
|
Vector3 *w = &to[0];
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
|
|
||||||
|
@ -2139,13 +2139,13 @@ Variant::operator Vector<Vector3>() const {
|
||||||
}
|
}
|
||||||
Variant::operator Vector<Color>() const {
|
Variant::operator Vector<Color>() const {
|
||||||
|
|
||||||
DVector<Color> from=operator DVector<Color>();
|
PoolVector<Color> from=operator PoolVector<Color>();
|
||||||
Vector<Color> to;
|
Vector<Color> to;
|
||||||
int len=from.size();
|
int len=from.size();
|
||||||
if (len==0)
|
if (len==0)
|
||||||
return Vector<Color>();
|
return Vector<Color>();
|
||||||
to.resize(len);
|
to.resize(len);
|
||||||
DVector<Color>::Read r = from.read();
|
PoolVector<Color>::Read r = from.read();
|
||||||
Color *w = &to[0];
|
Color *w = &to[0];
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
|
|
||||||
|
@ -2167,7 +2167,7 @@ Variant::operator IP_Address() const {
|
||||||
|
|
||||||
if (type==REAL_ARRAY || type==INT_ARRAY || type==RAW_ARRAY) {
|
if (type==REAL_ARRAY || type==INT_ARRAY || type==RAW_ARRAY) {
|
||||||
|
|
||||||
DVector<int> addr=operator DVector<int>();
|
PoolVector<int> addr=operator PoolVector<int>();
|
||||||
if (addr.size()==4) {
|
if (addr.size()==4) {
|
||||||
return IP_Address(addr.get(0),addr.get(1),addr.get(2),addr.get(3));
|
return IP_Address(addr.get(0),addr.get(1),addr.get(2),addr.get(3));
|
||||||
}
|
}
|
||||||
|
@ -2418,7 +2418,7 @@ Variant::Variant(const Array& p_array) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const DVector<Plane>& p_array) {
|
Variant::Variant(const PoolVector<Plane>& p_array) {
|
||||||
|
|
||||||
|
|
||||||
type=ARRAY;
|
type=ARRAY;
|
||||||
|
@ -2467,11 +2467,11 @@ Variant::Variant(const Vector<Vector2>& p_array) {
|
||||||
|
|
||||||
|
|
||||||
type=NIL;
|
type=NIL;
|
||||||
DVector<Vector2> v;
|
PoolVector<Vector2> v;
|
||||||
int len=p_array.size();
|
int len=p_array.size();
|
||||||
if (len>0) {
|
if (len>0) {
|
||||||
v.resize(len);
|
v.resize(len);
|
||||||
DVector<Vector2>::Write w = v.write();
|
PoolVector<Vector2>::Write w = v.write();
|
||||||
const Vector2 *r = p_array.ptr();
|
const Vector2 *r = p_array.ptr();
|
||||||
|
|
||||||
for (int i=0;i<len;i++)
|
for (int i=0;i<len;i++)
|
||||||
|
@ -2481,59 +2481,59 @@ Variant::Variant(const Vector<Vector2>& p_array) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Variant::Variant(const DVector<uint8_t>& p_raw_array) {
|
Variant::Variant(const PoolVector<uint8_t>& p_raw_array) {
|
||||||
|
|
||||||
type=RAW_ARRAY;
|
type=RAW_ARRAY;
|
||||||
memnew_placement( _data._mem, DVector<uint8_t>(p_raw_array) );
|
memnew_placement( _data._mem, PoolVector<uint8_t>(p_raw_array) );
|
||||||
|
|
||||||
}
|
}
|
||||||
Variant::Variant(const DVector<int>& p_int_array) {
|
Variant::Variant(const PoolVector<int>& p_int_array) {
|
||||||
|
|
||||||
type=INT_ARRAY;
|
type=INT_ARRAY;
|
||||||
memnew_placement( _data._mem, DVector<int>(p_int_array) );
|
memnew_placement( _data._mem, PoolVector<int>(p_int_array) );
|
||||||
|
|
||||||
}
|
}
|
||||||
Variant::Variant(const DVector<real_t>& p_real_array) {
|
Variant::Variant(const PoolVector<real_t>& p_real_array) {
|
||||||
|
|
||||||
type=REAL_ARRAY;
|
type=REAL_ARRAY;
|
||||||
memnew_placement( _data._mem, DVector<real_t>(p_real_array) );
|
memnew_placement( _data._mem, PoolVector<real_t>(p_real_array) );
|
||||||
|
|
||||||
}
|
}
|
||||||
Variant::Variant(const DVector<String>& p_string_array) {
|
Variant::Variant(const PoolVector<String>& p_string_array) {
|
||||||
|
|
||||||
type=STRING_ARRAY;
|
type=STRING_ARRAY;
|
||||||
memnew_placement( _data._mem, DVector<String>(p_string_array) );
|
memnew_placement( _data._mem, PoolVector<String>(p_string_array) );
|
||||||
|
|
||||||
}
|
}
|
||||||
Variant::Variant(const DVector<Vector3>& p_vector3_array) {
|
Variant::Variant(const PoolVector<Vector3>& p_vector3_array) {
|
||||||
|
|
||||||
type=VECTOR3_ARRAY;
|
type=VECTOR3_ARRAY;
|
||||||
memnew_placement( _data._mem, DVector<Vector3>(p_vector3_array) );
|
memnew_placement( _data._mem, PoolVector<Vector3>(p_vector3_array) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const DVector<Vector2>& p_vector2_array) {
|
Variant::Variant(const PoolVector<Vector2>& p_vector2_array) {
|
||||||
|
|
||||||
type=VECTOR2_ARRAY;
|
type=VECTOR2_ARRAY;
|
||||||
memnew_placement( _data._mem, DVector<Vector2>(p_vector2_array) );
|
memnew_placement( _data._mem, PoolVector<Vector2>(p_vector2_array) );
|
||||||
|
|
||||||
}
|
}
|
||||||
Variant::Variant(const DVector<Color>& p_color_array) {
|
Variant::Variant(const PoolVector<Color>& p_color_array) {
|
||||||
|
|
||||||
type=COLOR_ARRAY;
|
type=COLOR_ARRAY;
|
||||||
memnew_placement( _data._mem, DVector<Color>(p_color_array) );
|
memnew_placement( _data._mem, PoolVector<Color>(p_color_array) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const DVector<Face3>& p_face_array) {
|
Variant::Variant(const PoolVector<Face3>& p_face_array) {
|
||||||
|
|
||||||
|
|
||||||
DVector<Vector3> vertices;
|
PoolVector<Vector3> vertices;
|
||||||
int face_count=p_face_array.size();
|
int face_count=p_face_array.size();
|
||||||
vertices.resize(face_count*3);
|
vertices.resize(face_count*3);
|
||||||
|
|
||||||
if (face_count) {
|
if (face_count) {
|
||||||
DVector<Face3>::Read r = p_face_array.read();
|
PoolVector<Face3>::Read r = p_face_array.read();
|
||||||
DVector<Vector3>::Write w = vertices.write();
|
PoolVector<Vector3>::Write w = vertices.write();
|
||||||
|
|
||||||
for(int i=0;i<face_count;i++) {
|
for(int i=0;i<face_count;i++) {
|
||||||
|
|
||||||
|
@ -2541,8 +2541,8 @@ Variant::Variant(const DVector<Face3>& p_face_array) {
|
||||||
w[i*3+j]=r[i].vertex[j];
|
w[i*3+j]=r[i].vertex[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
r=DVector<Face3>::Read();
|
r=PoolVector<Face3>::Read();
|
||||||
w=DVector<Vector3>::Write();
|
w=PoolVector<Vector3>::Write();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2567,7 +2567,7 @@ Variant::Variant(const Vector<Variant>& p_array) {
|
||||||
Variant::Variant(const Vector<uint8_t>& p_array) {
|
Variant::Variant(const Vector<uint8_t>& p_array) {
|
||||||
|
|
||||||
type=NIL;
|
type=NIL;
|
||||||
DVector<uint8_t> v;
|
PoolVector<uint8_t> v;
|
||||||
int len=p_array.size();
|
int len=p_array.size();
|
||||||
v.resize(len);
|
v.resize(len);
|
||||||
for (int i=0;i<len;i++)
|
for (int i=0;i<len;i++)
|
||||||
|
@ -2578,7 +2578,7 @@ Variant::Variant(const Vector<uint8_t>& p_array) {
|
||||||
Variant::Variant(const Vector<int>& p_array) {
|
Variant::Variant(const Vector<int>& p_array) {
|
||||||
|
|
||||||
type=NIL;
|
type=NIL;
|
||||||
DVector<int> v;
|
PoolVector<int> v;
|
||||||
int len=p_array.size();
|
int len=p_array.size();
|
||||||
v.resize(len);
|
v.resize(len);
|
||||||
for (int i=0;i<len;i++)
|
for (int i=0;i<len;i++)
|
||||||
|
@ -2589,7 +2589,7 @@ Variant::Variant(const Vector<int>& p_array) {
|
||||||
Variant::Variant(const Vector<real_t>& p_array) {
|
Variant::Variant(const Vector<real_t>& p_array) {
|
||||||
|
|
||||||
type=NIL;
|
type=NIL;
|
||||||
DVector<real_t> v;
|
PoolVector<real_t> v;
|
||||||
int len=p_array.size();
|
int len=p_array.size();
|
||||||
v.resize(len);
|
v.resize(len);
|
||||||
for (int i=0;i<len;i++)
|
for (int i=0;i<len;i++)
|
||||||
|
@ -2600,7 +2600,7 @@ Variant::Variant(const Vector<real_t>& p_array) {
|
||||||
Variant::Variant(const Vector<String>& p_array) {
|
Variant::Variant(const Vector<String>& p_array) {
|
||||||
|
|
||||||
type=NIL;
|
type=NIL;
|
||||||
DVector<String> v;
|
PoolVector<String> v;
|
||||||
int len=p_array.size();
|
int len=p_array.size();
|
||||||
v.resize(len);
|
v.resize(len);
|
||||||
for (int i=0;i<len;i++)
|
for (int i=0;i<len;i++)
|
||||||
|
@ -2611,11 +2611,11 @@ Variant::Variant(const Vector<String>& p_array) {
|
||||||
Variant::Variant(const Vector<Vector3>& p_array) {
|
Variant::Variant(const Vector<Vector3>& p_array) {
|
||||||
|
|
||||||
type=NIL;
|
type=NIL;
|
||||||
DVector<Vector3> v;
|
PoolVector<Vector3> v;
|
||||||
int len=p_array.size();
|
int len=p_array.size();
|
||||||
if (len>0) {
|
if (len>0) {
|
||||||
v.resize(len);
|
v.resize(len);
|
||||||
DVector<Vector3>::Write w = v.write();
|
PoolVector<Vector3>::Write w = v.write();
|
||||||
const Vector3 *r = p_array.ptr();
|
const Vector3 *r = p_array.ptr();
|
||||||
|
|
||||||
for (int i=0;i<len;i++)
|
for (int i=0;i<len;i++)
|
||||||
|
@ -2627,7 +2627,7 @@ Variant::Variant(const Vector<Vector3>& p_array) {
|
||||||
Variant::Variant(const Vector<Color>& p_array) {
|
Variant::Variant(const Vector<Color>& p_array) {
|
||||||
|
|
||||||
type=NIL;
|
type=NIL;
|
||||||
DVector<Color> v;
|
PoolVector<Color> v;
|
||||||
int len=p_array.size();
|
int len=p_array.size();
|
||||||
v.resize(len);
|
v.resize(len);
|
||||||
for (int i=0;i<len;i++)
|
for (int i=0;i<len;i++)
|
||||||
|
@ -2826,27 +2826,27 @@ uint32_t Variant::hash() const {
|
||||||
} break;
|
} break;
|
||||||
case RAW_ARRAY: {
|
case RAW_ARRAY: {
|
||||||
|
|
||||||
const DVector<uint8_t>& arr = *reinterpret_cast<const DVector<uint8_t>* >(_data._mem);
|
const PoolVector<uint8_t>& arr = *reinterpret_cast<const PoolVector<uint8_t>* >(_data._mem);
|
||||||
int len = arr.size();
|
int len = arr.size();
|
||||||
DVector<uint8_t>::Read r = arr.read();
|
PoolVector<uint8_t>::Read r = arr.read();
|
||||||
|
|
||||||
return hash_djb2_buffer((uint8_t*)&r[0],len);
|
return hash_djb2_buffer((uint8_t*)&r[0],len);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case INT_ARRAY: {
|
case INT_ARRAY: {
|
||||||
|
|
||||||
const DVector<int>& arr = *reinterpret_cast<const DVector<int>* >(_data._mem);
|
const PoolVector<int>& arr = *reinterpret_cast<const PoolVector<int>* >(_data._mem);
|
||||||
int len = arr.size();
|
int len = arr.size();
|
||||||
DVector<int>::Read r = arr.read();
|
PoolVector<int>::Read r = arr.read();
|
||||||
|
|
||||||
return hash_djb2_buffer((uint8_t*)&r[0],len*sizeof(int));
|
return hash_djb2_buffer((uint8_t*)&r[0],len*sizeof(int));
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case REAL_ARRAY: {
|
case REAL_ARRAY: {
|
||||||
|
|
||||||
const DVector<real_t>& arr = *reinterpret_cast<const DVector<real_t>* >(_data._mem);
|
const PoolVector<real_t>& arr = *reinterpret_cast<const PoolVector<real_t>* >(_data._mem);
|
||||||
int len = arr.size();
|
int len = arr.size();
|
||||||
DVector<real_t>::Read r = arr.read();
|
PoolVector<real_t>::Read r = arr.read();
|
||||||
|
|
||||||
return hash_djb2_buffer((uint8_t*)&r[0],len*sizeof(real_t));
|
return hash_djb2_buffer((uint8_t*)&r[0],len*sizeof(real_t));
|
||||||
|
|
||||||
|
@ -2854,9 +2854,9 @@ uint32_t Variant::hash() const {
|
||||||
case STRING_ARRAY: {
|
case STRING_ARRAY: {
|
||||||
|
|
||||||
uint32_t hash=5831;
|
uint32_t hash=5831;
|
||||||
const DVector<String>& arr = *reinterpret_cast<const DVector<String>* >(_data._mem);
|
const PoolVector<String>& arr = *reinterpret_cast<const PoolVector<String>* >(_data._mem);
|
||||||
int len = arr.size();
|
int len = arr.size();
|
||||||
DVector<String>::Read r = arr.read();
|
PoolVector<String>::Read r = arr.read();
|
||||||
|
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
hash = hash_djb2_one_32(r[i].hash(),hash);
|
hash = hash_djb2_one_32(r[i].hash(),hash);
|
||||||
|
@ -2867,9 +2867,9 @@ uint32_t Variant::hash() const {
|
||||||
case VECTOR2_ARRAY: {
|
case VECTOR2_ARRAY: {
|
||||||
|
|
||||||
uint32_t hash=5831;
|
uint32_t hash=5831;
|
||||||
const DVector<Vector2>& arr = *reinterpret_cast<const DVector<Vector2>* >(_data._mem);
|
const PoolVector<Vector2>& arr = *reinterpret_cast<const PoolVector<Vector2>* >(_data._mem);
|
||||||
int len = arr.size();
|
int len = arr.size();
|
||||||
DVector<Vector2>::Read r = arr.read();
|
PoolVector<Vector2>::Read r = arr.read();
|
||||||
|
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
hash = hash_djb2_one_float(r[i].x,hash);
|
hash = hash_djb2_one_float(r[i].x,hash);
|
||||||
|
@ -2882,9 +2882,9 @@ uint32_t Variant::hash() const {
|
||||||
case VECTOR3_ARRAY: {
|
case VECTOR3_ARRAY: {
|
||||||
|
|
||||||
uint32_t hash=5831;
|
uint32_t hash=5831;
|
||||||
const DVector<Vector3>& arr = *reinterpret_cast<const DVector<Vector3>* >(_data._mem);
|
const PoolVector<Vector3>& arr = *reinterpret_cast<const PoolVector<Vector3>* >(_data._mem);
|
||||||
int len = arr.size();
|
int len = arr.size();
|
||||||
DVector<Vector3>::Read r = arr.read();
|
PoolVector<Vector3>::Read r = arr.read();
|
||||||
|
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
hash = hash_djb2_one_float(r[i].x,hash);
|
hash = hash_djb2_one_float(r[i].x,hash);
|
||||||
|
@ -2898,9 +2898,9 @@ uint32_t Variant::hash() const {
|
||||||
case COLOR_ARRAY: {
|
case COLOR_ARRAY: {
|
||||||
|
|
||||||
uint32_t hash=5831;
|
uint32_t hash=5831;
|
||||||
const DVector<Color>& arr = *reinterpret_cast<const DVector<Color>* >(_data._mem);
|
const PoolVector<Color>& arr = *reinterpret_cast<const PoolVector<Color>* >(_data._mem);
|
||||||
int len = arr.size();
|
int len = arr.size();
|
||||||
DVector<Color>::Read r = arr.read();
|
PoolVector<Color>::Read r = arr.read();
|
||||||
|
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
hash = hash_djb2_one_float(r[i].r,hash);
|
hash = hash_djb2_one_float(r[i].r,hash);
|
||||||
|
|
|
@ -63,13 +63,13 @@ struct PropertyInfo;
|
||||||
struct MethodInfo;
|
struct MethodInfo;
|
||||||
|
|
||||||
|
|
||||||
typedef DVector<uint8_t> ByteArray;
|
typedef PoolVector<uint8_t> ByteArray;
|
||||||
typedef DVector<int> IntArray;
|
typedef PoolVector<int> IntArray;
|
||||||
typedef DVector<real_t> RealArray;
|
typedef PoolVector<real_t> RealArray;
|
||||||
typedef DVector<String> StringArray;
|
typedef PoolVector<String> StringArray;
|
||||||
typedef DVector<Vector2> Vector2Array;
|
typedef PoolVector<Vector2> Vector2Array;
|
||||||
typedef DVector<Vector3> Vector3Array;
|
typedef PoolVector<Vector3> Vector3Array;
|
||||||
typedef DVector<Color> ColorArray;
|
typedef PoolVector<Color> ColorArray;
|
||||||
|
|
||||||
class Variant {
|
class Variant {
|
||||||
public:
|
public:
|
||||||
|
@ -227,14 +227,14 @@ public:
|
||||||
operator Dictionary() const;
|
operator Dictionary() const;
|
||||||
operator Array() const;
|
operator Array() const;
|
||||||
|
|
||||||
operator DVector<uint8_t>() const;
|
operator PoolVector<uint8_t>() const;
|
||||||
operator DVector<int>() const;
|
operator PoolVector<int>() const;
|
||||||
operator DVector<real_t>() const;
|
operator PoolVector<real_t>() const;
|
||||||
operator DVector<String>() const;
|
operator PoolVector<String>() const;
|
||||||
operator DVector<Vector3>() const;
|
operator PoolVector<Vector3>() const;
|
||||||
operator DVector<Color>() const;
|
operator PoolVector<Color>() const;
|
||||||
operator DVector<Plane>() const;
|
operator PoolVector<Plane>() const;
|
||||||
operator DVector<Face3>() const;
|
operator PoolVector<Face3>() const;
|
||||||
|
|
||||||
|
|
||||||
operator Vector<Variant>() const;
|
operator Vector<Variant>() const;
|
||||||
|
@ -246,7 +246,7 @@ public:
|
||||||
operator Vector<Color>() const;
|
operator Vector<Color>() const;
|
||||||
operator Vector<RID>() const;
|
operator Vector<RID>() const;
|
||||||
operator Vector<Vector2>() const;
|
operator Vector<Vector2>() const;
|
||||||
operator DVector<Vector2>() const;
|
operator PoolVector<Vector2>() const;
|
||||||
operator Vector<Plane>() const;
|
operator Vector<Plane>() const;
|
||||||
|
|
||||||
// some core type enums to convert to
|
// some core type enums to convert to
|
||||||
|
@ -295,14 +295,14 @@ public:
|
||||||
Variant(const Dictionary& p_dictionary);
|
Variant(const Dictionary& p_dictionary);
|
||||||
|
|
||||||
Variant(const Array& p_array);
|
Variant(const Array& p_array);
|
||||||
Variant(const DVector<Plane>& p_array); // helper
|
Variant(const PoolVector<Plane>& p_array); // helper
|
||||||
Variant(const DVector<uint8_t>& p_raw_array);
|
Variant(const PoolVector<uint8_t>& p_raw_array);
|
||||||
Variant(const DVector<int>& p_int_array);
|
Variant(const PoolVector<int>& p_int_array);
|
||||||
Variant(const DVector<real_t>& p_real_array);
|
Variant(const PoolVector<real_t>& p_real_array);
|
||||||
Variant(const DVector<String>& p_string_array);
|
Variant(const PoolVector<String>& p_string_array);
|
||||||
Variant(const DVector<Vector3>& p_vector3_array);
|
Variant(const PoolVector<Vector3>& p_vector3_array);
|
||||||
Variant(const DVector<Color>& p_color_array);
|
Variant(const PoolVector<Color>& p_color_array);
|
||||||
Variant(const DVector<Face3>& p_face_array);
|
Variant(const PoolVector<Face3>& p_face_array);
|
||||||
|
|
||||||
|
|
||||||
Variant(const Vector<Variant>& p_array);
|
Variant(const Vector<Variant>& p_array);
|
||||||
|
@ -315,7 +315,7 @@ public:
|
||||||
Variant(const Vector<Plane>& p_array); // helper
|
Variant(const Vector<Plane>& p_array); // helper
|
||||||
Variant(const Vector<RID>& p_array); // helper
|
Variant(const Vector<RID>& p_array); // helper
|
||||||
Variant(const Vector<Vector2>& p_array); // helper
|
Variant(const Vector<Vector2>& p_array); // helper
|
||||||
Variant(const DVector<Vector2>& p_array); // helper
|
Variant(const PoolVector<Vector2>& p_array); // helper
|
||||||
|
|
||||||
Variant(const IP_Address& p_address);
|
Variant(const IP_Address& p_address);
|
||||||
|
|
||||||
|
|
|
@ -305,7 +305,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
|
||||||
retval.resize(len);
|
retval.resize(len);
|
||||||
ByteArray::Write w = retval.write();
|
ByteArray::Write w = retval.write();
|
||||||
copymem(w.ptr(), charstr.ptr(), len);
|
copymem(w.ptr(), charstr.ptr(), len);
|
||||||
w = DVector<uint8_t>::Write();
|
w = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
r_ret = retval;
|
r_ret = retval;
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
|
||||||
retval.resize(len);
|
retval.resize(len);
|
||||||
ByteArray::Write w = retval.write();
|
ByteArray::Write w = retval.write();
|
||||||
copymem(w.ptr(), charstr.ptr(), len);
|
copymem(w.ptr(), charstr.ptr(), len);
|
||||||
w = DVector<uint8_t>::Write();
|
w = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
r_ret = retval;
|
r_ret = retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,16 +186,16 @@ case m_name: { \
|
||||||
r_valid=false;\
|
r_valid=false;\
|
||||||
return;\
|
return;\
|
||||||
}\
|
}\
|
||||||
const DVector<m_type> &array_a=*reinterpret_cast<const DVector<m_type> *>(p_a._data._mem);\
|
const PoolVector<m_type> &array_a=*reinterpret_cast<const PoolVector<m_type> *>(p_a._data._mem);\
|
||||||
const DVector<m_type> &array_b=*reinterpret_cast<const DVector<m_type> *>(p_b._data._mem);\
|
const PoolVector<m_type> &array_b=*reinterpret_cast<const PoolVector<m_type> *>(p_b._data._mem);\
|
||||||
\
|
\
|
||||||
int a_len = array_a.size();\
|
int a_len = array_a.size();\
|
||||||
if (a_len m_opa array_b.size()){\
|
if (a_len m_opa array_b.size()){\
|
||||||
_RETURN( m_ret_s);\
|
_RETURN( m_ret_s);\
|
||||||
}else {\
|
}else {\
|
||||||
\
|
\
|
||||||
DVector<m_type>::Read ra = array_a.read();\
|
PoolVector<m_type>::Read ra = array_a.read();\
|
||||||
DVector<m_type>::Read rb = array_b.read();\
|
PoolVector<m_type>::Read rb = array_b.read();\
|
||||||
\
|
\
|
||||||
for(int i=0;i<a_len;i++) {\
|
for(int i=0;i<a_len;i++) {\
|
||||||
if (ra[i] m_opb rb[i])\
|
if (ra[i] m_opb rb[i])\
|
||||||
|
@ -212,9 +212,9 @@ case m_name: { \
|
||||||
r_valid=false;\
|
r_valid=false;\
|
||||||
_RETURN( NIL);\
|
_RETURN( NIL);\
|
||||||
}\
|
}\
|
||||||
const DVector<m_type> &array_a=*reinterpret_cast<const DVector<m_type> *>(p_a._data._mem);\
|
const PoolVector<m_type> &array_a=*reinterpret_cast<const PoolVector<m_type> *>(p_a._data._mem);\
|
||||||
const DVector<m_type> &array_b=*reinterpret_cast<const DVector<m_type> *>(p_b._data._mem);\
|
const PoolVector<m_type> &array_b=*reinterpret_cast<const PoolVector<m_type> *>(p_b._data._mem);\
|
||||||
DVector<m_type> sum = array_a;\
|
PoolVector<m_type> sum = array_a;\
|
||||||
sum.append_array(array_b);\
|
sum.append_array(array_b);\
|
||||||
_RETURN( sum );\
|
_RETURN( sum );\
|
||||||
}
|
}
|
||||||
|
@ -1049,10 +1049,10 @@ Variant Variant::get_named(const StringName& p_index, bool *r_valid) const {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
#define DEFAULT_OP_DVECTOR_SET(m_name, dv_type, skip_cond)\
|
#define DEFAULT_OP_DVECTOR_SET(m_name, dv_type, skip_cond)\
|
||||||
DEFAULT_OP_ARRAY_CMD(m_name, DVector<dv_type>, if(skip_cond) return;, arr->set(index, p_value);return)
|
DEFAULT_OP_ARRAY_CMD(m_name, PoolVector<dv_type>, if(skip_cond) return;, arr->set(index, p_value);return)
|
||||||
|
|
||||||
#define DEFAULT_OP_DVECTOR_GET(m_name, dv_type)\
|
#define DEFAULT_OP_DVECTOR_GET(m_name, dv_type)\
|
||||||
DEFAULT_OP_ARRAY_CMD(m_name, const DVector<dv_type>, ;, return arr->get(index))
|
DEFAULT_OP_ARRAY_CMD(m_name, const PoolVector<dv_type>, ;, return arr->get(index))
|
||||||
|
|
||||||
void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid) {
|
void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid) {
|
||||||
|
|
||||||
|
@ -2561,10 +2561,10 @@ bool Variant::in(const Variant& p_index, bool *r_valid) const {
|
||||||
if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
|
if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
|
||||||
|
|
||||||
int index = p_index;
|
int index = p_index;
|
||||||
const DVector<uint8_t> *arr=reinterpret_cast<const DVector<uint8_t>* >(_data._mem);
|
const PoolVector<uint8_t> *arr=reinterpret_cast<const PoolVector<uint8_t>* >(_data._mem);
|
||||||
int l=arr->size();
|
int l=arr->size();
|
||||||
if (l) {
|
if (l) {
|
||||||
DVector<uint8_t>::Read r = arr->read();
|
PoolVector<uint8_t>::Read r = arr->read();
|
||||||
for(int i=0;i<l;i++) {
|
for(int i=0;i<l;i++) {
|
||||||
if (r[i]==index)
|
if (r[i]==index)
|
||||||
return true;
|
return true;
|
||||||
|
@ -2580,10 +2580,10 @@ bool Variant::in(const Variant& p_index, bool *r_valid) const {
|
||||||
if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
|
if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
|
||||||
|
|
||||||
int index = p_index;
|
int index = p_index;
|
||||||
const DVector<int> *arr=reinterpret_cast<const DVector<int>* >(_data._mem);
|
const PoolVector<int> *arr=reinterpret_cast<const PoolVector<int>* >(_data._mem);
|
||||||
int l=arr->size();
|
int l=arr->size();
|
||||||
if (l) {
|
if (l) {
|
||||||
DVector<int>::Read r = arr->read();
|
PoolVector<int>::Read r = arr->read();
|
||||||
for(int i=0;i<l;i++) {
|
for(int i=0;i<l;i++) {
|
||||||
if (r[i]==index)
|
if (r[i]==index)
|
||||||
return true;
|
return true;
|
||||||
|
@ -2599,10 +2599,10 @@ bool Variant::in(const Variant& p_index, bool *r_valid) const {
|
||||||
if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
|
if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
|
||||||
|
|
||||||
real_t index = p_index;
|
real_t index = p_index;
|
||||||
const DVector<real_t> *arr=reinterpret_cast<const DVector<real_t>* >(_data._mem);
|
const PoolVector<real_t> *arr=reinterpret_cast<const PoolVector<real_t>* >(_data._mem);
|
||||||
int l=arr->size();
|
int l=arr->size();
|
||||||
if (l) {
|
if (l) {
|
||||||
DVector<real_t>::Read r = arr->read();
|
PoolVector<real_t>::Read r = arr->read();
|
||||||
for(int i=0;i<l;i++) {
|
for(int i=0;i<l;i++) {
|
||||||
if (r[i]==index)
|
if (r[i]==index)
|
||||||
return true;
|
return true;
|
||||||
|
@ -2618,11 +2618,11 @@ bool Variant::in(const Variant& p_index, bool *r_valid) const {
|
||||||
if (p_index.get_type()==Variant::STRING) {
|
if (p_index.get_type()==Variant::STRING) {
|
||||||
|
|
||||||
String index = p_index;
|
String index = p_index;
|
||||||
const DVector<String> *arr=reinterpret_cast<const DVector<String>* >(_data._mem);
|
const PoolVector<String> *arr=reinterpret_cast<const PoolVector<String>* >(_data._mem);
|
||||||
|
|
||||||
int l=arr->size();
|
int l=arr->size();
|
||||||
if (l) {
|
if (l) {
|
||||||
DVector<String>::Read r = arr->read();
|
PoolVector<String>::Read r = arr->read();
|
||||||
for(int i=0;i<l;i++) {
|
for(int i=0;i<l;i++) {
|
||||||
if (r[i]==index)
|
if (r[i]==index)
|
||||||
return true;
|
return true;
|
||||||
|
@ -2638,11 +2638,11 @@ bool Variant::in(const Variant& p_index, bool *r_valid) const {
|
||||||
if (p_index.get_type()==Variant::VECTOR2) {
|
if (p_index.get_type()==Variant::VECTOR2) {
|
||||||
|
|
||||||
Vector2 index = p_index;
|
Vector2 index = p_index;
|
||||||
const DVector<Vector2> *arr=reinterpret_cast<const DVector<Vector2>* >(_data._mem);
|
const PoolVector<Vector2> *arr=reinterpret_cast<const PoolVector<Vector2>* >(_data._mem);
|
||||||
|
|
||||||
int l=arr->size();
|
int l=arr->size();
|
||||||
if (l) {
|
if (l) {
|
||||||
DVector<Vector2>::Read r = arr->read();
|
PoolVector<Vector2>::Read r = arr->read();
|
||||||
for(int i=0;i<l;i++) {
|
for(int i=0;i<l;i++) {
|
||||||
if (r[i]==index)
|
if (r[i]==index)
|
||||||
return true;
|
return true;
|
||||||
|
@ -2658,11 +2658,11 @@ bool Variant::in(const Variant& p_index, bool *r_valid) const {
|
||||||
if (p_index.get_type()==Variant::VECTOR3) {
|
if (p_index.get_type()==Variant::VECTOR3) {
|
||||||
|
|
||||||
Vector3 index = p_index;
|
Vector3 index = p_index;
|
||||||
const DVector<Vector3> *arr=reinterpret_cast<const DVector<Vector3>* >(_data._mem);
|
const PoolVector<Vector3> *arr=reinterpret_cast<const PoolVector<Vector3>* >(_data._mem);
|
||||||
|
|
||||||
int l=arr->size();
|
int l=arr->size();
|
||||||
if (l) {
|
if (l) {
|
||||||
DVector<Vector3>::Read r = arr->read();
|
PoolVector<Vector3>::Read r = arr->read();
|
||||||
for(int i=0;i<l;i++) {
|
for(int i=0;i<l;i++) {
|
||||||
if (r[i]==index)
|
if (r[i]==index)
|
||||||
return true;
|
return true;
|
||||||
|
@ -2679,12 +2679,12 @@ bool Variant::in(const Variant& p_index, bool *r_valid) const {
|
||||||
if (p_index.get_type()==Variant::COLOR) {
|
if (p_index.get_type()==Variant::COLOR) {
|
||||||
|
|
||||||
Color index = p_index;
|
Color index = p_index;
|
||||||
const DVector<Color> *arr=reinterpret_cast<const DVector<Color>* >(_data._mem);
|
const PoolVector<Color> *arr=reinterpret_cast<const PoolVector<Color>* >(_data._mem);
|
||||||
|
|
||||||
|
|
||||||
int l=arr->size();
|
int l=arr->size();
|
||||||
if (l) {
|
if (l) {
|
||||||
DVector<Color>::Read r = arr->read();
|
PoolVector<Color>::Read r = arr->read();
|
||||||
for(int i=0;i<l;i++) {
|
for(int i=0;i<l;i++) {
|
||||||
if (r[i]==index)
|
if (r[i]==index)
|
||||||
return true;
|
return true;
|
||||||
|
@ -2992,7 +2992,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const {
|
||||||
return true;
|
return true;
|
||||||
} break;
|
} break;
|
||||||
case RAW_ARRAY: {
|
case RAW_ARRAY: {
|
||||||
const DVector<uint8_t> *arr=reinterpret_cast<const DVector<uint8_t>*>(_data._mem);
|
const PoolVector<uint8_t> *arr=reinterpret_cast<const PoolVector<uint8_t>*>(_data._mem);
|
||||||
if (arr->size()==0)
|
if (arr->size()==0)
|
||||||
return false;
|
return false;
|
||||||
r_iter=0;
|
r_iter=0;
|
||||||
|
@ -3000,7 +3000,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const {
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case INT_ARRAY: {
|
case INT_ARRAY: {
|
||||||
const DVector<int> *arr=reinterpret_cast<const DVector<int>*>(_data._mem);
|
const PoolVector<int> *arr=reinterpret_cast<const PoolVector<int>*>(_data._mem);
|
||||||
if (arr->size()==0)
|
if (arr->size()==0)
|
||||||
return false;
|
return false;
|
||||||
r_iter=0;
|
r_iter=0;
|
||||||
|
@ -3008,7 +3008,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const {
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case REAL_ARRAY: {
|
case REAL_ARRAY: {
|
||||||
const DVector<real_t> *arr=reinterpret_cast<const DVector<real_t>*>(_data._mem);
|
const PoolVector<real_t> *arr=reinterpret_cast<const PoolVector<real_t>*>(_data._mem);
|
||||||
if (arr->size()==0)
|
if (arr->size()==0)
|
||||||
return false;
|
return false;
|
||||||
r_iter=0;
|
r_iter=0;
|
||||||
|
@ -3016,7 +3016,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const {
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case STRING_ARRAY: {
|
case STRING_ARRAY: {
|
||||||
const DVector<String> *arr=reinterpret_cast<const DVector<String>*>(_data._mem);
|
const PoolVector<String> *arr=reinterpret_cast<const PoolVector<String>*>(_data._mem);
|
||||||
if (arr->size()==0)
|
if (arr->size()==0)
|
||||||
return false;
|
return false;
|
||||||
r_iter=0;
|
r_iter=0;
|
||||||
|
@ -3024,7 +3024,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const {
|
||||||
} break;
|
} break;
|
||||||
case VECTOR2_ARRAY: {
|
case VECTOR2_ARRAY: {
|
||||||
|
|
||||||
const DVector<Vector2> *arr=reinterpret_cast<const DVector<Vector2>*>(_data._mem);
|
const PoolVector<Vector2> *arr=reinterpret_cast<const PoolVector<Vector2>*>(_data._mem);
|
||||||
if (arr->size()==0)
|
if (arr->size()==0)
|
||||||
return false;
|
return false;
|
||||||
r_iter=0;
|
r_iter=0;
|
||||||
|
@ -3032,7 +3032,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const {
|
||||||
} break;
|
} break;
|
||||||
case VECTOR3_ARRAY: {
|
case VECTOR3_ARRAY: {
|
||||||
|
|
||||||
const DVector<Vector3> *arr=reinterpret_cast<const DVector<Vector3>*>(_data._mem);
|
const PoolVector<Vector3> *arr=reinterpret_cast<const PoolVector<Vector3>*>(_data._mem);
|
||||||
if (arr->size()==0)
|
if (arr->size()==0)
|
||||||
return false;
|
return false;
|
||||||
r_iter=0;
|
r_iter=0;
|
||||||
|
@ -3040,7 +3040,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const {
|
||||||
} break;
|
} break;
|
||||||
case COLOR_ARRAY: {
|
case COLOR_ARRAY: {
|
||||||
|
|
||||||
const DVector<Color> *arr=reinterpret_cast<const DVector<Color>*>(_data._mem);
|
const PoolVector<Color> *arr=reinterpret_cast<const PoolVector<Color>*>(_data._mem);
|
||||||
if (arr->size()==0)
|
if (arr->size()==0)
|
||||||
return false;
|
return false;
|
||||||
r_iter=0;
|
r_iter=0;
|
||||||
|
@ -3123,7 +3123,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const {
|
||||||
return true;
|
return true;
|
||||||
} break;
|
} break;
|
||||||
case RAW_ARRAY: {
|
case RAW_ARRAY: {
|
||||||
const DVector<uint8_t> *arr=reinterpret_cast<const DVector<uint8_t>*>(_data._mem);
|
const PoolVector<uint8_t> *arr=reinterpret_cast<const PoolVector<uint8_t>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
idx++;
|
idx++;
|
||||||
if (idx>=arr->size())
|
if (idx>=arr->size())
|
||||||
|
@ -3133,7 +3133,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const {
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case INT_ARRAY: {
|
case INT_ARRAY: {
|
||||||
const DVector<int> *arr=reinterpret_cast<const DVector<int>*>(_data._mem);
|
const PoolVector<int> *arr=reinterpret_cast<const PoolVector<int>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
idx++;
|
idx++;
|
||||||
if (idx>=arr->size())
|
if (idx>=arr->size())
|
||||||
|
@ -3143,7 +3143,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const {
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case REAL_ARRAY: {
|
case REAL_ARRAY: {
|
||||||
const DVector<real_t> *arr=reinterpret_cast<const DVector<real_t>*>(_data._mem);
|
const PoolVector<real_t> *arr=reinterpret_cast<const PoolVector<real_t>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
idx++;
|
idx++;
|
||||||
if (idx>=arr->size())
|
if (idx>=arr->size())
|
||||||
|
@ -3153,7 +3153,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const {
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case STRING_ARRAY: {
|
case STRING_ARRAY: {
|
||||||
const DVector<String> *arr=reinterpret_cast<const DVector<String>*>(_data._mem);
|
const PoolVector<String> *arr=reinterpret_cast<const PoolVector<String>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
idx++;
|
idx++;
|
||||||
if (idx>=arr->size())
|
if (idx>=arr->size())
|
||||||
|
@ -3163,7 +3163,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const {
|
||||||
} break;
|
} break;
|
||||||
case VECTOR2_ARRAY: {
|
case VECTOR2_ARRAY: {
|
||||||
|
|
||||||
const DVector<Vector2> *arr=reinterpret_cast<const DVector<Vector2>*>(_data._mem);
|
const PoolVector<Vector2> *arr=reinterpret_cast<const PoolVector<Vector2>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
idx++;
|
idx++;
|
||||||
if (idx>=arr->size())
|
if (idx>=arr->size())
|
||||||
|
@ -3173,7 +3173,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const {
|
||||||
} break;
|
} break;
|
||||||
case VECTOR3_ARRAY: {
|
case VECTOR3_ARRAY: {
|
||||||
|
|
||||||
const DVector<Vector3> *arr=reinterpret_cast<const DVector<Vector3>*>(_data._mem);
|
const PoolVector<Vector3> *arr=reinterpret_cast<const PoolVector<Vector3>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
idx++;
|
idx++;
|
||||||
if (idx>=arr->size())
|
if (idx>=arr->size())
|
||||||
|
@ -3183,7 +3183,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const {
|
||||||
} break;
|
} break;
|
||||||
case COLOR_ARRAY: {
|
case COLOR_ARRAY: {
|
||||||
|
|
||||||
const DVector<Color> *arr=reinterpret_cast<const DVector<Color>*>(_data._mem);
|
const PoolVector<Color> *arr=reinterpret_cast<const PoolVector<Color>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
idx++;
|
idx++;
|
||||||
if (idx>=arr->size())
|
if (idx>=arr->size())
|
||||||
|
@ -3255,7 +3255,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const {
|
||||||
return arr->get(idx);
|
return arr->get(idx);
|
||||||
} break;
|
} break;
|
||||||
case RAW_ARRAY: {
|
case RAW_ARRAY: {
|
||||||
const DVector<uint8_t> *arr=reinterpret_cast<const DVector<uint8_t>*>(_data._mem);
|
const PoolVector<uint8_t> *arr=reinterpret_cast<const PoolVector<uint8_t>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (idx<0 || idx>=arr->size()) {
|
if (idx<0 || idx>=arr->size()) {
|
||||||
|
@ -3266,7 +3266,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const {
|
||||||
return arr->get(idx);
|
return arr->get(idx);
|
||||||
} break;
|
} break;
|
||||||
case INT_ARRAY: {
|
case INT_ARRAY: {
|
||||||
const DVector<int> *arr=reinterpret_cast<const DVector<int>*>(_data._mem);
|
const PoolVector<int> *arr=reinterpret_cast<const PoolVector<int>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (idx<0 || idx>=arr->size()) {
|
if (idx<0 || idx>=arr->size()) {
|
||||||
|
@ -3277,7 +3277,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const {
|
||||||
return arr->get(idx);
|
return arr->get(idx);
|
||||||
} break;
|
} break;
|
||||||
case REAL_ARRAY: {
|
case REAL_ARRAY: {
|
||||||
const DVector<real_t> *arr=reinterpret_cast<const DVector<real_t>*>(_data._mem);
|
const PoolVector<real_t> *arr=reinterpret_cast<const PoolVector<real_t>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (idx<0 || idx>=arr->size()) {
|
if (idx<0 || idx>=arr->size()) {
|
||||||
|
@ -3288,7 +3288,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const {
|
||||||
return arr->get(idx);
|
return arr->get(idx);
|
||||||
} break;
|
} break;
|
||||||
case STRING_ARRAY: {
|
case STRING_ARRAY: {
|
||||||
const DVector<String> *arr=reinterpret_cast<const DVector<String>*>(_data._mem);
|
const PoolVector<String> *arr=reinterpret_cast<const PoolVector<String>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (idx<0 || idx>=arr->size()) {
|
if (idx<0 || idx>=arr->size()) {
|
||||||
|
@ -3300,7 +3300,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const {
|
||||||
} break;
|
} break;
|
||||||
case VECTOR2_ARRAY: {
|
case VECTOR2_ARRAY: {
|
||||||
|
|
||||||
const DVector<Vector2> *arr=reinterpret_cast<const DVector<Vector2>*>(_data._mem);
|
const PoolVector<Vector2> *arr=reinterpret_cast<const PoolVector<Vector2>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (idx<0 || idx>=arr->size()) {
|
if (idx<0 || idx>=arr->size()) {
|
||||||
|
@ -3312,7 +3312,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const {
|
||||||
} break;
|
} break;
|
||||||
case VECTOR3_ARRAY: {
|
case VECTOR3_ARRAY: {
|
||||||
|
|
||||||
const DVector<Vector3> *arr=reinterpret_cast<const DVector<Vector3>*>(_data._mem);
|
const PoolVector<Vector3> *arr=reinterpret_cast<const PoolVector<Vector3>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (idx<0 || idx>=arr->size()) {
|
if (idx<0 || idx>=arr->size()) {
|
||||||
|
@ -3324,7 +3324,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const {
|
||||||
} break;
|
} break;
|
||||||
case COLOR_ARRAY: {
|
case COLOR_ARRAY: {
|
||||||
|
|
||||||
const DVector<Color> *arr=reinterpret_cast<const DVector<Color>*>(_data._mem);
|
const PoolVector<Color> *arr=reinterpret_cast<const PoolVector<Color>*>(_data._mem);
|
||||||
int idx=r_iter;
|
int idx=r_iter;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (idx<0 || idx>=arr->size()) {
|
if (idx<0 || idx>=arr->size()) {
|
||||||
|
@ -3495,20 +3495,20 @@ void Variant::interpolate(const Variant& a, const Variant& b, float c,Variant &r
|
||||||
case REAL_ARRAY:{ r_dst=a; } return;
|
case REAL_ARRAY:{ r_dst=a; } return;
|
||||||
case STRING_ARRAY:{ r_dst=a; } return;
|
case STRING_ARRAY:{ r_dst=a; } return;
|
||||||
case VECTOR2_ARRAY:{
|
case VECTOR2_ARRAY:{
|
||||||
const DVector<Vector2> *arr_a=reinterpret_cast<const DVector<Vector2>* >(a._data._mem);
|
const PoolVector<Vector2> *arr_a=reinterpret_cast<const PoolVector<Vector2>* >(a._data._mem);
|
||||||
const DVector<Vector2> *arr_b=reinterpret_cast<const DVector<Vector2>* >(b._data._mem);
|
const PoolVector<Vector2> *arr_b=reinterpret_cast<const PoolVector<Vector2>* >(b._data._mem);
|
||||||
int sz = arr_a->size();
|
int sz = arr_a->size();
|
||||||
if (sz==0 || arr_b->size()!=sz) {
|
if (sz==0 || arr_b->size()!=sz) {
|
||||||
|
|
||||||
r_dst=a;
|
r_dst=a;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
DVector<Vector2> v;
|
PoolVector<Vector2> v;
|
||||||
v.resize(sz);
|
v.resize(sz);
|
||||||
{
|
{
|
||||||
DVector<Vector2>::Write vw=v.write();
|
PoolVector<Vector2>::Write vw=v.write();
|
||||||
DVector<Vector2>::Read ar=arr_a->read();
|
PoolVector<Vector2>::Read ar=arr_a->read();
|
||||||
DVector<Vector2>::Read br=arr_b->read();
|
PoolVector<Vector2>::Read br=arr_b->read();
|
||||||
|
|
||||||
for(int i=0;i<sz;i++) {
|
for(int i=0;i<sz;i++) {
|
||||||
vw[i]=ar[i].linear_interpolate(br[i],c);
|
vw[i]=ar[i].linear_interpolate(br[i],c);
|
||||||
|
@ -3523,20 +3523,20 @@ void Variant::interpolate(const Variant& a, const Variant& b, float c,Variant &r
|
||||||
case VECTOR3_ARRAY:{
|
case VECTOR3_ARRAY:{
|
||||||
|
|
||||||
|
|
||||||
const DVector<Vector3> *arr_a=reinterpret_cast<const DVector<Vector3>* >(a._data._mem);
|
const PoolVector<Vector3> *arr_a=reinterpret_cast<const PoolVector<Vector3>* >(a._data._mem);
|
||||||
const DVector<Vector3> *arr_b=reinterpret_cast<const DVector<Vector3>* >(b._data._mem);
|
const PoolVector<Vector3> *arr_b=reinterpret_cast<const PoolVector<Vector3>* >(b._data._mem);
|
||||||
int sz = arr_a->size();
|
int sz = arr_a->size();
|
||||||
if (sz==0 || arr_b->size()!=sz) {
|
if (sz==0 || arr_b->size()!=sz) {
|
||||||
|
|
||||||
r_dst=a;
|
r_dst=a;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
DVector<Vector3> v;
|
PoolVector<Vector3> v;
|
||||||
v.resize(sz);
|
v.resize(sz);
|
||||||
{
|
{
|
||||||
DVector<Vector3>::Write vw=v.write();
|
PoolVector<Vector3>::Write vw=v.write();
|
||||||
DVector<Vector3>::Read ar=arr_a->read();
|
PoolVector<Vector3>::Read ar=arr_a->read();
|
||||||
DVector<Vector3>::Read br=arr_b->read();
|
PoolVector<Vector3>::Read br=arr_b->read();
|
||||||
|
|
||||||
for(int i=0;i<sz;i++) {
|
for(int i=0;i<sz;i++) {
|
||||||
vw[i]=ar[i].linear_interpolate(br[i],c);
|
vw[i]=ar[i].linear_interpolate(br[i],c);
|
||||||
|
|
|
@ -802,7 +802,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
|
||||||
|
|
||||||
int len = Image::get_image_data_size(width,height,format,mipmaps);
|
int len = Image::get_image_data_size(width,height,format,mipmaps);
|
||||||
|
|
||||||
DVector<uint8_t> buffer;
|
PoolVector<uint8_t> buffer;
|
||||||
buffer.resize(len);
|
buffer.resize(len);
|
||||||
|
|
||||||
if (buffer.size()!=len) {
|
if (buffer.size()!=len) {
|
||||||
|
@ -810,7 +810,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
DVector<uint8_t>::Write w=buffer.write();
|
PoolVector<uint8_t>::Write w=buffer.write();
|
||||||
|
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
get_token(p_stream,token,line,r_err_str);
|
get_token(p_stream,token,line,r_err_str);
|
||||||
|
@ -1156,11 +1156,11 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
DVector<uint8_t> arr;
|
PoolVector<uint8_t> arr;
|
||||||
{
|
{
|
||||||
int len=args.size();
|
int len=args.size();
|
||||||
arr.resize(len);
|
arr.resize(len);
|
||||||
DVector<uint8_t>::Write w = arr.write();
|
PoolVector<uint8_t>::Write w = arr.write();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
w[i]=args[i];
|
w[i]=args[i];
|
||||||
}
|
}
|
||||||
|
@ -1177,11 +1177,11 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
DVector<int> arr;
|
PoolVector<int> arr;
|
||||||
{
|
{
|
||||||
int len=args.size();
|
int len=args.size();
|
||||||
arr.resize(len);
|
arr.resize(len);
|
||||||
DVector<int>::Write w = arr.write();
|
PoolVector<int>::Write w = arr.write();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
w[i]=int(args[i]);
|
w[i]=int(args[i]);
|
||||||
}
|
}
|
||||||
|
@ -1198,11 +1198,11 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
DVector<float> arr;
|
PoolVector<float> arr;
|
||||||
{
|
{
|
||||||
int len=args.size();
|
int len=args.size();
|
||||||
arr.resize(len);
|
arr.resize(len);
|
||||||
DVector<float>::Write w = arr.write();
|
PoolVector<float>::Write w = arr.write();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
w[i]=args[i];
|
w[i]=args[i];
|
||||||
}
|
}
|
||||||
|
@ -1251,11 +1251,11 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DVector<String> arr;
|
PoolVector<String> arr;
|
||||||
{
|
{
|
||||||
int len=cs.size();
|
int len=cs.size();
|
||||||
arr.resize(len);
|
arr.resize(len);
|
||||||
DVector<String>::Write w = arr.write();
|
PoolVector<String>::Write w = arr.write();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
w[i]=cs[i];
|
w[i]=cs[i];
|
||||||
}
|
}
|
||||||
|
@ -1273,11 +1273,11 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
DVector<Vector2> arr;
|
PoolVector<Vector2> arr;
|
||||||
{
|
{
|
||||||
int len=args.size()/2;
|
int len=args.size()/2;
|
||||||
arr.resize(len);
|
arr.resize(len);
|
||||||
DVector<Vector2>::Write w = arr.write();
|
PoolVector<Vector2>::Write w = arr.write();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
w[i]=Vector2(args[i*2+0],args[i*2+1]);
|
w[i]=Vector2(args[i*2+0],args[i*2+1]);
|
||||||
}
|
}
|
||||||
|
@ -1294,11 +1294,11 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
DVector<Vector3> arr;
|
PoolVector<Vector3> arr;
|
||||||
{
|
{
|
||||||
int len=args.size()/3;
|
int len=args.size()/3;
|
||||||
arr.resize(len);
|
arr.resize(len);
|
||||||
DVector<Vector3>::Write w = arr.write();
|
PoolVector<Vector3>::Write w = arr.write();
|
||||||
for(int i=0;i<len;i++) {
|
for(int i=0;i<len;i++) {
|
||||||
w[i]=Vector3(args[i*3+0],args[i*3+1],args[i*3+2]);
|
w[i]=Vector3(args[i*3+0],args[i*3+1],args[i*3+2]);
|
||||||
}
|
}
|
||||||
|
@ -1315,11 +1315,11 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
DVector<Color> arr;
|
PoolVector<Color> arr;
|
||||||
{
|
{
|
||||||
int len=args.size()/4;
|
int len=args.size()/4;
|
||||||
arr.resize(len);
|
arr.resize(len);
|
||||||
DVector<Color>::Write w = arr.write();
|
PoolVector<Color>::Write w = arr.write();
|
||||||
for(int i=0;i<len;i++) {
|
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]);
|
w[i]=Color(args[i*4+0],args[i*4+1],args[i*4+2],args[i*4+3]);
|
||||||
}
|
}
|
||||||
|
@ -1986,9 +1986,9 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
|
||||||
|
|
||||||
String s;
|
String s;
|
||||||
|
|
||||||
DVector<uint8_t> data = img.get_data();
|
PoolVector<uint8_t> data = img.get_data();
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
const uint8_t *ptr=r.ptr();;
|
const uint8_t *ptr=r.ptr();;
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
|
|
||||||
|
@ -2128,9 +2128,9 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
|
||||||
|
|
||||||
p_store_string_func(p_store_string_ud,"ByteArray( ");
|
p_store_string_func(p_store_string_ud,"ByteArray( ");
|
||||||
String s;
|
String s;
|
||||||
DVector<uint8_t> data = p_variant;
|
PoolVector<uint8_t> data = p_variant;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
const uint8_t *ptr=r.ptr();;
|
const uint8_t *ptr=r.ptr();;
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
|
|
||||||
|
@ -2147,9 +2147,9 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
|
||||||
case Variant::INT_ARRAY: {
|
case Variant::INT_ARRAY: {
|
||||||
|
|
||||||
p_store_string_func(p_store_string_ud,"IntArray( ");
|
p_store_string_func(p_store_string_ud,"IntArray( ");
|
||||||
DVector<int> data = p_variant;
|
PoolVector<int> data = p_variant;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<int>::Read r = data.read();
|
PoolVector<int>::Read r = data.read();
|
||||||
const int *ptr=r.ptr();;
|
const int *ptr=r.ptr();;
|
||||||
|
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
|
@ -2167,9 +2167,9 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
|
||||||
case Variant::REAL_ARRAY: {
|
case Variant::REAL_ARRAY: {
|
||||||
|
|
||||||
p_store_string_func(p_store_string_ud,"FloatArray( ");
|
p_store_string_func(p_store_string_ud,"FloatArray( ");
|
||||||
DVector<real_t> data = p_variant;
|
PoolVector<real_t> data = p_variant;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<real_t>::Read r = data.read();
|
PoolVector<real_t>::Read r = data.read();
|
||||||
const real_t *ptr=r.ptr();;
|
const real_t *ptr=r.ptr();;
|
||||||
|
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
|
@ -2185,9 +2185,9 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
|
||||||
case Variant::STRING_ARRAY: {
|
case Variant::STRING_ARRAY: {
|
||||||
|
|
||||||
p_store_string_func(p_store_string_ud,"StringArray( ");
|
p_store_string_func(p_store_string_ud,"StringArray( ");
|
||||||
DVector<String> data = p_variant;
|
PoolVector<String> data = p_variant;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<String>::Read r = data.read();
|
PoolVector<String>::Read r = data.read();
|
||||||
const String *ptr=r.ptr();;
|
const String *ptr=r.ptr();;
|
||||||
String s;
|
String s;
|
||||||
//write_string("\n");
|
//write_string("\n");
|
||||||
|
@ -2208,9 +2208,9 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
|
||||||
case Variant::VECTOR2_ARRAY: {
|
case Variant::VECTOR2_ARRAY: {
|
||||||
|
|
||||||
p_store_string_func(p_store_string_ud,"Vector2Array( ");
|
p_store_string_func(p_store_string_ud,"Vector2Array( ");
|
||||||
DVector<Vector2> data = p_variant;
|
PoolVector<Vector2> data = p_variant;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<Vector2>::Read r = data.read();
|
PoolVector<Vector2>::Read r = data.read();
|
||||||
const Vector2 *ptr=r.ptr();;
|
const Vector2 *ptr=r.ptr();;
|
||||||
|
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
|
@ -2226,9 +2226,9 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
|
||||||
case Variant::VECTOR3_ARRAY: {
|
case Variant::VECTOR3_ARRAY: {
|
||||||
|
|
||||||
p_store_string_func(p_store_string_ud,"Vector3Array( ");
|
p_store_string_func(p_store_string_ud,"Vector3Array( ");
|
||||||
DVector<Vector3> data = p_variant;
|
PoolVector<Vector3> data = p_variant;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<Vector3>::Read r = data.read();
|
PoolVector<Vector3>::Read r = data.read();
|
||||||
const Vector3 *ptr=r.ptr();;
|
const Vector3 *ptr=r.ptr();;
|
||||||
|
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
|
@ -2245,9 +2245,9 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
|
||||||
|
|
||||||
p_store_string_func(p_store_string_ud,"ColorArray( ");
|
p_store_string_func(p_store_string_ud,"ColorArray( ");
|
||||||
|
|
||||||
DVector<Color> data = p_variant;
|
PoolVector<Color> data = p_variant;
|
||||||
int len = data.size();
|
int len = data.size();
|
||||||
DVector<Color>::Read r = data.read();
|
PoolVector<Color>::Read r = data.read();
|
||||||
const Color *ptr=r.ptr();;
|
const Color *ptr=r.ptr();;
|
||||||
|
|
||||||
for (int i=0;i<len;i++) {
|
for (int i=0;i<len;i++) {
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
/**
|
/**
|
||||||
* @class Vector
|
* @class Vector
|
||||||
* @author Juan Linietsky
|
* @author Juan Linietsky
|
||||||
* Vector container. Regular Vector Container. Use with care and for smaller arrays when possible. Use DVector for large arrays.
|
* Vector container. Regular Vector Container. Use with care and for smaller arrays when possible. Use PoolVector for large arrays.
|
||||||
*/
|
*/
|
||||||
#include "os/memory.h"
|
#include "os/memory.h"
|
||||||
#include "error_macros.h"
|
#include "error_macros.h"
|
||||||
|
|
|
@ -998,7 +998,7 @@ void RasterizerGLES2::texture_set_data(RID p_texture,const Image& p_image,VS::Cu
|
||||||
GLenum blit_target = (texture->target == GL_TEXTURE_CUBE_MAP)?_cube_side_enum[p_cube_side]:GL_TEXTURE_2D;
|
GLenum blit_target = (texture->target == GL_TEXTURE_CUBE_MAP)?_cube_side_enum[p_cube_side]:GL_TEXTURE_2D;
|
||||||
|
|
||||||
texture->data_size=img.get_data().size();
|
texture->data_size=img.get_data().size();
|
||||||
DVector<uint8_t>::Read read = img.get_data().read();
|
PoolVector<uint8_t>::Read read = img.get_data().read();
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(texture->target, texture->tex_id);
|
glBindTexture(texture->target, texture->tex_id);
|
||||||
|
@ -1133,7 +1133,7 @@ Image RasterizerGLES2::texture_get_data(RID p_texture,VS::CubeMapSide p_cube_sid
|
||||||
ERR_FAIL_COND_V(!texture->active,Image());
|
ERR_FAIL_COND_V(!texture->active,Image());
|
||||||
ERR_FAIL_COND_V(texture->data_size==0,Image());
|
ERR_FAIL_COND_V(texture->data_size==0,Image());
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
GLenum format,type=GL_UNSIGNED_BYTE;
|
GLenum format,type=GL_UNSIGNED_BYTE;
|
||||||
Image::Format fmt;
|
Image::Format fmt;
|
||||||
int pixelsize=0;
|
int pixelsize=0;
|
||||||
|
@ -1235,7 +1235,7 @@ Image RasterizerGLES2::texture_get_data(RID p_texture,VS::CubeMapSide p_cube_sid
|
||||||
}
|
}
|
||||||
|
|
||||||
data.resize(texture->data_size);
|
data.resize(texture->data_size);
|
||||||
DVector<uint8_t>::Write wb = data.write();
|
PoolVector<uint8_t>::Write wb = data.write();
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
int ofs=0;
|
int ofs=0;
|
||||||
|
@ -1264,7 +1264,7 @@ Image RasterizerGLES2::texture_get_data(RID p_texture,VS::CubeMapSide p_cube_sid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wb=DVector<uint8_t>::Write();
|
wb=PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
Image img(texture->alloc_width,texture->alloc_height,texture->mipmaps,fmt,data);
|
Image img(texture->alloc_width,texture->alloc_height,texture->mipmaps,fmt,data);
|
||||||
|
|
||||||
|
@ -2103,10 +2103,10 @@ void RasterizerGLES2::mesh_add_surface(RID p_mesh,VS::PrimitiveType p_primitive,
|
||||||
|
|
||||||
uint8_t *array_ptr=NULL;
|
uint8_t *array_ptr=NULL;
|
||||||
uint8_t *index_array_ptr=NULL;
|
uint8_t *index_array_ptr=NULL;
|
||||||
DVector<uint8_t> array_pre_vbo;
|
PoolVector<uint8_t> array_pre_vbo;
|
||||||
DVector<uint8_t>::Write vaw;
|
PoolVector<uint8_t>::Write vaw;
|
||||||
DVector<uint8_t> index_array_pre_vbo;
|
PoolVector<uint8_t> index_array_pre_vbo;
|
||||||
DVector<uint8_t>::Write iaw;
|
PoolVector<uint8_t>::Write iaw;
|
||||||
|
|
||||||
/* create pointers */
|
/* create pointers */
|
||||||
if (use_VBO) {
|
if (use_VBO) {
|
||||||
|
@ -2191,11 +2191,11 @@ Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem,ui
|
||||||
|
|
||||||
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
DVector<Vector3> array = p_arrays[ai];
|
PoolVector<Vector3> array = p_arrays[ai];
|
||||||
ERR_FAIL_COND_V( array.size() != p_surface->array_len, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( array.size() != p_surface->array_len, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
|
|
||||||
DVector<Vector3>::Read read = array.read();
|
PoolVector<Vector3>::Read read = array.read();
|
||||||
const Vector3* src=read.ptr();
|
const Vector3* src=read.ptr();
|
||||||
|
|
||||||
// setting vertices means regenerating the AABB
|
// setting vertices means regenerating the AABB
|
||||||
|
@ -2252,11 +2252,11 @@ Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem,ui
|
||||||
|
|
||||||
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
DVector<Vector3> array = p_arrays[ai];
|
PoolVector<Vector3> array = p_arrays[ai];
|
||||||
ERR_FAIL_COND_V( array.size() != p_surface->array_len, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( array.size() != p_surface->array_len, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
|
|
||||||
DVector<Vector3>::Read read = array.read();
|
PoolVector<Vector3>::Read read = array.read();
|
||||||
const Vector3* src=read.ptr();
|
const Vector3* src=read.ptr();
|
||||||
|
|
||||||
// setting vertices means regenerating the AABB
|
// setting vertices means regenerating the AABB
|
||||||
|
@ -2292,12 +2292,12 @@ Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem,ui
|
||||||
|
|
||||||
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
DVector<real_t> array = p_arrays[ai];
|
PoolVector<real_t> array = p_arrays[ai];
|
||||||
|
|
||||||
ERR_FAIL_COND_V( array.size() != p_surface->array_len*4, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( array.size() != p_surface->array_len*4, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
|
|
||||||
DVector<real_t>::Read read = array.read();
|
PoolVector<real_t>::Read read = array.read();
|
||||||
const real_t* src = read.ptr();
|
const real_t* src = read.ptr();
|
||||||
|
|
||||||
if (p_surface->array[VS::ARRAY_TANGENT].datatype==GL_BYTE) {
|
if (p_surface->array[VS::ARRAY_TANGENT].datatype==GL_BYTE) {
|
||||||
|
@ -2337,12 +2337,12 @@ Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem,ui
|
||||||
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::COLOR_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::COLOR_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
|
|
||||||
DVector<Color> array = p_arrays[ai];
|
PoolVector<Color> array = p_arrays[ai];
|
||||||
|
|
||||||
ERR_FAIL_COND_V( array.size() != p_surface->array_len, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( array.size() != p_surface->array_len, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
|
|
||||||
DVector<Color>::Read read = array.read();
|
PoolVector<Color>::Read read = array.read();
|
||||||
const Color* src = read.ptr();
|
const Color* src = read.ptr();
|
||||||
bool alpha=false;
|
bool alpha=false;
|
||||||
|
|
||||||
|
@ -2371,11 +2371,11 @@ Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem,ui
|
||||||
|
|
||||||
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::VECTOR2_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::VECTOR2_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
DVector<Vector2> array = p_arrays[ai];
|
PoolVector<Vector2> array = p_arrays[ai];
|
||||||
|
|
||||||
ERR_FAIL_COND_V( array.size() != p_surface->array_len , ERR_INVALID_PARAMETER);
|
ERR_FAIL_COND_V( array.size() != p_surface->array_len , ERR_INVALID_PARAMETER);
|
||||||
|
|
||||||
DVector<Vector2>::Read read = array.read();
|
PoolVector<Vector2>::Read read = array.read();
|
||||||
|
|
||||||
const Vector2 * src=read.ptr();
|
const Vector2 * src=read.ptr();
|
||||||
float scale=1.0;
|
float scale=1.0;
|
||||||
|
@ -2417,12 +2417,12 @@ Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem,ui
|
||||||
|
|
||||||
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
DVector<real_t> array = p_arrays[ai];
|
PoolVector<real_t> array = p_arrays[ai];
|
||||||
|
|
||||||
ERR_FAIL_COND_V( array.size() != p_surface->array_len*VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( array.size() != p_surface->array_len*VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
|
|
||||||
DVector<real_t>::Read read = array.read();
|
PoolVector<real_t>::Read read = array.read();
|
||||||
|
|
||||||
const real_t * src = read.ptr();
|
const real_t * src = read.ptr();
|
||||||
|
|
||||||
|
@ -2460,12 +2460,12 @@ Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem,ui
|
||||||
|
|
||||||
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
DVector<int> array = p_arrays[ai];
|
PoolVector<int> array = p_arrays[ai];
|
||||||
|
|
||||||
ERR_FAIL_COND_V( array.size() != p_surface->array_len*VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( array.size() != p_surface->array_len*VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
|
|
||||||
DVector<int>::Read read = array.read();
|
PoolVector<int>::Read read = array.read();
|
||||||
|
|
||||||
const int * src = read.ptr();
|
const int * src = read.ptr();
|
||||||
|
|
||||||
|
@ -2511,13 +2511,13 @@ Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem,ui
|
||||||
ERR_FAIL_COND_V( p_surface->index_array_len<=0, ERR_INVALID_DATA );
|
ERR_FAIL_COND_V( p_surface->index_array_len<=0, ERR_INVALID_DATA );
|
||||||
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
DVector<int> indices = p_arrays[ai];
|
PoolVector<int> indices = p_arrays[ai];
|
||||||
ERR_FAIL_COND_V( indices.size() == 0, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( indices.size() == 0, ERR_INVALID_PARAMETER );
|
||||||
ERR_FAIL_COND_V( indices.size() != p_surface->index_array_len, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( indices.size() != p_surface->index_array_len, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
/* determine wether using 16 or 32 bits indices */
|
/* determine wether using 16 or 32 bits indices */
|
||||||
|
|
||||||
DVector<int>::Read read = indices.read();
|
PoolVector<int>::Read read = indices.read();
|
||||||
const int *src=read.ptr();
|
const int *src=read.ptr();
|
||||||
|
|
||||||
for (int i=0;i<p_surface->index_array_len;i++) {
|
for (int i=0;i<p_surface->index_array_len;i++) {
|
||||||
|
@ -2553,18 +2553,18 @@ Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem,ui
|
||||||
for(int i=0;i<total_bones;i++)
|
for(int i=0;i<total_bones;i++)
|
||||||
p_surface->skeleton_bone_used[i]=false;
|
p_surface->skeleton_bone_used[i]=false;
|
||||||
}
|
}
|
||||||
DVector<Vector3> vertices = p_arrays[VS::ARRAY_VERTEX];
|
PoolVector<Vector3> vertices = p_arrays[VS::ARRAY_VERTEX];
|
||||||
DVector<int> bones = p_arrays[VS::ARRAY_BONES];
|
PoolVector<int> bones = p_arrays[VS::ARRAY_BONES];
|
||||||
DVector<float> weights = p_arrays[VS::ARRAY_WEIGHTS];
|
PoolVector<float> weights = p_arrays[VS::ARRAY_WEIGHTS];
|
||||||
|
|
||||||
bool any_valid=false;
|
bool any_valid=false;
|
||||||
|
|
||||||
if (vertices.size() && bones.size()==vertices.size()*4 && weights.size()==bones.size()) {
|
if (vertices.size() && bones.size()==vertices.size()*4 && weights.size()==bones.size()) {
|
||||||
//print_line("MAKING SKELETHONG");
|
//print_line("MAKING SKELETHONG");
|
||||||
int vs = vertices.size();
|
int vs = vertices.size();
|
||||||
DVector<Vector3>::Read rv =vertices.read();
|
PoolVector<Vector3>::Read rv =vertices.read();
|
||||||
DVector<int>::Read rb=bones.read();
|
PoolVector<int>::Read rb=bones.read();
|
||||||
DVector<float>::Read rw=weights.read();
|
PoolVector<float>::Read rw=weights.read();
|
||||||
|
|
||||||
Vector<bool> first;
|
Vector<bool> first;
|
||||||
first.resize(total_bones);
|
first.resize(total_bones);
|
||||||
|
@ -3310,7 +3310,7 @@ Vector3 RasterizerGLES2::particles_get_emission_base_velocity(RID p_particles) c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RasterizerGLES2::particles_set_emission_points(RID p_particles, const DVector<Vector3>& p_points) {
|
void RasterizerGLES2::particles_set_emission_points(RID p_particles, const PoolVector<Vector3>& p_points) {
|
||||||
|
|
||||||
Particles* particles = particles_owner.get( p_particles );
|
Particles* particles = particles_owner.get( p_particles );
|
||||||
ERR_FAIL_COND(!particles);
|
ERR_FAIL_COND(!particles);
|
||||||
|
@ -3318,10 +3318,10 @@ void RasterizerGLES2::particles_set_emission_points(RID p_particles, const DVect
|
||||||
particles->data.emission_points=p_points;
|
particles->data.emission_points=p_points;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<Vector3> RasterizerGLES2::particles_get_emission_points(RID p_particles) const {
|
PoolVector<Vector3> RasterizerGLES2::particles_get_emission_points(RID p_particles) const {
|
||||||
|
|
||||||
Particles* particles = particles_owner.get( p_particles );
|
Particles* particles = particles_owner.get( p_particles );
|
||||||
ERR_FAIL_COND_V(!particles,DVector<Vector3>());
|
ERR_FAIL_COND_V(!particles,PoolVector<Vector3>());
|
||||||
|
|
||||||
return particles->data.emission_points;
|
return particles->data.emission_points;
|
||||||
|
|
||||||
|
@ -4304,9 +4304,9 @@ void RasterizerGLES2::begin_frame() {
|
||||||
|
|
||||||
void RasterizerGLES2::capture_viewport(Image* r_capture) {
|
void RasterizerGLES2::capture_viewport(Image* r_capture) {
|
||||||
#if 0
|
#if 0
|
||||||
DVector<uint8_t> pixels;
|
PoolVector<uint8_t> pixels;
|
||||||
pixels.resize(viewport.width*viewport.height*3);
|
pixels.resize(viewport.width*viewport.height*3);
|
||||||
DVector<uint8_t>::Write w = pixels.write();
|
PoolVector<uint8_t>::Write w = pixels.write();
|
||||||
#ifdef GLEW_ENABLED
|
#ifdef GLEW_ENABLED
|
||||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -4318,15 +4318,15 @@ void RasterizerGLES2::capture_viewport(Image* r_capture) {
|
||||||
|
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||||
|
|
||||||
w=DVector<uint8_t>::Write();
|
w=PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
r_capture->create(viewport.width,viewport.height,0,Image::FORMAT_RGB8,pixels);
|
r_capture->create(viewport.width,viewport.height,0,Image::FORMAT_RGB8,pixels);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
DVector<uint8_t> pixels;
|
PoolVector<uint8_t> pixels;
|
||||||
pixels.resize(viewport.width*viewport.height*4);
|
pixels.resize(viewport.width*viewport.height*4);
|
||||||
DVector<uint8_t>::Write w = pixels.write();
|
PoolVector<uint8_t>::Write w = pixels.write();
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||||
|
|
||||||
// uint64_t time = OS::get_singleton()->get_ticks_usec();
|
// uint64_t time = OS::get_singleton()->get_ticks_usec();
|
||||||
|
@ -4359,7 +4359,7 @@ void RasterizerGLES2::capture_viewport(Image* r_capture) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w=DVector<uint8_t>::Write();
|
w=PoolVector<uint8_t>::Write();
|
||||||
r_capture->create(viewport.width,viewport.height,0,Image::FORMAT_RGBA8,pixels);
|
r_capture->create(viewport.width,viewport.height,0,Image::FORMAT_RGBA8,pixels);
|
||||||
//r_capture->flip_y();
|
//r_capture->flip_y();
|
||||||
|
|
||||||
|
@ -8685,7 +8685,7 @@ RID RasterizerGLES2::canvas_light_occluder_create() {
|
||||||
return canvas_occluder_owner.make_rid(co);
|
return canvas_occluder_owner.make_rid(co);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const DVector<Vector2>& p_lines) {
|
void RasterizerGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2>& p_lines) {
|
||||||
|
|
||||||
CanvasOccluder *co = canvas_occluder_owner.get(p_occluder);
|
CanvasOccluder *co = canvas_occluder_owner.get(p_occluder);
|
||||||
ERR_FAIL_COND(!co);
|
ERR_FAIL_COND(!co);
|
||||||
|
@ -8709,18 +8709,18 @@ void RasterizerGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DVector<float> geometry;
|
PoolVector<float> geometry;
|
||||||
DVector<uint16_t> indices;
|
PoolVector<uint16_t> indices;
|
||||||
int lc = p_lines.size();
|
int lc = p_lines.size();
|
||||||
|
|
||||||
geometry.resize(lc*6);
|
geometry.resize(lc*6);
|
||||||
indices.resize(lc*3);
|
indices.resize(lc*3);
|
||||||
|
|
||||||
DVector<float>::Write vw=geometry.write();
|
PoolVector<float>::Write vw=geometry.write();
|
||||||
DVector<uint16_t>::Write iw=indices.write();
|
PoolVector<uint16_t>::Write iw=indices.write();
|
||||||
|
|
||||||
|
|
||||||
DVector<Vector2>::Read lr=p_lines.read();
|
PoolVector<Vector2>::Read lr=p_lines.read();
|
||||||
|
|
||||||
const int POLY_HEIGHT = 16384;
|
const int POLY_HEIGHT = 16384;
|
||||||
|
|
||||||
|
|
|
@ -4596,10 +4596,10 @@ void RasterizerSceneGLES3::_generate_brdf() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DVector<uint8_t> brdf;
|
PoolVector<uint8_t> brdf;
|
||||||
brdf.resize(brdf_size*brdf_size*2);
|
brdf.resize(brdf_size*brdf_size*2);
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = brdf.write();
|
PoolVector<uint8_t>::Write w = brdf.write();
|
||||||
|
|
||||||
|
|
||||||
for(int i=0;i<brdf_size;i++) {
|
for(int i=0;i<brdf_size;i++) {
|
||||||
|
|
|
@ -670,7 +670,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image
|
||||||
GLenum blit_target = (texture->target == GL_TEXTURE_CUBE_MAP)?_cube_side_enum[p_cube_side]:GL_TEXTURE_2D;
|
GLenum blit_target = (texture->target == GL_TEXTURE_CUBE_MAP)?_cube_side_enum[p_cube_side]:GL_TEXTURE_2D;
|
||||||
|
|
||||||
texture->data_size=img.get_data().size();
|
texture->data_size=img.get_data().size();
|
||||||
DVector<uint8_t>::Read read = img.get_data().read();
|
PoolVector<uint8_t>::Read read = img.get_data().read();
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(texture->target, texture->tex_id);
|
glBindTexture(texture->target, texture->tex_id);
|
||||||
|
@ -831,12 +831,12 @@ Image RasterizerStorageGLES3::texture_get_data(RID p_texture,VS::CubeMapSide p_c
|
||||||
|
|
||||||
#ifdef GLES_OVER_GL
|
#ifdef GLES_OVER_GL
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
|
|
||||||
int data_size = Image::get_image_data_size(texture->alloc_width,texture->alloc_height,texture->format,texture->mipmaps>1?-1:0);
|
int data_size = Image::get_image_data_size(texture->alloc_width,texture->alloc_height,texture->format,texture->mipmaps>1?-1:0);
|
||||||
|
|
||||||
data.resize(data_size*2); //add some memory at the end, just in case for buggy drivers
|
data.resize(data_size*2); //add some memory at the end, just in case for buggy drivers
|
||||||
DVector<uint8_t>::Write wb = data.write();
|
PoolVector<uint8_t>::Write wb = data.write();
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
|
@ -868,7 +868,7 @@ Image RasterizerStorageGLES3::texture_get_data(RID p_texture,VS::CubeMapSide p_c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wb=DVector<uint8_t>::Write();
|
wb=PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
data.resize(data_size);
|
data.resize(data_size);
|
||||||
|
|
||||||
|
@ -1848,11 +1848,11 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
|
||||||
} break;
|
} break;
|
||||||
case ShaderLanguage::TYPE_IVEC2: {
|
case ShaderLanguage::TYPE_IVEC2: {
|
||||||
|
|
||||||
DVector<int> iv = value;
|
PoolVector<int> iv = value;
|
||||||
int s = iv.size();
|
int s = iv.size();
|
||||||
GLint *gui = (GLint*)data;
|
GLint *gui = (GLint*)data;
|
||||||
|
|
||||||
DVector<int>::Read r = iv.read();
|
PoolVector<int>::Read r = iv.read();
|
||||||
|
|
||||||
for(int i=0;i<2;i++) {
|
for(int i=0;i<2;i++) {
|
||||||
if (i<s)
|
if (i<s)
|
||||||
|
@ -1865,11 +1865,11 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
|
||||||
} break;
|
} break;
|
||||||
case ShaderLanguage::TYPE_IVEC3: {
|
case ShaderLanguage::TYPE_IVEC3: {
|
||||||
|
|
||||||
DVector<int> iv = value;
|
PoolVector<int> iv = value;
|
||||||
int s = iv.size();
|
int s = iv.size();
|
||||||
GLint *gui = (GLint*)data;
|
GLint *gui = (GLint*)data;
|
||||||
|
|
||||||
DVector<int>::Read r = iv.read();
|
PoolVector<int>::Read r = iv.read();
|
||||||
|
|
||||||
for(int i=0;i<3;i++) {
|
for(int i=0;i<3;i++) {
|
||||||
if (i<s)
|
if (i<s)
|
||||||
|
@ -1882,11 +1882,11 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
|
||||||
case ShaderLanguage::TYPE_IVEC4: {
|
case ShaderLanguage::TYPE_IVEC4: {
|
||||||
|
|
||||||
|
|
||||||
DVector<int> iv = value;
|
PoolVector<int> iv = value;
|
||||||
int s = iv.size();
|
int s = iv.size();
|
||||||
GLint *gui = (GLint*)data;
|
GLint *gui = (GLint*)data;
|
||||||
|
|
||||||
DVector<int>::Read r = iv.read();
|
PoolVector<int>::Read r = iv.read();
|
||||||
|
|
||||||
for(int i=0;i<4;i++) {
|
for(int i=0;i<4;i++) {
|
||||||
if (i<s)
|
if (i<s)
|
||||||
|
@ -1905,11 +1905,11 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
|
||||||
} break;
|
} break;
|
||||||
case ShaderLanguage::TYPE_UVEC2: {
|
case ShaderLanguage::TYPE_UVEC2: {
|
||||||
|
|
||||||
DVector<int> iv = value;
|
PoolVector<int> iv = value;
|
||||||
int s = iv.size();
|
int s = iv.size();
|
||||||
GLuint *gui = (GLuint*)data;
|
GLuint *gui = (GLuint*)data;
|
||||||
|
|
||||||
DVector<int>::Read r = iv.read();
|
PoolVector<int>::Read r = iv.read();
|
||||||
|
|
||||||
for(int i=0;i<2;i++) {
|
for(int i=0;i<2;i++) {
|
||||||
if (i<s)
|
if (i<s)
|
||||||
|
@ -1920,11 +1920,11 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case ShaderLanguage::TYPE_UVEC3: {
|
case ShaderLanguage::TYPE_UVEC3: {
|
||||||
DVector<int> iv = value;
|
PoolVector<int> iv = value;
|
||||||
int s = iv.size();
|
int s = iv.size();
|
||||||
GLuint *gui = (GLuint*)data;
|
GLuint *gui = (GLuint*)data;
|
||||||
|
|
||||||
DVector<int>::Read r = iv.read();
|
PoolVector<int>::Read r = iv.read();
|
||||||
|
|
||||||
for(int i=0;i<3;i++) {
|
for(int i=0;i<3;i++) {
|
||||||
if (i<s)
|
if (i<s)
|
||||||
|
@ -1935,11 +1935,11 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case ShaderLanguage::TYPE_UVEC4: {
|
case ShaderLanguage::TYPE_UVEC4: {
|
||||||
DVector<int> iv = value;
|
PoolVector<int> iv = value;
|
||||||
int s = iv.size();
|
int s = iv.size();
|
||||||
GLuint *gui = (GLuint*)data;
|
GLuint *gui = (GLuint*)data;
|
||||||
|
|
||||||
DVector<int>::Read r = iv.read();
|
PoolVector<int>::Read r = iv.read();
|
||||||
|
|
||||||
for(int i=0;i<4;i++) {
|
for(int i=0;i<4;i++) {
|
||||||
if (i<s)
|
if (i<s)
|
||||||
|
@ -2463,9 +2463,9 @@ RID RasterizerStorageGLES3::mesh_create(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const DVector<uint8_t>& p_array,int p_vertex_count,const DVector<uint8_t>& p_index_array,int p_index_count,const AABB& p_aabb,const Vector<DVector<uint8_t> >& p_blend_shapes,const Vector<AABB>& p_bone_aabbs){
|
void RasterizerStorageGLES3::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){
|
||||||
|
|
||||||
DVector<uint8_t> array = p_array;
|
PoolVector<uint8_t> array = p_array;
|
||||||
|
|
||||||
Mesh *mesh = mesh_owner.getornull(p_mesh);
|
Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||||
ERR_FAIL_COND(!mesh);
|
ERR_FAIL_COND(!mesh);
|
||||||
|
@ -2667,12 +2667,12 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
|
||||||
print_line("desired size: "+itos(array_size)+" vcount "+itos(p_vertex_count)+" should be: "+itos(array.size()+p_vertex_count*2)+" but is "+itos(array.size()));
|
print_line("desired size: "+itos(array_size)+" vcount "+itos(p_vertex_count)+" should be: "+itos(array.size()+p_vertex_count*2)+" but is "+itos(array.size()));
|
||||||
if (array.size()!=array_size && array.size()+p_vertex_count*2 == array_size) {
|
if (array.size()!=array_size && array.size()+p_vertex_count*2 == array_size) {
|
||||||
//old format, convert
|
//old format, convert
|
||||||
array = DVector<uint8_t>();
|
array = PoolVector<uint8_t>();
|
||||||
|
|
||||||
array.resize( p_array.size()+p_vertex_count*2 );
|
array.resize( p_array.size()+p_vertex_count*2 );
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = array.write();
|
PoolVector<uint8_t>::Write w = array.write();
|
||||||
DVector<uint8_t>::Read r = p_array.read();
|
PoolVector<uint8_t>::Read r = p_array.read();
|
||||||
|
|
||||||
uint16_t *w16 = (uint16_t*)w.ptr();
|
uint16_t *w16 = (uint16_t*)w.ptr();
|
||||||
const uint16_t *r16 = (uint16_t*)r.ptr();
|
const uint16_t *r16 = (uint16_t*)r.ptr();
|
||||||
|
@ -2739,7 +2739,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
DVector<uint8_t>::Read vr = array.read();
|
PoolVector<uint8_t>::Read vr = array.read();
|
||||||
|
|
||||||
glGenBuffers(1,&surface->vertex_id);
|
glGenBuffers(1,&surface->vertex_id);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id);
|
glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id);
|
||||||
|
@ -2749,7 +2749,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
|
||||||
|
|
||||||
if (p_format&VS::ARRAY_FORMAT_INDEX) {
|
if (p_format&VS::ARRAY_FORMAT_INDEX) {
|
||||||
|
|
||||||
DVector<uint8_t>::Read ir = p_index_array.read();
|
PoolVector<uint8_t>::Read ir = p_index_array.read();
|
||||||
|
|
||||||
glGenBuffers(1,&surface->index_id);
|
glGenBuffers(1,&surface->index_id);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,surface->index_id);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,surface->index_id);
|
||||||
|
@ -2809,7 +2809,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
|
||||||
|
|
||||||
Surface::MorphTarget mt;
|
Surface::MorphTarget mt;
|
||||||
|
|
||||||
DVector<uint8_t>::Read vr = p_blend_shapes[i].read();
|
PoolVector<uint8_t>::Read vr = p_blend_shapes[i].read();
|
||||||
|
|
||||||
glGenBuffers(1,&mt.vertex_id);
|
glGenBuffers(1,&mt.vertex_id);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER,mt.vertex_id);
|
glBindBuffer(GL_ARRAY_BUFFER,mt.vertex_id);
|
||||||
|
@ -2933,25 +2933,25 @@ int RasterizerStorageGLES3::mesh_surface_get_array_index_len(RID p_mesh, int p_s
|
||||||
return mesh->surfaces[p_surface]->index_array_len;
|
return mesh->surfaces[p_surface]->index_array_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t> RasterizerStorageGLES3::mesh_surface_get_array(RID p_mesh, int p_surface) const{
|
PoolVector<uint8_t> RasterizerStorageGLES3::mesh_surface_get_array(RID p_mesh, int p_surface) const{
|
||||||
|
|
||||||
const Mesh *mesh = mesh_owner.getornull(p_mesh);
|
const Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||||
ERR_FAIL_COND_V(!mesh,DVector<uint8_t>());
|
ERR_FAIL_COND_V(!mesh,PoolVector<uint8_t>());
|
||||||
ERR_FAIL_INDEX_V(p_surface,mesh->surfaces.size(),DVector<uint8_t>());
|
ERR_FAIL_INDEX_V(p_surface,mesh->surfaces.size(),PoolVector<uint8_t>());
|
||||||
|
|
||||||
Surface *surface = mesh->surfaces[p_surface];
|
Surface *surface = mesh->surfaces[p_surface];
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id);
|
glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id);
|
||||||
void * data = glMapBufferRange(GL_ARRAY_BUFFER,0,surface->array_byte_size,GL_MAP_READ_BIT);
|
void * data = glMapBufferRange(GL_ARRAY_BUFFER,0,surface->array_byte_size,GL_MAP_READ_BIT);
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!data,DVector<uint8_t>());
|
ERR_FAIL_COND_V(!data,PoolVector<uint8_t>());
|
||||||
|
|
||||||
DVector<uint8_t> ret;
|
PoolVector<uint8_t> ret;
|
||||||
ret.resize(surface->array_byte_size);
|
ret.resize(surface->array_byte_size);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = ret.write();
|
PoolVector<uint8_t>::Write w = ret.write();
|
||||||
copymem(w.ptr(),data,surface->array_byte_size);
|
copymem(w.ptr(),data,surface->array_byte_size);
|
||||||
}
|
}
|
||||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||||
|
@ -2960,26 +2960,26 @@ DVector<uint8_t> RasterizerStorageGLES3::mesh_surface_get_array(RID p_mesh, int
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t> RasterizerStorageGLES3::mesh_surface_get_index_array(RID p_mesh, int p_surface) const {
|
PoolVector<uint8_t> RasterizerStorageGLES3::mesh_surface_get_index_array(RID p_mesh, int p_surface) const {
|
||||||
const Mesh *mesh = mesh_owner.getornull(p_mesh);
|
const Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||||
ERR_FAIL_COND_V(!mesh,DVector<uint8_t>());
|
ERR_FAIL_COND_V(!mesh,PoolVector<uint8_t>());
|
||||||
ERR_FAIL_INDEX_V(p_surface,mesh->surfaces.size(),DVector<uint8_t>());
|
ERR_FAIL_INDEX_V(p_surface,mesh->surfaces.size(),PoolVector<uint8_t>());
|
||||||
|
|
||||||
Surface *surface = mesh->surfaces[p_surface];
|
Surface *surface = mesh->surfaces[p_surface];
|
||||||
|
|
||||||
ERR_FAIL_COND_V(surface->index_array_len==0,DVector<uint8_t>());
|
ERR_FAIL_COND_V(surface->index_array_len==0,PoolVector<uint8_t>());
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,surface->index_id);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,surface->index_id);
|
||||||
void * data = glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER,0,surface->index_array_byte_size,GL_MAP_READ_BIT);
|
void * data = glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER,0,surface->index_array_byte_size,GL_MAP_READ_BIT);
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!data,DVector<uint8_t>());
|
ERR_FAIL_COND_V(!data,PoolVector<uint8_t>());
|
||||||
|
|
||||||
DVector<uint8_t> ret;
|
PoolVector<uint8_t> ret;
|
||||||
ret.resize(surface->index_array_byte_size);
|
ret.resize(surface->index_array_byte_size);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = ret.write();
|
PoolVector<uint8_t>::Write w = ret.write();
|
||||||
copymem(w.ptr(),data,surface->index_array_byte_size);
|
copymem(w.ptr(),data,surface->index_array_byte_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3019,27 +3019,27 @@ AABB RasterizerStorageGLES3::mesh_surface_get_aabb(RID p_mesh, int p_surface) co
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Vector<DVector<uint8_t> > RasterizerStorageGLES3::mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const{
|
Vector<PoolVector<uint8_t> > RasterizerStorageGLES3::mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const{
|
||||||
|
|
||||||
const Mesh *mesh = mesh_owner.getornull(p_mesh);
|
const Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||||
ERR_FAIL_COND_V(!mesh,Vector<DVector<uint8_t> >());
|
ERR_FAIL_COND_V(!mesh,Vector<PoolVector<uint8_t> >());
|
||||||
ERR_FAIL_INDEX_V(p_surface,mesh->surfaces.size(),Vector<DVector<uint8_t> >());
|
ERR_FAIL_INDEX_V(p_surface,mesh->surfaces.size(),Vector<PoolVector<uint8_t> >());
|
||||||
|
|
||||||
Vector<DVector<uint8_t> > bsarr;
|
Vector<PoolVector<uint8_t> > bsarr;
|
||||||
|
|
||||||
for(int i=0;i<mesh->surfaces[p_surface]->morph_targets.size();i++) {
|
for(int i=0;i<mesh->surfaces[p_surface]->morph_targets.size();i++) {
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,mesh->surfaces[p_surface]->morph_targets[i].vertex_id);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,mesh->surfaces[p_surface]->morph_targets[i].vertex_id);
|
||||||
void * data = glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER,0,mesh->surfaces[p_surface]->array_byte_size,GL_MAP_READ_BIT);
|
void * data = glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER,0,mesh->surfaces[p_surface]->array_byte_size,GL_MAP_READ_BIT);
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!data,Vector<DVector<uint8_t> >());
|
ERR_FAIL_COND_V(!data,Vector<PoolVector<uint8_t> >());
|
||||||
|
|
||||||
DVector<uint8_t> ret;
|
PoolVector<uint8_t> ret;
|
||||||
ret.resize(mesh->surfaces[p_surface]->array_byte_size);
|
ret.resize(mesh->surfaces[p_surface]->array_byte_size);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = ret.write();
|
PoolVector<uint8_t>::Write w = ret.write();
|
||||||
copymem(w.ptr(),data,mesh->surfaces[p_surface]->array_byte_size);
|
copymem(w.ptr(),data,mesh->surfaces[p_surface]->array_byte_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4705,7 +4705,7 @@ RID RasterizerStorageGLES3::room_create(){
|
||||||
|
|
||||||
return RID();
|
return RID();
|
||||||
}
|
}
|
||||||
void RasterizerStorageGLES3::room_add_bounds(RID p_room, const DVector<Vector2>& p_convex_polygon,float p_height,const Transform& p_transform){
|
void RasterizerStorageGLES3::room_add_bounds(RID p_room, const PoolVector<Vector2>& p_convex_polygon,float p_height,const Transform& p_transform){
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4810,7 +4810,7 @@ Transform RasterizerStorageGLES3::gi_probe_get_to_cell_xform(RID p_probe) const
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void RasterizerStorageGLES3::gi_probe_set_dynamic_data(RID p_probe,const DVector<int>& p_data){
|
void RasterizerStorageGLES3::gi_probe_set_dynamic_data(RID p_probe,const PoolVector<int>& p_data){
|
||||||
GIProbe *gip = gi_probe_owner.getornull(p_probe);
|
GIProbe *gip = gi_probe_owner.getornull(p_probe);
|
||||||
ERR_FAIL_COND(!gip);
|
ERR_FAIL_COND(!gip);
|
||||||
|
|
||||||
|
@ -4819,10 +4819,10 @@ void RasterizerStorageGLES3::gi_probe_set_dynamic_data(RID p_probe,const DVector
|
||||||
gip->instance_change_notify();
|
gip->instance_change_notify();
|
||||||
|
|
||||||
}
|
}
|
||||||
DVector<int> RasterizerStorageGLES3::gi_probe_get_dynamic_data(RID p_probe) const{
|
PoolVector<int> RasterizerStorageGLES3::gi_probe_get_dynamic_data(RID p_probe) const{
|
||||||
|
|
||||||
const GIProbe *gip = gi_probe_owner.getornull(p_probe);
|
const GIProbe *gip = gi_probe_owner.getornull(p_probe);
|
||||||
ERR_FAIL_COND_V(!gip,DVector<int>());
|
ERR_FAIL_COND_V(!gip,PoolVector<int>());
|
||||||
|
|
||||||
return gip->dynamic_data;
|
return gip->dynamic_data;
|
||||||
}
|
}
|
||||||
|
@ -5125,7 +5125,7 @@ void RasterizerStorageGLES3::particles_set_emission_box_extents(RID p_particles,
|
||||||
|
|
||||||
particles->emission_box_extents=p_extents;
|
particles->emission_box_extents=p_extents;
|
||||||
}
|
}
|
||||||
void RasterizerStorageGLES3::particles_set_emission_points(RID p_particles,const DVector<Vector3>& p_points) {
|
void RasterizerStorageGLES3::particles_set_emission_points(RID p_particles,const PoolVector<Vector3>& p_points) {
|
||||||
|
|
||||||
Particles *particles = particles_owner.getornull(p_particles);
|
Particles *particles = particles_owner.getornull(p_particles);
|
||||||
ERR_FAIL_COND(!particles);
|
ERR_FAIL_COND(!particles);
|
||||||
|
@ -5961,7 +5961,7 @@ RID RasterizerStorageGLES3::canvas_light_occluder_create() {
|
||||||
return canvas_occluder_owner.make_rid(co);
|
return canvas_occluder_owner.make_rid(co);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, const DVector<Vector2>& p_lines) {
|
void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2>& p_lines) {
|
||||||
|
|
||||||
CanvasOccluder *co = canvas_occluder_owner.get(p_occluder);
|
CanvasOccluder *co = canvas_occluder_owner.get(p_occluder);
|
||||||
ERR_FAIL_COND(!co);
|
ERR_FAIL_COND(!co);
|
||||||
|
@ -5985,18 +5985,18 @@ void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DVector<float> geometry;
|
PoolVector<float> geometry;
|
||||||
DVector<uint16_t> indices;
|
PoolVector<uint16_t> indices;
|
||||||
int lc = p_lines.size();
|
int lc = p_lines.size();
|
||||||
|
|
||||||
geometry.resize(lc*6);
|
geometry.resize(lc*6);
|
||||||
indices.resize(lc*3);
|
indices.resize(lc*3);
|
||||||
|
|
||||||
DVector<float>::Write vw=geometry.write();
|
PoolVector<float>::Write vw=geometry.write();
|
||||||
DVector<uint16_t>::Write iw=indices.write();
|
PoolVector<uint16_t>::Write iw=indices.write();
|
||||||
|
|
||||||
|
|
||||||
DVector<Vector2>::Read lr=p_lines.read();
|
PoolVector<Vector2>::Read lr=p_lines.read();
|
||||||
|
|
||||||
const int POLY_HEIGHT = 16384;
|
const int POLY_HEIGHT = 16384;
|
||||||
|
|
||||||
|
|
|
@ -599,7 +599,7 @@ public:
|
||||||
|
|
||||||
virtual RID mesh_create();
|
virtual RID mesh_create();
|
||||||
|
|
||||||
virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const DVector<uint8_t>& p_array,int p_vertex_count,const DVector<uint8_t>& p_index_array,int p_index_count,const AABB& p_aabb,const Vector<DVector<uint8_t> >& p_blend_shapes=Vector<DVector<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 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_set_morph_target_count(RID p_mesh,int p_amount);
|
virtual void mesh_set_morph_target_count(RID p_mesh,int p_amount);
|
||||||
virtual int mesh_get_morph_target_count(RID p_mesh) const;
|
virtual int mesh_get_morph_target_count(RID p_mesh) const;
|
||||||
|
@ -614,15 +614,15 @@ public:
|
||||||
virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const;
|
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 int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const;
|
||||||
|
|
||||||
virtual DVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const;
|
virtual PoolVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const;
|
||||||
virtual DVector<uint8_t> mesh_surface_get_index_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 uint32_t mesh_surface_get_format(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 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 AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const;
|
||||||
virtual Vector<DVector<uint8_t> > mesh_surface_get_blend_shapes(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<AABB> mesh_surface_get_skeleton_aabb(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);
|
virtual void mesh_remove_surface(RID p_mesh, int p_surface);
|
||||||
|
@ -877,7 +877,7 @@ public:
|
||||||
/* ROOM API */
|
/* ROOM API */
|
||||||
|
|
||||||
virtual RID room_create();
|
virtual RID room_create();
|
||||||
virtual void room_add_bounds(RID p_room, const DVector<Vector2>& p_convex_polygon,float p_height,const Transform& p_transform);
|
virtual void room_add_bounds(RID p_room, const PoolVector<Vector2>& p_convex_polygon,float p_height,const Transform& p_transform);
|
||||||
virtual void room_clear_bounds(RID p_room);
|
virtual void room_clear_bounds(RID p_room);
|
||||||
|
|
||||||
/* PORTAL API */
|
/* PORTAL API */
|
||||||
|
@ -913,7 +913,7 @@ public:
|
||||||
|
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
|
||||||
DVector<int> dynamic_data;
|
PoolVector<int> dynamic_data;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -931,8 +931,8 @@ public:
|
||||||
virtual void gi_probe_set_to_cell_xform(RID p_probe,const Transform& p_xform);
|
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 Transform gi_probe_get_to_cell_xform(RID p_probe) const;
|
||||||
|
|
||||||
virtual void gi_probe_set_dynamic_data(RID p_probe,const DVector<int>& p_data);
|
virtual void gi_probe_set_dynamic_data(RID p_probe,const PoolVector<int>& p_data);
|
||||||
virtual DVector<int> gi_probe_get_dynamic_data(RID p_probe) const;
|
virtual PoolVector<int> gi_probe_get_dynamic_data(RID p_probe) const;
|
||||||
|
|
||||||
virtual void gi_probe_set_dynamic_range(RID p_probe,int p_range);
|
virtual void gi_probe_set_dynamic_range(RID p_probe,int p_range);
|
||||||
virtual int gi_probe_get_dynamic_range(RID p_probe) const;
|
virtual int gi_probe_get_dynamic_range(RID p_probe) const;
|
||||||
|
@ -985,7 +985,7 @@ public:
|
||||||
VS::ParticlesEmissionShape emission_shape;
|
VS::ParticlesEmissionShape emission_shape;
|
||||||
float emission_sphere_radius;
|
float emission_sphere_radius;
|
||||||
Vector3 emission_box_extents;
|
Vector3 emission_box_extents;
|
||||||
DVector<Vector3> emission_points;
|
PoolVector<Vector3> emission_points;
|
||||||
GLuint emission_point_texture;
|
GLuint emission_point_texture;
|
||||||
|
|
||||||
VS::ParticlesDrawOrder draw_order;
|
VS::ParticlesDrawOrder draw_order;
|
||||||
|
@ -1061,7 +1061,7 @@ public:
|
||||||
virtual void particles_set_emission_shape(RID p_particles,VS::ParticlesEmissionShape p_shape);
|
virtual void particles_set_emission_shape(RID p_particles,VS::ParticlesEmissionShape p_shape);
|
||||||
virtual void particles_set_emission_sphere_radius(RID p_particles,float p_radius);
|
virtual void particles_set_emission_sphere_radius(RID p_particles,float p_radius);
|
||||||
virtual void particles_set_emission_box_extents(RID p_particles,const Vector3& p_extents);
|
virtual void particles_set_emission_box_extents(RID p_particles,const Vector3& p_extents);
|
||||||
virtual void particles_set_emission_points(RID p_particles,const DVector<Vector3>& p_points);
|
virtual void particles_set_emission_points(RID p_particles,const PoolVector<Vector3>& p_points);
|
||||||
|
|
||||||
|
|
||||||
virtual void particles_set_draw_order(RID p_particles,VS::ParticlesDrawOrder p_order);
|
virtual void particles_set_draw_order(RID p_particles,VS::ParticlesDrawOrder p_order);
|
||||||
|
@ -1208,14 +1208,14 @@ public:
|
||||||
|
|
||||||
GLuint vertex_id; // 0 means, unconfigured
|
GLuint vertex_id; // 0 means, unconfigured
|
||||||
GLuint index_id; // 0 means, unconfigured
|
GLuint index_id; // 0 means, unconfigured
|
||||||
DVector<Vector2> lines;
|
PoolVector<Vector2> lines;
|
||||||
int len;
|
int len;
|
||||||
};
|
};
|
||||||
|
|
||||||
RID_Owner<CanvasOccluder> canvas_occluder_owner;
|
RID_Owner<CanvasOccluder> canvas_occluder_owner;
|
||||||
|
|
||||||
virtual RID canvas_light_occluder_create();
|
virtual RID canvas_light_occluder_create();
|
||||||
virtual void canvas_light_occluder_set_polylines(RID p_occluder, const DVector<Vector2>& p_lines);
|
virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2>& p_lines);
|
||||||
|
|
||||||
virtual VS::InstanceType get_base_type(RID p_rid) const;
|
virtual VS::InstanceType get_base_type(RID p_rid) const;
|
||||||
|
|
||||||
|
|
|
@ -181,11 +181,11 @@ Error ImageLoaderPNG::_load_image(void *rf_up,png_rw_ptr p_func,Image *p_image)
|
||||||
//int rowsize = png_get_rowbytes(png, info);
|
//int rowsize = png_get_rowbytes(png, info);
|
||||||
int rowsize = components * width;
|
int rowsize = components * width;
|
||||||
|
|
||||||
DVector<uint8_t> dstbuff;
|
PoolVector<uint8_t> dstbuff;
|
||||||
|
|
||||||
dstbuff.resize( rowsize * height );
|
dstbuff.resize( rowsize * height );
|
||||||
|
|
||||||
DVector<uint8_t>::Write dstbuff_write = dstbuff.write();
|
PoolVector<uint8_t>::Write dstbuff_write = dstbuff.write();
|
||||||
|
|
||||||
uint8_t* data = dstbuff_write.ptr();
|
uint8_t* data = dstbuff_write.ptr();
|
||||||
|
|
||||||
|
@ -265,10 +265,10 @@ static Image _load_mem_png(const uint8_t* p_png,int p_size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Image _lossless_unpack_png(const DVector<uint8_t>& p_data) {
|
static Image _lossless_unpack_png(const PoolVector<uint8_t>& p_data) {
|
||||||
|
|
||||||
int len = p_data.size();
|
int len = p_data.size();
|
||||||
DVector<uint8_t>::Read r = p_data.read();
|
PoolVector<uint8_t>::Read r = p_data.read();
|
||||||
ERR_FAIL_COND_V(r[0]!='P' || r[1]!='N' || r[2]!='G' || r[3]!=' ',Image());
|
ERR_FAIL_COND_V(r[0]!='P' || r[1]!='N' || r[2]!='G' || r[3]!=' ',Image());
|
||||||
return _load_mem_png(&r[4],len-4);
|
return _load_mem_png(&r[4],len-4);
|
||||||
|
|
||||||
|
@ -276,17 +276,17 @@ static Image _lossless_unpack_png(const DVector<uint8_t>& p_data) {
|
||||||
|
|
||||||
static void _write_png_data(png_structp png_ptr,png_bytep data, png_size_t p_length) {
|
static void _write_png_data(png_structp png_ptr,png_bytep data, png_size_t p_length) {
|
||||||
|
|
||||||
DVector<uint8_t> &v = *(DVector<uint8_t>*)png_get_io_ptr(png_ptr);
|
PoolVector<uint8_t> &v = *(PoolVector<uint8_t>*)png_get_io_ptr(png_ptr);
|
||||||
int vs = v.size();
|
int vs = v.size();
|
||||||
|
|
||||||
v.resize(vs+p_length);
|
v.resize(vs+p_length);
|
||||||
DVector<uint8_t>::Write w = v.write();
|
PoolVector<uint8_t>::Write w = v.write();
|
||||||
copymem(&w[vs],data,p_length);
|
copymem(&w[vs],data,p_length);
|
||||||
//print_line("png write: "+itos(p_length));
|
//print_line("png write: "+itos(p_length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static DVector<uint8_t> _lossless_pack_png(const Image& p_image) {
|
static PoolVector<uint8_t> _lossless_pack_png(const Image& p_image) {
|
||||||
|
|
||||||
|
|
||||||
Image img = p_image;
|
Image img = p_image;
|
||||||
|
@ -294,7 +294,7 @@ static DVector<uint8_t> _lossless_pack_png(const Image& p_image) {
|
||||||
img.decompress();
|
img.decompress();
|
||||||
|
|
||||||
|
|
||||||
ERR_FAIL_COND_V(img.is_compressed(), DVector<uint8_t>());
|
ERR_FAIL_COND_V(img.is_compressed(), PoolVector<uint8_t>());
|
||||||
|
|
||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
png_infop info_ptr;
|
png_infop info_ptr;
|
||||||
|
@ -304,16 +304,16 @@ static DVector<uint8_t> _lossless_pack_png(const Image& p_image) {
|
||||||
/* initialize stuff */
|
/* initialize stuff */
|
||||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!png_ptr,DVector<uint8_t>());
|
ERR_FAIL_COND_V(!png_ptr,PoolVector<uint8_t>());
|
||||||
|
|
||||||
info_ptr = png_create_info_struct(png_ptr);
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!info_ptr,DVector<uint8_t>());
|
ERR_FAIL_COND_V(!info_ptr,PoolVector<uint8_t>());
|
||||||
|
|
||||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||||
ERR_FAIL_V(DVector<uint8_t>());
|
ERR_FAIL_V(PoolVector<uint8_t>());
|
||||||
}
|
}
|
||||||
DVector<uint8_t> ret;
|
PoolVector<uint8_t> ret;
|
||||||
ret.push_back('P');
|
ret.push_back('P');
|
||||||
ret.push_back('N');
|
ret.push_back('N');
|
||||||
ret.push_back('G');
|
ret.push_back('G');
|
||||||
|
@ -323,7 +323,7 @@ static DVector<uint8_t> _lossless_pack_png(const Image& p_image) {
|
||||||
|
|
||||||
/* write header */
|
/* write header */
|
||||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||||
ERR_FAIL_V(DVector<uint8_t>());
|
ERR_FAIL_V(PoolVector<uint8_t>());
|
||||||
}
|
}
|
||||||
|
|
||||||
int pngf=0;
|
int pngf=0;
|
||||||
|
@ -379,11 +379,11 @@ static DVector<uint8_t> _lossless_pack_png(const Image& p_image) {
|
||||||
|
|
||||||
/* write bytes */
|
/* write bytes */
|
||||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||||
ERR_FAIL_V(DVector<uint8_t>());
|
ERR_FAIL_V(PoolVector<uint8_t>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = img.get_data().read();
|
PoolVector<uint8_t>::Read r = img.get_data().read();
|
||||||
|
|
||||||
row_pointers = (png_bytep*)memalloc(sizeof(png_bytep)*h);
|
row_pointers = (png_bytep*)memalloc(sizeof(png_bytep)*h);
|
||||||
for(int i=0;i<h;i++) {
|
for(int i=0;i<h;i++) {
|
||||||
|
@ -397,7 +397,7 @@ static DVector<uint8_t> _lossless_pack_png(const Image& p_image) {
|
||||||
/* end write */
|
/* end write */
|
||||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||||
|
|
||||||
ERR_FAIL_V(DVector<uint8_t>());
|
ERR_FAIL_V(PoolVector<uint8_t>());
|
||||||
}
|
}
|
||||||
|
|
||||||
png_write_end(png_ptr, NULL);
|
png_write_end(png_ptr, NULL);
|
||||||
|
|
|
@ -193,7 +193,7 @@ Error ResourceSaverPNG::save_image(const String &p_path, Image &p_img) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = p_img.get_data().read();
|
PoolVector<uint8_t>::Read r = p_img.get_data().read();
|
||||||
|
|
||||||
row_pointers = (png_bytep*)memalloc(sizeof(png_bytep)*h);
|
row_pointers = (png_bytep*)memalloc(sizeof(png_bytep)*h);
|
||||||
for(int i=0;i<h;i++) {
|
for(int i=0;i<h;i++) {
|
||||||
|
|
|
@ -31,10 +31,10 @@
|
||||||
#ifdef UNIX_ENABLED
|
#ifdef UNIX_ENABLED
|
||||||
|
|
||||||
|
|
||||||
#include "os/memory_pool_dynamic_static.h"
|
|
||||||
#include "thread_posix.h"
|
#include "thread_posix.h"
|
||||||
#include "semaphore_posix.h"
|
#include "semaphore_posix.h"
|
||||||
#include "mutex_posix.h"
|
#include "mutex_posix.h"
|
||||||
|
#include "rw_lock_posix.h"
|
||||||
#include "core/os/thread_dummy.h"
|
#include "core/os/thread_dummy.h"
|
||||||
|
|
||||||
//#include "core/io/file_access_buffered_fa.h"
|
//#include "core/io/file_access_buffered_fa.h"
|
||||||
|
@ -116,7 +116,6 @@ int OS_Unix::unix_initialize_audio(int p_audio_driver) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MemoryPoolDynamicStatic *mempool_dynamic=NULL;
|
|
||||||
|
|
||||||
|
|
||||||
void OS_Unix::initialize_core() {
|
void OS_Unix::initialize_core() {
|
||||||
|
@ -129,6 +128,7 @@ void OS_Unix::initialize_core() {
|
||||||
ThreadPosix::make_default();
|
ThreadPosix::make_default();
|
||||||
SemaphorePosix::make_default();
|
SemaphorePosix::make_default();
|
||||||
MutexPosix::make_default();
|
MutexPosix::make_default();
|
||||||
|
RWLockPosix::make_default();
|
||||||
#endif
|
#endif
|
||||||
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
|
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
|
||||||
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
|
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
|
||||||
|
@ -144,7 +144,6 @@ void OS_Unix::initialize_core() {
|
||||||
PacketPeerUDPPosix::make_default();
|
PacketPeerUDPPosix::make_default();
|
||||||
IP_Unix::make_default();
|
IP_Unix::make_default();
|
||||||
#endif
|
#endif
|
||||||
mempool_dynamic = memnew( MemoryPoolDynamicStatic );
|
|
||||||
|
|
||||||
ticks_start=0;
|
ticks_start=0;
|
||||||
ticks_start=get_ticks_usec();
|
ticks_start=get_ticks_usec();
|
||||||
|
@ -153,8 +152,6 @@ void OS_Unix::initialize_core() {
|
||||||
void OS_Unix::finalize_core() {
|
void OS_Unix::finalize_core() {
|
||||||
|
|
||||||
|
|
||||||
if (mempool_dynamic)
|
|
||||||
memdelete( mempool_dynamic );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
76
drivers/unix/rw_lock_posix.cpp
Normal file
76
drivers/unix/rw_lock_posix.cpp
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
|
||||||
|
#if defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED)
|
||||||
|
|
||||||
|
#include "os/memory.h"
|
||||||
|
#include "rw_lock_posix.h"
|
||||||
|
#include "error_macros.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void RWLockPosix::read_lock() {
|
||||||
|
|
||||||
|
int err =pthread_rwlock_rdlock(&rwlock);
|
||||||
|
if (err!=0) {
|
||||||
|
perror("wtf: ");
|
||||||
|
}
|
||||||
|
ERR_FAIL_COND(err!=0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RWLockPosix::read_unlock() {
|
||||||
|
|
||||||
|
pthread_rwlock_unlock(&rwlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
Error RWLockPosix::read_try_lock() {
|
||||||
|
|
||||||
|
if (pthread_rwlock_tryrdlock(&rwlock)!=0) {
|
||||||
|
return ERR_BUSY;
|
||||||
|
} else {
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void RWLockPosix::write_lock() {
|
||||||
|
|
||||||
|
int err = pthread_rwlock_wrlock(&rwlock);
|
||||||
|
ERR_FAIL_COND(err!=0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RWLockPosix::write_unlock() {
|
||||||
|
|
||||||
|
pthread_rwlock_unlock(&rwlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
Error RWLockPosix::write_try_lock() {
|
||||||
|
if (pthread_rwlock_trywrlock(&rwlock)!=0) {
|
||||||
|
return ERR_BUSY;
|
||||||
|
} else {
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RWLock *RWLockPosix::create_func_posix() {
|
||||||
|
|
||||||
|
return memnew( RWLockPosix );
|
||||||
|
}
|
||||||
|
|
||||||
|
void RWLockPosix::make_default() {
|
||||||
|
|
||||||
|
create_func=create_func_posix;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RWLockPosix::RWLockPosix() {
|
||||||
|
|
||||||
|
rwlock=PTHREAD_RWLOCK_INITIALIZER;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RWLockPosix::~RWLockPosix() {
|
||||||
|
|
||||||
|
pthread_rwlock_destroy(&rwlock);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
37
drivers/unix/rw_lock_posix.h
Normal file
37
drivers/unix/rw_lock_posix.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef RWLOCKPOSIX_H
|
||||||
|
#define RWLOCKPOSIX_H
|
||||||
|
|
||||||
|
#if defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED)
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include "os/rw_lock.h"
|
||||||
|
|
||||||
|
class RWLockPosix : public RWLock {
|
||||||
|
|
||||||
|
|
||||||
|
pthread_rwlock_t rwlock;
|
||||||
|
|
||||||
|
static RWLock *create_func_posix();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void read_lock();
|
||||||
|
virtual void read_unlock();
|
||||||
|
virtual Error read_try_lock();
|
||||||
|
|
||||||
|
virtual void write_lock();
|
||||||
|
virtual void write_unlock();
|
||||||
|
virtual Error write_try_lock();
|
||||||
|
|
||||||
|
static void make_default();
|
||||||
|
|
||||||
|
RWLockPosix();
|
||||||
|
|
||||||
|
~RWLockPosix();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // RWLOCKPOSIX_H
|
|
@ -122,9 +122,9 @@ float Performance::get_monitor(Monitor p_monitor) const {
|
||||||
case TIME_PROCESS: return _process_time;
|
case TIME_PROCESS: return _process_time;
|
||||||
case TIME_FIXED_PROCESS: return _fixed_process_time;
|
case TIME_FIXED_PROCESS: return _fixed_process_time;
|
||||||
case MEMORY_STATIC: return Memory::get_mem_usage();
|
case MEMORY_STATIC: return Memory::get_mem_usage();
|
||||||
case MEMORY_DYNAMIC: return Memory::get_dynamic_mem_usage();
|
case MEMORY_DYNAMIC: return MemoryPool::total_memory;
|
||||||
case MEMORY_STATIC_MAX: return Memory::get_mem_max_usage();
|
case MEMORY_STATIC_MAX: return MemoryPool::max_memory;
|
||||||
case MEMORY_DYNAMIC_MAX: return Memory::get_dynamic_mem_available();
|
case MEMORY_DYNAMIC_MAX: return 0;
|
||||||
case MEMORY_MESSAGE_BUFFER_MAX: return MessageQueue::get_singleton()->get_max_buffer_usage();
|
case MEMORY_MESSAGE_BUFFER_MAX: return MessageQueue::get_singleton()->get_max_buffer_usage();
|
||||||
case OBJECT_COUNT: return ObjectDB::get_object_count();
|
case OBJECT_COUNT: return ObjectDB::get_object_count();
|
||||||
case OBJECT_RESOURCE_COUNT: return ResourceCache::get_cached_resource_count();
|
case OBJECT_RESOURCE_COUNT: return ResourceCache::get_cached_resource_count();
|
||||||
|
|
|
@ -298,9 +298,9 @@ void CPSampleManagerImpl::unlock_data(CPSample_ID p_id){
|
||||||
|
|
||||||
sd->locks--;
|
sd->locks--;
|
||||||
if (sd->locks==0) {
|
if (sd->locks==0) {
|
||||||
sd->w=DVector<uint8_t>::Write();
|
sd->w=PoolVector<uint8_t>::Write();
|
||||||
AudioServer::get_singleton()->sample_set_data(sd->rid,sd->lock);
|
AudioServer::get_singleton()->sample_set_data(sd->rid,sd->lock);
|
||||||
sd->lock=DVector<uint8_t>();
|
sd->lock=PoolVector<uint8_t>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,8 @@ class CPSampleManagerImpl : public CPSampleManager {
|
||||||
int loop_begin;
|
int loop_begin;
|
||||||
int loop_end;
|
int loop_end;
|
||||||
int locks;
|
int locks;
|
||||||
DVector<uint8_t> lock;
|
PoolVector<uint8_t> lock;
|
||||||
DVector<uint8_t>::Write w;
|
PoolVector<uint8_t>::Write w;
|
||||||
CPSample_Loop_Type loop_type;
|
CPSample_Loop_Type loop_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path,
|
||||||
|
|
||||||
// print_line("found format: "+String(dds_format_info[dds_format].name));
|
// print_line("found format: "+String(dds_format_info[dds_format].name));
|
||||||
|
|
||||||
DVector<uint8_t> src_data;
|
PoolVector<uint8_t> src_data;
|
||||||
|
|
||||||
const DDSFormatInfo &info=dds_format_info[dds_format];
|
const DDSFormatInfo &info=dds_format_info[dds_format];
|
||||||
uint32_t w = width;
|
uint32_t w = width;
|
||||||
|
@ -247,9 +247,9 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path,
|
||||||
}
|
}
|
||||||
|
|
||||||
src_data.resize(size);
|
src_data.resize(size);
|
||||||
DVector<uint8_t>::Write wb = src_data.write();
|
PoolVector<uint8_t>::Write wb = src_data.write();
|
||||||
f->get_buffer(wb.ptr(),size);
|
f->get_buffer(wb.ptr(),size);
|
||||||
wb=DVector<uint8_t>::Write();
|
wb=PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
} else if (info.palette) {
|
} else if (info.palette) {
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path,
|
||||||
}
|
}
|
||||||
|
|
||||||
src_data.resize(size + 256*colsize );
|
src_data.resize(size + 256*colsize );
|
||||||
DVector<uint8_t>::Write wb = src_data.write();
|
PoolVector<uint8_t>::Write wb = src_data.write();
|
||||||
f->get_buffer(wb.ptr(),size);
|
f->get_buffer(wb.ptr(),size);
|
||||||
|
|
||||||
for(int i=0;i<256;i++) {
|
for(int i=0;i<256;i++) {
|
||||||
|
@ -296,7 +296,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wb=DVector<uint8_t>::Write();
|
wb=PoolVector<uint8_t>::Write();
|
||||||
} else {
|
} else {
|
||||||
//uncompressed generic...
|
//uncompressed generic...
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path,
|
||||||
size=size*2;
|
size=size*2;
|
||||||
|
|
||||||
src_data.resize(size);
|
src_data.resize(size);
|
||||||
DVector<uint8_t>::Write wb = src_data.write();
|
PoolVector<uint8_t>::Write wb = src_data.write();
|
||||||
f->get_buffer(wb.ptr(),size);
|
f->get_buffer(wb.ptr(),size);
|
||||||
|
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wb=DVector<uint8_t>::Write();
|
wb=PoolVector<uint8_t>::Write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,10 +37,10 @@ static void _decompress_etc(Image *p_img) {
|
||||||
|
|
||||||
int imgw = p_img->get_width();
|
int imgw = p_img->get_width();
|
||||||
int imgh = p_img->get_height();
|
int imgh = p_img->get_height();
|
||||||
DVector<uint8_t> src=p_img->get_data();
|
PoolVector<uint8_t> src=p_img->get_data();
|
||||||
DVector<uint8_t> dst;
|
PoolVector<uint8_t> dst;
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = src.read();
|
PoolVector<uint8_t>::Read r = src.read();
|
||||||
|
|
||||||
int mmc=p_img->get_mipmap_count();
|
int mmc=p_img->get_mipmap_count();
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ static void _decompress_etc(Image *p_img) {
|
||||||
|
|
||||||
dst.resize(dst.size()+imgw*imgh*3);
|
dst.resize(dst.size()+imgw*imgh*3);
|
||||||
const uint8_t *srcbr=&r[p_img->get_mipmap_offset(i)];
|
const uint8_t *srcbr=&r[p_img->get_mipmap_offset(i)];
|
||||||
DVector<uint8_t>::Write w = dst.write();
|
PoolVector<uint8_t>::Write w = dst.write();
|
||||||
|
|
||||||
uint8_t *wptr = &w[dst.size()-imgw*imgh*3];
|
uint8_t *wptr = &w[dst.size()-imgw*imgh*3];
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ static void _decompress_etc(Image *p_img) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
r=DVector<uint8_t>::Read();
|
r=PoolVector<uint8_t>::Read();
|
||||||
//print_line("Re Creating ETC into regular image: w "+itos(p_img->get_width())+" h "+itos(p_img->get_height())+" mm "+itos(p_img->get_mipmaps()));
|
//print_line("Re Creating ETC into regular image: w "+itos(p_img->get_width())+" h "+itos(p_img->get_height())+" mm "+itos(p_img->get_mipmaps()));
|
||||||
*p_img=Image(p_img->get_width(),p_img->get_height(),p_img->has_mipmaps(),Image::FORMAT_RGB8,dst);
|
*p_img=Image(p_img->get_width(),p_img->get_height(),p_img->has_mipmaps(),Image::FORMAT_RGB8,dst);
|
||||||
if (p_img->has_mipmaps())
|
if (p_img->has_mipmaps())
|
||||||
|
@ -117,9 +117,9 @@ static void _compress_etc(Image *p_img) {
|
||||||
img.generate_mipmaps(); // force mipmaps, so it works on most hardware
|
img.generate_mipmaps(); // force mipmaps, so it works on most hardware
|
||||||
|
|
||||||
|
|
||||||
DVector<uint8_t> res_data;
|
PoolVector<uint8_t> res_data;
|
||||||
DVector<uint8_t> dst_data;
|
PoolVector<uint8_t> dst_data;
|
||||||
DVector<uint8_t>::Read r = img.get_data().read();
|
PoolVector<uint8_t>::Read r = img.get_data().read();
|
||||||
|
|
||||||
int mc=0;
|
int mc=0;
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ static void _compress_etc(Image *p_img) {
|
||||||
const uint8_t *src = &r[img.get_mipmap_offset(i)];
|
const uint8_t *src = &r[img.get_mipmap_offset(i)];
|
||||||
int mmsize = MAX(bw,1)*MAX(bh,1)*8;
|
int mmsize = MAX(bw,1)*MAX(bh,1)*8;
|
||||||
dst_data.resize(dst_data.size()+mmsize);
|
dst_data.resize(dst_data.size()+mmsize);
|
||||||
DVector<uint8_t>::Write w=dst_data.write();
|
PoolVector<uint8_t>::Write w=dst_data.write();
|
||||||
uint8_t *dst = &w[dst_data.size()-mmsize];
|
uint8_t *dst = &w[dst_data.size()-mmsize];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,13 @@ RES ResourceFormatPKM::load(const String &p_path, const String& p_original_path,
|
||||||
h.origWidth = f->get_16();
|
h.origWidth = f->get_16();
|
||||||
h.origHeight = f->get_16();
|
h.origHeight = f->get_16();
|
||||||
|
|
||||||
DVector<uint8_t> src_data;
|
PoolVector<uint8_t> src_data;
|
||||||
|
|
||||||
uint32_t size = h.texWidth * h.texHeight / 2;
|
uint32_t size = h.texWidth * h.texHeight / 2;
|
||||||
src_data.resize(size);
|
src_data.resize(size);
|
||||||
DVector<uint8_t>::Write wb = src_data.write();
|
PoolVector<uint8_t>::Write wb = src_data.write();
|
||||||
f->get_buffer(wb.ptr(),size);
|
f->get_buffer(wb.ptr(),size);
|
||||||
wb=DVector<uint8_t>::Write();
|
wb=PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
int mipmaps = h.format;
|
int mipmaps = h.format;
|
||||||
int width = h.origWidth;
|
int width = h.origWidth;
|
||||||
|
|
|
@ -830,7 +830,7 @@ Error GDScript::load_byte_code(const String& p_path) {
|
||||||
Error GDScript::load_source_code(const String& p_path) {
|
Error GDScript::load_source_code(const String& p_path) {
|
||||||
|
|
||||||
|
|
||||||
DVector<uint8_t> sourcef;
|
PoolVector<uint8_t> sourcef;
|
||||||
Error err;
|
Error err;
|
||||||
FileAccess *f=FileAccess::open(p_path,FileAccess::READ,&err);
|
FileAccess *f=FileAccess::open(p_path,FileAccess::READ,&err);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -840,7 +840,7 @@ Error GDScript::load_source_code(const String& p_path) {
|
||||||
|
|
||||||
int len = f->get_len();
|
int len = f->get_len();
|
||||||
sourcef.resize(len+1);
|
sourcef.resize(len+1);
|
||||||
DVector<uint8_t>::Write w = sourcef.write();
|
PoolVector<uint8_t>::Write w = sourcef.write();
|
||||||
int r = f->get_buffer(w.ptr(),len);
|
int r = f->get_buffer(w.ptr(),len);
|
||||||
f->close();
|
f->close();
|
||||||
memdelete(f);
|
memdelete(f);
|
||||||
|
|
|
@ -61,9 +61,9 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) {
|
||||||
} else if (name=="theme/bake") {
|
} else if (name=="theme/bake") {
|
||||||
set_bake(p_value);
|
set_bake(p_value);
|
||||||
/* } else if (name=="cells") {
|
/* } else if (name=="cells") {
|
||||||
DVector<int> cells = p_value;
|
PoolVector<int> cells = p_value;
|
||||||
int amount=cells.size();
|
int amount=cells.size();
|
||||||
DVector<int>::Read r = cells.read();
|
PoolVector<int>::Read r = cells.read();
|
||||||
ERR_FAIL_COND_V(amount&1,false); // not even
|
ERR_FAIL_COND_V(amount&1,false); // not even
|
||||||
cell_map.clear();;
|
cell_map.clear();;
|
||||||
for(int i=0;i<amount/3;i++) {
|
for(int i=0;i<amount/3;i++) {
|
||||||
|
@ -86,9 +86,9 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) {
|
||||||
baked=d["baked"];
|
baked=d["baked"];
|
||||||
if (d.has("cells")) {
|
if (d.has("cells")) {
|
||||||
|
|
||||||
DVector<int> cells = d["cells"];
|
PoolVector<int> cells = d["cells"];
|
||||||
int amount=cells.size();
|
int amount=cells.size();
|
||||||
DVector<int>::Read r = cells.read();
|
PoolVector<int>::Read r = cells.read();
|
||||||
ERR_FAIL_COND_V(amount%3,false); // not even
|
ERR_FAIL_COND_V(amount%3,false); // not even
|
||||||
cell_map.clear();;
|
cell_map.clear();;
|
||||||
for(int i=0;i<amount/3;i++) {
|
for(int i=0;i<amount/3;i++) {
|
||||||
|
@ -183,10 +183,10 @@ bool GridMap::_get(const StringName& p_name,Variant &r_ret) const {
|
||||||
|
|
||||||
Dictionary d;
|
Dictionary d;
|
||||||
|
|
||||||
DVector<int> cells;
|
PoolVector<int> cells;
|
||||||
cells.resize(cell_map.size()*3);
|
cells.resize(cell_map.size()*3);
|
||||||
{
|
{
|
||||||
DVector<int>::Write w = cells.write();
|
PoolVector<int>::Write w = cells.write();
|
||||||
int i=0;
|
int i=0;
|
||||||
for (Map<IndexKey,Cell>::Element *E=cell_map.front();E;E=E->next(),i++) {
|
for (Map<IndexKey,Cell>::Element *E=cell_map.front();E;E=E->next(),i++) {
|
||||||
|
|
||||||
|
@ -665,7 +665,7 @@ void GridMap::_octant_update(const OctantKey &p_key) {
|
||||||
VS::get_singleton()->mesh_clear(g.collision_debug);
|
VS::get_singleton()->mesh_clear(g.collision_debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<Vector3> col_debug;
|
PoolVector<Vector3> col_debug;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* foreach item in this octant,
|
* foreach item in this octant,
|
||||||
|
@ -863,15 +863,15 @@ void GridMap::_octant_bake(const OctantKey &p_key, const Ref<TriangleMesh>& p_tm
|
||||||
if (ii.mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES)
|
if (ii.mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES)
|
||||||
continue;
|
continue;
|
||||||
Array a = ii.mesh->surface_get_arrays(i);
|
Array a = ii.mesh->surface_get_arrays(i);
|
||||||
DVector<Vector3> av=a[VS::ARRAY_VERTEX];
|
PoolVector<Vector3> av=a[VS::ARRAY_VERTEX];
|
||||||
int avs = av.size();
|
int avs = av.size();
|
||||||
DVector<Vector3>::Read vr = av.read();
|
PoolVector<Vector3>::Read vr = av.read();
|
||||||
|
|
||||||
DVector<int> ai=a[VS::ARRAY_INDEX];
|
PoolVector<int> ai=a[VS::ARRAY_INDEX];
|
||||||
int ais=ai.size();
|
int ais=ai.size();
|
||||||
if (ais) {
|
if (ais) {
|
||||||
|
|
||||||
DVector<int>::Read ir=ai.read();
|
PoolVector<int>::Read ir=ai.read();
|
||||||
for(int j=0;j<ais;j++) {
|
for(int j=0;j<ais;j++) {
|
||||||
|
|
||||||
p_prebake->push_back(xform.xform(vr[ir[j]]));
|
p_prebake->push_back(xform.xform(vr[ir[j]]));
|
||||||
|
@ -1667,7 +1667,7 @@ void GridMap::bake_geometry() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<Vector3> vv;
|
PoolVector<Vector3> vv;
|
||||||
vv.fill_with(vertices);
|
vv.fill_with(vertices);
|
||||||
//print_line("TOTAL VERTICES: "+itos(vv.size()));
|
//print_line("TOTAL VERTICES: "+itos(vv.size()));
|
||||||
tmesh = Ref<TriangleMesh>( memnew( TriangleMesh ));
|
tmesh = Ref<TriangleMesh>( memnew( TriangleMesh ));
|
||||||
|
|
|
@ -1126,7 +1126,7 @@ void GridMapEditor::_update_areas_display() {
|
||||||
|
|
||||||
RID mesh = VisualServer::get_singleton()->mesh_create();
|
RID mesh = VisualServer::get_singleton()->mesh_create();
|
||||||
|
|
||||||
DVector<Plane> planes;
|
PoolVector<Plane> planes;
|
||||||
for(int i=0;i<3;i++) {
|
for(int i=0;i<3;i++) {
|
||||||
|
|
||||||
Vector3 axis;
|
Vector3 axis;
|
||||||
|
@ -1343,8 +1343,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
|
||||||
//selection mesh create
|
//selection mesh create
|
||||||
|
|
||||||
|
|
||||||
DVector<Vector3> lines;
|
PoolVector<Vector3> lines;
|
||||||
DVector<Vector3> triangles;
|
PoolVector<Vector3> triangles;
|
||||||
|
|
||||||
for (int i=0;i<6;i++) {
|
for (int i=0;i<6;i++) {
|
||||||
|
|
||||||
|
|
|
@ -56,11 +56,11 @@ Error jpeg_load_image_from_buffer(Image *p_image,const uint8_t* p_buffer, int p_
|
||||||
|
|
||||||
const int dst_bpl = image_width * comps;
|
const int dst_bpl = image_width * comps;
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
|
|
||||||
data.resize(dst_bpl * image_height);
|
data.resize(dst_bpl * image_height);
|
||||||
|
|
||||||
DVector<uint8_t>::Write dw = data.write();
|
PoolVector<uint8_t>::Write dw = data.write();
|
||||||
|
|
||||||
jpgd::uint8 *pImage_data = (jpgd::uint8*)dw.ptr();
|
jpgd::uint8 *pImage_data = (jpgd::uint8*)dw.ptr();
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ Error jpeg_load_image_from_buffer(Image *p_image,const uint8_t* p_buffer, int p_
|
||||||
else
|
else
|
||||||
fmt=Image::FORMAT_RGBA8;
|
fmt=Image::FORMAT_RGBA8;
|
||||||
|
|
||||||
dw = DVector<uint8_t>::Write();
|
dw = PoolVector<uint8_t>::Write();
|
||||||
p_image->create(image_width,image_height,0,fmt,data);
|
p_image->create(image_width,image_height,0,fmt,data);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
@ -99,12 +99,12 @@ Error jpeg_load_image_from_buffer(Image *p_image,const uint8_t* p_buffer, int p_
|
||||||
Error ImageLoaderJPG::load_image(Image *p_image,FileAccess *f) {
|
Error ImageLoaderJPG::load_image(Image *p_image,FileAccess *f) {
|
||||||
|
|
||||||
|
|
||||||
DVector<uint8_t> src_image;
|
PoolVector<uint8_t> src_image;
|
||||||
int src_image_len = f->get_len();
|
int src_image_len = f->get_len();
|
||||||
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
|
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
|
||||||
src_image.resize(src_image_len);
|
src_image.resize(src_image_len);
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = src_image.write();
|
PoolVector<uint8_t>::Write w = src_image.write();
|
||||||
|
|
||||||
f->get_buffer(&w[0],src_image_len);
|
f->get_buffer(&w[0],src_image_len);
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ Error ImageLoaderJPG::load_image(Image *p_image,FileAccess *f) {
|
||||||
|
|
||||||
Error err = jpeg_load_image_from_buffer(p_image,w.ptr(),src_image_len);
|
Error err = jpeg_load_image_from_buffer(p_image,w.ptr(),src_image_len);
|
||||||
|
|
||||||
w = DVector<uint8_t>::Write();
|
w = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ Error AudioStreamPlaybackMPC::_open_file() {
|
||||||
if (preload) {
|
if (preload) {
|
||||||
|
|
||||||
data.resize(streamlen);
|
data.resize(streamlen);
|
||||||
DVector<uint8_t>::Write w = data.write();
|
PoolVector<uint8_t>::Write w = data.write();
|
||||||
f->get_buffer(&w[0],streamlen);
|
f->get_buffer(&w[0],streamlen);
|
||||||
memdelete(f);
|
memdelete(f);
|
||||||
f=NULL;
|
f=NULL;
|
||||||
|
@ -85,7 +85,7 @@ int AudioStreamPlaybackMPC::_read_file(void *p_dst,int p_bytes) {
|
||||||
if (f)
|
if (f)
|
||||||
return f->get_buffer((uint8_t*)p_dst,p_bytes);
|
return f->get_buffer((uint8_t*)p_dst,p_bytes);
|
||||||
|
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
if (p_bytes+data_ofs > streamlen) {
|
if (p_bytes+data_ofs > streamlen) {
|
||||||
p_bytes=streamlen-data_ofs;
|
p_bytes=streamlen-data_ofs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ class AudioStreamPlaybackMPC : public AudioStreamPlayback {
|
||||||
bool preload;
|
bool preload;
|
||||||
FileAccess *f;
|
FileAccess *f;
|
||||||
String file;
|
String file;
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
int data_ofs;
|
int data_ofs;
|
||||||
int streamlen;
|
int streamlen;
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,11 @@
|
||||||
#include "scene/resources/bit_mask.h"
|
#include "scene/resources/bit_mask.h"
|
||||||
|
|
||||||
|
|
||||||
static bool _get_token(FileAccessRef& f,uint8_t &saved,DVector<uint8_t>& r_token,bool p_binary=false,bool p_single_chunk=false) {
|
static bool _get_token(FileAccessRef& f,uint8_t &saved,PoolVector<uint8_t>& r_token,bool p_binary=false,bool p_single_chunk=false) {
|
||||||
|
|
||||||
|
|
||||||
int token_max = r_token.size();
|
int token_max = r_token.size();
|
||||||
DVector<uint8_t>::Write w;
|
PoolVector<uint8_t>::Write w;
|
||||||
if (token_max)
|
if (token_max)
|
||||||
w=r_token.write();
|
w=r_token.write();
|
||||||
int ofs=0;
|
int ofs=0;
|
||||||
|
@ -53,7 +53,7 @@ static bool _get_token(FileAccessRef& f,uint8_t &saved,DVector<uint8_t>& r_token
|
||||||
}
|
}
|
||||||
if (f->eof_reached()) {
|
if (f->eof_reached()) {
|
||||||
if (ofs) {
|
if (ofs) {
|
||||||
w=DVector<uint8_t>::Write();
|
w=PoolVector<uint8_t>::Write();
|
||||||
r_token.resize(ofs);
|
r_token.resize(ofs);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -81,7 +81,7 @@ static bool _get_token(FileAccessRef& f,uint8_t &saved,DVector<uint8_t>& r_token
|
||||||
|
|
||||||
|
|
||||||
if (ofs && !p_single_chunk) {
|
if (ofs && !p_single_chunk) {
|
||||||
w=DVector<uint8_t>::Write();
|
w=PoolVector<uint8_t>::Write();
|
||||||
r_token.resize(ofs);
|
r_token.resize(ofs);
|
||||||
saved=b;
|
saved=b;
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ static bool _get_token(FileAccessRef& f,uint8_t &saved,DVector<uint8_t>& r_token
|
||||||
resized=true;
|
resized=true;
|
||||||
}
|
}
|
||||||
if (resized) {
|
if (resized) {
|
||||||
w=DVector<uint8_t>::Write();
|
w=PoolVector<uint8_t>::Write();
|
||||||
r_token.resize(token_max);
|
r_token.resize(token_max);
|
||||||
w=r_token.write();
|
w=r_token.write();
|
||||||
}
|
}
|
||||||
|
@ -109,10 +109,10 @@ static bool _get_token(FileAccessRef& f,uint8_t &saved,DVector<uint8_t>& r_token
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _get_number_from_token(DVector<uint8_t>& r_token) {
|
static int _get_number_from_token(PoolVector<uint8_t>& r_token) {
|
||||||
|
|
||||||
int len = r_token.size();
|
int len = r_token.size();
|
||||||
DVector<uint8_t>::Read r = r_token.read();
|
PoolVector<uint8_t>::Read r = r_token.read();
|
||||||
return String::to_int((const char*)r.ptr(),len);
|
return String::to_int((const char*)r.ptr(),len);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ RES ResourceFormatPBM::load(const String &p_path,const String& p_original_path,E
|
||||||
if (!f)
|
if (!f)
|
||||||
_RETURN(ERR_CANT_OPEN);
|
_RETURN(ERR_CANT_OPEN);
|
||||||
|
|
||||||
DVector<uint8_t> token;
|
PoolVector<uint8_t> token;
|
||||||
|
|
||||||
if (!_get_token(f,saved,token)) {
|
if (!_get_token(f,saved,token)) {
|
||||||
_RETURN(ERR_PARSE_ERROR);
|
_RETURN(ERR_PARSE_ERROR);
|
||||||
|
@ -186,7 +186,7 @@ RES ResourceFormatPBM::load(const String &p_path,const String& p_original_path,E
|
||||||
_RETURN(ERR_FILE_CORRUPT);
|
_RETURN(ERR_FILE_CORRUPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t>::Read r=token.read();
|
PoolVector<uint8_t>::Read r=token.read();
|
||||||
|
|
||||||
for(int i=0;i<height;i++) {
|
for(int i=0;i<height;i++) {
|
||||||
for(int j=0;j<width;j++) {
|
for(int j=0;j<width;j++) {
|
||||||
|
@ -210,7 +210,7 @@ RES ResourceFormatPBM::load(const String &p_path,const String& p_original_path,E
|
||||||
_RETURN(ERR_FILE_CORRUPT);
|
_RETURN(ERR_FILE_CORRUPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector<uint8_t>::Read r=token.read();
|
PoolVector<uint8_t>::Read r=token.read();
|
||||||
int bitwidth = width;
|
int bitwidth = width;
|
||||||
if (bitwidth % 8)
|
if (bitwidth % 8)
|
||||||
bitwidth+=8-(bitwidth%8);
|
bitwidth+=8-(bitwidth%8);
|
||||||
|
|
|
@ -99,13 +99,13 @@ RES ResourceFormatPVR::load(const String &p_path,const String& p_original_path,E
|
||||||
print_line("surfcount: "+itos(surfcount));
|
print_line("surfcount: "+itos(surfcount));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
data.resize(surfsize);
|
data.resize(surfsize);
|
||||||
|
|
||||||
ERR_FAIL_COND_V(data.size()==0,RES());
|
ERR_FAIL_COND_V(data.size()==0,RES());
|
||||||
|
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = data.write();
|
PoolVector<uint8_t>::Write w = data.write();
|
||||||
f->get_buffer(&w[0],surfsize);
|
f->get_buffer(&w[0],surfsize);
|
||||||
err = f->get_error();
|
err = f->get_error();
|
||||||
ERR_FAIL_COND_V(err!=OK,RES());
|
ERR_FAIL_COND_V(err!=OK,RES());
|
||||||
|
@ -151,7 +151,7 @@ RES ResourceFormatPVR::load(const String &p_path,const String& p_original_path,E
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w = DVector<uint8_t>::Write();
|
w = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
int tex_flags=Texture::FLAG_FILTER|Texture::FLAG_REPEAT;
|
int tex_flags=Texture::FLAG_FILTER|Texture::FLAG_REPEAT;
|
||||||
|
|
||||||
|
@ -209,10 +209,10 @@ static void _compress_pvrtc4(Image * p_img) {
|
||||||
|
|
||||||
Image new_img;
|
Image new_img;
|
||||||
new_img.create(img.get_width(),img.get_height(),true,use_alpha?Image::FORMAT_PVRTC4A:Image::FORMAT_PVRTC4);
|
new_img.create(img.get_width(),img.get_height(),true,use_alpha?Image::FORMAT_PVRTC4A:Image::FORMAT_PVRTC4);
|
||||||
DVector<uint8_t> data=new_img.get_data();
|
PoolVector<uint8_t> data=new_img.get_data();
|
||||||
{
|
{
|
||||||
DVector<uint8_t>::Write wr=data.write();
|
PoolVector<uint8_t>::Write wr=data.write();
|
||||||
DVector<uint8_t>::Read r=img.get_data().read();
|
PoolVector<uint8_t>::Read r=img.get_data().read();
|
||||||
|
|
||||||
|
|
||||||
for(int i=0;i<=new_img.get_mipmap_count();i++) {
|
for(int i=0;i<=new_img.get_mipmap_count();i++) {
|
||||||
|
@ -677,13 +677,13 @@ static void _pvrtc_decompress(Image* p_img) {
|
||||||
|
|
||||||
bool _2bit = (p_img->get_format()==Image::FORMAT_PVRTC2 || p_img->get_format()==Image::FORMAT_PVRTC2A );
|
bool _2bit = (p_img->get_format()==Image::FORMAT_PVRTC2 || p_img->get_format()==Image::FORMAT_PVRTC2A );
|
||||||
|
|
||||||
DVector<uint8_t> data = p_img->get_data();
|
PoolVector<uint8_t> data = p_img->get_data();
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
|
|
||||||
|
|
||||||
DVector<uint8_t> newdata;
|
PoolVector<uint8_t> newdata;
|
||||||
newdata.resize( p_img->get_width() * p_img->get_height() * 4);
|
newdata.resize( p_img->get_width() * p_img->get_height() * 4);
|
||||||
DVector<uint8_t>::Write w=newdata.write();
|
PoolVector<uint8_t>::Write w=newdata.write();
|
||||||
|
|
||||||
decompress_pvrtc((PVRTCBlock*)r.ptr(),_2bit,p_img->get_width(),p_img->get_height(),0,(unsigned char*)w.ptr());
|
decompress_pvrtc((PVRTCBlock*)r.ptr(),_2bit,p_img->get_width(),p_img->get_height(),0,(unsigned char*)w.ptr());
|
||||||
|
|
||||||
|
@ -691,8 +691,8 @@ static void _pvrtc_decompress(Image* p_img) {
|
||||||
// print_line(itos(w[i]));
|
// print_line(itos(w[i]));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
w=DVector<uint8_t>::Write();
|
w=PoolVector<uint8_t>::Write();
|
||||||
r=DVector<uint8_t>::Read();
|
r=PoolVector<uint8_t>::Read();
|
||||||
|
|
||||||
bool make_mipmaps=p_img->has_mipmaps();
|
bool make_mipmaps=p_img->has_mipmaps();
|
||||||
Image newimg(p_img->get_width(),p_img->get_height(),false,Image::FORMAT_RGBA8,newdata);
|
Image newimg(p_img->get_width(),p_img->get_height(),false,Image::FORMAT_RGBA8,newdata);
|
||||||
|
|
|
@ -66,12 +66,12 @@ void image_compress_squish(Image *p_image) {
|
||||||
|
|
||||||
int mm_count = p_image->get_mipmap_count();
|
int mm_count = p_image->get_mipmap_count();
|
||||||
|
|
||||||
DVector<uint8_t> data;
|
PoolVector<uint8_t> data;
|
||||||
int target_size = Image::get_image_data_size(w,h,target_format,mm_count);
|
int target_size = Image::get_image_data_size(w,h,target_format,mm_count);
|
||||||
data.resize(target_size);
|
data.resize(target_size);
|
||||||
|
|
||||||
DVector<uint8_t>::Read rb = p_image->get_data().read();
|
PoolVector<uint8_t>::Read rb = p_image->get_data().read();
|
||||||
DVector<uint8_t>::Write wb = data.write();
|
PoolVector<uint8_t>::Write wb = data.write();
|
||||||
|
|
||||||
int dst_ofs=0;
|
int dst_ofs=0;
|
||||||
|
|
||||||
|
@ -84,8 +84,8 @@ void image_compress_squish(Image *p_image) {
|
||||||
h>>=1;
|
h>>=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rb = DVector<uint8_t>::Read();
|
rb = PoolVector<uint8_t>::Read();
|
||||||
wb = DVector<uint8_t>::Write();
|
wb = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
p_image->create(p_image->get_width(),p_image->get_height(),p_image->has_mipmaps(),target_format,data);
|
p_image->create(p_image->get_width(),p_image->get_height(),p_image->has_mipmaps(),target_format,data);
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ void VideoStreamPlaybackTheora::video_write(void){
|
||||||
{
|
{
|
||||||
int pixels = size.x * size.y;
|
int pixels = size.x * size.y;
|
||||||
frame_data.resize(pixels * 4);
|
frame_data.resize(pixels * 4);
|
||||||
DVector<uint8_t>::Write w = frame_data.write();
|
PoolVector<uint8_t>::Write w = frame_data.write();
|
||||||
char* dst = (char*)w.ptr();
|
char* dst = (char*)w.ptr();
|
||||||
int p = 0;
|
int p = 0;
|
||||||
for (int i=0; i<size.y; i++) {
|
for (int i=0; i<size.y; i++) {
|
||||||
|
@ -112,7 +112,7 @@ void VideoStreamPlaybackTheora::video_write(void){
|
||||||
int pitch = 4;
|
int pitch = 4;
|
||||||
frame_data.resize(size.x * size.y * pitch);
|
frame_data.resize(size.x * size.y * pitch);
|
||||||
{
|
{
|
||||||
DVector<uint8_t>::Write w = frame_data.write();
|
PoolVector<uint8_t>::Write w = frame_data.write();
|
||||||
char* dst = (char*)w.ptr();
|
char* dst = (char*)w.ptr();
|
||||||
|
|
||||||
//uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y/2);
|
//uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y/2);
|
||||||
|
@ -143,7 +143,7 @@ void VideoStreamPlaybackTheora::video_write(void){
|
||||||
|
|
||||||
int pitch = 3;
|
int pitch = 3;
|
||||||
frame_data.resize(size.x * size.y * pitch);
|
frame_data.resize(size.x * size.y * pitch);
|
||||||
DVector<uint8_t>::Write w = frame_data.write();
|
PoolVector<uint8_t>::Write w = frame_data.write();
|
||||||
char* dst = (char*)w.ptr();
|
char* dst = (char*)w.ptr();
|
||||||
|
|
||||||
for(int i=0;i<size.y;i++) {
|
for(int i=0;i<size.y;i++) {
|
||||||
|
@ -174,7 +174,7 @@ void VideoStreamPlaybackTheora::video_write(void){
|
||||||
|
|
||||||
int pitch = 4;
|
int pitch = 4;
|
||||||
frame_data.resize(size.x * size.y * pitch);
|
frame_data.resize(size.x * size.y * pitch);
|
||||||
DVector<uint8_t>::Write w = frame_data.write();
|
PoolVector<uint8_t>::Write w = frame_data.write();
|
||||||
char* dst = (char*)w.ptr();
|
char* dst = (char*)w.ptr();
|
||||||
|
|
||||||
uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y / div);
|
uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y / div);
|
||||||
|
@ -208,7 +208,7 @@ void VideoStreamPlaybackTheora::video_write(void){
|
||||||
|
|
||||||
int pitch = 2;
|
int pitch = 2;
|
||||||
frame_data.resize(size.x * size.y * pitch);
|
frame_data.resize(size.x * size.y * pitch);
|
||||||
DVector<uint8_t>::Write w = frame_data.write();
|
PoolVector<uint8_t>::Write w = frame_data.write();
|
||||||
char* dst = (char*)w.ptr();
|
char* dst = (char*)w.ptr();
|
||||||
|
|
||||||
uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y / div);
|
uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y / div);
|
||||||
|
|
|
@ -51,7 +51,7 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback {
|
||||||
|
|
||||||
//Image frames[MAX_FRAMES];
|
//Image frames[MAX_FRAMES];
|
||||||
Image::Format format;
|
Image::Format format;
|
||||||
DVector<uint8_t> frame_data;
|
PoolVector<uint8_t> frame_data;
|
||||||
int frames_pending;
|
int frames_pending;
|
||||||
FileAccess* file;
|
FileAccess* file;
|
||||||
String file_name;
|
String file_name;
|
||||||
|
|
|
@ -293,7 +293,7 @@ void VideoStreamPlaybackWebm::update(float p_delta) {
|
||||||
|
|
||||||
if (err == VPXDecoder::NO_ERROR && image.w == webm->getWidth() && image.h == webm->getHeight()) {
|
if (err == VPXDecoder::NO_ERROR && image.w == webm->getWidth() && image.h == webm->getHeight()) {
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = frame_data.write();
|
PoolVector<uint8_t>::Write w = frame_data.write();
|
||||||
bool converted = false;
|
bool converted = false;
|
||||||
|
|
||||||
if (image.chromaShiftW == 1 && image.chromaShiftH == 1) {
|
if (image.chromaShiftW == 1 && image.chromaShiftH == 1) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ class VideoStreamPlaybackWebm : public VideoStreamPlayback {
|
||||||
double delay_compensation;
|
double delay_compensation;
|
||||||
double time, video_frame_delay, video_pos;
|
double time, video_frame_delay, video_pos;
|
||||||
|
|
||||||
DVector<uint8_t> frame_data;
|
PoolVector<uint8_t> frame_data;
|
||||||
Ref<ImageTexture> texture;
|
Ref<ImageTexture> texture;
|
||||||
|
|
||||||
int16_t *pcm;
|
int16_t *pcm;
|
||||||
|
|
|
@ -36,9 +36,9 @@
|
||||||
#include <webp/decode.h>
|
#include <webp/decode.h>
|
||||||
#include <webp/encode.h>
|
#include <webp/encode.h>
|
||||||
|
|
||||||
static DVector<uint8_t> _webp_lossy_pack(const Image& p_image,float p_quality) {
|
static PoolVector<uint8_t> _webp_lossy_pack(const Image& p_image,float p_quality) {
|
||||||
|
|
||||||
ERR_FAIL_COND_V(p_image.empty(),DVector<uint8_t>());
|
ERR_FAIL_COND_V(p_image.empty(),PoolVector<uint8_t>());
|
||||||
|
|
||||||
Image img=p_image;
|
Image img=p_image;
|
||||||
if (img.detect_alpha())
|
if (img.detect_alpha())
|
||||||
|
@ -47,8 +47,8 @@ static DVector<uint8_t> _webp_lossy_pack(const Image& p_image,float p_quality) {
|
||||||
img.convert(Image::FORMAT_RGB8);
|
img.convert(Image::FORMAT_RGB8);
|
||||||
|
|
||||||
Size2 s(img.get_width(),img.get_height());
|
Size2 s(img.get_width(),img.get_height());
|
||||||
DVector<uint8_t> data = img.get_data();
|
PoolVector<uint8_t> data = img.get_data();
|
||||||
DVector<uint8_t>::Read r = data.read();
|
PoolVector<uint8_t>::Read r = data.read();
|
||||||
|
|
||||||
uint8_t *dst_buff=NULL;
|
uint8_t *dst_buff=NULL;
|
||||||
size_t dst_size=0;
|
size_t dst_size=0;
|
||||||
|
@ -59,25 +59,25 @@ static DVector<uint8_t> _webp_lossy_pack(const Image& p_image,float p_quality) {
|
||||||
dst_size = WebPEncodeRGBA(r.ptr(),s.width,s.height,4*s.width,CLAMP(p_quality*100.0,0,100.0),&dst_buff);
|
dst_size = WebPEncodeRGBA(r.ptr(),s.width,s.height,4*s.width,CLAMP(p_quality*100.0,0,100.0),&dst_buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
ERR_FAIL_COND_V(dst_size==0,DVector<uint8_t>());
|
ERR_FAIL_COND_V(dst_size==0,PoolVector<uint8_t>());
|
||||||
DVector<uint8_t> dst;
|
PoolVector<uint8_t> dst;
|
||||||
dst.resize(4+dst_size);
|
dst.resize(4+dst_size);
|
||||||
DVector<uint8_t>::Write w = dst.write();
|
PoolVector<uint8_t>::Write w = dst.write();
|
||||||
w[0]='W';
|
w[0]='W';
|
||||||
w[1]='E';
|
w[1]='E';
|
||||||
w[2]='B';
|
w[2]='B';
|
||||||
w[3]='P';
|
w[3]='P';
|
||||||
copymem(&w[4],dst_buff,dst_size);
|
copymem(&w[4],dst_buff,dst_size);
|
||||||
free(dst_buff);
|
free(dst_buff);
|
||||||
w=DVector<uint8_t>::Write();
|
w=PoolVector<uint8_t>::Write();
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Image _webp_lossy_unpack(const DVector<uint8_t>& p_buffer) {
|
static Image _webp_lossy_unpack(const PoolVector<uint8_t>& p_buffer) {
|
||||||
|
|
||||||
int size = p_buffer.size()-4;
|
int size = p_buffer.size()-4;
|
||||||
ERR_FAIL_COND_V(size<=0,Image());
|
ERR_FAIL_COND_V(size<=0,Image());
|
||||||
DVector<uint8_t>::Read r = p_buffer.read();
|
PoolVector<uint8_t>::Read r = p_buffer.read();
|
||||||
|
|
||||||
ERR_FAIL_COND_V(r[0]!='W' || r[1]!='E' || r[2]!='B' || r[3]!='P',Image());
|
ERR_FAIL_COND_V(r[0]!='W' || r[1]!='E' || r[2]!='B' || r[3]!='P',Image());
|
||||||
WebPBitstreamFeatures features;
|
WebPBitstreamFeatures features;
|
||||||
|
@ -90,11 +90,11 @@ static Image _webp_lossy_unpack(const DVector<uint8_t>& p_buffer) {
|
||||||
//print_line("height: "+itos(features.height));
|
//print_line("height: "+itos(features.height));
|
||||||
//print_line("alpha: "+itos(features.has_alpha));
|
//print_line("alpha: "+itos(features.has_alpha));
|
||||||
|
|
||||||
DVector<uint8_t> dst_image;
|
PoolVector<uint8_t> dst_image;
|
||||||
int datasize = features.width*features.height*(features.has_alpha?4:3);
|
int datasize = features.width*features.height*(features.has_alpha?4:3);
|
||||||
dst_image.resize(datasize);
|
dst_image.resize(datasize);
|
||||||
|
|
||||||
DVector<uint8_t>::Write dst_w = dst_image.write();
|
PoolVector<uint8_t>::Write dst_w = dst_image.write();
|
||||||
|
|
||||||
bool errdec=false;
|
bool errdec=false;
|
||||||
if (features.has_alpha) {
|
if (features.has_alpha) {
|
||||||
|
@ -107,7 +107,7 @@ static Image _webp_lossy_unpack(const DVector<uint8_t>& p_buffer) {
|
||||||
//ERR_EXPLAIN("Error decoding webp! - "+p_file);
|
//ERR_EXPLAIN("Error decoding webp! - "+p_file);
|
||||||
ERR_FAIL_COND_V(errdec,Image());
|
ERR_FAIL_COND_V(errdec,Image());
|
||||||
|
|
||||||
dst_w = DVector<uint8_t>::Write();
|
dst_w = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
return Image(features.width,features.height,0,features.has_alpha?Image::FORMAT_RGBA8:Image::FORMAT_RGB8,dst_image);
|
return Image(features.width,features.height,0,features.has_alpha?Image::FORMAT_RGBA8:Image::FORMAT_RGB8,dst_image);
|
||||||
|
|
||||||
|
@ -118,12 +118,12 @@ Error ImageLoaderWEBP::load_image(Image *p_image,FileAccess *f) {
|
||||||
|
|
||||||
|
|
||||||
uint32_t size = f->get_len();
|
uint32_t size = f->get_len();
|
||||||
DVector<uint8_t> src_image;
|
PoolVector<uint8_t> src_image;
|
||||||
src_image.resize(size);
|
src_image.resize(size);
|
||||||
|
|
||||||
WebPBitstreamFeatures features;
|
WebPBitstreamFeatures features;
|
||||||
|
|
||||||
DVector<uint8_t>::Write src_w = src_image.write();
|
PoolVector<uint8_t>::Write src_w = src_image.write();
|
||||||
f->get_buffer(src_w.ptr(),size);
|
f->get_buffer(src_w.ptr(),size);
|
||||||
ERR_FAIL_COND_V(f->eof_reached(), ERR_FILE_EOF);
|
ERR_FAIL_COND_V(f->eof_reached(), ERR_FILE_EOF);
|
||||||
|
|
||||||
|
@ -137,14 +137,14 @@ Error ImageLoaderWEBP::load_image(Image *p_image,FileAccess *f) {
|
||||||
print_line("height: "+itos(features.height));
|
print_line("height: "+itos(features.height));
|
||||||
print_line("alpha: "+itos(features.has_alpha));
|
print_line("alpha: "+itos(features.has_alpha));
|
||||||
|
|
||||||
src_w = DVector<uint8_t>::Write();
|
src_w = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
DVector<uint8_t> dst_image;
|
PoolVector<uint8_t> dst_image;
|
||||||
int datasize = features.width*features.height*(features.has_alpha?4:3);
|
int datasize = features.width*features.height*(features.has_alpha?4:3);
|
||||||
dst_image.resize(datasize);
|
dst_image.resize(datasize);
|
||||||
|
|
||||||
DVector<uint8_t>::Read src_r = src_image.read();
|
PoolVector<uint8_t>::Read src_r = src_image.read();
|
||||||
DVector<uint8_t>::Write dst_w = dst_image.write();
|
PoolVector<uint8_t>::Write dst_w = dst_image.write();
|
||||||
|
|
||||||
|
|
||||||
bool errdec=false;
|
bool errdec=false;
|
||||||
|
@ -158,8 +158,8 @@ Error ImageLoaderWEBP::load_image(Image *p_image,FileAccess *f) {
|
||||||
//ERR_EXPLAIN("Error decoding webp! - "+p_file);
|
//ERR_EXPLAIN("Error decoding webp! - "+p_file);
|
||||||
ERR_FAIL_COND_V(errdec,ERR_FILE_CORRUPT);
|
ERR_FAIL_COND_V(errdec,ERR_FILE_CORRUPT);
|
||||||
|
|
||||||
src_r = DVector<uint8_t>::Read();
|
src_r = PoolVector<uint8_t>::Read();
|
||||||
dst_w = DVector<uint8_t>::Write();
|
dst_w = PoolVector<uint8_t>::Write();
|
||||||
|
|
||||||
*p_image = Image(features.width,features.height,0,features.has_alpha?Image::FORMAT_RGBA8:Image::FORMAT_RGB8,dst_image);
|
*p_image = Image(features.width,features.height,0,features.has_alpha?Image::FORMAT_RGBA8:Image::FORMAT_RGB8,dst_image);
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ public:
|
||||||
} break;
|
} break;
|
||||||
case Variant::STRING_ARRAY: {
|
case Variant::STRING_ARRAY: {
|
||||||
|
|
||||||
DVector<String> sarray = *p_args[i];
|
PoolVector<String> sarray = *p_args[i];
|
||||||
jobjectArray arr = env->NewObjectArray(sarray.size(),env->FindClass("java/lang/String"),env->NewStringUTF(""));
|
jobjectArray arr = env->NewObjectArray(sarray.size(),env->FindClass("java/lang/String"),env->NewStringUTF(""));
|
||||||
|
|
||||||
for(int j=0;j<sarray.size();j++) {
|
for(int j=0;j<sarray.size();j++) {
|
||||||
|
@ -165,18 +165,18 @@ public:
|
||||||
} break;
|
} break;
|
||||||
case Variant::INT_ARRAY: {
|
case Variant::INT_ARRAY: {
|
||||||
|
|
||||||
DVector<int> array = *p_args[i];
|
PoolVector<int> array = *p_args[i];
|
||||||
jintArray arr = env->NewIntArray(array.size());
|
jintArray arr = env->NewIntArray(array.size());
|
||||||
DVector<int>::Read r = array.read();
|
PoolVector<int>::Read r = array.read();
|
||||||
env->SetIntArrayRegion(arr,0,array.size(),r.ptr());
|
env->SetIntArrayRegion(arr,0,array.size(),r.ptr());
|
||||||
v[i].l=arr;
|
v[i].l=arr;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case Variant::REAL_ARRAY: {
|
case Variant::REAL_ARRAY: {
|
||||||
|
|
||||||
DVector<float> array = *p_args[i];
|
PoolVector<float> array = *p_args[i];
|
||||||
jfloatArray arr = env->NewFloatArray(array.size());
|
jfloatArray arr = env->NewFloatArray(array.size());
|
||||||
DVector<float>::Read r = array.read();
|
PoolVector<float>::Read r = array.read();
|
||||||
env->SetFloatArrayRegion(arr,0,array.size(),r.ptr());
|
env->SetFloatArrayRegion(arr,0,array.size(),r.ptr());
|
||||||
v[i].l=arr;
|
v[i].l=arr;
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ public:
|
||||||
jobjectArray arr = (jobjectArray)env->CallObjectMethodA(instance,E->get().method,v);
|
jobjectArray arr = (jobjectArray)env->CallObjectMethodA(instance,E->get().method,v);
|
||||||
|
|
||||||
int stringCount = env->GetArrayLength(arr);
|
int stringCount = env->GetArrayLength(arr);
|
||||||
DVector<String> sarr;
|
PoolVector<String> sarr;
|
||||||
|
|
||||||
for (int i=0; i<stringCount; i++) {
|
for (int i=0; i<stringCount; i++) {
|
||||||
jstring string = (jstring) env->GetObjectArrayElement(arr, i);
|
jstring string = (jstring) env->GetObjectArrayElement(arr, i);
|
||||||
|
@ -241,12 +241,12 @@ public:
|
||||||
jintArray arr = (jintArray)env->CallObjectMethodA(instance,E->get().method,v);
|
jintArray arr = (jintArray)env->CallObjectMethodA(instance,E->get().method,v);
|
||||||
|
|
||||||
int fCount = env->GetArrayLength(arr);
|
int fCount = env->GetArrayLength(arr);
|
||||||
DVector<int> sarr;
|
PoolVector<int> sarr;
|
||||||
sarr.resize(fCount);
|
sarr.resize(fCount);
|
||||||
|
|
||||||
DVector<int>::Write w = sarr.write();
|
PoolVector<int>::Write w = sarr.write();
|
||||||
env->GetIntArrayRegion(arr,0,fCount,w.ptr());
|
env->GetIntArrayRegion(arr,0,fCount,w.ptr());
|
||||||
w = DVector<int>::Write();
|
w = PoolVector<int>::Write();
|
||||||
ret=sarr;
|
ret=sarr;
|
||||||
} break;
|
} break;
|
||||||
case Variant::REAL_ARRAY: {
|
case Variant::REAL_ARRAY: {
|
||||||
|
@ -254,12 +254,12 @@ public:
|
||||||
jfloatArray arr = (jfloatArray)env->CallObjectMethodA(instance,E->get().method,v);
|
jfloatArray arr = (jfloatArray)env->CallObjectMethodA(instance,E->get().method,v);
|
||||||
|
|
||||||
int fCount = env->GetArrayLength(arr);
|
int fCount = env->GetArrayLength(arr);
|
||||||
DVector<float> sarr;
|
PoolVector<float> sarr;
|
||||||
sarr.resize(fCount);
|
sarr.resize(fCount);
|
||||||
|
|
||||||
DVector<float>::Write w = sarr.write();
|
PoolVector<float>::Write w = sarr.write();
|
||||||
env->GetFloatArrayRegion(arr,0,fCount,w.ptr());
|
env->GetFloatArrayRegion(arr,0,fCount,w.ptr());
|
||||||
w = DVector<float>::Write();
|
w = PoolVector<float>::Write();
|
||||||
ret=sarr;
|
ret=sarr;
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -122,7 +122,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_a
|
||||||
} break;
|
} break;
|
||||||
case Variant::STRING_ARRAY: {
|
case Variant::STRING_ARRAY: {
|
||||||
|
|
||||||
DVector<String> sarray = *p_arg;
|
PoolVector<String> sarray = *p_arg;
|
||||||
jobjectArray arr = env->NewObjectArray(sarray.size(),env->FindClass("java/lang/String"),env->NewStringUTF(""));
|
jobjectArray arr = env->NewObjectArray(sarray.size(),env->FindClass("java/lang/String"),env->NewStringUTF(""));
|
||||||
|
|
||||||
for(int j=0;j<sarray.size();j++) {
|
for(int j=0;j<sarray.size();j++) {
|
||||||
|
@ -181,18 +181,18 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_a
|
||||||
|
|
||||||
case Variant::INT_ARRAY: {
|
case Variant::INT_ARRAY: {
|
||||||
|
|
||||||
DVector<int> array = *p_arg;
|
PoolVector<int> array = *p_arg;
|
||||||
jintArray arr = env->NewIntArray(array.size());
|
jintArray arr = env->NewIntArray(array.size());
|
||||||
DVector<int>::Read r = array.read();
|
PoolVector<int>::Read r = array.read();
|
||||||
env->SetIntArrayRegion(arr,0,array.size(),r.ptr());
|
env->SetIntArrayRegion(arr,0,array.size(),r.ptr());
|
||||||
v.val.l=arr;
|
v.val.l=arr;
|
||||||
v.obj=arr;
|
v.obj=arr;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case Variant::RAW_ARRAY: {
|
case Variant::RAW_ARRAY: {
|
||||||
DVector<uint8_t> array = *p_arg;
|
PoolVector<uint8_t> array = *p_arg;
|
||||||
jbyteArray arr = env->NewByteArray(array.size());
|
jbyteArray arr = env->NewByteArray(array.size());
|
||||||
DVector<uint8_t>::Read r = array.read();
|
PoolVector<uint8_t>::Read r = array.read();
|
||||||
env->SetByteArrayRegion(arr,0,array.size(),reinterpret_cast<const signed char*>(r.ptr()));
|
env->SetByteArrayRegion(arr,0,array.size(),reinterpret_cast<const signed char*>(r.ptr()));
|
||||||
v.val.l=arr;
|
v.val.l=arr;
|
||||||
v.obj=arr;
|
v.obj=arr;
|
||||||
|
@ -200,9 +200,9 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_a
|
||||||
} break;
|
} break;
|
||||||
case Variant::REAL_ARRAY: {
|
case Variant::REAL_ARRAY: {
|
||||||
|
|
||||||
DVector<float> array = *p_arg;
|
PoolVector<float> array = *p_arg;
|
||||||
jfloatArray arr = env->NewFloatArray(array.size());
|
jfloatArray arr = env->NewFloatArray(array.size());
|
||||||
DVector<float>::Read r = array.read();
|
PoolVector<float>::Read r = array.read();
|
||||||
env->SetFloatArrayRegion(arr,0,array.size(),r.ptr());
|
env->SetFloatArrayRegion(arr,0,array.size(),r.ptr());
|
||||||
v.val.l=arr;
|
v.val.l=arr;
|
||||||
v.obj=arr;
|
v.obj=arr;
|
||||||
|
@ -259,7 +259,7 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
|
||||||
jobjectArray arr = (jobjectArray)obj;
|
jobjectArray arr = (jobjectArray)obj;
|
||||||
int stringCount = env->GetArrayLength(arr);
|
int stringCount = env->GetArrayLength(arr);
|
||||||
//print_line("String array! " + String::num(stringCount));
|
//print_line("String array! " + String::num(stringCount));
|
||||||
DVector<String> sarr;
|
PoolVector<String> sarr;
|
||||||
|
|
||||||
for (int i=0; i<stringCount; i++) {
|
for (int i=0; i<stringCount; i++) {
|
||||||
jstring string = (jstring) env->GetObjectArrayElement(arr, i);
|
jstring string = (jstring) env->GetObjectArrayElement(arr, i);
|
||||||
|
@ -290,12 +290,12 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
|
||||||
|
|
||||||
jintArray arr = (jintArray)obj;
|
jintArray arr = (jintArray)obj;
|
||||||
int fCount = env->GetArrayLength(arr);
|
int fCount = env->GetArrayLength(arr);
|
||||||
DVector<int> sarr;
|
PoolVector<int> sarr;
|
||||||
sarr.resize(fCount);
|
sarr.resize(fCount);
|
||||||
|
|
||||||
DVector<int>::Write w = sarr.write();
|
PoolVector<int>::Write w = sarr.write();
|
||||||
env->GetIntArrayRegion(arr,0,fCount,w.ptr());
|
env->GetIntArrayRegion(arr,0,fCount,w.ptr());
|
||||||
w = DVector<int>::Write();
|
w = PoolVector<int>::Write();
|
||||||
return sarr;
|
return sarr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -303,12 +303,12 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
|
||||||
|
|
||||||
jbyteArray arr = (jbyteArray)obj;
|
jbyteArray arr = (jbyteArray)obj;
|
||||||
int fCount = env->GetArrayLength(arr);
|
int fCount = env->GetArrayLength(arr);
|
||||||
DVector<uint8_t> sarr;
|
PoolVector<uint8_t> sarr;
|
||||||
sarr.resize(fCount);
|
sarr.resize(fCount);
|
||||||
|
|
||||||
DVector<uint8_t>::Write w = sarr.write();
|
PoolVector<uint8_t>::Write w = sarr.write();
|
||||||
env->GetByteArrayRegion(arr,0,fCount,reinterpret_cast<signed char*>(w.ptr()));
|
env->GetByteArrayRegion(arr,0,fCount,reinterpret_cast<signed char*>(w.ptr()));
|
||||||
w = DVector<uint8_t>::Write();
|
w = PoolVector<uint8_t>::Write();
|
||||||
return sarr;
|
return sarr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -540,12 +540,12 @@ public:
|
||||||
jintArray arr = (jintArray)env->CallObjectMethodA(instance,E->get().method,v);
|
jintArray arr = (jintArray)env->CallObjectMethodA(instance,E->get().method,v);
|
||||||
|
|
||||||
int fCount = env->GetArrayLength(arr);
|
int fCount = env->GetArrayLength(arr);
|
||||||
DVector<int> sarr;
|
PoolVector<int> sarr;
|
||||||
sarr.resize(fCount);
|
sarr.resize(fCount);
|
||||||
|
|
||||||
DVector<int>::Write w = sarr.write();
|
PoolVector<int>::Write w = sarr.write();
|
||||||
env->GetIntArrayRegion(arr,0,fCount,w.ptr());
|
env->GetIntArrayRegion(arr,0,fCount,w.ptr());
|
||||||
w = DVector<int>::Write();
|
w = PoolVector<int>::Write();
|
||||||
ret=sarr;
|
ret=sarr;
|
||||||
env->DeleteLocalRef(arr);
|
env->DeleteLocalRef(arr);
|
||||||
} break;
|
} break;
|
||||||
|
@ -554,12 +554,12 @@ public:
|
||||||
jfloatArray arr = (jfloatArray)env->CallObjectMethodA(instance,E->get().method,v);
|
jfloatArray arr = (jfloatArray)env->CallObjectMethodA(instance,E->get().method,v);
|
||||||
|
|
||||||
int fCount = env->GetArrayLength(arr);
|
int fCount = env->GetArrayLength(arr);
|
||||||
DVector<float> sarr;
|
PoolVector<float> sarr;
|
||||||
sarr.resize(fCount);
|
sarr.resize(fCount);
|
||||||
|
|
||||||
DVector<float>::Write w = sarr.write();
|
PoolVector<float>::Write w = sarr.write();
|
||||||
env->GetFloatArrayRegion(arr,0,fCount,w.ptr());
|
env->GetFloatArrayRegion(arr,0,fCount,w.ptr());
|
||||||
w = DVector<float>::Write();
|
w = PoolVector<float>::Write();
|
||||||
ret=sarr;
|
ret=sarr;
|
||||||
env->DeleteLocalRef(arr);
|
env->DeleteLocalRef(arr);
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -286,7 +286,7 @@ void RasterizerIPhone::texture_blit_rect(RID p_texture,int p_x,int p_y, const Im
|
||||||
|
|
||||||
GLenum blit_target = GL_TEXTURE_2D; //(texture->target == GL_TEXTURE_CUBE_MAP)?_cube_side_enum[p_cube_side]:GL_TEXTURE_2D;
|
GLenum blit_target = GL_TEXTURE_2D; //(texture->target == GL_TEXTURE_CUBE_MAP)?_cube_side_enum[p_cube_side]:GL_TEXTURE_2D;
|
||||||
|
|
||||||
DVector<uint8_t>::Read read = img.get_data().read();
|
PoolVector<uint8_t>::Read read = img.get_data().read();
|
||||||
|
|
||||||
glBindTexture(texture->target, texture->tex_id);
|
glBindTexture(texture->target, texture->tex_id);
|
||||||
glTexSubImage2D( blit_target, 0, p_x,p_y,img.get_width(),img.get_height(),format,GL_UNSIGNED_BYTE,read.ptr() );
|
glTexSubImage2D( blit_target, 0, p_x,p_y,img.get_width(),img.get_height(),format,GL_UNSIGNED_BYTE,read.ptr() );
|
||||||
|
@ -770,7 +770,7 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr
|
||||||
ERR_FAIL_COND_V( surface->index_array_len<=0, ERR_INVALID_DATA );
|
ERR_FAIL_COND_V( surface->index_array_len<=0, ERR_INVALID_DATA );
|
||||||
ERR_FAIL_COND_V( p_array.get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_array.get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
DVector<int> indices = p_array;
|
PoolVector<int> indices = p_array;
|
||||||
ERR_FAIL_COND_V( indices.size() == 0, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( indices.size() == 0, ERR_INVALID_PARAMETER );
|
||||||
ERR_FAIL_COND_V( indices.size() != surface->index_array_len, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( indices.size() != surface->index_array_len, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
|
@ -780,7 +780,7 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,surface->index_id);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,surface->index_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
DVector<int>::Read read = indices.read();
|
PoolVector<int>::Read read = indices.read();
|
||||||
const int *src=read.ptr();
|
const int *src=read.ptr();
|
||||||
|
|
||||||
for (int i=0;i<surface->index_array_len;i++) {
|
for (int i=0;i<surface->index_array_len;i++) {
|
||||||
|
@ -822,14 +822,14 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr
|
||||||
ERR_FAIL_COND_V( p_array.get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_array.get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
|
|
||||||
DVector<Vector3> array = p_array;
|
PoolVector<Vector3> array = p_array;
|
||||||
ERR_FAIL_COND_V( array.size() != surface->array_len, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( array.size() != surface->array_len, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
if (surface->array_local == 0) {
|
if (surface->array_local == 0) {
|
||||||
glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id);
|
glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
DVector<Vector3>::Read read = array.read();
|
PoolVector<Vector3>::Read read = array.read();
|
||||||
const Vector3* src=read.ptr();
|
const Vector3* src=read.ptr();
|
||||||
|
|
||||||
// setting vertices means regenerating the AABB
|
// setting vertices means regenerating the AABB
|
||||||
|
@ -868,7 +868,7 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr
|
||||||
|
|
||||||
ERR_FAIL_COND_V( p_array.get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_array.get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
DVector<real_t> array = p_array;
|
PoolVector<real_t> array = p_array;
|
||||||
|
|
||||||
ERR_FAIL_COND_V( array.size() != surface->array_len*4, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( array.size() != surface->array_len*4, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
|
@ -877,7 +877,7 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
DVector<real_t>::Read read = array.read();
|
PoolVector<real_t>::Read read = array.read();
|
||||||
const real_t* src = read.ptr();
|
const real_t* src = read.ptr();
|
||||||
|
|
||||||
for (int i=0;i<surface->array_len;i++) {
|
for (int i=0;i<surface->array_len;i++) {
|
||||||
|
@ -908,7 +908,7 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr
|
||||||
ERR_FAIL_COND_V( p_array.get_type() != Variant::COLOR_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_array.get_type() != Variant::COLOR_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
|
|
||||||
DVector<Color> array = p_array;
|
PoolVector<Color> array = p_array;
|
||||||
|
|
||||||
ERR_FAIL_COND_V( array.size() != surface->array_len, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( array.size() != surface->array_len, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
|
@ -916,7 +916,7 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr
|
||||||
glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id);
|
glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id);
|
||||||
|
|
||||||
|
|
||||||
DVector<Color>::Read read = array.read();
|
PoolVector<Color>::Read read = array.read();
|
||||||
const Color* src = read.ptr();
|
const Color* src = read.ptr();
|
||||||
surface->has_alpha_cache=false;
|
surface->has_alpha_cache=false;
|
||||||
|
|
||||||
|
@ -943,14 +943,14 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr
|
||||||
|
|
||||||
ERR_FAIL_COND_V( p_array.get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_array.get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
DVector<Vector3> array = p_array;
|
PoolVector<Vector3> array = p_array;
|
||||||
|
|
||||||
ERR_FAIL_COND_V( array.size() != surface->array_len , ERR_INVALID_PARAMETER);
|
ERR_FAIL_COND_V( array.size() != surface->array_len , ERR_INVALID_PARAMETER);
|
||||||
|
|
||||||
if (surface->array_local == 0)
|
if (surface->array_local == 0)
|
||||||
glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id);
|
glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id);
|
||||||
|
|
||||||
DVector<Vector3>::Read read = array.read();
|
PoolVector<Vector3>::Read read = array.read();
|
||||||
|
|
||||||
const Vector3 * src=read.ptr();
|
const Vector3 * src=read.ptr();
|
||||||
|
|
||||||
|
@ -975,14 +975,14 @@ Error RasterizerIPhone::mesh_surface_set_array(RID p_mesh, int p_surface,VS::Arr
|
||||||
|
|
||||||
ERR_FAIL_COND_V( p_array.get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( p_array.get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
DVector<real_t> array = p_array;
|
PoolVector<real_t> array = p_array;
|
||||||
|
|
||||||
ERR_FAIL_COND_V( array.size() != surface->array_len*VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER );
|
ERR_FAIL_COND_V( array.size() != surface->array_len*VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER );
|
||||||
|
|
||||||
if (surface->array_local == 0)
|
if (surface->array_local == 0)
|
||||||
glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id);
|
glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id);
|
||||||
|
|
||||||
DVector<real_t>::Read read = array.read();
|
PoolVector<real_t>::Read read = array.read();
|
||||||
|
|
||||||
const real_t * src = read.ptr();
|
const real_t * src = read.ptr();
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue