Skip to content

Commit

Permalink
Move function into class body
Browse files Browse the repository at this point in the history
  • Loading branch information
Cultrarius committed Jul 25, 2016
1 parent a1c482e commit ced785d
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions swarmz.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,6 @@ namespace sw {
}
};

float TransformDistance(float distance, DistanceType type) {
if (type == DistanceType::LINEAR) {
return distance;
}
else if (type == DistanceType::INVERSE_LINEAR) {
return distance == 0 ? 0 : 1 / distance;
}
else if (type == DistanceType::QUADRATIC) {
return std::pow(distance, 2);
}
else if (type == DistanceType::INVERSE_QUADRATIC) {
float quad = std::pow(distance, 2);
return quad == 0 ? 0 : 1 / quad;
}
else {
return distance; // throw exception instead?
}
}

struct Boid {
Vec3 Position;
Vec3 Velocity;
Expand Down Expand Up @@ -333,5 +314,24 @@ namespace sw {
voxelPos.Z = static_cast<int>(p.Z / r);
return voxelPos;
}

float TransformDistance(float distance, DistanceType type) {
if (type == DistanceType::LINEAR) {
return distance;
}
else if (type == DistanceType::INVERSE_LINEAR) {
return distance == 0 ? 0 : 1 / distance;
}
else if (type == DistanceType::QUADRATIC) {
return std::pow(distance, 2);
}
else if (type == DistanceType::INVERSE_QUADRATIC) {
float quad = std::pow(distance, 2);
return quad == 0 ? 0 : 1 / quad;
}
else {
return distance; // throw exception instead?
}
}
};
}

0 comments on commit ced785d

Please sign in to comment.