From 2ab83e1abbf5ee6d00e16056a9e9394114026f28 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 7 Jan 2017 18:25:37 -0300 Subject: [PATCH] Memory pool vectors (DVector) have been enormously simplified in code, and renamed to PoolVector --- bin/tests/test_math.cpp | 33 +- bin/tests/test_physics.cpp | 8 +- bin/tests/test_physics_2d.cpp | 10 +- bin/tests/test_render.cpp | 2 +- core/bind/core_bind.cpp | 96 +-- core/bind/core_bind.h | 28 +- core/compressed_translation.cpp | 12 +- core/compressed_translation.h | 6 +- core/dvector.cpp | 41 ++ core/dvector.h | 550 ++++++++++++------ core/globals.cpp | 10 +- core/image.cpp | 100 ++-- core/image.h | 16 +- core/io/file_access_buffered.cpp | 4 +- core/io/file_access_buffered_fa.h | 2 +- core/io/http_client.cpp | 6 +- core/io/http_client.h | 2 +- core/io/marshalls.cpp | 62 +- core/io/packet_peer.cpp | 14 +- core/io/packet_peer.h | 8 +- core/io/resource_format_binary.cpp | 88 +-- core/io/resource_format_xml.cpp | 96 +-- core/io/stream_peer.cpp | 32 +- core/io/stream_peer.h | 10 +- core/io/tcp_server.cpp | 4 +- core/io/tcp_server.h | 2 +- core/math/a_star.cpp | 28 +- core/math/a_star.h | 4 +- core/math/bsp_tree.cpp | 14 +- core/math/bsp_tree.h | 2 +- core/math/geometry.cpp | 44 +- core/math/geometry.h | 14 +- core/math/triangle_mesh.cpp | 48 +- core/math/triangle_mesh.h | 10 +- core/method_ptrcall.h | 64 +- core/object.cpp | 45 +- core/object.h | 8 +- core/object_type_db.cpp | 77 ++- core/object_type_db.h | 2 +- core/os/memory.cpp | 83 --- core/os/memory.h | 104 +--- core/os/memory_pool_dynamic.cpp | 50 -- core/os/memory_pool_dynamic.h | 79 --- core/os/memory_pool_dynamic_prealloc.cpp | 116 ---- core/os/memory_pool_dynamic_prealloc.h | 60 -- core/os/memory_pool_dynamic_static.cpp | 272 --------- core/os/memory_pool_dynamic_static.h | 86 --- core/os/os.cpp | 2 +- core/os/rw_lock.cpp | 21 + core/os/rw_lock.h | 46 ++ core/packed_data_container.cpp | 14 +- core/packed_data_container.h | 6 +- core/path_remap.cpp | 6 +- core/register_core_types.cpp | 6 + core/resource.cpp | 59 +- core/resource.h | 3 + core/safe_refcount.cpp | 9 + core/safe_refcount.h | 1 + core/string_db.cpp | 53 +- core/string_db.h | 3 +- core/translation.cpp | 16 +- core/translation.h | 6 +- core/variant.cpp | 234 ++++---- core/variant.h | 50 +- core/variant_call.cpp | 4 +- core/variant_op.cpp | 112 ++-- core/variant_parser.cpp | 64 +- core/vector.h | 2 +- drivers/gles2/rasterizer_gles2.cpp | 90 +-- drivers/gles3/rasterizer_scene_gles3.cpp | 4 +- drivers/gles3/rasterizer_storage_gles3.cpp | 110 ++-- drivers/gles3/rasterizer_storage_gles3.h | 24 +- drivers/png/image_loader_png.cpp | 32 +- drivers/png/resource_saver_png.cpp | 2 +- drivers/unix/os_unix.cpp | 7 +- drivers/unix/rw_lock_posix.cpp | 76 +++ drivers/unix/rw_lock_posix.h | 37 ++ main/performance.cpp | 6 +- modules/chibi/event_stream_chibi.cpp | 4 +- modules/chibi/event_stream_chibi.h | 4 +- modules/dds/texture_loader_dds.cpp | 14 +- modules/etc1/image_etc.cpp | 18 +- modules/etc1/texture_loader_pkm.cpp | 6 +- modules/gdscript/gd_script.cpp | 4 +- modules/gridmap/grid_map.cpp | 24 +- modules/gridmap/grid_map_editor_plugin.cpp | 6 +- modules/jpg/image_loader_jpegd.cpp | 12 +- modules/mpc/audio_stream_mpc.cpp | 4 +- modules/mpc/audio_stream_mpc.h | 2 +- modules/pbm/bitmap_loader_pbm.cpp | 20 +- modules/pvr/texture_loader_pvr.cpp | 24 +- modules/squish/image_compress_squish.cpp | 10 +- modules/theora/video_stream_theora.cpp | 10 +- modules/theora/video_stream_theora.h | 2 +- modules/webm/video_stream_webm.cpp | 2 +- modules/webm/video_stream_webm.h | 2 +- modules/webp/image_loader_webp.cpp | 42 +- platform/android/godot_android.cpp | 24 +- platform/android/java_glue.cpp | 40 +- platform/iphone/rasterizer_iphone.cpp | 26 +- .../javascript/audio_server_javascript.cpp | 8 +- platform/javascript/audio_server_javascript.h | 4 +- platform/osx/os_osx.mm | 4 +- platform/windows/os_windows.cpp | 2 +- platform/x11/os_x11.cpp | 2 +- scene/2d/collision_polygon_2d.cpp | 6 +- scene/2d/light_occluder_2d.cpp | 8 +- scene/2d/light_occluder_2d.h | 6 +- scene/2d/navigation2d.cpp | 4 +- scene/2d/navigation_polygon.cpp | 30 +- scene/2d/navigation_polygon.h | 16 +- scene/2d/particles_2d.cpp | 6 +- scene/2d/particles_2d.h | 6 +- scene/2d/polygon_2d.cpp | 20 +- scene/2d/polygon_2d.h | 18 +- scene/2d/tile_map.cpp | 12 +- scene/2d/tile_map.h | 4 +- scene/3d/baked_light_instance.cpp | 34 +- scene/3d/baked_light_instance.h | 8 +- scene/3d/body_shape.cpp | 10 +- scene/3d/collision_polygon.cpp | 10 +- scene/3d/gi_probe.cpp | 30 +- scene/3d/gi_probe.h | 6 +- scene/3d/immediate_geometry.cpp | 4 +- scene/3d/immediate_geometry.h | 2 +- scene/3d/light.cpp | 4 +- scene/3d/light.h | 2 +- scene/3d/mesh_instance.cpp | 6 +- scene/3d/mesh_instance.h | 2 +- scene/3d/multimesh_instance.cpp | 4 +- scene/3d/multimesh_instance.h | 2 +- scene/3d/navigation.cpp | 4 +- scene/3d/navigation_mesh.cpp | 24 +- scene/3d/navigation_mesh.h | 6 +- scene/3d/particles.cpp | 10 +- scene/3d/particles.h | 6 +- scene/3d/portal.cpp | 12 +- scene/3d/portal.h | 2 +- scene/3d/quad.cpp | 28 +- scene/3d/quad.h | 2 +- scene/3d/reflection_probe.cpp | 4 +- scene/3d/reflection_probe.h | 2 +- scene/3d/room_instance.cpp | 12 +- scene/3d/room_instance.h | 4 +- scene/3d/sprite_3d.cpp | 4 +- scene/3d/sprite_3d.h | 2 +- scene/3d/test_cube.cpp | 4 +- scene/3d/test_cube.h | 2 +- scene/3d/visual_instance.h | 2 +- scene/animation/animation_player.h | 4 +- scene/animation/animation_tree_player.cpp | 4 +- scene/animation/animation_tree_player.h | 2 +- scene/gui/color_picker.cpp | 6 +- scene/gui/file_dialog.cpp | 2 +- scene/gui/text_edit.cpp | 6 +- scene/gui/text_edit.h | 2 +- scene/io/resource_format_wav.cpp | 6 +- scene/main/http_request.h | 2 +- scene/main/resource_preloader.cpp | 8 +- scene/main/resource_preloader.h | 2 +- scene/main/scene_main_loop.cpp | 4 +- scene/resources/animation.cpp | 52 +- scene/resources/animation.h | 8 +- scene/resources/bit_mask.cpp | 2 +- scene/resources/concave_polygon_shape.cpp | 8 +- scene/resources/concave_polygon_shape.h | 4 +- scene/resources/concave_polygon_shape_2d.cpp | 12 +- scene/resources/concave_polygon_shape_2d.h | 4 +- scene/resources/convex_polygon_shape.cpp | 6 +- scene/resources/convex_polygon_shape.h | 6 +- scene/resources/curve.cpp | 8 +- scene/resources/curve.h | 2 +- scene/resources/dynamic_font.cpp | 4 +- scene/resources/dynamic_font.h | 2 +- scene/resources/dynamic_font_stb.cpp | 12 +- scene/resources/dynamic_font_stb.h | 8 +- scene/resources/font.cpp | 16 +- scene/resources/font.h | 8 +- scene/resources/mesh.cpp | 106 ++-- scene/resources/mesh.h | 4 +- scene/resources/mesh_data_tool.cpp | 74 +-- scene/resources/multimesh.cpp | 26 +- scene/resources/multimesh.h | 8 +- scene/resources/packed_scene.cpp | 20 +- scene/resources/packed_scene.h | 2 +- scene/resources/polygon_path_finder.cpp | 32 +- scene/resources/room.cpp | 4 +- scene/resources/room.h | 6 +- scene/resources/sample.cpp | 6 +- scene/resources/sample.h | 4 +- scene/resources/shader_graph.cpp | 46 +- scene/resources/shader_graph.h | 10 +- scene/resources/shape.cpp | 8 +- scene/resources/shape.h | 2 +- scene/resources/surface_tool.cpp | 78 +-- scene/resources/theme.h | 14 +- servers/audio/audio_server_sw.cpp | 4 +- servers/audio/audio_server_sw.h | 4 +- servers/audio/sample_manager_sw.cpp | 14 +- servers/audio/sample_manager_sw.h | 8 +- servers/audio_server.cpp | 10 +- servers/audio_server.h | 6 +- servers/physics/shape_sw.cpp | 62 +- servers/physics/shape_sw.h | 16 +- servers/physics_2d/shape_2d_sw.cpp | 20 +- .../spatial_sound_2d_server_sw.cpp | 6 +- .../spatial_sound_2d_server_sw.h | 6 +- servers/spatial_sound_2d_server.h | 4 +- servers/visual/rasterizer.h | 24 +- servers/visual/visual_server_canvas.cpp | 12 +- servers/visual/visual_server_canvas.h | 4 +- servers/visual/visual_server_raster.cpp | 42 +- servers/visual/visual_server_raster.h | 22 +- servers/visual/visual_server_scene.cpp | 24 +- servers/visual/visual_server_scene.h | 10 +- servers/visual_server.cpp | 183 +++--- servers/visual_server.h | 28 +- tools/editor/editor_file_dialog.cpp | 2 +- tools/editor/editor_import_export.cpp | 8 +- tools/editor/editor_import_export.h | 4 +- tools/editor/editor_profiler.cpp | 4 +- tools/editor/editor_profiler.h | 2 +- .../io_plugins/editor_font_import_plugin.cpp | 10 +- .../io_plugins/editor_import_collada.cpp | 104 ++-- .../editor_sample_import_plugin.cpp | 22 +- .../io_plugins/editor_sample_import_plugin.h | 2 +- .../io_plugins/editor_scene_import_plugin.cpp | 4 +- .../editor_scene_importer_fbxconv.cpp | 32 +- .../editor_texture_import_plugin.cpp | 4 +- tools/editor/plugins/baked_light_baker.cpp | 40 +- tools/editor/plugins/baked_light_baker.h | 4 +- .../plugins/baked_light_editor_plugin.cpp | 2 +- .../plugins/baked_light_editor_plugin.h | 6 +- .../plugins/canvas_item_editor_plugin.cpp | 2 +- .../collision_polygon_editor_plugin.cpp | 4 +- .../plugins/color_ramp_editor_plugin.cpp | 2 +- .../editor/plugins/editor_preview_plugins.cpp | 26 +- .../editor/plugins/material_editor_plugin.cpp | 18 +- .../plugins/multimesh_editor_plugin.cpp | 10 +- .../navigation_polygon_editor_plugin.cpp | 18 +- .../navigation_polygon_editor_plugin.h | 2 +- .../plugins/particles_2d_editor_plugin.cpp | 12 +- .../plugins/particles_editor_plugin.cpp | 8 +- .../editor/plugins/particles_editor_plugin.h | 2 +- .../plugins/polygon_2d_editor_plugin.cpp | 26 +- .../editor/plugins/polygon_2d_editor_plugin.h | 2 +- tools/editor/plugins/sample_editor_plugin.cpp | 10 +- .../plugins/sample_library_editor_plugin.cpp | 4 +- .../plugins/sample_library_editor_plugin.h | 2 +- .../plugins/shader_graph_editor_plugin.cpp | 30 +- .../editor/plugins/spatial_editor_plugin.cpp | 10 +- .../plugins/sprite_frames_editor_plugin.cpp | 4 +- .../plugins/sprite_frames_editor_plugin.h | 2 +- .../editor/plugins/tile_map_editor_plugin.cpp | 24 +- tools/editor/plugins/tile_map_editor_plugin.h | 8 +- tools/editor/project_export.cpp | 4 +- tools/editor/spatial_editor_gizmos.cpp | 32 +- 257 files changed, 2818 insertions(+), 3130 deletions(-) delete mode 100644 core/os/memory_pool_dynamic.cpp delete mode 100644 core/os/memory_pool_dynamic.h delete mode 100644 core/os/memory_pool_dynamic_prealloc.cpp delete mode 100644 core/os/memory_pool_dynamic_prealloc.h delete mode 100644 core/os/memory_pool_dynamic_static.cpp delete mode 100644 core/os/memory_pool_dynamic_static.h create mode 100644 core/os/rw_lock.cpp create mode 100644 core/os/rw_lock.h create mode 100644 drivers/unix/rw_lock_posix.cpp create mode 100644 drivers/unix/rw_lock_posix.h diff --git a/bin/tests/test_math.cpp b/bin/tests/test_math.cpp index e3e74af14c6..b3b70986c90 100644 --- a/bin/tests/test_math.cpp +++ b/bin/tests/test_math.cpp @@ -477,17 +477,34 @@ uint32_t ihash3( uint32_t a) MainLoop* test() { - Matrix3 m; - m.rotate(Vector3(0,1,0),Math_PI*0.5); - print_line(m.scaled(Vector3(0.5,1,1))); - Matrix3 s; - s.scale(Vector3(0.5,1.0,1.0)); + print_line("Dvectors: "+itos(MemoryPool::allocs_used)); + print_line("Mem used: "+itos(MemoryPool::total_memory)); + print_line("MAx mem used: "+itos(MemoryPool::max_memory)); - print_line(m * s); + PoolVector ints; + ints.resize(20); + { + PoolVector::Write w; + w = ints.write(); + for(int i=0;i posho = ints; + { + PoolVector::Read r = posho.read(); + for(int i=0;i a; - DVector b; + PoolVector a; + PoolVector b; a.resize(20); b=a; diff --git a/bin/tests/test_physics.cpp b/bin/tests/test_physics.cpp index 8a270f721fb..15dc40a4fd1 100644 --- a/bin/tests/test_physics.cpp +++ b/bin/tests/test_physics.cpp @@ -146,7 +146,7 @@ protected: /* BOX SHAPE */ - DVector box_planes = Geometry::build_box_planes(Vector3(0.5,0.5,0.5)); + PoolVector box_planes = Geometry::build_box_planes(Vector3(0.5,0.5,0.5)); RID box_mesh = vs->mesh_create(); Geometry::MeshData box_data = Geometry::build_convex_mesh(box_planes); vs->mesh_add_surface_from_mesh_data(box_mesh,box_data); @@ -159,7 +159,7 @@ protected: /* CAPSULE SHAPE */ - DVector capsule_planes = Geometry::build_capsule_planes(0.5,0.7,12,Vector3::AXIS_Z); + PoolVector capsule_planes = Geometry::build_capsule_planes(0.5,0.7,12,Vector3::AXIS_Z); RID capsule_mesh = vs->mesh_create(); Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes); @@ -176,7 +176,7 @@ protected: /* CONVEX SHAPE */ - DVector convex_planes = Geometry::build_cylinder_planes(0.5,0.7,5,Vector3::AXIS_Z); + PoolVector convex_planes = Geometry::build_cylinder_planes(0.5,0.7,5,Vector3::AXIS_Z); RID convex_mesh = vs->mesh_create(); Geometry::MeshData convex_data = Geometry::build_convex_mesh(convex_planes); @@ -534,7 +534,7 @@ public: PhysicsServer * ps = PhysicsServer::get_singleton(); - DVector capsule_planes = Geometry::build_capsule_planes(0.5,1,12,5,Vector3::AXIS_Y); + PoolVector capsule_planes = Geometry::build_capsule_planes(0.5,1,12,5,Vector3::AXIS_Y); RID capsule_mesh = vs->mesh_create(); Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes); diff --git a/bin/tests/test_physics_2d.cpp b/bin/tests/test_physics_2d.cpp index 93d707b26a5..39b4e7edda5 100644 --- a/bin/tests/test_physics_2d.cpp +++ b/bin/tests/test_physics_2d.cpp @@ -74,7 +74,7 @@ class TestPhysics2DMainLoop : public MainLoop { { - DVector pixels; + PoolVector pixels; pixels.resize(32*2*2); for(int i=0;i<2;i++) { @@ -100,7 +100,7 @@ class TestPhysics2DMainLoop : public MainLoop { { - DVector pixels; + PoolVector pixels; pixels.resize(32*32*2); for(int i=0;i<32;i++) { @@ -128,7 +128,7 @@ class TestPhysics2DMainLoop : public MainLoop { { - DVector pixels; + PoolVector pixels; pixels.resize(32*32*2); for(int i=0;i<32;i++) { @@ -157,7 +157,7 @@ class TestPhysics2DMainLoop : public MainLoop { { - DVector pixels; + PoolVector pixels; pixels.resize(32*64*2); 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); - DVector arr; + PoolVector arr; Point2 sb(32,32); arr.push_back(Point2(20,3)-sb); arr.push_back(Point2(58,23)-sb); diff --git a/bin/tests/test_render.cpp b/bin/tests/test_render.cpp index b971d412aa9..51e13660736 100644 --- a/bin/tests/test_render.cpp +++ b/bin/tests/test_render.cpp @@ -87,7 +87,7 @@ public: Vector vts; /* - DVector sp = Geometry::build_sphere_planes(2,5,5); + PoolVector sp = Geometry::build_sphere_planes(2,5,5); Geometry::MeshData md2 = Geometry::build_convex_mesh(sp); vts=md2.vertices; */ diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 0d89659cef0..384813ecdf3 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -69,11 +69,11 @@ RES _ResourceLoader::load(const String &p_path,const String& p_type_hint, bool p return ret; } -DVector _ResourceLoader::get_recognized_extensions_for_type(const String& p_type) { +PoolVector _ResourceLoader::get_recognized_extensions_for_type(const String& p_type) { List exts; ResourceLoader::get_recognized_extensions_for_type(p_type,&exts); - DVector ret; + PoolVector ret; for(List::Element *E=exts.front();E;E=E->next()) { 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); } -DVector _ResourceSaver::get_recognized_extensions(const RES& p_resource) { +PoolVector _ResourceSaver::get_recognized_extensions(const RES& p_resource) { - ERR_FAIL_COND_V(p_resource.is_null(),DVector()); + ERR_FAIL_COND_V(p_resource.is_null(),PoolVector()); List exts; ResourceSaver::get_recognized_extensions(p_resource,&exts); - DVector ret; + PoolVector ret; for(List::Element *E=exts.front();E;E=E->next()) { ret.push_back(E->get()); @@ -1232,16 +1232,16 @@ _Geometry *_Geometry::get_singleton() { return singleton; } -DVector _Geometry::build_box_planes(const Vector3& p_extents) { +PoolVector _Geometry::build_box_planes(const Vector3& p_extents) { return Geometry::build_box_planes(p_extents); } -DVector _Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) { +PoolVector _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); } -DVector _Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) { +PoolVector _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); } @@ -1262,22 +1262,22 @@ Variant _Geometry::segment_intersects_segment_2d(const Vector2& p_from_a,const V }; }; -DVector _Geometry::get_closest_points_between_segments_2d( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2) { +PoolVector _Geometry::get_closest_points_between_segments_2d( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2) { Vector2 r1, r2; Geometry::get_closest_points_between_segments(p1,q1,p2,q2,r1,r2); - DVector r; + PoolVector r; r.resize(2); r.set(0,r1); r.set(1,r2); return r; } -DVector _Geometry::get_closest_points_between_segments(const Vector3& p1,const Vector3& p2,const Vector3& q1,const Vector3& q2) { +PoolVector _Geometry::get_closest_points_between_segments(const Vector3& p1,const Vector3& p2,const Vector3& q1,const Vector3& q2) { Vector3 r1, r2; Geometry::get_closest_points_between_segments(p1,p2,q1,q2,r1,r2); - DVector r; + PoolVector r; r.resize(2); r.set(0,r1); 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); } -DVector _Geometry::segment_intersects_sphere( const Vector3& p_from, const Vector3& p_to, const Vector3& p_sphere_pos,real_t p_sphere_radius) { +PoolVector _Geometry::segment_intersects_sphere( const Vector3& p_from, const Vector3& p_to, const Vector3& p_sphere_pos,real_t p_sphere_radius) { - DVector r; + PoolVector r; Vector3 res,norm; if (!Geometry::segment_intersects_sphere(p_from,p_to,p_sphere_pos,p_sphere_radius,&res,&norm)) return r; @@ -1326,9 +1326,9 @@ DVector _Geometry::segment_intersects_sphere( const Vector3& p_from, co r.set(1,norm); return r; } -DVector _Geometry::segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, float p_height,float p_radius) { +PoolVector _Geometry::segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, float p_height,float p_radius) { - DVector r; + PoolVector r; Vector3 res,norm; if (!Geometry::segment_intersects_cylinder(p_from,p_to,p_height,p_radius,&res,&norm)) return r; @@ -1339,9 +1339,9 @@ DVector _Geometry::segment_intersects_cylinder( const Vector3& p_from, return r; } -DVector _Geometry::segment_intersects_convex(const Vector3& p_from, const Vector3& p_to,const Vector& p_planes) { +PoolVector _Geometry::segment_intersects_convex(const Vector3& p_from, const Vector3& p_to,const Vector& p_planes) { - DVector r; + PoolVector r; Vector3 res,norm; if (!Geometry::segment_intersects_convex(p_from,p_to,p_planes.ptr(),p_planes.size(),&res,&norm)) return r; @@ -1566,9 +1566,9 @@ real_t _File::get_real() const{ return f->get_real(); } -DVector _File::get_buffer(int p_length) const{ +PoolVector _File::get_buffer(int p_length) const{ - DVector data; + PoolVector data; ERR_FAIL_COND_V(!f,data); ERR_FAIL_COND_V(p_length<0,data); @@ -1576,11 +1576,11 @@ DVector _File::get_buffer(int p_length) const{ return data; Error err = data.resize(p_length); ERR_FAIL_COND_V(err!=OK,data); - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); int len = f->get_buffer(&w[0],p_length); - ERR_FAIL_COND_V( len < 0 , DVector()); + ERR_FAIL_COND_V( len < 0 , PoolVector()); - w = DVector::Write(); + w = PoolVector::Write(); if (len < p_length) data.resize(p_length); @@ -1735,7 +1735,7 @@ void _File::store_line(const String& p_string){ f->store_line(p_string); } -void _File::store_buffer(const DVector& p_buffer){ +void _File::store_buffer(const PoolVector& p_buffer){ ERR_FAIL_COND(!f); @@ -1743,7 +1743,7 @@ void _File::store_buffer(const DVector& p_buffer){ if (len==0) return; - DVector::Read r = p_buffer.read(); + PoolVector::Read r = p_buffer.read(); 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); ERR_FAIL_COND( err != OK ); - DVector buff; + PoolVector buff; buff.resize(len); - DVector::Write w = buff.write(); + PoolVector::Write w = buff.write(); err = encode_variant(p_var,&w[0],len); ERR_FAIL_COND( err != OK ); - w=DVector::Write(); + w=PoolVector::Write(); store_32(len); store_buffer(buff); @@ -1778,10 +1778,10 @@ Variant _File::get_var() const { ERR_FAIL_COND_V(!f,Variant()); uint32_t len = get_32(); - DVector buff = get_buffer(len); + PoolVector buff = get_buffer(len); ERR_FAIL_COND_V(buff.size() != len, Variant()); - DVector::Read r = buff.read(); + PoolVector::Read r = buff.read(); Variant v; 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); ERR_FAIL_COND_V( err != OK, "" ); - DVector buff; + PoolVector buff; buff.resize(len); - DVector::Write w = buff.write(); + PoolVector::Write w = buff.write(); err = encode_variant(p_var,&w[0],len); ERR_FAIL_COND_V( err != OK, "" ); int b64len = len / 3 * 4 + 4 + 1; - DVector b64buff; + PoolVector b64buff; b64buff.resize(b64len); - DVector::Write w64 = b64buff.write(); + PoolVector::Write w64 = b64buff.write(); 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); @@ -2081,9 +2081,9 @@ Variant _Marshalls::base64_to_variant(const String& p_str) { int strlen = p_str.length(); CharString cstr = p_str.ascii(); - DVector buf; + PoolVector buf; buf.resize(strlen / 4 * 3 + 1); - DVector::Write w = buf.write(); + PoolVector::Write w = buf.write(); 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; }; -String _Marshalls::raw_to_base64(const DVector &p_arr) { +String _Marshalls::raw_to_base64(const PoolVector &p_arr) { int len = p_arr.size(); - DVector::Read r = p_arr.read(); + PoolVector::Read r = p_arr.read(); int b64len = len / 3 * 4 + 4 + 1; - DVector b64buff; + PoolVector b64buff; b64buff.resize(b64len); - DVector::Write w64 = b64buff.write(); + PoolVector::Write w64 = b64buff.write(); int strlen = base64_encode((char*)(&w64[0]), (char*)(&r[0]), len); w64[strlen] = 0; @@ -2111,22 +2111,22 @@ String _Marshalls::raw_to_base64(const DVector &p_arr) { return ret; }; -DVector _Marshalls::base64_to_raw(const String &p_str) { +PoolVector _Marshalls::base64_to_raw(const String &p_str) { int strlen = p_str.length(); CharString cstr = p_str.ascii(); int arr_len; - DVector buf; + PoolVector buf; { buf.resize(strlen / 4 * 3 + 1); - DVector::Write w = buf.write(); + PoolVector::Write w = buf.write(); arr_len = base64_decode((char*)(&w[0]), (char*)cstr.get_data(), strlen); }; buf.resize(arr_len); - // conversion from DVector to raw array? + // conversion from PoolVector to raw array? return buf; }; @@ -2136,9 +2136,9 @@ String _Marshalls::utf8_to_base64(const String& p_str) { int len = cstr.length(); int b64len = len / 3 * 4 + 4 + 1; - DVector b64buff; + PoolVector b64buff; b64buff.resize(b64len); - DVector::Write w64 = b64buff.write(); + PoolVector::Write w64 = b64buff.write(); 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(); CharString cstr = p_str.ascii(); - DVector buf; + PoolVector buf; buf.resize(strlen / 4 * 3 + 1 + 1); - DVector::Write w = buf.write(); + PoolVector::Write w = buf.write(); int len = base64_decode((char*)(&w[0]), (char*)cstr.get_data(), strlen); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 9a4f26a12dc..f1c98a58dce 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -50,7 +50,7 @@ public: static _ResourceLoader *get_singleton() { return singleton; } Ref 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); - DVector get_recognized_extensions_for_type(const String& p_type); + PoolVector get_recognized_extensions_for_type(const String& p_type); void set_abort_on_missing_resources(bool p_abort); StringArray get_dependencies(const String& p_path); bool has(const String& p_path); @@ -81,7 +81,7 @@ public: static _ResourceSaver *get_singleton() { return singleton; } Error save(const String &p_path,const RES& p_resource, uint32_t p_flags); - DVector get_recognized_extensions(const RES& p_resource); + PoolVector get_recognized_extensions(const RES& p_resource); _ResourceSaver(); @@ -342,20 +342,20 @@ protected: public: static _Geometry *get_singleton(); - DVector build_box_planes(const Vector3& p_extents); - DVector build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z); - DVector build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis=Vector3::AXIS_Z); + PoolVector build_box_planes(const Vector3& p_extents); + PoolVector build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z); + PoolVector 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); - DVector get_closest_points_between_segments_2d( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2); - DVector get_closest_points_between_segments(const Vector3& p1,const Vector3& p2,const Vector3& q1,const Vector3& q2); + PoolVector get_closest_points_between_segments_2d( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2); + PoolVector 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); 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); bool point_is_inside_triangle(const Vector2& s, const Vector2& a, const Vector2& b, const Vector2& c) const; - DVector segment_intersects_sphere( const Vector3& p_from, const Vector3& p_to, const Vector3& p_sphere_pos,real_t p_sphere_radius); - DVector segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, float p_height,float p_radius); - DVector segment_intersects_convex(const Vector3& p_from, const Vector3& p_to,const Vector& p_planes); + PoolVector segment_intersects_sphere( const Vector3& p_from, const Vector3& p_to, const Vector3& p_sphere_pos,real_t p_sphere_radius); + PoolVector segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, float p_height,float p_radius); + PoolVector segment_intersects_convex(const Vector3& p_from, const Vector3& p_to,const Vector& 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); int get_uv84_normal_bit(const Vector3& p_vector); @@ -413,7 +413,7 @@ public: Variant get_var() const; - DVector get_buffer(int p_length) const; ///< get an array of bytes + PoolVector get_buffer(int p_length) const; ///< get an array of bytes String get_line() const; String get_as_text() const; String get_md5(const String& p_path) const; @@ -447,7 +447,7 @@ public: Vector get_csv_line(String delim=",") const; - void store_buffer(const DVector& p_buffer); ///< store an array of bytes + void store_buffer(const PoolVector& p_buffer); ///< store an array of bytes void store_var(const Variant& p_var); @@ -517,8 +517,8 @@ public: String variant_to_base64(const Variant& p_var); Variant base64_to_variant(const String& p_str); - String raw_to_base64(const DVector& p_arr); - DVector base64_to_raw(const String& p_str); + String raw_to_base64(const PoolVector& p_arr); + PoolVector base64_to_raw(const String& p_str); String utf8_to_base64(const String& p_str); String base64_to_utf8(const String& p_str); diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp index 9b39eeb2c16..f8aa3915d4c 100644 --- a/core/compressed_translation.cpp +++ b/core/compressed_translation.cpp @@ -356,8 +356,8 @@ void PHashTranslation::generate(const Ref &p_from) { hash_table.resize(size); bucket_table.resize(bucket_table_size); - DVector::Write htwb = hash_table.write(); - DVector::Write btwb = bucket_table.write(); + PoolVector::Write htwb = hash_table.write(); + PoolVector::Write btwb = bucket_table.write(); uint32_t *htw = (uint32_t*)&htwb[0]; uint32_t *btw = (uint32_t*)&btwb[0]; @@ -392,7 +392,7 @@ void PHashTranslation::generate(const Ref &p_from) { print_line("total collisions: "+itos(collisions)); strings.resize(total_compression_size); - DVector::Write cw = strings.write(); + PoolVector::Write cw = strings.write(); for(int i=0;i::Read htr = hash_table.read(); + PoolVector::Read htr = hash_table.read(); const uint32_t *htptr = (const uint32_t*)&htr[0]; - DVector::Read btr = bucket_table.read(); + PoolVector::Read btr = bucket_table.read(); const uint32_t *btptr = (const uint32_t*)&btr[0]; - DVector::Read sr = strings.read(); + PoolVector::Read sr = strings.read(); const char *sptr= (const char*)&sr[0]; uint32_t p = htptr[ h % htsize]; diff --git a/core/compressed_translation.h b/core/compressed_translation.h index 218a59c05df..cb1e0840515 100644 --- a/core/compressed_translation.h +++ b/core/compressed_translation.h @@ -42,9 +42,9 @@ class PHashTranslation : public Translation { //of catching untranslated strings //load/store friendly types - DVector hash_table; - DVector bucket_table; - DVector strings; + PoolVector hash_table; + PoolVector bucket_table; + PoolVector strings; struct Bucket { diff --git a/core/dvector.cpp b/core/dvector.cpp index 7caa198c4ca..f6b5a5fcbf7 100644 --- a/core/dvector.cpp +++ b/core/dvector.cpp @@ -30,3 +30,44 @@ 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;i0); + +} diff --git a/core/dvector.h b/core/dvector.h index 9e0090fb7cb..f109f842a20 100644 --- a/core/dvector.h +++ b/core/dvector.h @@ -30,6 +30,46 @@ #define DVECTOR_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 DVector { +class PoolVector { - mutable MID mem; + MemoryPool::Alloc *alloc; - void copy_on_write() { + void _copy_on_write() { - if (!mem.is_valid()) + + if (!alloc) return; - if (dvector_lock) - dvector_lock->lock(); + ERR_FAIL_COND(alloc->lock>0); - MID_Lock lock( mem ); + if (alloc->refcount.get()==1) + return; //nothing to do - if ( *(int*)lock.data() == 1 ) { - // one reference, means no refcount changes - if (dvector_lock) - dvector_lock->unlock(); - return; + //must allocate something + + MemoryPool::alloc_mutex->lock(); + if (MemoryPool::allocs_used==MemoryPool::alloc_count) { + 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) - dvector_lock->unlock(); - ERR_FAIL_COND( new_mem.is_valid() ); // out of memory + //copy the alloc data + alloc->size=old_alloc->size; + alloc->refcount.init(); + alloc->pool_id=POOL_ALLOCATOR_INVALID_ID; + alloc->lock=0; + +#ifdef DEBUG_ENABLED + MemoryPool::total_memory+=alloc->size; + if (MemoryPool::total_memory>MemoryPool::max_memory) { + MemoryPool::max_memory=MemoryPool::total_memory; + } +#endif + + MemoryPool::alloc_mutex->unlock(); + + if (MemoryPool::memory_pool) { + + + } else { + alloc->mem = memalloc( alloc->size ); + 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(); - - *rc=1; - - T * dst = (T*)(rc + 1 ); - - T * src =(T*) ((int*)lock.data() + 1 ); - - int count = (mem.get_size() - sizeof(int)) / sizeof(T); - - for (int i=0;iunlock(); - - } - - 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(); - - } +#ifdef DEBUG_ENABLED + MemoryPool::alloc_mutex->lock(); + MemoryPool::total_memory-=old_alloc->size; + MemoryPool::alloc_mutex->unlock(); +#endif - void unreference() { + if (MemoryPool::memory_pool) { + //resize memory pool + //if none, create + //if some resize + } else { - if (dvector_lock) - dvector_lock->lock(); + memfree( old_alloc->mem ); + old_alloc->mem=NULL; + old_alloc->size=0; - if (!mem.is_valid()) { - if (dvector_lock) - dvector_lock->unlock(); - return; - } - - 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;ilock(); + old_alloc->free_list=MemoryPool::free_list; + MemoryPool::free_list=old_alloc; + MemoryPool::allocs_used--; + MemoryPool::alloc_mutex->unlock(); } } + } - lock = MID_Lock(); + void _reference( const PoolVector& p_dvector ) { - mem = MID (); + if (alloc==p_dvector.alloc) + return; - if (dvector_lock) - dvector_lock->unlock(); + _unreference(); + 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;ilock(); + MemoryPool::total_memory-=alloc->size; + MemoryPool::alloc_mutex->unlock(); +#endif + + + if (MemoryPool::memory_pool) { + //resize memory pool + //if none, create + //if some resize + } else { + + memfree( alloc->mem ); + alloc->mem=NULL; + alloc->size=0; + + + MemoryPool::alloc_mutex->lock(); + alloc->free_list=MemoryPool::free_list; + MemoryPool::free_list=alloc; + MemoryPool::allocs_used--; + MemoryPool::alloc_mutex->unlock(); + + } + + alloc=NULL; } public: - class Read { - friend class DVector; - MID_Lock lock; - const T * mem; + class Access { + friend class PoolVector; + protected: + MemoryPool::Alloc *alloc; + T * mem; + + _FORCE_INLINE_ void _ref(MemoryPool::Alloc *p_alloc) { + alloc=p_alloc; + if (alloc) { + if (atomic_increment(&alloc->lock)==1) { + if (MemoryPool::memory_pool) { + //lock it and get mem + } + } + + mem = (T*)alloc->mem; + } + } + + _FORCE_INLINE_ void _unref() { + + + if (alloc) { + if (atomic_decrement(&alloc->lock)==0) { + if (MemoryPool::memory_pool) { + //put mem back + } + } + + mem = NULL; + alloc=NULL; + } + + + } + + Access() { + alloc=NULL; + mem=NULL; + } + + public: - - _FORCE_INLINE_ const T& operator[](int p_index) const { return mem[p_index]; } - _FORCE_INLINE_ const T *ptr() const { return mem; } - - Read() { mem=NULL; } + virtual ~Access() { + _unref(); + } }; - class Write { - friend class DVector; - MID_Lock lock; - T * mem; + class Read : public Access { public: - _FORCE_INLINE_ T& operator[](int p_index) { return mem[p_index]; } - _FORCE_INLINE_ T *ptr() { return mem; } + _FORCE_INLINE_ const T& operator[](int p_index) const { return this->mem[p_index]; } + _FORCE_INLINE_ const T *ptr() const { return this->mem; } + + void operator=(const Read& p_read) { + if (this->alloc==p_read.alloc) + return; + this->_unref(); + this->_ref(p_read.alloc); + } + + Read(const Read& p_read) { + this->_ref(p_read.alloc); + } + + Read() {} + + + }; + + class Write : public Access { + public: + + _FORCE_INLINE_ T& operator[](int p_index) const { return this->mem[p_index]; } + _FORCE_INLINE_ T *ptr() const { return this->mem; } + + void operator=(const Write& p_read) { + if (this->alloc==p_read.alloc) + return; + this->_unref(); + this->_ref(p_read.alloc); + } + + Write(const Write& p_read) { + this->_ref(p_read.alloc); + } + + Write() {} - Write() { mem=NULL; } }; Read read() const { Read r; - if (mem.is_valid()) { - r.lock = MID_Lock( mem ); - r.mem = (const T*)((int*)r.lock.data()+1); + if (alloc) { + r._ref(alloc); } return r; + } Write write() { Write w; - if (mem.is_valid()) { - copy_on_write(); - w.lock = MID_Lock( mem ); - w.mem = (T*)((int*)w.lock.data()+1); + if (alloc) { + _copy_on_write(); //make sure there is only one being acessed + w._ref(alloc); } return w; } @@ -250,7 +382,7 @@ public: void set(int p_index, const T& p_val); void push_back(const T& p_val); void append(const T& p_val) { push_back(p_val); } - void append_array(const DVector& p_arr) { + void append_array(const PoolVector& p_arr) { int ds = p_arr.size(); if (ds==0) return; @@ -262,7 +394,7 @@ public: w[bs+i]=r[i]; } - DVector subarray(int p_from, int p_to) { + PoolVector subarray(int p_from, int p_to) { if (p_from<0) { p_from=size()+p_from; @@ -271,15 +403,15 @@ public: p_to=size()+p_to; } if (p_from<0 || p_from>=size()) { - DVector& aux=*((DVector*)0); // nullreturn + PoolVector& aux=*((PoolVector*)0); // nullreturn ERR_FAIL_COND_V(p_from<0 || p_from>=size(),aux) } if (p_to<0 || p_to>=size()) { - DVector& aux=*((DVector*)0); // nullreturn + PoolVector& aux=*((PoolVector*)0); // nullreturn ERR_FAIL_COND_V(p_to<0 || p_to>=size(),aux) } - DVector slice; + PoolVector slice; int span=1 + p_to - p_from; slice.resize(span); 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; @@ -315,27 +447,27 @@ public: void invert(); - void operator=(const DVector& p_dvector) { reference(p_dvector); } - DVector() {} - DVector(const DVector& p_dvector) { reference(p_dvector); } - ~DVector() { unreference(); } + void operator=(const PoolVector& p_dvector) { _reference(p_dvector); } + PoolVector() { alloc=NULL; } + PoolVector(const PoolVector& p_dvector) { alloc=NULL; _reference(p_dvector); } + ~PoolVector() { _unreference(); } }; template -int DVector::size() const { +int PoolVector::size() const { - return mem.is_valid() ? ((mem.get_size() - sizeof(int)) / sizeof(T) ) : 0; + return alloc ? alloc->size/sizeof(T) : 0; } template -T DVector::get(int p_index) const { +T PoolVector::get(int p_index) const { return operator[](p_index); } template -void DVector::set(int p_index, const T& p_val) { +void PoolVector::set(int p_index, const T& p_val) { if (p_index<0 || p_index>=size()) { ERR_FAIL_COND(p_index<0 || p_index>=size()); @@ -346,14 +478,14 @@ void DVector::set(int p_index, const T& p_val) { } template -void DVector::push_back(const T& p_val) { +void PoolVector::push_back(const T& p_val) { resize( size() + 1 ); set( size() -1, p_val ); } template -const T DVector::operator[](int p_index) const { +const T PoolVector::operator[](int p_index) const { if (p_index<0 || p_index>=size()) { T& aux=*((T*)0); //nullreturn @@ -367,94 +499,130 @@ const T DVector::operator[](int p_index) const { template -Error DVector::resize(int p_size) { +Error PoolVector::resize(int p_size) { - if (dvector_lock) - dvector_lock->lock(); - bool same = p_size==size(); + if (alloc==NULL) { - if (dvector_lock) - dvector_lock->unlock(); - // no further locking is necesary because we are supposed to own the only copy of this (using copy on write) + if (p_size==0) + return OK; //nothing to do here - if (same) - return OK; + //must allocate something + 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 ) { - - unreference(); + _unreference(); 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(); - - 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 (p_size > cur_elements ) { + if (MemoryPool::memory_pool) { + //resize memory pool + //if none, create + //if some resize } else { - if (dynrealloc( mem, p_size * sizeof(T) + sizeof(int) )!=OK ) { - - ERR_FAIL_V(ERR_OUT_OF_MEMORY); // out of memory + if (alloc->size==0) { + alloc->mem = memalloc( new_size ); + } else { + alloc->mem = memrealloc( alloc->mem, new_size ); } + } - lock=MID_Lock(mem); + alloc->size=new_size; + + Write w = write(); + + for (int i=cur_elements;imem ); + 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; } template -void DVector::invert() { +void PoolVector::invert() { T temp; Write w = write(); int s = size(); diff --git a/core/globals.cpp b/core/globals.cpp index 6609b47147c..b6498c62e47 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -691,9 +691,9 @@ static Variant _decode_variant(const String& p_string) { String data=params[4]; int datasize=data.length()/2; - DVector pixels; + PoolVector pixels; pixels.resize(datasize); - DVector::Write wb = pixels.write(); + PoolVector::Write wb = pixels.write(); const CharType *cptr=data.c_str(); int idx=0; @@ -720,7 +720,7 @@ static Variant _decode_variant(const String& p_string) { } - wb = DVector::Write(); + wb = PoolVector::Write(); 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.get_width())+", "; str+=itos(img.get_height())+", "; - DVector data = img.get_data(); + PoolVector data = img.get_data(); int ds=data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); for(int i=0;i::Read r = data.read(); - DVector::Write w = new_img.data.write(); + PoolVector::Read r = data.read(); + PoolVector::Write w = new_img.data.write(); const uint8_t *rptr = r.ptr(); uint8_t *wptr = w.ptr(); @@ -409,8 +409,8 @@ void Image::convert( Format p_new_format ){ } - r = DVector::Read(); - w = DVector::Write(); + r = PoolVector::Read(); + w = PoolVector::Write(); 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 ); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const unsigned char*r_ptr=r.ptr(); - DVector::Write w = dst.data.write(); + PoolVector::Write w = dst.data.write(); unsigned char*w_ptr=w.ptr(); @@ -693,8 +693,8 @@ void Image::resize( int p_width, int p_height, Interpolation p_interpolation ) { } - r = DVector::Read(); - w = DVector::Write(); + r = PoolVector::Read(); + w = PoolVector::Write(); if (mipmaps>0) dst.generate_mipmaps(); @@ -725,8 +725,8 @@ void Image::crop( int p_width, int p_height ) { Image dst( p_width, p_height,0, format ); { - DVector::Read r = data.read(); - DVector::Write w = dst.data.write(); + PoolVector::Read r = data.read(); + PoolVector::Write w = dst.data.write(); for (int y=0;y::Write w = data.write(); + PoolVector::Write w = data.write(); uint8_t up[16]; uint8_t down[16]; uint32_t pixel_size = get_format_pixel_size(format); @@ -806,7 +806,7 @@ void Image::flip_x() { { - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); uint8_t up[16]; uint8_t down[16]; uint32_t pixel_size = get_format_pixel_size(format); @@ -925,12 +925,12 @@ void Image::expand_x2_hq2x() { if (current!=FORMAT_RGBA8) convert(FORMAT_RGBA8); - DVector dest; + PoolVector dest; dest.resize(width*2*height*2*4); { - DVector::Read r = data.read(); - DVector::Write w = dest.write(); + PoolVector::Read r = data.read(); + PoolVector::Write w = dest.write(); hq2x_resize((const uint32_t*)r.ptr(),width,height,(uint32_t*)w.ptr()); @@ -959,7 +959,7 @@ void Image::shrink_x2() { if (mipmaps) { //just use the lower mipmap as base and copy all - DVector new_img; + PoolVector new_img; int ofs = get_mipmap_offset(1); @@ -968,8 +968,8 @@ void Image::shrink_x2() { { - DVector::Write w=new_img.write(); - DVector::Read r=data.read(); + PoolVector::Write w=new_img.write(); + PoolVector::Read r=data.read(); copymem(w.ptr(),&r[ofs],new_size); } @@ -980,15 +980,15 @@ void Image::shrink_x2() { } else { - DVector new_img; + PoolVector new_img; ERR_FAIL_COND( !_can_modify(format) ); int ps = get_format_pixel_size(format); new_img.resize((width/2)*(height/2)*ps); { - DVector::Write w=new_img.write(); - DVector::Read r=data.read(); + PoolVector::Write w=new_img.write(); + PoolVector::Read r=data.read(); switch(format) { @@ -1027,7 +1027,7 @@ Error Image::generate_mipmaps(bool p_keep_existing) { data.resize(size); - DVector::Write wp=data.write(); + PoolVector::Write wp=data.write(); if (nearest_power_of_2(width)==uint32_t(width) && nearest_power_of_2(height)==uint32_t(height)) { //use fast code for powers of 2 @@ -1122,7 +1122,7 @@ bool Image::empty() const { return (data.size()==0); } -DVector Image::get_data() const { +PoolVector Image::get_data() const { 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); data.resize( size ); { - DVector::Write w= data.write(); + PoolVector::Write w= data.write(); 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& p_data) { +void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const PoolVector& p_data) { ERR_FAIL_INDEX(p_width-1,MAX_WIDTH); ERR_FAIL_INDEX(p_height-1,MAX_HEIGHT); @@ -1188,7 +1188,7 @@ void Image::create( const char ** p_xpm ) { HashMap colormap; int colormap_size; uint32_t pixel_size; - DVector::Write w; + PoolVector::Write w; while (status!=DONE) { @@ -1355,7 +1355,7 @@ bool Image::is_invisible() const { int w,h; _get_mipmap_offset_and_size(1,len,w,h); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const unsigned char *data_ptr=r.ptr(); bool detected=false; @@ -1401,7 +1401,7 @@ Image::AlphaMode Image::detect_alpha() const { int w,h; _get_mipmap_offset_and_size(1,len,w,h); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const unsigned char *data_ptr=r.ptr(); bool bit=false; @@ -1459,8 +1459,8 @@ bool Image::operator==(const Image& p_image) const { if (data.size() == 0 && p_image.data.size() == 0) return true; - DVector::Read r = data.read(); - DVector::Read pr = p_image.data.read(); + PoolVector::Read r = data.read(); + PoolVector::Read pr = p_image.data.read(); return r.ptr() == pr.ptr(); } @@ -1502,11 +1502,11 @@ Error Image::_decompress_bc() { int mm; int size = _get_dst_image_size(wd,ht,FORMAT_RGBA8,mm); - DVector newdata; + PoolVector newdata; newdata.resize(size); - DVector::Write w = newdata.write(); - DVector::Read r = data.read(); + PoolVector::Write w = newdata.write(); + PoolVector::Read r = data.read(); int rofs=0; int wofs=0; @@ -1814,8 +1814,8 @@ Error Image::_decompress_bc() { } - w=DVector::Write(); - r=DVector::Read(); + w=PoolVector::Write(); + r=PoolVector::Read(); data=newdata; 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& p_data) { +Image::Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const PoolVector& p_data) { width=0; height=0; @@ -1950,7 +1950,7 @@ Rect2 Image::get_used_rect() const { return Rect2(); //int data_size = len; - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const unsigned char *rptr=r.ptr(); 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; Rect2i src_rect( p_src_rect.pos + ( local_src_rect.pos - p_dest), local_src_rect.size ); - DVector::Write wp = data.write(); + PoolVector::Write wp = data.write(); uint8_t *dst_data_ptr=wp.ptr(); - DVector::Read rp = p_src.data.read(); + PoolVector::Read rp = p_src.data.read(); const uint8_t *src_data_ptr=rp.ptr(); 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_etc2)(Image *)=NULL; -DVector (*Image::lossy_packer)(const Image& ,float )=NULL; -Image (*Image::lossy_unpacker)(const DVector& )=NULL; -DVector (*Image::lossless_packer)(const Image& )=NULL; -Image (*Image::lossless_unpacker)(const DVector& )=NULL; +PoolVector (*Image::lossy_packer)(const Image& ,float )=NULL; +Image (*Image::lossy_unpacker)(const PoolVector& )=NULL; +PoolVector (*Image::lossless_packer)(const Image& )=NULL; +Image (*Image::lossless_unpacker)(const PoolVector& )=NULL; 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; - DVector::Write wp = data.write(); + PoolVector::Write wp = data.write(); unsigned char *data_ptr=wp.ptr(); for(int i=0;i::Write wp = data.write(); + PoolVector::Write wp = data.write(); unsigned char *data_ptr=wp.ptr(); for(int i=0;i::Write wp = data.write(); + PoolVector::Write wp = data.write(); unsigned char *data_ptr=wp.ptr(); for(int i=0;i::Write wp = data.write(); + PoolVector::Write wp = data.write(); unsigned char *data_ptr=wp.ptr(); @@ -2152,11 +2152,11 @@ void Image::fix_alpha_edges() { if (format!=FORMAT_RGBA8) return; //not needed - DVector dcopy = data; - DVector::Read rp = data.read(); + PoolVector dcopy = data; + PoolVector::Read rp = data.read(); const uint8_t *srcptr=rp.ptr(); - DVector::Write wp = data.write(); + PoolVector::Write wp = data.write(); unsigned char *data_ptr=wp.ptr(); const int max_radius=4; diff --git a/core/image.h b/core/image.h index 2c585d74d93..620160147b4 100644 --- a/core/image.h +++ b/core/image.h @@ -123,14 +123,14 @@ public: Error _decompress_bc(); - static DVector (*lossy_packer)(const Image& p_image,float p_quality); - static Image (*lossy_unpacker)(const DVector& p_buffer); - static DVector (*lossless_packer)(const Image& p_image); - static Image (*lossless_unpacker)(const DVector& p_buffer); + static PoolVector (*lossy_packer)(const Image& p_image,float p_quality); + static Image (*lossy_unpacker)(const PoolVector& p_buffer); + static PoolVector (*lossless_packer)(const Image& p_image); + static Image (*lossless_unpacker)(const PoolVector& p_buffer); private: Format format; - DVector data; + PoolVector data; int width,height; bool mipmaps; @@ -206,7 +206,7 @@ public: * Create a new image of a given size and format. Current image will be lost */ void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format); - void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const DVector& p_data); + void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const PoolVector& p_data); void create( const char ** p_xpm ); /** @@ -214,7 +214,7 @@ public: */ bool empty() const; - DVector get_data() const; + PoolVector get_data() const; Error load(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 */ - Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const DVector& p_data); + Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const PoolVector& p_data); enum AlphaMode { ALPHA_NONE, diff --git a/core/io/file_access_buffered.cpp b/core/io/file_access_buffered.cpp index 347edc74075..71518de38b7 100644 --- a/core/io/file_access_buffered.cpp +++ b/core/io/file_access_buffered.cpp @@ -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)); size = size - (size % 4); - //DVector::Read read = cache.buffer.read(); + //PoolVector::Read read = cache.buffer.read(); //memcpy(p_dest, read.ptr() + (file.offset - cache.offset), size); memcpy(p_dest, cache.buffer.ptr() + (file.offset - cache.offset), 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); - //DVector::Read read = cache.buffer.read(); + //PoolVector::Read read = cache.buffer.read(); //memcpy(p_dest+total_read, &read.ptr()[file.offset - cache.offset], r); memcpy(p_dest+total_read, cache.buffer.ptr() + (file.offset - cache.offset), r); diff --git a/core/io/file_access_buffered_fa.h b/core/io/file_access_buffered_fa.h index 8a15584b137..884d40a2665 100644 --- a/core/io/file_access_buffered_fa.h +++ b/core/io/file_access_buffered_fa.h @@ -53,7 +53,7 @@ class FileAccessBufferedFA : public FileAccessBuffered { cache.buffer.resize(p_size); // on dvector - //DVector::Write write = cache.buffer.write(); + //PoolVector::Write write = cache.buffer.write(); //f.get_buffer(write.ptr(), p_size); // on vector diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 4051ae302f3..b556d461052 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -87,7 +87,7 @@ Ref HTTPClient::get_connection() const { return connection; } -Error HTTPClient::request_raw( Method p_method, const String& p_url, const Vector& p_headers,const DVector& p_body) { +Error HTTPClient::request_raw( Method p_method, const String& p_url, const Vector& p_headers,const PoolVector& p_body) { ERR_FAIL_INDEX_V(p_method,METHOD_MAX,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"; CharString cs=request.utf8(); - DVector data; + PoolVector data; //Maybe this goes faster somehow? for(int i=0;i::Read r = data.read(); + PoolVector::Read r = data.read(); Error err = connection->put_data(&r[0], data.size()); if (err) { diff --git a/core/io/http_client.h b/core/io/http_client.h index 2e78882303e..231475775fa 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -172,7 +172,7 @@ public: void set_connection(const Ref& p_connection); Ref get_connection() const; - Error request_raw( Method p_method, const String& p_url, const Vector& p_headers,const DVector& p_body); + Error request_raw( Method p_method, const String& p_url, const Vector& p_headers,const PoolVector& p_body); Error request( Method p_method, const String& p_url, const Vector& p_headers,const String& p_body=String()); Error send_body_text(const String& p_body); Error send_body_data(const ByteArray& p_body); diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index bc6cc0bb83a..e10e4413bcb 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -272,11 +272,11 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * if (datalen>0) { len-=5*4; ERR_FAIL_COND_V( len < datalen, ERR_INVALID_DATA ); - DVector data; + PoolVector data; data.resize(datalen); - DVector::Write wr = data.write(); + PoolVector::Write wr = data.write(); copymem(&wr[0],&buf[20],datalen); - wr = DVector::Write(); + wr = PoolVector::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); - DVector data; + PoolVector data; if (count) { data.resize(count); - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); for(int i=0;i::Write(); + w = PoolVector::Write(); } r_variant=data; @@ -569,18 +569,18 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * len-=4; ERR_FAIL_COND_V((int)count*4>len,ERR_INVALID_DATA); - DVector data; + PoolVector data; if (count) { //const int*rbuf=(const int*)buf; data.resize(count); - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); for(int i=0;i::Write(); + w = PoolVector::Write(); } r_variant=Variant(data); if (r_len) { @@ -596,18 +596,18 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * len-=4; ERR_FAIL_COND_V((int)count*4>len,ERR_INVALID_DATA); - DVector data; + PoolVector data; if (count) { //const float*rbuf=(const float*)buf; data.resize(count); - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); for(int i=0;i::Write(); + w = PoolVector::Write(); } 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); ERR_FAIL_COND_V(count<0,ERR_INVALID_DATA); - DVector strings; + PoolVector strings; buf+=4; len-=4; @@ -676,7 +676,7 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * len-=4; ERR_FAIL_COND_V((int)count*4*2>len,ERR_INVALID_DATA); - DVector varray; + PoolVector varray; if (r_len) { (*r_len)+=4; @@ -684,7 +684,7 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * if (count) { varray.resize(count); - DVector::Write w = varray.write(); + PoolVector::Write w = varray.write(); 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; ERR_FAIL_COND_V((int)count*4*3>len,ERR_INVALID_DATA); - DVector varray; + PoolVector varray; if (r_len) { (*r_len)+=4; @@ -722,7 +722,7 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * if (count) { varray.resize(count); - DVector::Write w = varray.write(); + PoolVector::Write w = varray.write(); 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; ERR_FAIL_COND_V((int)count*4*4>len,ERR_INVALID_DATA); - DVector carray; + PoolVector carray; if (r_len) { (*r_len)+=4; @@ -761,7 +761,7 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * if (count) { carray.resize(count); - DVector::Write w = carray.write(); + PoolVector::Write w = carray.write(); 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: { Image image = p_variant; - DVector data=image.get_data(); + PoolVector data=image.get_data(); 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]); int ds=data.size(); encode_uint32(ds,&buf[16]); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); 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 case Variant::RAW_ARRAY: { - DVector data = p_variant; + PoolVector data = p_variant; int datalen=data.size(); int datasize=sizeof(uint8_t); if (buf) { encode_uint32(datalen,buf); buf+=4; - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); 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; case Variant::INT_ARRAY: { - DVector data = p_variant; + PoolVector data = p_variant; int datalen=data.size(); int datasize=sizeof(int32_t); if (buf) { encode_uint32(datalen,buf); buf+=4; - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); for(int i=0;i data = p_variant; + PoolVector data = p_variant; int datalen=data.size(); int datasize=sizeof(real_t); if (buf) { encode_uint32(datalen,buf); buf+=4; - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); for(int i=0;i data = p_variant; + PoolVector data = p_variant; int len=data.size(); if (buf) { @@ -1323,7 +1323,7 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) { } break; case Variant::VECTOR2_ARRAY: { - DVector data = p_variant; + PoolVector data = p_variant; int len=data.size(); if (buf) { @@ -1351,7 +1351,7 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) { } break; case Variant::VECTOR3_ARRAY: { - DVector data = p_variant; + PoolVector data = p_variant; int len=data.size(); if (buf) { @@ -1380,7 +1380,7 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) { } break; case Variant::COLOR_ARRAY: { - DVector data = p_variant; + PoolVector data = p_variant; int len=data.size(); if (buf) { diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index 720e912e719..5ff09f9fb0f 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -39,7 +39,7 @@ PacketPeer::PacketPeer() { last_get_error=OK; } -Error PacketPeer::get_packet_buffer(DVector &r_buffer) const { +Error PacketPeer::get_packet_buffer(PoolVector &r_buffer) const { const uint8_t *buffer; int buffer_size; @@ -51,7 +51,7 @@ Error PacketPeer::get_packet_buffer(DVector &r_buffer) const { if (buffer_size==0) return OK; - DVector::Write w = r_buffer.write(); + PoolVector::Write w = r_buffer.write(); for(int i=0;i &r_buffer) const { } -Error PacketPeer::put_packet_buffer(const DVector &p_buffer) { +Error PacketPeer::put_packet_buffer(const PoolVector &p_buffer) { int len = p_buffer.size(); if (len==0) return OK; - DVector::Read r = p_buffer.read(); + PoolVector::Read r = p_buffer.read(); return put_packet(&r[0],len); } @@ -108,12 +108,12 @@ Variant PacketPeer::_bnd_get_var() const { return var; }; -Error PacketPeer::_put_packet(const DVector &p_buffer) { +Error PacketPeer::_put_packet(const PoolVector &p_buffer) { return put_packet_buffer(p_buffer); } -DVector PacketPeer::_get_packet() const { +PoolVector PacketPeer::_get_packet() const { - DVector raw; + PoolVector raw; last_get_error=get_packet_buffer(raw); return raw; } diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h index c67cfb943e7..bacd5214f11 100644 --- a/core/io/packet_peer.h +++ b/core/io/packet_peer.h @@ -42,8 +42,8 @@ class PacketPeer : public Reference { static void _bind_methods(); - Error _put_packet(const DVector &p_buffer); - DVector _get_packet() const; + Error _put_packet(const PoolVector &p_buffer); + PoolVector _get_packet() const; Error _get_packet_error() const; @@ -59,8 +59,8 @@ public: /* helpers / binders */ - virtual Error get_packet_buffer(DVector &r_buffer) const; - virtual Error put_packet_buffer(const DVector &p_buffer); + virtual Error get_packet_buffer(PoolVector &r_buffer) const; + virtual Error put_packet_buffer(const PoolVector &p_buffer); virtual Error get_var(Variant &r_variant) const; virtual Error put_var(const Variant& p_packet); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 512031b1282..2a9089e8e89 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -264,22 +264,22 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { uint32_t datalen = f->get_32(); - DVector imgdata; + PoolVector imgdata; imgdata.resize(datalen); - DVector::Write w = imgdata.write(); + PoolVector::Write w = imgdata.write(); f->get_buffer(w.ptr(),datalen); _advance_padding(datalen); - w=DVector::Write(); + w=PoolVector::Write(); r_v=Image(width,height,mipmaps,fmt,imgdata); } else { //compressed - DVector data; + PoolVector data; data.resize(f->get_32()); - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); f->get_buffer(w.ptr(),data.size()); - w = DVector::Write(); + w = PoolVector::Write(); Image img; @@ -448,12 +448,12 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { uint32_t len = f->get_32(); - DVector array; + PoolVector array; array.resize(len); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); f->get_buffer(w.ptr(),len); _advance_padding(len); - w=DVector::Write(); + w=PoolVector::Write(); r_v=array; } break; @@ -461,9 +461,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { uint32_t len = f->get_32(); - DVector array; + PoolVector array; array.resize(len); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); f->get_buffer((uint8_t*)w.ptr(),len*4); #ifdef BIG_ENDIAN_ENABLED { @@ -475,16 +475,16 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { } #endif - w=DVector::Write(); + w=PoolVector::Write(); r_v=array; } break; case VARIANT_REAL_ARRAY: { uint32_t len = f->get_32(); - DVector array; + PoolVector array; array.resize(len); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)); #ifdef BIG_ENDIAN_ENABLED { @@ -497,18 +497,18 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { #endif - w=DVector::Write(); + w=PoolVector::Write(); r_v=array; } break; case VARIANT_STRING_ARRAY: { uint32_t len = f->get_32(); - DVector array; + PoolVector array; array.resize(len); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); for(uint32_t i=0;i::Write(); + w=PoolVector::Write(); r_v=array; @@ -517,9 +517,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { uint32_t len = f->get_32(); - DVector array; + PoolVector array; array.resize(len); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); if (sizeof(Vector2)==8) { f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)*2); #ifdef BIG_ENDIAN_ENABLED @@ -537,7 +537,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { ERR_EXPLAIN("Vector2 size is NOT 8!"); ERR_FAIL_V(ERR_UNAVAILABLE); } - w=DVector::Write(); + w=PoolVector::Write(); r_v=array; } break; @@ -545,9 +545,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { uint32_t len = f->get_32(); - DVector array; + PoolVector array; array.resize(len); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); if (sizeof(Vector3)==12) { f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)*3); #ifdef BIG_ENDIAN_ENABLED @@ -565,7 +565,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { ERR_EXPLAIN("Vector3 size is NOT 12!"); ERR_FAIL_V(ERR_UNAVAILABLE); } - w=DVector::Write(); + w=PoolVector::Write(); r_v=array; } break; @@ -573,9 +573,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { uint32_t len = f->get_32(); - DVector array; + PoolVector array; array.resize(len); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); if (sizeof(Color)==16) { f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)*4); #ifdef BIG_ENDIAN_ENABLED @@ -593,7 +593,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { ERR_EXPLAIN("Color size is NOT 16!"); ERR_FAIL_V(ERR_UNAVAILABLE); } - w=DVector::Write(); + w=PoolVector::Write(); r_v=array; } break; @@ -1587,12 +1587,12 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, int dlen = val.get_data().size(); f->store_32(dlen); - DVector::Read r = val.get_data().read(); + PoolVector::Read r = val.get_data().read(); f->store_buffer(r.ptr(),dlen); _pad_buffer(dlen); } else { - DVector data; + PoolVector data; if (encoding==IMAGE_ENCODING_LOSSY) { data=Image::lossy_packer(val,quality); @@ -1604,7 +1604,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, int ds=data.size(); f->store_32(ds); if (ds>0) { - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); f->store_buffer(r.ptr(),ds); _pad_buffer(ds); @@ -1703,10 +1703,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, case Variant::RAW_ARRAY: { f->store_32(VARIANT_RAW_ARRAY); - DVector arr = p_property; + PoolVector arr = p_property; int len=arr.size(); f->store_32(len); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); f->store_buffer(r.ptr(),len); _pad_buffer(len); @@ -1714,10 +1714,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, case Variant::INT_ARRAY: { f->store_32(VARIANT_INT_ARRAY); - DVector arr = p_property; + PoolVector arr = p_property; int len=arr.size(); f->store_32(len); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); for(int i=0;istore_32(r[i]); @@ -1725,10 +1725,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, case Variant::REAL_ARRAY: { f->store_32(VARIANT_REAL_ARRAY); - DVector arr = p_property; + PoolVector arr = p_property; int len=arr.size(); f->store_32(len); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); for(int i=0;istore_real(r[i]); } @@ -1737,10 +1737,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, case Variant::STRING_ARRAY: { f->store_32(VARIANT_STRING_ARRAY); - DVector arr = p_property; + PoolVector arr = p_property; int len=arr.size(); f->store_32(len); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); for(int i=0;istore_32(VARIANT_VECTOR3_ARRAY); - DVector arr = p_property; + PoolVector arr = p_property; int len=arr.size(); f->store_32(len); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); for(int i=0;istore_real(r[i].x); f->store_real(r[i].y); @@ -1763,10 +1763,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, case Variant::VECTOR2_ARRAY: { f->store_32(VARIANT_VECTOR2_ARRAY); - DVector arr = p_property; + PoolVector arr = p_property; int len=arr.size(); f->store_32(len); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); for(int i=0;istore_real(r[i].x); f->store_real(r[i].y); @@ -1776,10 +1776,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, case Variant::COLOR_ARRAY: { f->store_32(VARIANT_COLOR_ARRAY); - DVector arr = p_property; + PoolVector arr = p_property; int len=arr.size(); f->store_32(len); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); for(int i=0;istore_real(r[i].r); f->store_real(r[i].g); diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index d4808d47419..34e3f282c1f 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -623,9 +623,9 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) return OK; }; - DVector pixels; + PoolVector pixels; pixels.resize(datasize); - DVector::Write wb = pixels.write(); + PoolVector::Write wb = pixels.write(); int idx=0; 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); - wb=DVector::Write(); + wb=PoolVector::Write(); r_v=Image(w,h,mipmaps,imgformat,pixels); String sdfsdfg; @@ -672,9 +672,9 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) } int len=tag->args["len"].to_int(); - DVector bytes; + PoolVector bytes; bytes.resize(len); - DVector::Write w=bytes.write(); + PoolVector::Write w=bytes.write(); uint8_t *bytesptr=w.ptr(); int idx=0; 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); - w=DVector::Write(); + w=PoolVector::Write(); r_v=bytes; String 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(); - DVector ints; + PoolVector ints; ints.resize(len); - DVector::Write w=ints.write(); + PoolVector::Write w=ints.write(); int *intsptr=w.ptr(); int idx=0; String str; @@ -770,7 +770,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) } #endif - w=DVector::Write(); + w=PoolVector::Write(); r_v=ints; 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();; - DVector reals; + PoolVector reals; reals.resize(len); - DVector::Write w=reals.write(); + PoolVector::Write w=reals.write(); real_t *realsptr=w.ptr(); int idx=0; String str; @@ -845,7 +845,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) #endif - w=DVector::Write(); + w=PoolVector::Write(); r_v=reals; 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(); - DVector strings; + PoolVector strings; strings.resize(len); - DVector::Write w=strings.write(); + PoolVector::Write w=strings.write(); String *stringsptr=w.ptr(); int idx=0; String str; @@ -903,7 +903,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) cs.push_back(c); } } - w=DVector::Write(); + w=PoolVector::Write(); r_v=strings; String sdfsdfg; Error err=parse_property_data(sdfsdfg); @@ -923,7 +923,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) StringArray array; array.resize(len); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); Error err; Variant v; @@ -964,9 +964,9 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) } int len=tag->args["len"].to_int();; - DVector vectors; + PoolVector vectors; vectors.resize(len); - DVector::Write w=vectors.write(); + PoolVector::Write w=vectors.write(); Vector3 *vectorsptr=w.ptr(); int idx=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; - w=DVector::Write(); + w=PoolVector::Write(); r_v=vectors; String sdfsdfg; 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();; - DVector vectors; + PoolVector vectors; vectors.resize(len); - DVector::Write w=vectors.write(); + PoolVector::Write w=vectors.write(); Vector2 *vectorsptr=w.ptr(); int idx=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; - w=DVector::Write(); + w=PoolVector::Write(); r_v=vectors; String sdfsdfg; 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();; - DVector colors; + PoolVector colors; colors.resize(len); - DVector::Write w=colors.write(); + PoolVector::Write w=colors.write(); Color *colorsptr=w.ptr(); int idx=0; int subidx=0; @@ -1194,7 +1194,7 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) str+=c; } } - w=DVector::Write(); + w=PoolVector::Write(); r_v=colors; String 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::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::INT_ARRAY: type="int_array"; params="len=\""+itos(p_property.operator DVector < int >().size())+"\""; break; - case Variant::REAL_ARRAY: type="real_array"; params="len=\""+itos(p_property.operator DVector < 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::VECTOR2_ARRAY: type="vector2_array"; params="len=\""+itos(p_property.operator DVector < Vector2 >().size())+"\""; break; - case Variant::VECTOR3_ARRAY: type="vector3_array"; params="len=\""+itos(p_property.operator DVector < Vector3 >().size())+"\""; break; - case Variant::COLOR_ARRAY: type="color_array"; params="len=\""+itos(p_property.operator DVector < Color >().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 PoolVector < int >().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 PoolVector < String >().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 PoolVector < Vector3 >().size())+"\""; break; + case Variant::COLOR_ARRAY: type="color_array"; params="len=\""+itos(p_property.operator PoolVector < Color >().size())+"\""; break; default: { ERR_PRINT("Unknown Variant type."); @@ -2403,9 +2403,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V String s; Image img = p_property; - DVector data = img.get_data(); + PoolVector data = img.get_data(); int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const uint8_t *ptr=r.ptr();; for (int i=0;i data = p_property; + PoolVector data = p_property; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const uint8_t *ptr=r.ptr();; for (int i=0;i data = p_property; + PoolVector data = p_property; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const int *ptr=r.ptr();; write_tabs(); @@ -2523,9 +2523,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V } break; case Variant::REAL_ARRAY: { - DVector data = p_property; + PoolVector data = p_property; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const real_t *ptr=r.ptr();; write_tabs(); String cm=", " ; @@ -2541,9 +2541,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V } break; case Variant::STRING_ARRAY: { - DVector data = p_property; + PoolVector data = p_property; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const String *ptr=r.ptr();; String s; //write_string("\n"); @@ -2560,9 +2560,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V } break; case Variant::VECTOR2_ARRAY: { - DVector data = p_property; + PoolVector data = p_property; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const Vector2 *ptr=r.ptr();; write_tabs(); @@ -2579,9 +2579,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V } break; case Variant::VECTOR3_ARRAY: { - DVector data = p_property; + PoolVector data = p_property; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const Vector3 *ptr=r.ptr();; write_tabs(); @@ -2599,9 +2599,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V } break; case Variant::COLOR_ARRAY: { - DVector data = p_property; + PoolVector data = p_property; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const Color *ptr=r.ptr();; write_tabs(); diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index 218e17278e3..a2812edb81f 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -29,16 +29,16 @@ #include "stream_peer.h" #include "io/marshalls.h" -Error StreamPeer::_put_data(const DVector& p_data) { +Error StreamPeer::_put_data(const PoolVector& p_data) { int len = p_data.size(); if (len==0) return OK; - DVector::Read r = p_data.read(); + PoolVector::Read r = p_data.read(); return put_data(&r[0],len); } -Array StreamPeer::_put_partial_data(const DVector& p_data) { +Array StreamPeer::_put_partial_data(const PoolVector& p_data) { Array ret; @@ -49,7 +49,7 @@ Array StreamPeer::_put_partial_data(const DVector& p_data) { return ret; } - DVector::Read r = p_data.read(); + PoolVector::Read r = p_data.read(); int sent; Error err = put_partial_data(&r[0],len,sent); @@ -66,18 +66,18 @@ Array StreamPeer::_get_data(int p_bytes) { Array ret; - DVector data; + PoolVector data; data.resize(p_bytes); if (data.size()!=p_bytes) { ret.push_back(ERR_OUT_OF_MEMORY); - ret.push_back(DVector()); + ret.push_back(PoolVector()); return ret; } - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); Error err = get_data(&w[0],p_bytes); - w = DVector::Write(); + w = PoolVector::Write(); ret.push_back(err); ret.push_back(data); return ret; @@ -88,19 +88,19 @@ Array StreamPeer::_get_partial_data(int p_bytes) { Array ret; - DVector data; + PoolVector data; data.resize(p_bytes); if (data.size()!=p_bytes) { ret.push_back(ERR_OUT_OF_MEMORY); - ret.push_back(DVector()); + ret.push_back(PoolVector()); return ret; } - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); int received; Error err = get_partial_data(&w[0],p_bytes,received); - w = DVector::Write(); + w = PoolVector::Write(); if (err!=OK) { data.resize(0); @@ -454,7 +454,7 @@ Error StreamPeerBuffer::put_data(const uint8_t* p_data,int p_bytes) { } - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); copymem(&w[pointer],p_data,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; } - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); copymem(p_buffer,r.ptr(),r_received); } @@ -520,13 +520,13 @@ void StreamPeerBuffer::resize(int p_size){ data.resize(p_size); } -void StreamPeerBuffer::set_data_array(const DVector & p_data){ +void StreamPeerBuffer::set_data_array(const PoolVector & p_data){ data=p_data; pointer=0; } -DVector StreamPeerBuffer::get_data_array() const{ +PoolVector StreamPeerBuffer::get_data_array() const{ return data; } diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h index 232a908dd76..eb0f90ba50e 100644 --- a/core/io/stream_peer.h +++ b/core/io/stream_peer.h @@ -38,8 +38,8 @@ protected: static void _bind_methods(); //bind helpers - Error _put_data(const DVector& p_data); - Array _put_partial_data(const DVector& p_data); + Error _put_data(const PoolVector& p_data); + Array _put_partial_data(const PoolVector& p_data); Array _get_data(int p_bytes); Array _get_partial_data(int p_bytes); @@ -96,7 +96,7 @@ class StreamPeerBuffer : public StreamPeer { GDCLASS(StreamPeerBuffer,StreamPeer); - DVector data; + PoolVector data; int pointer; protected: @@ -116,8 +116,8 @@ public: void resize(int p_size); - void set_data_array(const DVector & p_data); - DVector get_data_array() const; + void set_data_array(const PoolVector & p_data); + PoolVector get_data_array() const; void clear(); diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp index 751dfbadca6..bfa5dce58f0 100644 --- a/core/io/tcp_server.cpp +++ b/core/io/tcp_server.cpp @@ -44,7 +44,7 @@ TCP_Server* TCP_Server::create() { return _create(); } -Error TCP_Server::_listen(uint16_t p_port, DVector p_accepted_hosts) { +Error TCP_Server::_listen(uint16_t p_port, PoolVector p_accepted_hosts) { List hosts; for(int i=0;i())); + ClassDB::bind_method(_MD("listen","port","accepted_hosts"),&TCP_Server::_listen,DEFVAL(PoolVector())); 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("stop"),&TCP_Server::stop); diff --git a/core/io/tcp_server.h b/core/io/tcp_server.h index 5fd65575f60..3d7b3ddd8d4 100644 --- a/core/io/tcp_server.h +++ b/core/io/tcp_server.h @@ -43,7 +43,7 @@ protected: static TCP_Server* (*_create)(); //bind helper - Error _listen(uint16_t p_port, DVector p_accepted_hosts=DVector()); + Error _listen(uint16_t p_port, PoolVector p_accepted_hosts=PoolVector()); static void _bind_methods(); public: diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 29f61834b4a..0d6997183fa 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -295,10 +295,10 @@ bool AStar::_solve(Point* begin_point, Point* end_point) { } -DVector AStar::get_point_path(int p_from_id, int p_to_id) { +PoolVector AStar::get_point_path(int p_from_id, int p_to_id) { - ERR_FAIL_COND_V(!points.has(p_from_id),DVector()); - ERR_FAIL_COND_V(!points.has(p_to_id),DVector()); + ERR_FAIL_COND_V(!points.has(p_from_id),PoolVector()); + ERR_FAIL_COND_V(!points.has(p_to_id),PoolVector()); pass++; @@ -307,7 +307,7 @@ DVector AStar::get_point_path(int p_from_id, int p_to_id) { Point* b = points[p_to_id]; if (a==b) { - DVector ret; + PoolVector ret; ret.push_back(a->pos); return ret; } @@ -319,7 +319,7 @@ DVector AStar::get_point_path(int p_from_id, int p_to_id) { bool found_route=_solve(begin_point,end_point); if (!found_route) - return DVector(); + return PoolVector(); //midpoints Point *p=end_point; @@ -329,11 +329,11 @@ DVector AStar::get_point_path(int p_from_id, int p_to_id) { p=p->prev_point; } - DVector path; + PoolVector path; path.resize(pc); { - DVector::Write w = path.write(); + PoolVector::Write w = path.write(); Point *p=end_point; int idx=pc-1; @@ -351,10 +351,10 @@ DVector AStar::get_point_path(int p_from_id, int p_to_id) { } -DVector AStar::get_id_path(int p_from_id, int p_to_id) { +PoolVector AStar::get_id_path(int p_from_id, int p_to_id) { - ERR_FAIL_COND_V(!points.has(p_from_id),DVector()); - ERR_FAIL_COND_V(!points.has(p_to_id),DVector()); + ERR_FAIL_COND_V(!points.has(p_from_id),PoolVector()); + ERR_FAIL_COND_V(!points.has(p_to_id),PoolVector()); pass++; @@ -363,7 +363,7 @@ DVector AStar::get_id_path(int p_from_id, int p_to_id) { Point* b = points[p_to_id]; if (a==b) { - DVector ret; + PoolVector ret; ret.push_back(a->id); return ret; } @@ -375,7 +375,7 @@ DVector AStar::get_id_path(int p_from_id, int p_to_id) { bool found_route=_solve(begin_point,end_point); if (!found_route) - return DVector(); + return PoolVector(); //midpoints Point *p=end_point; @@ -385,11 +385,11 @@ DVector AStar::get_id_path(int p_from_id, int p_to_id) { p=p->prev_point; } - DVector path; + PoolVector path; path.resize(pc); { - DVector::Write w = path.write(); + PoolVector::Write w = path.write(); p=end_point; int idx=pc-1; diff --git a/core/math/a_star.h b/core/math/a_star.h index 66a983a6cec..35e6ead2262 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -113,8 +113,8 @@ public: int get_closest_point(const Vector3& p_point) const; Vector3 get_closest_pos_in_segment(const Vector3& p_point) const; - DVector get_point_path(int p_from_id, int p_to_id); - DVector get_id_path(int p_from_id, int p_to_id); + PoolVector get_point_path(int p_from_id, int p_to_id); + PoolVector get_id_path(int p_from_id, int p_to_id); AStar(); ~AStar(); diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp index 5242abfa3bc..b7194d7ffbe 100644 --- a/core/math/bsp_tree.cpp +++ b/core/math/bsp_tree.cpp @@ -484,7 +484,7 @@ BSP_Tree::operator Variant() const { d["planes"]=plane_values; - DVector dst_nodes; + PoolVector dst_nodes; dst_nodes.resize(nodes.size()*3); for(int i=0;i src_nodes = d["nodes"]; + PoolVector src_nodes = d["nodes"]; ERR_FAIL_COND(src_nodes.size()%3); if (d["planes"].get_type()==Variant::REAL_ARRAY) { - DVector src_planes=d["planes"]; + PoolVector src_planes=d["planes"]; int plane_count=src_planes.size(); ERR_FAIL_COND(plane_count%4); planes.resize(plane_count/4); if (plane_count) { - DVector::Read r = src_planes.read(); + PoolVector::Read r = src_planes.read(); for(int i=0;i::Read r = src_nodes.read(); + PoolVector::Read r = src_nodes.read(); for(int i=0;i& p_faces,float p_error_radius) { +BSP_Tree::BSP_Tree(const PoolVector& p_faces,float p_error_radius) { // compute aabb int face_count=p_faces.size(); - DVector::Read faces_r=p_faces.read(); + PoolVector::Read faces_r=p_faces.read(); const Face3 *facesptr = faces_r.ptr(); diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h index 3913e3d34ae..236b6e5ac2d 100644 --- a/core/math/bsp_tree.h +++ b/core/math/bsp_tree.h @@ -91,7 +91,7 @@ public: BSP_Tree(); BSP_Tree(const Variant& p_variant); - BSP_Tree(const DVector& p_faces,float p_error_radius=0); + BSP_Tree(const PoolVector& p_faces,float p_error_radius=0); BSP_Tree(const Vector &p_nodes, const Vector &p_planes, const AABB& p_aabb,float p_error_radius=0); ~BSP_Tree(); diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index 91f7cf179a2..3232d36262d 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -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(); - DVector::Read r=p_array.read(); + PoolVector::Read r=p_array.read(); const Face3* arrayptr = r.ptr(); - DVector< _FaceClassify> fc; + PoolVector< _FaceClassify> fc; fc.resize( len ); - DVector< _FaceClassify >::Write fcw=fc.write(); + PoolVector< _FaceClassify >::Write fcw=fc.write(); _FaceClassify * _fcptr = fcw.ptr(); @@ -231,7 +231,7 @@ DVector< DVector< Face3 > > Geometry::separate_objects( DVector< Face3 > p_array 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 */ @@ -257,8 +257,8 @@ DVector< DVector< Face3 > > Geometry::separate_objects( DVector< Face3 > p_array if (group>=0) { objects.resize(group); - DVector< DVector >::Write obw=objects.write(); - DVector< Face3 > *group_faces = obw.ptr(); + PoolVector< PoolVector >::Write obw=objects.write(); + PoolVector< Face3 > *group_faces = obw.ptr(); for (int i=0;i& 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& p_faces) { ERR_FAIL_INDEX(x,len_x); 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 _MAX_LENGTH 20 int face_count=p_array.size(); - DVector::Read facesr=p_array.read(); + PoolVector::Read facesr=p_array.read(); const Face3 *faces = facesr.ptr(); 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"); - DVector wrapped_faces; + PoolVector wrapped_faces; for (int i=0;i Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro // transform face vertices to global coords int wrapped_faces_count=wrapped_faces.size(); - DVector::Write wrapped_facesw=wrapped_faces.write(); + PoolVector::Write wrapped_facesw=wrapped_faces.write(); Face3* wrapped_faces_ptr=wrapped_facesw.ptr(); for(int i=0;i Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro return wrapped_faces; } -Geometry::MeshData Geometry::build_convex_mesh(const DVector &p_planes) { +Geometry::MeshData Geometry::build_convex_mesh(const PoolVector &p_planes) { MeshData mesh; @@ -896,9 +896,9 @@ Geometry::MeshData Geometry::build_convex_mesh(const DVector &p_planes) { } -DVector Geometry::build_box_planes(const Vector3& p_extents) { +PoolVector Geometry::build_box_planes(const Vector3& p_extents) { - DVector planes; + PoolVector planes; 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 Geometry::build_box_planes(const Vector3& p_extents) { return planes; } -DVector Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) { +PoolVector Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) { - DVector planes; + PoolVector planes; for (int i=0;i Geometry::build_cylinder_planes(float p_radius, float p_height, i } -DVector Geometry::build_sphere_planes(float p_radius, int p_lats,int p_lons, Vector3::Axis p_axis) { +PoolVector Geometry::build_sphere_planes(float p_radius, int p_lats,int p_lons, Vector3::Axis p_axis) { - DVector planes; + PoolVector planes; Vector3 axis; axis[p_axis]=1.0; @@ -969,9 +969,9 @@ DVector Geometry::build_sphere_planes(float p_radius, int p_lats,int p_lo } -DVector Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) { +PoolVector Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) { - DVector planes; + PoolVector planes; Vector3 axis; axis[p_axis]=1.0; diff --git a/core/math/geometry.h b/core/math/geometry.h index dae556cd09c..9800e5513cc 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -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 { @@ -919,11 +919,11 @@ public: return H; } - static MeshData build_convex_mesh(const DVector &p_planes); - static DVector build_sphere_planes(float p_radius, int p_lats, int p_lons, Vector3::Axis p_axis=Vector3::AXIS_Z); - static DVector build_box_planes(const Vector3& p_extents); - static DVector build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z); - static DVector build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis=Vector3::AXIS_Z); + static MeshData build_convex_mesh(const PoolVector &p_planes); + static PoolVector build_sphere_planes(float p_radius, int p_lats, int p_lons, Vector3::Axis p_axis=Vector3::AXIS_Z); + static PoolVector build_box_planes(const Vector3& p_extents); + static PoolVector build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z); + static PoolVector 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& p_rects,Vector& r_result, Size2i& r_size); diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index b3daee0c7e4..101e164eaef 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -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& p_faces) { +void TriangleMesh::create(const PoolVector& p_faces) { valid=false; @@ -104,7 +104,7 @@ void TriangleMesh::create(const DVector& p_faces) { triangles.resize(fc); bvh.resize(fc*3); //will never be larger than this (todo make better) - DVector::Write bw = bvh.write(); + PoolVector::Write bw = bvh.write(); { @@ -112,8 +112,8 @@ void TriangleMesh::create(const DVector& p_faces) { //except for the Set for repeated triangles, everything //goes in-place. - DVector::Read r = p_faces.read(); - DVector::Write w = triangles.write(); + PoolVector::Read r = p_faces.read(); + PoolVector::Write w = triangles.write(); Map db; for(int i=0;i& p_faces) { } vertices.resize(db.size()); - DVector::Write vw = vertices.write(); + PoolVector::Write vw = vertices.write(); for (Map::Element *E=db.front();E;E=E->next()) { vw[E->get()]=E->key(); } } - DVector bwptrs; + PoolVector bwptrs; bwptrs.resize(fc); - DVector::Write bwp = bwptrs.write(); + PoolVector::Write bwp = bwptrs.write(); for(int i=0;i& p_faces) { int max_alloc=fc; int max=_create_bvh(bw.ptr(),bwp.ptr(),0,fc,1,max_depth,max_alloc); - bw=DVector::Write(); //clearup + bw=PoolVector::Write(); //clearup bvh.resize(max_alloc); //resize back valid=true; @@ -197,9 +197,9 @@ Vector3 TriangleMesh::get_area_normal(const AABB& p_aabb) const { int level=0; - DVector::Read trianglesr = triangles.read(); - DVector::Read verticesr=vertices.read(); - DVector::Read bvhr=bvh.read(); + PoolVector::Read trianglesr = triangles.read(); + PoolVector::Read verticesr=vertices.read(); + PoolVector::Read bvhr=bvh.read(); const Triangle *triangleptr=trianglesr.ptr(); int pos=bvh.size()-1; @@ -299,9 +299,9 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end int level=0; - DVector::Read trianglesr = triangles.read(); - DVector::Read verticesr=vertices.read(); - DVector::Read bvhr=bvh.read(); + PoolVector::Read trianglesr = triangles.read(); + PoolVector::Read verticesr=vertices.read(); + PoolVector::Read bvhr=bvh.read(); const Triangle *triangleptr=trianglesr.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; - DVector::Read trianglesr = triangles.read(); - DVector::Read verticesr=vertices.read(); - DVector::Read bvhr=bvh.read(); + PoolVector::Read trianglesr = triangles.read(); + PoolVector::Read verticesr=vertices.read(); + PoolVector::Read bvhr=bvh.read(); const Triangle *triangleptr=trianglesr.ptr(); const Vector3 *vertexptr=verticesr.ptr(); @@ -524,18 +524,18 @@ bool TriangleMesh::is_valid() const { return valid; } -DVector TriangleMesh::get_faces() const { +PoolVector TriangleMesh::get_faces() const { if (!valid) - return DVector(); + return PoolVector(); - DVector faces; + PoolVector faces; int ts = triangles.size(); faces.resize(triangles.size()); - DVector::Write w=faces.write(); - DVector::Read r = triangles.read(); - DVector::Read rv = vertices.read(); + PoolVector::Write w=faces.write(); + PoolVector::Read r = triangles.read(); + PoolVector::Read rv = vertices.read(); for(int i=0;i TriangleMesh::get_faces() const { } } - w = DVector::Write(); + w = PoolVector::Write(); return faces; } diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h index d42f9c8dded..37d32bd7ec7 100644 --- a/core/math/triangle_mesh.h +++ b/core/math/triangle_mesh.h @@ -41,8 +41,8 @@ class TriangleMesh : public Reference { int indices[3]; }; - DVector triangles; - DVector vertices; + PoolVector triangles; + PoolVector vertices; 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); - DVector bvh; + PoolVector bvh; int max_depth; 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_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; - DVector get_faces() const; + PoolVector get_faces() const; - void create(const DVector& p_faces); + void create(const PoolVector& p_faces); TriangleMesh(); }; diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h index e38d59fd8f7..2e3959c3ab6 100644 --- a/core/method_ptrcall.h +++ b/core/method_ptrcall.h @@ -133,12 +133,12 @@ struct PtrToArg< const T* > { template<>\ struct PtrToArg > {\ _FORCE_INLINE_ static Vector convert(const void* p_ptr) {\ - const DVector *dvs = reinterpret_cast *>(p_ptr);\ + const PoolVector *dvs = reinterpret_cast *>(p_ptr);\ Vector ret;\ int len = dvs->size();\ ret.resize(len);\ {\ - DVector::Read r=dvs->read();\ + PoolVector::Read r=dvs->read();\ for(int i=0;i > {\ return ret;\ }\ _FORCE_INLINE_ static void encode(Vector p_vec, void* p_ptr) {\ - DVector *dv = reinterpret_cast *>(p_ptr);\ + PoolVector *dv = reinterpret_cast *>(p_ptr);\ int len=p_vec.size();\ dv->resize(len);\ {\ - DVector::Write w=dv->write();\ + PoolVector::Write w=dv->write();\ for(int i=0;i > {\ template<>\ struct PtrToArg& > {\ _FORCE_INLINE_ static Vector convert(const void* p_ptr) {\ - const DVector *dvs = reinterpret_cast *>(p_ptr);\ + const PoolVector *dvs = reinterpret_cast *>(p_ptr);\ Vector ret;\ int len = dvs->size();\ ret.resize(len);\ {\ - DVector::Read r=dvs->read();\ + PoolVector::Read r=dvs->read();\ for(int i=0;i\ -struct PtrToArg > {\ - _FORCE_INLINE_ static DVector convert(const void* p_ptr) {\ +struct PtrToArg > {\ + _FORCE_INLINE_ static PoolVector convert(const void* p_ptr) {\ const Array *arr = reinterpret_cast(p_ptr);\ - DVector ret;\ + PoolVector ret;\ int len = arr->size();\ ret.resize(len);\ {\ - DVector::Write w=ret.write();\ + PoolVector::Write w=ret.write();\ for(int i=0;i p_vec, void* p_ptr) {\ + _FORCE_INLINE_ static void encode(PoolVector p_vec, void* p_ptr) {\ Array *arr = reinterpret_cast(p_ptr);\ int len = p_vec.size();\ arr->resize(len);\ {\ - DVector::Read r=p_vec.read();\ + PoolVector::Read r=p_vec.read();\ for(int i=0;i > {\ } \ };\ template<>\ -struct PtrToArg& > {\ - _FORCE_INLINE_ static DVector convert(const void* p_ptr) {\ +struct PtrToArg& > {\ + _FORCE_INLINE_ static PoolVector convert(const void* p_ptr) {\ const Array *arr = reinterpret_cast(p_ptr);\ - DVector ret;\ + PoolVector ret;\ int len = arr->size();\ ret.resize(len);\ {\ - DVector::Write w=ret.write();\ + PoolVector::Write w=ret.write();\ for(int i=0;i -struct PtrToArg > { - _FORCE_INLINE_ static DVector convert(const void* p_ptr) { - const DVector *dvs = reinterpret_cast *>(p_ptr); - DVector ret; +struct PtrToArg > { + _FORCE_INLINE_ static PoolVector convert(const void* p_ptr) { + const PoolVector *dvs = reinterpret_cast *>(p_ptr); + PoolVector ret; int len = dvs->size()/3; ret.resize(len); { - DVector::Read r=dvs->read(); - DVector::Write w=ret.write(); + PoolVector::Read r=dvs->read(); + PoolVector::Write w=ret.write(); for(int i=0;i > { } return ret; } - _FORCE_INLINE_ static void encode(DVector p_vec, void* p_ptr) {\ - DVector *arr = reinterpret_cast *>(p_ptr);\ + _FORCE_INLINE_ static void encode(PoolVector p_vec, void* p_ptr) {\ + PoolVector *arr = reinterpret_cast *>(p_ptr);\ int len = p_vec.size();\ arr->resize(len*3);\ {\ - DVector::Read r=p_vec.read();\ - DVector::Write w=arr->write();\ + PoolVector::Read r=p_vec.read();\ + PoolVector::Write w=arr->write();\ for(int i=0;i > { } \ }; template<> -struct PtrToArg& > { - _FORCE_INLINE_ static DVector convert(const void* p_ptr) { - const DVector *dvs = reinterpret_cast *>(p_ptr); - DVector ret; +struct PtrToArg& > { + _FORCE_INLINE_ static PoolVector convert(const void* p_ptr) { + const PoolVector *dvs = reinterpret_cast *>(p_ptr); + PoolVector ret; int len = dvs->size()/3; ret.resize(len); { - DVector::Read r=dvs->read(); - DVector::Write w=ret.write(); + PoolVector::Read r=dvs->read(); + PoolVector::Write w=ret.write(); for(int i=0;i Object::_get_meta_list_bind() const { +PoolVector Object::_get_meta_list_bind() const { - DVector _metaret; + PoolVector _metaret; List keys; metadata.get_key_list(&keys); @@ -1942,27 +1942,37 @@ uint32_t ObjectDB::instance_counter=1; HashMap ObjectDB::instance_checks; uint32_t ObjectDB::add_instance(Object *p_object) { - GLOBAL_LOCK_FUNCTION; + ERR_FAIL_COND_V( p_object->get_instance_ID()!=0, 0 ); + + rw_lock->write_lock(); instances[++instance_counter]=p_object; #ifdef DEBUG_ENABLED instance_checks[p_object]=instance_counter; #endif + rw_lock->write_unlock(); + return instance_counter; } void ObjectDB::remove_instance(Object *p_object) { - GLOBAL_LOCK_FUNCTION; + + rw_lock->write_lock(); + instances.erase( p_object->get_instance_ID() ); #ifdef DEBUG_ENABLED instance_checks.erase(p_object); #endif + + rw_lock->write_unlock(); } Object *ObjectDB::get_instance(uint32_t p_instance_ID) { - GLOBAL_LOCK_FUNCTION; + rw_lock->read_lock(); Object**obj=instances.getptr(p_instance_ID); + rw_lock->read_unlock(); + if (!obj) return NULL; return *obj; @@ -1970,13 +1980,16 @@ Object *ObjectDB::get_instance(uint32_t p_instance_ID) { void ObjectDB::debug_objects(DebugFunc p_func) { - GLOBAL_LOCK_FUNCTION; + rw_lock->read_lock(); const uint32_t *K=NULL; while((K=instances.next(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,Listread_lock(); + 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() { - GLOBAL_LOCK_FUNCTION; + rw_lock->write_lock(); if (instances.size()) { WARN_PRINT("ObjectDB Instances still exist!"); @@ -2014,4 +2038,7 @@ void ObjectDB::cleanup() { } instances.clear(); instance_checks.clear(); + rw_lock->write_unlock(); + + memdelete(rw_lock); } diff --git a/core/object.h b/core/object.h index 6dd427bf410..7c74f705189 100644 --- a/core/object.h +++ b/core/object.h @@ -34,6 +34,7 @@ #include "set.h" #include "map.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_PASS p_arg1,p_arg2,p_arg3,p_arg4,p_arg5 @@ -481,7 +482,7 @@ protected: return &_class_name; } - DVector _get_meta_list_bind() const; + PoolVector _get_meta_list_bind() const; Array _get_property_list_bind() const; Array _get_method_list_bind() const; @@ -686,9 +687,14 @@ class ObjectDB { friend class Object; friend void unregister_core_types(); + + static RWLock *rw_lock; static void cleanup(); static uint32_t add_instance(Object *p_object); static void remove_instance(Object *p_object); +friend void register_core_types(); + static void setup(); + public: typedef void (*DebugFunc)(Object *p_obj); diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp index 94cc865b623..7432c095637 100644 --- a/core/object_type_db.cpp +++ b/core/object_type_db.cpp @@ -31,11 +31,12 @@ #ifdef NO_THREADS -#define OBJTYPE_LOCK +#define OBJTYPE_RLOCK #else -#define OBJTYPE_LOCK MutexLock _mutex_lock_(lock); +#define OBJTYPE_RLOCK RWLockRead _rw_lockr_(lock); +#define OBJTYPE_WLOCK RWLockWrite _rw_lockw_(lock); #endif @@ -215,7 +216,7 @@ ClassDB::ClassInfo::~ClassInfo() { bool ClassDB::is_parent_class(const StringName &p_class,const StringName& p_inherits) { - OBJTYPE_LOCK; + OBJTYPE_RLOCK; 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 *p_classes) { - OBJTYPE_LOCK; + OBJTYPE_RLOCK; const StringName *k=NULL; @@ -245,7 +246,7 @@ void ClassDB::get_class_list( List *p_classes) { void ClassDB::get_inheriters_from_class( const StringName& p_class,List *p_classes) { - OBJTYPE_LOCK; + OBJTYPE_RLOCK; const StringName *k=NULL; @@ -259,7 +260,7 @@ void ClassDB::get_inheriters_from_class( const StringName& p_class,Listdisabled || !ti->creation_func) { 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) { - OBJTYPE_LOCK; + OBJTYPE_RLOCK; ClassInfo *ti = classes.getptr(p_class); 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) { - OBJTYPE_LOCK; + OBJTYPE_WLOCK; 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 *p_methods,bool p_no_inheritance) { - OBJTYPE_LOCK; + OBJTYPE_RLOCK; ClassInfo *type=classes.getptr(p_class); @@ -572,7 +575,7 @@ void ClassDB::get_method_list(StringName p_class,List *p_methods,boo MethodBind *ClassDB::get_method(StringName p_class, StringName p_name) { - OBJTYPE_LOCK; + OBJTYPE_RLOCK; 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) { - OBJTYPE_LOCK; + OBJTYPE_WLOCK; ClassInfo *type=classes.getptr(p_class); 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 *p_constants, bool p_no_inheritance) { - OBJTYPE_LOCK; + OBJTYPE_RLOCK; ClassInfo *type=classes.getptr(p_class); @@ -639,7 +642,7 @@ void ClassDB::get_integer_constant_list(const StringName& p_class, List 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); @@ -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) { + OBJTYPE_WLOCK; + ClassInfo *type=classes.getptr(p_class); 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 *p_signals,bool p_no_inheritance) { + OBJTYPE_RLOCK; + ClassInfo *type=classes.getptr(p_class); ERR_FAIL_COND(!type); @@ -712,6 +719,7 @@ void ClassDB::get_signal_list(StringName p_class,List *p_signals,boo bool ClassDB::has_signal(StringName p_class,StringName p_signal) { + OBJTYPE_RLOCK; ClassInfo *type=classes.getptr(p_class); ClassInfo *check=type; 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) { + OBJTYPE_RLOCK; ClassInfo *type=classes.getptr(p_class); ClassInfo *check=type; 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) { + OBJTYPE_WLOCK; ClassInfo *type=classes.getptr(p_class); 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) { + + lock->read_lock(); + ClassInfo *type=classes.getptr(p_class); + + lock->read_unlock(); + ERR_FAIL_COND(!type); MethodBind *mb_set=NULL; @@ -804,6 +820,9 @@ void ClassDB::add_property(StringName p_class,const PropertyInfo& p_pinfo, const ERR_FAIL(); } #endif + + OBJTYPE_WLOCK + type->property_list.push_back(p_pinfo); 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 *p_list, bool p_no_inheritance,const Object *p_validator) { + OBJTYPE_RLOCK; + ClassInfo *type=classes.getptr(p_class); ClassInfo *check=type; while(check) { @@ -846,6 +867,7 @@ void ClassDB::get_property_list(StringName p_class, List *p_list, 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 *check=type; 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) { + OBJTYPE_WLOCK; ClassInfo *type=classes.getptr(p_class); ClassInfo *check=type; 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); 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) { ERR_FAIL_COND(!classes.has(p_class)); + OBJTYPE_WLOCK; + #ifdef DEBUG_METHODS_ENABLED MethodInfo mi=p_method; if (p_virtual) @@ -1149,12 +1174,16 @@ void ClassDB::get_virtual_methods(const StringName& p_class, List * void ClassDB::set_class_enabled(StringName p_class,bool p_enable) { + OBJTYPE_WLOCK; + ERR_FAIL_COND(!classes.has(p_class)); classes[p_class].disabled=!p_enable; } bool ClassDB::is_class_enabled(StringName p_class) { + OBJTYPE_RLOCK; + ClassInfo *ti=classes.getptr(p_class); if (!ti || !ti->creation_func) { if (compat_classes.has(p_class)) { @@ -1206,23 +1235,19 @@ void ClassDB::get_extensions_for_type(const StringName& p_class,List *p_ } -Mutex *ClassDB::lock=NULL; +RWLock *ClassDB::lock=NULL; void ClassDB::init() { #ifndef NO_THREADS - lock = Mutex::create(); + lock = RWLock::create(); #endif } void ClassDB::cleanup() { -#ifndef NO_THREADS - - memdelete(lock); -#endif //OBJTYPE_LOCK; hah not here @@ -1241,6 +1266,12 @@ void ClassDB::cleanup() { classes.clear(); resource_base_extensions.clear(); compat_classes.clear(); + +#ifndef NO_THREADS + + memdelete(lock); +#endif + } // diff --git a/core/object_type_db.h b/core/object_type_db.h index 3613d351e4d..158a4dae23a 100644 --- a/core/object_type_db.h +++ b/core/object_type_db.h @@ -156,7 +156,7 @@ public: return memnew( T ); } - static Mutex *lock; + static RWLock *lock; static HashMap classes; static HashMap resource_base_extensions; static HashMap compat_classes; diff --git a/core/os/memory.cpp b/core/os/memory.cpp index cf42c3681a7..37a523b763c 100644 --- a/core/os/memory.cpp +++ b/core/os/memory.cpp @@ -33,61 +33,6 @@ #include -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) { @@ -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() { diff --git a/core/os/memory.h b/core/os/memory.h index 6a939e3d6f2..0e6dea48d34 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -31,8 +31,6 @@ #include #include "safe_refcount.h" -#include "os/memory_pool_dynamic.h" - /** @@ -44,88 +42,6 @@ #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{ @@ -148,12 +64,6 @@ public: 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 { @@ -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) -#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 *) {} @@ -241,7 +139,7 @@ T* memnew_arr_template(size_t p_elements,const char *p_descr="") { if (p_elements==0) return 0; /** overloading operator new[] cannot be done , because it may not return the real allocated address (it may pad the 'element count' before the actual array). Because of that, it must be done by hand. This is the - same strategy used by std::vector, and the 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; uint64_t *mem = (uint64_t*)Memory::alloc_static( len , true ); diff --git a/core/os/memory_pool_dynamic.cpp b/core/os/memory_pool_dynamic.cpp deleted file mode 100644 index 0bd64a03626..00000000000 --- a/core/os/memory_pool_dynamic.cpp +++ /dev/null @@ -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; -} diff --git a/core/os/memory_pool_dynamic.h b/core/os/memory_pool_dynamic.h deleted file mode 100644 index 025e925d3c0..00000000000 --- a/core/os/memory_pool_dynamic.h +++ /dev/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 - - - - - diff --git a/core/os/memory_pool_dynamic_prealloc.cpp b/core/os/memory_pool_dynamic_prealloc.cpp deleted file mode 100644 index d2efa4cc889..00000000000 --- a/core/os/memory_pool_dynamic_prealloc.cpp +++ /dev/null @@ -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 ); -} - diff --git a/core/os/memory_pool_dynamic_prealloc.h b/core/os/memory_pool_dynamic_prealloc.h deleted file mode 100644 index a2e51b93f34..00000000000 --- a/core/os/memory_pool_dynamic_prealloc.h +++ /dev/null @@ -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 diff --git a/core/os/memory_pool_dynamic_static.cpp b/core/os/memory_pool_dynamic_static.cpp deleted file mode 100644 index b7a1bbc19fa..00000000000 --- a/core/os/memory_pool_dynamic_static.cpp +++ /dev/null @@ -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 - -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) - 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 + + + +RWLock* (*RWLock::create_func)()=0; + +RWLock *RWLock::create() { + + ERR_FAIL_COND_V( !create_func, 0 ); + + return create_func(); +} + + +RWLock::~RWLock() { + + +} + diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h new file mode 100644 index 00000000000..c513e6d6360 --- /dev/null +++ b/core/os/rw_lock.h @@ -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 diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index 8bf77b735a6..77afbfc2147 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -82,7 +82,7 @@ Variant PackedDataContainer::_iter_get_ofs(const Variant& p_iter,uint32_t p_offs if (pos<0 || pos>=size) return Variant(); - DVector::Read rd=data.read(); + PoolVector::Read rd=data.read(); const uint8_t *r=&rd[p_offset]; 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 { - DVector::Read rd=data.read(); + PoolVector::Read rd=data.read(); const uint8_t *r=&rd[p_ofs]; 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 { - DVector::Read rd=data.read(); + PoolVector::Read rd=data.read(); const uint8_t *r=&rd[p_ofs]; 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 { - DVector::Read rd=data.read(); + PoolVector::Read rd=data.read(); const uint8_t *r=&rd[p_ofs]; uint32_t type = decode_uint32(r); @@ -344,21 +344,21 @@ Error PackedDataContainer::pack(const Variant& p_data) { _pack(p_data,tmpdata,string_cache); datalen=tmpdata.size(); data.resize(tmpdata.size()); - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); copymem(w.ptr(),tmpdata.ptr(),tmpdata.size()); return OK; } -void PackedDataContainer::_set_data(const DVector& p_data) { +void PackedDataContainer::_set_data(const PoolVector& p_data) { data=p_data; datalen=data.size(); } -DVector PackedDataContainer::_get_data() const { +PoolVector PackedDataContainer::_get_data() const { return data; } diff --git a/core/packed_data_container.h b/core/packed_data_container.h index 5e0180a4249..f8ff43f9b03 100644 --- a/core/packed_data_container.h +++ b/core/packed_data_container.h @@ -50,7 +50,7 @@ class PackedDataContainer : public Resource { }; - DVector data; + PoolVector data; int datalen; @@ -73,8 +73,8 @@ friend class PackedDataContainerRef; protected: - void _set_data(const DVector& p_data); - DVector _get_data() const; + void _set_data(const PoolVector& p_data); + PoolVector _get_data() const; static void _bind_methods(); public: diff --git a/core/path_remap.cpp b/core/path_remap.cpp index 92a2ab9af7c..980e8f76e72 100644 --- a/core/path_remap.cpp +++ b/core/path_remap.cpp @@ -124,13 +124,13 @@ void PathRemap::clear_remaps() { void PathRemap::load_remaps() { // default remaps first - DVector remaps = GlobalConfig::get_singleton()->get("remap/all"); + PoolVector remaps = GlobalConfig::get_singleton()->get("remap/all"); { int rlen = remaps.size(); ERR_FAIL_COND( rlen%2 ); - DVector::Read r = remaps.read(); + PoolVector::Read r = remaps.read(); for(int i=0;i::Read r = remaps.read(); + PoolVector::Read r = remaps.read(); for(int i=0;iwrite_lock(); ResourceCache::resources.erase(path_cache); + ResourceCache::lock->write_unlock(); } 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) { + ResourceCache::lock->write_lock(); ResourceCache::resources.get(p_path)->set_name(""); + ResourceCache::lock->write_unlock(); } else { 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!="") { + ResourceCache::lock->write_lock(); ResourceCache::resources[path_cache]=this;; + ResourceCache::lock->write_unlock(); } _change_notify("resource/path"); @@ -393,8 +409,11 @@ Resource::Resource() { Resource::~Resource() { - if (path_cache!="") + if (path_cache!="") { + ResourceCache::lock->write_lock(); ResourceCache::resources.erase(path_cache); + ResourceCache::lock->write_unlock(); + } if (owners.size()) { WARN_PRINT("Resource is still owned"); } @@ -402,18 +421,24 @@ Resource::~Resource() { HashMap ResourceCache::resources; +RWLock *ResourceCache::lock=NULL; + +void ResourceCache::setup() { + + lock = RWLock::create(); +} + void ResourceCache::clear() { if (resources.size()) ERR_PRINT("Resources Still in use at Exit!"); resources.clear(); + memdelete(lock); } void ResourceCache::reload_externals() { - GLOBAL_LOCK_FUNCTION - //const String *K=NULL; //while ((K=resources.next(K))) { // resources[*K]->reload_external_data(); @@ -423,15 +448,21 @@ void ResourceCache::reload_externals() { 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) { - GLOBAL_LOCK_FUNCTION + lock->read_lock(); Resource **res = resources.getptr(p_path); + + lock->read_unlock(); + if (!res) { return NULL; } @@ -443,6 +474,7 @@ Resource *ResourceCache::get(const String& p_path) { void ResourceCache::get_cached_resources(List > *p_resources) { + lock->read_lock(); const String* K=NULL; while((K=resources.next(K))) { @@ -450,17 +482,22 @@ void ResourceCache::get_cached_resources(List > *p_resources) { p_resources->push_back( Ref( r )); } + lock->read_unlock(); } 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) { #ifdef DEBUG_ENABLED - GLOBAL_LOCK_FUNCTION + lock->read_lock(); Map type_count; @@ -500,5 +537,7 @@ void ResourceCache::dump(const char* p_file,bool p_short) { memdelete(f); } + lock->read_unlock(); + #endif } diff --git a/core/resource.h b/core/resource.h index cb109b37675..11f2c5ee2a9 100644 --- a/core/resource.h +++ b/core/resource.h @@ -165,9 +165,12 @@ typedef Ref RES; class ResourceCache { friend class Resource; + static RWLock *lock; static HashMap resources; friend void unregister_core_types(); static void clear(); +friend void register_core_types(); + static void setup(); public: static void reload_externals(); diff --git a/core/safe_refcount.cpp b/core/safe_refcount.cpp index f0d4fbd610a..ede37bbe8a7 100644 --- a/core/safe_refcount.cpp +++ b/core/safe_refcount.cpp @@ -76,6 +76,9 @@ uint32_t atomic_decrement( register uint32_t * pw ) { return InterlockedDecrement( (LONG volatile*)pw ); } +uint32_t atomic_increment( register uint32_t * pw ) { + return InterlockedIncrement( (LONG volatile*)pw ); +} #elif defined(__GNUC__) 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 //no threads supported? #error Must provide atomic functions for this platform or compiler! diff --git a/core/safe_refcount.h b/core/safe_refcount.h index 08bea9d244f..6e349d89d8d 100644 --- a/core/safe_refcount.h +++ b/core/safe_refcount.h @@ -38,6 +38,7 @@ uint32_t atomic_conditional_increment( register uint32_t * counter ); uint32_t atomic_decrement( register uint32_t * pw ); +uint32_t atomic_increment( register uint32_t * pw ); diff --git a/core/string_db.cpp b/core/string_db.cpp index 471195ceda0..be35a44ed13 100644 --- a/core/string_db.cpp +++ b/core/string_db.cpp @@ -41,9 +41,12 @@ StringName _scs_create(const char *p_chr) { } bool StringName::configured=false; +Mutex* StringName::lock=NULL; void StringName::setup() { + lock = Mutex::create(); + ERR_FAIL_COND(configured); for(int i=0;ilock(); + int lost_strings=0; for(int i=0;iis_stdout_verbose() && lost_strings) { print_line("StringName: "+itos(lost_strings)+" unclaimed string names at exit."); } - _global_unlock(); + lock->unlock(); + + memdelete(lock); } void StringName::unref() { @@ -87,7 +93,7 @@ void StringName::unref() { if (_data && _data->refcount.unref()) { - _global_lock(); + lock->lock(); if (_data->prev) { _data->prev->next=_data->next; @@ -103,7 +109,7 @@ void StringName::unref() { } memdelete(_data); - _global_unlock(); + lock->unlock(); } _data=NULL; @@ -186,7 +192,7 @@ StringName::StringName(const char *p_name) { if (!p_name || p_name[0]==0) return; //empty, ignore - _global_lock(); + lock->lock(); uint32_t hash = String::hash(p_name); @@ -206,7 +212,7 @@ StringName::StringName(const char *p_name) { if (_data) { if (_data->refcount.ref()) { // exists - _global_unlock(); + lock->unlock(); return; } else { @@ -226,8 +232,7 @@ StringName::StringName(const char *p_name) { _table[idx]=_data; - _global_unlock(); - + lock->unlock(); } 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]); - _global_lock(); + lock->lock(); uint32_t hash = String::hash(p_static_string.ptr); @@ -258,7 +263,7 @@ StringName::StringName(const StaticCString& p_static_string) { if (_data) { if (_data->refcount.ref()) { // exists - _global_unlock(); + lock->unlock(); return; } else { @@ -278,7 +283,8 @@ StringName::StringName(const StaticCString& p_static_string) { _table[idx]=_data; - _global_unlock(); + lock->unlock(); + } @@ -292,7 +298,7 @@ StringName::StringName(const String& p_name) { if (p_name==String()) return; - _global_lock(); + lock->lock(); uint32_t hash = p_name.hash(); @@ -311,7 +317,7 @@ StringName::StringName(const String& p_name) { if (_data) { if (_data->refcount.ref()) { // exists - _global_unlock(); + lock->unlock(); return; } else { @@ -332,7 +338,7 @@ StringName::StringName(const String& p_name) { _table[idx]->prev=_data; _table[idx]=_data; - _global_unlock(); + lock->unlock(); } @@ -344,7 +350,7 @@ StringName StringName::search(const char *p_name) { if (!p_name[0]) return StringName(); - _global_lock(); + lock->lock(); uint32_t hash = String::hash(p_name); @@ -361,12 +367,13 @@ StringName StringName::search(const char *p_name) { } if (_data && _data->refcount.ref()) { - _global_unlock(); + lock->unlock(); + return StringName(_data); } - _global_unlock(); + lock->unlock(); return StringName(); //does not exist @@ -380,7 +387,7 @@ StringName StringName::search(const CharType *p_name) { if (!p_name[0]) return StringName(); - _global_lock(); + lock->lock(); uint32_t hash = String::hash(p_name); @@ -397,12 +404,12 @@ StringName StringName::search(const CharType *p_name) { } if (_data && _data->refcount.ref()) { - _global_unlock(); + lock->unlock(); return StringName(_data); } - _global_unlock(); + lock->unlock(); return StringName(); //does not exist } @@ -410,7 +417,7 @@ StringName StringName::search(const String &p_name) { ERR_FAIL_COND_V( p_name=="", StringName() ); - _global_lock(); + lock->lock(); uint32_t hash = p_name.hash(); @@ -427,12 +434,12 @@ StringName StringName::search(const String &p_name) { } if (_data && _data->refcount.ref()) { - _global_unlock(); + lock->unlock(); return StringName(_data); } - _global_unlock(); + lock->unlock(); return StringName(); //does not exist } diff --git a/core/string_db.h b/core/string_db.h index fd241592650..a14cdbc7baa 100644 --- a/core/string_db.h +++ b/core/string_db.h @@ -32,7 +32,7 @@ #include "hash_map.h" #include "ustring.h" #include "safe_refcount.h" - +#include "os/mutex.h" /** @author Juan Linietsky */ @@ -83,6 +83,7 @@ class StringName { friend void register_core_types(); friend void unregister_core_types(); + static Mutex *lock; static void setup(); static void cleanup(); static bool configured; diff --git a/core/translation.cpp b/core/translation.cpp index 8e58b45565e..302f74a98cd 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -799,9 +799,9 @@ static bool is_valid_locale(const String& p_locale) { return false; } -DVector Translation::_get_messages() const { +PoolVector Translation::_get_messages() const { - DVector msgs; + PoolVector msgs; msgs.resize(translation_map.size()*2); int idx=0; for (const Map::Element *E=translation_map.front();E;E=E->next()) { @@ -814,9 +814,9 @@ DVector Translation::_get_messages() const { return msgs; } -DVector Translation::_get_message_list() const { +PoolVector Translation::_get_message_list() const { - DVector msgs; + PoolVector msgs; msgs.resize(translation_map.size()); int idx=0; for (const Map::Element *E=translation_map.front();E;E=E->next()) { @@ -829,12 +829,12 @@ DVector Translation::_get_message_list() const { } -void Translation::_set_messages(const DVector& p_messages){ +void Translation::_set_messages(const PoolVector& p_messages){ int msg_count=p_messages.size(); ERR_FAIL_COND(msg_count%2); - DVector::Read r = p_messages.read(); + PoolVector::Read r = p_messages.read(); for(int i=0;ihas(p_from)) { - DVector translations=GlobalConfig::get_singleton()->get(p_from); + PoolVector translations=GlobalConfig::get_singleton()->get(p_from); int tcount=translations.size(); if (tcount) { - DVector::Read r = translations.read(); + PoolVector::Read r = translations.read(); for(int i=0;i translation_map; - DVector _get_message_list() const; + PoolVector _get_message_list() const; - DVector _get_messages() const; - void _set_messages(const DVector& p_messages); + PoolVector _get_messages() const; + void _set_messages(const PoolVector& p_messages); protected: static void _bind_methods(); diff --git a/core/variant.cpp b/core/variant.cpp index 19b0ea71291..f2c614e14f4 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -842,37 +842,37 @@ bool Variant::is_zero() const { // arrays case RAW_ARRAY: { - return reinterpret_cast*>(_data._mem)->size()==0; + return reinterpret_cast*>(_data._mem)->size()==0; } break; case INT_ARRAY: { - return reinterpret_cast*>(_data._mem)->size()==0; + return reinterpret_cast*>(_data._mem)->size()==0; } break; case REAL_ARRAY: { - return reinterpret_cast*>(_data._mem)->size()==0; + return reinterpret_cast*>(_data._mem)->size()==0; } break; case STRING_ARRAY: { - return reinterpret_cast*>(_data._mem)->size()==0; + return reinterpret_cast*>(_data._mem)->size()==0; } break; case VECTOR2_ARRAY: { - return reinterpret_cast*>(_data._mem)->size()==0; + return reinterpret_cast*>(_data._mem)->size()==0; } break; case VECTOR3_ARRAY: { - return reinterpret_cast*>(_data._mem)->size()==0; + return reinterpret_cast*>(_data._mem)->size()==0; } break; case COLOR_ARRAY: { - return reinterpret_cast*>(_data._mem)->size()==0; + return reinterpret_cast*>(_data._mem)->size()==0; } break; default: {} @@ -1070,37 +1070,37 @@ void Variant::reference(const Variant& p_variant) { // arrays case RAW_ARRAY: { - memnew_placement( _data._mem, DVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); + memnew_placement( _data._mem, PoolVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); } break; case INT_ARRAY: { - memnew_placement( _data._mem, DVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); + memnew_placement( _data._mem, PoolVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); } break; case REAL_ARRAY: { - memnew_placement( _data._mem, DVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); + memnew_placement( _data._mem, PoolVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); } break; case STRING_ARRAY: { - memnew_placement( _data._mem, DVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); + memnew_placement( _data._mem, PoolVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); } break; case VECTOR2_ARRAY: { - memnew_placement( _data._mem, DVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); + memnew_placement( _data._mem, PoolVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); } break; case VECTOR3_ARRAY: { - memnew_placement( _data._mem, DVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); + memnew_placement( _data._mem, PoolVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); } break; case COLOR_ARRAY: { - memnew_placement( _data._mem, DVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); + memnew_placement( _data._mem, PoolVector ( *reinterpret_cast*>(p_variant._data._mem) ) ); } break; default: {} @@ -1198,37 +1198,37 @@ void Variant::clear() { // arrays case RAW_ARRAY: { - reinterpret_cast< DVector* >(_data._mem)->~DVector(); + reinterpret_cast< PoolVector* >(_data._mem)->~PoolVector(); } break; case INT_ARRAY: { - reinterpret_cast< DVector* >(_data._mem)->~DVector(); + reinterpret_cast< PoolVector* >(_data._mem)->~PoolVector(); } break; case REAL_ARRAY: { - reinterpret_cast< DVector* >(_data._mem)->~DVector(); + reinterpret_cast< PoolVector* >(_data._mem)->~PoolVector(); } break; case STRING_ARRAY: { - reinterpret_cast< DVector* >(_data._mem)->~DVector(); + reinterpret_cast< PoolVector* >(_data._mem)->~PoolVector(); } break; case VECTOR2_ARRAY: { - reinterpret_cast< DVector* >(_data._mem)->~DVector(); + reinterpret_cast< PoolVector* >(_data._mem)->~PoolVector(); } break; case VECTOR3_ARRAY: { - reinterpret_cast< DVector* >(_data._mem)->~DVector(); + reinterpret_cast< PoolVector* >(_data._mem)->~PoolVector(); } break; case COLOR_ARRAY: { - reinterpret_cast< DVector* >(_data._mem)->~DVector(); + reinterpret_cast< PoolVector* >(_data._mem)->~PoolVector(); } break; default: {} /* not needed */ @@ -1578,7 +1578,7 @@ Variant::operator String() const { } break; case VECTOR2_ARRAY: { - DVector vec = operator DVector(); + PoolVector vec = operator PoolVector(); String str("["); for(int i=0;i vec = operator DVector(); + PoolVector vec = operator PoolVector(); String str("["); for(int i=0;i vec = operator DVector(); + PoolVector vec = operator PoolVector(); String str("["); for(int i=0;i vec = operator DVector(); + PoolVector vec = operator PoolVector(); String str("["); for(int i=0;i vec = operator DVector(); + PoolVector vec = operator PoolVector(); String str("["); for(int i=0;i( p_variant.operator Array () ); } - case Variant::RAW_ARRAY: { return _convert_array >( p_variant.operator DVector () ); } - case Variant::INT_ARRAY: { return _convert_array >( p_variant.operator DVector () ); } - case Variant::REAL_ARRAY: { return _convert_array >( p_variant.operator DVector () ); } - case Variant::STRING_ARRAY: { return _convert_array >( p_variant.operator DVector () ); } - case Variant::VECTOR2_ARRAY: { return _convert_array >( p_variant.operator DVector () ); } - case Variant::VECTOR3_ARRAY: { return _convert_array >( p_variant.operator DVector () ); } - case Variant::COLOR_ARRAY: { return _convert_array >( p_variant.operator DVector() ); } + case Variant::RAW_ARRAY: { return _convert_array >( p_variant.operator PoolVector () ); } + case Variant::INT_ARRAY: { return _convert_array >( p_variant.operator PoolVector () ); } + case Variant::REAL_ARRAY: { return _convert_array >( p_variant.operator PoolVector () ); } + case Variant::STRING_ARRAY: { return _convert_array >( p_variant.operator PoolVector () ); } + case Variant::VECTOR2_ARRAY: { return _convert_array >( p_variant.operator PoolVector () ); } + case Variant::VECTOR3_ARRAY: { return _convert_array >( p_variant.operator PoolVector () ); } + case Variant::COLOR_ARRAY: { return _convert_array >( p_variant.operator PoolVector() ); } default: { return DA(); } } @@ -1914,64 +1914,64 @@ Variant::operator Array() const { return _convert_array_from_variant(*this); } -Variant::operator DVector() const { +Variant::operator PoolVector() const { if (type==RAW_ARRAY) - return *reinterpret_cast* >(_data._mem); + return *reinterpret_cast* >(_data._mem); else - return _convert_array_from_variant >(*this); + return _convert_array_from_variant >(*this); } -Variant::operator DVector() const { +Variant::operator PoolVector() const { if (type==INT_ARRAY) - return *reinterpret_cast* >(_data._mem); + return *reinterpret_cast* >(_data._mem); else - return _convert_array_from_variant >(*this); + return _convert_array_from_variant >(*this); } -Variant::operator DVector() const { +Variant::operator PoolVector() const { if (type==REAL_ARRAY) - return *reinterpret_cast* >(_data._mem); + return *reinterpret_cast* >(_data._mem); else - return _convert_array_from_variant >(*this); + return _convert_array_from_variant >(*this); } -Variant::operator DVector() const { +Variant::operator PoolVector() const { if (type==STRING_ARRAY) - return *reinterpret_cast* >(_data._mem); + return *reinterpret_cast* >(_data._mem); else - return _convert_array_from_variant >(*this); + return _convert_array_from_variant >(*this); } -Variant::operator DVector() const { +Variant::operator PoolVector() const { if (type==VECTOR3_ARRAY) - return *reinterpret_cast* >(_data._mem); + return *reinterpret_cast* >(_data._mem); else - return _convert_array_from_variant >(*this); + return _convert_array_from_variant >(*this); } -Variant::operator DVector() const { +Variant::operator PoolVector() const { if (type==VECTOR2_ARRAY) - return *reinterpret_cast* >(_data._mem); + return *reinterpret_cast* >(_data._mem); else - return _convert_array_from_variant >(*this); + return _convert_array_from_variant >(*this); } -Variant::operator DVector() const { +Variant::operator PoolVector() const { if (type==COLOR_ARRAY) - return *reinterpret_cast* >(_data._mem); + return *reinterpret_cast* >(_data._mem); else - return _convert_array_from_variant >(*this); + return _convert_array_from_variant >(*this); } @@ -1990,13 +1990,13 @@ Variant::operator Vector() const { Variant::operator Vector() const { - DVector from=operator DVector(); + PoolVector from=operator PoolVector(); Vector to; int len=from.size(); if (len==0) return Vector(); to.resize(len); - DVector::Read r = from.read(); + PoolVector::Read r = from.read(); Vector2 *w = &to[0]; for (int i=0;i() const { return to; } -Variant::operator DVector() const { +Variant::operator PoolVector() const { Array va= operator Array(); - DVector planes; + PoolVector planes; int va_size=va.size(); if (va_size==0) return planes; planes.resize(va_size); - DVector::Write w = planes.write(); + PoolVector::Write w = planes.write(); for(int i=0;i() const { return planes; } -Variant::operator DVector() const { +Variant::operator PoolVector() const { - DVector va= operator DVector(); - DVector faces; + PoolVector va= operator PoolVector(); + PoolVector faces; int va_size=va.size(); if (va_size==0) return faces; faces.resize(va_size/3); - DVector::Write w = faces.write(); - DVector::Read r = va.read(); + PoolVector::Write w = faces.write(); + PoolVector::Read r = va.read(); for(int i=0;i() const { Variant::operator Vector() const { - DVector from=operator DVector(); + PoolVector from=operator PoolVector(); Vector to; int len=from.size(); to.resize(len); @@ -2084,7 +2084,7 @@ Variant::operator Vector() const { } Variant::operator Vector() const { - DVector from=operator DVector(); + PoolVector from=operator PoolVector(); Vector to; int len=from.size(); to.resize(len); @@ -2096,7 +2096,7 @@ Variant::operator Vector() const { } Variant::operator Vector() const { - DVector from=operator DVector(); + PoolVector from=operator PoolVector(); Vector to; int len=from.size(); to.resize(len); @@ -2109,7 +2109,7 @@ Variant::operator Vector() const { Variant::operator Vector() const { - DVector from=operator DVector(); + PoolVector from=operator PoolVector(); Vector to; int len=from.size(); to.resize(len); @@ -2122,13 +2122,13 @@ Variant::operator Vector() const { } Variant::operator Vector() const { - DVector from=operator DVector(); + PoolVector from=operator PoolVector(); Vector to; int len=from.size(); if (len==0) return Vector(); to.resize(len); - DVector::Read r = from.read(); + PoolVector::Read r = from.read(); Vector3 *w = &to[0]; for (int i=0;i() const { } Variant::operator Vector() const { - DVector from=operator DVector(); + PoolVector from=operator PoolVector(); Vector to; int len=from.size(); if (len==0) return Vector(); to.resize(len); - DVector::Read r = from.read(); + PoolVector::Read r = from.read(); Color *w = &to[0]; for (int i=0;i addr=operator DVector(); + PoolVector addr=operator PoolVector(); if (addr.size()==4) { 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& p_array) { +Variant::Variant(const PoolVector& p_array) { type=ARRAY; @@ -2467,11 +2467,11 @@ Variant::Variant(const Vector& p_array) { type=NIL; - DVector v; + PoolVector v; int len=p_array.size(); if (len>0) { v.resize(len); - DVector::Write w = v.write(); + PoolVector::Write w = v.write(); const Vector2 *r = p_array.ptr(); for (int i=0;i& p_array) { } -Variant::Variant(const DVector& p_raw_array) { +Variant::Variant(const PoolVector& p_raw_array) { type=RAW_ARRAY; - memnew_placement( _data._mem, DVector(p_raw_array) ); + memnew_placement( _data._mem, PoolVector(p_raw_array) ); } -Variant::Variant(const DVector& p_int_array) { +Variant::Variant(const PoolVector& p_int_array) { type=INT_ARRAY; - memnew_placement( _data._mem, DVector(p_int_array) ); + memnew_placement( _data._mem, PoolVector(p_int_array) ); } -Variant::Variant(const DVector& p_real_array) { +Variant::Variant(const PoolVector& p_real_array) { type=REAL_ARRAY; - memnew_placement( _data._mem, DVector(p_real_array) ); + memnew_placement( _data._mem, PoolVector(p_real_array) ); } -Variant::Variant(const DVector& p_string_array) { +Variant::Variant(const PoolVector& p_string_array) { type=STRING_ARRAY; - memnew_placement( _data._mem, DVector(p_string_array) ); + memnew_placement( _data._mem, PoolVector(p_string_array) ); } -Variant::Variant(const DVector& p_vector3_array) { +Variant::Variant(const PoolVector& p_vector3_array) { type=VECTOR3_ARRAY; - memnew_placement( _data._mem, DVector(p_vector3_array) ); + memnew_placement( _data._mem, PoolVector(p_vector3_array) ); } -Variant::Variant(const DVector& p_vector2_array) { +Variant::Variant(const PoolVector& p_vector2_array) { type=VECTOR2_ARRAY; - memnew_placement( _data._mem, DVector(p_vector2_array) ); + memnew_placement( _data._mem, PoolVector(p_vector2_array) ); } -Variant::Variant(const DVector& p_color_array) { +Variant::Variant(const PoolVector& p_color_array) { type=COLOR_ARRAY; - memnew_placement( _data._mem, DVector(p_color_array) ); + memnew_placement( _data._mem, PoolVector(p_color_array) ); } -Variant::Variant(const DVector& p_face_array) { +Variant::Variant(const PoolVector& p_face_array) { - DVector vertices; + PoolVector vertices; int face_count=p_face_array.size(); vertices.resize(face_count*3); if (face_count) { - DVector::Read r = p_face_array.read(); - DVector::Write w = vertices.write(); + PoolVector::Read r = p_face_array.read(); + PoolVector::Write w = vertices.write(); for(int i=0;i& p_face_array) { w[i*3+j]=r[i].vertex[j]; } - r=DVector::Read(); - w=DVector::Write(); + r=PoolVector::Read(); + w=PoolVector::Write(); } @@ -2567,7 +2567,7 @@ Variant::Variant(const Vector& p_array) { Variant::Variant(const Vector& p_array) { type=NIL; - DVector v; + PoolVector v; int len=p_array.size(); v.resize(len); for (int i=0;i& p_array) { Variant::Variant(const Vector& p_array) { type=NIL; - DVector v; + PoolVector v; int len=p_array.size(); v.resize(len); for (int i=0;i& p_array) { Variant::Variant(const Vector& p_array) { type=NIL; - DVector v; + PoolVector v; int len=p_array.size(); v.resize(len); for (int i=0;i& p_array) { Variant::Variant(const Vector& p_array) { type=NIL; - DVector v; + PoolVector v; int len=p_array.size(); v.resize(len); for (int i=0;i& p_array) { Variant::Variant(const Vector& p_array) { type=NIL; - DVector v; + PoolVector v; int len=p_array.size(); if (len>0) { v.resize(len); - DVector::Write w = v.write(); + PoolVector::Write w = v.write(); const Vector3 *r = p_array.ptr(); for (int i=0;i& p_array) { Variant::Variant(const Vector& p_array) { type=NIL; - DVector v; + PoolVector v; int len=p_array.size(); v.resize(len); for (int i=0;i& arr = *reinterpret_cast* >(_data._mem); + const PoolVector& arr = *reinterpret_cast* >(_data._mem); int len = arr.size(); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); return hash_djb2_buffer((uint8_t*)&r[0],len); } break; case INT_ARRAY: { - const DVector& arr = *reinterpret_cast* >(_data._mem); + const PoolVector& arr = *reinterpret_cast* >(_data._mem); int len = arr.size(); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); return hash_djb2_buffer((uint8_t*)&r[0],len*sizeof(int)); } break; case REAL_ARRAY: { - const DVector& arr = *reinterpret_cast* >(_data._mem); + const PoolVector& arr = *reinterpret_cast* >(_data._mem); int len = arr.size(); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); return hash_djb2_buffer((uint8_t*)&r[0],len*sizeof(real_t)); @@ -2854,9 +2854,9 @@ uint32_t Variant::hash() const { case STRING_ARRAY: { uint32_t hash=5831; - const DVector& arr = *reinterpret_cast* >(_data._mem); + const PoolVector& arr = *reinterpret_cast* >(_data._mem); int len = arr.size(); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); for(int i=0;i& arr = *reinterpret_cast* >(_data._mem); + const PoolVector& arr = *reinterpret_cast* >(_data._mem); int len = arr.size(); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); for(int i=0;i& arr = *reinterpret_cast* >(_data._mem); + const PoolVector& arr = *reinterpret_cast* >(_data._mem); int len = arr.size(); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); for(int i=0;i& arr = *reinterpret_cast* >(_data._mem); + const PoolVector& arr = *reinterpret_cast* >(_data._mem); int len = arr.size(); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); for(int i=0;i ByteArray; -typedef DVector IntArray; -typedef DVector RealArray; -typedef DVector StringArray; -typedef DVector Vector2Array; -typedef DVector Vector3Array; -typedef DVector ColorArray; +typedef PoolVector ByteArray; +typedef PoolVector IntArray; +typedef PoolVector RealArray; +typedef PoolVector StringArray; +typedef PoolVector Vector2Array; +typedef PoolVector Vector3Array; +typedef PoolVector ColorArray; class Variant { public: @@ -227,14 +227,14 @@ public: operator Dictionary() const; operator Array() const; - operator DVector() const; - operator DVector() const; - operator DVector() const; - operator DVector() const; - operator DVector() const; - operator DVector() const; - operator DVector() const; - operator DVector() const; + operator PoolVector() const; + operator PoolVector() const; + operator PoolVector() const; + operator PoolVector() const; + operator PoolVector() const; + operator PoolVector() const; + operator PoolVector() const; + operator PoolVector() const; operator Vector() const; @@ -246,7 +246,7 @@ public: operator Vector() const; operator Vector() const; operator Vector() const; - operator DVector() const; + operator PoolVector() const; operator Vector() const; // some core type enums to convert to @@ -295,14 +295,14 @@ public: Variant(const Dictionary& p_dictionary); Variant(const Array& p_array); - Variant(const DVector& p_array); // helper - Variant(const DVector& p_raw_array); - Variant(const DVector& p_int_array); - Variant(const DVector& p_real_array); - Variant(const DVector& p_string_array); - Variant(const DVector& p_vector3_array); - Variant(const DVector& p_color_array); - Variant(const DVector& p_face_array); + Variant(const PoolVector& p_array); // helper + Variant(const PoolVector& p_raw_array); + Variant(const PoolVector& p_int_array); + Variant(const PoolVector& p_real_array); + Variant(const PoolVector& p_string_array); + Variant(const PoolVector& p_vector3_array); + Variant(const PoolVector& p_color_array); + Variant(const PoolVector& p_face_array); Variant(const Vector& p_array); @@ -315,7 +315,7 @@ public: Variant(const Vector& p_array); // helper Variant(const Vector& p_array); // helper Variant(const Vector& p_array); // helper - Variant(const DVector& p_array); // helper + Variant(const PoolVector& p_array); // helper Variant(const IP_Address& p_address); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index cedf21b3770..a9adc744b6c 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -305,7 +305,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var retval.resize(len); ByteArray::Write w = retval.write(); copymem(w.ptr(), charstr.ptr(), len); - w = DVector::Write(); + w = PoolVector::Write(); 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); ByteArray::Write w = retval.write(); copymem(w.ptr(), charstr.ptr(), len); - w = DVector::Write(); + w = PoolVector::Write(); r_ret = retval; } diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 94a2ea99773..a8495a4913d 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -186,16 +186,16 @@ case m_name: { \ r_valid=false;\ return;\ }\ - const DVector &array_a=*reinterpret_cast *>(p_a._data._mem);\ - const DVector &array_b=*reinterpret_cast *>(p_b._data._mem);\ + const PoolVector &array_a=*reinterpret_cast *>(p_a._data._mem);\ + const PoolVector &array_b=*reinterpret_cast *>(p_b._data._mem);\ \ int a_len = array_a.size();\ if (a_len m_opa array_b.size()){\ _RETURN( m_ret_s);\ }else {\ \ - DVector::Read ra = array_a.read();\ - DVector::Read rb = array_b.read();\ + PoolVector::Read ra = array_a.read();\ + PoolVector::Read rb = array_b.read();\ \ for(int i=0;i &array_a=*reinterpret_cast *>(p_a._data._mem);\ - const DVector &array_b=*reinterpret_cast *>(p_b._data._mem);\ - DVector sum = array_a;\ + const PoolVector &array_a=*reinterpret_cast *>(p_a._data._mem);\ + const PoolVector &array_b=*reinterpret_cast *>(p_b._data._mem);\ + PoolVector sum = array_a;\ sum.append_array(array_b);\ _RETURN( sum );\ } @@ -1049,10 +1049,10 @@ Variant Variant::get_named(const StringName& p_index, bool *r_valid) const { } break; #define DEFAULT_OP_DVECTOR_SET(m_name, dv_type, skip_cond)\ - DEFAULT_OP_ARRAY_CMD(m_name, DVector, if(skip_cond) return;, arr->set(index, p_value);return) + DEFAULT_OP_ARRAY_CMD(m_name, PoolVector, if(skip_cond) return;, arr->set(index, p_value);return) #define DEFAULT_OP_DVECTOR_GET(m_name, dv_type)\ - DEFAULT_OP_ARRAY_CMD(m_name, const DVector, ;, return arr->get(index)) + DEFAULT_OP_ARRAY_CMD(m_name, const PoolVector, ;, return arr->get(index)) 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) { int index = p_index; - const DVector *arr=reinterpret_cast* >(_data._mem); + const PoolVector *arr=reinterpret_cast* >(_data._mem); int l=arr->size(); if (l) { - DVector::Read r = arr->read(); + PoolVector::Read r = arr->read(); for(int i=0;i *arr=reinterpret_cast* >(_data._mem); + const PoolVector *arr=reinterpret_cast* >(_data._mem); int l=arr->size(); if (l) { - DVector::Read r = arr->read(); + PoolVector::Read r = arr->read(); for(int i=0;i *arr=reinterpret_cast* >(_data._mem); + const PoolVector *arr=reinterpret_cast* >(_data._mem); int l=arr->size(); if (l) { - DVector::Read r = arr->read(); + PoolVector::Read r = arr->read(); for(int i=0;i *arr=reinterpret_cast* >(_data._mem); + const PoolVector *arr=reinterpret_cast* >(_data._mem); int l=arr->size(); if (l) { - DVector::Read r = arr->read(); + PoolVector::Read r = arr->read(); for(int i=0;i *arr=reinterpret_cast* >(_data._mem); + const PoolVector *arr=reinterpret_cast* >(_data._mem); int l=arr->size(); if (l) { - DVector::Read r = arr->read(); + PoolVector::Read r = arr->read(); for(int i=0;i *arr=reinterpret_cast* >(_data._mem); + const PoolVector *arr=reinterpret_cast* >(_data._mem); int l=arr->size(); if (l) { - DVector::Read r = arr->read(); + PoolVector::Read r = arr->read(); for(int i=0;i *arr=reinterpret_cast* >(_data._mem); + const PoolVector *arr=reinterpret_cast* >(_data._mem); int l=arr->size(); if (l) { - DVector::Read r = arr->read(); + PoolVector::Read r = arr->read(); for(int i=0;i *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); if (arr->size()==0) return false; r_iter=0; @@ -3000,7 +3000,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const { } break; case INT_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); if (arr->size()==0) return false; r_iter=0; @@ -3008,7 +3008,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const { } break; case REAL_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); if (arr->size()==0) return false; r_iter=0; @@ -3016,7 +3016,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const { } break; case STRING_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); if (arr->size()==0) return false; r_iter=0; @@ -3024,7 +3024,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const { } break; case VECTOR2_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); if (arr->size()==0) return false; r_iter=0; @@ -3032,7 +3032,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const { } break; case VECTOR3_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); if (arr->size()==0) return false; r_iter=0; @@ -3040,7 +3040,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const { } break; case COLOR_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); if (arr->size()==0) return false; r_iter=0; @@ -3123,7 +3123,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const { return true; } break; case RAW_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; idx++; if (idx>=arr->size()) @@ -3133,7 +3133,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const { } break; case INT_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; idx++; if (idx>=arr->size()) @@ -3143,7 +3143,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const { } break; case REAL_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; idx++; if (idx>=arr->size()) @@ -3153,7 +3153,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const { } break; case STRING_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; idx++; if (idx>=arr->size()) @@ -3163,7 +3163,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const { } break; case VECTOR2_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; idx++; if (idx>=arr->size()) @@ -3173,7 +3173,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const { } break; case VECTOR3_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; idx++; if (idx>=arr->size()) @@ -3183,7 +3183,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const { } break; case COLOR_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; idx++; if (idx>=arr->size()) @@ -3255,7 +3255,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const { return arr->get(idx); } break; case RAW_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; #ifdef DEBUG_ENABLED 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); } break; case INT_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; #ifdef DEBUG_ENABLED 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); } break; case REAL_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; #ifdef DEBUG_ENABLED 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); } break; case STRING_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; #ifdef DEBUG_ENABLED if (idx<0 || idx>=arr->size()) { @@ -3300,7 +3300,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const { } break; case VECTOR2_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; #ifdef DEBUG_ENABLED if (idx<0 || idx>=arr->size()) { @@ -3312,7 +3312,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const { } break; case VECTOR3_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; #ifdef DEBUG_ENABLED if (idx<0 || idx>=arr->size()) { @@ -3324,7 +3324,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const { } break; case COLOR_ARRAY: { - const DVector *arr=reinterpret_cast*>(_data._mem); + const PoolVector *arr=reinterpret_cast*>(_data._mem); int idx=r_iter; #ifdef DEBUG_ENABLED 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 STRING_ARRAY:{ r_dst=a; } return; case VECTOR2_ARRAY:{ - const DVector *arr_a=reinterpret_cast* >(a._data._mem); - const DVector *arr_b=reinterpret_cast* >(b._data._mem); + const PoolVector *arr_a=reinterpret_cast* >(a._data._mem); + const PoolVector *arr_b=reinterpret_cast* >(b._data._mem); int sz = arr_a->size(); if (sz==0 || arr_b->size()!=sz) { r_dst=a; } else { - DVector v; + PoolVector v; v.resize(sz); { - DVector::Write vw=v.write(); - DVector::Read ar=arr_a->read(); - DVector::Read br=arr_b->read(); + PoolVector::Write vw=v.write(); + PoolVector::Read ar=arr_a->read(); + PoolVector::Read br=arr_b->read(); for(int i=0;i *arr_a=reinterpret_cast* >(a._data._mem); - const DVector *arr_b=reinterpret_cast* >(b._data._mem); + const PoolVector *arr_a=reinterpret_cast* >(a._data._mem); + const PoolVector *arr_b=reinterpret_cast* >(b._data._mem); int sz = arr_a->size(); if (sz==0 || arr_b->size()!=sz) { r_dst=a; } else { - DVector v; + PoolVector v; v.resize(sz); { - DVector::Write vw=v.write(); - DVector::Read ar=arr_a->read(); - DVector::Read br=arr_b->read(); + PoolVector::Write vw=v.write(); + PoolVector::Read ar=arr_a->read(); + PoolVector::Read br=arr_b->read(); for(int i=0;i buffer; + PoolVector buffer; buffer.resize(len); if (buffer.size()!=len) { @@ -810,7 +810,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in } { - DVector::Write w=buffer.write(); + PoolVector::Write w=buffer.write(); for(int i=0;i arr; + PoolVector arr; { int len=args.size(); arr.resize(len); - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int i=0;i arr; + PoolVector arr; { int len=args.size(); arr.resize(len); - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int i=0;i arr; + PoolVector arr; { int len=args.size(); arr.resize(len); - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int i=0;i arr; + PoolVector arr; { int len=cs.size(); arr.resize(len); - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int i=0;i arr; + PoolVector arr; { int len=args.size()/2; arr.resize(len); - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int i=0;i arr; + PoolVector arr; { int len=args.size()/3; arr.resize(len); - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int i=0;i arr; + PoolVector arr; { int len=args.size()/4; arr.resize(len); - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int i=0;i data = img.get_data(); + PoolVector data = img.get_data(); int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const uint8_t *ptr=r.ptr();; for (int i=0;i data = p_variant; + PoolVector data = p_variant; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const uint8_t *ptr=r.ptr();; for (int i=0;i data = p_variant; + PoolVector data = p_variant; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const int *ptr=r.ptr();; for (int i=0;i data = p_variant; + PoolVector data = p_variant; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const real_t *ptr=r.ptr();; for (int i=0;i data = p_variant; + PoolVector data = p_variant; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const String *ptr=r.ptr();; String s; //write_string("\n"); @@ -2208,9 +2208,9 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str case Variant::VECTOR2_ARRAY: { p_store_string_func(p_store_string_ud,"Vector2Array( "); - DVector data = p_variant; + PoolVector data = p_variant; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const Vector2 *ptr=r.ptr();; for (int i=0;i data = p_variant; + PoolVector data = p_variant; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const Vector3 *ptr=r.ptr();; for (int i=0;i data = p_variant; + PoolVector data = p_variant; int len = data.size(); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); const Color *ptr=r.ptr();; for (int i=0;itarget == GL_TEXTURE_CUBE_MAP)?_cube_side_enum[p_cube_side]:GL_TEXTURE_2D; texture->data_size=img.get_data().size(); - DVector::Read read = img.get_data().read(); + PoolVector::Read read = img.get_data().read(); glActiveTexture(GL_TEXTURE0); 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->data_size==0,Image()); - DVector data; + PoolVector data; GLenum format,type=GL_UNSIGNED_BYTE; Image::Format fmt; 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); - DVector::Write wb = data.write(); + PoolVector::Write wb = data.write(); glActiveTexture(GL_TEXTURE0); int ofs=0; @@ -1264,7 +1264,7 @@ Image RasterizerGLES2::texture_get_data(RID p_texture,VS::CubeMapSide p_cube_sid } - wb=DVector::Write(); + wb=PoolVector::Write(); 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 *index_array_ptr=NULL; - DVector array_pre_vbo; - DVector::Write vaw; - DVector index_array_pre_vbo; - DVector::Write iaw; + PoolVector array_pre_vbo; + PoolVector::Write vaw; + PoolVector index_array_pre_vbo; + PoolVector::Write iaw; /* create pointers */ 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 ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_surface->array_len, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const Vector3* src=read.ptr(); // 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 ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_surface->array_len, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const Vector3* src=read.ptr(); // 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 ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_surface->array_len*4, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const real_t* src = read.ptr(); 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 ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_surface->array_len, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const Color* src = read.ptr(); 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 ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_surface->array_len , ERR_INVALID_PARAMETER); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const Vector2 * src=read.ptr(); 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 ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_surface->array_len*VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); 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 ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_surface->array_len*VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); 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_arrays[ai].get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER ); - DVector indices = p_arrays[ai]; + PoolVector indices = p_arrays[ai]; ERR_FAIL_COND_V( indices.size() == 0, 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 */ - DVector::Read read = indices.read(); + PoolVector::Read read = indices.read(); const int *src=read.ptr(); for (int i=0;iindex_array_len;i++) { @@ -2553,18 +2553,18 @@ Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem,ui for(int i=0;iskeleton_bone_used[i]=false; } - DVector vertices = p_arrays[VS::ARRAY_VERTEX]; - DVector bones = p_arrays[VS::ARRAY_BONES]; - DVector weights = p_arrays[VS::ARRAY_WEIGHTS]; + PoolVector vertices = p_arrays[VS::ARRAY_VERTEX]; + PoolVector bones = p_arrays[VS::ARRAY_BONES]; + PoolVector weights = p_arrays[VS::ARRAY_WEIGHTS]; bool any_valid=false; if (vertices.size() && bones.size()==vertices.size()*4 && weights.size()==bones.size()) { //print_line("MAKING SKELETHONG"); int vs = vertices.size(); - DVector::Read rv =vertices.read(); - DVector::Read rb=bones.read(); - DVector::Read rw=weights.read(); + PoolVector::Read rv =vertices.read(); + PoolVector::Read rb=bones.read(); + PoolVector::Read rw=weights.read(); Vector first; 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& p_points) { +void RasterizerGLES2::particles_set_emission_points(RID p_particles, const PoolVector& p_points) { Particles* particles = particles_owner.get( p_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; } -DVector RasterizerGLES2::particles_get_emission_points(RID p_particles) const { +PoolVector RasterizerGLES2::particles_get_emission_points(RID p_particles) const { Particles* particles = particles_owner.get( p_particles ); - ERR_FAIL_COND_V(!particles,DVector()); + ERR_FAIL_COND_V(!particles,PoolVector()); return particles->data.emission_points; @@ -4304,9 +4304,9 @@ void RasterizerGLES2::begin_frame() { void RasterizerGLES2::capture_viewport(Image* r_capture) { #if 0 - DVector pixels; + PoolVector pixels; pixels.resize(viewport.width*viewport.height*3); - DVector::Write w = pixels.write(); + PoolVector::Write w = pixels.write(); #ifdef GLEW_ENABLED glReadBuffer(GL_COLOR_ATTACHMENT0); #endif @@ -4318,15 +4318,15 @@ void RasterizerGLES2::capture_viewport(Image* r_capture) { glPixelStorei(GL_PACK_ALIGNMENT, 4); - w=DVector::Write(); + w=PoolVector::Write(); r_capture->create(viewport.width,viewport.height,0,Image::FORMAT_RGB8,pixels); #else - DVector pixels; + PoolVector pixels; pixels.resize(viewport.width*viewport.height*4); - DVector::Write w = pixels.write(); + PoolVector::Write w = pixels.write(); glPixelStorei(GL_PACK_ALIGNMENT, 4); // uint64_t time = OS::get_singleton()->get_ticks_usec(); @@ -4359,7 +4359,7 @@ void RasterizerGLES2::capture_viewport(Image* r_capture) { } } - w=DVector::Write(); + w=PoolVector::Write(); r_capture->create(viewport.width,viewport.height,0,Image::FORMAT_RGBA8,pixels); //r_capture->flip_y(); @@ -8685,7 +8685,7 @@ RID RasterizerGLES2::canvas_light_occluder_create() { return canvas_occluder_owner.make_rid(co); } -void RasterizerGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const DVector& p_lines) { +void RasterizerGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector& p_lines) { CanvasOccluder *co = canvas_occluder_owner.get(p_occluder); ERR_FAIL_COND(!co); @@ -8709,18 +8709,18 @@ void RasterizerGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const - DVector geometry; - DVector indices; + PoolVector geometry; + PoolVector indices; int lc = p_lines.size(); geometry.resize(lc*6); indices.resize(lc*3); - DVector::Write vw=geometry.write(); - DVector::Write iw=indices.write(); + PoolVector::Write vw=geometry.write(); + PoolVector::Write iw=indices.write(); - DVector::Read lr=p_lines.read(); + PoolVector::Read lr=p_lines.read(); const int POLY_HEIGHT = 16384; diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 5f82e1691bc..b5904e09d02 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -4596,10 +4596,10 @@ void RasterizerSceneGLES3::_generate_brdf() { - DVector brdf; + PoolVector brdf; brdf.resize(brdf_size*brdf_size*2); - DVector::Write w = brdf.write(); + PoolVector::Write w = brdf.write(); for(int i=0;itarget == GL_TEXTURE_CUBE_MAP)?_cube_side_enum[p_cube_side]:GL_TEXTURE_2D; texture->data_size=img.get_data().size(); - DVector::Read read = img.get_data().read(); + PoolVector::Read read = img.get_data().read(); glActiveTexture(GL_TEXTURE0); 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 - DVector data; + PoolVector data; 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 - DVector::Write wb = data.write(); + PoolVector::Write wb = data.write(); glActiveTexture(GL_TEXTURE0); @@ -868,7 +868,7 @@ Image RasterizerStorageGLES3::texture_get_data(RID p_texture,VS::CubeMapSide p_c } - wb=DVector::Write(); + wb=PoolVector::Write(); data.resize(data_size); @@ -1848,11 +1848,11 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } break; case ShaderLanguage::TYPE_IVEC2: { - DVector iv = value; + PoolVector iv = value; int s = iv.size(); GLint *gui = (GLint*)data; - DVector::Read r = iv.read(); + PoolVector::Read r = iv.read(); for(int i=0;i<2;i++) { if (i iv = value; + PoolVector iv = value; int s = iv.size(); GLint *gui = (GLint*)data; - DVector::Read r = iv.read(); + PoolVector::Read r = iv.read(); for(int i=0;i<3;i++) { if (i iv = value; + PoolVector iv = value; int s = iv.size(); GLint *gui = (GLint*)data; - DVector::Read r = iv.read(); + PoolVector::Read r = iv.read(); for(int i=0;i<4;i++) { if (i iv = value; + PoolVector iv = value; int s = iv.size(); GLuint *gui = (GLuint*)data; - DVector::Read r = iv.read(); + PoolVector::Read r = iv.read(); for(int i=0;i<2;i++) { if (i iv = value; + PoolVector iv = value; int s = iv.size(); GLuint *gui = (GLuint*)data; - DVector::Read r = iv.read(); + PoolVector::Read r = iv.read(); for(int i=0;i<3;i++) { if (i iv = value; + PoolVector iv = value; int s = iv.size(); GLuint *gui = (GLuint*)data; - DVector::Read r = iv.read(); + PoolVector::Read r = iv.read(); for(int i=0;i<4;i++) { if (i& p_array,int p_vertex_count,const DVector& p_index_array,int p_index_count,const AABB& p_aabb,const Vector >& p_blend_shapes,const Vector& p_bone_aabbs){ +void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const PoolVector& p_array,int p_vertex_count,const PoolVector& p_index_array,int p_index_count,const AABB& p_aabb,const Vector >& p_blend_shapes,const Vector& p_bone_aabbs){ - DVector array = p_array; + PoolVector array = p_array; Mesh *mesh = mesh_owner.getornull(p_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())); if (array.size()!=array_size && array.size()+p_vertex_count*2 == array_size) { //old format, convert - array = DVector(); + array = PoolVector(); array.resize( p_array.size()+p_vertex_count*2 ); - DVector::Write w = array.write(); - DVector::Read r = p_array.read(); + PoolVector::Write w = array.write(); + PoolVector::Read r = p_array.read(); uint16_t *w16 = (uint16_t*)w.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::Read vr = array.read(); + PoolVector::Read vr = array.read(); glGenBuffers(1,&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) { - DVector::Read ir = p_index_array.read(); + PoolVector::Read ir = p_index_array.read(); glGenBuffers(1,&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; - DVector::Read vr = p_blend_shapes[i].read(); + PoolVector::Read vr = p_blend_shapes[i].read(); glGenBuffers(1,&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; } -DVector RasterizerStorageGLES3::mesh_surface_get_array(RID p_mesh, int p_surface) const{ +PoolVector RasterizerStorageGLES3::mesh_surface_get_array(RID p_mesh, int p_surface) const{ const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh,DVector()); - ERR_FAIL_INDEX_V(p_surface,mesh->surfaces.size(),DVector()); + ERR_FAIL_COND_V(!mesh,PoolVector()); + ERR_FAIL_INDEX_V(p_surface,mesh->surfaces.size(),PoolVector()); Surface *surface = mesh->surfaces[p_surface]; glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id); void * data = glMapBufferRange(GL_ARRAY_BUFFER,0,surface->array_byte_size,GL_MAP_READ_BIT); - ERR_FAIL_COND_V(!data,DVector()); + ERR_FAIL_COND_V(!data,PoolVector()); - DVector ret; + PoolVector ret; ret.resize(surface->array_byte_size); { - DVector::Write w = ret.write(); + PoolVector::Write w = ret.write(); copymem(w.ptr(),data,surface->array_byte_size); } glUnmapBuffer(GL_ARRAY_BUFFER); @@ -2960,26 +2960,26 @@ DVector RasterizerStorageGLES3::mesh_surface_get_array(RID p_mesh, int return ret; } -DVector RasterizerStorageGLES3::mesh_surface_get_index_array(RID p_mesh, int p_surface) const { +PoolVector RasterizerStorageGLES3::mesh_surface_get_index_array(RID p_mesh, int p_surface) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh,DVector()); - ERR_FAIL_INDEX_V(p_surface,mesh->surfaces.size(),DVector()); + ERR_FAIL_COND_V(!mesh,PoolVector()); + ERR_FAIL_INDEX_V(p_surface,mesh->surfaces.size(),PoolVector()); Surface *surface = mesh->surfaces[p_surface]; - ERR_FAIL_COND_V(surface->index_array_len==0,DVector()); + ERR_FAIL_COND_V(surface->index_array_len==0,PoolVector()); 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); - ERR_FAIL_COND_V(!data,DVector()); + ERR_FAIL_COND_V(!data,PoolVector()); - DVector ret; + PoolVector ret; ret.resize(surface->index_array_byte_size); { - DVector::Write w = ret.write(); + PoolVector::Write w = ret.write(); 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 > RasterizerStorageGLES3::mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const{ +Vector > RasterizerStorageGLES3::mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const{ const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh,Vector >()); - ERR_FAIL_INDEX_V(p_surface,mesh->surfaces.size(),Vector >()); + ERR_FAIL_COND_V(!mesh,Vector >()); + ERR_FAIL_INDEX_V(p_surface,mesh->surfaces.size(),Vector >()); - Vector > bsarr; + Vector > bsarr; for(int i=0;isurfaces[p_surface]->morph_targets.size();i++) { 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); - ERR_FAIL_COND_V(!data,Vector >()); + ERR_FAIL_COND_V(!data,Vector >()); - DVector ret; + PoolVector ret; ret.resize(mesh->surfaces[p_surface]->array_byte_size); { - DVector::Write w = ret.write(); + PoolVector::Write w = ret.write(); copymem(w.ptr(),data,mesh->surfaces[p_surface]->array_byte_size); } @@ -4705,7 +4705,7 @@ RID RasterizerStorageGLES3::room_create(){ return RID(); } -void RasterizerStorageGLES3::room_add_bounds(RID p_room, const DVector& p_convex_polygon,float p_height,const Transform& p_transform){ +void RasterizerStorageGLES3::room_add_bounds(RID p_room, const PoolVector& 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& p_data){ +void RasterizerStorageGLES3::gi_probe_set_dynamic_data(RID p_probe,const PoolVector& p_data){ GIProbe *gip = gi_probe_owner.getornull(p_probe); ERR_FAIL_COND(!gip); @@ -4819,10 +4819,10 @@ void RasterizerStorageGLES3::gi_probe_set_dynamic_data(RID p_probe,const DVector gip->instance_change_notify(); } -DVector RasterizerStorageGLES3::gi_probe_get_dynamic_data(RID p_probe) const{ +PoolVector RasterizerStorageGLES3::gi_probe_get_dynamic_data(RID p_probe) const{ const GIProbe *gip = gi_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gip,DVector()); + ERR_FAIL_COND_V(!gip,PoolVector()); return gip->dynamic_data; } @@ -5125,7 +5125,7 @@ void RasterizerStorageGLES3::particles_set_emission_box_extents(RID p_particles, particles->emission_box_extents=p_extents; } -void RasterizerStorageGLES3::particles_set_emission_points(RID p_particles,const DVector& p_points) { +void RasterizerStorageGLES3::particles_set_emission_points(RID p_particles,const PoolVector& p_points) { Particles *particles = particles_owner.getornull(p_particles); ERR_FAIL_COND(!particles); @@ -5961,7 +5961,7 @@ RID RasterizerStorageGLES3::canvas_light_occluder_create() { return canvas_occluder_owner.make_rid(co); } -void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, const DVector& p_lines) { +void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector& p_lines) { CanvasOccluder *co = canvas_occluder_owner.get(p_occluder); ERR_FAIL_COND(!co); @@ -5985,18 +5985,18 @@ void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, - DVector geometry; - DVector indices; + PoolVector geometry; + PoolVector indices; int lc = p_lines.size(); geometry.resize(lc*6); indices.resize(lc*3); - DVector::Write vw=geometry.write(); - DVector::Write iw=indices.write(); + PoolVector::Write vw=geometry.write(); + PoolVector::Write iw=indices.write(); - DVector::Read lr=p_lines.read(); + PoolVector::Read lr=p_lines.read(); const int POLY_HEIGHT = 16384; diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 357b69183e5..32581e860d2 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -599,7 +599,7 @@ public: virtual RID mesh_create(); - virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const DVector& p_array,int p_vertex_count,const DVector& p_index_array,int p_index_count,const AABB& p_aabb,const Vector >& p_blend_shapes=Vector >(),const Vector& p_bone_aabbs=Vector()); + virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const PoolVector& p_array,int p_vertex_count,const PoolVector& p_index_array,int p_index_count,const AABB& p_aabb,const Vector >& p_blend_shapes=Vector >(),const Vector& p_bone_aabbs=Vector()); virtual void mesh_set_morph_target_count(RID p_mesh,int p_amount); 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_index_len(RID p_mesh, int p_surface) const; - virtual DVector mesh_surface_get_array(RID p_mesh, int p_surface) const; - virtual DVector mesh_surface_get_index_array(RID p_mesh, int p_surface) const; + virtual PoolVector mesh_surface_get_array(RID p_mesh, int p_surface) const; + virtual PoolVector mesh_surface_get_index_array(RID p_mesh, int p_surface) const; virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const; virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const; virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const; - virtual Vector > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const; + virtual Vector > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const; virtual Vector mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const; virtual void mesh_remove_surface(RID p_mesh, int p_surface); @@ -877,7 +877,7 @@ public: /* ROOM API */ virtual RID room_create(); - virtual void room_add_bounds(RID p_room, const DVector& p_convex_polygon,float p_height,const Transform& p_transform); + virtual void room_add_bounds(RID p_room, const PoolVector& p_convex_polygon,float p_height,const Transform& p_transform); virtual void room_clear_bounds(RID p_room); /* PORTAL API */ @@ -913,7 +913,7 @@ public: uint32_t version; - DVector dynamic_data; + PoolVector dynamic_data; }; @@ -931,8 +931,8 @@ public: virtual void gi_probe_set_to_cell_xform(RID p_probe,const Transform& p_xform); virtual Transform gi_probe_get_to_cell_xform(RID p_probe) const; - virtual void gi_probe_set_dynamic_data(RID p_probe,const DVector& p_data); - virtual DVector gi_probe_get_dynamic_data(RID p_probe) const; + virtual void gi_probe_set_dynamic_data(RID p_probe,const PoolVector& p_data); + virtual PoolVector gi_probe_get_dynamic_data(RID p_probe) const; virtual void gi_probe_set_dynamic_range(RID p_probe,int p_range); virtual int gi_probe_get_dynamic_range(RID p_probe) const; @@ -985,7 +985,7 @@ public: VS::ParticlesEmissionShape emission_shape; float emission_sphere_radius; Vector3 emission_box_extents; - DVector emission_points; + PoolVector emission_points; GLuint emission_point_texture; 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_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_points(RID p_particles,const DVector& p_points); + virtual void particles_set_emission_points(RID p_particles,const PoolVector& p_points); 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 index_id; // 0 means, unconfigured - DVector lines; + PoolVector lines; int len; }; RID_Owner canvas_occluder_owner; virtual RID canvas_light_occluder_create(); - virtual void canvas_light_occluder_set_polylines(RID p_occluder, const DVector& p_lines); + virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector& p_lines); virtual VS::InstanceType get_base_type(RID p_rid) const; diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp index d74a12ba93c..de095c20ac9 100644 --- a/drivers/png/image_loader_png.cpp +++ b/drivers/png/image_loader_png.cpp @@ -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 = components * width; - DVector dstbuff; + PoolVector dstbuff; dstbuff.resize( rowsize * height ); - DVector::Write dstbuff_write = dstbuff.write(); + PoolVector::Write dstbuff_write = dstbuff.write(); 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& p_data) { +static Image _lossless_unpack_png(const PoolVector& p_data) { int len = p_data.size(); - DVector::Read r = p_data.read(); + PoolVector::Read r = p_data.read(); ERR_FAIL_COND_V(r[0]!='P' || r[1]!='N' || r[2]!='G' || r[3]!=' ',Image()); return _load_mem_png(&r[4],len-4); @@ -276,17 +276,17 @@ static Image _lossless_unpack_png(const DVector& p_data) { static void _write_png_data(png_structp png_ptr,png_bytep data, png_size_t p_length) { - DVector &v = *(DVector*)png_get_io_ptr(png_ptr); + PoolVector &v = *(PoolVector*)png_get_io_ptr(png_ptr); int vs = v.size(); v.resize(vs+p_length); - DVector::Write w = v.write(); + PoolVector::Write w = v.write(); copymem(&w[vs],data,p_length); //print_line("png write: "+itos(p_length)); } -static DVector _lossless_pack_png(const Image& p_image) { +static PoolVector _lossless_pack_png(const Image& p_image) { Image img = p_image; @@ -294,7 +294,7 @@ static DVector _lossless_pack_png(const Image& p_image) { img.decompress(); - ERR_FAIL_COND_V(img.is_compressed(), DVector()); + ERR_FAIL_COND_V(img.is_compressed(), PoolVector()); png_structp png_ptr; png_infop info_ptr; @@ -304,16 +304,16 @@ static DVector _lossless_pack_png(const Image& p_image) { /* initialize stuff */ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - ERR_FAIL_COND_V(!png_ptr,DVector()); + ERR_FAIL_COND_V(!png_ptr,PoolVector()); info_ptr = png_create_info_struct(png_ptr); - ERR_FAIL_COND_V(!info_ptr,DVector()); + ERR_FAIL_COND_V(!info_ptr,PoolVector()); if (setjmp(png_jmpbuf(png_ptr))) { - ERR_FAIL_V(DVector()); + ERR_FAIL_V(PoolVector()); } - DVector ret; + PoolVector ret; ret.push_back('P'); ret.push_back('N'); ret.push_back('G'); @@ -323,7 +323,7 @@ static DVector _lossless_pack_png(const Image& p_image) { /* write header */ if (setjmp(png_jmpbuf(png_ptr))) { - ERR_FAIL_V(DVector()); + ERR_FAIL_V(PoolVector()); } int pngf=0; @@ -379,11 +379,11 @@ static DVector _lossless_pack_png(const Image& p_image) { /* write bytes */ if (setjmp(png_jmpbuf(png_ptr))) { - ERR_FAIL_V(DVector()); + ERR_FAIL_V(PoolVector()); } - DVector::Read r = img.get_data().read(); + PoolVector::Read r = img.get_data().read(); row_pointers = (png_bytep*)memalloc(sizeof(png_bytep)*h); for(int i=0;i _lossless_pack_png(const Image& p_image) { /* end write */ if (setjmp(png_jmpbuf(png_ptr))) { - ERR_FAIL_V(DVector()); + ERR_FAIL_V(PoolVector()); } png_write_end(png_ptr, NULL); diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index b06b02b2001..a9a199bb593 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -193,7 +193,7 @@ Error ResourceSaverPNG::save_image(const String &p_path, Image &p_img) { } - DVector::Read r = p_img.get_data().read(); + PoolVector::Read r = p_img.get_data().read(); row_pointers = (png_bytep*)memalloc(sizeof(png_bytep)*h); for(int i=0;i(FileAccess::ACCESS_RESOURCES); FileAccess::make_default(FileAccess::ACCESS_USERDATA); @@ -144,7 +144,6 @@ void OS_Unix::initialize_core() { PacketPeerUDPPosix::make_default(); IP_Unix::make_default(); #endif - mempool_dynamic = memnew( MemoryPoolDynamicStatic ); ticks_start=0; ticks_start=get_ticks_usec(); @@ -153,8 +152,6 @@ void OS_Unix::initialize_core() { void OS_Unix::finalize_core() { - if (mempool_dynamic) - memdelete( mempool_dynamic ); } diff --git a/drivers/unix/rw_lock_posix.cpp b/drivers/unix/rw_lock_posix.cpp new file mode 100644 index 00000000000..772a7b812a1 --- /dev/null +++ b/drivers/unix/rw_lock_posix.cpp @@ -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 + +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 diff --git a/drivers/unix/rw_lock_posix.h b/drivers/unix/rw_lock_posix.h new file mode 100644 index 00000000000..bcc102f6a63 --- /dev/null +++ b/drivers/unix/rw_lock_posix.h @@ -0,0 +1,37 @@ +#ifndef RWLOCKPOSIX_H +#define RWLOCKPOSIX_H + +#if defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED) + +#include +#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 diff --git a/main/performance.cpp b/main/performance.cpp index 637ff2b0795..2ca73c6d4b6 100644 --- a/main/performance.cpp +++ b/main/performance.cpp @@ -122,9 +122,9 @@ float Performance::get_monitor(Monitor p_monitor) const { case TIME_PROCESS: return _process_time; case TIME_FIXED_PROCESS: return _fixed_process_time; case MEMORY_STATIC: return Memory::get_mem_usage(); - case MEMORY_DYNAMIC: return Memory::get_dynamic_mem_usage(); - case MEMORY_STATIC_MAX: return Memory::get_mem_max_usage(); - case MEMORY_DYNAMIC_MAX: return Memory::get_dynamic_mem_available(); + case MEMORY_DYNAMIC: return MemoryPool::total_memory; + case MEMORY_STATIC_MAX: return MemoryPool::max_memory; + case MEMORY_DYNAMIC_MAX: return 0; case MEMORY_MESSAGE_BUFFER_MAX: return MessageQueue::get_singleton()->get_max_buffer_usage(); case OBJECT_COUNT: return ObjectDB::get_object_count(); case OBJECT_RESOURCE_COUNT: return ResourceCache::get_cached_resource_count(); diff --git a/modules/chibi/event_stream_chibi.cpp b/modules/chibi/event_stream_chibi.cpp index 0b680b4fda6..73d1c01e33a 100644 --- a/modules/chibi/event_stream_chibi.cpp +++ b/modules/chibi/event_stream_chibi.cpp @@ -298,9 +298,9 @@ void CPSampleManagerImpl::unlock_data(CPSample_ID p_id){ sd->locks--; if (sd->locks==0) { - sd->w=DVector::Write(); + sd->w=PoolVector::Write(); AudioServer::get_singleton()->sample_set_data(sd->rid,sd->lock); - sd->lock=DVector(); + sd->lock=PoolVector(); } } diff --git a/modules/chibi/event_stream_chibi.h b/modules/chibi/event_stream_chibi.h index 9c6c883f61c..0244ee0a957 100644 --- a/modules/chibi/event_stream_chibi.h +++ b/modules/chibi/event_stream_chibi.h @@ -54,8 +54,8 @@ class CPSampleManagerImpl : public CPSampleManager { int loop_begin; int loop_end; int locks; - DVector lock; - DVector::Write w; + PoolVector lock; + PoolVector::Write w; CPSample_Loop_Type loop_type; }; diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index 598b2aab0e3..1de98a6b1f4 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -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)); - DVector src_data; + PoolVector src_data; const DDSFormatInfo &info=dds_format_info[dds_format]; uint32_t w = width; @@ -247,9 +247,9 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path, } src_data.resize(size); - DVector::Write wb = src_data.write(); + PoolVector::Write wb = src_data.write(); f->get_buffer(wb.ptr(),size); - wb=DVector::Write(); + wb=PoolVector::Write(); } 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 ); - DVector::Write wb = src_data.write(); + PoolVector::Write wb = src_data.write(); f->get_buffer(wb.ptr(),size); 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::Write(); + wb=PoolVector::Write(); } else { //uncompressed generic... @@ -316,7 +316,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path, size=size*2; src_data.resize(size); - DVector::Write wb = src_data.write(); + PoolVector::Write wb = src_data.write(); f->get_buffer(wb.ptr(),size); @@ -449,7 +449,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path, } - wb=DVector::Write(); + wb=PoolVector::Write(); } diff --git a/modules/etc1/image_etc.cpp b/modules/etc1/image_etc.cpp index 4bbdc0a60a9..845084fef70 100644 --- a/modules/etc1/image_etc.cpp +++ b/modules/etc1/image_etc.cpp @@ -37,10 +37,10 @@ static void _decompress_etc(Image *p_img) { int imgw = p_img->get_width(); int imgh = p_img->get_height(); - DVector src=p_img->get_data(); - DVector dst; + PoolVector src=p_img->get_data(); + PoolVector dst; - DVector::Read r = src.read(); + PoolVector::Read r = src.read(); 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); const uint8_t *srcbr=&r[p_img->get_mipmap_offset(i)]; - DVector::Write w = dst.write(); + PoolVector::Write w = dst.write(); uint8_t *wptr = &w[dst.size()-imgw*imgh*3]; @@ -91,7 +91,7 @@ static void _decompress_etc(Image *p_img) { } - r=DVector::Read(); + r=PoolVector::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())); *p_img=Image(p_img->get_width(),p_img->get_height(),p_img->has_mipmaps(),Image::FORMAT_RGB8,dst); 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 - DVector res_data; - DVector dst_data; - DVector::Read r = img.get_data().read(); + PoolVector res_data; + PoolVector dst_data; + PoolVector::Read r = img.get_data().read(); int mc=0; @@ -134,7 +134,7 @@ static void _compress_etc(Image *p_img) { const uint8_t *src = &r[img.get_mipmap_offset(i)]; int mmsize = MAX(bw,1)*MAX(bh,1)*8; dst_data.resize(dst_data.size()+mmsize); - DVector::Write w=dst_data.write(); + PoolVector::Write w=dst_data.write(); uint8_t *dst = &w[dst_data.size()-mmsize]; diff --git a/modules/etc1/texture_loader_pkm.cpp b/modules/etc1/texture_loader_pkm.cpp index f8af1419798..42c9937b8f7 100644 --- a/modules/etc1/texture_loader_pkm.cpp +++ b/modules/etc1/texture_loader_pkm.cpp @@ -43,13 +43,13 @@ RES ResourceFormatPKM::load(const String &p_path, const String& p_original_path, h.origWidth = f->get_16(); h.origHeight = f->get_16(); - DVector src_data; + PoolVector src_data; uint32_t size = h.texWidth * h.texHeight / 2; src_data.resize(size); - DVector::Write wb = src_data.write(); + PoolVector::Write wb = src_data.write(); f->get_buffer(wb.ptr(),size); - wb=DVector::Write(); + wb=PoolVector::Write(); int mipmaps = h.format; int width = h.origWidth; diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index b205a0a8907..5fe97335f0d 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -830,7 +830,7 @@ Error GDScript::load_byte_code(const String& p_path) { Error GDScript::load_source_code(const String& p_path) { - DVector sourcef; + PoolVector sourcef; Error err; FileAccess *f=FileAccess::open(p_path,FileAccess::READ,&err); if (err) { @@ -840,7 +840,7 @@ Error GDScript::load_source_code(const String& p_path) { int len = f->get_len(); sourcef.resize(len+1); - DVector::Write w = sourcef.write(); + PoolVector::Write w = sourcef.write(); int r = f->get_buffer(w.ptr(),len); f->close(); memdelete(f); diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 84d82500336..b934e7ab1bc 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -61,9 +61,9 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) { } else if (name=="theme/bake") { set_bake(p_value); /* } else if (name=="cells") { - DVector cells = p_value; + PoolVector cells = p_value; int amount=cells.size(); - DVector::Read r = cells.read(); + PoolVector::Read r = cells.read(); ERR_FAIL_COND_V(amount&1,false); // not even cell_map.clear();; for(int i=0;i cells = d["cells"]; + PoolVector cells = d["cells"]; int amount=cells.size(); - DVector::Read r = cells.read(); + PoolVector::Read r = cells.read(); ERR_FAIL_COND_V(amount%3,false); // not even cell_map.clear();; for(int i=0;i cells; + PoolVector cells; cells.resize(cell_map.size()*3); { - DVector::Write w = cells.write(); + PoolVector::Write w = cells.write(); int i=0; for (Map::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); } - DVector col_debug; + PoolVector col_debug; /* * foreach item in this octant, @@ -863,15 +863,15 @@ void GridMap::_octant_bake(const OctantKey &p_key, const Ref& p_tm if (ii.mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES) continue; Array a = ii.mesh->surface_get_arrays(i); - DVector av=a[VS::ARRAY_VERTEX]; + PoolVector av=a[VS::ARRAY_VERTEX]; int avs = av.size(); - DVector::Read vr = av.read(); + PoolVector::Read vr = av.read(); - DVector ai=a[VS::ARRAY_INDEX]; + PoolVector ai=a[VS::ARRAY_INDEX]; int ais=ai.size(); if (ais) { - DVector::Read ir=ai.read(); + PoolVector::Read ir=ai.read(); for(int j=0;jpush_back(xform.xform(vr[ir[j]])); @@ -1667,7 +1667,7 @@ void GridMap::bake_geometry() { } - DVector vv; + PoolVector vv; vv.fill_with(vertices); //print_line("TOTAL VERTICES: "+itos(vv.size())); tmesh = Ref( memnew( TriangleMesh )); diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 08f2c4fbbc0..db0952b1cbf 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -1126,7 +1126,7 @@ void GridMapEditor::_update_areas_display() { RID mesh = VisualServer::get_singleton()->mesh_create(); - DVector planes; + PoolVector planes; for(int i=0;i<3;i++) { Vector3 axis; @@ -1343,8 +1343,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { //selection mesh create - DVector lines; - DVector triangles; + PoolVector lines; + PoolVector triangles; for (int i=0;i<6;i++) { diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp index 9709c0c7068..1152d42e1b1 100644 --- a/modules/jpg/image_loader_jpegd.cpp +++ b/modules/jpg/image_loader_jpegd.cpp @@ -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; - DVector data; + PoolVector data; data.resize(dst_bpl * image_height); - DVector::Write dw = data.write(); + PoolVector::Write dw = data.write(); 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 fmt=Image::FORMAT_RGBA8; - dw = DVector::Write(); + dw = PoolVector::Write(); p_image->create(image_width,image_height,0,fmt,data); 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) { - DVector src_image; + PoolVector src_image; int src_image_len = f->get_len(); ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT); src_image.resize(src_image_len); - DVector::Write w = src_image.write(); + PoolVector::Write w = src_image.write(); 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); - w = DVector::Write(); + w = PoolVector::Write(); return err; diff --git a/modules/mpc/audio_stream_mpc.cpp b/modules/mpc/audio_stream_mpc.cpp index d8572d3b5d9..bcb7e4c8718 100644 --- a/modules/mpc/audio_stream_mpc.cpp +++ b/modules/mpc/audio_stream_mpc.cpp @@ -59,7 +59,7 @@ Error AudioStreamPlaybackMPC::_open_file() { if (preload) { data.resize(streamlen); - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); f->get_buffer(&w[0],streamlen); memdelete(f); f=NULL; @@ -85,7 +85,7 @@ int AudioStreamPlaybackMPC::_read_file(void *p_dst,int p_bytes) { if (f) return f->get_buffer((uint8_t*)p_dst,p_bytes); - DVector::Read r = data.read(); + PoolVector::Read r = data.read(); if (p_bytes+data_ofs > streamlen) { p_bytes=streamlen-data_ofs; } diff --git a/modules/mpc/audio_stream_mpc.h b/modules/mpc/audio_stream_mpc.h index e7d677aa8c5..5330fa055f0 100644 --- a/modules/mpc/audio_stream_mpc.h +++ b/modules/mpc/audio_stream_mpc.h @@ -43,7 +43,7 @@ class AudioStreamPlaybackMPC : public AudioStreamPlayback { bool preload; FileAccess *f; String file; - DVector data; + PoolVector data; int data_ofs; int streamlen; diff --git a/modules/pbm/bitmap_loader_pbm.cpp b/modules/pbm/bitmap_loader_pbm.cpp index f9fc19b2cc3..6caaf103341 100644 --- a/modules/pbm/bitmap_loader_pbm.cpp +++ b/modules/pbm/bitmap_loader_pbm.cpp @@ -31,11 +31,11 @@ #include "scene/resources/bit_mask.h" -static bool _get_token(FileAccessRef& f,uint8_t &saved,DVector& r_token,bool p_binary=false,bool p_single_chunk=false) { +static bool _get_token(FileAccessRef& f,uint8_t &saved,PoolVector& r_token,bool p_binary=false,bool p_single_chunk=false) { int token_max = r_token.size(); - DVector::Write w; + PoolVector::Write w; if (token_max) w=r_token.write(); int ofs=0; @@ -53,7 +53,7 @@ static bool _get_token(FileAccessRef& f,uint8_t &saved,DVector& r_token } if (f->eof_reached()) { if (ofs) { - w=DVector::Write(); + w=PoolVector::Write(); r_token.resize(ofs); return true; } else { @@ -81,7 +81,7 @@ static bool _get_token(FileAccessRef& f,uint8_t &saved,DVector& r_token if (ofs && !p_single_chunk) { - w=DVector::Write(); + w=PoolVector::Write(); r_token.resize(ofs); saved=b; @@ -98,7 +98,7 @@ static bool _get_token(FileAccessRef& f,uint8_t &saved,DVector& r_token resized=true; } if (resized) { - w=DVector::Write(); + w=PoolVector::Write(); r_token.resize(token_max); w=r_token.write(); } @@ -109,10 +109,10 @@ static bool _get_token(FileAccessRef& f,uint8_t &saved,DVector& r_token return false; } -static int _get_number_from_token(DVector& r_token) { +static int _get_number_from_token(PoolVector& r_token) { int len = r_token.size(); - DVector::Read r = r_token.read(); + PoolVector::Read r = r_token.read(); 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) _RETURN(ERR_CANT_OPEN); - DVector token; + PoolVector token; if (!_get_token(f,saved,token)) { _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); } - DVector::Read r=token.read(); + PoolVector::Read r=token.read(); for(int i=0;i::Read r=token.read(); + PoolVector::Read r=token.read(); int bitwidth = width; if (bitwidth % 8) bitwidth+=8-(bitwidth%8); diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 0b07e05410f..9f8db98e05e 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -99,13 +99,13 @@ RES ResourceFormatPVR::load(const String &p_path,const String& p_original_path,E print_line("surfcount: "+itos(surfcount)); */ - DVector data; + PoolVector data; data.resize(surfsize); ERR_FAIL_COND_V(data.size()==0,RES()); - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); f->get_buffer(&w[0],surfsize); err = f->get_error(); 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::Write(); + w = PoolVector::Write(); int tex_flags=Texture::FLAG_FILTER|Texture::FLAG_REPEAT; @@ -209,10 +209,10 @@ static void _compress_pvrtc4(Image * p_img) { Image new_img; new_img.create(img.get_width(),img.get_height(),true,use_alpha?Image::FORMAT_PVRTC4A:Image::FORMAT_PVRTC4); - DVector data=new_img.get_data(); + PoolVector data=new_img.get_data(); { - DVector::Write wr=data.write(); - DVector::Read r=img.get_data().read(); + PoolVector::Write wr=data.write(); + PoolVector::Read r=img.get_data().read(); 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 ); - DVector data = p_img->get_data(); - DVector::Read r = data.read(); + PoolVector data = p_img->get_data(); + PoolVector::Read r = data.read(); - DVector newdata; + PoolVector newdata; newdata.resize( p_img->get_width() * p_img->get_height() * 4); - DVector::Write w=newdata.write(); + PoolVector::Write w=newdata.write(); 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])); //} - w=DVector::Write(); - r=DVector::Read(); + w=PoolVector::Write(); + r=PoolVector::Read(); bool make_mipmaps=p_img->has_mipmaps(); Image newimg(p_img->get_width(),p_img->get_height(),false,Image::FORMAT_RGBA8,newdata); diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp index 6cd9048f1b8..74106586036 100644 --- a/modules/squish/image_compress_squish.cpp +++ b/modules/squish/image_compress_squish.cpp @@ -66,12 +66,12 @@ void image_compress_squish(Image *p_image) { int mm_count = p_image->get_mipmap_count(); - DVector data; + PoolVector data; int target_size = Image::get_image_data_size(w,h,target_format,mm_count); data.resize(target_size); - DVector::Read rb = p_image->get_data().read(); - DVector::Write wb = data.write(); + PoolVector::Read rb = p_image->get_data().read(); + PoolVector::Write wb = data.write(); int dst_ofs=0; @@ -84,8 +84,8 @@ void image_compress_squish(Image *p_image) { h>>=1; } - rb = DVector::Read(); - wb = DVector::Write(); + rb = PoolVector::Read(); + wb = PoolVector::Write(); p_image->create(p_image->get_width(),p_image->get_height(),p_image->has_mipmaps(),target_format,data); diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index e6bf55185eb..b847f17bb76 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -88,7 +88,7 @@ void VideoStreamPlaybackTheora::video_write(void){ { int pixels = size.x * size.y; frame_data.resize(pixels * 4); - DVector::Write w = frame_data.write(); + PoolVector::Write w = frame_data.write(); char* dst = (char*)w.ptr(); int p = 0; for (int i=0; i::Write w = frame_data.write(); + PoolVector::Write w = frame_data.write(); char* dst = (char*)w.ptr(); //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; frame_data.resize(size.x * size.y * pitch); - DVector::Write w = frame_data.write(); + PoolVector::Write w = frame_data.write(); char* dst = (char*)w.ptr(); for(int i=0;i::Write w = frame_data.write(); + PoolVector::Write w = frame_data.write(); char* dst = (char*)w.ptr(); 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; frame_data.resize(size.x * size.y * pitch); - DVector::Write w = frame_data.write(); + PoolVector::Write w = frame_data.write(); char* dst = (char*)w.ptr(); uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y / div); diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h index bff9d2538d9..0e1f5fa8645 100644 --- a/modules/theora/video_stream_theora.h +++ b/modules/theora/video_stream_theora.h @@ -51,7 +51,7 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback { //Image frames[MAX_FRAMES]; Image::Format format; - DVector frame_data; + PoolVector frame_data; int frames_pending; FileAccess* file; String file_name; diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 35b215cb525..d132e896904 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -293,7 +293,7 @@ void VideoStreamPlaybackWebm::update(float p_delta) { if (err == VPXDecoder::NO_ERROR && image.w == webm->getWidth() && image.h == webm->getHeight()) { - DVector::Write w = frame_data.write(); + PoolVector::Write w = frame_data.write(); bool converted = false; if (image.chromaShiftW == 1 && image.chromaShiftH == 1) { diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h index a34591d9b90..cb4ef53f6dd 100644 --- a/modules/webm/video_stream_webm.h +++ b/modules/webm/video_stream_webm.h @@ -56,7 +56,7 @@ class VideoStreamPlaybackWebm : public VideoStreamPlayback { double delay_compensation; double time, video_frame_delay, video_pos; - DVector frame_data; + PoolVector frame_data; Ref texture; int16_t *pcm; diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp index 56fc386ef44..3508c6a6638 100644 --- a/modules/webp/image_loader_webp.cpp +++ b/modules/webp/image_loader_webp.cpp @@ -36,9 +36,9 @@ #include #include -static DVector _webp_lossy_pack(const Image& p_image,float p_quality) { +static PoolVector _webp_lossy_pack(const Image& p_image,float p_quality) { - ERR_FAIL_COND_V(p_image.empty(),DVector()); + ERR_FAIL_COND_V(p_image.empty(),PoolVector()); Image img=p_image; if (img.detect_alpha()) @@ -47,8 +47,8 @@ static DVector _webp_lossy_pack(const Image& p_image,float p_quality) { img.convert(Image::FORMAT_RGB8); Size2 s(img.get_width(),img.get_height()); - DVector data = img.get_data(); - DVector::Read r = data.read(); + PoolVector data = img.get_data(); + PoolVector::Read r = data.read(); uint8_t *dst_buff=NULL; size_t dst_size=0; @@ -59,25 +59,25 @@ static DVector _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); } - ERR_FAIL_COND_V(dst_size==0,DVector()); - DVector dst; + ERR_FAIL_COND_V(dst_size==0,PoolVector()); + PoolVector dst; dst.resize(4+dst_size); - DVector::Write w = dst.write(); + PoolVector::Write w = dst.write(); w[0]='W'; w[1]='E'; w[2]='B'; w[3]='P'; copymem(&w[4],dst_buff,dst_size); free(dst_buff); - w=DVector::Write(); + w=PoolVector::Write(); return dst; } -static Image _webp_lossy_unpack(const DVector& p_buffer) { +static Image _webp_lossy_unpack(const PoolVector& p_buffer) { int size = p_buffer.size()-4; ERR_FAIL_COND_V(size<=0,Image()); - DVector::Read r = p_buffer.read(); + PoolVector::Read r = p_buffer.read(); ERR_FAIL_COND_V(r[0]!='W' || r[1]!='E' || r[2]!='B' || r[3]!='P',Image()); WebPBitstreamFeatures features; @@ -90,11 +90,11 @@ static Image _webp_lossy_unpack(const DVector& p_buffer) { //print_line("height: "+itos(features.height)); //print_line("alpha: "+itos(features.has_alpha)); - DVector dst_image; + PoolVector dst_image; int datasize = features.width*features.height*(features.has_alpha?4:3); dst_image.resize(datasize); - DVector::Write dst_w = dst_image.write(); + PoolVector::Write dst_w = dst_image.write(); bool errdec=false; if (features.has_alpha) { @@ -107,7 +107,7 @@ static Image _webp_lossy_unpack(const DVector& p_buffer) { //ERR_EXPLAIN("Error decoding webp! - "+p_file); ERR_FAIL_COND_V(errdec,Image()); - dst_w = DVector::Write(); + dst_w = PoolVector::Write(); 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(); - DVector src_image; + PoolVector src_image; src_image.resize(size); WebPBitstreamFeatures features; - DVector::Write src_w = src_image.write(); + PoolVector::Write src_w = src_image.write(); f->get_buffer(src_w.ptr(),size); 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("alpha: "+itos(features.has_alpha)); - src_w = DVector::Write(); + src_w = PoolVector::Write(); - DVector dst_image; + PoolVector dst_image; int datasize = features.width*features.height*(features.has_alpha?4:3); dst_image.resize(datasize); - DVector::Read src_r = src_image.read(); - DVector::Write dst_w = dst_image.write(); + PoolVector::Read src_r = src_image.read(); + PoolVector::Write dst_w = dst_image.write(); bool errdec=false; @@ -158,8 +158,8 @@ Error ImageLoaderWEBP::load_image(Image *p_image,FileAccess *f) { //ERR_EXPLAIN("Error decoding webp! - "+p_file); ERR_FAIL_COND_V(errdec,ERR_FILE_CORRUPT); - src_r = DVector::Read(); - dst_w = DVector::Write(); + src_r = PoolVector::Read(); + dst_w = PoolVector::Write(); *p_image = Image(features.width,features.height,0,features.has_alpha?Image::FORMAT_RGBA8:Image::FORMAT_RGB8,dst_image); diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp index 715021db338..c4d1a85c5f5 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -153,7 +153,7 @@ public: } break; case Variant::STRING_ARRAY: { - DVector sarray = *p_args[i]; + PoolVector sarray = *p_args[i]; jobjectArray arr = env->NewObjectArray(sarray.size(),env->FindClass("java/lang/String"),env->NewStringUTF("")); for(int j=0;j array = *p_args[i]; + PoolVector array = *p_args[i]; jintArray arr = env->NewIntArray(array.size()); - DVector::Read r = array.read(); + PoolVector::Read r = array.read(); env->SetIntArrayRegion(arr,0,array.size(),r.ptr()); v[i].l=arr; } break; case Variant::REAL_ARRAY: { - DVector array = *p_args[i]; + PoolVector array = *p_args[i]; jfloatArray arr = env->NewFloatArray(array.size()); - DVector::Read r = array.read(); + PoolVector::Read r = array.read(); env->SetFloatArrayRegion(arr,0,array.size(),r.ptr()); v[i].l=arr; @@ -225,7 +225,7 @@ public: jobjectArray arr = (jobjectArray)env->CallObjectMethodA(instance,E->get().method,v); int stringCount = env->GetArrayLength(arr); - DVector sarr; + PoolVector sarr; for (int i=0; iGetObjectArrayElement(arr, i); @@ -241,12 +241,12 @@ public: jintArray arr = (jintArray)env->CallObjectMethodA(instance,E->get().method,v); int fCount = env->GetArrayLength(arr); - DVector sarr; + PoolVector sarr; sarr.resize(fCount); - DVector::Write w = sarr.write(); + PoolVector::Write w = sarr.write(); env->GetIntArrayRegion(arr,0,fCount,w.ptr()); - w = DVector::Write(); + w = PoolVector::Write(); ret=sarr; } break; case Variant::REAL_ARRAY: { @@ -254,12 +254,12 @@ public: jfloatArray arr = (jfloatArray)env->CallObjectMethodA(instance,E->get().method,v); int fCount = env->GetArrayLength(arr); - DVector sarr; + PoolVector sarr; sarr.resize(fCount); - DVector::Write w = sarr.write(); + PoolVector::Write w = sarr.write(); env->GetFloatArrayRegion(arr,0,fCount,w.ptr()); - w = DVector::Write(); + w = PoolVector::Write(); ret=sarr; } break; default: { diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 602d22dfa2c..6d479462639 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -122,7 +122,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_a } break; case Variant::STRING_ARRAY: { - DVector sarray = *p_arg; + PoolVector sarray = *p_arg; jobjectArray arr = env->NewObjectArray(sarray.size(),env->FindClass("java/lang/String"),env->NewStringUTF("")); for(int j=0;j array = *p_arg; + PoolVector array = *p_arg; jintArray arr = env->NewIntArray(array.size()); - DVector::Read r = array.read(); + PoolVector::Read r = array.read(); env->SetIntArrayRegion(arr,0,array.size(),r.ptr()); v.val.l=arr; v.obj=arr; } break; case Variant::RAW_ARRAY: { - DVector array = *p_arg; + PoolVector array = *p_arg; jbyteArray arr = env->NewByteArray(array.size()); - DVector::Read r = array.read(); + PoolVector::Read r = array.read(); env->SetByteArrayRegion(arr,0,array.size(),reinterpret_cast(r.ptr())); v.val.l=arr; v.obj=arr; @@ -200,9 +200,9 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_a } break; case Variant::REAL_ARRAY: { - DVector array = *p_arg; + PoolVector array = *p_arg; jfloatArray arr = env->NewFloatArray(array.size()); - DVector::Read r = array.read(); + PoolVector::Read r = array.read(); env->SetFloatArrayRegion(arr,0,array.size(),r.ptr()); v.val.l=arr; v.obj=arr; @@ -259,7 +259,7 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) { jobjectArray arr = (jobjectArray)obj; int stringCount = env->GetArrayLength(arr); //print_line("String array! " + String::num(stringCount)); - DVector sarr; + PoolVector sarr; for (int i=0; iGetObjectArrayElement(arr, i); @@ -290,12 +290,12 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) { jintArray arr = (jintArray)obj; int fCount = env->GetArrayLength(arr); - DVector sarr; + PoolVector sarr; sarr.resize(fCount); - DVector::Write w = sarr.write(); + PoolVector::Write w = sarr.write(); env->GetIntArrayRegion(arr,0,fCount,w.ptr()); - w = DVector::Write(); + w = PoolVector::Write(); return sarr; }; @@ -303,12 +303,12 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) { jbyteArray arr = (jbyteArray)obj; int fCount = env->GetArrayLength(arr); - DVector sarr; + PoolVector sarr; sarr.resize(fCount); - DVector::Write w = sarr.write(); + PoolVector::Write w = sarr.write(); env->GetByteArrayRegion(arr,0,fCount,reinterpret_cast(w.ptr())); - w = DVector::Write(); + w = PoolVector::Write(); return sarr; }; @@ -540,12 +540,12 @@ public: jintArray arr = (jintArray)env->CallObjectMethodA(instance,E->get().method,v); int fCount = env->GetArrayLength(arr); - DVector sarr; + PoolVector sarr; sarr.resize(fCount); - DVector::Write w = sarr.write(); + PoolVector::Write w = sarr.write(); env->GetIntArrayRegion(arr,0,fCount,w.ptr()); - w = DVector::Write(); + w = PoolVector::Write(); ret=sarr; env->DeleteLocalRef(arr); } break; @@ -554,12 +554,12 @@ public: jfloatArray arr = (jfloatArray)env->CallObjectMethodA(instance,E->get().method,v); int fCount = env->GetArrayLength(arr); - DVector sarr; + PoolVector sarr; sarr.resize(fCount); - DVector::Write w = sarr.write(); + PoolVector::Write w = sarr.write(); env->GetFloatArrayRegion(arr,0,fCount,w.ptr()); - w = DVector::Write(); + w = PoolVector::Write(); ret=sarr; env->DeleteLocalRef(arr); } break; diff --git a/platform/iphone/rasterizer_iphone.cpp b/platform/iphone/rasterizer_iphone.cpp index 3654f6d2d61..ee0457cfb1b 100644 --- a/platform/iphone/rasterizer_iphone.cpp +++ b/platform/iphone/rasterizer_iphone.cpp @@ -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; - DVector::Read read = img.get_data().read(); + PoolVector::Read read = img.get_data().read(); 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() ); @@ -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( p_array.get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER ); - DVector indices = p_array; + PoolVector indices = p_array; ERR_FAIL_COND_V( indices.size() == 0, 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); }; - DVector::Read read = indices.read(); + PoolVector::Read read = indices.read(); const int *src=read.ptr(); for (int i=0;iindex_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 ); - DVector array = p_array; + PoolVector array = p_array; ERR_FAIL_COND_V( array.size() != surface->array_len, ERR_INVALID_PARAMETER ); if (surface->array_local == 0) { glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id); }; - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const Vector3* src=read.ptr(); // 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 ); - DVector array = p_array; + PoolVector array = p_array; 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::Read read = array.read(); + PoolVector::Read read = array.read(); const real_t* src = read.ptr(); for (int i=0;iarray_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 ); - DVector array = p_array; + PoolVector array = p_array; 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); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const Color* src = read.ptr(); 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 ); - DVector array = p_array; + PoolVector array = p_array; ERR_FAIL_COND_V( array.size() != surface->array_len , ERR_INVALID_PARAMETER); if (surface->array_local == 0) glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); 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 ); - DVector array = p_array; + PoolVector array = p_array; ERR_FAIL_COND_V( array.size() != surface->array_len*VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER ); if (surface->array_local == 0) glBindBuffer(GL_ARRAY_BUFFER,surface->vertex_id); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const real_t * src = read.ptr(); diff --git a/platform/javascript/audio_server_javascript.cpp b/platform/javascript/audio_server_javascript.cpp index fec553df044..d1fba030a5f 100644 --- a/platform/javascript/audio_server_javascript.cpp +++ b/platform/javascript/audio_server_javascript.cpp @@ -87,7 +87,7 @@ const void* AudioServerJavascript::sample_get_data_ptr(RID p_sample) const{ return NULL; } -void AudioServerJavascript::sample_set_data(RID p_sample, const DVector& p_buffer){ +void AudioServerJavascript::sample_set_data(RID p_sample, const PoolVector& p_buffer){ Sample *sample = sample_owner.get(p_sample); ERR_FAIL_COND(!sample); @@ -95,7 +95,7 @@ void AudioServerJavascript::sample_set_data(RID p_sample, const DVector Vector buffer; buffer.resize(sample->length*chans); - DVector::Read r=p_buffer.read(); + PoolVector::Read r=p_buffer.read(); if (sample->format==SAMPLE_FORMAT_PCM8) { const int8_t*ptr = (const int8_t*)r.ptr(); for(int i=0;ilength*chans;i++) { @@ -116,10 +116,10 @@ void AudioServerJavascript::sample_set_data(RID p_sample, const DVector } -DVector AudioServerJavascript::sample_get_data(RID p_sample) const{ +PoolVector AudioServerJavascript::sample_get_data(RID p_sample) const{ - return DVector(); + return PoolVector(); } void AudioServerJavascript::sample_set_mix_rate(RID p_sample,int p_rate){ diff --git a/platform/javascript/audio_server_javascript.h b/platform/javascript/audio_server_javascript.h index 47aadf6bc65..8e61e94dfce 100644 --- a/platform/javascript/audio_server_javascript.h +++ b/platform/javascript/audio_server_javascript.h @@ -131,8 +131,8 @@ public: virtual const void* sample_get_data_ptr(RID p_sample) const; - virtual void sample_set_data(RID p_sample, const DVector& p_buffer); - virtual DVector sample_get_data(RID p_sample) const; + virtual void sample_set_data(RID p_sample, const PoolVector& p_buffer); + virtual PoolVector sample_get_data(RID p_sample) const; virtual void sample_set_mix_rate(RID p_sample,int p_rate); virtual int sample_get_mix_rate(RID p_sample) const; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index f27eb987640..548d33ebfa3 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1327,8 +1327,8 @@ void OS_OSX::set_icon(const Image& p_icon) { uint8_t *pixels = [imgrep bitmapData]; int len = img.get_width()*img.get_height(); - DVector data = img.get_data(); - DVector::Read r = data.read(); + PoolVector data = img.get_data(); + PoolVector::Read r = data.read(); /* Premultiply the alpha channel */ for (int i = 0; i::Read r= icon.get_data().read(); + PoolVector::Read r= icon.get_data().read(); for(int i=0;i::Read r = img.get_data().read(); + PoolVector::Read r = img.get_data().read(); long * wr = &pd[2]; uint8_t const * pr = r.ptr(); diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 4b7a9180235..46baa7c1848 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -68,16 +68,16 @@ void CollisionPolygon2D::_add_to_collision_object(Object *p_obj) { Ref concave = memnew( ConcavePolygonShape2D ); - DVector segments; + PoolVector segments; segments.resize(polygon.size()*2); - DVector::Write w=segments.write(); + PoolVector::Write w=segments.write(); for(int i=0;i::Write(); + w=PoolVector::Write(); concave->set_segments(segments); co->add_shape(concave,get_transform()); diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp index ac1fb16d781..ac2a8d4dc5f 100644 --- a/scene/2d/light_occluder_2d.cpp +++ b/scene/2d/light_occluder_2d.cpp @@ -29,14 +29,14 @@ #include "light_occluder_2d.h" -void OccluderPolygon2D::set_polygon(const DVector& p_polygon) { +void OccluderPolygon2D::set_polygon(const PoolVector& p_polygon) { polygon=p_polygon; VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon,p_polygon,closed); emit_changed(); } -DVector OccluderPolygon2D::get_polygon() const{ +PoolVector OccluderPolygon2D::get_polygon() const{ return polygon; } @@ -141,7 +141,7 @@ void LightOccluder2D::_notification(int p_what) { if (occluder_polygon.is_valid()) { - DVector poly = occluder_polygon->get_polygon(); + PoolVector poly = occluder_polygon->get_polygon(); if (poly.size()) { if (occluder_polygon->is_closed()) { @@ -151,7 +151,7 @@ void LightOccluder2D::_notification(int p_what) { } else { int ps=poly.size(); - DVector::Read r = poly.read(); + PoolVector::Read r = poly.read(); for(int i=0;i polygon; + PoolVector polygon; bool closed; CullMode cull; @@ -54,8 +54,8 @@ protected: static void _bind_methods(); public: - void set_polygon(const DVector& p_polygon); - DVector get_polygon() const; + void set_polygon(const PoolVector& p_polygon); + PoolVector get_polygon() const; void set_closed(bool p_closed); bool is_closed() const; diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index 1a7d01c7626..be68c61bd8f 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -36,12 +36,12 @@ void Navigation2D::_navpoly_link(int p_id) { NavMesh &nm=navpoly_map[p_id]; ERR_FAIL_COND(nm.linked); - DVector vertices=nm.navpoly->get_vertices(); + PoolVector vertices=nm.navpoly->get_vertices(); int len = vertices.size(); if (len==0) return; - DVector::Read r=vertices.read(); + PoolVector::Read r=vertices.read(); for(int i=0;iget_polygon_count();i++) { diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index a11f2240f9e..add3a183efb 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -31,12 +31,12 @@ #include "triangulator.h" #include "core_string_names.h" -void NavigationPolygon::set_vertices(const DVector& p_vertices) { +void NavigationPolygon::set_vertices(const PoolVector& p_vertices) { vertices=p_vertices; } -DVector NavigationPolygon::get_vertices() const{ +PoolVector NavigationPolygon::get_vertices() const{ return vertices; } @@ -89,7 +89,7 @@ void NavigationPolygon::add_polygon(const Vector& p_polygon){ } -void NavigationPolygon::add_outline_at_index(const DVector& p_outline,int p_index) { +void NavigationPolygon::add_outline_at_index(const PoolVector& p_outline,int p_index) { outlines.insert(p_index,p_outline); } @@ -108,7 +108,7 @@ void NavigationPolygon::clear_polygons(){ polygons.clear(); } -void NavigationPolygon::add_outline(const DVector& p_outline) { +void NavigationPolygon::add_outline(const PoolVector& p_outline) { outlines.push_back(p_outline); } @@ -118,7 +118,7 @@ int NavigationPolygon::get_outline_count() const{ return outlines.size(); } -void NavigationPolygon::set_outline(int p_idx,const DVector& p_outline) { +void NavigationPolygon::set_outline(int p_idx,const PoolVector& p_outline) { ERR_FAIL_INDEX(p_idx,outlines.size()); outlines[p_idx]=p_outline; } @@ -130,8 +130,8 @@ void NavigationPolygon::remove_outline(int p_idx) { } -DVector NavigationPolygon::get_outline(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx,outlines.size(),DVector()); +PoolVector NavigationPolygon::get_outline(int p_idx) const { + ERR_FAIL_INDEX_V(p_idx,outlines.size(),PoolVector()); return outlines[p_idx]; } @@ -147,11 +147,11 @@ void NavigationPolygon::make_polygons_from_outlines(){ for(int i=0;i ol = outlines[i]; + PoolVector ol = outlines[i]; int olsize = ol.size(); if (olsize<3) continue; - DVector::Read r=ol.read(); + PoolVector::Read r=ol.read(); for(int j=0;j ol = outlines[i]; + PoolVector ol = outlines[i]; int olsize = ol.size(); if (olsize<3) continue; - DVector::Read r=ol.read(); + PoolVector::Read r=ol.read(); int interscount=0; //test if this is an outer outline @@ -178,11 +178,11 @@ void NavigationPolygon::make_polygons_from_outlines(){ if (i==k) continue; //no self intersect - DVector ol2 = outlines[k]; + PoolVector ol2 = outlines[k]; int olsize2 = ol2.size(); if (olsize2<3) continue; - DVector::Read r2=ol2.read(); + PoolVector::Read r2=ol2.read(); for(int l=0;lis_editor_hint() || get_tree()->is_debugging_navigation_hint()) && navpoly.is_valid()) { - DVector verts=navpoly->get_vertices(); + PoolVector verts=navpoly->get_vertices(); int vsize = verts.size(); if (vsize<3) return; @@ -385,7 +385,7 @@ void NavigationPolygonInstance::_notification(int p_what) { vertices.resize(vsize); colors.resize(vsize); { - DVector::Read vr = verts.read(); + PoolVector::Read vr = verts.read(); for(int i=0;i vertices; + PoolVector vertices; struct Polygon { Vector indices; }; Vector polygons; - Vector< DVector > outlines; + Vector< PoolVector > outlines; protected: @@ -57,16 +57,16 @@ public: - void set_vertices(const DVector& p_vertices); - DVector get_vertices() const; + void set_vertices(const PoolVector& p_vertices); + PoolVector get_vertices() const; void add_polygon(const Vector& p_polygon); int get_polygon_count() const; - void add_outline(const DVector& p_outline); - void add_outline_at_index(const DVector& p_outline,int p_index); - void set_outline(int p_idx,const DVector& p_outline); - DVector get_outline(int p_idx) const; + void add_outline(const PoolVector& p_outline); + void add_outline_at_index(const PoolVector& p_outline,int p_index); + void set_outline(int p_idx,const PoolVector& p_outline); + PoolVector get_outline(int p_idx) const; void remove_outline(int p_idx); int get_outline_count() const; diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index 168bd1b2898..f8747d54b77 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -276,7 +276,7 @@ void Particles2D::_process_particles(float p_delta) { active_count=0; - DVector::Read r; + PoolVector::Read r; int emission_point_count=0; if (emission_points.size()) { @@ -992,12 +992,12 @@ int Particles2D::get_v_frames() const{ -void Particles2D::set_emission_points(const DVector& p_points) { +void Particles2D::set_emission_points(const PoolVector& p_points) { emission_points=p_points; } -DVector Particles2D::get_emission_points() const{ +PoolVector Particles2D::get_emission_points() const{ return emission_points; } diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h index 9b740dad7dc..91f42c52224 100644 --- a/scene/2d/particles_2d.h +++ b/scene/2d/particles_2d.h @@ -151,7 +151,7 @@ private: Point2 emissor_offset; Vector2 initial_velocity; Vector2 extents; - DVector emission_points; + PoolVector emission_points; float time; int active_count; @@ -245,8 +245,8 @@ public: void set_initial_velocity(const Vector2& p_velocity); Vector2 get_initial_velocity() const; - void set_emission_points(const DVector& p_points); - DVector get_emission_points() const; + void set_emission_points(const PoolVector& p_points); + PoolVector get_emission_points() const; void pre_process(float p_delta); void reset(); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 179e71fa900..948c8b08182 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -33,7 +33,7 @@ Rect2 Polygon2D::get_item_rect() const { if (rect_cache_dirty){ int l =polygon.size(); - DVector::Read r = polygon.read(); + PoolVector::Read r = polygon.read(); item_rect=Rect2(); for(int i=0;i::Read polyr =polygon.read(); + PoolVector::Read polyr =polygon.read(); for(int i=0;i::Read uvr = uv.read(); + PoolVector::Read uvr = uv.read(); for(int i=0;i::Read color_r=vertex_colors.read(); + PoolVector::Read color_r=vertex_colors.read(); for(int i=0;i& p_polygon) { +void Polygon2D::set_polygon(const PoolVector& p_polygon) { polygon=p_polygon; rect_cache_dirty=true; update(); } -DVector Polygon2D::get_polygon() const{ +PoolVector Polygon2D::get_polygon() const{ return polygon; } -void Polygon2D::set_uv(const DVector& p_uv) { +void Polygon2D::set_uv(const PoolVector& p_uv) { uv=p_uv; update(); } -DVector Polygon2D::get_uv() const{ +PoolVector Polygon2D::get_uv() const{ return uv; } @@ -227,12 +227,12 @@ Color Polygon2D::get_color() const{ return color; } -void Polygon2D::set_vertex_colors(const DVector& p_colors){ +void Polygon2D::set_vertex_colors(const PoolVector& p_colors){ vertex_colors=p_colors; update(); } -DVector Polygon2D::get_vertex_colors() const{ +PoolVector Polygon2D::get_vertex_colors() const{ return vertex_colors; } diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index 6327021295e..8434dae40cd 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -35,9 +35,9 @@ class Polygon2D : public Node2D { GDCLASS(Polygon2D,Node2D); - DVector polygon; - DVector uv; - DVector vertex_colors; + PoolVector polygon; + PoolVector uv; + PoolVector vertex_colors; Color color; Ref texture; Size2 tex_scale; @@ -60,17 +60,17 @@ protected: static void _bind_methods(); public: - void set_polygon(const DVector& p_polygon); - DVector get_polygon() const; + void set_polygon(const PoolVector& p_polygon); + PoolVector get_polygon() const; - void set_uv(const DVector& p_uv); - DVector get_uv() const; + void set_uv(const PoolVector& p_uv); + PoolVector get_uv() const; void set_color(const Color& p_color); Color get_color() const; - void set_vertex_colors(const DVector& p_colors); - DVector get_vertex_colors() const; + void set_vertex_colors(const PoolVector& p_colors); + PoolVector get_vertex_colors() const; void set_texture(const Ref& p_texture); Ref get_texture() const; diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 54d3f9f5ddb..04b0379a1c8 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -819,10 +819,10 @@ void TileMap::clear() { tile_map.clear(); } -void TileMap::_set_tile_data(const DVector& p_data) { +void TileMap::_set_tile_data(const PoolVector& p_data) { int c=p_data.size(); - DVector::Read r = p_data.read(); + PoolVector::Read r = p_data.read(); for(int i=0;i& p_data) { } -DVector TileMap::_get_tile_data() const { +PoolVector TileMap::_get_tile_data() const { - DVector data; + PoolVector data; data.resize(tile_map.size()*2); - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); int idx=0; for(const Map::Element *E=tile_map.front();E;E=E->next()) { @@ -882,7 +882,7 @@ DVector TileMap::_get_tile_data() const { } - w = DVector::Write(); + w = PoolVector::Write(); return data; diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 8cc144b74d5..f863c0b2eaa 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -168,8 +168,8 @@ private: _FORCE_INLINE_ int _get_quadrant_size() const; - void _set_tile_data(const DVector& p_data); - DVector _get_tile_data() const; + void _set_tile_data(const PoolVector& p_data); + PoolVector _get_tile_data() const; void _set_old_cell_size(int p_size) { set_cell_size(Size2(p_size,p_size)); } int _get_old_cell_size() const { return cell_size.x; } diff --git a/scene/3d/baked_light_instance.cpp b/scene/3d/baked_light_instance.cpp index b5cc4518359..f85dfea80e7 100644 --- a/scene/3d/baked_light_instance.cpp +++ b/scene/3d/baked_light_instance.cpp @@ -204,7 +204,7 @@ Vector BakedLight::_get_bake_texture(Image &p_image,const Color& p_color) p_image.resize(bake_texture_size,bake_texture_size,Image::INTERPOLATE_CUBIC); - DVector::Read r = p_image.get_data().read(); + PoolVector::Read r = p_image.get_data().read(); ret.resize(bake_texture_size*bake_texture_size); for(int i=0;i::Write(); + bake_cells_write=PoolVector::Write(); bake_cells.resize(1<& p_mesh) { Array a = p_mesh->surface_get_arrays(i); - DVector vertices = a[Mesh::ARRAY_VERTEX]; - DVector::Read vr=vertices.read(); - DVector uv = a[Mesh::ARRAY_TEX_UV]; - DVector::Read uvr; - DVector index = a[Mesh::ARRAY_INDEX]; + PoolVector vertices = a[Mesh::ARRAY_VERTEX]; + PoolVector::Read vr=vertices.read(); + PoolVector uv = a[Mesh::ARRAY_TEX_UV]; + PoolVector::Read uvr; + PoolVector index = a[Mesh::ARRAY_INDEX]; bool read_uv=false; @@ -687,7 +687,7 @@ void BakedLight::_bake_add_mesh(const Transform& p_xform,Ref& p_mesh) { if (index.size()) { int facecount = index.size()/3; - DVector::Read ir=index.read(); + PoolVector::Read ir=index.read(); for(int j=0;j& p_mesh,bo continue; //only triangles Array a = p_mesh->surface_get_arrays(i); - DVector vertices = a[Mesh::ARRAY_VERTEX]; + PoolVector vertices = a[Mesh::ARRAY_VERTEX]; int vc = vertices.size(); - DVector::Read vr=vertices.read(); + PoolVector::Read vr=vertices.read(); if (first) { bounds.pos=p_xform.xform(vr[0]); @@ -827,7 +827,7 @@ void BakedLight::bake() { _fixup_plot(0, 0,0,0,0); - bake_cells_write=DVector::Write(); + bake_cells_write=PoolVector::Write(); bake_cells.resize(bake_cells_used); @@ -1005,7 +1005,7 @@ void BakedLight::bake_lights() { _upscale_light(0,0); - bake_cells_write=DVector::Write(); + bake_cells_write=PoolVector::Write(); } @@ -1371,7 +1371,7 @@ void BakedLight::bake_radiance() { _bake_radiance(0,0,0,0,0); - bake_cells_write=DVector::Write(); + bake_cells_write=PoolVector::Write(); } int BakedLight::_find_cell(int x,int y, int z) { @@ -1538,9 +1538,9 @@ AABB BakedLight::get_aabb() const { return AABB(Vector3(0,0,0),Vector3(1,1,1)); } -DVector BakedLight::get_faces(uint32_t p_usage_flags) const { +PoolVector BakedLight::get_faces(uint32_t p_usage_flags) const { - return DVector(); + return PoolVector(); } @@ -1621,8 +1621,8 @@ void BakedLight::create_debug_mesh(DebugMode p_mode) { Array arr; arr.resize(Mesh::ARRAY_MAX); - DVector vertices; - DVector colors; + PoolVector vertices; + PoolVector colors; int vtx_idx=0; #define ADD_VTX(m_idx);\ diff --git a/scene/3d/baked_light_instance.h b/scene/3d/baked_light_instance.h index d097a9af60e..461b3adeff1 100644 --- a/scene/3d/baked_light_instance.h +++ b/scene/3d/baked_light_instance.h @@ -107,8 +107,8 @@ private: int bake_cells_used; int zero_alphas; Vector bake_cells_level_used; - DVector bake_cells; - DVector::Write bake_cells_write; + PoolVector bake_cells; + PoolVector::Write bake_cells_write; @@ -157,7 +157,7 @@ public: void create_debug_mesh(DebugMode p_mode); virtual AABB get_aabb() const; - virtual DVector get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; String get_configuration_warning() const; @@ -192,7 +192,7 @@ protected: public: virtual AABB get_aabb() const; - virtual DVector get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; void set_param(Param p_param,float p_value); float get_param(Param p_param) const; diff --git a/scene/3d/body_shape.cpp b/scene/3d/body_shape.cpp index 0f71933388a..ff8b0f15bfe 100644 --- a/scene/3d/body_shape.cpp +++ b/scene/3d/body_shape.cpp @@ -83,8 +83,8 @@ void CollisionShape::_update_indicator() { if (shape.is_null()) return; - DVector points; - DVector normals; + PoolVector points; + PoolVector normals; VS::PrimitiveType pt = VS::PRIMITIVE_TRIANGLES; @@ -235,7 +235,7 @@ void CollisionShape::_update_indicator() { CapsuleShape *shapeptr=shape->cast_to(); - DVector planes = Geometry::build_capsule_planes(shapeptr->get_radius(), shapeptr->get_height()/2.0, 12, Vector3::AXIS_Z); + PoolVector planes = Geometry::build_capsule_planes(shapeptr->get_radius(), shapeptr->get_height()/2.0, 12, Vector3::AXIS_Z); Geometry::MeshData md = Geometry::build_convex_mesh(planes); for(int i=0;ipoly_clear(p_indicator); Color col(0.4,1.0,1.0,0.5); - DVector planes = Geometry::build_cylinder_planes(radius, height, 12, Vector3::AXIS_Z); + PoolVector planes = Geometry::build_cylinder_planes(radius, height, 12, Vector3::AXIS_Z); Geometry::MeshData md = Geometry::build_convex_mesh(planes); for(int i=0;ipoly_clear(p_indicator); Color col(0.4,1.0,1.0,0.5); - DVector planes = Geometry::build_capsule_planes(radius, height, 12, 3, Vector3::AXIS_Z); + PoolVector planes = Geometry::build_capsule_planes(radius, height, 12, 3, Vector3::AXIS_Z); Geometry::MeshData md = Geometry::build_convex_mesh(planes); for(int i=0;iget_shape_count(); for(int i=0;i convex = memnew( ConvexPolygonShape ); - DVector cp; + PoolVector cp; int cs = decomp[i].size(); cp.resize(cs*2); { - DVector::Write w = cp.write(); + PoolVector::Write w = cp.write(); int idx=0; for(int j=0;j concave = memnew( ConcavePolygonShape ); - DVector segments; + PoolVector segments; segments.resize(polygon.size()*2); - DVector::Write w=segments.write(); + PoolVector::Write w=segments.write(); for(int i=0;i::Write(); + w=PoolVector::Write(); concave->set_segments(segments); co->add_shape(concave,get_transform()); diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 19c67faa398..5b51273d0e6 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -37,12 +37,12 @@ Transform GIProbeData::get_to_cell_xform() const { } -void GIProbeData::set_dynamic_data(const DVector& p_data){ +void GIProbeData::set_dynamic_data(const PoolVector& p_data){ VS::get_singleton()->gi_probe_set_dynamic_data(probe,p_data); } -DVector GIProbeData::get_dynamic_data() const{ +PoolVector GIProbeData::get_dynamic_data() const{ return VS::get_singleton()->gi_probe_get_dynamic_data(probe); } @@ -832,7 +832,7 @@ Vector GIProbe::_get_bake_texture(Image &p_image,const Color& p_color) { p_image.resize(bake_texture_size,bake_texture_size,Image::INTERPOLATE_CUBIC); - DVector::Read r = p_image.get_data().read(); + PoolVector::Read r = p_image.get_data().read(); ret.resize(bake_texture_size*bake_texture_size); for(int i=0;i& p_mesh, Baker *p_b Array a = p_mesh->surface_get_arrays(i); - DVector vertices = a[Mesh::ARRAY_VERTEX]; - DVector::Read vr=vertices.read(); - DVector uv = a[Mesh::ARRAY_TEX_UV]; - DVector::Read uvr; - DVector index = a[Mesh::ARRAY_INDEX]; + PoolVector vertices = a[Mesh::ARRAY_VERTEX]; + PoolVector::Read vr=vertices.read(); + PoolVector uv = a[Mesh::ARRAY_TEX_UV]; + PoolVector::Read uvr; + PoolVector index = a[Mesh::ARRAY_INDEX]; bool read_uv=false; @@ -936,7 +936,7 @@ void GIProbe::_plot_mesh(const Transform& p_xform, Ref& p_mesh, Baker *p_b if (index.size()) { int facecount = index.size()/3; - DVector::Read ir=index.read(); + PoolVector::Read ir=index.read(); for(int j=0;j data; + PoolVector data; data.resize( 16+(8+1+1+1+1)*baker.bake_cells.size() ); //4 for header, rest for rest. { - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); uint32_t * w32 = (uint32_t*)w.ptr(); @@ -1247,8 +1247,8 @@ void GIProbe::_create_debug_mesh(Baker *p_baker) { Array arr; arr.resize(Mesh::ARRAY_MAX); - DVector vertices; - DVector colors; + PoolVector vertices; + PoolVector colors; int vtx_idx=0; #define ADD_VTX(m_idx);\ @@ -1333,9 +1333,9 @@ AABB GIProbe::get_aabb() const { return AABB(-extents,extents*2); } -DVector GIProbe::get_faces(uint32_t p_usage_flags) const { +PoolVector GIProbe::get_faces(uint32_t p_usage_flags) const { - return DVector(); + return PoolVector(); } void GIProbe::_bind_methods() { diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index 4b06c132686..55cde2960ad 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -26,8 +26,8 @@ public: void set_to_cell_xform(const Transform& p_xform); Transform get_to_cell_xform() const; - void set_dynamic_data(const DVector& p_data); - DVector get_dynamic_data() const; + void set_dynamic_data(const PoolVector& p_data); + PoolVector get_dynamic_data() const; void set_dynamic_range(int p_range); int get_dynamic_range() const; @@ -179,7 +179,7 @@ public: void bake(Node *p_from_node=NULL,bool p_create_visual_debug=false); virtual AABB get_aabb() const; - virtual DVector get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; GIProbe(); ~GIProbe(); diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp index 4ee2e646e65..ee200cb3eab 100644 --- a/scene/3d/immediate_geometry.cpp +++ b/scene/3d/immediate_geometry.cpp @@ -96,9 +96,9 @@ AABB ImmediateGeometry::get_aabb() const { return aabb; } -DVector ImmediateGeometry::get_faces(uint32_t p_usage_flags) const { +PoolVector ImmediateGeometry::get_faces(uint32_t p_usage_flags) const { - return DVector(); + return PoolVector(); } diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h index 3c8a76fbc7e..bf624e67fde 100644 --- a/scene/3d/immediate_geometry.h +++ b/scene/3d/immediate_geometry.h @@ -67,7 +67,7 @@ public: virtual AABB get_aabb() const; - virtual DVector get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; ImmediateGeometry(); ~ImmediateGeometry(); diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 84a6fecf5e8..ba3c63c403b 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -135,9 +135,9 @@ AABB Light::get_aabb() const { return AABB(); } -DVector Light::get_faces(uint32_t p_usage_flags) const { +PoolVector Light::get_faces(uint32_t p_usage_flags) const { - return DVector(); + return PoolVector(); } diff --git a/scene/3d/light.h b/scene/3d/light.h index d3585b5cf29..3481d0229c6 100644 --- a/scene/3d/light.h +++ b/scene/3d/light.h @@ -118,7 +118,7 @@ public: virtual AABB get_aabb() const; - virtual DVector get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; Light(); ~Light(); diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index ef633ac301f..5b12f80d5c6 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -177,13 +177,13 @@ AABB MeshInstance::get_aabb() const { return AABB(); } -DVector MeshInstance::get_faces(uint32_t p_usage_flags) const { +PoolVector MeshInstance::get_faces(uint32_t p_usage_flags) const { if (!(p_usage_flags&(FACES_SOLID|FACES_ENCLOSING))) - return DVector(); + return PoolVector(); if (mesh.is_null()) - return DVector(); + return PoolVector(); return mesh->get_faces(); } diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h index 92f181c24eb..1291d6b12fe 100644 --- a/scene/3d/mesh_instance.h +++ b/scene/3d/mesh_instance.h @@ -81,7 +81,7 @@ public: void create_convex_collision(); virtual AABB get_aabb() const; - virtual DVector get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; MeshInstance(); ~MeshInstance(); diff --git a/scene/3d/multimesh_instance.cpp b/scene/3d/multimesh_instance.cpp index 44cd7485ca8..a9d1de1cfa2 100644 --- a/scene/3d/multimesh_instance.cpp +++ b/scene/3d/multimesh_instance.cpp @@ -58,9 +58,9 @@ Ref MultiMeshInstance::get_multimesh() const { -DVector MultiMeshInstance::get_faces(uint32_t p_usage_flags) const { +PoolVector MultiMeshInstance::get_faces(uint32_t p_usage_flags) const { - return DVector(); + return PoolVector(); } AABB MultiMeshInstance::get_aabb() const { diff --git a/scene/3d/multimesh_instance.h b/scene/3d/multimesh_instance.h index 503f5e75fc0..ef2403a44a7 100644 --- a/scene/3d/multimesh_instance.h +++ b/scene/3d/multimesh_instance.h @@ -49,7 +49,7 @@ protected: public: - virtual DVector get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; void set_multimesh(const Ref& p_multimesh); Ref get_multimesh() const; diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp index 598a935e4bd..40666a60dcd 100644 --- a/scene/3d/navigation.cpp +++ b/scene/3d/navigation.cpp @@ -36,12 +36,12 @@ void Navigation::_navmesh_link(int p_id) { print_line("LINK"); - DVector vertices=nm.navmesh->get_vertices(); + PoolVector vertices=nm.navmesh->get_vertices(); int len = vertices.size(); if (len==0) return; - DVector::Read r=vertices.read(); + PoolVector::Read r=vertices.read(); for(int i=0;iget_polygon_count();i++) { diff --git a/scene/3d/navigation_mesh.cpp b/scene/3d/navigation_mesh.cpp index 9ed3b4147ac..7ec9085e308 100644 --- a/scene/3d/navigation_mesh.cpp +++ b/scene/3d/navigation_mesh.cpp @@ -33,7 +33,7 @@ void NavigationMesh::create_from_mesh(const Ref& p_mesh) { - vertices=DVector(); + vertices=PoolVector(); clear_polygons(); for(int i=0;iget_surface_count();i++) { @@ -41,15 +41,15 @@ void NavigationMesh::create_from_mesh(const Ref& p_mesh) { if (p_mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES) continue; Array arr = p_mesh->surface_get_arrays(i); - DVector varr = arr[Mesh::ARRAY_VERTEX]; - DVector iarr = arr[Mesh::ARRAY_INDEX]; + PoolVector varr = arr[Mesh::ARRAY_VERTEX]; + PoolVector iarr = arr[Mesh::ARRAY_INDEX]; if (varr.size()==0 || iarr.size()==0) continue; int from = vertices.size(); vertices.append_array(varr); int rlen = iarr.size(); - DVector::Read r = iarr.read(); + PoolVector::Read r = iarr.read(); for(int j=0;j vi; @@ -63,12 +63,12 @@ void NavigationMesh::create_from_mesh(const Ref& p_mesh) { } } -void NavigationMesh::set_vertices(const DVector& p_vertices) { +void NavigationMesh::set_vertices(const PoolVector& p_vertices) { vertices=p_vertices; } -DVector NavigationMesh::get_vertices() const{ +PoolVector NavigationMesh::get_vertices() const{ return vertices; } @@ -122,8 +122,8 @@ Ref NavigationMesh::get_debug_mesh() { - DVector vertices = get_vertices(); - DVector::Read vr=vertices.read(); + PoolVector vertices = get_vertices(); + PoolVector::Read vr=vertices.read(); List faces; for(int i=0;i p = get_polygon(i); @@ -140,11 +140,11 @@ Ref NavigationMesh::get_debug_mesh() { Map<_EdgeKey,bool> edge_map; - DVector tmeshfaces; + PoolVector tmeshfaces; tmeshfaces.resize(faces.size()*3); { - DVector::Write tw=tmeshfaces.write(); + PoolVector::Write tw=tmeshfaces.write(); int tidx=0; @@ -185,10 +185,10 @@ Ref NavigationMesh::get_debug_mesh() { } } - DVector varr; + PoolVector varr; varr.resize(lines.size()); { - DVector::Write w = varr.write(); + PoolVector::Write w = varr.write(); int idx=0; for(List::Element *E=lines.front();E;E=E->next()) { w[idx++]=E->get(); diff --git a/scene/3d/navigation_mesh.h b/scene/3d/navigation_mesh.h index a0bdc5a516a..e025b7ce8be 100644 --- a/scene/3d/navigation_mesh.h +++ b/scene/3d/navigation_mesh.h @@ -38,7 +38,7 @@ class NavigationMesh : public Resource { GDCLASS( NavigationMesh, Resource ); - DVector vertices; + PoolVector vertices; struct Polygon { Vector indices; }; @@ -65,8 +65,8 @@ public: void create_from_mesh(const Ref& p_mesh); - void set_vertices(const DVector& p_vertices); - DVector get_vertices() const; + void set_vertices(const PoolVector& p_vertices); + PoolVector get_vertices() const; void add_polygon(const Vector& p_polygon); int get_polygon_count() const; diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 09be49d7d6d..9e37658cd9f 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -88,9 +88,9 @@ AABB Particles::get_aabb() const { return AABB( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) ); } -DVector Particles::get_faces(uint32_t p_usage_flags) const { +PoolVector Particles::get_faces(uint32_t p_usage_flags) const { - return DVector(); + return PoolVector(); } @@ -130,16 +130,16 @@ AABB Particles::get_visibility_aabb() const { } -void Particles::set_emission_points(const DVector& p_points) { +void Particles::set_emission_points(const PoolVector& p_points) { using_points = p_points.size(); VisualServer::get_singleton()->particles_set_emission_points(particles,p_points); } -DVector Particles::get_emission_points() const { +PoolVector Particles::get_emission_points() const { if (!using_points) - return DVector(); + return PoolVector(); return VisualServer::get_singleton()->particles_get_emission_points(particles); diff --git a/scene/3d/particles.h b/scene/3d/particles.h index 95cf44a0335..b96bd4e69e7 100644 --- a/scene/3d/particles.h +++ b/scene/3d/particles.h @@ -103,7 +103,7 @@ public: AABB get_aabb() const; - DVector get_faces(uint32_t p_usage_flags) const; + PoolVector get_faces(uint32_t p_usage_flags) const; void set_amount(int p_amount); int get_amount() const; @@ -120,8 +120,8 @@ public: void set_emission_base_velocity(const Vector3& p_base_velocity); Vector3 get_emission_base_velocity() const; - void set_emission_points(const DVector& p_points); - DVector get_emission_points() const; + void set_emission_points(const PoolVector& p_points); + PoolVector get_emission_points() const; void set_gravity_normal(const Vector3& p_normal); Vector3 get_gravity_normal() const; diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp index 1de9188e82c..e4c03a78ee3 100644 --- a/scene/3d/portal.cpp +++ b/scene/3d/portal.cpp @@ -34,7 +34,7 @@ bool Portal::_set(const StringName& p_name, const Variant& p_value) { if (p_name=="shape") { - DVector src_coords=p_value; + PoolVector src_coords=p_value; Vector points; int src_coords_size = src_coords.size(); ERR_FAIL_COND_V(src_coords_size%2,false); @@ -63,7 +63,7 @@ bool Portal::_get(const StringName& p_name,Variant &r_ret) const { if (p_name=="shape") { Vector points=get_shape(); - DVector dst_coords; + PoolVector dst_coords; dst_coords.resize(points.size()*2); for (int i=0;i Portal::get_faces(uint32_t p_usage_flags) const { +PoolVector Portal::get_faces(uint32_t p_usage_flags) const { if (!(p_usage_flags&FACES_ENCLOSING)) - return DVector(); + return PoolVector(); Vector shape = get_shape(); if (shape.size()==0) - return DVector(); + return PoolVector(); Vector2 center; for (int i=0;i Portal::get_faces(uint32_t p_usage_flags) const { } - DVector ret; + PoolVector ret; center/=shape.size(); for (int i=0;i get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; void set_enabled(bool p_enabled); bool is_enabled() const; diff --git a/scene/3d/quad.cpp b/scene/3d/quad.cpp index 4ba828f9278..f1c59860af5 100644 --- a/scene/3d/quad.cpp +++ b/scene/3d/quad.cpp @@ -44,9 +44,9 @@ void Quad::_update() { - DVector points; + PoolVector points; points.resize(4); - DVector::Write pointsw = points.write(); + PoolVector::Write pointsw = points.write(); Vector2 s2 = size*0.5; Vector2 o = offset; @@ -70,34 +70,34 @@ void Quad::_update() { for(int i=1;i<4;i++) aabb.expand_to(pointsw[i]); - pointsw = DVector::Write(); + pointsw = PoolVector::Write(); - DVector normals; + PoolVector normals; normals.resize(4); - DVector::Write normalsw = normals.write(); + PoolVector::Write normalsw = normals.write(); for(int i=0;i<4;i++) normalsw[i]=normal; - normalsw=DVector::Write(); + normalsw=PoolVector::Write(); - DVector uvs; + PoolVector uvs; uvs.resize(4); - DVector::Write uvsw = uvs.write(); + PoolVector::Write uvsw = uvs.write(); uvsw[0]=Vector2(0,0); uvsw[1]=Vector2(1,0); uvsw[2]=Vector2(1,1); uvsw[3]=Vector2(0,1); - uvsw = DVector::Write(); + uvsw = PoolVector::Write(); - DVector indices; + PoolVector indices; indices.resize(6); - DVector::Write indicesw = indices.write(); + PoolVector::Write indicesw = indices.write(); indicesw[0]=0; indicesw[1]=1; indicesw[2]=2; @@ -105,7 +105,7 @@ void Quad::_update() { indicesw[4]=3; indicesw[5]=0; - indicesw=DVector::Write(); + indicesw=PoolVector::Write(); Array arr; arr.resize(VS::ARRAY_MAX); @@ -187,9 +187,9 @@ void Quad::_notification(int p_what) { } } -DVector Quad::get_faces(uint32_t p_usage_flags) const { +PoolVector Quad::get_faces(uint32_t p_usage_flags) const { - return DVector(); + return PoolVector(); } AABB Quad::get_aabb() const { diff --git a/scene/3d/quad.h b/scene/3d/quad.h index bdb2cb3088f..94b438c5483 100644 --- a/scene/3d/quad.h +++ b/scene/3d/quad.h @@ -67,7 +67,7 @@ public: void set_centered(bool p_enabled); bool is_centered() const; - virtual DVector get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; virtual AABB get_aabb() const; Quad(); diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index 63855b7e98b..0235a063ead 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -169,9 +169,9 @@ AABB ReflectionProbe::get_aabb() const { aabb.size=origin_offset+extents; return aabb; } -DVector ReflectionProbe::get_faces(uint32_t p_usage_flags) const { +PoolVector ReflectionProbe::get_faces(uint32_t p_usage_flags) const { - return DVector(); + return PoolVector(); } void ReflectionProbe::_validate_property(PropertyInfo& property) const { diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h index 2de02ebbfae..789e5837b04 100644 --- a/scene/3d/reflection_probe.h +++ b/scene/3d/reflection_probe.h @@ -78,7 +78,7 @@ public: UpdateMode get_update_mode() const; virtual AABB get_aabb() const; - virtual DVector get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp index 1423f567866..137a16490d1 100644 --- a/scene/3d/room_instance.cpp +++ b/scene/3d/room_instance.cpp @@ -86,9 +86,9 @@ AABB Room::get_aabb() const { return AABB(); } -DVector Room::get_faces(uint32_t p_usage_flags) const { +PoolVector Room::get_faces(uint32_t p_usage_flags) const { - return DVector(); + return PoolVector(); } @@ -119,21 +119,21 @@ Ref Room::get_room() const { return room; } -void Room::_parse_node_faces(DVector &all_faces,const Node *p_node) const { +void Room::_parse_node_faces(PoolVector &all_faces,const Node *p_node) const { const VisualInstance *vi=p_node->cast_to(); if (vi) { - DVector faces=vi->get_faces(FACES_ENCLOSING); + PoolVector faces=vi->get_faces(FACES_ENCLOSING); if (faces.size()) { int old_len=all_faces.size(); all_faces.resize( all_faces.size() + faces.size() ); int new_len=all_faces.size(); - DVector::Write all_facesw=all_faces.write(); + PoolVector::Write all_facesw=all_faces.write(); Face3 * all_facesptr=all_facesw.ptr(); - DVector::Read facesr=faces.read(); + PoolVector::Read facesr=faces.read(); const Face3 * facesptr=facesr.ptr(); Transform tr=vi->get_relative_transform(this); diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h index 8c2bb76a388..8cdc908ceb0 100644 --- a/scene/3d/room_instance.h +++ b/scene/3d/room_instance.h @@ -63,7 +63,7 @@ private: bool sound_enabled; int level; - void _parse_node_faces(DVector &all_faces,const Node *p_node) const; + void _parse_node_faces(PoolVector &all_faces,const Node *p_node) const; void _bounds_changed(); @@ -83,7 +83,7 @@ public: }; virtual AABB get_aabb() const; - virtual DVector get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; void set_room( const Ref& p_room ); Ref get_room() const; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 576f085120f..5d686e87152 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -211,9 +211,9 @@ AABB SpriteBase3D::get_aabb() const { return aabb; } -DVector SpriteBase3D::get_faces(uint32_t p_usage_flags) const { +PoolVector SpriteBase3D::get_faces(uint32_t p_usage_flags) const { - return DVector(); + return PoolVector(); } diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 58d70fa2f78..f82a3910381 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -135,7 +135,7 @@ public: virtual Rect2 get_item_rect() const=0; virtual AABB get_aabb() const; - virtual DVector get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; SpriteBase3D(); ~SpriteBase3D(); diff --git a/scene/3d/test_cube.cpp b/scene/3d/test_cube.cpp index bd99de417ed..c2ebe63e21f 100644 --- a/scene/3d/test_cube.cpp +++ b/scene/3d/test_cube.cpp @@ -35,9 +35,9 @@ AABB TestCube::get_aabb() const { return AABB( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) ); } -DVector TestCube::get_faces(uint32_t p_usage_flags) const { +PoolVector TestCube::get_faces(uint32_t p_usage_flags) const { - return DVector(); + return PoolVector(); } diff --git a/scene/3d/test_cube.h b/scene/3d/test_cube.h index cbd9918b130..c62999c34b7 100644 --- a/scene/3d/test_cube.h +++ b/scene/3d/test_cube.h @@ -47,7 +47,7 @@ class TestCube : public GeometryInstance { public: virtual AABB get_aabb() const; - virtual DVector get_faces(uint32_t p_usage_flags) const; + virtual PoolVector get_faces(uint32_t p_usage_flags) const; TestCube(); ~TestCube(); diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h index 7b76cd299e9..f59ec3a7e65 100644 --- a/scene/3d/visual_instance.h +++ b/scene/3d/visual_instance.h @@ -66,7 +66,7 @@ public: RID get_instance() const; virtual AABB get_aabb() const=0; - virtual DVector get_faces(uint32_t p_usage_flags) const=0; + virtual PoolVector get_faces(uint32_t p_usage_flags) const=0; virtual AABB get_transformed_aabb() const; // helper diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index c03762549b7..94955bec606 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -208,11 +208,11 @@ private: void _node_removed(Node *p_node); // bind helpers - DVector _get_animation_list() const { + PoolVector _get_animation_list() const { List animations; get_animation_list(&animations); - DVector ret; + PoolVector ret; while(animations.size()) { ret.push_back( animations.front()->get()); diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index 2ed8e52615d..4df37af7a17 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -1740,11 +1740,11 @@ NodePath AnimationTreePlayer::get_master_player() const{ return master; } -DVector AnimationTreePlayer::_get_node_list() { +PoolVector AnimationTreePlayer::_get_node_list() { List nl; get_node_list(&nl); - DVector ret; + PoolVector ret; ret.resize(nl.size()); int idx=0; for(List::Element *E=nl.front();E;E=E->next()) { diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h index 6d9db5dc638..ae2fe8c2bbd 100644 --- a/scene/animation/animation_tree_player.h +++ b/scene/animation/animation_tree_player.h @@ -282,7 +282,7 @@ private: Track* _find_track(const NodePath& p_path); void _recompute_caches(); void _recompute_caches(const StringName& p_node); - DVector _get_node_list(); + PoolVector _get_node_list(); void _compute_weights(float *p_fallback_weight, HashMap *p_weights, float p_coeff, const HashMap *p_filter = NULL, float p_filtered_coeff = 0); diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index ceb3b69f2f2..10f4ae9fec5 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -170,11 +170,11 @@ void ColorPicker::_update_presets() Size2 size=bt_add_preset->get_size(); preset->set_custom_minimum_size(Size2(size.width*presets.size(),size.height)); - DVector img; + PoolVector img; img.resize(size.x*presets.size()*size.y*3); { - DVector::Write w=img.write(); + PoolVector::Write w=img.write(); for (int y=0;y::Read r = last_capture.get_data().read(); + PoolVector::Read r = last_capture.get_data().read(); Color c( r[ofs+0]/255.0, r[ofs+1]/255.0, r[ofs+2]/255.0 ); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 4fe65fad750..6828ae39803 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -164,7 +164,7 @@ void FileDialog::_action_pressed() { TreeItem *ti=tree->get_next_selected(NULL); String fbase=dir_access->get_current_dir(); - DVector files; + PoolVector files; while(ti) { files.push_back( fbase.plus_file(ti->get_text(0)) ); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 397edbf3b64..4ea44a6ead3 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3794,11 +3794,11 @@ int TextEdit::_get_column_pos_of_word(const String &p_key, const String &p_searc return col; } -DVector TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const { +PoolVector TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const { int col,line; if (search(p_key,p_search_flags,p_from_line,p_from_column,col,line)) { - DVector result; + PoolVector result; result.resize(2); result.set(0,line); result.set(1,col); @@ -3806,7 +3806,7 @@ DVector TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags, } else { - return DVector(); + return PoolVector(); } } diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index c674c859e65..2cb3d713864 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -316,7 +316,7 @@ class TextEdit : public Control { int _get_column_pos_of_word(const String &p_key, const String &p_search, uint32_t p_search_flags, int p_from_column); - DVector _search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const; + PoolVector _search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const; PopupMenu *menu; diff --git a/scene/io/resource_format_wav.cpp b/scene/io/resource_format_wav.cpp index 3720aa13fdf..f75836d2dfb 100644 --- a/scene/io/resource_format_wav.cpp +++ b/scene/io/resource_format_wav.cpp @@ -171,9 +171,9 @@ RES ResourceFormatLoaderWAV::load(const String &p_path, const String& p_original if (format_bits>8) len*=2; - DVector data; + PoolVector data; data.resize(len); - DVector::Write dataw = data.write(); + PoolVector::Write dataw = data.write(); void * data_ptr = dataw.ptr(); for (int i=0;i::Write(); + dataw=PoolVector::Write(); sample->set_data(data); diff --git a/scene/main/http_request.h b/scene/main/http_request.h index d4adaa16d47..59be9800779 100644 --- a/scene/main/http_request.h +++ b/scene/main/http_request.h @@ -76,7 +76,7 @@ private: bool got_response; int response_code; - DVector response_headers; + PoolVector response_headers; String download_to_file; diff --git a/scene/main/resource_preloader.cpp b/scene/main/resource_preloader.cpp index 57bda91494d..93a836a2eb1 100644 --- a/scene/main/resource_preloader.cpp +++ b/scene/main/resource_preloader.cpp @@ -33,7 +33,7 @@ void ResourcePreloader::_set_resources(const Array& p_data) { resources.clear(); ERR_FAIL_COND(p_data.size()!=2); - DVector names=p_data[0]; + PoolVector names=p_data[0]; Array resdata=p_data[1]; ERR_FAIL_COND(names.size()!=resdata.size()); @@ -52,7 +52,7 @@ void ResourcePreloader::_set_resources(const Array& p_data) { Array ResourcePreloader::_get_resources() const { - DVector names; + PoolVector names; Array arr; arr.resize(resources.size()); names.resize(resources.size()); @@ -139,9 +139,9 @@ RES ResourcePreloader::get_resource(const StringName& p_name) const { return resources[p_name]; } -DVector ResourcePreloader::_get_resource_list() const { +PoolVector ResourcePreloader::_get_resource_list() const { - DVector res; + PoolVector res; res.resize(resources.size()); int i=0; for(Map::Element *E=resources.front();E;E=E->next(),i++) { diff --git a/scene/main/resource_preloader.h b/scene/main/resource_preloader.h index 8f4f997ceec..4e585d17511 100644 --- a/scene/main/resource_preloader.h +++ b/scene/main/resource_preloader.h @@ -41,7 +41,7 @@ class ResourcePreloader : public Node { void _set_resources(const Array& p_data); Array _get_resources() const; - DVector _get_resource_list() const; + PoolVector _get_resource_list() const; protected: diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index af6d6b18db4..a6ef136b842 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -831,11 +831,11 @@ Ref SceneTree::get_debug_contact_mesh() { 1,3,5, }; - DVector indices; + PoolVector indices; for(int i=0;i<8*3;i++) indices.push_back(diamond_faces[i]); - DVector vertices; + PoolVector vertices; for(int i=0;i<6;i++) vertices.push_back(diamond[i]*0.1); diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index b5c438d9537..76c6f29bcb1 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -79,14 +79,14 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) { if (track_get_type(track)==TYPE_TRANSFORM) { TransformTrack *tt = static_cast(tracks[track]); - DVector values=p_value; + PoolVector values=p_value; int vcount=values.size(); #if 0 // old compatibility hack if ((vcount%11) == 0) { - DVector::Read r = values.read(); + PoolVector::Read r = values.read(); tt->transforms.resize(vcount/11); @@ -121,7 +121,7 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) { #endif ERR_FAIL_COND_V(vcount%12,false); // shuld be multiple of 11 - DVector::Read r = values.read(); + PoolVector::Read r = values.read(); tt->transforms.resize(vcount/12); @@ -172,7 +172,7 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) { - DVector times=d["times"]; + PoolVector times=d["times"]; Array values=d["values"]; ERR_FAIL_COND_V(times.size()!=values.size(),false); @@ -181,7 +181,7 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) { int valcount=times.size(); - DVector::Read rt = times.read(); + PoolVector::Read rt = times.read(); vt->values.resize(valcount); @@ -193,10 +193,10 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) { if (d.has("transitions")) { - DVector transitions = d["transitions"]; + PoolVector transitions = d["transitions"]; ERR_FAIL_COND_V(transitions.size()!=valcount,false); - DVector::Read rtr = transitions.read(); + PoolVector::Read rtr = transitions.read(); for(int i=0;i times=d["times"]; + PoolVector times=d["times"]; Array values=d["values"]; ERR_FAIL_COND_V(times.size()!=values.size(),false); @@ -227,7 +227,7 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) { int valcount=times.size(); - DVector::Read rt = times.read(); + PoolVector::Read rt = times.read(); for(int i=0;i transitions = d["transitions"]; + PoolVector transitions = d["transitions"]; ERR_FAIL_COND_V(transitions.size()!=valcount,false); - DVector::Read rtr = transitions.read(); + PoolVector::Read rtr = transitions.read(); for(int i=0;i keys; + PoolVector keys; int kk=track_get_key_count(track); keys.resize(kk*12); - DVector::Write w = keys.write(); + PoolVector::Write w = keys.write(); int idx=0; for(int i=0;i::Write(); + w = PoolVector::Write(); r_ret=keys; return true; @@ -338,8 +338,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { Dictionary d; - DVector key_times; - DVector key_transitions; + PoolVector key_times; + PoolVector key_transitions; Array key_values; int kk=vt->values.size(); @@ -348,8 +348,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { key_transitions.resize(kk); key_values.resize(kk); - DVector::Write wti=key_times.write(); - DVector::Write wtr=key_transitions.write(); + PoolVector::Write wti=key_times.write(); + PoolVector::Write wtr=key_transitions.write(); int idx=0; @@ -363,8 +363,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { idx++; } - wti=DVector::Write(); - wtr=DVector::Write(); + wti=PoolVector::Write(); + wtr=PoolVector::Write(); d["times"]=key_times; d["transitions"]=key_transitions; @@ -382,8 +382,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { Dictionary d; - DVector key_times; - DVector key_transitions; + PoolVector key_times; + PoolVector key_transitions; Array key_values; int kk=track_get_key_count(track); @@ -392,8 +392,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { key_transitions.resize(kk); key_values.resize(kk); - DVector::Write wti=key_times.write(); - DVector::Write wtr=key_transitions.write(); + PoolVector::Write wti=key_times.write(); + PoolVector::Write wtr=key_transitions.write(); int idx=0; for(int i=0;i::Write(); - wtr=DVector::Write(); + wti=PoolVector::Write(); + wtr=PoolVector::Write(); d["times"]=key_times; d["transitions"]=key_transitions; diff --git a/scene/resources/animation.h b/scene/resources/animation.h index 90824d8c7b8..c236b3ef374 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -188,11 +188,11 @@ private: return ret; } - DVector _value_track_get_key_indices(int p_track, float p_time, float p_delta) const { + PoolVector _value_track_get_key_indices(int p_track, float p_time, float p_delta) const { List idxs; value_track_get_key_indices(p_track,p_time,p_delta,&idxs); - DVector idxr; + PoolVector idxr; for (List::Element *E=idxs.front();E;E=E->next()) { @@ -200,11 +200,11 @@ private: } return idxr; } - DVector _method_track_get_key_indices(int p_track, float p_time, float p_delta) const { + PoolVector _method_track_get_key_indices(int p_track, float p_time, float p_delta) const { List idxs; method_track_get_key_indices(p_track,p_time,p_delta,&idxs); - DVector idxr; + PoolVector idxr; for (List::Element *E=idxs.front();E;E=E->next()) { diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp index 81ba28fd261..d669ab771cb 100644 --- a/scene/resources/bit_mask.cpp +++ b/scene/resources/bit_mask.cpp @@ -51,7 +51,7 @@ void BitMap::create_from_image_alpha(const Image& p_image){ create(Size2(img.get_width(),img.get_height())); - DVector::Read r = img.get_data().read(); + PoolVector::Read r = img.get_data().read(); uint8_t *w = bitmask.ptr(); for(int i=0;i ConcavePolygonShape::_gen_debug_mesh_lines() { Set edges; - DVector data=get_faces(); + PoolVector data=get_faces(); int datalen=data.size(); ERR_FAIL_COND_V( (datalen%3)!=0,Vector() ); - DVector::Read r=data.read(); + PoolVector::Read r=data.read(); for(int i=0;i& p_faces) { +void ConcavePolygonShape::set_faces(const PoolVector& p_faces) { PhysicsServer::get_singleton()->shape_set_data(get_shape(),p_faces); notify_change_to_owners(); } -DVector ConcavePolygonShape::get_faces() const { +PoolVector ConcavePolygonShape::get_faces() const { return PhysicsServer::get_singleton()->shape_get_data(get_shape()); diff --git a/scene/resources/concave_polygon_shape.h b/scene/resources/concave_polygon_shape.h index 08d95da0ac8..36e806d37aa 100644 --- a/scene/resources/concave_polygon_shape.h +++ b/scene/resources/concave_polygon_shape.h @@ -67,8 +67,8 @@ protected: virtual Vector _gen_debug_mesh_lines(); public: - void set_faces(const DVector& p_faces); - DVector get_faces() const; + void set_faces(const PoolVector& p_faces); + PoolVector get_faces() const; ConcavePolygonShape(); diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp index 4be95cb26d1..e794643132f 100644 --- a/scene/resources/concave_polygon_shape_2d.cpp +++ b/scene/resources/concave_polygon_shape_2d.cpp @@ -31,13 +31,13 @@ #include "servers/physics_2d_server.h" #include "servers/visual_server.h" -void ConcavePolygonShape2D::set_segments(const DVector& p_segments) { +void ConcavePolygonShape2D::set_segments(const PoolVector& p_segments) { Physics2DServer::get_singleton()->shape_set_data(get_rid(),p_segments); emit_changed(); } -DVector ConcavePolygonShape2D::get_segments() const { +PoolVector ConcavePolygonShape2D::get_segments() const { return Physics2DServer::get_singleton()->shape_get_data(get_rid()); } @@ -45,12 +45,12 @@ DVector ConcavePolygonShape2D::get_segments() const { void ConcavePolygonShape2D::draw(const RID& p_to_rid,const Color& p_color) { - DVector s = get_segments(); + PoolVector s = get_segments(); int len=s.size(); if (len==0 || (len%2)==1) return; - DVector::Read r = s.read(); + PoolVector::Read r = s.read(); for(int i=0;icanvas_item_add_line(p_to_rid,r[i],r[i+1],p_color,2); } @@ -60,14 +60,14 @@ void ConcavePolygonShape2D::draw(const RID& p_to_rid,const Color& p_color) { Rect2 ConcavePolygonShape2D::get_rect() const { - DVector s = get_segments(); + PoolVector s = get_segments(); int len=s.size(); if (len==0) return Rect2(); Rect2 rect; - DVector::Read r = s.read(); + PoolVector::Read r = s.read(); for(int i=0;i& p_segments); - DVector get_segments() const; + void set_segments(const PoolVector& p_segments); + PoolVector get_segments() const; virtual void draw(const RID& p_to_rid,const Color& p_color); virtual Rect2 get_rect() const ; diff --git a/scene/resources/convex_polygon_shape.cpp b/scene/resources/convex_polygon_shape.cpp index 21e93e4b5c5..ca9897bf97e 100644 --- a/scene/resources/convex_polygon_shape.cpp +++ b/scene/resources/convex_polygon_shape.cpp @@ -32,7 +32,7 @@ Vector ConvexPolygonShape::_gen_debug_mesh_lines() { - DVector points = get_points(); + PoolVector points = get_points(); if (points.size()>3) { @@ -64,14 +64,14 @@ void ConvexPolygonShape::_update_shape() { emit_changed(); } -void ConvexPolygonShape::set_points(const DVector& p_points) { +void ConvexPolygonShape::set_points(const PoolVector& p_points) { points=p_points; _update_shape(); notify_change_to_owners(); } -DVector ConvexPolygonShape::get_points() const { +PoolVector ConvexPolygonShape::get_points() const { return points; } diff --git a/scene/resources/convex_polygon_shape.h b/scene/resources/convex_polygon_shape.h index 296a0ce4caa..215de941c68 100644 --- a/scene/resources/convex_polygon_shape.h +++ b/scene/resources/convex_polygon_shape.h @@ -34,7 +34,7 @@ class ConvexPolygonShape : public Shape { GDCLASS(ConvexPolygonShape,Shape); - DVector points; + PoolVector points; protected: @@ -45,8 +45,8 @@ protected: virtual Vector _gen_debug_mesh_lines(); public: - void set_points(const DVector& p_points); - DVector get_points() const; + void set_points(const PoolVector& p_points); + PoolVector get_points() const; ConvexPolygonShape(); }; diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index fd0e9be3043..50c546b8550 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -143,17 +143,17 @@ Vector2 Curve2D::interpolatef(real_t p_findex) const { } -DVector Curve2D::bake(int p_subdivs) const { +PoolVector Curve2D::bake(int p_subdivs) const { int pc = points.size(); - DVector ret; + PoolVector ret; if (pc<2) return ret; ret.resize((pc-1)*p_subdivs+1); - DVector::Write w = ret.write(); + PoolVector::Write w = ret.write(); const Point *r = points.ptr(); for(int i=0;i Curve2D::bake(int p_subdivs) const { } } - w = DVector::Write(); + w = PoolVector::Write(); return ret; } diff --git a/scene/resources/curve.h b/scene/resources/curve.h index 289de504442..670232c9b27 100644 --- a/scene/resources/curve.h +++ b/scene/resources/curve.h @@ -72,7 +72,7 @@ public: Vector2 interpolate(int p_index, float p_offset) const; Vector2 interpolatef(real_t p_findex) const; - DVector bake(int p_subdivs=10) const; + PoolVector bake(int p_subdivs=10) const; void advance(real_t p_distance,int &r_index, real_t &r_pos) const; void get_approx_position_from_offset(real_t p_offset,int &r_index, real_t &r_pos,int p_subdivs=16) const; diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 7ab7cc74e5b..3aadbdbe19e 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -535,7 +535,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { { //zero texture - DVector::Write w = tex.imgdata.write(); + PoolVector::Write w = tex.imgdata.write(); ERR_FAIL_COND(texsize*texsize*2 > tex.imgdata.size()); for(int i=0;i::Write wr = tex.imgdata.write(); + PoolVector::Write wr = tex.imgdata.write(); for(int i=0;i imgdata; + PoolVector imgdata; int texture_size; Vector offsets; Ref texture; diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp index c931b4d6c86..a25667d85a9 100644 --- a/scene/resources/dynamic_font_stb.cpp +++ b/scene/resources/dynamic_font_stb.cpp @@ -26,10 +26,10 @@ void DynamicFontData::lock() { void DynamicFontData::unlock() { - fr = DVector::Read(); + fr = PoolVector::Read(); } -void DynamicFontData::set_font_data(const DVector& p_font) { +void DynamicFontData::set_font_data(const PoolVector& p_font) { //clear caches and stuff ERR_FAIL_COND(font_data.size()) ; font_data=p_font; @@ -284,7 +284,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { { //zero texture - DVector::Write w = tex.imgdata.write(); + PoolVector::Write w = tex.imgdata.write(); ERR_FAIL_COND(texsize*texsize*2 > tex.imgdata.size()); for(int i=0;i::Write wr = tex.imgdata.write(); + PoolVector::Write wr = tex.imgdata.write(); for(int i=0;i data; + PoolVector data; data.resize(f->get_len()); ERR_FAIL_COND_V(data.size()==0,RES()); { - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); f->get_buffer(w.ptr(),data.size()); } diff --git a/scene/resources/dynamic_font_stb.h b/scene/resources/dynamic_font_stb.h index ad7ca0009dc..07a3e5ee6cc 100644 --- a/scene/resources/dynamic_font_stb.h +++ b/scene/resources/dynamic_font_stb.h @@ -18,8 +18,8 @@ class DynamicFontData : public Resource { bool valid; - DVector font_data; - DVector::Read fr; + PoolVector font_data; + PoolVector::Read fr; const uint8_t* last_data_ptr; struct KerningPairKey { @@ -56,7 +56,7 @@ friend class DynamicFont; Ref _get_dynamic_font_at_size(int p_size); public: - void set_font_data(const DVector& p_font); + void set_font_data(const PoolVector& p_font); DynamicFontData(); ~DynamicFontData(); }; @@ -71,7 +71,7 @@ class DynamicFontAtSize : public Reference { struct CharTexture { - DVector imgdata; + PoolVector imgdata; int texture_size; Vector offsets; Ref texture; diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index d4e18c58b80..0464a640314 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -97,7 +97,7 @@ Font::Font() { ///////////////////////////////////////////////////////////////// -void BitmapFont::_set_chars(const DVector& p_chars) { +void BitmapFont::_set_chars(const PoolVector& p_chars) { int len = p_chars.size(); //char 1 charsize 1 texture, 4 rect, 2 align, advance 1 @@ -107,7 +107,7 @@ void BitmapFont::_set_chars(const DVector& p_chars) { int chars = len/9; - DVector::Read r=p_chars.read(); + PoolVector::Read r=p_chars.read(); for(int i=0;i& p_chars) { } -DVector BitmapFont::_get_chars() const { +PoolVector BitmapFont::_get_chars() const { - DVector chars; + PoolVector chars; const CharType* key=NULL; @@ -140,13 +140,13 @@ DVector BitmapFont::_get_chars() const { return chars; } -void BitmapFont::_set_kernings(const DVector& p_kernings) { +void BitmapFont::_set_kernings(const PoolVector& p_kernings) { int len=p_kernings.size(); ERR_FAIL_COND(len%3); if (!len) return; - DVector::Read r=p_kernings.read(); + PoolVector::Read r=p_kernings.read(); for(int i=0;i& p_kernings) { } } -DVector BitmapFont::_get_kernings() const { +PoolVector BitmapFont::_get_kernings() const { - DVector kernings; + PoolVector kernings; for(Map::Element *E=kerning_map.front();E;E=E->next()) { diff --git a/scene/resources/font.h b/scene/resources/font.h index 397d48cbb00..ad0f0176dbd 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -109,10 +109,10 @@ private: float ascent; bool distance_field_hint; - void _set_chars(const DVector& p_chars); - DVector _get_chars() const; - void _set_kernings(const DVector& p_kernings); - DVector _get_kernings() const; + void _set_chars(const PoolVector& p_chars); + PoolVector _get_chars() const; + void _set_kernings(const PoolVector& p_kernings); + PoolVector _get_kernings() const; void _set_textures(const Vector & p_textures); Vector _get_textures() const; diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index ed35eb02160..bad87910ffe 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -79,9 +79,9 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) { if (p_name=="morph_target/names") { - DVector sk=p_value; + PoolVector sk=p_value; int sz = sk.size(); - DVector::Read r = sk.read(); + PoolVector::Read r = sk.read(); for(int i=0;i array_data = d["array_data"]; - DVector array_index_data; + PoolVector array_data = d["array_data"]; + PoolVector array_index_data; if (d.has("array_index_data")) array_index_data=d["array_index_data"]; @@ -151,12 +151,12 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) { if (d.has("index_count")) index_count=d["index_count"]; - Vector< DVector > morphs; + Vector< PoolVector > morphs; if (d.has("morph_data")) { Array morph_data=d["morph_data"]; for(int i=0;i morph = morph_data[i]; + PoolVector morph = morph_data[i]; morphs.push_back(morph_data[i]); } } @@ -201,7 +201,7 @@ bool Mesh::_get(const StringName& p_name,Variant &r_ret) const { if (p_name=="morph_target/names") { - DVector sk; + PoolVector sk; for(int i=0;i > morph_data = VS::get_singleton()->mesh_surface_get_blend_shapes(mesh,idx); + Vector< PoolVector > morph_data = VS::get_singleton()->mesh_surface_get_blend_shapes(mesh,idx); Array md; for(int i=0;i& p_array,int p_vertex_count,const DVector& p_index_array,int p_index_count,const AABB& p_aabb,const Vector >& p_blend_shapes,const Vector& p_bone_aabbs) { +void Mesh::add_surface(uint32_t p_format,PrimitiveType p_primitive,const PoolVector& p_array,int p_vertex_count,const PoolVector& p_index_array,int p_index_count,const AABB& p_aabb,const Vector >& p_blend_shapes,const Vector& p_bone_aabbs) { Surface s; s.aabb=p_aabb; @@ -330,10 +330,10 @@ void Mesh::add_surface_from_arrays(PrimitiveType p_primitive,const Array& p_arra /* make aABB? */ { - DVector vertices=p_arrays[ARRAY_VERTEX]; + PoolVector vertices=p_arrays[ARRAY_VERTEX]; int len=vertices.size(); ERR_FAIL_COND(len==0); - DVector::Read r=vertices.read(); + PoolVector::Read r=vertices.read(); const Vector3 *vtx=r.ptr(); // check AABB @@ -569,21 +569,21 @@ AABB Mesh::get_custom_aabb() const { } -DVector Mesh::get_faces() const { +PoolVector Mesh::get_faces() const { Ref tm = generate_triangle_mesh(); if (tm.is_valid()) return tm->get_faces(); - return DVector(); + return PoolVector(); /* for (int i=0;imesh_surface_get_primitive_type( mesh, i ) != VisualServer::PRIMITIVE_TRIANGLES ) continue; - DVector indices; - DVector vertices; + PoolVector indices; + PoolVector vertices; vertices=VisualServer::get_singleton()->mesh_surface_get_array(mesh, i,VisualServer::ARRAY_VERTEX); @@ -604,10 +604,10 @@ DVector Mesh::get_faces() const { if (len<=0) continue; - DVector::Read indicesr = indices.read(); + PoolVector::Read indicesr = indices.read(); const int *indicesptr = indicesr.ptr(); - DVector::Read verticesr = vertices.read(); + PoolVector::Read verticesr = vertices.read(); const Vector3 *verticesptr = verticesr.ptr(); int old_faces=faces.size(); @@ -615,7 +615,7 @@ DVector Mesh::get_faces() const { faces.resize(new_faces); - DVector::Write facesw = faces.write(); + PoolVector::Write facesw = faces.write(); Face3 *facesptr=facesw.ptr(); @@ -639,12 +639,12 @@ DVector Mesh::get_faces() const { Ref Mesh::create_convex_shape() const { - DVector vertices; + PoolVector vertices; for(int i=0;i v=a[ARRAY_VERTEX]; + PoolVector v=a[ARRAY_VERTEX]; vertices.append_array(v); } @@ -656,11 +656,11 @@ Ref Mesh::create_convex_shape() const { Ref Mesh::create_trimesh_shape() const { - DVector faces = get_faces(); + PoolVector faces = get_faces(); if (faces.size()==0) return Ref(); - DVector face_points; + PoolVector face_points; face_points.resize( faces.size()*3 ); for (int i=0;i geom = surface_get_array(i,ARRAY_VERTEX); + PoolVector geom = surface_get_array(i,ARRAY_VERTEX); int gc =geom.size(); - DVector::Write w = geom.write(); + PoolVector::Write w = geom.write(); surfaces[i].aabb.pos-=ofs; for(int i=0;i::Write(); + w = PoolVector::Write(); surface_set_array(i,ARRAY_VERTEX,geom); @@ -752,9 +752,9 @@ Ref Mesh::generate_triangle_mesh() const { if (facecount==0 || (facecount%3)!=0) return triangle_mesh; - DVector faces; + PoolVector faces; faces.resize(facecount); - DVector::Write facesw=faces.write(); + PoolVector::Write facesw=faces.write(); int widx=0; @@ -766,14 +766,14 @@ Ref Mesh::generate_triangle_mesh() const { Array a = surface_get_arrays(i); int vc = surface_get_array_len(i); - DVector vertices = a[ARRAY_VERTEX]; - DVector::Read vr=vertices.read(); + PoolVector vertices = a[ARRAY_VERTEX]; + PoolVector::Read vr=vertices.read(); if (surface_get_format(i)&ARRAY_FORMAT_INDEX) { int ic=surface_get_array_index_len(i); - DVector indices = a[ARRAY_INDEX]; - DVector::Read ir = indices.read(); + PoolVector indices = a[ARRAY_INDEX]; + PoolVector::Read ir = indices.read(); for(int i=0;i Mesh::generate_triangle_mesh() const { } - facesw=DVector::Write(); + facesw=PoolVector::Write(); triangle_mesh = Ref( memnew( TriangleMesh )); @@ -814,7 +814,7 @@ Ref Mesh::create_outline(float p_margin) const { if (i==0) { arrays=a; - DVector v=a[ARRAY_VERTEX]; + PoolVector v=a[ARRAY_VERTEX]; index_accum+=v.size(); } else { @@ -831,8 +831,8 @@ Ref Mesh::create_outline(float p_margin) const { case ARRAY_VERTEX: case ARRAY_NORMAL: { - DVector dst = arrays[j]; - DVector src = a[j]; + PoolVector dst = arrays[j]; + PoolVector src = a[j]; if (j==ARRAY_VERTEX) vcount=src.size(); if (dst.size()==0 || src.size()==0) { @@ -846,8 +846,8 @@ Ref Mesh::create_outline(float p_margin) const { case ARRAY_BONES: case ARRAY_WEIGHTS: { - DVector dst = arrays[j]; - DVector src = a[j]; + PoolVector dst = arrays[j]; + PoolVector src = a[j]; if (dst.size()==0 || src.size()==0) { arrays[j]=Variant(); continue; @@ -857,8 +857,8 @@ Ref Mesh::create_outline(float p_margin) const { } break; case ARRAY_COLOR: { - DVector dst = arrays[j]; - DVector src = a[j]; + PoolVector dst = arrays[j]; + PoolVector src = a[j]; if (dst.size()==0 || src.size()==0) { arrays[j]=Variant(); continue; @@ -869,8 +869,8 @@ Ref Mesh::create_outline(float p_margin) const { } break; case ARRAY_TEX_UV: case ARRAY_TEX_UV2: { - DVector dst = arrays[j]; - DVector src = a[j]; + PoolVector dst = arrays[j]; + PoolVector src = a[j]; if (dst.size()==0 || src.size()==0) { arrays[j]=Variant(); continue; @@ -880,15 +880,15 @@ Ref Mesh::create_outline(float p_margin) const { } break; case ARRAY_INDEX: { - DVector dst = arrays[j]; - DVector src = a[j]; + PoolVector dst = arrays[j]; + PoolVector src = a[j]; if (dst.size()==0 || src.size()==0) { arrays[j]=Variant(); continue; } { int ss = src.size(); - DVector::Write w = src.write(); + PoolVector::Write w = src.write(); for(int k=0;k Mesh::create_outline(float p_margin) const { } { - DVector::Write ir; - DVector indices =arrays[ARRAY_INDEX]; + PoolVector::Write ir; + PoolVector indices =arrays[ARRAY_INDEX]; bool has_indices=false; - DVector vertices =arrays[ARRAY_VERTEX]; + PoolVector vertices =arrays[ARRAY_VERTEX]; int vc = vertices.size(); ERR_FAIL_COND_V(!vc,Ref()); - DVector::Write r=vertices.write(); + PoolVector::Write r=vertices.write(); if (indices.size()) { @@ -977,14 +977,14 @@ Ref Mesh::create_outline(float p_margin) const { r[i]=t; } - r = DVector::Write(); + r = PoolVector::Write(); arrays[ARRAY_VERTEX]=vertices; if (!has_indices) { - DVector new_indices; + PoolVector new_indices; new_indices.resize(vertices.size()); - DVector::Write iw = new_indices.write(); + PoolVector::Write iw = new_indices.write(); for(int j=0;j Mesh::create_outline(float p_margin) const { iw[j+2]=j+1; } - iw=DVector::Write(); + iw=PoolVector::Write(); arrays[ARRAY_INDEX]=new_indices; } else { @@ -1002,7 +1002,7 @@ Ref Mesh::create_outline(float p_margin) const { SWAP(ir[j+1],ir[j+2]); } - ir=DVector::Write(); + ir=PoolVector::Write(); arrays[ARRAY_INDEX]=indices; } diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h index 9be90b64366..f92db837ea3 100644 --- a/scene/resources/mesh.h +++ b/scene/resources/mesh.h @@ -139,7 +139,7 @@ protected: public: void add_surface_from_arrays(PrimitiveType p_primitive, const Array& p_arrays, const Array& p_blend_shapes=Array(), uint32_t p_flags=ARRAY_COMPRESS_DEFAULT); - void add_surface(uint32_t p_format,PrimitiveType p_primitive,const DVector& p_array,int p_vertex_count,const DVector& p_index_array,int p_index_count,const AABB& p_aabb,const Vector >& p_blend_shapes=Vector >(),const Vector& p_bone_aabbs=Vector()); + void add_surface(uint32_t p_format,PrimitiveType p_primitive,const PoolVector& p_array,int p_vertex_count,const PoolVector& p_index_array,int p_index_count,const AABB& p_aabb,const Vector >& p_blend_shapes=Vector >(),const Vector& p_bone_aabbs=Vector()); Array surface_get_arrays(int p_surface) const; virtual Array surface_get_morph_arrays(int p_surface) const; @@ -186,7 +186,7 @@ public: void center_geometry(); void regen_normalmaps(); - DVector get_faces() const; + PoolVector get_faces() const; Ref generate_triangle_mesh() const; Mesh(); diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp index 4a753e6c093..ec699ee8e34 100644 --- a/scene/resources/mesh_data_tool.cpp +++ b/scene/resources/mesh_data_tool.cpp @@ -51,7 +51,7 @@ Error MeshDataTool::create_from_surface(const Ref& p_mesh,int p_surface) { Array arrays = p_mesh->surface_get_arrays(p_surface); ERR_FAIL_COND_V( arrays.empty(), ERR_INVALID_PARAMETER ); - DVector varray = arrays[Mesh::ARRAY_VERTEX]; + PoolVector varray = arrays[Mesh::ARRAY_VERTEX]; int vcount = varray.size(); ERR_FAIL_COND_V( vcount == 0, ERR_INVALID_PARAMETER); @@ -60,34 +60,34 @@ Error MeshDataTool::create_from_surface(const Ref& p_mesh,int p_surface) { format = p_mesh->surface_get_format(p_surface); material=p_mesh->surface_get_material(p_surface); - DVector::Read vr = varray.read(); + PoolVector::Read vr = varray.read(); - DVector::Read nr; + PoolVector::Read nr; if (arrays[Mesh::ARRAY_NORMAL].get_type()!=Variant::NIL) - nr = arrays[Mesh::ARRAY_NORMAL].operator DVector().read(); + nr = arrays[Mesh::ARRAY_NORMAL].operator PoolVector().read(); - DVector::Read ta; + PoolVector::Read ta; if (arrays[Mesh::ARRAY_TANGENT].get_type()!=Variant::NIL) - ta = arrays[Mesh::ARRAY_TANGENT].operator DVector().read(); + ta = arrays[Mesh::ARRAY_TANGENT].operator PoolVector().read(); - DVector::Read uv; + PoolVector::Read uv; if (arrays[Mesh::ARRAY_TEX_UV].get_type()!=Variant::NIL) - uv = arrays[Mesh::ARRAY_TEX_UV].operator DVector().read(); - DVector::Read uv2; + uv = arrays[Mesh::ARRAY_TEX_UV].operator PoolVector().read(); + PoolVector::Read uv2; if (arrays[Mesh::ARRAY_TEX_UV2].get_type()!=Variant::NIL) - uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator DVector().read(); + uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator PoolVector().read(); - DVector::Read col; + PoolVector::Read col; if (arrays[Mesh::ARRAY_COLOR].get_type()!=Variant::NIL) - col = arrays[Mesh::ARRAY_COLOR].operator DVector().read(); + col = arrays[Mesh::ARRAY_COLOR].operator PoolVector().read(); - DVector::Read bo; + PoolVector::Read bo; if (arrays[Mesh::ARRAY_BONES].get_type()!=Variant::NIL) - bo = arrays[Mesh::ARRAY_BONES].operator DVector().read(); + bo = arrays[Mesh::ARRAY_BONES].operator PoolVector().read(); - DVector::Read we; + PoolVector::Read we; if (arrays[Mesh::ARRAY_WEIGHTS].get_type()!=Variant::NIL) - we = arrays[Mesh::ARRAY_WEIGHTS].operator DVector().read(); + we = arrays[Mesh::ARRAY_WEIGHTS].operator PoolVector().read(); vertices.resize(vcount); @@ -129,7 +129,7 @@ Error MeshDataTool::create_from_surface(const Ref& p_mesh,int p_surface) { } - DVector indices; + PoolVector indices; if (arrays[Mesh::ARRAY_INDEX].get_type()!=Variant::NIL) { @@ -137,14 +137,14 @@ Error MeshDataTool::create_from_surface(const Ref& p_mesh,int p_surface) { } else { //make code simpler indices.resize(vcount); - DVector::Write iw=indices.write(); + PoolVector::Write iw=indices.write(); for(int i=0;i::Read r = indices.read(); + PoolVector::Read r = indices.read(); Map edge_indices; @@ -199,59 +199,59 @@ Error MeshDataTool::commit_to_surface(const Ref& p_mesh) { int vcount=vertices.size(); - DVector v; - DVector n; - DVector t; - DVector u; - DVector u2; - DVector c; - DVector b; - DVector w; - DVector in; + PoolVector v; + PoolVector n; + PoolVector t; + PoolVector u; + PoolVector u2; + PoolVector c; + PoolVector b; + PoolVector w; + PoolVector in; { v.resize(vcount); - DVector::Write vr=v.write(); + PoolVector::Write vr=v.write(); - DVector::Write nr; + PoolVector::Write nr; if (format&Mesh::ARRAY_FORMAT_NORMAL) { n.resize(vcount); nr = n.write(); } - DVector::Write ta; + PoolVector::Write ta; if (format&Mesh::ARRAY_FORMAT_TANGENT) { t.resize(vcount*4); ta = t.write(); } - DVector::Write uv; + PoolVector::Write uv; if (format&Mesh::ARRAY_FORMAT_TEX_UV) { u.resize(vcount); uv = u.write(); } - DVector::Write uv2; + PoolVector::Write uv2; if (format&Mesh::ARRAY_FORMAT_TEX_UV2) { u2.resize(vcount); uv2 = u2.write(); } - DVector::Write col; + PoolVector::Write col; if (format&Mesh::ARRAY_FORMAT_COLOR) { c.resize(vcount); col = c.write(); } - DVector::Write bo; + PoolVector::Write bo; if (format&Mesh::ARRAY_FORMAT_BONES) { b.resize(vcount*4); bo = b.write(); } - DVector::Write we; + PoolVector::Write we; if (format&Mesh::ARRAY_FORMAT_WEIGHTS) { w.resize(vcount*4); we = w.write(); @@ -299,7 +299,7 @@ Error MeshDataTool::commit_to_surface(const Ref& p_mesh) { int fc = faces.size(); in.resize(fc*3); - DVector::Write iw=in.write(); + PoolVector::Write iw=in.write(); for(int i=0;i& p_array) { +void MultiMesh::_set_transform_array(const PoolVector& p_array) { int instance_count = get_instance_count(); - DVector xforms = p_array; + PoolVector xforms = p_array; int len=xforms.size(); ERR_FAIL_COND((len/4) != instance_count); if (len==0) return; - DVector::Read r = xforms.read(); + PoolVector::Read r = xforms.read(); for(int i=0;i& p_array) { } -DVector MultiMesh::_get_transform_array() const { +PoolVector MultiMesh::_get_transform_array() const { int instance_count = get_instance_count(); if (instance_count==0) - return DVector(); + return PoolVector(); - DVector xforms; + PoolVector xforms; xforms.resize(instance_count*4); - DVector::Write w = xforms.write(); + PoolVector::Write w = xforms.write(); for(int i=0;i MultiMesh::_get_transform_array() const { } -void MultiMesh::_set_color_array(const DVector& p_array) { +void MultiMesh::_set_color_array(const PoolVector& p_array) { int instance_count = get_instance_count(); - DVector colors = p_array; + PoolVector colors = p_array; int len=colors.size(); ERR_FAIL_COND(len != instance_count); if (len==0) return; - DVector::Read r = colors.read(); + PoolVector::Read r = colors.read(); for(int i=0;i& p_array) { } -DVector MultiMesh::_get_color_array() const { +PoolVector MultiMesh::_get_color_array() const { int instance_count = get_instance_count(); if (instance_count==0) - return DVector(); + return PoolVector(); - DVector colors; + PoolVector colors; colors.resize(instance_count); for(int i=0;i& p_array); - DVector _get_transform_array() const; + void _set_transform_array(const PoolVector& p_array); + PoolVector _get_transform_array() const; - void _set_color_array(const DVector& p_array); - DVector _get_color_array() const; + void _set_color_array(const PoolVector& p_array); + PoolVector _get_color_array() const; public: diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 7d86513c513..c3b98af8112 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -1139,12 +1139,12 @@ void SceneState::set_bundled_scene(const Dictionary& d) { ERR_FAIL(); } - DVector snames = d["names"]; + PoolVector snames = d["names"]; if (snames.size()) { int namecount = snames.size(); names.resize(namecount); - DVector::Read r =snames.read(); + PoolVector::Read r =snames.read(); for(int i=0;i snodes = d["nodes"]; - DVector::Read r = snodes.read(); + PoolVector snodes = d["nodes"]; + PoolVector::Read r = snodes.read(); int idx=0; for(int i=0;i sconns = d["conns"]; - DVector::Read r = sconns.read(); + PoolVector sconns = d["conns"]; + PoolVector::Read r = sconns.read(); int idx=0; for(int i=0;i rnames; + PoolVector rnames; rnames.resize(names.size()); if (names.size()) { - DVector::Write r=rnames.write(); + PoolVector::Write r=rnames.write(); for(int i=0;i SceneState::_get_node_groups(int p_idx) const { +PoolVector SceneState::_get_node_groups(int p_idx) const { Vector groups = get_node_groups(p_idx); - DVector ret; + PoolVector ret; for(int i=0;i _get_node_groups(int p_idx) const; + PoolVector _get_node_groups(int p_idx) const; protected: diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp index 3dc3e6005a3..2156487407c 100644 --- a/scene/resources/polygon_path_finder.cpp +++ b/scene/resources/polygon_path_finder.cpp @@ -448,7 +448,7 @@ void PolygonPathFinder::_set_data(const Dictionary& p_data) { ERR_FAIL_COND(!p_data.has("segments")); ERR_FAIL_COND(!p_data.has("bounds")); - DVector p=p_data["points"]; + PoolVector p=p_data["points"]; Array c=p_data["connections"]; ERR_FAIL_COND(c.size()!=p.size()); @@ -458,11 +458,11 @@ void PolygonPathFinder::_set_data(const Dictionary& p_data) { int pc = p.size(); points.resize(pc+2); - DVector::Read pr=p.read(); + PoolVector::Read pr=p.read(); for(int i=0;i con=c[i]; - DVector::Read cr=con.read(); + PoolVector con=c[i]; + PoolVector::Read cr=con.read(); int cc=con.size(); for(int j=0;j penalties=p_data["penalties"]; + PoolVector penalties=p_data["penalties"]; if (penalties.size()==pc) { - DVector::Read pr = penalties.read(); + PoolVector::Read pr = penalties.read(); for(int i=0;i segs=p_data["segments"]; + PoolVector segs=p_data["segments"]; int sc=segs.size(); ERR_FAIL_COND(sc&1); - DVector::Read sr = segs.read(); + PoolVector::Read sr = segs.read(); for(int i=0;i p; - DVector ind; + PoolVector p; + PoolVector ind; Array connections; p.resize(points.size()-2); connections.resize(points.size()-2); ind.resize(edges.size()*2); - DVector penalties; + PoolVector penalties; penalties.resize(points.size()-2); { - DVector::Write wp=p.write(); - DVector::Write pw=penalties.write(); + PoolVector::Write wp=p.write(); + PoolVector::Write pw=penalties.write(); for(int i=0;i c; + PoolVector c; c.resize(points[i].connections.size()); { - DVector::Write cw=c.write(); + PoolVector::Write cw=c.write(); int idx=0; for (Set::Element *E=points[i].connections.front();E;E=E->next()) { cw[idx++]=E->get(); @@ -527,7 +527,7 @@ Dictionary PolygonPathFinder::_get_data() const{ } { - DVector::Write iw=ind.write(); + PoolVector::Write iw=ind.write(); int idx=0; for (Set::Element *E=edges.front();E;E=E->next()) { iw[idx++]=E->get().points[0]; diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp index c4d11b94d12..88648272be5 100644 --- a/scene/resources/room.cpp +++ b/scene/resources/room.cpp @@ -37,12 +37,12 @@ RID RoomBounds::get_rid() const { } -void RoomBounds::set_geometry_hint(const DVector& p_geometry_hint) { +void RoomBounds::set_geometry_hint(const PoolVector& p_geometry_hint) { geometry_hint=p_geometry_hint; } -DVector RoomBounds::get_geometry_hint() const { +PoolVector RoomBounds::get_geometry_hint() const { return geometry_hint; } diff --git a/scene/resources/room.h b/scene/resources/room.h index 6a8deac8b39..84d68e57186 100644 --- a/scene/resources/room.h +++ b/scene/resources/room.h @@ -41,7 +41,7 @@ class RoomBounds : public Resource { RES_BASE_EXTENSION("room"); RID area; - DVector geometry_hint; + PoolVector geometry_hint; protected: @@ -53,8 +53,8 @@ public: virtual RID get_rid() const; - void set_geometry_hint(const DVector& geometry_hint); - DVector get_geometry_hint() const; + void set_geometry_hint(const PoolVector& geometry_hint); + PoolVector get_geometry_hint() const; RoomBounds(); ~RoomBounds(); diff --git a/scene/resources/sample.cpp b/scene/resources/sample.cpp index 8ea02ac9431..e07e4d37676 100644 --- a/scene/resources/sample.cpp +++ b/scene/resources/sample.cpp @@ -119,18 +119,18 @@ int Sample::get_length() const { return length; } -void Sample::set_data(const DVector& p_buffer) { +void Sample::set_data(const PoolVector& p_buffer) { if (sample.is_valid()) AudioServer::get_singleton()->sample_set_data(sample,p_buffer); } -DVector Sample::get_data() const { +PoolVector Sample::get_data() const { if (sample.is_valid()) return AudioServer::get_singleton()->sample_get_data(sample); - return DVector(); + return PoolVector(); } diff --git a/scene/resources/sample.h b/scene/resources/sample.h index c011f631445..be2cf679543 100644 --- a/scene/resources/sample.h +++ b/scene/resources/sample.h @@ -82,8 +82,8 @@ public: bool is_stereo() const; int get_length() const; - void set_data(const DVector& p_buffer); - DVector get_data() const; + void set_data(const PoolVector& p_buffer); + PoolVector get_data() const; void set_mix_rate(int p_rate); int get_mix_rate() const; diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index 0c31e1406fe..37b019e369a 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -554,8 +554,8 @@ void ShaderGraph::node_add(ShaderType p_type, NodeType p_node_type,int p_id) { case NODE_XFORM_TO_VEC: {} break; // 3 scalar input: {} break; 1 vec3 output case NODE_SCALAR_INTERP: {} break; // scalar interpolation (with optional curve) case NODE_VEC_INTERP: {} break; // vec3 interpolation (with optional curve) - case NODE_COLOR_RAMP: { node.param1=DVector(); node.param2=DVector();} break; // vec3 interpolation (with optional curve) - case NODE_CURVE_MAP: { node.param1=DVector();} break; // vec3 interpolation (with optional curve) + case NODE_COLOR_RAMP: { node.param1=PoolVector(); node.param2=PoolVector();} break; // vec3 interpolation (with optional curve) + case NODE_CURVE_MAP: { node.param1=PoolVector();} break; // vec3 interpolation (with optional curve) case NODE_SCALAR_INPUT: {node.param1=_find_unique_name("Scalar"); node.param2=0;} break; // scalar uniform (assignable in material) case NODE_VEC_INPUT: {node.param1=_find_unique_name("Vec3");node.param2=Vector3();} break; // vec3 uniform (assignable in material) case NODE_RGB_INPUT: {node.param1=_find_unique_name("Color");node.param2=Color();} break; // color uniform (assignable in material) @@ -1082,7 +1082,7 @@ ShaderGraph::VecFunc ShaderGraph::vec_func_node_get_function(ShaderType p_type, return VecFunc(func); } -void ShaderGraph::color_ramp_node_set_ramp(ShaderType p_type,int p_id,const DVector& p_colors, const DVector& p_offsets){ +void ShaderGraph::color_ramp_node_set_ramp(ShaderType p_type,int p_id,const PoolVector& p_colors, const PoolVector& p_offsets){ ERR_FAIL_INDEX(p_type,3); ERR_FAIL_COND(!shader[p_type].node_map.has(p_id)); @@ -1094,27 +1094,27 @@ void ShaderGraph::color_ramp_node_set_ramp(ShaderType p_type,int p_id,const DVec } -DVector ShaderGraph::color_ramp_node_get_colors(ShaderType p_type,int p_id) const{ +PoolVector ShaderGraph::color_ramp_node_get_colors(ShaderType p_type,int p_id) const{ - ERR_FAIL_INDEX_V(p_type,3,DVector()); - ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector()); + ERR_FAIL_INDEX_V(p_type,3,PoolVector()); + ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),PoolVector()); const Node& n = shader[p_type].node_map[p_id]; return n.param1; } -DVector ShaderGraph::color_ramp_node_get_offsets(ShaderType p_type,int p_id) const{ +PoolVector ShaderGraph::color_ramp_node_get_offsets(ShaderType p_type,int p_id) const{ - ERR_FAIL_INDEX_V(p_type,3,DVector()); - ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector()); + ERR_FAIL_INDEX_V(p_type,3,PoolVector()); + ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),PoolVector()); const Node& n = shader[p_type].node_map[p_id]; return n.param2; } -void ShaderGraph::curve_map_node_set_points(ShaderType p_type,int p_id,const DVector& p_points) { +void ShaderGraph::curve_map_node_set_points(ShaderType p_type,int p_id,const PoolVector& p_points) { ERR_FAIL_INDEX(p_type,3); ERR_FAIL_COND(!shader[p_type].node_map.has(p_id)); @@ -1124,10 +1124,10 @@ void ShaderGraph::curve_map_node_set_points(ShaderType p_type,int p_id,const DVe } -DVector ShaderGraph::curve_map_node_get_points(ShaderType p_type,int p_id) const{ +PoolVector ShaderGraph::curve_map_node_get_points(ShaderType p_type,int p_id) const{ - ERR_FAIL_INDEX_V(p_type,3,DVector()); - ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector()); + ERR_FAIL_INDEX_V(p_type,3,PoolVector()); + ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),PoolVector()); const Node& n = shader[p_type].node_map[p_id]; return n.param1; @@ -2450,16 +2450,16 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector cramp; + PoolVector cramp; cramp.resize(color_ramp_len*4); { - DVector colors=p_node->param1; - DVector offsets=p_node->param2; + PoolVector colors=p_node->param1; + PoolVector offsets=p_node->param2; int cc =colors.size(); - DVector::Write crw = cramp.write(); - DVector::Read cr = colors.read(); - DVector::Read ofr = offsets.read(); + PoolVector::Write crw = cramp.write(); + PoolVector::Read cr = colors.read(); + PoolVector::Read ofr = offsets.read(); int at=0; Color color_at(0,0,0,1); @@ -2508,14 +2508,14 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector cmap; + PoolVector cmap; cmap.resize(curve_map_len); { - DVector points=p_node->param1; + PoolVector points=p_node->param1; int pc =points.size(); - DVector::Write cmw = cmap.write(); - DVector::Read pr = points.read(); + PoolVector::Write cmw = cmap.write(); + PoolVector::Read pr = points.read(); Vector2 prev=Vector2(0,0); Vector2 prev2=Vector2(0,0); diff --git a/scene/resources/shader_graph.h b/scene/resources/shader_graph.h index 57893f27c04..f4e24dbe78f 100644 --- a/scene/resources/shader_graph.h +++ b/scene/resources/shader_graph.h @@ -326,12 +326,12 @@ public: void vec_func_node_set_function(ShaderType p_which,int p_id,VecFunc p_func); VecFunc vec_func_node_get_function(ShaderType p_which,int p_id) const; - void color_ramp_node_set_ramp(ShaderType p_which,int p_id,const DVector& p_colors, const DVector& p_offsets); - DVector color_ramp_node_get_colors(ShaderType p_which,int p_id) const; - DVector color_ramp_node_get_offsets(ShaderType p_which,int p_id) const; + void color_ramp_node_set_ramp(ShaderType p_which,int p_id,const PoolVector& p_colors, const PoolVector& p_offsets); + PoolVector color_ramp_node_get_colors(ShaderType p_which,int p_id) const; + PoolVector color_ramp_node_get_offsets(ShaderType p_which,int p_id) const; - void curve_map_node_set_points(ShaderType p_which, int p_id, const DVector& p_points); - DVector curve_map_node_get_points(ShaderType p_which,int p_id) const; + void curve_map_node_set_points(ShaderType p_which, int p_id, const PoolVector& p_points); + PoolVector curve_map_node_get_points(ShaderType p_which,int p_id) const; void input_node_set_name(ShaderType p_which,int p_id,const String& p_name); String input_node_get_name(ShaderType p_which,int p_id); diff --git a/scene/resources/shape.cpp b/scene/resources/shape.cpp index f00443276f3..a90c3b47a9e 100644 --- a/scene/resources/shape.cpp +++ b/scene/resources/shape.cpp @@ -34,7 +34,7 @@ #include "scene/main/scene_main_loop.h" -void Shape::add_vertices_to_array(DVector &array, const Transform& p_xform) { +void Shape::add_vertices_to_array(PoolVector &array, const Transform& p_xform) { Vector toadd = _gen_debug_mesh_lines(); @@ -42,7 +42,7 @@ void Shape::add_vertices_to_array(DVector &array, const Transform& p_xf int base=array.size(); array.resize(base+toadd.size()); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); for(int i=0;i Shape::get_debug_mesh() { if (!lines.empty()) { //make mesh - DVector array; + PoolVector array; array.resize(lines.size()); { - DVector::Write w=array.write(); + PoolVector::Write w=array.write(); for(int i=0;i get_debug_mesh(); - void add_vertices_to_array(DVector &array, const Transform& p_xform); + void add_vertices_to_array(PoolVector &array, const Transform& p_xform); Shape(); ~Shape(); diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 2ed620c0972..cc13c0ff111 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -262,9 +262,9 @@ Ref SurfaceTool::commit(const Ref& p_existing) { case Mesh::ARRAY_FORMAT_VERTEX: case Mesh::ARRAY_FORMAT_NORMAL: { - DVector array; + PoolVector array; array.resize(varr_len); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); int idx=0; for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx++) { @@ -282,7 +282,7 @@ Ref SurfaceTool::commit(const Ref& p_existing) { } - w=DVector::Write(); + w=PoolVector::Write(); a[i]=array; } break; @@ -290,9 +290,9 @@ Ref SurfaceTool::commit(const Ref& p_existing) { case Mesh::ARRAY_FORMAT_TEX_UV: case Mesh::ARRAY_FORMAT_TEX_UV2: { - DVector array; + PoolVector array; array.resize(varr_len); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); int idx=0; for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx++) { @@ -311,15 +311,15 @@ Ref SurfaceTool::commit(const Ref& p_existing) { } - w=DVector::Write(); + w=PoolVector::Write(); a[i]=array; } break; case Mesh::ARRAY_FORMAT_TANGENT: { - DVector array; + PoolVector array; array.resize(varr_len*4); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); int idx=0; for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx+=4) { @@ -335,15 +335,15 @@ Ref SurfaceTool::commit(const Ref& p_existing) { w[idx+3]=d<0 ? -1 : 1; } - w=DVector::Write(); + w=PoolVector::Write(); a[i]=array; } break; case Mesh::ARRAY_FORMAT_COLOR: { - DVector array; + PoolVector array; array.resize(varr_len); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); int idx=0; for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx++) { @@ -352,15 +352,15 @@ Ref SurfaceTool::commit(const Ref& p_existing) { w[idx]=v.color; } - w=DVector::Write(); + w=PoolVector::Write(); a[i]=array; } break; case Mesh::ARRAY_FORMAT_BONES: { - DVector array; + PoolVector array; array.resize(varr_len*4); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); int idx=0; for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx+=4) { @@ -375,16 +375,16 @@ Ref SurfaceTool::commit(const Ref& p_existing) { } - w=DVector::Write(); + w=PoolVector::Write(); a[i]=array; } break; case Mesh::ARRAY_FORMAT_WEIGHTS: { - DVector array; + PoolVector array; array.resize(varr_len*4); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); int idx=0; for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx+=4) { @@ -399,7 +399,7 @@ Ref SurfaceTool::commit(const Ref& p_existing) { } - w=DVector::Write(); + w=PoolVector::Write(); a[i]=array; } break; @@ -407,9 +407,9 @@ Ref SurfaceTool::commit(const Ref& p_existing) { ERR_CONTINUE( index_array.size() ==0 ); - DVector array; + PoolVector array; array.resize(index_array.size()); - DVector::Write w = array.write(); + PoolVector::Write w = array.write(); int idx=0; for(List< int>::Element *E=index_array.front();E;E=E->next(),idx++) { @@ -417,7 +417,7 @@ Ref SurfaceTool::commit(const Ref& p_existing) { w[idx]=E->get(); } - w=DVector::Write(); + w=PoolVector::Write(); a[i]=array; } break; @@ -490,14 +490,14 @@ void SurfaceTool::_create_list(const Ref& p_existing, int p_surface, List< Array arr = p_existing->surface_get_arrays(p_surface); ERR_FAIL_COND( arr.size() !=VS::ARRAY_MAX ); - DVector varr = arr[VS::ARRAY_VERTEX]; - DVector narr = arr[VS::ARRAY_NORMAL]; - DVector tarr = arr[VS::ARRAY_TANGENT]; - DVector carr = arr[VS::ARRAY_COLOR]; - DVector uvarr = arr[VS::ARRAY_TEX_UV]; - DVector uv2arr = arr[VS::ARRAY_TEX_UV2]; - DVector barr = arr[VS::ARRAY_BONES]; - DVector warr = arr[VS::ARRAY_WEIGHTS]; + PoolVector varr = arr[VS::ARRAY_VERTEX]; + PoolVector narr = arr[VS::ARRAY_NORMAL]; + PoolVector tarr = arr[VS::ARRAY_TANGENT]; + PoolVector carr = arr[VS::ARRAY_COLOR]; + PoolVector uvarr = arr[VS::ARRAY_TEX_UV]; + PoolVector uv2arr = arr[VS::ARRAY_TEX_UV2]; + PoolVector barr = arr[VS::ARRAY_BONES]; + PoolVector warr = arr[VS::ARRAY_WEIGHTS]; int vc = varr.size(); @@ -505,46 +505,46 @@ void SurfaceTool::_create_list(const Ref& p_existing, int p_surface, List< return; lformat=0; - DVector::Read rv; + PoolVector::Read rv; if (varr.size()) { lformat|=VS::ARRAY_FORMAT_VERTEX; rv=varr.read(); } - DVector::Read rn; + PoolVector::Read rn; if (narr.size()) { lformat|=VS::ARRAY_FORMAT_NORMAL; rn=narr.read(); } - DVector::Read rt; + PoolVector::Read rt; if (tarr.size()) { lformat|=VS::ARRAY_FORMAT_TANGENT; rt=tarr.read(); } - DVector::Read rc; + PoolVector::Read rc; if (carr.size()) { lformat|=VS::ARRAY_FORMAT_COLOR; rc=carr.read(); } - DVector::Read ruv; + PoolVector::Read ruv; if (uvarr.size()) { lformat|=VS::ARRAY_FORMAT_TEX_UV; ruv=uvarr.read(); } - DVector::Read ruv2; + PoolVector::Read ruv2; if (uv2arr.size()) { lformat|=VS::ARRAY_FORMAT_TEX_UV2; ruv2=uv2arr.read(); } - DVector::Read rb; + PoolVector::Read rb; if (barr.size()) { lformat|=VS::ARRAY_FORMAT_BONES; rb=barr.read(); } - DVector::Read rw; + PoolVector::Read rw; if (warr.size()) { lformat|=VS::ARRAY_FORMAT_WEIGHTS; rw=warr.read(); @@ -592,12 +592,12 @@ void SurfaceTool::_create_list(const Ref& p_existing, int p_surface, List< //indices - DVector idx= arr[VS::ARRAY_INDEX]; + PoolVector idx= arr[VS::ARRAY_INDEX]; int is = idx.size(); if (is) { lformat|=VS::ARRAY_FORMAT_INDEX; - DVector::Read iarr=idx.read(); + PoolVector::Read iarr=idx.read(); for(int i=0;ipush_back(iarr[i]); } diff --git a/scene/resources/theme.h b/scene/resources/theme.h index 94ac910e9fc..e9d890cf973 100644 --- a/scene/resources/theme.h +++ b/scene/resources/theme.h @@ -72,13 +72,13 @@ protected: Ref default_theme_font; - DVector _get_icon_list(const String& p_type) const { DVector ilret; List il; get_icon_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } - DVector _get_stylebox_list(const String& p_type) const { DVector ilret; List il; get_stylebox_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } - DVector _get_stylebox_types(void) const { DVector ilret; List il; get_stylebox_types(&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } - DVector _get_font_list(const String& p_type) const { DVector ilret; List il; get_font_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } - DVector _get_color_list(const String& p_type) const { DVector ilret; List il; get_color_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } - DVector _get_constant_list(const String& p_type) const { DVector ilret; List il; get_constant_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } - DVector _get_type_list(const String& p_type) const { DVector ilret; List il; get_type_list(&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } + PoolVector _get_icon_list(const String& p_type) const { PoolVector ilret; List il; get_icon_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } + PoolVector _get_stylebox_list(const String& p_type) const { PoolVector ilret; List il; get_stylebox_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } + PoolVector _get_stylebox_types(void) const { PoolVector ilret; List il; get_stylebox_types(&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } + PoolVector _get_font_list(const String& p_type) const { PoolVector ilret; List il; get_font_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } + PoolVector _get_color_list(const String& p_type) const { PoolVector ilret; List il; get_color_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } + PoolVector _get_constant_list(const String& p_type) const { PoolVector ilret; List il; get_constant_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } + PoolVector _get_type_list(const String& p_type) const { PoolVector ilret; List il; get_type_list(&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } static void _bind_methods(); public: diff --git a/servers/audio/audio_server_sw.cpp b/servers/audio/audio_server_sw.cpp index edf8143eb57..f508a130b40 100644 --- a/servers/audio/audio_server_sw.cpp +++ b/servers/audio/audio_server_sw.cpp @@ -384,11 +384,11 @@ const void* AudioServerSW::sample_get_data_ptr(RID p_sample) const { return sample_manager->sample_get_data_ptr(p_sample); } -void AudioServerSW::sample_set_data(RID p_sample, const DVector& p_buffer) { +void AudioServerSW::sample_set_data(RID p_sample, const PoolVector& p_buffer) { AUDIO_LOCK sample_manager->sample_set_data(p_sample,p_buffer); } -DVector AudioServerSW::sample_get_data(RID p_sample) const { +PoolVector AudioServerSW::sample_get_data(RID p_sample) const { AUDIO_LOCK return sample_manager->sample_get_data(p_sample); } diff --git a/servers/audio/audio_server_sw.h b/servers/audio/audio_server_sw.h index f97ae8db82f..52b45351c3d 100644 --- a/servers/audio/audio_server_sw.h +++ b/servers/audio/audio_server_sw.h @@ -125,8 +125,8 @@ public: virtual int sample_get_length(RID p_sample) const; const void* sample_get_data_ptr(RID p_sample) const; - virtual void sample_set_data(RID p_sample, const DVector& p_buffer); - virtual DVector sample_get_data(RID p_sample) const; + virtual void sample_set_data(RID p_sample, const PoolVector& p_buffer); + virtual PoolVector sample_get_data(RID p_sample) const; virtual void sample_set_mix_rate(RID p_sample,int p_rate); virtual int sample_get_mix_rate(RID p_sample) const; diff --git a/servers/audio/sample_manager_sw.cpp b/servers/audio/sample_manager_sw.cpp index 623bb0f9cb7..fe4cc367764 100644 --- a/servers/audio/sample_manager_sw.cpp +++ b/servers/audio/sample_manager_sw.cpp @@ -125,7 +125,7 @@ int SampleManagerMallocSW::sample_get_length(RID p_sample) const { return s->length; } -void SampleManagerMallocSW::sample_set_data(RID p_sample, const DVector& p_buffer) { +void SampleManagerMallocSW::sample_set_data(RID p_sample, const PoolVector& p_buffer) { Sample *s = sample_owner.get(p_sample); ERR_FAIL_COND(!s); @@ -137,7 +137,7 @@ void SampleManagerMallocSW::sample_set_data(RID p_sample, const DVector ERR_EXPLAIN("Sample buffer size does not match sample size."); //print_line("len bytes: "+itos(s->length_bytes)+" bufsize: "+itos(buff_size)); ERR_FAIL_COND(s->length_bytes!=buff_size); - DVector::Read buffer_r=p_buffer.read(); + PoolVector::Read buffer_r=p_buffer.read(); const uint8_t *src = buffer_r.ptr(); uint8_t *dst = (uint8_t*)s->data; //print_line("set data: "+itos(s->length_bytes)); @@ -181,14 +181,14 @@ void SampleManagerMallocSW::sample_set_data(RID p_sample, const DVector } -const DVector SampleManagerMallocSW::sample_get_data(RID p_sample) const { +const PoolVector SampleManagerMallocSW::sample_get_data(RID p_sample) const { Sample *s = sample_owner.get(p_sample); - ERR_FAIL_COND_V(!s,DVector()); + ERR_FAIL_COND_V(!s,PoolVector()); - DVector ret_buffer; + PoolVector ret_buffer; ret_buffer.resize(s->length_bytes); - DVector::Write buffer_w=ret_buffer.write(); + PoolVector::Write buffer_w=ret_buffer.write(); uint8_t *dst = buffer_w.ptr(); const uint8_t *src = (const uint8_t*)s->data; @@ -197,7 +197,7 @@ const DVector SampleManagerMallocSW::sample_get_data(RID p_sample) cons dst[i]=src[i]; } - buffer_w = DVector::Write(); //unlock + buffer_w = PoolVector::Write(); //unlock return ret_buffer; } diff --git a/servers/audio/sample_manager_sw.h b/servers/audio/sample_manager_sw.h index ad71723cd67..93cad96f1a2 100644 --- a/servers/audio/sample_manager_sw.h +++ b/servers/audio/sample_manager_sw.h @@ -45,8 +45,8 @@ public: virtual bool sample_is_stereo(RID p_sample) const=0; virtual int sample_get_length(RID p_sample) const=0; - virtual void sample_set_data(RID p_sample, const DVector& p_buffer)=0; - virtual const DVector sample_get_data(RID p_sample) const=0; + virtual void sample_set_data(RID p_sample, const PoolVector& p_buffer)=0; + virtual const PoolVector sample_get_data(RID p_sample) const=0; virtual void *sample_get_data_ptr(RID p_sample) const=0; @@ -102,8 +102,8 @@ public: virtual bool sample_is_stereo(RID p_sample) const; virtual int sample_get_length(RID p_sample) const; - virtual void sample_set_data(RID p_sample, const DVector& p_buffer); - virtual const DVector sample_get_data(RID p_sample) const; + virtual void sample_set_data(RID p_sample, const PoolVector& p_buffer); + virtual const PoolVector sample_get_data(RID p_sample) const; virtual void *sample_get_data_ptr(RID p_sample) const; diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 78d793fe462..5037b199242 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -46,7 +46,7 @@ AudioServer *AudioServer::get_singleton() { return singleton; } -void AudioServer::sample_set_signed_data(RID p_sample, const DVector& p_buffer) { +void AudioServer::sample_set_signed_data(RID p_sample, const PoolVector& p_buffer) { SampleFormat format = sample_get_format(p_sample); @@ -56,9 +56,9 @@ void AudioServer::sample_set_signed_data(RID p_sample, const DVector& p_b int len = p_buffer.size(); ERR_FAIL_COND( len == 0 ); - DVector data; - DVector::Write w; - DVector::Read r = p_buffer.read(); + PoolVector data; + PoolVector::Write w; + PoolVector::Read r = p_buffer.read(); switch(format) { case SAMPLE_FORMAT_PCM8: { @@ -95,7 +95,7 @@ void AudioServer::sample_set_signed_data(RID p_sample, const DVector& p_b } break; } - w = DVector::Write(); + w = PoolVector::Write(); sample_set_data(p_sample,data); diff --git a/servers/audio_server.h b/servers/audio_server.h index 9d8ae2bff91..1482b40d4c6 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -168,9 +168,9 @@ public: virtual int sample_get_length(RID p_sample) const=0; virtual const void* sample_get_data_ptr(RID p_sample) const=0; - virtual void sample_set_signed_data(RID p_sample, const DVector& p_buffer); - virtual void sample_set_data(RID p_sample, const DVector& p_buffer)=0; - virtual DVector sample_get_data(RID p_sample) const=0; + virtual void sample_set_signed_data(RID p_sample, const PoolVector& p_buffer); + virtual void sample_set_data(RID p_sample, const PoolVector& p_buffer)=0; + virtual PoolVector sample_get_data(RID p_sample) const=0; virtual void sample_set_mix_rate(RID p_sample,int p_rate)=0; virtual int sample_get_mix_rate(RID p_sample) const=0; diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp index 304bcf8f7b2..c853dcff35e 100644 --- a/servers/physics/shape_sw.cpp +++ b/servers/physics/shape_sw.cpp @@ -971,10 +971,10 @@ FaceShapeSW::FaceShapeSW() { -DVector ConcavePolygonShapeSW::get_faces() const { +PoolVector ConcavePolygonShapeSW::get_faces() const { - DVector rfaces; + PoolVector rfaces; rfaces.resize(faces.size()*3); for(int i=0;i::Read r=vertices.read(); + PoolVector::Read r=vertices.read(); const Vector3 *vptr=r.ptr(); for (int i=0;i::Read r=vertices.read(); + PoolVector::Read r=vertices.read(); const Vector3 *vptr=r.ptr(); Vector3 n=p_normal; @@ -1111,9 +1111,9 @@ bool ConcavePolygonShapeSW::intersect_segment(const Vector3& p_begin,const Vecto return false; // unlock data - DVector::Read fr=faces.read(); - DVector::Read vr=vertices.read(); - DVector::Read br=bvh.read(); + PoolVector::Read fr=faces.read(); + PoolVector::Read vr=vertices.read(); + PoolVector::Read br=bvh.read(); _SegmentCullParams params; @@ -1184,9 +1184,9 @@ void ConcavePolygonShapeSW::cull(const AABB& p_local_aabb,Callback p_callback,vo AABB local_aabb=p_local_aabb; // unlock data - DVector::Read fr=faces.read(); - DVector::Read vr=vertices.read(); - DVector::Read br=bvh.read(); + PoolVector::Read fr=faces.read(); + PoolVector::Read vr=vertices.read(); + PoolVector::Read br=bvh.read(); FaceShapeSW face; // use this to send in the callback @@ -1347,7 +1347,7 @@ void ConcavePolygonShapeSW::_fill_bvh(_VolumeSW_BVH* p_bvh_tree,BVH* p_bvh_array } -void ConcavePolygonShapeSW::_setup(DVector p_faces) { +void ConcavePolygonShapeSW::_setup(PoolVector p_faces) { int src_face_count=p_faces.size(); if (src_face_count==0) { @@ -1357,7 +1357,7 @@ void ConcavePolygonShapeSW::_setup(DVector p_faces) { ERR_FAIL_COND(src_face_count%3); src_face_count/=3; - DVector::Read r = p_faces.read(); + PoolVector::Read r = p_faces.read(); const Vector3 * facesr= r.ptr(); #if 0 @@ -1399,7 +1399,7 @@ void ConcavePolygonShapeSW::_setup(DVector p_faces) { vertices.resize( point_map.size() ); - DVector::Write vw = vertices.write(); + PoolVector::Write vw = vertices.write(); Vector3 *verticesw=vw.ptr(); AABB _aabb; @@ -1418,7 +1418,7 @@ void ConcavePolygonShapeSW::_setup(DVector p_faces) { point_map.clear(); // not needed anymore faces.resize(face_list.size()); - DVector::Write w = faces.write(); + PoolVector::Write w = faces.write(); Face *facesw=w.ptr(); int fc=0; @@ -1431,10 +1431,10 @@ void ConcavePolygonShapeSW::_setup(DVector p_faces) { face_list.clear(); - DVector<_VolumeSW_BVH_Element> bvh_array; + PoolVector<_VolumeSW_BVH_Element> bvh_array; bvh_array.resize( fc ); - DVector<_VolumeSW_BVH_Element>::Write bvhw = bvh_array.write(); + PoolVector<_VolumeSW_BVH_Element>::Write bvhw = bvh_array.write(); _VolumeSW_BVH_Element *bvh_arrayw=bvhw.ptr(); @@ -1451,8 +1451,8 @@ void ConcavePolygonShapeSW::_setup(DVector p_faces) { } - w=DVector::Write(); - vw=DVector::Write(); + w=PoolVector::Write(); + vw=PoolVector::Write(); int count=0; @@ -1460,11 +1460,11 @@ void ConcavePolygonShapeSW::_setup(DVector p_faces) { ERR_FAIL_COND(count==0); - bvhw=DVector<_VolumeSW_BVH_Element>::Write(); + bvhw=PoolVector<_VolumeSW_BVH_Element>::Write(); bvh.resize( count+1 ); - DVector::Write bvhw2 = bvh.write(); + PoolVector::Write bvhw2 = bvh.write(); BVH*bvh_arrayw2=bvhw2.ptr(); int idx=0; @@ -1473,19 +1473,19 @@ void ConcavePolygonShapeSW::_setup(DVector p_faces) { set_aabb(_aabb); #else - DVector<_VolumeSW_BVH_Element> bvh_array; + PoolVector<_VolumeSW_BVH_Element> bvh_array; bvh_array.resize( src_face_count ); - DVector<_VolumeSW_BVH_Element>::Write bvhw = bvh_array.write(); + PoolVector<_VolumeSW_BVH_Element>::Write bvhw = bvh_array.write(); _VolumeSW_BVH_Element *bvh_arrayw=bvhw.ptr(); faces.resize(src_face_count); - DVector::Write w = faces.write(); + PoolVector::Write w = faces.write(); Face *facesw=w.ptr(); vertices.resize( src_face_count*3 ); - DVector::Write vw = vertices.write(); + PoolVector::Write vw = vertices.write(); Vector3 *verticesw=vw.ptr(); AABB _aabb; @@ -1512,15 +1512,15 @@ void ConcavePolygonShapeSW::_setup(DVector p_faces) { } - w=DVector::Write(); - vw=DVector::Write(); + w=PoolVector::Write(); + vw=PoolVector::Write(); int count=0; _VolumeSW_BVH *bvh_tree=_volume_sw_build_bvh(bvh_arrayw,src_face_count,count); bvh.resize( count+1 ); - DVector::Write bvhw2 = bvh.write(); + PoolVector::Write bvhw2 = bvh.write(); BVH*bvh_arrayw2=bvhw2.ptr(); int idx=0; @@ -1553,7 +1553,7 @@ ConcavePolygonShapeSW::ConcavePolygonShapeSW() { /* HEIGHT MAP SHAPE */ -DVector HeightMapShapeSW::get_heights() const { +PoolVector HeightMapShapeSW::get_heights() const { return heights; } @@ -1614,14 +1614,14 @@ Vector3 HeightMapShapeSW::get_moment_of_inertia(float p_mass) const { } -void HeightMapShapeSW::_setup(DVector p_heights,int p_width,int p_depth,real_t p_cell_size) { +void HeightMapShapeSW::_setup(PoolVector p_heights,int p_width,int p_depth,real_t p_cell_size) { heights=p_heights; width=p_width; depth=p_depth;; cell_size=p_cell_size; - DVector::Read r = heights. read(); + PoolVector::Read r = heights. read(); AABB aabb; @@ -1656,7 +1656,7 @@ void HeightMapShapeSW::set_data(const Variant& p_data) { int width=d["width"]; int depth=d["depth"]; float cell_size=d["cell_size"]; - DVector heights=d["heights"]; + PoolVector heights=d["heights"]; ERR_FAIL_COND( width<= 0); ERR_FAIL_COND( depth<= 0); diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h index d031a9fb9b6..5916fd98813 100644 --- a/servers/physics/shape_sw.h +++ b/servers/physics/shape_sw.h @@ -279,8 +279,8 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW { int indices[3]; }; - DVector faces; - DVector vertices; + PoolVector faces; + PoolVector vertices; struct BVH { @@ -291,7 +291,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW { int face_index; }; - DVector bvh; + PoolVector bvh; struct _CullParams { @@ -326,10 +326,10 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW { void _fill_bvh(_VolumeSW_BVH* p_bvh_tree,BVH* p_bvh_array,int& p_idx); - void _setup(DVector p_faces); + void _setup(PoolVector p_faces); public: - DVector get_faces() const; + PoolVector get_faces() const; virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONCAVE_POLYGON; } @@ -352,7 +352,7 @@ public: struct HeightMapShapeSW : public ConcaveShapeSW { - DVector heights; + PoolVector heights; int width; int depth; float cell_size; @@ -360,10 +360,10 @@ struct HeightMapShapeSW : public ConcaveShapeSW { // void _cull_segment(int p_idx,_SegmentCullParams *p_params) const; // void _cull(int p_idx,_CullParams *p_params) const; - void _setup(DVector p_heights,int p_width,int p_depth,float p_cell_size); + void _setup(PoolVector p_heights,int p_width,int p_depth,float p_cell_size); public: - DVector get_heights() const; + PoolVector get_heights() const; int get_width() const; int get_depth() const; float get_cell_size() const; diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index 6506349eadf..e9089e6173f 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -693,11 +693,11 @@ void ConvexPolygonShape2DSW::set_data(const Variant& p_data) { point_count=0; if (p_data.get_type()==Variant::VECTOR2_ARRAY) { - DVector arr=p_data; + PoolVector arr=p_data; ERR_FAIL_COND(arr.size()==0); point_count=arr.size(); points = memnew_arr(Point,point_count); - DVector::Read r = arr.read(); + PoolVector::Read r = arr.read(); for(int i=0;i dvr = p_data; + PoolVector dvr = p_data; point_count=dvr.size()/4; ERR_FAIL_COND(point_count==0); points = memnew_arr(Point,point_count); - DVector::Read r = dvr.read(); + PoolVector::Read r = dvr.read(); for(int i=0;i dvr; + PoolVector dvr; dvr.resize(point_count); @@ -970,7 +970,7 @@ void ConcavePolygonShape2DSW::set_data(const Variant& p_data) { if (p_data.get_type()==Variant::VECTOR2_ARRAY) { - DVector p2arr = p_data; + PoolVector p2arr = p_data; int len = p2arr.size(); ERR_FAIL_COND(len%2); @@ -984,7 +984,7 @@ void ConcavePolygonShape2DSW::set_data(const Variant& p_data) { return; } - DVector::Read arr = p2arr.read(); + PoolVector::Read arr = p2arr.read(); Map pointmap; for(int i=0;i rsegments; + PoolVector rsegments; int len = segments.size(); rsegments.resize(len*2); - DVector::Write w = rsegments.write(); + PoolVector::Write w = rsegments.write(); for(int i=0;i::Write(); + w=PoolVector::Write(); return rsegments; } diff --git a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp index 3ec19b60c19..a930daf7295 100644 --- a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp +++ b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp @@ -181,7 +181,7 @@ RID SpatialSound2DServerSW::room_get_space(RID p_room) const { -void SpatialSound2DServerSW::room_set_bounds(RID p_room, const DVector& p_bounds) { +void SpatialSound2DServerSW::room_set_bounds(RID p_room, const PoolVector& p_bounds) { Room *room = room_owner.get(p_room); ERR_FAIL_COND(!room); @@ -198,9 +198,9 @@ void SpatialSound2DServerSW::room_set_bounds(RID p_room, const DVector& // space->octree.move(room->octree_id,room->transform.xform(aabb)); } -DVector SpatialSound2DServerSW::room_get_bounds(RID p_room) const { +PoolVector SpatialSound2DServerSW::room_get_bounds(RID p_room) const { Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,DVector()); + ERR_FAIL_COND_V(!room,PoolVector()); return room->bounds; } diff --git a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h index a4e4b3a4a1a..d6c09f50a87 100644 --- a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h +++ b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h @@ -82,7 +82,7 @@ class SpatialSound2DServerSW : public SpatialSound2DServer { RID space; Matrix32 transform; Matrix32 inverse_transform; - DVector bounds; + PoolVector bounds; RoomReverb reverb; float params[ROOM_PARAM_MAX]; bool override_other_sources; @@ -198,8 +198,8 @@ public: virtual void room_set_space(RID p_room,RID p_space); virtual RID room_get_space(RID p_room) const; - virtual void room_set_bounds(RID p_room, const DVector& p_bounds); - virtual DVector room_get_bounds(RID p_room) const; + virtual void room_set_bounds(RID p_room, const PoolVector& p_bounds); + virtual PoolVector room_get_bounds(RID p_room) const; virtual void room_set_transform(RID p_room, const Matrix32& p_transform); virtual Matrix32 room_get_transform(RID p_room) const; diff --git a/servers/spatial_sound_2d_server.h b/servers/spatial_sound_2d_server.h index b54368fec58..c19da87c049 100644 --- a/servers/spatial_sound_2d_server.h +++ b/servers/spatial_sound_2d_server.h @@ -57,8 +57,8 @@ public: virtual RID room_get_space(RID p_room) const=0; - virtual void room_set_bounds(RID p_room, const DVector& p_bounds)=0; - virtual DVector room_get_bounds(RID p_room) const=0; + virtual void room_set_bounds(RID p_room, const PoolVector& p_bounds)=0; + virtual PoolVector room_get_bounds(RID p_room) const=0; virtual void room_set_transform(RID p_room, const Matrix32& p_transform)=0; virtual Matrix32 room_get_transform(RID p_room) const=0; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 27268dcabf4..de570b7e4d8 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -242,7 +242,7 @@ public: virtual RID mesh_create()=0; - virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const DVector& p_array,int p_vertex_count,const DVector& p_index_array,int p_index_count,const AABB& p_aabb,const Vector >& p_blend_shapes=Vector >(),const Vector& p_bone_aabbs=Vector())=0; + virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const PoolVector& p_array,int p_vertex_count,const PoolVector& p_index_array,int p_index_count,const AABB& p_aabb,const Vector >& p_blend_shapes=Vector >(),const Vector& p_bone_aabbs=Vector())=0; virtual void mesh_set_morph_target_count(RID p_mesh,int p_amount)=0; virtual int mesh_get_morph_target_count(RID p_mesh) const=0; @@ -257,15 +257,15 @@ public: virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const=0; virtual int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const=0; - virtual DVector mesh_surface_get_array(RID p_mesh, int p_surface) const=0; - virtual DVector mesh_surface_get_index_array(RID p_mesh, int p_surface) const=0; + virtual PoolVector mesh_surface_get_array(RID p_mesh, int p_surface) const=0; + virtual PoolVector mesh_surface_get_index_array(RID p_mesh, int p_surface) const=0; virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const=0; virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const=0; virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const=0; - virtual Vector > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const=0; + virtual Vector > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const=0; virtual Vector mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const=0; virtual void mesh_remove_surface(RID p_mesh,int p_index)=0; @@ -388,7 +388,7 @@ public: /* ROOM API */ virtual RID room_create()=0; - virtual void room_add_bounds(RID p_room, const DVector& p_convex_polygon,float p_height,const Transform& p_transform)=0; + virtual void room_add_bounds(RID p_room, const PoolVector& p_convex_polygon,float p_height,const Transform& p_transform)=0; virtual void room_clear_bounds(RID p_room)=0; /* PORTAL API */ @@ -421,8 +421,8 @@ public: virtual void gi_probe_set_to_cell_xform(RID p_probe,const Transform& p_xform)=0; virtual Transform gi_probe_get_to_cell_xform(RID p_probe) const=0; - virtual void gi_probe_set_dynamic_data(RID p_probe,const DVector& p_data)=0; - virtual DVector gi_probe_get_dynamic_data(RID p_probe) const=0; + virtual void gi_probe_set_dynamic_data(RID p_probe,const PoolVector& p_data)=0; + virtual PoolVector gi_probe_get_dynamic_data(RID p_probe) const=0; virtual void gi_probe_set_dynamic_range(RID p_probe,int p_range)=0; virtual int gi_probe_get_dynamic_range(RID p_probe) const=0; @@ -467,7 +467,7 @@ public: virtual void particles_set_emission_shape(RID p_particles,VS::ParticlesEmissionShape p_shape)=0; virtual void particles_set_emission_sphere_radius(RID p_particles,float p_radius)=0; virtual void particles_set_emission_box_extents(RID p_particles,const Vector3& p_extents)=0; - virtual void particles_set_emission_points(RID p_particles,const DVector& p_points)=0; + virtual void particles_set_emission_points(RID p_particles,const PoolVector& p_points)=0; virtual void particles_set_draw_order(RID p_particles,VS::ParticlesDrawOrder p_order)=0; @@ -506,7 +506,7 @@ public: /* LIGHT SHADOW MAPPING */ virtual RID canvas_light_occluder_create()=0; - virtual void canvas_light_occluder_set_polylines(RID p_occluder, const DVector& p_lines)=0; + virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector& p_lines)=0; virtual VS::InstanceType get_base_type(RID p_rid) const=0; @@ -1275,8 +1275,8 @@ public: virtual void particles_set_emission_base_velocity(RID p_particles, const Vector3& p_base_velocity)=0; virtual Vector3 particles_get_emission_base_velocity(RID p_particles) const=0; - virtual void particles_set_emission_points(RID p_particles, const DVector& p_points)=0; - virtual DVector particles_get_emission_points(RID p_particles) const=0; + virtual void particles_set_emission_points(RID p_particles, const PoolVector& p_points)=0; + virtual PoolVector particles_get_emission_points(RID p_particles) const=0; virtual void particles_set_gravity_normal(RID p_particles, const Vector3& p_normal)=0; virtual Vector3 particles_get_gravity_normal(RID p_particles) const=0; @@ -1876,7 +1876,7 @@ public: /* LIGHT SHADOW MAPPING */ virtual RID canvas_light_occluder_create()=0; - virtual void canvas_light_occluder_set_polylines(RID p_occluder, const DVector& p_lines)=0; + virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector& p_lines)=0; virtual RID canvas_light_shadow_buffer_create(int p_width)=0; diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp index f70ce46a3d4..8e6345960fc 100644 --- a/servers/visual/visual_server_canvas.cpp +++ b/servers/visual/visual_server_canvas.cpp @@ -1058,20 +1058,20 @@ RID VisualServerCanvas::canvas_occluder_polygon_create() { return canvas_light_occluder_polygon_owner.make_rid(occluder_poly); } -void VisualServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygon,const DVector& p_shape,bool p_closed) { +void VisualServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygon,const PoolVector& p_shape,bool p_closed) { if (p_shape.size()<3) { canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon,p_shape); return; } - DVector lines; + PoolVector lines; int lc = p_shape.size()*2; lines.resize(lc-(p_closed?0:2)); { - DVector::Write w = lines.write(); - DVector::Read r = p_shape.read(); + PoolVector::Write w = lines.write(); + PoolVector::Read r = p_shape.read(); int max=lc/2; if (!p_closed) { @@ -1089,7 +1089,7 @@ void VisualServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygo canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon,lines); } -void VisualServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon,const DVector& p_shape) { +void VisualServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon,const PoolVector& p_shape) { LightOccluderPolygon * occluder_poly = canvas_light_occluder_polygon_owner.get(p_occluder_polygon); ERR_FAIL_COND(!occluder_poly); @@ -1098,7 +1098,7 @@ void VisualServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occlud int lc = p_shape.size(); occluder_poly->aabb=Rect2(); { - DVector::Read r = p_shape.read(); + PoolVector::Read r = p_shape.read(); for(int i=0;iaabb.pos=r[i]; diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h index e1edc47f9fa..4a5091e7544 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/visual/visual_server_canvas.h @@ -201,8 +201,8 @@ public: void canvas_light_occluder_set_light_mask(RID p_occluder,int p_mask); RID canvas_occluder_polygon_create(); - void canvas_occluder_polygon_set_shape(RID p_occluder_polygon,const DVector& p_shape,bool p_closed); - void canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon,const DVector& p_shape); + void canvas_occluder_polygon_set_shape(RID p_occluder_polygon,const PoolVector& p_shape,bool p_closed); + void canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon,const PoolVector& p_shape); void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon,VS::CanvasOccluderPolygonCullMode p_mode); diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 58cfab3b970..3262479c432 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -819,13 +819,13 @@ Vector3 VisualServerRaster::particles_get_emission_base_velocity(RID p_particles return rasterizer->particles_get_emission_base_velocity(p_particles); } -void VisualServerRaster::particles_set_emission_points(RID p_particles, const DVector& p_points) { +void VisualServerRaster::particles_set_emission_points(RID p_particles, const PoolVector& p_points) { VS_CHANGED; rasterizer->particles_set_emission_points(p_particles,p_points); } -DVector VisualServerRaster::particles_get_emission_points(RID p_particles) const { +PoolVector VisualServerRaster::particles_get_emission_points(RID p_particles) const { return rasterizer->particles_get_emission_points(p_particles); } @@ -1279,7 +1279,7 @@ float VisualServerRaster::baked_light_get_lightmap_multiplier(RID p_baked_light) } -void VisualServerRaster::baked_light_set_octree(RID p_baked_light,const DVector p_octree){ +void VisualServerRaster::baked_light_set_octree(RID p_baked_light,const PoolVector p_octree){ VS_CHANGED; BakedLight *baked_light = baked_light_owner.get(p_baked_light); @@ -1301,7 +1301,7 @@ void VisualServerRaster::baked_light_set_octree(RID p_baked_light,const DVector< bool has_light_tex=false; { - DVector::Read r=p_octree.read(); + PoolVector::Read r=p_octree.read(); tex_w = decode_uint32(&r[0]); tex_h = decode_uint32(&r[4]); print_line("TEX W: "+itos(tex_w)+" TEX H:"+itos(tex_h)+" LEN: "+itos(p_octree.size())); @@ -1386,22 +1386,22 @@ void VisualServerRaster::baked_light_set_octree(RID p_baked_light,const DVector< } -DVector VisualServerRaster::baked_light_get_octree(RID p_baked_light) const{ +PoolVector VisualServerRaster::baked_light_get_octree(RID p_baked_light) const{ BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND_V(!baked_light,DVector()); + ERR_FAIL_COND_V(!baked_light,PoolVector()); if (rasterizer->is_texture(baked_light->data.octree_texture)) { Image img = rasterizer->texture_get_data(baked_light->data.octree_texture); return img.get_data(); } else { - return DVector(); + return PoolVector(); } } -void VisualServerRaster::baked_light_set_light(RID p_baked_light,const DVector p_light) { +void VisualServerRaster::baked_light_set_light(RID p_baked_light,const PoolVector p_light) { VS_CHANGED; BakedLight *baked_light = baked_light_owner.get(p_baked_light); @@ -1425,23 +1425,23 @@ void VisualServerRaster::baked_light_set_light(RID p_baked_light,const DVector VisualServerRaster::baked_light_get_light(RID p_baked_light) const{ +PoolVector VisualServerRaster::baked_light_get_light(RID p_baked_light) const{ BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND_V(!baked_light,DVector()); + ERR_FAIL_COND_V(!baked_light,PoolVector()); if (rasterizer->is_texture(baked_light->data.light_texture)) { Image img = rasterizer->texture_get_data(baked_light->data.light_texture); return img.get_data(); } else { - return DVector(); + return PoolVector(); } } -void VisualServerRaster::baked_light_set_sampler_octree(RID p_baked_light, const DVector &p_sampler) { +void VisualServerRaster::baked_light_set_sampler_octree(RID p_baked_light, const PoolVector &p_sampler) { BakedLight *baked_light = baked_light_owner.get(p_baked_light); ERR_FAIL_COND(!baked_light); @@ -1452,10 +1452,10 @@ void VisualServerRaster::baked_light_set_sampler_octree(RID p_baked_light, const } -DVector VisualServerRaster::baked_light_get_sampler_octree(RID p_baked_light) const { +PoolVector VisualServerRaster::baked_light_get_sampler_octree(RID p_baked_light) const { BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND_V(!baked_light,DVector()); + ERR_FAIL_COND_V(!baked_light,PoolVector()); return baked_light->sampler; @@ -4466,20 +4466,20 @@ RID VisualServerRaster::canvas_occluder_polygon_create() { } -void VisualServerRaster::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const DVector& p_shape, bool p_close){ +void VisualServerRaster::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const PoolVector& p_shape, bool p_close){ if (p_shape.size()<3) { canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon,p_shape); return; } - DVector lines; + PoolVector lines; int lc = p_shape.size()*2; lines.resize(lc-(p_close?0:2)); { - DVector::Write w = lines.write(); - DVector::Read r = p_shape.read(); + PoolVector::Write w = lines.write(); + PoolVector::Read r = p_shape.read(); int max=lc/2; if (!p_close) { @@ -4498,7 +4498,7 @@ void VisualServerRaster::canvas_occluder_polygon_set_shape(RID p_occluder_polygo canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon,lines); } -void VisualServerRaster::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon,const DVector& p_shape) { +void VisualServerRaster::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon,const PoolVector& p_shape) { CanvasLightOccluderPolygon * occluder_poly = canvas_light_occluder_polygon_owner.get(p_occluder_polygon); ERR_FAIL_COND(!occluder_poly); @@ -4507,7 +4507,7 @@ void VisualServerRaster::canvas_occluder_polygon_set_shape_as_lines(RID p_occlud int lc = p_shape.size(); occluder_poly->aabb=Rect2(); { - DVector::Read r = p_shape.read(); + PoolVector::Read r = p_shape.read(); for(int i=0;iaabb.pos=r[i]; @@ -6338,7 +6338,7 @@ void VisualServerRaster::_process_sampled_light(const Transform& p_camera,Instan AABB sample_aabb= bl->data.transform.affine_inverse().xform(AABB(Vector3(-r,-r,-r)+p_sampled_light->data.transform.origin,Vector3(r*2,r*2,r*2))); //ok got octree local AABB - DVector::Read rp = bl->baked_light_info->baked_light->sampler.read(); + PoolVector::Read rp = bl->baked_light_info->baked_light->sampler.read(); const int *rptr = rp.ptr(); int first = rptr[1]; diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 0f75d7ab8be..5fb71aa0f58 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -103,7 +103,7 @@ class VisualServerRaster : public VisualServer { struct BakedLight { Rasterizer::BakedLightData data; - DVector sampler; + PoolVector sampler; AABB octree_aabb; Size2i octree_tex_size; Size2i light_tex_size; @@ -671,7 +671,7 @@ public: BIND0R(RID,mesh_create) - BIND10(mesh_add_surface,RID,uint32_t,PrimitiveType,const DVector&,int ,const DVector& ,int ,const AABB&,const Vector >&,const Vector& ) + BIND10(mesh_add_surface,RID,uint32_t,PrimitiveType,const PoolVector&,int ,const PoolVector& ,int ,const AABB&,const Vector >&,const Vector& ) BIND2(mesh_set_morph_target_count,RID,int) BIND1RC(int,mesh_get_morph_target_count,RID) @@ -686,14 +686,14 @@ public: BIND2RC(int,mesh_surface_get_array_len,RID,int) BIND2RC(int,mesh_surface_get_array_index_len,RID,int) - BIND2RC(DVector,mesh_surface_get_array,RID,int) - BIND2RC(DVector,mesh_surface_get_index_array,RID, int) + BIND2RC(PoolVector,mesh_surface_get_array,RID,int) + BIND2RC(PoolVector,mesh_surface_get_index_array,RID, int) BIND2RC(uint32_t,mesh_surface_get_format,RID,int) BIND2RC(PrimitiveType,mesh_surface_get_primitive_type,RID,int) BIND2RC(AABB,mesh_surface_get_aabb,RID,int) - BIND2RC(Vector >,mesh_surface_get_blend_shapes,RID,int) + BIND2RC(Vector >,mesh_surface_get_blend_shapes,RID,int) BIND2RC(Vector,mesh_surface_get_skeleton_aabb,RID,int) BIND2(mesh_remove_surface,RID,int) @@ -791,7 +791,7 @@ public: /* ROOM API */ BIND0R(RID,room_create) - BIND4(room_add_bounds,RID, const DVector& ,float ,const Transform& ) + BIND4(room_add_bounds,RID, const PoolVector& ,float ,const Transform& ) BIND1(room_clear_bounds,RID) /* PORTAL API */ @@ -830,8 +830,8 @@ public: BIND2(gi_probe_set_compress,RID,bool) BIND1RC(bool,gi_probe_is_compressed,RID) - BIND2(gi_probe_set_dynamic_data,RID,const DVector& ) - BIND1RC( DVector,gi_probe_get_dynamic_data,RID) + BIND2(gi_probe_set_dynamic_data,RID,const PoolVector& ) + BIND1RC( PoolVector,gi_probe_get_dynamic_data,RID) /* PARTICLES */ @@ -851,7 +851,7 @@ public: BIND2(particles_set_emission_shape,RID,VS::ParticlesEmissionShape ) BIND2(particles_set_emission_sphere_radius,RID,float ) BIND2(particles_set_emission_box_extents,RID,const Vector3& ) - BIND2(particles_set_emission_points,RID,const DVector& ) + BIND2(particles_set_emission_points,RID,const PoolVector& ) BIND2(particles_set_draw_order,RID,VS::ParticlesDrawOrder ) @@ -1088,8 +1088,8 @@ public: BIND0R(RID,canvas_occluder_polygon_create) - BIND3(canvas_occluder_polygon_set_shape,RID,const DVector& ,bool) - BIND2(canvas_occluder_polygon_set_shape_as_lines,RID ,const DVector&) + BIND3(canvas_occluder_polygon_set_shape,RID,const PoolVector& ,bool) + BIND2(canvas_occluder_polygon_set_shape_as_lines,RID ,const PoolVector&) BIND2(canvas_occluder_polygon_set_cull_mode,RID,CanvasOccluderPolygonCullMode) diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 816d4230346..0f789d96952 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -2423,14 +2423,14 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) { if (probe->dynamic.light_data.size()==0) return; //using dynamic data - DVector::Read r=probe->dynamic.light_data.read(); + PoolVector::Read r=probe->dynamic.light_data.read(); const GIProbeDataHeader *header = (GIProbeDataHeader *)r.ptr(); probe->dynamic.local_data.resize(header->cell_count); int cell_count = probe->dynamic.local_data.size(); - DVector::Write ldw = probe->dynamic.local_data.write(); + PoolVector::Write ldw = probe->dynamic.local_data.write(); const GIProbeDataCell *cells = (GIProbeDataCell*)&r[16]; probe->dynamic.level_cell_lists.resize(header->cell_subdiv); @@ -2466,13 +2466,13 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) { uint32_t z = header->depth >> i; //create and clear mipmap - DVector mipmap; + PoolVector mipmap; int size = x*y*z*4; size/=size_divisor; mipmap.resize(size); - DVector::Write w = mipmap.write(); + PoolVector::Write w = mipmap.write(); zeromem(w.ptr(),size); - w = DVector::Write(); + w = PoolVector::Write(); probe->dynamic.mipmaps_3d.push_back(mipmap); @@ -2547,7 +2547,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) { for(int i=0;idynamic.mipmaps_s3tc[i].resize(comp_blocks[i].size()); - DVector::Write w = probe->dynamic.mipmaps_s3tc[i].write(); + PoolVector::Write w = probe->dynamic.mipmaps_s3tc[i].write(); int block_idx=0; for (Map::Element *E=comp_blocks[i].front();E;E=E->next()) { @@ -2979,7 +2979,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) { InstanceGIProbeData * probe_data = static_cast(p_gi_probe->base_data); - DVector::Read r=probe_data->dynamic.light_data.read(); + PoolVector::Read r=probe_data->dynamic.light_data.read(); const GIProbeDataHeader *header = (const GIProbeDataHeader *)r.ptr(); const GIProbeDataCell *cells = (const GIProbeDataCell*)&r[16]; @@ -2987,7 +2987,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) { int leaf_count = probe_data->dynamic.level_cell_lists[ header->cell_subdiv -1 ].size(); const uint32_t *leaves = probe_data->dynamic.level_cell_lists[ header->cell_subdiv -1 ].ptr(); - DVector::Write ldw = probe_data->dynamic.local_data.write(); + PoolVector::Write ldw = probe_data->dynamic.local_data.write(); InstanceGIProbeData::LocalData *local_data = ldw.ptr(); @@ -3039,7 +3039,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) { int level_cell_count = probe_data->dynamic.level_cell_lists[ i ].size(); const uint32_t *level_cells = probe_data->dynamic.level_cell_lists[ i ].ptr(); - DVector::Write lw = probe_data->dynamic.mipmaps_3d[stage].write(); + PoolVector::Write lw = probe_data->dynamic.mipmaps_3d[stage].write(); uint8_t *mipmapw = lw.ptr(); uint32_t sizes[3]={header->width>>stage,header->height>>stage,header->depth>>stage}; @@ -3071,9 +3071,9 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) { for(int mmi=0;mmi::Write mmw = probe_data->dynamic.mipmaps_3d[mmi].write(); + PoolVector::Write mmw = probe_data->dynamic.mipmaps_3d[mmi].write(); int block_count = probe_data->dynamic.mipmaps_s3tc[mmi].size(); - DVector::Read mmr = probe_data->dynamic.mipmaps_s3tc[mmi].read(); + PoolVector::Read mmr = probe_data->dynamic.mipmaps_s3tc[mmi].read(); for(int i=0;idynamic.mipmaps_3d.size();i++) { int mmsize = probe->dynamic.mipmaps_3d[i].size(); - DVector::Read r = probe->dynamic.mipmaps_3d[i].read(); + PoolVector::Read r = probe->dynamic.mipmaps_3d[i].read(); VSG::storage->gi_probe_dynamic_data_update(probe->dynamic.probe_data,0,probe->dynamic.grid_size[2]>>i,i,r.ptr()); } diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h index 300db1b41ca..ac272467b43 100644 --- a/servers/visual/visual_server_scene.h +++ b/servers/visual/visual_server_scene.h @@ -45,7 +45,7 @@ public: struct BakedLight { Rasterizer::BakedLightData data; - DVector sampler; + PoolVector sampler; AABB octree_aabb; Size2i octree_tex_size; Size2i light_tex_size; @@ -433,16 +433,16 @@ public: Map light_cache; Map light_cache_changes; - DVector light_data; - DVector local_data; + PoolVector light_data; + PoolVector local_data; Vector > level_cell_lists; RID probe_data; bool enabled; int bake_dynamic_range; RasterizerStorage::GIProbeCompression compression; - Vector< DVector > mipmaps_3d; - Vector< DVector > mipmaps_s3tc; //for s3tc + Vector< PoolVector > mipmaps_3d; + Vector< PoolVector > mipmaps_s3tc; //for s3tc int updating_stage; diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 3e6c30d6f5a..9de17dc431b 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -40,11 +40,11 @@ VisualServer *VisualServer::get_singleton() { -DVector VisualServer::_shader_get_param_list(RID p_shader) const { +PoolVector VisualServer::_shader_get_param_list(RID p_shader) const { //remove at some point - DVector pl; + PoolVector pl; #if 0 @@ -90,11 +90,11 @@ RID VisualServer::get_test_texture() { #define TEST_TEXTURE_SIZE 256 - DVector test_data; + PoolVector test_data; test_data.resize(TEST_TEXTURE_SIZE*TEST_TEXTURE_SIZE*3); { - DVector::Write w=test_data.write(); + PoolVector::Write w=test_data.write(); for (int x=0;x vertices; - DVector normals; - DVector tangents; - DVector uvs; + PoolVector vertices; + PoolVector normals; + PoolVector tangents; + PoolVector uvs; int vtx_idx=0; #define ADD_VTX(m_idx);\ @@ -211,7 +211,7 @@ RID VisualServer::_make_test_cube() { d[VisualServer::ARRAY_TEX_UV]= uvs ; d[VisualServer::ARRAY_VERTEX]= vertices ; - DVector indices; + PoolVector indices; indices.resize(vertices.size()); for(int i=0;i vertices; - DVector normals; + PoolVector vertices; + PoolVector normals; for(int i = 1; i <= p_lats; i++) { double lat0 = Math_PI * (-0.5 + (double) (i - 1) / p_lats); @@ -329,10 +329,10 @@ RID VisualServer::get_white_texture() { if (white_texture.is_valid()) return white_texture; - DVector wt; + PoolVector wt; wt.resize(16*3); { - DVector::Write w =wt.write(); + PoolVector::Write w =wt.write(); for(int i=0;i<16*3;i++) w[i]=255; } @@ -345,13 +345,16 @@ RID VisualServer::get_white_texture() { } -Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t *p_offsets,uint32_t p_stride,DVector &r_vertex_array,int p_vertex_array_len,DVector &r_index_array,int p_index_array_len,AABB &r_aabb,Vector r_bone_aabb) { +Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t *p_offsets,uint32_t p_stride,PoolVector &r_vertex_array,int p_vertex_array_len,PoolVector &r_index_array,int p_index_array_len,AABB &r_aabb,Vector r_bone_aabb) { - DVector::Write vw = r_vertex_array.write(); + PoolVector::Write vw = r_vertex_array.write(); - DVector::Write iw; + PoolVector::Write iw; if (r_index_array.size()) { + print_line("elements: "+itos(r_index_array.size())); + iw=r_index_array.write(); + } int max_bone=0; @@ -369,11 +372,11 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t if (p_format& VS::ARRAY_FLAG_USE_2D_VERTICES) { - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const Vector2* src=read.ptr(); // setting vertices means regenerating the AABB @@ -421,11 +424,11 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t } else { - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const Vector3* src=read.ptr(); // setting vertices means regenerating the AABB @@ -479,11 +482,11 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const Vector3* src=read.ptr(); // setting vertices means regenerating the AABB @@ -519,12 +522,12 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_vertex_array_len*4, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const real_t* src = read.ptr(); if (p_format&ARRAY_COMPRESS_TANGENT) { @@ -564,12 +567,12 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::COLOR_ARRAY, ERR_INVALID_PARAMETER ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const Color* src = read.ptr(); if (p_format&ARRAY_COMPRESS_COLOR) { @@ -603,11 +606,11 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::VECTOR2_ARRAY, ERR_INVALID_PARAMETER ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_vertex_array_len , ERR_INVALID_PARAMETER); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const Vector2 * src=read.ptr(); @@ -639,11 +642,11 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::VECTOR2_ARRAY, ERR_INVALID_PARAMETER ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_vertex_array_len , ERR_INVALID_PARAMETER); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const Vector2 * src=read.ptr(); @@ -671,12 +674,12 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_vertex_array_len*VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const real_t * src = read.ptr(); @@ -711,12 +714,12 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER ); - DVector array = p_arrays[ai]; + PoolVector array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_vertex_array_len*VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER ); - DVector::Read read = array.read(); + PoolVector::Read read = array.read(); const int * src = read.ptr(); @@ -761,13 +764,13 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t ERR_FAIL_COND_V( p_index_array_len<=0, ERR_INVALID_DATA ); ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER ); - DVector indices = p_arrays[ai]; + PoolVector indices = p_arrays[ai]; ERR_FAIL_COND_V( indices.size() == 0, ERR_INVALID_PARAMETER ); ERR_FAIL_COND_V( indices.size() != p_index_array_len, ERR_INVALID_PARAMETER ); /* determine wether using 16 or 32 bits indices */ - DVector::Read read = indices.read(); + PoolVector::Read read = indices.read(); const int *src=read.ptr(); for (int i=0;i vertices = p_arrays[VS::ARRAY_VERTEX]; - DVector bones = p_arrays[VS::ARRAY_BONES]; - DVector weights = p_arrays[VS::ARRAY_WEIGHTS]; + PoolVector vertices = p_arrays[VS::ARRAY_VERTEX]; + PoolVector bones = p_arrays[VS::ARRAY_BONES]; + PoolVector weights = p_arrays[VS::ARRAY_WEIGHTS]; bool any_valid=false; if (vertices.size() && bones.size()==vertices.size()*4 && weights.size()==bones.size()) { int vs = vertices.size(); - DVector::Read rv =vertices.read(); - DVector::Read rb=bones.read(); - DVector::Read rw=weights.read(); + PoolVector::Read rv =vertices.read(); + PoolVector::Read rb=bones.read(); + PoolVector::Read rw=weights.read(); AABB *bptr = r_bone_aabb.ptr(); @@ -875,11 +878,11 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primi Variant var = p_arrays[i]; switch(var.get_type()) { case Variant::VECTOR2_ARRAY: { - DVector v2 = var; + PoolVector v2 = var; array_len=v2.size(); } break; case Variant::VECTOR3_ARRAY: { - DVector v3 = var; + PoolVector v3 = var; array_len=v3.size(); } break; default: { @@ -1012,12 +1015,12 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primi } break; case VS::ARRAY_BONES: { - DVector bones = p_arrays[VS::ARRAY_BONES]; + PoolVector bones = p_arrays[VS::ARRAY_BONES]; int max_bone=0; { int bc = bones.size(); - DVector::Read r=bones.read(); + PoolVector::Read r=bones.read(); for(int j=0;j vertex_array; + PoolVector vertex_array; vertex_array.resize(array_size); int index_array_size = offsets[VS::ARRAY_INDEX]*index_array_len; - DVector index_array; + PoolVector index_array; index_array.resize(index_array_size); AABB aabb; @@ -1085,13 +1088,13 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primi ERR_FAIL_COND(err!=OK); } - Vector > blend_shape_data; + Vector > blend_shape_data; for(int i=0;i vertex_array_shape; + PoolVector vertex_array_shape; vertex_array_shape.resize(array_size); - DVector noindex; + PoolVector noindex; AABB laabb; Error err = _surface_set_data(p_blend_shapes[i],format&~ARRAY_FORMAT_INDEX,offsets,total_elem_size,vertex_array_shape,array_len,noindex,0,laabb,bone_aabb); @@ -1108,7 +1111,7 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primi } -Array VisualServer::_get_array_from_surface(uint32_t p_format,DVector p_vertex_data,int p_vertex_len,DVector p_index_data,int p_index_len) const { +Array VisualServer::_get_array_from_surface(uint32_t p_format,PoolVector p_vertex_data,int p_vertex_len,PoolVector p_index_data,int p_index_len) const { uint32_t offsets[ARRAY_MAX]; @@ -1240,7 +1243,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format,DVector p Array ret; ret.resize(VS::ARRAY_MAX); - DVector::Read r = p_vertex_data.read(); + PoolVector::Read r = p_vertex_data.read(); for(int i=0;i p if (p_format&ARRAY_FLAG_USE_2D_VERTICES) { - DVector arr_2d; + PoolVector arr_2d; arr_2d.resize(p_vertex_len); if (p_format&ARRAY_COMPRESS_VERTEX) { - DVector::Write w = arr_2d.write(); + PoolVector::Write w = arr_2d.write(); for(int j=0;j p } } else { - DVector::Write w = arr_2d.write(); + PoolVector::Write w = arr_2d.write(); for(int j=0;j p ret[i]=arr_2d; } else { - DVector arr_3d; + PoolVector arr_3d; arr_3d.resize(p_vertex_len); if (p_format&ARRAY_COMPRESS_VERTEX) { - DVector::Write w = arr_3d.write(); + PoolVector::Write w = arr_3d.write(); for(int j=0;j p } } else { - DVector::Write w = arr_3d.write(); + PoolVector::Write w = arr_3d.write(); for(int j=0;j p } break; case VS::ARRAY_NORMAL: { - DVector arr; + PoolVector arr; arr.resize(p_vertex_len); if (p_format&ARRAY_COMPRESS_NORMAL) { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p w[j]=Vector3( float(v[0]/255.0)*2.0-1.0, float(v[1]/255.0)*2.0-1.0, float(v[2]/255.0)*2.0-1.0 ); } } else { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p } break; case VS::ARRAY_TANGENT: { - DVector arr; + PoolVector arr; arr.resize(p_vertex_len*4); if (p_format&ARRAY_COMPRESS_TANGENT) { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p } } else { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p } break; case VS::ARRAY_COLOR: { - DVector arr; + PoolVector arr; arr.resize(p_vertex_len); if (p_format&ARRAY_COMPRESS_COLOR) { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p w[j]=Color( float(v[0]/255.0)*2.0-1.0, float(v[1]/255.0)*2.0-1.0, float(v[2]/255.0)*2.0-1.0, float(v[3]/255.0)*2.0-1.0 ); } } else { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p } break; case VS::ARRAY_TEX_UV: { - DVector arr; + PoolVector arr; arr.resize(p_vertex_len); if (p_format&ARRAY_COMPRESS_TEX_UV) { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p } } else { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p } break; case VS::ARRAY_TEX_UV2: { - DVector arr; + PoolVector arr; arr.resize(p_vertex_len); if (p_format&ARRAY_COMPRESS_TEX_UV2) { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p } } else { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p } break; case VS::ARRAY_WEIGHTS: { - DVector arr; + PoolVector arr; arr.resize(p_vertex_len*4); if (p_format&ARRAY_COMPRESS_WEIGHTS) { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p } } else { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p } break; case VS::ARRAY_BONES: { - DVector arr; + PoolVector arr; arr.resize(p_vertex_len*4); if (p_format&ARRAY_FLAG_USE_16_BIT_BONES) { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p } } else { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p case VS::ARRAY_INDEX: { /* determine wether using 16 or 32 bits indices */ - DVector::Read ir = p_index_data.read(); + PoolVector::Read ir = p_index_data.read(); - DVector arr; + PoolVector arr; arr.resize(p_index_len); if (p_vertex_len<(1<<16)) { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p } } else { - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int j=0;j p Array VisualServer::mesh_surface_get_arrays(RID p_mesh,int p_surface) const { - DVector vertex_data = mesh_surface_get_array(p_mesh,p_surface); + PoolVector vertex_data = mesh_surface_get_array(p_mesh,p_surface); ERR_FAIL_COND_V(vertex_data.size()==0,Array()); int vertex_len = mesh_surface_get_array_len(p_mesh,p_surface); - DVector index_data = mesh_surface_get_index_array(p_mesh,p_surface); + PoolVector index_data = mesh_surface_get_index_array(p_mesh,p_surface); int index_len = mesh_surface_get_array_index_len(p_mesh,p_surface); uint32_t format = mesh_surface_get_format(p_mesh,p_surface); @@ -1598,8 +1601,8 @@ void VisualServer::_camera_set_orthogonal(RID p_camera,float p_size,float p_z_ne void VisualServer::mesh_add_surface_from_mesh_data( RID p_mesh, const Geometry::MeshData& p_mesh_data) { #if 1 - DVector vertices; - DVector normals; + PoolVector vertices; + PoolVector normals; for (int i=0;i vertices; + PoolVector vertices; @@ -1649,7 +1652,7 @@ void VisualServer::mesh_add_surface_from_mesh_data( RID p_mesh, const Geometry:: } -void VisualServer::mesh_add_surface_from_planes( RID p_mesh, const DVector& p_planes) { +void VisualServer::mesh_add_surface_from_planes( RID p_mesh, const PoolVector& p_planes) { Geometry::MeshData mdata = Geometry::build_convex_mesh(p_planes); diff --git a/servers/visual_server.h b/servers/visual_server.h index 16f14655df1..d1a20dd6ba0 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -48,10 +48,10 @@ class VisualServer : public Object { int mm_policy; - DVector _shader_get_param_list(RID p_shader) const; + PoolVector _shader_get_param_list(RID p_shader) const; void _camera_set_orthogonal(RID p_camera,float p_size,float p_z_near,float p_z_far); void _canvas_item_add_style_box(RID p_item, const Rect2& p_rect, const Rect2& p_source, RID p_texture,const Vector& p_margins, const Color& p_modulate=Color(1,1,1)); - Array _get_array_from_surface(uint32_t p_format,DVector p_vertex_data,int p_vertex_len,DVector p_index_data,int p_index_len) const; + Array _get_array_from_surface(uint32_t p_format,PoolVector p_vertex_data,int p_vertex_len,PoolVector p_index_data,int p_index_len) const; protected: RID _make_test_cube(); @@ -62,7 +62,7 @@ protected: RID material_2d[16]; - Error _surface_set_data(Array p_arrays,uint32_t p_format,uint32_t *p_offsets,uint32_t p_stride,DVector &r_vertex_array,int p_vertex_array_len,DVector &r_index_array,int p_index_array_len,AABB &r_aabb,Vector r_bone_aabb); + Error _surface_set_data(Array p_arrays,uint32_t p_format,uint32_t *p_offsets,uint32_t p_stride,PoolVector &r_vertex_array,int p_vertex_array_len,PoolVector &r_index_array,int p_index_array_len,AABB &r_aabb,Vector r_bone_aabb); static VisualServer* (*create_func)(); static void _bind_methods(); @@ -244,7 +244,7 @@ public: virtual void mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes=Array(),uint32_t p_compress_format=ARRAY_COMPRESS_DEFAULT); - virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,PrimitiveType p_primitive,const DVector& p_array,int p_vertex_count,const DVector& p_index_array,int p_index_count,const AABB& p_aabb,const Vector >& p_blend_shapes=Vector >(),const Vector& p_bone_aabbs=Vector())=0; + virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,PrimitiveType p_primitive,const PoolVector& p_array,int p_vertex_count,const PoolVector& p_index_array,int p_index_count,const AABB& p_aabb,const Vector >& p_blend_shapes=Vector >(),const Vector& p_bone_aabbs=Vector())=0; virtual void mesh_set_morph_target_count(RID p_mesh,int p_amount)=0; virtual int mesh_get_morph_target_count(RID p_mesh) const=0; @@ -263,8 +263,8 @@ public: virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const=0; virtual int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const=0; - virtual DVector mesh_surface_get_array(RID p_mesh, int p_surface) const=0; - virtual DVector mesh_surface_get_index_array(RID p_mesh, int p_surface) const=0; + virtual PoolVector mesh_surface_get_array(RID p_mesh, int p_surface) const=0; + virtual PoolVector mesh_surface_get_index_array(RID p_mesh, int p_surface) const=0; virtual Array mesh_surface_get_arrays(RID p_mesh,int p_surface) const; @@ -272,7 +272,7 @@ public: virtual PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const=0; virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const=0; - virtual Vector > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const=0; + virtual Vector > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const=0; virtual Vector mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const=0; virtual void mesh_remove_surface(RID p_mesh,int p_index)=0; @@ -433,7 +433,7 @@ public: /* ROOM API */ virtual RID room_create()=0; - virtual void room_add_bounds(RID p_room, const DVector& p_convex_polygon,float p_height,const Transform& p_transform)=0; + virtual void room_add_bounds(RID p_room, const PoolVector& p_convex_polygon,float p_height,const Transform& p_transform)=0; virtual void room_clear_bounds(RID p_room)=0; /* PORTAL API */ @@ -460,8 +460,8 @@ public: virtual void gi_probe_set_to_cell_xform(RID p_probe,const Transform& p_xform)=0; virtual Transform gi_probe_get_to_cell_xform(RID p_probe) const=0; - virtual void gi_probe_set_dynamic_data(RID p_probe,const DVector& p_data)=0; - virtual DVector gi_probe_get_dynamic_data(RID p_probe) const=0; + virtual void gi_probe_set_dynamic_data(RID p_probe,const PoolVector& p_data)=0; + virtual PoolVector gi_probe_get_dynamic_data(RID p_probe) const=0; virtual void gi_probe_set_dynamic_range(RID p_probe,int p_range)=0; virtual int gi_probe_get_dynamic_range(RID p_probe) const=0; @@ -501,7 +501,7 @@ public: virtual void particles_set_emission_shape(RID p_particles,ParticlesEmissionShape)=0; virtual void particles_set_emission_sphere_radius(RID p_particles,float p_radius)=0; virtual void particles_set_emission_box_extents(RID p_particles,const Vector3& p_extents)=0; - virtual void particles_set_emission_points(RID p_particles,const DVector& p_points)=0; + virtual void particles_set_emission_points(RID p_particles,const PoolVector& p_points)=0; enum ParticlesDrawOrder { PARTICLES_DRAW_ORDER_INDEX, @@ -856,8 +856,8 @@ public: virtual void canvas_light_occluder_set_light_mask(RID p_occluder,int p_mask)=0; virtual RID canvas_occluder_polygon_create()=0; - virtual void canvas_occluder_polygon_set_shape(RID p_occluder_polygon,const DVector& p_shape,bool p_closed)=0; - virtual void canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon,const DVector& p_shape)=0; + virtual void canvas_occluder_polygon_set_shape(RID p_occluder_polygon,const PoolVector& p_shape,bool p_closed)=0; + virtual void canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon,const PoolVector& p_shape)=0; enum CanvasOccluderPolygonCullMode { CANVAS_OCCLUDER_POLYGON_CULL_DISABLED, @@ -926,7 +926,7 @@ public: virtual RID make_sphere_mesh(int p_lats,int p_lons,float p_radius); virtual void mesh_add_surface_from_mesh_data( RID p_mesh, const Geometry::MeshData& p_mesh_data); - virtual void mesh_add_surface_from_planes( RID p_mesh, const DVector& p_planes); + virtual void mesh_add_surface_from_planes( RID p_mesh, const PoolVector& p_planes); virtual void set_boot_image(const Image& p_image, const Color& p_color,bool p_scale)=0; virtual void set_default_clear_color(const Color& p_color)=0; diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index dfdd14673c7..07cb72a6b0c 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -313,7 +313,7 @@ void EditorFileDialog::_action_pressed() { String fbase=dir_access->get_current_dir(); - DVector files; + PoolVector files; for(int i=0;iget_item_count();i++) { if (item_list->is_selected(i)) files.push_back( fbase.plus_file(item_list->get_item_text(i) )); diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index 1245efafa1f..c1be2cd9405 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -2174,9 +2174,9 @@ bool EditorImportExport::sample_get_trim() const{ return sample_action_trim; } -DVector EditorImportExport::_get_export_file_list() { +PoolVector EditorImportExport::_get_export_file_list() { - DVector fl; + PoolVector fl; for (Map::Element *E=files.front();E;E=E->next()) { fl.push_back(E->key()); @@ -2185,9 +2185,9 @@ DVector EditorImportExport::_get_export_file_list() { return fl; } -DVector EditorImportExport::_get_export_platforms() { +PoolVector EditorImportExport::_get_export_platforms() { - DVector ep; + PoolVector ep; for (Map >::Element *E=exporters.front();E;E=E->next()) { ep.push_back(E->key()); diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h index 9109e9ae9ff..fb75373f171 100644 --- a/tools/editor/editor_import_export.h +++ b/tools/editor/editor_import_export.h @@ -321,8 +321,8 @@ protected: static EditorImportExport* singleton; - DVector _get_export_file_list(); - DVector _get_export_platforms(); + PoolVector _get_export_file_list(); + PoolVector _get_export_platforms(); static void _bind_methods(); public: diff --git a/tools/editor/editor_profiler.cpp b/tools/editor/editor_profiler.cpp index 5c7b7407b4c..5a6de2fa1a2 100644 --- a/tools/editor/editor_profiler.cpp +++ b/tools/editor/editor_profiler.cpp @@ -154,7 +154,7 @@ void EditorProfiler::_update_plot() { } - DVector::Write wr = graph_image.write(); + PoolVector::Write wr = graph_image.write(); @@ -336,7 +336,7 @@ void EditorProfiler::_update_plot() { } - wr = DVector::Write(); + wr = PoolVector::Write(); Image img(w,h,0,Image::FORMAT_RGBA8,graph_image); diff --git a/tools/editor/editor_profiler.h b/tools/editor/editor_profiler.h index 4e18f2e29a1..233bc2e0fd8 100644 --- a/tools/editor/editor_profiler.h +++ b/tools/editor/editor_profiler.h @@ -73,7 +73,7 @@ private: Button *activate; TextureFrame *graph; Ref graph_texture; - DVector graph_image; + PoolVector graph_image; Tree *variables; HSplitContainer *h_split; diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index 2bc29039eab..861af594551 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -1380,10 +1380,10 @@ Ref EditorFontImportPlugin::generate_font(const Refwidth; int oh=font_data_list[i]->height; - DVector pixels; + PoolVector pixels; pixels.resize(s.x*s.y*4); - DVector::Write w = pixels.write(); + PoolVector::Write w = pixels.write(); //print_line("val: "+itos(font_data_list[i]->valign)); for(int y=0;y EditorFontImportPlugin::generate_font(const Ref::Write(); + w=PoolVector::Write(); Image img(s.width,s.height,0,Image::FORMAT_RGBA8,pixels); @@ -1552,10 +1552,10 @@ Ref EditorFontImportPlugin::generate_font(const Refhas_option("advanced/premultiply_alpha") && bool(from->get_option("advanced/premultiply_alpha"))) { - DVector data = atlas.get_data(); + PoolVector data = atlas.get_data(); int dl = data.size(); { - DVector::Write w = data.write(); + PoolVector::Write w = data.write(); for(int i=0;i& p_indices,const DVector& p_vertices,DVector&r_normals) { +static void _generate_normals(const PoolVector& p_indices,const PoolVector& p_vertices,PoolVector&r_normals) { r_normals.resize(p_vertices.size()); - DVector::Write narrayw = r_normals.write(); + PoolVector::Write narrayw = r_normals.write(); int iacount=p_indices.size()/3; - DVector::Read index_arrayr = p_indices.read(); - DVector::Read vertex_arrayr = p_vertices.read(); + PoolVector::Read index_arrayr = p_indices.read(); + PoolVector::Read vertex_arrayr = p_vertices.read(); for(int idx=0;idx& p_indices,const DVector& p_indices,const DVector& p_vertices,const DVector& p_uvs,const DVector& p_normals,DVector&r_tangents) { +static void _generate_tangents_and_binormals(const PoolVector& p_indices,const PoolVector& p_vertices,const PoolVector& p_uvs,const PoolVector& p_normals,PoolVector&r_tangents) { int vlen=p_vertices.size(); @@ -531,10 +531,10 @@ static void _generate_tangents_and_binormals(const DVector& p_indices,const int iacount=p_indices.size()/3; - DVector::Read index_arrayr = p_indices.read(); - DVector::Read vertex_arrayr = p_vertices.read(); - DVector::Read narrayr = p_normals.read(); - DVector::Read uvarrayr = p_uvs.read(); + PoolVector::Read index_arrayr = p_indices.read(); + PoolVector::Read vertex_arrayr = p_vertices.read(); + PoolVector::Read narrayr = p_normals.read(); + PoolVector::Read uvarrayr = p_uvs.read(); for(int idx=0;idx& p_indices,const } r_tangents.resize(vlen*4); - DVector::Write tarrayw = r_tangents.write(); + PoolVector::Write tarrayw = r_tangents.write(); for(int idx=0;idx& p_mesh,con } - DVector index_array; + PoolVector index_array; index_array.resize(indices_list.size()); - DVector::Write index_arrayw = index_array.write(); + PoolVector::Write index_arrayw = index_array.write(); int iidx=0; for(List::Element *F=indices_list.front();F;F=F->next()) { @@ -1041,7 +1041,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref& p_mesh,con index_arrayw[iidx++]=F->get(); } - index_arrayw=DVector::Write(); + index_arrayw=PoolVector::Write(); /*****************/ @@ -1075,14 +1075,14 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref& p_mesh,con - DVector final_vertex_array; - DVector final_normal_array; - DVector final_tangent_array; - DVector final_color_array; - DVector final_uv_array; - DVector final_uv2_array; - DVector final_bone_array; - DVector final_weight_array; + PoolVector final_vertex_array; + PoolVector final_normal_array; + PoolVector final_tangent_array; + PoolVector final_color_array; + PoolVector final_uv_array; + PoolVector final_uv2_array; + PoolVector final_bone_array; + PoolVector final_weight_array; uint32_t final_format=0; @@ -1117,61 +1117,61 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref& p_mesh,con int vlen = vertex_array.size(); { //vertices - DVector varray; + PoolVector varray; varray.resize(vertex_array.size()); - DVector::Write varrayw = varray.write(); + PoolVector::Write varrayw = varray.write(); for(int k=0;k::Write(); + varrayw = PoolVector::Write(); final_vertex_array=varray; } if (uv_src) { //compute uv first, may be needed for computing tangent/bionrmal - DVector uvarray; + PoolVector uvarray; uvarray.resize(vertex_array.size()); - DVector::Write uvarrayw = uvarray.write(); + PoolVector::Write uvarrayw = uvarray.write(); for(int k=0;k::Write(); + uvarrayw = PoolVector::Write(); final_uv_array=uvarray; } if (uv2_src) { //compute uv first, may be needed for computing tangent/bionrmal - DVector uv2array; + PoolVector uv2array; uv2array.resize(vertex_array.size()); - DVector::Write uv2arrayw = uv2array.write(); + PoolVector::Write uv2arrayw = uv2array.write(); for(int k=0;k::Write(); + uv2arrayw = PoolVector::Write(); final_uv2_array=uv2array; } if (normal_src) { - DVector narray; + PoolVector narray; narray.resize(vertex_array.size()); - DVector::Write narrayw = narray.write(); + PoolVector::Write narrayw = narray.write(); for(int k=0;k::Write(); + narrayw = PoolVector::Write(); final_normal_array=narray; - //DVector altnaray; + //PoolVector altnaray; //_generate_normals(index_array,final_vertex_array,altnaray); //for(int i=0;i& p_mesh,con if (final_normal_array.size() && uv_src && binormal_src && tangent_src && !force_make_tangents) { - DVector tarray; + PoolVector tarray; tarray.resize(vertex_array.size()*4); - DVector::Write tarrayw = tarray.write(); + PoolVector::Write tarrayw = tarray.write(); for(int k=0;k& p_mesh,con } - tarrayw = DVector::Write(); + tarrayw = PoolVector::Write(); final_tangent_array=tarray; } else if (final_normal_array.size() && primitive==Mesh::PRIMITIVE_TRIANGLES && final_uv_array.size() && (force_make_tangents || (material.is_valid()))){ @@ -1217,27 +1217,27 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref& p_mesh,con if (color_src) { - DVector colorarray; + PoolVector colorarray; colorarray.resize(vertex_array.size()); - DVector::Write colorarrayw = colorarray.write(); + PoolVector::Write colorarrayw = colorarray.write(); for(int k=0;k::Write(); + colorarrayw = PoolVector::Write(); final_color_array=colorarray; } if (has_weights) { - DVector weightarray; - DVector bonearray; + PoolVector weightarray; + PoolVector bonearray; weightarray.resize(vertex_array.size()*4); - DVector::Write weightarrayw = weightarray.write(); + PoolVector::Write weightarrayw = weightarray.write(); bonearray.resize(vertex_array.size()*4); - DVector::Write bonearrayw = bonearray.write(); + PoolVector::Write bonearrayw = bonearray.write(); for(int k=0;k& p_mesh,con } - weightarrayw = DVector::Write(); - bonearrayw = DVector::Write(); + weightarrayw = PoolVector::Write(); + bonearrayw = PoolVector::Write(); final_weight_array = weightarray; final_bone_array = bonearray; @@ -1326,7 +1326,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref& p_mesh,con // morph anything but "POSITIONS" seem to exit. Because of this, normals and binormals/tangents have to be regenerated here, // which may result in inaccurate (but most of the time good enough) results. - DVector vertices; + PoolVector vertices; vertices.resize(vlen); ERR_FAIL_COND_V( md.vertices.size() != 1, ERR_INVALID_DATA); @@ -1345,7 +1345,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref& p_mesh,con //read vertices from morph target - DVector::Write vertw = vertices.write(); + PoolVector::Write vertw = vertices.write(); for(int m_i=0;m_iarray.size()/stride;m_i++) { @@ -1381,9 +1381,9 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref& p_mesh,con //vertices are in place, now generate everything else - vertw = DVector::Write(); - DVector normals; - DVector tangents; + vertw = PoolVector::Write(); + PoolVector normals; + PoolVector tangents; print_line("vertex source id: "+vertex_src_id); if(md.vertices[vertex_src_id].sources.has("NORMAL")){ //has normals @@ -1402,7 +1402,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref& p_mesh,con //read normals from morph target - DVector::Write vertw = normals.write(); + PoolVector::Write vertw = normals.write(); for(int m_i=0;m_iarray.size()/stride;m_i++) { diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.cpp b/tools/editor/io_plugins/editor_sample_import_plugin.cpp index b776fdeec04..db405b1cd73 100644 --- a/tools/editor/io_plugins/editor_sample_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_sample_import_plugin.cpp @@ -443,8 +443,8 @@ Error EditorSampleImportPlugin::import(const String& p_path, const Ref src_data = smp->get_data(); - DVector::Read sr = src_data.read(); + PoolVector src_data = smp->get_data(); + PoolVector::Read sr = src_data.read(); for(int i=0;i dst_data; + PoolVector dst_data; Sample::Format dst_format; if ( compression == _EditorSampleImportOptions::COMPRESS_MODE_RAM) { @@ -629,8 +629,8 @@ Error EditorSampleImportPlugin::import(const String& p_path, const Ref bleft; - DVector bright; + PoolVector bleft; + PoolVector bright; _compress_ima_adpcm(left,bleft); _compress_ima_adpcm(right,bright); @@ -638,9 +638,9 @@ Error EditorSampleImportPlugin::import(const String& p_path, const Ref::Write w=dst_data.write(); - DVector::Read rl=bleft.read(); - DVector::Read rr=bright.read(); + PoolVector::Write w=dst_data.write(); + PoolVector::Read rl=bleft.read(); + PoolVector::Read rr=bright.read(); for(int i=0;i::Write w = dst_data.write(); + PoolVector::Write w = dst_data.write(); int ds=data.size(); for(int i=0;i& p_data,DVector& dst_data) { +void EditorSampleImportPlugin::_compress_ima_adpcm(const Vector& p_data,PoolVector& dst_data) { /*p_sample_data->data = (void*)malloc(len); @@ -730,7 +730,7 @@ void EditorSampleImportPlugin::_compress_ima_adpcm(const Vector& p_data,D datalen++; dst_data.resize(datalen/2+4); - DVector::Write w = dst_data.write(); + PoolVector::Write w = dst_data.write(); int i,step_idx=0,prev=0; diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.h b/tools/editor/io_plugins/editor_sample_import_plugin.h index 915ca3883cd..6d781756b2b 100644 --- a/tools/editor/io_plugins/editor_sample_import_plugin.h +++ b/tools/editor/io_plugins/editor_sample_import_plugin.h @@ -40,7 +40,7 @@ class EditorSampleImportPlugin : public EditorImportPlugin { GDCLASS(EditorSampleImportPlugin,EditorImportPlugin); EditorSampleImportDialog *dialog; - void _compress_ima_adpcm(const Vector& p_data,DVector& dst_data); + void _compress_ima_adpcm(const Vector& p_data,PoolVector& dst_data); public: static EditorSampleImportPlugin *singleton; diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index c387e503e60..076750e59e8 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -1897,7 +1897,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map return p_node; MeshInstance *mi = p_node->cast_to(); - DVector faces = mi->get_faces(VisualInstance::FACES_SOLID); + PoolVector faces = mi->get_faces(VisualInstance::FACES_SOLID); BSP_Tree bsptree(faces); @@ -1940,7 +1940,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map return p_node; MeshInstance *mi = p_node->cast_to(); - DVector faces = mi->get_faces(VisualInstance::FACES_SOLID); + PoolVector faces = mi->get_faces(VisualInstance::FACES_SOLID); ERR_FAIL_COND_V(faces.size()==0,NULL); //step 1 compute the plane diff --git a/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp b/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp index 1cb16843c5c..e1b07199411 100644 --- a/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp +++ b/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp @@ -336,7 +336,7 @@ void EditorSceneImporterFBXConv::_add_surface(State& state,Ref& m,const Di int idx = m->get_surface_count(); Array array = state.surface_cache[id].array; - DVector indices = array[Mesh::ARRAY_BONES]; + PoolVector indices = array[Mesh::ARRAY_BONES]; if (indices.size() && part.has("bones")) { @@ -361,7 +361,7 @@ void EditorSceneImporterFBXConv::_add_surface(State& state,Ref& m,const Di int ilen=indices.size(); { - DVector::Write iw=indices.write(); + PoolVector::Write iw=indices.write(); for(int j=0;j vtx; + PoolVector vtx; vtx.resize(array.size()); { int len=array.size(); - DVector::Write w = vtx.write(); + PoolVector::Write w = vtx.write(); for(int l=0;l tangents; + PoolVector tangents; tangents.resize(array.size()*4); { int len=array.size(); - DVector::Write w = tangents.write(); + PoolVector::Write w = tangents.write(); for(int l=0;l cols; + PoolVector cols; cols.resize(array.size()); { int len=array.size(); - DVector::Write w = cols.write(); + PoolVector::Write w = cols.write(); for(int l=0;l uvs; + PoolVector uvs; uvs.resize(array.size()); { int len=array.size(); - DVector::Write w = uvs.write(); + PoolVector::Write w = uvs.write(); for(int l=0;l arr; + PoolVector arr; arr.resize(array.size()*4); int po=k==Mesh::ARRAY_WEIGHTS?1:0; lofs=ofs[Mesh::ARRAY_BONES]; { int len=array.size(); - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int l=0;l arr; + PoolVector arr; arr.resize(indices.size()); { int len=indices.size(); - DVector::Write w = arr.write(); + PoolVector::Write w = arr.write(); for(int l=0;l ia=arrays[Mesh::ARRAY_INDEX]; + PoolVector ia=arrays[Mesh::ARRAY_INDEX]; int len=ia.size(); { - DVector::Write w=ia.write(); + PoolVector::Write w=ia.write(); for(int l=0;l data = src.get_data(); + PoolVector data = src.get_data(); MD5_CTX md5; - DVector::Read r=data.read(); + PoolVector::Read r=data.read(); MD5Init(&md5); int len=data.size(); for(int j=0;j& image=copy; } - DVector dvt=image.get_data(); - DVector::Read r=dvt.read(); + PoolVector dvt=image.get_data(); + PoolVector::Read r=dvt.read(); MeshTexture mt; mt.tex_w=image.get_width(); mt.tex_h=image.get_height(); @@ -194,14 +194,14 @@ void BakedLightBaker::_add_mesh(const Ref& p_mesh,const Ref& p_m Array a = p_mesh->surface_get_arrays(i); - DVector vertices = a[Mesh::ARRAY_VERTEX]; - DVector::Read vr=vertices.read(); - DVector uv; - DVector::Read uvr; - DVector uv2; - DVector::Read uv2r; - DVector normal; - DVector::Read normalr; + PoolVector vertices = a[Mesh::ARRAY_VERTEX]; + PoolVector::Read vr=vertices.read(); + PoolVector uv; + PoolVector::Read uvr; + PoolVector uv2; + PoolVector::Read uv2r; + PoolVector normal; + PoolVector::Read normalr; bool read_uv=false; bool read_normal=false; @@ -236,8 +236,8 @@ void BakedLightBaker::_add_mesh(const Ref& p_mesh,const Ref& p_m if (p_mesh->surface_get_format(i)&Mesh::ARRAY_FORMAT_INDEX) { - DVector indices = a[Mesh::ARRAY_INDEX]; - DVector::Read ir = indices.read(); + PoolVector indices = a[Mesh::ARRAY_INDEX]; + PoolVector::Read ir = indices.read(); for(int i=0;i &p_light, Node* p_node) { } -void BakedLightBaker::update_octree_sampler(DVector &p_sampler) { +void BakedLightBaker::update_octree_sampler(PoolVector &p_sampler) { BakedLightBaker::Octant *octants=octant_pool.ptr(); double norm = 1.0/double(total_rays); @@ -1845,7 +1845,7 @@ void BakedLightBaker::update_octree_sampler(DVector &p_sampler) { } p_sampler.resize(tmp_smp.size()); - DVector::Write w = p_sampler.write(); + PoolVector::Write w = p_sampler.write(); int ss = tmp_smp.size(); for(int i=0;i &p_sampler) { double mult = baked_light->get_energy_multiplier(); float saturation = baked_light->get_saturation(); - DVector::Write w = p_sampler.write(); + PoolVector::Write w = p_sampler.write(); encode_uint32(octree_depth,(uint8_t*)&w[2]); encode_uint32(linear_color,(uint8_t*)&w[3]); @@ -1900,7 +1900,7 @@ void BakedLightBaker::update_octree_sampler(DVector &p_sampler) { } -void BakedLightBaker::update_octree_images(DVector &p_octree,DVector &p_light) { +void BakedLightBaker::update_octree_images(PoolVector &p_octree,PoolVector &p_light) { int len = baked_octree_texture_w*baked_octree_texture_h*4; @@ -1910,10 +1910,10 @@ void BakedLightBaker::update_octree_images(DVector &p_octree,DVector::Write w = p_octree.write(); + PoolVector::Write w = p_octree.write(); zeromem(w.ptr(),len); - DVector::Write iw = p_light.write(); + PoolVector::Write iw = p_light.write(); zeromem(iw.ptr(),ilen); float gamma = baked_light->get_gamma_adjust(); @@ -2612,10 +2612,10 @@ Error BakedLightBaker::transfer_to_lightmaps() { } } - DVector dv; + PoolVector dv; dv.resize(baked_textures[i].data.size()); { - DVector::Write w = dv.write(); + PoolVector::Write w = dv.write(); copymem(w.ptr(),baked_textures[i].data.ptr(),baked_textures[i].data.size()); } diff --git a/tools/editor/plugins/baked_light_baker.h b/tools/editor/plugins/baked_light_baker.h index 5616183cb18..6fcf78dd0a1 100644 --- a/tools/editor/plugins/baked_light_baker.h +++ b/tools/editor/plugins/baked_light_baker.h @@ -364,8 +364,8 @@ public: Error transfer_to_lightmaps(); - void update_octree_sampler(DVector &p_sampler); - void update_octree_images(DVector &p_octree,DVector &p_light); + void update_octree_sampler(PoolVector &p_sampler); + void update_octree_images(PoolVector &p_octree,PoolVector &p_light); Ref get_baked_light() { return baked_light; } diff --git a/tools/editor/plugins/baked_light_editor_plugin.cpp b/tools/editor/plugins/baked_light_editor_plugin.cpp index e6d969c3992..8f564a32479 100644 --- a/tools/editor/plugins/baked_light_editor_plugin.cpp +++ b/tools/editor/plugins/baked_light_editor_plugin.cpp @@ -88,7 +88,7 @@ void BakedLightEditor::_notification(int p_option) { float max_lum=0; { - DVector::Write cw=colors.write(); + PoolVector::Write cw=colors.write(); BakedLightBaker::Octant *octants=baker->octant_pool.ptr(); BakedLightBaker::Octant *oct = &octants[baker->leaf_list]; int vert_idx=0; diff --git a/tools/editor/plugins/baked_light_editor_plugin.h b/tools/editor/plugins/baked_light_editor_plugin.h index 82310dc07ee..e311fe9f17e 100644 --- a/tools/editor/plugins/baked_light_editor_plugin.h +++ b/tools/editor/plugins/baked_light_editor_plugin.h @@ -50,9 +50,9 @@ class BakedLightEditor : public Control { float update_timeout; - DVector octree_texture; - DVector light_texture; - DVector octree_sampler; + PoolVector octree_texture; + PoolVector light_texture; + PoolVector octree_sampler; BakedLightBaker *baker; AcceptDialog *err_dialog; diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 5fa0d88ca53..168b41e51fa 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -3771,7 +3771,7 @@ void CanvasItemEditorViewport::_create_nodes(Node* parent, Node* child, String& if (default_type=="Patch9Frame") { editor_data->get_undo_redo().add_do_property(child,"rect/size",texture_size); } else if (default_type=="Polygon2D") { - DVector list; + PoolVector list; list.push_back(Vector2(0,0)); list.push_back(Vector2(texture_size.width,0)); list.push_back(Vector2(texture_size.width,texture_size.height)); diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp index 5ac40231778..1aea1bdfdb2 100644 --- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp @@ -478,11 +478,11 @@ void CollisionPolygonEditor::_polygon_draw() { Array a; a.resize(Mesh::ARRAY_MAX); - DVector va; + PoolVector va; { va.resize(poly.size()); - DVector::Write w=va.write(); + PoolVector::Write w=va.write(); for(int i=0;iget_undo_redo(); - //Not sure if I should convert this data to DVector + //Not sure if I should convert this data to PoolVector Vector new_offsets=ramp_editor->get_offsets(); Vector new_colors=ramp_editor->get_colors(); Vector old_offsets=color_ramp_ref->get_offsets(); diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index 5a41f7e9e8d..9dcfc2fa94a 100644 --- a/tools/editor/plugins/editor_preview_plugins.cpp +++ b/tools/editor/plugins/editor_preview_plugins.cpp @@ -118,12 +118,12 @@ Ref EditorBitmapPreviewPlugin::generate(const RES& p_from) { return Ref(); } - DVector data; + PoolVector data; data.resize(bm->get_size().width*bm->get_size().height); { - DVector::Write w=data.write(); + PoolVector::Write w=data.write(); for(int i=0;iget_size().width;i++) { for(int j=0;jget_size().height;j++) { @@ -193,14 +193,14 @@ Ref EditorPackedScenePreviewPlugin::_gen_from_imd(Refget_option("thumbnail"); //print_line(Variant::get_type_name(tn.get_type())); - DVector thumbnail = tn; + PoolVector thumbnail = tn; int len = thumbnail.size(); if (len==0) return Ref(); - DVector::Read r = thumbnail.read(); + PoolVector::Read r = thumbnail.read(); Image img(r.ptr(),len); if (img.empty()) @@ -311,10 +311,10 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { int lons=32; float radius=1.0; - DVector vertices; - DVector normals; - DVector uvs; - DVector tangents; + PoolVector vertices; + PoolVector normals; + PoolVector uvs; + PoolVector tangents; Matrix3 tt = Matrix3(Vector3(0,1,0),Math_PI*0.5); for(int i = 1; i <= lats; i++) { @@ -535,15 +535,15 @@ Ref EditorSamplePreviewPlugin::generate(const RES& p_from) { int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); thumbnail_size*=EDSCALE; - DVector img; + PoolVector img; int w = thumbnail_size; int h = thumbnail_size; img.resize(w*h*3); - DVector::Write imgdata = img.write(); + PoolVector::Write imgdata = img.write(); uint8_t * imgw = imgdata.ptr(); - DVector data = smp->get_data(); - DVector::Read sampledata = data.read(); + PoolVector data = smp->get_data(); + PoolVector::Read sampledata = data.read(); const uint8_t *sdata=sampledata.ptr(); bool stereo = smp->is_stereo(); @@ -776,7 +776,7 @@ Ref EditorSamplePreviewPlugin::generate(const RES& p_from) { } } - imgdata = DVector::Write(); + imgdata = PoolVector::Write(); Ref ptex = Ref( memnew( ImageTexture)); ptex->create_from_image(Image(w,h,0,Image::FORMAT_RGB8,img),0); diff --git a/tools/editor/plugins/material_editor_plugin.cpp b/tools/editor/plugins/material_editor_plugin.cpp index 3ef18181350..e43872deec9 100644 --- a/tools/editor/plugins/material_editor_plugin.cpp +++ b/tools/editor/plugins/material_editor_plugin.cpp @@ -143,10 +143,10 @@ MaterialEditor::MaterialEditor() { int lons=32; float radius=1.0; - DVector vertices; - DVector normals; - DVector uvs; - DVector tangents; + PoolVector vertices; + PoolVector normals; + PoolVector uvs; + PoolVector tangents; Matrix3 tt = Matrix3(Vector3(0,1,0),Math_PI*0.5); for(int i = 1; i <= lats; i++) { @@ -221,10 +221,10 @@ MaterialEditor::MaterialEditor() { box_mesh.instance(); - DVector vertices; - DVector normals; - DVector tangents; - DVector uvs; + PoolVector vertices; + PoolVector normals; + PoolVector tangents; + PoolVector uvs; int vtx_idx=0; #define ADD_VTX(m_idx);\ @@ -282,7 +282,7 @@ MaterialEditor::MaterialEditor() { d[VisualServer::ARRAY_TEX_UV]= uvs ; d[VisualServer::ARRAY_VERTEX]= vertices ; - DVector indices; + PoolVector indices; indices.resize(vertices.size()); for(int i=0;iget_global_transform().affine_inverse() * ss_instance->get_global_transform(); - DVector geometry = ss_instance->get_faces(VisualInstance::FACES_SOLID); + PoolVector geometry = ss_instance->get_faces(VisualInstance::FACES_SOLID); if (geometry.size()==0) { @@ -137,7 +137,7 @@ void MultiMeshEditor::_populate() { //make all faces local int gc = geometry.size(); - DVector::Write w = geometry.write(); + PoolVector::Write w = geometry.write(); for(int i=0;i::Write(); + w = PoolVector::Write(); #if 0 node->get_multimesh()->set_instance_count(populate_amount->get_val()); node->populate_parent(populate_rotate_random->get_val(),populate_tilt_random->get_val(),populate_scale_random->get_val(),populate_scale->get_val()); @@ -164,12 +164,12 @@ void MultiMeshEditor::_populate() { ERR_FAIL_COND(!vi); #endif - DVector faces = geometry; + PoolVector faces = geometry; ERR_EXPLAIN(TTR("Parent has no solid faces to populate.")); int facecount=faces.size(); ERR_FAIL_COND(!facecount); - DVector::Read r = faces.read(); + PoolVector::Read r = faces.read(); diff --git a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp index d08c89c1efb..2d99522e0eb 100644 --- a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -211,10 +211,10 @@ bool NavigationPolygonEditor::forward_input_event(const InputEvent& p_event) { for(int j=0;jget_navigation_polygon()->get_outline_count();j++) { - DVector points=node->get_navigation_polygon()->get_outline(j); + PoolVector points=node->get_navigation_polygon()->get_outline(j); int pc=points.size(); - DVector::Read poly=points.read(); + PoolVector::Read poly=points.read(); for(int i=0;i=0) { pre_move_edit=node->get_navigation_polygon()->get_outline(closest_outline); - DVector poly = pre_move_edit; + PoolVector poly = pre_move_edit; poly.insert(closest_idx+1,xform.affine_inverse().xform(closest_pos)); edited_point=closest_idx+1; edited_outline=closest_outline; @@ -260,10 +260,10 @@ bool NavigationPolygonEditor::forward_input_event(const InputEvent& p_event) { for(int j=0;jget_navigation_polygon()->get_outline_count();j++) { - DVector points=node->get_navigation_polygon()->get_outline(j); + PoolVector points=node->get_navigation_polygon()->get_outline(j); int pc=points.size(); - DVector::Read poly=points.read(); + PoolVector::Read poly=points.read(); for(int i=0;i poly = node->get_navigation_polygon()->get_outline(edited_outline); + PoolVector poly = node->get_navigation_polygon()->get_outline(edited_outline); ERR_FAIL_INDEX_V(edited_point,poly.size(),false); poly.set(edited_point,edited_point_pos); undo_redo->create_action(TTR("Edit Poly")); @@ -322,10 +322,10 @@ bool NavigationPolygonEditor::forward_input_event(const InputEvent& p_event) { for(int j=0;jget_navigation_polygon()->get_outline_count();j++) { - DVector points=node->get_navigation_polygon()->get_outline(j); + PoolVector points=node->get_navigation_polygon()->get_outline(j); int pc=points.size(); - DVector::Read poly=points.read(); + PoolVector::Read poly=points.read(); for(int i=0;i=0) { - DVector poly = node->get_navigation_polygon()->get_outline(closest_outline); + PoolVector poly = node->get_navigation_polygon()->get_outline(closest_outline); if (poly.size()>3) { undo_redo->create_action(TTR("Edit Poly (Remove Point)")); diff --git a/tools/editor/plugins/navigation_polygon_editor_plugin.h b/tools/editor/plugins/navigation_polygon_editor_plugin.h index 50ba0cfedb6..1a5fa3c4565 100644 --- a/tools/editor/plugins/navigation_polygon_editor_plugin.h +++ b/tools/editor/plugins/navigation_polygon_editor_plugin.h @@ -70,7 +70,7 @@ class NavigationPolygonEditor : public HBoxContainer { int edited_outline; int edited_point; Vector2 edited_point_pos; - DVector pre_move_edit; + PoolVector pre_move_edit; Vector wip; bool wip_active; diff --git a/tools/editor/plugins/particles_2d_editor_plugin.cpp b/tools/editor/plugins/particles_2d_editor_plugin.cpp index 0eda9d3c1a2..aee6b68e3cc 100644 --- a/tools/editor/plugins/particles_2d_editor_plugin.cpp +++ b/tools/editor/plugins/particles_2d_editor_plugin.cpp @@ -74,8 +74,8 @@ void Particles2DEditorPlugin::_file_selected(const String& p_file) { Size2i s = Size2(img.get_width(),img.get_height()); ERR_FAIL_COND(s.width==0 || s.height==0); - DVector data = img.get_data(); - DVector::Read r = data.read(); + PoolVector data = img.get_data(); + PoolVector::Read r = data.read(); Vector valid_positions; valid_positions.resize(s.width*s.height); @@ -95,9 +95,9 @@ void Particles2DEditorPlugin::_file_selected(const String& p_file) { ERR_EXPLAIN(TTR("No pixels with transparency > 128 in image..")); ERR_FAIL_COND(valid_positions.size()==0); - DVector epoints; + PoolVector epoints; epoints.resize(epc); - DVector::Write w = epoints.write(); + PoolVector::Write w = epoints.write(); Size2 extents = Size2(img.get_width()*0.5,img.get_height()*0.5); @@ -108,7 +108,7 @@ void Particles2DEditorPlugin::_file_selected(const String& p_file) { w[i]=p/extents; } - w = DVector::Write(); + w = PoolVector::Write(); undo_redo->create_action(TTR("Set Emission Mask")); undo_redo->add_do_method(particles,"set_emission_points",epoints); @@ -131,7 +131,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) { case MENU_CLEAR_EMISSION_MASK: { undo_redo->create_action(TTR("Clear Emission Mask")); - undo_redo->add_do_method(particles,"set_emission_points",DVector()); + undo_redo->add_do_method(particles,"set_emission_points",PoolVector()); undo_redo->add_undo_method(particles,"set_emission_points",particles->get_emission_points()); undo_redo->commit_action(); } break; diff --git a/tools/editor/plugins/particles_editor_plugin.cpp b/tools/editor/plugins/particles_editor_plugin.cpp index 4f4477070b4..f290a453bb8 100644 --- a/tools/editor/plugins/particles_editor_plugin.cpp +++ b/tools/editor/plugins/particles_editor_plugin.cpp @@ -77,7 +77,7 @@ void ParticlesEditor::_node_selected(const NodePath& p_path){ Transform geom_xform = node->get_global_transform().affine_inverse() * vi->get_global_transform(); int gc = geometry.size(); - DVector::Write w = geometry.write(); + PoolVector::Write w = geometry.write(); for(int i=0;i::Write(); + w = PoolVector::Write(); emission_dialog->popup_centered(Size2(300,130)); } @@ -202,7 +202,7 @@ void ParticlesEditor::edit(Particles *p_particles) { void ParticlesEditor::_generate_emission_points() { /// hacer codigo aca - DVector points; + PoolVector points; if (emission_fill->get_selected()==0) { @@ -256,7 +256,7 @@ void ParticlesEditor::_generate_emission_points() { return; } - DVector::Read r = geometry.read(); + PoolVector::Read r = geometry.read(); AABB aabb; diff --git a/tools/editor/plugins/particles_editor_plugin.h b/tools/editor/plugins/particles_editor_plugin.h index fa4ca3b9ec9..c32fbe5ada6 100644 --- a/tools/editor/plugins/particles_editor_plugin.h +++ b/tools/editor/plugins/particles_editor_plugin.h @@ -69,7 +69,7 @@ class ParticlesEditor : public Control { }; - DVector geometry; + PoolVector geometry; void _generate_emission_points(); void _resource_seleted(const String& p_res); diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.cpp b/tools/editor/plugins/polygon_2d_editor_plugin.cpp index 7900f032c01..4977d5facc1 100644 --- a/tools/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/tools/editor/plugins/polygon_2d_editor_plugin.cpp @@ -102,8 +102,8 @@ void Polygon2DEditor::_menu_option(int p_option) { } - DVector points = node->get_polygon(); - DVector uvs = node->get_uv(); + PoolVector points = node->get_polygon(); + PoolVector uvs = node->get_uv(); if (uvs.size()!=points.size()) { undo_redo->create_action(TTR("Create UV Map")); undo_redo->add_do_method(node,"set_uv",points); @@ -119,10 +119,10 @@ void Polygon2DEditor::_menu_option(int p_option) { } break; case UVEDIT_POLYGON_TO_UV: { - DVector points = node->get_polygon(); + PoolVector points = node->get_polygon(); if (points.size()==0) break; - DVector uvs = node->get_uv(); + PoolVector uvs = node->get_uv(); undo_redo->create_action(TTR("Create UV Map")); undo_redo->add_do_method(node,"set_uv",points); undo_redo->add_undo_method(node,"set_uv",uvs); @@ -134,8 +134,8 @@ void Polygon2DEditor::_menu_option(int p_option) { } break; case UVEDIT_UV_TO_POLYGON: { - DVector points = node->get_polygon(); - DVector uvs = node->get_uv(); + PoolVector points = node->get_polygon(); + PoolVector uvs = node->get_uv(); if (uvs.size()==0) break; @@ -149,11 +149,11 @@ void Polygon2DEditor::_menu_option(int p_option) { } break; case UVEDIT_UV_CLEAR: { - DVector uvs = node->get_uv(); + PoolVector uvs = node->get_uv(); if (uvs.size()==0) break; undo_redo->create_action(TTR("Create UV Map")); - undo_redo->add_do_method(node,"set_uv",DVector()); + undo_redo->add_do_method(node,"set_uv",PoolVector()); undo_redo->add_undo_method(node,"set_uv",uvs); undo_redo->add_do_method(uv_edit_draw,"update"); undo_redo->add_undo_method(uv_edit_draw,"update"); @@ -593,13 +593,13 @@ void Polygon2DEditor::_uv_input(const InputEvent& p_input) { case UV_MODE_EDIT_POINT: { - DVector uv_new=uv_prev; + PoolVector uv_new=uv_prev; uv_new.set( uv_drag_index, uv_new[uv_drag_index]+drag ); node->set_uv(uv_new); } break; case UV_MODE_MOVE: { - DVector uv_new=uv_prev; + PoolVector uv_new=uv_prev; for(int i=0;i uv_new=uv_prev; + PoolVector uv_new=uv_prev; for(int i=0;i uv_new=uv_prev; + PoolVector uv_new=uv_prev; for(int i=0;i uvs = node->get_uv(); + PoolVector uvs = node->get_uv(); Ref handle = get_icon("EditorHandle","EditorIcons"); Rect2 rect(Point2(),mtx.basis_xform(base_tex->get_size())); diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.h b/tools/editor/plugins/polygon_2d_editor_plugin.h index a2fd3dc4d08..67d50f6ac21 100644 --- a/tools/editor/plugins/polygon_2d_editor_plugin.h +++ b/tools/editor/plugins/polygon_2d_editor_plugin.h @@ -81,7 +81,7 @@ class Polygon2DEditor : public HBoxContainer { Vector2 uv_draw_ofs; float uv_draw_zoom; - DVector uv_prev; + PoolVector uv_prev; int uv_drag_index; bool uv_drag; UVMode uv_move_current; diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp index a8fb5743b05..e836e04e193 100644 --- a/tools/editor/plugins/sample_editor_plugin.cpp +++ b/tools/editor/plugins/sample_editor_plugin.cpp @@ -77,15 +77,15 @@ void SampleEditor::_stop_pressed() { void SampleEditor::generate_preview_texture(const Ref& p_sample,Ref &p_texture) { - DVector data = p_sample->get_data(); + PoolVector data = p_sample->get_data(); - DVector img; + PoolVector img; int w = p_texture->get_width(); int h = p_texture->get_height(); img.resize(w*h*3); - DVector::Write imgdata = img.write(); + PoolVector::Write imgdata = img.write(); uint8_t * imgw = imgdata.ptr(); - DVector::Read sampledata = data.read(); + PoolVector::Read sampledata = data.read(); const uint8_t *sdata=sampledata.ptr(); bool stereo = p_sample->is_stereo(); @@ -308,7 +308,7 @@ void SampleEditor::generate_preview_texture(const Ref& p_sample,Ref::Write(); + imgdata = PoolVector::Write(); p_texture->set_data(Image(w,h,0,Image::FORMAT_RGB8,img)); diff --git a/tools/editor/plugins/sample_library_editor_plugin.cpp b/tools/editor/plugins/sample_library_editor_plugin.cpp index 730c3b69a2e..45615ccf9e3 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.cpp +++ b/tools/editor/plugins/sample_library_editor_plugin.cpp @@ -66,7 +66,7 @@ void SampleLibraryEditor::_notification(int p_what) { } } -void SampleLibraryEditor::_file_load_request(const DVector& p_path) { +void SampleLibraryEditor::_file_load_request(const PoolVector& p_path) { for(int i=0;i files = d["files"]; + PoolVector files = d["files"]; _file_load_request(files); diff --git a/tools/editor/plugins/sample_library_editor_plugin.h b/tools/editor/plugins/sample_library_editor_plugin.h index 46b216af820..03bf01a4592 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.h +++ b/tools/editor/plugins/sample_library_editor_plugin.h @@ -59,7 +59,7 @@ class SampleLibraryEditor : public Panel { void _load_pressed(); - void _file_load_request(const DVector& p_path); + void _file_load_request(const PoolVector& p_path); void _delete_pressed(); void _update_library(); void _item_edited(); diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp index 15906563c79..1f319a97cc5 100644 --- a/tools/editor/plugins/shader_graph_editor_plugin.cpp +++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp @@ -986,13 +986,13 @@ void ShaderGraphView::_color_ramp_changed(int p_id,Node* p_ramp) { Vector offsets=cr->get_offsets(); Vector colors=cr->get_colors(); - DVector new_offsets; - DVector new_colors; + PoolVector new_offsets; + PoolVector new_colors; { new_offsets.resize(offsets.size()); new_colors.resize(colors.size()); - DVector::Write ow=new_offsets.write(); - DVector::Write cw=new_colors.write(); + PoolVector::Write ow=new_offsets.write(); + PoolVector::Write cw=new_colors.write(); for(int i=0;i old_offsets=graph->color_ramp_node_get_offsets(type,p_id); - DVector old_colors=graph->color_ramp_node_get_colors(type,p_id); + PoolVector old_offsets=graph->color_ramp_node_get_offsets(type,p_id); + PoolVector old_colors=graph->color_ramp_node_get_colors(type,p_id); if (old_offsets.size()!=new_offsets.size()) ur->create_action(TTR("Add/Remove to Color Ramp")); @@ -1027,10 +1027,10 @@ void ShaderGraphView::_curve_changed(int p_id,Node* p_curve) { Vector points=cr->get_points(); - DVector new_points; + PoolVector new_points; { new_points.resize(points.size()); - DVector::Write ow=new_points.write(); + PoolVector::Write ow=new_points.write(); for(int i=0;i old_points=graph->curve_map_node_get_points(type,p_id); + PoolVector old_points=graph->curve_map_node_get_points(type,p_id); if (old_points.size()!=new_points.size()) ur->create_action(TTR("Add/Remove to Curve Map")); @@ -2131,14 +2131,14 @@ void ShaderGraphView::_create_node(int p_id) { gn->set_title("ColorRamp"); GraphColorRampEdit * ramp = memnew( GraphColorRampEdit ); - DVector offsets = graph->color_ramp_node_get_offsets(type,p_id); - DVector colors = graph->color_ramp_node_get_colors(type,p_id); + PoolVector offsets = graph->color_ramp_node_get_offsets(type,p_id); + PoolVector colors = graph->color_ramp_node_get_colors(type,p_id); int oc = offsets.size(); if (oc) { - DVector::Read rofs = offsets.read(); - DVector::Read rcol = colors.read(); + PoolVector::Read rofs = offsets.read(); + PoolVector::Read rcol = colors.read(); Vector ofsv; Vector colorv; @@ -2184,12 +2184,12 @@ void ShaderGraphView::_create_node(int p_id) { gn->set_title("CurveMap"); GraphCurveMapEdit * map = memnew( GraphCurveMapEdit ); - DVector points = graph->curve_map_node_get_points(type,p_id); + PoolVector points = graph->curve_map_node_get_points(type,p_id); int oc = points.size(); if (oc) { - DVector::Read rofs = points.read(); + PoolVector::Read rofs = points.read(); Vector ofsv; diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 439b8849379..7913d097b7e 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -898,10 +898,10 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { if (p.distance_to(aabb.get_support(-ray_dir))>min_d) continue; - DVector faces = vi->get_faces(VisualInstance::FACES_SOLID); + PoolVector faces = vi->get_faces(VisualInstance::FACES_SOLID); int c = faces.size(); if (c>0) { - DVector::Read r = faces.read(); + PoolVector::Read r = faces.read(); for(int j=0;jset_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true); - DVector grid_colors[3]; - DVector grid_points[3]; + PoolVector grid_colors[3]; + PoolVector grid_points[3]; Vector origin_colors; Vector origin_points; @@ -3262,7 +3262,7 @@ void SpatialEditor::_init_indicators() { { cursor_mesh = VisualServer::get_singleton()->mesh_create(); - DVector cursor_points; + PoolVector cursor_points; float cs = 0.25; cursor_points.push_back(Vector3(+cs,0,0)); cursor_points.push_back(Vector3(-cs,0,0)); diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.cpp b/tools/editor/plugins/sprite_frames_editor_plugin.cpp index 7c6e2f65329..fbdbb37b545 100644 --- a/tools/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/tools/editor/plugins/sprite_frames_editor_plugin.cpp @@ -64,7 +64,7 @@ void SpriteFramesEditor::_notification(int p_what) { } } -void SpriteFramesEditor::_file_load_request(const DVector& p_path,int p_at_pos) { +void SpriteFramesEditor::_file_load_request(const PoolVector& p_path,int p_at_pos) { ERR_FAIL_COND(!frames->has_animation(edited_anim)); @@ -744,7 +744,7 @@ void SpriteFramesEditor::drop_data_fw(const Point2& p_point,const Variant& p_dat if (String(d["type"])=="files") { - DVector files = d["files"]; + PoolVector files = d["files"]; _file_load_request(files,at_pos); } diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.h b/tools/editor/plugins/sprite_frames_editor_plugin.h index a6fc53d3441..383b831a23c 100644 --- a/tools/editor/plugins/sprite_frames_editor_plugin.h +++ b/tools/editor/plugins/sprite_frames_editor_plugin.h @@ -73,7 +73,7 @@ class SpriteFramesEditor : public PanelContainer { void _load_pressed(); void _load_scene_pressed(); - void _file_load_request(const DVector& p_path, int p_at_pos=-1); + void _file_load_request(const PoolVector& p_path, int p_at_pos=-1); void _paste_pressed(); void _empty_pressed(); void _empty2_pressed(); diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index c4bde133522..3dd86527b0b 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -289,7 +289,7 @@ void TileMapEditor::_pick_tile(const Point2& p_pos) { canvas_item_editor->update(); } -DVector TileMapEditor::_bucket_fill(const Point2i& p_start, bool erase, bool preview) { +PoolVector TileMapEditor::_bucket_fill(const Point2i& p_start, bool erase, bool preview) { int prev_id = node->get_cell(p_start.x, p_start.y); int id = TileMap::INVALID_CELL; @@ -297,7 +297,7 @@ DVector TileMapEditor::_bucket_fill(const Point2i& p_start, bool erase, id = get_selected_tile(); if (id == TileMap::INVALID_CELL) - return DVector(); + return PoolVector(); } Rect2i r = node->get_item_rect(); @@ -324,7 +324,7 @@ DVector TileMapEditor::_bucket_fill(const Point2i& p_start, bool erase, if(invalidate_cache) { for(int i = 0; i < area; ++i) bucket_cache_visited[i] = false; - bucket_cache = DVector(); + bucket_cache = PoolVector(); bucket_cache_tile = prev_id; bucket_cache_rect = r; } @@ -333,7 +333,7 @@ DVector TileMapEditor::_bucket_fill(const Point2i& p_start, bool erase, } } - DVector points; + PoolVector points; List queue; queue.push_back(p_start); @@ -370,10 +370,10 @@ DVector TileMapEditor::_bucket_fill(const Point2i& p_start, bool erase, return preview ? bucket_cache : points; } -void TileMapEditor::_fill_points(const DVector p_points, const Dictionary& p_op) { +void TileMapEditor::_fill_points(const PoolVector p_points, const Dictionary& p_op) { int len = p_points.size(); - DVector::Read pr = p_points.read(); + PoolVector::Read pr = p_points.read(); int id = p_op["id"]; bool xf = p_op["flip_h"]; @@ -386,10 +386,10 @@ void TileMapEditor::_fill_points(const DVector p_points, const Dictiona } } -void TileMapEditor::_erase_points(const DVector p_points) { +void TileMapEditor::_erase_points(const PoolVector p_points) { int len = p_points.size(); - DVector::Read pr = p_points.read(); + PoolVector::Read pr = p_points.read(); for (int i=0;i points = _bucket_fill(p_point, false, true); - DVector::Read pr = points.read(); + PoolVector points = _bucket_fill(p_point, false, true); + PoolVector::Read pr = points.read(); int len = points.size(); int time_after = OS::get_singleton()->get_ticks_msec(); @@ -748,7 +748,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { pop["flip_v"] = node->is_cell_y_flipped(over_tile.x, over_tile.y); pop["transpose"] = node->is_cell_transposed(over_tile.x, over_tile.y); - DVector points = _bucket_fill(over_tile); + PoolVector points = _bucket_fill(over_tile); if (points.size() == 0) return false; @@ -854,7 +854,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { pop["flip_v"] = node->is_cell_y_flipped(over_tile.x, over_tile.y); pop["transpose"] = node->is_cell_transposed(over_tile.x, over_tile.y); - DVector points = _bucket_fill(over_tile, true); + PoolVector points = _bucket_fill(over_tile, true); if (points.size() == 0) return false; diff --git a/tools/editor/plugins/tile_map_editor_plugin.h b/tools/editor/plugins/tile_map_editor_plugin.h index 612593c56af..52174537405 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.h +++ b/tools/editor/plugins/tile_map_editor_plugin.h @@ -109,7 +109,7 @@ class TileMapEditor : public VBoxContainer { bool * bucket_cache_visited; Rect2i bucket_cache_rect; int bucket_cache_tile; - DVector bucket_cache; + PoolVector bucket_cache; struct CellOp { int idx; @@ -134,10 +134,10 @@ class TileMapEditor : public VBoxContainer { void _pick_tile(const Point2& p_pos); - DVector _bucket_fill(const Point2i& p_start, bool erase=false, bool preview=false); + PoolVector _bucket_fill(const Point2i& p_start, bool erase=false, bool preview=false); - void _fill_points(const DVector p_points, const Dictionary& p_op); - void _erase_points(const DVector p_points); + void _fill_points(const PoolVector p_points, const Dictionary& p_op); + void _erase_points(const PoolVector p_points); void _select(const Point2i& p_from, const Point2i& p_to); diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index b183de7c7bc..2bb8a63cb7e 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -1732,7 +1732,7 @@ Error ProjectExport::export_project(const String& p_preset) { String selected=p_preset; - DVector preset_settings = GlobalConfig::get_singleton()->get("export_presets/"+selected); + PoolVector preset_settings = GlobalConfig::get_singleton()->get("export_presets/"+selected); String preset_path=GlobalConfig::get_singleton()->get("export_presets_path/"+selected); if (preset_path=="") { @@ -2084,7 +2084,7 @@ Error ProjectExport::export_project(const String& p_preset) { for (Map >::Element *E=remapped_paths.front();E;E=E->next()) { String platform=E->key(); - DVector remaps; + PoolVector remaps; for(Map::Element *F=E->get().front();F;F=F->next() ) { remaps.push_back(F->key()); diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp index 809c824d91d..ed96fe9e3f9 100644 --- a/tools/editor/spatial_editor_gizmos.cpp +++ b/tools/editor/spatial_editor_gizmos.cpp @@ -117,10 +117,10 @@ void EditorSpatialGizmo::add_lines(const Vector &p_lines, const Ref color; + PoolVector color; color.resize(p_lines.size()); { - DVector::Write w = color.write(); + PoolVector::Write w = color.write(); for(int i=0;i &p_handles, bool p_bi a.resize(VS::ARRAY_MAX); a[VS::ARRAY_VERTEX]=p_handles; print_line("handles?: "+itos(p_handles.size())); - DVector colors; + PoolVector colors; { colors.resize(p_handles.size()); - DVector::Write w=colors.write(); + PoolVector::Write w=colors.write(); for(int i=0;i roomie = room->get_room(); if (roomie.is_null()) return; - DVector faces = roomie->get_geometry_hint(); + PoolVector faces = roomie->get_geometry_hint(); Vector lines; int fc=faces.size(); - DVector::Read r =faces.read(); + PoolVector::Read r =faces.read(); Map<_EdgeKey,Vector3> edge_map; @@ -2056,7 +2056,7 @@ void CollisionShapeSpatialGizmo::redraw(){ if (s->cast_to()) { - DVector points = s->cast_to()->get_points(); + PoolVector points = s->cast_to()->get_points(); if (points.size()>3) { @@ -2562,8 +2562,8 @@ void NavigationMeshSpatialGizmo::redraw() { if (navmeshie.is_null()) return; - DVector vertices = navmeshie->get_vertices(); - DVector::Read vr=vertices.read(); + PoolVector vertices = navmeshie->get_vertices(); + PoolVector::Read vr=vertices.read(); List faces; for(int i=0;iget_polygon_count();i++) { Vector p = navmeshie->get_polygon(i); @@ -2582,11 +2582,11 @@ void NavigationMeshSpatialGizmo::redraw() { return; Map<_EdgeKey,bool> edge_map; - DVector tmeshfaces; + PoolVector tmeshfaces; tmeshfaces.resize(faces.size()*3); { - DVector::Write tw=tmeshfaces.write(); + PoolVector::Write tw=tmeshfaces.write(); int tidx=0; @@ -3391,8 +3391,8 @@ SpatialEditorGizmos::SpatialEditorGizmos() { pos3d_mesh = Ref( memnew( Mesh ) ); { - DVector cursor_points; - DVector cursor_colors; + PoolVector cursor_points; + PoolVector cursor_colors; float cs = 0.25; cursor_points.push_back(Vector3(+cs,0,0)); cursor_points.push_back(Vector3(-cs,0,0)); @@ -3424,8 +3424,8 @@ SpatialEditorGizmos::SpatialEditorGizmos() { listener_line_mesh = Ref(memnew(Mesh)); { - DVector cursor_points; - DVector cursor_colors; + PoolVector cursor_points; + PoolVector cursor_colors; cursor_points.push_back(Vector3(0, 0, 0)); cursor_points.push_back(Vector3(0, 0, -1.0)); cursor_colors.push_back(Color(0.5, 0.5, 0.5, 0.7)); @@ -3491,7 +3491,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() { { - DVector vertices; + PoolVector vertices; #undef ADD_VTX #define ADD_VTX(m_idx);\