A very simple and stupid but working way would be to do that:
Code:
procedure AddNode(Vector: TD3DXVector3);
procedure AddNeighbourNode(CurNode, Neightbour: integer);
var
i: integer;
begin
for i := 0 to 3 do
if path.NodeList[CurNode].NextNode[i] = -1 then
begin
path.NodeList[CurNode].NextNode[i] := Neightbour;
path.NodeList[CurNode].Distance[i] :=
path.GetNodeDistance(
Neightbour,
path.NodeList[CurNode].Position
);
break;
end;
end;
var
NodeID: integer;
NeighbourID: integer;
begin
path.AddNode(LVector(Vector));
NodeID := path.NodeCount;
NeighbourID := GetNearNode(LVector(Vector));
if NeighbourID = -1 then exit;
AddNeighbourNode(NodeID, NeighbourID);
AddNeighbourNode(NeighbourID, NodeID);
end;
...
//So instead of path.AddNode(D3DXVector3(...));
//you put
AddNode(D3DXVector3(...));
there might be errors in the code cause I was just typing straight it.
but you can probably see the logic, even though it is probably the worst
implementation possible
Bookmarks