new assertions

stair fixes
This commit is contained in:
2016-01-27 21:36:07 +01:00
parent 0e05f4bef8
commit c4ea811342
2 changed files with 6 additions and 2 deletions

View File

@@ -154,7 +154,7 @@ public:
/** get the center-node the given Point belongs to */ /** get the center-node the given Point belongs to */
const T& getNodeFor(const GridPoint& p) { const T& getNodeFor(const GridPoint& p) {
const UID uid = getUID(p); const UID uid = getUID(p);
if (hashes.find(uid) == hashes.end()) {throw Exception("element not found!");} Assert::isTrue(hashes.find(uid) != hashes.end(), "element not found!");
return nodes[hashes[uid]]; return nodes[hashes[uid]];
} }

View File

@@ -119,6 +119,10 @@ public:
} }
float align(const float val) {
const float gridSize_cm = grid.getGridSize_cm();
return std::round(val/gridSize_cm) * gridSize_cm;
}
/** shrink the given bbox to be grid-aligned */ /** shrink the given bbox to be grid-aligned */
BBox2 shrinkAlign(const BBox2& bb) { BBox2 shrinkAlign(const BBox2& bb) {
@@ -135,7 +139,7 @@ public:
/** add a new platform-stair between the two given floors */ /** add a new platform-stair between the two given floors */
void buildPlatformStair(const PlatformStair& s, const float z1_cm, const float z2_cm) { void buildPlatformStair(const PlatformStair& s, const float z1_cm, const float z2_cm) {
const float zCenter_cm = (z2_cm + z1_cm) / 2; const float zCenter_cm = align((z2_cm + z1_cm) / 2);
std::vector<int> indices; std::vector<int> indices;
// add the platform in the middle // add the platform in the middle