summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-01-07 18:25:37 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-01-07 18:26:38 -0300
commit2ab83e1abbf5ee6d00e16056a9e9394114026f28 (patch)
tree7efbb375cc4d00d8e8589fcf1b6a1303bec5df2d /scene/2d
parent2a38a5eaa844043b846e03d6655f84caf8a31e74 (diff)
Memory pool vectors (DVector) have been enormously simplified in code, and renamed to PoolVector
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/collision_polygon_2d.cpp6
-rw-r--r--scene/2d/light_occluder_2d.cpp8
-rw-r--r--scene/2d/light_occluder_2d.h6
-rw-r--r--scene/2d/navigation2d.cpp4
-rw-r--r--scene/2d/navigation_polygon.cpp30
-rw-r--r--scene/2d/navigation_polygon.h16
-rw-r--r--scene/2d/particles_2d.cpp6
-rw-r--r--scene/2d/particles_2d.h6
-rw-r--r--scene/2d/polygon_2d.cpp20
-rw-r--r--scene/2d/polygon_2d.h18
-rw-r--r--scene/2d/tile_map.cpp12
-rw-r--r--scene/2d/tile_map.h4
12 files changed, 68 insertions, 68 deletions
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 4b7a918023..46baa7c184 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<ConcavePolygonShape2D> concave = memnew( ConcavePolygonShape2D );
- DVector<Vector2> segments;
+ PoolVector<Vector2> segments;
segments.resize(polygon.size()*2);
- DVector<Vector2>::Write w=segments.write();
+ PoolVector<Vector2>::Write w=segments.write();
for(int i=0;i<polygon.size();i++) {
w[(i<<1)+0]=polygon[i];
w[(i<<1)+1]=polygon[(i+1)%polygon.size()];
}
- w=DVector<Vector2>::Write();
+ w=PoolVector<Vector2>::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 ac1fb16d78..ac2a8d4dc5 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<Vector2>& p_polygon) {
+void OccluderPolygon2D::set_polygon(const PoolVector<Vector2>& p_polygon) {
polygon=p_polygon;
VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon,p_polygon,closed);
emit_changed();
}
-DVector<Vector2> OccluderPolygon2D::get_polygon() const{
+PoolVector<Vector2> OccluderPolygon2D::get_polygon() const{
return polygon;
}
@@ -141,7 +141,7 @@ void LightOccluder2D::_notification(int p_what) {
if (occluder_polygon.is_valid()) {
- DVector<Vector2> poly = occluder_polygon->get_polygon();
+ PoolVector<Vector2> 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<Vector2>::Read r = poly.read();
+ PoolVector<Vector2>::Read r = poly.read();
for(int i=0;i<ps-1;i++) {
draw_line(r[i],r[i+1],Color(0,0,0,0.6),3);
diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h
index 1d7430689f..777785cd1d 100644
--- a/scene/2d/light_occluder_2d.h
+++ b/scene/2d/light_occluder_2d.h
@@ -45,7 +45,7 @@ private:
RID occ_polygon;
- DVector<Vector2> polygon;
+ PoolVector<Vector2> polygon;
bool closed;
CullMode cull;
@@ -54,8 +54,8 @@ protected:
static void _bind_methods();
public:
- void set_polygon(const DVector<Vector2>& p_polygon);
- DVector<Vector2> get_polygon() const;
+ void set_polygon(const PoolVector<Vector2>& p_polygon);
+ PoolVector<Vector2> 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 1a7d01c762..be68c61bd8 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<Vector2> vertices=nm.navpoly->get_vertices();
+ PoolVector<Vector2> vertices=nm.navpoly->get_vertices();
int len = vertices.size();
if (len==0)
return;
- DVector<Vector2>::Read r=vertices.read();
+ PoolVector<Vector2>::Read r=vertices.read();
for(int i=0;i<nm.navpoly->get_polygon_count();i++) {
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp
index a11f2240f9..add3a183ef 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<Vector2>& p_vertices) {
+void NavigationPolygon::set_vertices(const PoolVector<Vector2>& p_vertices) {
vertices=p_vertices;
}
-DVector<Vector2> NavigationPolygon::get_vertices() const{
+PoolVector<Vector2> NavigationPolygon::get_vertices() const{
return vertices;
}
@@ -89,7 +89,7 @@ void NavigationPolygon::add_polygon(const Vector<int>& p_polygon){
}
-void NavigationPolygon::add_outline_at_index(const DVector<Vector2>& p_outline,int p_index) {
+void NavigationPolygon::add_outline_at_index(const PoolVector<Vector2>& 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<Vector2>& p_outline) {
+void NavigationPolygon::add_outline(const PoolVector<Vector2>& 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<Vector2>& p_outline) {
+void NavigationPolygon::set_outline(int p_idx,const PoolVector<Vector2>& 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<Vector2> NavigationPolygon::get_outline(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,outlines.size(),DVector<Vector2>());
+PoolVector<Vector2> NavigationPolygon::get_outline(int p_idx) const {
+ ERR_FAIL_INDEX_V(p_idx,outlines.size(),PoolVector<Vector2>());
return outlines[p_idx];
}
@@ -147,11 +147,11 @@ void NavigationPolygon::make_polygons_from_outlines(){
for(int i=0;i<outlines.size();i++) {
- DVector<Vector2> ol = outlines[i];
+ PoolVector<Vector2> ol = outlines[i];
int olsize = ol.size();
if (olsize<3)
continue;
- DVector<Vector2>::Read r=ol.read();
+ PoolVector<Vector2>::Read r=ol.read();
for(int j=0;j<olsize;j++) {
outside_point.x = MAX( r[j].x, outside_point.x );
outside_point.y = MAX( r[j].y, outside_point.y );
@@ -165,11 +165,11 @@ void NavigationPolygon::make_polygons_from_outlines(){
for(int i=0;i<outlines.size();i++) {
- DVector<Vector2> ol = outlines[i];
+ PoolVector<Vector2> ol = outlines[i];
int olsize = ol.size();
if (olsize<3)
continue;
- DVector<Vector2>::Read r=ol.read();
+ PoolVector<Vector2>::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<Vector2> ol2 = outlines[k];
+ PoolVector<Vector2> ol2 = outlines[k];
int olsize2 = ol2.size();
if (olsize2<3)
continue;
- DVector<Vector2>::Read r2=ol2.read();
+ PoolVector<Vector2>::Read r2=ol2.read();
for(int l=0;l<olsize2;l++) {
@@ -368,7 +368,7 @@ void NavigationPolygonInstance::_notification(int p_what) {
if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) && navpoly.is_valid()) {
- DVector<Vector2> verts=navpoly->get_vertices();
+ PoolVector<Vector2> 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<Vector2>::Read vr = verts.read();
+ PoolVector<Vector2>::Read vr = verts.read();
for(int i=0;i<vsize;i++) {
vertices[i]=vr[i];
colors[i]=color;
diff --git a/scene/2d/navigation_polygon.h b/scene/2d/navigation_polygon.h
index edf3dcadc3..7f1762b6f5 100644
--- a/scene/2d/navigation_polygon.h
+++ b/scene/2d/navigation_polygon.h
@@ -36,12 +36,12 @@ class NavigationPolygon : public Resource {
GDCLASS( NavigationPolygon, Resource );
- DVector<Vector2> vertices;
+ PoolVector<Vector2> vertices;
struct Polygon {
Vector<int> indices;
};
Vector<Polygon> polygons;
- Vector< DVector<Vector2> > outlines;
+ Vector< PoolVector<Vector2> > outlines;
protected:
@@ -57,16 +57,16 @@ public:
- void set_vertices(const DVector<Vector2>& p_vertices);
- DVector<Vector2> get_vertices() const;
+ void set_vertices(const PoolVector<Vector2>& p_vertices);
+ PoolVector<Vector2> get_vertices() const;
void add_polygon(const Vector<int>& p_polygon);
int get_polygon_count() const;
- void add_outline(const DVector<Vector2>& p_outline);
- void add_outline_at_index(const DVector<Vector2>& p_outline,int p_index);
- void set_outline(int p_idx,const DVector<Vector2>& p_outline);
- DVector<Vector2> get_outline(int p_idx) const;
+ void add_outline(const PoolVector<Vector2>& p_outline);
+ void add_outline_at_index(const PoolVector<Vector2>& p_outline,int p_index);
+ void set_outline(int p_idx,const PoolVector<Vector2>& p_outline);
+ PoolVector<Vector2> 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 168bd1b289..f8747d54b7 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<Point2>::Read r;
+ PoolVector<Point2>::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<Vector2>& p_points) {
+void Particles2D::set_emission_points(const PoolVector<Vector2>& p_points) {
emission_points=p_points;
}
-DVector<Vector2> Particles2D::get_emission_points() const{
+PoolVector<Vector2> Particles2D::get_emission_points() const{
return emission_points;
}
diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h
index 9b740dad7d..91f42c5222 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<Vector2> emission_points;
+ PoolVector<Vector2> 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<Vector2>& p_points);
- DVector<Vector2> get_emission_points() const;
+ void set_emission_points(const PoolVector<Vector2>& p_points);
+ PoolVector<Vector2> 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 179e71fa90..948c8b0818 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<Vector2>::Read r = polygon.read();
+ PoolVector<Vector2>::Read r = polygon.read();
item_rect=Rect2();
for(int i=0;i<l;i++) {
Vector2 pos = r[i] + offset;
@@ -84,7 +84,7 @@ void Polygon2D::_notification(int p_what) {
int len = points.size();
{
- DVector<Vector2>::Read polyr =polygon.read();
+ PoolVector<Vector2>::Read polyr =polygon.read();
for(int i=0;i<len;i++) {
points[i]=polyr[i]+offset;
}
@@ -157,7 +157,7 @@ void Polygon2D::_notification(int p_what) {
if (points.size()==uv.size()) {
- DVector<Vector2>::Read uvr = uv.read();
+ PoolVector<Vector2>::Read uvr = uv.read();
for(int i=0;i<len;i++) {
uvs[i]=texmat.xform(uvr[i])/tex_size;
@@ -176,7 +176,7 @@ void Polygon2D::_notification(int p_what) {
int color_len=vertex_colors.size();
colors.resize(len);
{
- DVector<Color>::Read color_r=vertex_colors.read();
+ PoolVector<Color>::Read color_r=vertex_colors.read();
for(int i=0;i<color_len && i<len;i++){
colors[i]=color_r[i];
}
@@ -194,25 +194,25 @@ void Polygon2D::_notification(int p_what) {
}
-void Polygon2D::set_polygon(const DVector<Vector2>& p_polygon) {
+void Polygon2D::set_polygon(const PoolVector<Vector2>& p_polygon) {
polygon=p_polygon;
rect_cache_dirty=true;
update();
}
-DVector<Vector2> Polygon2D::get_polygon() const{
+PoolVector<Vector2> Polygon2D::get_polygon() const{
return polygon;
}
-void Polygon2D::set_uv(const DVector<Vector2>& p_uv) {
+void Polygon2D::set_uv(const PoolVector<Vector2>& p_uv) {
uv=p_uv;
update();
}
-DVector<Vector2> Polygon2D::get_uv() const{
+PoolVector<Vector2> Polygon2D::get_uv() const{
return uv;
}
@@ -227,12 +227,12 @@ Color Polygon2D::get_color() const{
return color;
}
-void Polygon2D::set_vertex_colors(const DVector<Color>& p_colors){
+void Polygon2D::set_vertex_colors(const PoolVector<Color>& p_colors){
vertex_colors=p_colors;
update();
}
-DVector<Color> Polygon2D::get_vertex_colors() const{
+PoolVector<Color> Polygon2D::get_vertex_colors() const{
return vertex_colors;
}
diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h
index 6327021295..8434dae40c 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<Vector2> polygon;
- DVector<Vector2> uv;
- DVector<Color> vertex_colors;
+ PoolVector<Vector2> polygon;
+ PoolVector<Vector2> uv;
+ PoolVector<Color> vertex_colors;
Color color;
Ref<Texture> texture;
Size2 tex_scale;
@@ -60,17 +60,17 @@ protected:
static void _bind_methods();
public:
- void set_polygon(const DVector<Vector2>& p_polygon);
- DVector<Vector2> get_polygon() const;
+ void set_polygon(const PoolVector<Vector2>& p_polygon);
+ PoolVector<Vector2> get_polygon() const;
- void set_uv(const DVector<Vector2>& p_uv);
- DVector<Vector2> get_uv() const;
+ void set_uv(const PoolVector<Vector2>& p_uv);
+ PoolVector<Vector2> get_uv() const;
void set_color(const Color& p_color);
Color get_color() const;
- void set_vertex_colors(const DVector<Color>& p_colors);
- DVector<Color> get_vertex_colors() const;
+ void set_vertex_colors(const PoolVector<Color>& p_colors);
+ PoolVector<Color> get_vertex_colors() const;
void set_texture(const Ref<Texture>& p_texture);
Ref<Texture> get_texture() const;
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 54d3f9f5dd..04b0379a1c 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<int>& p_data) {
+void TileMap::_set_tile_data(const PoolVector<int>& p_data) {
int c=p_data.size();
- DVector<int>::Read r = p_data.read();
+ PoolVector<int>::Read r = p_data.read();
for(int i=0;i<c;i+=2) {
@@ -857,11 +857,11 @@ void TileMap::_set_tile_data(const DVector<int>& p_data) {
}
-DVector<int> TileMap::_get_tile_data() const {
+PoolVector<int> TileMap::_get_tile_data() const {
- DVector<int> data;
+ PoolVector<int> data;
data.resize(tile_map.size()*2);
- DVector<int>::Write w = data.write();
+ PoolVector<int>::Write w = data.write();
int idx=0;
for(const Map<PosKey,Cell>::Element *E=tile_map.front();E;E=E->next()) {
@@ -882,7 +882,7 @@ DVector<int> TileMap::_get_tile_data() const {
}
- w = DVector<int>::Write();
+ w = PoolVector<int>::Write();
return data;
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 8cc144b74d..f863c0b2ea 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<int>& p_data);
- DVector<int> _get_tile_data() const;
+ void _set_tile_data(const PoolVector<int>& p_data);
+ PoolVector<int> _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; }