mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 14:00:17 +00:00
fix calculation of link weight
This commit is contained in:
parent
30f69225ea
commit
f325ff298b
1 changed files with 8 additions and 3 deletions
|
@ -190,7 +190,7 @@ namespace SanAndreasUnity.Behaviours
|
||||||
if (idM.Equals(targetId))
|
if (idM.Equals(targetId))
|
||||||
{
|
{
|
||||||
var dataM = GetResettedData();
|
var dataM = GetResettedData();
|
||||||
dataM.g = dataN.g + link.Length;
|
dataM.g = dataN.g + CalculateLinkWeight(idN, idM);
|
||||||
float h = CalculateHeuristic(idM, targetId);
|
float h = CalculateHeuristic(idM, targetId);
|
||||||
dataM.f = dataM.g + h;
|
dataM.f = dataM.g + h;
|
||||||
dataM.parentId = idN;
|
dataM.parentId = idN;
|
||||||
|
@ -205,7 +205,7 @@ namespace SanAndreasUnity.Behaviours
|
||||||
|
|
||||||
if (openList.Contains(idM))
|
if (openList.Contains(idM))
|
||||||
{
|
{
|
||||||
float gNew = dataN.g + link.Length;
|
float gNew = dataN.g + CalculateLinkWeight(idN, idM);
|
||||||
float hNew = CalculateHeuristic(idM, targetId);
|
float hNew = CalculateHeuristic(idM, targetId);
|
||||||
float fNew = gNew + hNew;
|
float fNew = gNew + hNew;
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ namespace SanAndreasUnity.Behaviours
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var dataM = GetResettedData();
|
var dataM = GetResettedData();
|
||||||
dataM.g = dataN.g + link.Length;
|
dataM.g = dataN.g + CalculateLinkWeight(idN, idM);
|
||||||
float h = CalculateHeuristic(idM, targetId);
|
float h = CalculateHeuristic(idM, targetId);
|
||||||
dataM.f = dataM.g + h;
|
dataM.f = dataM.g + h;
|
||||||
dataM.parentId = idN;
|
dataM.parentId = idN;
|
||||||
|
@ -266,6 +266,11 @@ namespace SanAndreasUnity.Behaviours
|
||||||
return NodeReader.GetDistanceBetweenNodes(source, destination);
|
return NodeReader.GetDistanceBetweenNodes(source, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float CalculateLinkWeight(PathNodeId parentId, PathNodeId neighbourId)
|
||||||
|
{
|
||||||
|
return NodeReader.GetDistanceBetweenNodes(parentId, neighbourId);
|
||||||
|
}
|
||||||
|
|
||||||
private void RestoreModifiedDatas()
|
private void RestoreModifiedDatas()
|
||||||
{
|
{
|
||||||
foreach (var id in m_modifiedDatas)
|
foreach (var id in m_modifiedDatas)
|
||||||
|
|
Loading…
Reference in a new issue