Skip to content

Commit

Permalink
Add support for insulations
Browse files Browse the repository at this point in the history
  • Loading branch information
paxbun committed Dec 22, 2021
1 parent bc70960 commit 9ed3c9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion server/core/Public/leth/MatrixSpace.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MatrixSpace : public Space
private:
std::vector<float> _A, _x, _b;
std::vector<Pos> _i2Pos;
std::vector<uint32_t> _i2NumNeighbors;
std::vector<uint32_t> _i2NumNeighboringWalls;
std::vector<size_t> _pos2I;

public:
Expand Down
15 changes: 9 additions & 6 deletions server/core/Source/MatrixSpace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool MatrixSpace::BuildEquation(Point const* input) noexcept
_x.clear();
_b.clear();
_i2Pos.clear();
_i2NumNeighbors.clear();
_i2NumNeighboringWalls.clear();

constexpr int16_t offsets[4][2] {
{ -1, 0 },
Expand All @@ -76,25 +76,25 @@ bool MatrixSpace::BuildEquation(Point const* input) noexcept
size_t const idx { GetIndex(i, j) };
if (input[idx].type == PointType::GroundTruth)
{
uint32_t numNeighbors { 0 };
uint32_t numNeighboringWalls { 0 };
for (auto& offset : offsets)
{
if (!Inside(i + offset[0], j + offset[1]))
{
--numNeighbors;
++numNeighboringWalls;
continue;
}

if (input[GetIndex(i + offset[0], j + offset[1])].type == PointType::OutOfRange)
{
--numNeighbors;
++numNeighboringWalls;
continue;
}
}

_pos2I[idx] = _i2Pos.size();
_i2NumNeighboringWalls.push_back(numNeighboringWalls);
_i2Pos.push_back(Pos { static_cast<uint16_t>(j), static_cast<uint16_t>(i) });
_i2NumNeighbors.push_back(numNeighbors);
}
else
_pos2I[idx] = std::numeric_limits<size_t>::max();
Expand All @@ -108,11 +108,14 @@ bool MatrixSpace::BuildEquation(Point const* input) noexcept

for (size_t i { 0 }, iEnd { _i2Pos.size() }; i < iEnd; ++i)
{
_A[i * numVars + i] = -4 + _i2NumNeighbors[i];
_A[i * numVars + i] = -4 + static_cast<float>(_i2NumNeighboringWalls[i]);

size_t const idx { GetIndex(_i2Pos[i].y, _i2Pos[i].x) };
for (auto& offset : offsets)
{
if (!Inside(_i2Pos[i].y + offset[0], _i2Pos[i].x + offset[1]))
continue;

auto const offsetAppliedIdx {
GetIndex(_i2Pos[i].y + offset[0], _i2Pos[i].x + offset[1]),
};
Expand Down

0 comments on commit 9ed3c9c

Please sign in to comment.