mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 20:13:02 +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))
|
||||
{
|
||||
var dataM = GetResettedData();
|
||||
dataM.g = dataN.g + link.Length;
|
||||
dataM.g = dataN.g + CalculateLinkWeight(idN, idM);
|
||||
float h = CalculateHeuristic(idM, targetId);
|
||||
dataM.f = dataM.g + h;
|
||||
dataM.parentId = idN;
|
||||
|
@ -205,7 +205,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
|
||||
if (openList.Contains(idM))
|
||||
{
|
||||
float gNew = dataN.g + link.Length;
|
||||
float gNew = dataN.g + CalculateLinkWeight(idN, idM);
|
||||
float hNew = CalculateHeuristic(idM, targetId);
|
||||
float fNew = gNew + hNew;
|
||||
|
||||
|
@ -230,7 +230,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
else
|
||||
{
|
||||
var dataM = GetResettedData();
|
||||
dataM.g = dataN.g + link.Length;
|
||||
dataM.g = dataN.g + CalculateLinkWeight(idN, idM);
|
||||
float h = CalculateHeuristic(idM, targetId);
|
||||
dataM.f = dataM.g + h;
|
||||
dataM.parentId = idN;
|
||||
|
@ -266,6 +266,11 @@ namespace SanAndreasUnity.Behaviours
|
|||
return NodeReader.GetDistanceBetweenNodes(source, destination);
|
||||
}
|
||||
|
||||
private float CalculateLinkWeight(PathNodeId parentId, PathNodeId neighbourId)
|
||||
{
|
||||
return NodeReader.GetDistanceBetweenNodes(parentId, neighbourId);
|
||||
}
|
||||
|
||||
private void RestoreModifiedDatas()
|
||||
{
|
||||
foreach (var id in m_modifiedDatas)
|
||||
|
|
Loading…
Reference in a new issue