mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: add path compression to disjoint set algorithm
Improve performance for future lookups.
This commit is contained in:
parent
4801435d42
commit
e28ea6cab1
@ -136,12 +136,14 @@ public:
|
||||
|
||||
return newId;
|
||||
}
|
||||
inline int find(const int id) const
|
||||
int find(const int id) const
|
||||
{
|
||||
if (parent[id] != id)
|
||||
return find(parent[id]);
|
||||
int& parentRef = parent[id];
|
||||
|
||||
return id;
|
||||
if (parentRef != id)
|
||||
parentRef = find(parentRef);
|
||||
|
||||
return parentRef;
|
||||
}
|
||||
void setUnion(const int x, const int y)
|
||||
{
|
||||
@ -166,7 +168,7 @@ public:
|
||||
|
||||
private:
|
||||
rdIntArray rank;
|
||||
rdIntArray parent;
|
||||
mutable rdIntArray parent;
|
||||
};
|
||||
|
||||
/// Builds navigation mesh disjoint poly groups from the provided navmesh.
|
||||
|
Loading…
x
Reference in New Issue
Block a user