Skip to content

Commit

Permalink
Optimize base index calculate
Browse files Browse the repository at this point in the history
  • Loading branch information
defisym committed Aug 27, 2024
1 parent c1649f1 commit 98812b1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
2 changes: 0 additions & 2 deletions Extensions/FindTheWay/FindTheWay.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@
<ImportLibrary>$(IntDir)Template.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<Profile>false</Profile>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
Expand Down Expand Up @@ -234,7 +233,6 @@ copy $(TargetPath) "C:\Steam\steamapps\common\Clickteam Fusion 2.5\Extensions\Un
<ImportLibrary>$(IntDir)Template.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<Profile>false</Profile>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 8 additions & 13 deletions Extensions/_DeLib/FindTheWay.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,6 @@ namespace FindTheWay {
static inline auto addSet(CoordSet& v, CoordSet& src) {
v.insert(v.end(), src.begin(), src.end());
v.erase(std::ranges::unique(v).begin(), v.end());

//for(auto& it: src) {
// addSet(v, it);
//}
}

Base64<std::wstring> base64;
Expand Down Expand Up @@ -1241,18 +1237,11 @@ namespace FindTheWay {
return;
}

auto baseIdx = static_cast<size_t>(-1);
Point base = open_set.back();
open_set.pop_back();

close_set.emplace_back(base);

// put base point into point_set
auto baseIdx = findIdx(point_set, base);
if (baseIdx == static_cast<size_t>(-1)) {
point_set.emplace_back(base);
baseIdx = point_set.size() - 1;
}

for (size_t i = 0; i < neighbourSize; i++) {
auto neighCoord = Coord{ base.coord.x + (*pNeighbour)[i].x
,base.coord.y + (*pNeighbour)[i].y };
Expand Down Expand Up @@ -1284,8 +1273,14 @@ namespace FindTheWay {
auto updatePoint = [&] (Point& cur) {
cur.cost = neighPoint.cost;
cur.priority = static_cast<int>(heuristic(neighPoint.coord, destination) + neighPoint.cost);

// put base point into point_set
if (baseIdx == static_cast<size_t>(-1)) [[unlikely]] {
point_set.emplace_back(base);
baseIdx = point_set.size() - 1;
}
cur.parentID = baseIdx;
};
};

Point* next = find(open_set, neighPoint);

Expand Down

0 comments on commit 98812b1

Please sign in to comment.