From 56a3380b46f406ffaf093405ac2db4515b0a4f80 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Mon, 28 May 2012 16:44:39 +0000 Subject: Removes the ArrayList classes, and replaces all instances with std::vector implementations. --- Magic2/Magic.vcxproj | 1 - Magic2/Magic.vcxproj.filters | 3 --- Magic2/Selection.cpp | 33 ++++++++++++++++++++----- Magic2/Selection.h | 6 ++--- Magic2/Selector.cpp | 2 +- Magic2/UVMapView.cpp | 59 ++++++++++++++++++++++++++++++++++---------- Magic2/UVMapView.h | 4 +-- 7 files changed, 79 insertions(+), 29 deletions(-) (limited to 'Magic2') diff --git a/Magic2/Magic.vcxproj b/Magic2/Magic.vcxproj index a3d18c4..1e1337f 100644 --- a/Magic2/Magic.vcxproj +++ b/Magic2/Magic.vcxproj @@ -394,7 +394,6 @@ - diff --git a/Magic2/Magic.vcxproj.filters b/Magic2/Magic.vcxproj.filters index 7975525..1ed7515 100644 --- a/Magic2/Magic.vcxproj.filters +++ b/Magic2/Magic.vcxproj.filters @@ -27,9 +27,6 @@ Source Files - - Source Files - Source Files diff --git a/Magic2/Selection.cpp b/Magic2/Selection.cpp index 1c69129..3db43db 100644 --- a/Magic2/Selection.cpp +++ b/Magic2/Selection.cpp @@ -63,7 +63,7 @@ Selection::Render(Video* video, DWORD flags) } if (model) { - for (int i = 0; i < verts.size(); i++) { + for (size_t i = 0; i < verts.size(); i++) { DWORD value = verts[i]; WORD index = (WORD) (value >> 16); WORD vert = (WORD) (value & 0xffff); @@ -152,20 +152,41 @@ Selection::AddVert(WORD s, WORD v) { DWORD value = (s << 16) | v; - if (!verts.contains(value)) - verts.append(value); + bool contains = false; + for (auto vi = verts.begin(); vi != verts.end(); ++vi) { + if (*vi == value) { + contains = true; + break; + } + } + + if (!contains) + verts.push_back(value); } void Selection::RemoveVert(WORD s, WORD v) { DWORD value = (s << 16) | v; - verts.remove(value); + + for (auto vi = verts.begin(); vi != verts.end(); ++vi) { + if (*vi == value) { + verts.erase(vi); + return; + } + } } bool Selection::Contains(WORD s, WORD v) const { - DWORD value = (s << 16) | v; - return verts.contains(value); + DWORD value = (s << 16) | v; + + for (auto vi = verts.begin(); vi != verts.end(); ++vi) { + if (*vi == value) { + return true; + } + } + + return false; } \ No newline at end of file diff --git a/Magic2/Selection.h b/Magic2/Selection.h index 092f0ac..aba249a 100644 --- a/Magic2/Selection.h +++ b/Magic2/Selection.h @@ -15,11 +15,11 @@ #ifndef Selection_h #define Selection_h +#include #include "Polygon.h" #include "Graphic.h" #include "Video.h" #include "List.h" -#include "ArrayList.h" // +--------------------------------------------------------------------+ @@ -49,7 +49,7 @@ public: void UseView(ModelView* v){ model_view = v; } Model* GetModel() const { return model; } List& GetPolys() { return polys; } - ArrayList& GetVerts() { return verts; } + std::vector& GetVerts() { return verts; } virtual void Clear() { polys.clear(); verts.clear(); } @@ -65,7 +65,7 @@ protected: Model* model; ModelView* model_view; List polys; - ArrayList verts; + std::vector verts; }; // +--------------------------------------------------------------------+ diff --git a/Magic2/Selector.cpp b/Magic2/Selector.cpp index c79f813..898355e 100644 --- a/Magic2/Selector.cpp +++ b/Magic2/Selector.cpp @@ -232,7 +232,7 @@ Selector::SelectAll(int select_mode) for (int i = 0; i < s->NumVerts(); i++) { DWORD value = (iter.index() << 16) | i; - selection->GetVerts().append(value); + selection->GetVerts().push_back(value); } } } diff --git a/Magic2/UVMapView.cpp b/Magic2/UVMapView.cpp index 305782b..9e5ac98 100644 --- a/Magic2/UVMapView.cpp +++ b/Magic2/UVMapView.cpp @@ -182,8 +182,8 @@ UVMapView::DragBy(double dx, double dy) float du = (float) (dx/w); float dv = (float) (dy/h); - for (int i = 0; i < selverts.size(); i++) { - DWORD value = selverts[i]; + for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) { + DWORD value = *svi; DWORD p = value >> 16; DWORD n = value & 0xffff; @@ -266,10 +266,21 @@ UVMapView::End() DWORD value = (p_index << 16) | i; if (select_mode == SELECT_REMOVE) { - selverts.remove(value); + for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) { + if (*svi == value) { + selverts.erase(svi); + } + } } - else if (!selverts.contains(value)) { - selverts.append(value); + else { + bool contains = false; + for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) { + if (*svi == value) { + contains = true; + } + } + if (!contains) + selverts.push_back(value); } } } @@ -302,10 +313,19 @@ UVMapView::End() DWORD value = (p_index << 16) | i; if (select_mode == SELECT_REMOVE) { - selverts.remove(value); + for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) { + if (*svi == value) + selverts.erase(svi); + } } - else if (!selverts.contains(value)) { - selverts.append(value); + else { + bool contains = false; + for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) { + if (*svi == value) + contains = true; + } + if (!contains) + selverts.push_back(value); } } } @@ -332,7 +352,7 @@ UVMapView::SelectAll() for (int i = 0; i < p->nverts; i++) { WORD p_index = iter.index(); DWORD value = (p_index << 16) | i; - selverts.append(value); + selverts.push_back(value); } } } @@ -357,10 +377,17 @@ UVMapView::SelectInverse() WORD p_index = iter.index(); DWORD value = (p_index << 16) | i; - if (selverts.contains(value)) - selverts.remove(value); + bool contains = false; + auto svi = selverts.begin(); + for (; svi != selverts.end(); ++svi) { + if (*svi == value) contains = true; + break; + } + + if (contains) + selverts.erase(svi); else - selverts.append(value); + selverts.push_back(value); } } } @@ -371,7 +398,13 @@ UVMapView::IsSelected(Poly* poly, WORD v) WORD p = polys.index(poly); DWORD value = (p << 16) | v; - return selverts.contains(value); + bool contains = false; + + for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) { + return true; + } + + return false; } bool diff --git a/Magic2/UVMapView.h b/Magic2/UVMapView.h index 87b0eeb..fb40cbf 100644 --- a/Magic2/UVMapView.h +++ b/Magic2/UVMapView.h @@ -16,10 +16,10 @@ #ifndef UVMapView_h #define UVMapView_h +#include #include "View.h" #include "Polygon.h" #include "List.h" -#include "ArrayList.h" // +--------------------------------------------------------------------+ @@ -74,7 +74,7 @@ protected: int select_mode; bool active; - ArrayList selverts; + std::vector selverts; }; // +--------------------------------------------------------------------+ -- cgit v1.1