Change Vec dimension type to uint32_t.
This commit is contained in:
parent
4d8cbc4085
commit
e2273e0d14
3 changed files with 14 additions and 11 deletions
|
@ -9,6 +9,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -O3 -Wall -We
|
|||
add_definitions(
|
||||
-DWITH_VECTOR_IOSTREAM
|
||||
-DUSE_MANUAL_TYPENAMES
|
||||
-DVWR_DIM_TYPE=uint32_t
|
||||
)
|
||||
|
||||
find_library(Boost 1.53.0 REQUIRED)
|
||||
|
@ -27,7 +28,7 @@ target_include_directories(${PROJECT_NAME}
|
|||
|
||||
#add_subdirectory(lib/sprout)
|
||||
add_subdirectory(src)
|
||||
#add_subdirectory(test)
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(game)
|
||||
#add_subdirectory(tools/mapconv)
|
||||
add_subdirectory(test/gtest-1.7.0)
|
||||
|
|
|
@ -43,9 +43,9 @@ namespace dk {
|
|||
template <uint32_t D>
|
||||
inline CoordinateDistType to_index (const Vector<D>& parPos, const Vector<D>& parUpper) {
|
||||
CoordinateDistType index = 0;
|
||||
for (CoordinateDistType d = 0; d < D; ++d) {
|
||||
for (uint32_t d = 0; d < D; ++d) {
|
||||
auto pos = static_cast<CoordinateDistType>(parPos[D - 1 - d]);
|
||||
for (CoordinateDistType p = 0; p < D - 1 - d; ++p) {
|
||||
for (uint32_t p = 0; p < D - 1 - d; ++p) {
|
||||
pos *= static_cast<CoordinateDistType>(parUpper[p] + 1);
|
||||
}
|
||||
|
||||
|
@ -86,15 +86,16 @@ namespace dk {
|
|||
|
||||
template <uint32_t D>
|
||||
TileCoords<D>& TileCoords<D>::operator++ () {
|
||||
static_assert(D > 0, "Dimention must be a positive number");
|
||||
const coords lower(0);
|
||||
for (std::size_t d = 0; d < static_cast<std::size_t>(D - 1); ++d) {
|
||||
for (uint32_t d = 0; d < D - 1; ++d) {
|
||||
++m_pos[d];
|
||||
if (m_pos[d] > m_size[d])
|
||||
m_pos[d] = lower[d];
|
||||
else
|
||||
return *this;
|
||||
}
|
||||
++m_pos[static_cast<std::size_t>(D - 1)];
|
||||
++m_pos[D - 1];
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -107,8 +108,9 @@ namespace dk {
|
|||
|
||||
template <uint32_t D>
|
||||
TileCoords<D>& TileCoords<D>::operator-- () {
|
||||
static_assert(D > 0, "Dimention must be a positive number");
|
||||
const coords lower(0);
|
||||
for (std::size_t d = 0; d < static_cast<std::size_t>(D); ++d) {
|
||||
for (uint32_t d = 0; d < D; ++d) {
|
||||
if (m_pos[d] > lower[d]) {
|
||||
--m_pos[d];
|
||||
return *this;
|
||||
|
@ -117,7 +119,7 @@ namespace dk {
|
|||
m_pos[d] = m_size[d];
|
||||
}
|
||||
}
|
||||
++m_pos[static_cast<std::size_t>(D - 1)];
|
||||
++m_pos[D - 1];
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -130,7 +132,7 @@ namespace dk {
|
|||
|
||||
template <uint32_t D>
|
||||
const TileCoords<D>& TileCoords<D>::operator-= (CoordinateScalarType parValue) {
|
||||
std::size_t index = 0;
|
||||
uint32_t index = 0;
|
||||
if (parValue > 0) {
|
||||
while (parValue) {
|
||||
const auto t = parValue % (m_size[index] + 1);
|
||||
|
@ -158,7 +160,7 @@ namespace dk {
|
|||
|
||||
template <uint32_t D>
|
||||
const TileCoords<D>& TileCoords<D>::operator+= (CoordinateScalarType parValue) {
|
||||
std::size_t index = 0;
|
||||
uint32_t index = 0;
|
||||
if (parValue > 0) {
|
||||
while (parValue) {
|
||||
//naïve implementation
|
||||
|
|
|
@ -12,8 +12,8 @@ namespace dk {
|
|||
///--------------------------------------------------------------------------
|
||||
template <uint32_t D>
|
||||
typename Tyler<D>::coords::scalar_type Tyler<D>::tiles_count() const {
|
||||
typename coords::value_type retval = 1;
|
||||
for (size_t d = 0; d < D; ++d) {
|
||||
typename coords::scalar_type retval = 1;
|
||||
for (uint32_t d = 0; d < D; ++d) {
|
||||
retval *= m_size[d];
|
||||
}
|
||||
return retval;
|
||||
|
|
Loading…
Reference in a new issue