diff options
author | 2016-05-12 08:42:02 +0200 | |
---|---|---|
committer | 2016-05-12 08:42:02 +0200 | |
commit | 2fe208917976a66a315c83672cc2242ffb2ac88a (patch) | |
tree | 461cb81c293cd0a429db12a2ffe055a4b9400861 /3rdparty/bgfx/examples/common/cube_atlas.cpp | |
parent | f7f6569add35e5588fcdf686af4b4d9ad5396b11 (diff) |
Update BGFX, BX, Benchmark and RapidJSON (nw)
Diffstat (limited to '3rdparty/bgfx/examples/common/cube_atlas.cpp')
-rw-r--r-- | 3rdparty/bgfx/examples/common/cube_atlas.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/3rdparty/bgfx/examples/common/cube_atlas.cpp b/3rdparty/bgfx/examples/common/cube_atlas.cpp index ac7343b9b21..7b83f6f7518 100644 --- a/3rdparty/bgfx/examples/common/cube_atlas.cpp +++ b/3rdparty/bgfx/examples/common/cube_atlas.cpp @@ -81,7 +81,7 @@ RectanglePacker::RectanglePacker(uint32_t _width, uint32_t _height) { // We want a one pixel border around the whole atlas to avoid any artefact when // sampling texture - m_skyline.push_back(Node(1, 1, _width - 2) ); + m_skyline.push_back(Node(1, 1, uint16_t(_width - 2) ) ); } void RectanglePacker::init(uint32_t _width, uint32_t _height) @@ -95,38 +95,35 @@ void RectanglePacker::init(uint32_t _width, uint32_t _height) m_skyline.clear(); // We want a one pixel border around the whole atlas to avoid any artifact when // sampling texture - m_skyline.push_back(Node(1, 1, _width - 2) ); + m_skyline.push_back(Node(1, 1, uint16_t(_width - 2) ) ); } bool RectanglePacker::addRectangle(uint16_t _width, uint16_t _height, uint16_t& _outX, uint16_t& _outY) { - int yy, best_height, best_index; + int best_height, best_index; int32_t best_width; Node* node; Node* prev; _outX = 0; _outY = 0; - uint32_t ii; - best_height = INT_MAX; best_index = -1; best_width = INT_MAX; - for (ii = 0; ii < m_skyline.size(); ++ii) + for (uint16_t ii = 0, num = uint16_t(m_skyline.size() ); ii < num; ++ii) { - yy = fit(ii, _width, _height); + int32_t yy = fit(ii, _width, _height); if (yy >= 0) { node = &m_skyline[ii]; if ( ( (yy + _height) < best_height) - || ( ( (yy + _height) == best_height) - && (node->width < best_width) ) ) + || ( ( (yy + _height) == best_height) && (node->width < best_width) ) ) { - best_height = yy + _height; + best_height = uint16_t(yy) + _height; best_index = ii; best_width = node->width; _outX = node->x; - _outY = yy; + _outY = uint16_t(yy); } } } @@ -139,13 +136,13 @@ bool RectanglePacker::addRectangle(uint16_t _width, uint16_t _height, uint16_t& Node newNode(_outX, _outY + _height, _width); m_skyline.insert(m_skyline.begin() + best_index, newNode); - for (ii = best_index + 1; ii < m_skyline.size(); ++ii) + for (uint16_t ii = uint16_t(best_index + 1), num = uint16_t(m_skyline.size() ); ii < num; ++ii) { node = &m_skyline[ii]; prev = &m_skyline[ii - 1]; if (node->x < (prev->x + prev->width) ) { - int shrink = prev->x + prev->width - node->x; + uint16_t shrink = uint16_t(prev->x + prev->width - node->x); node->x += shrink; node->width -= shrink; if (node->width <= 0) @@ -187,7 +184,7 @@ void RectanglePacker::clear() // We want a one pixel border around the whole atlas to avoid any artefact when // sampling texture - m_skyline.push_back(Node(1, 1, m_width - 2) ); + m_skyline.push_back(Node(1, 1, uint16_t(m_width - 2) ) ); } int32_t RectanglePacker::fit(uint32_t _skylineNodeIndex, uint16_t _width, uint16_t _height) |