summary refs log tree commit diff stats
path: root/Source/Panel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Panel.cpp')
-rw-r--r--Source/Panel.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/Source/Panel.cpp b/Source/Panel.cpp index 14f803c..8642461 100644 --- a/Source/Panel.cpp +++ b/Source/Panel.cpp
@@ -1,12 +1,13 @@
1#include "Panel.h" 1#include "Panel.h"
2#include "Random.h" 2#include "Random.h"
3#include "Memory.h" 3#include "Memory.h"
4#include "Randomizer.h"
4#include <sstream> 5#include <sstream>
5 6
6template <class T> 7template <class T>
7int find(const std::vector<T> &data, T search, size_t startIndex = 0) { 8int find(const std::vector<T> &data, T search, size_t startIndex = 0) {
8 for (size_t i=startIndex ; i<data.size(); i++) { 9 for (size_t i=startIndex ; i<data.size(); i++) {
9 if (data[i] == search) return i; 10 if (data[i] == search) return static_cast<int>(i);
10 } 11 }
11 return -1; 12 return -1;
12} 13}
@@ -167,8 +168,8 @@ void Panel::WriteIntersections(int id) {
167 168
168 for (int y=0; y<_height; y++) { 169 for (int y=0; y<_height; y++) {
169 for (int x=0; x<_width; x++) { 170 for (int x=0; x<_width; x++) {
170 intersections.push_back(min + x * width_interval); 171 intersections.push_back(static_cast<float>(min + x * width_interval));
171 intersections.push_back(min + y * height_interval); 172 intersections.push_back(static_cast<float>(min + y * height_interval));
172 int flags = 0; 173 int flags = 0;
173 if (find(_startpoints, {x, y}) != -1) flags |= IntersectionFlags::IS_STARTPOINT; 174 if (find(_startpoints, {x, y}) != -1) flags |= IntersectionFlags::IS_STARTPOINT;
174 intersectionFlags.push_back(flags); 175 intersectionFlags.push_back(flags);
@@ -184,22 +185,22 @@ void Panel::WriteIntersections(int id) {
184 } 185 }
185 186
186 for (Endpoint endpoint : _endpoints) { 187 for (Endpoint endpoint : _endpoints) {
187 float xPos = min + endpoint.GetX() * width_interval; 188 double xPos = min + endpoint.GetX() * width_interval;
188 float yPos = min + endpoint.GetY() * height_interval; 189 double yPos = min + endpoint.GetY() * height_interval;
189 if (endpoint.GetDir()== Endpoint::Direction::LEFT) { 190 if (endpoint.GetDir()== Endpoint::Direction::LEFT) {
190 xPos -= .05f; 191 xPos -= .05;
191 } else if (endpoint.GetDir() == Endpoint::Direction::RIGHT) { 192 } else if (endpoint.GetDir() == Endpoint::Direction::RIGHT) {
192 xPos += .05f; 193 xPos += .05;
193 } else if (endpoint.GetDir() == Endpoint::Direction::UP) { 194 } else if (endpoint.GetDir() == Endpoint::Direction::UP) {
194 yPos += .05f; // Y position goes from 0 (bottom) to 1 (top), so this is reversed. 195 yPos += .05; // Y position goes from 0 (bottom) to 1 (top), so this is reversed.
195 } else if (endpoint.GetDir() == Endpoint::Direction::DOWN) { 196 } else if (endpoint.GetDir() == Endpoint::Direction::DOWN) {
196 yPos -= .05f; 197 yPos -= .05;
197 } 198 }
198 intersections.push_back(xPos); 199 intersections.push_back(static_cast<float>(xPos));
199 intersections.push_back(yPos); 200 intersections.push_back(static_cast<float>(yPos));
200 201
201 connections.first.push_back(endpoint.GetY() * _width + endpoint.GetX()); // Target to connect to 202 connections.first.push_back(endpoint.GetY() * _width + endpoint.GetX()); // Target to connect to
202 connections.second.push_back(intersectionFlags.size()); // This endpoint 203 connections.second.push_back(static_cast<int>(intersectionFlags.size())); // This endpoint
203 intersectionFlags.push_back(IntersectionFlags::IS_ENDPOINT); 204 intersectionFlags.push_back(IntersectionFlags::IS_ENDPOINT);
204 } 205 }
205 206