Alright, I don't think I'm going to squeeze any more performance out of this. On to OpenCL

This commit is contained in:
2015-12-29 21:40:13 -08:00
parent e6f3bef05f
commit cc28558ccc
3 changed files with 25 additions and 71 deletions

View File

@@ -17,7 +17,7 @@ void Node::Revive() {
curr_state = true;
}
bool Node::CurrentState() {
int Node::CurrentState() {
return curr_state;
}
@@ -33,20 +33,16 @@ void Node::Update(std::vector<Node> *node_vec) {
// x , y - 1
// x - 1 , y
if (position.x < x_bound - 1 && position.x > -1 && position.y + 1 < y_bound - 1 && position.y + 1 > -1) {
if (node_vec->operator[](multi_to_linear(sf::Vector2i(position.x, position.y + 1))).CurrentState())
neighbors++;
neighbors += node_vec->operator[](multi_to_linear(sf::Vector2i(position.x, position.y + 1))).CurrentState();
}
if (position.x + 1 < x_bound - 1 && position.x + 1 > -1 && position.y < y_bound - 1 && position.y > -1) {
if (node_vec->operator[](multi_to_linear(sf::Vector2i(position.x + 1, position.y))).CurrentState())
neighbors++;
neighbors += node_vec->operator[](multi_to_linear(sf::Vector2i(position.x + 1, position.y))).CurrentState();
}
if (position.x < x_bound - 1 && position.x > -1 && position.y - 1 < y_bound - 1 && position.y - 1 > -1) {
if (node_vec->operator[](multi_to_linear(sf::Vector2i(position.x, position.y - 1))).CurrentState())
neighbors++;
neighbors += node_vec->operator[](multi_to_linear(sf::Vector2i(position.x, position.y - 1))).CurrentState();
}
if (position.x - 1 < x_bound - 1 && position.x - 1 > -1 && position.y < y_bound - 1 && position.y > -1) {
if (node_vec->operator[](multi_to_linear(sf::Vector2i(position.x - 1, position.y))).CurrentState())
neighbors++;
neighbors += node_vec->operator[](multi_to_linear(sf::Vector2i(position.x - 1, position.y))).CurrentState();
}
// x + 1, y + 1
@@ -55,20 +51,16 @@ void Node::Update(std::vector<Node> *node_vec) {
// x - 1, y - 1
if (position.x + 1 < x_bound - 1 && position.x + 1 > -1 && position.y + 1 < y_bound - 1 && position.y + 1 > -1) {
if (node_vec->operator[](multi_to_linear(sf::Vector2i(position.x + 1, position.y + 1))).CurrentState())
neighbors++;
neighbors += node_vec->operator[](multi_to_linear(sf::Vector2i(position.x + 1, position.y + 1))).CurrentState();
}
if (position.x + 1 < x_bound - 1 && position.x + 1 > -1 && position.y - 1 < y_bound - 1 && position.y - 1 > -1) {
if (node_vec->operator[](multi_to_linear(sf::Vector2i(position.x + 1, position.y - 1))).CurrentState())
neighbors++;
neighbors += node_vec->operator[](multi_to_linear(sf::Vector2i(position.x + 1, position.y - 1))).CurrentState();
}
if (position.x - 1 < x_bound - 1 && position.x - 1 > -1 && position.y + 1 < y_bound - 1 && position.y + 1 > -1) {
if (node_vec->operator[](multi_to_linear(sf::Vector2i(position.x - 1, position.y + 1))).CurrentState())
neighbors++;
neighbors += node_vec->operator[](multi_to_linear(sf::Vector2i(position.x - 1, position.y + 1))).CurrentState();
}
if (position.x - 1 < x_bound - 1 && position.x - 1 > -1 && position.y - 1 < y_bound - 1 && position.y - 1 > -1) {
if (node_vec->operator[](multi_to_linear(sf::Vector2i(position.x - 1, position.y - 1))).CurrentState())
neighbors++;
neighbors += node_vec->operator[](multi_to_linear(sf::Vector2i(position.x - 1, position.y - 1))).CurrentState();
}
if (neighbors == 3 || (neighbors == 2 && curr_state)) {