#pragma once namespace population { constexpr unsigned d = 3; constexpr unsigned q = 19; constexpr int velocity[q][d] = { { 0, 1, 1}, {-1, 0, 1}, { 0, 0, 1}, { 1, 0, 1}, { 0,-1, 1}, {-1, 1, 0}, { 0, 1, 0}, { 1, 1, 0}, {-1, 0, 0}, { 0, 0, 0}, { 1, 0, 0}, {-1,-1, 0}, { 0,-1, 0}, { 1,-1, 0}, { 0, 1,-1}, {-1, 0,-1}, { 0, 0,-1}, { 1, 0,-1}, { 0,-1,-1} }; unsigned opposite(unsigned iPop) { return q - 1 - iPop; } std::ptrdiff_t offset(const Cuboid& c, int iX, int iY, int iZ) { return iX*c[1]*c[2] + iY*c[2] + iZ; } std::ptrdiff_t offset(const Cuboid& c, unsigned iPop) { return offset(c, velocity[iPop][0], velocity[iPop][1], velocity[iPop][2]); } std::ptrdiff_t max_offset(const Cuboid& c) { std::ptrdiff_t padding = 0; for (unsigned iPop=0; iPop < q; ++iPop) { padding = std::max(padding, std::abs(offset(c, iPop))); } return padding; } } namespace stage { struct pre_collision { }; struct post_collision { }; }