This topic is 1086 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

In the first pseudocode, the cooperative pathfinding thread unstoppingly producing waypoints for

Because the mainthread will delete all waypoints in each iteration, it will get the latest waypoints

from the "CPF" thread, but this has a shortcoming, the mainthread will jerk as the it has to wait

for the cpf thread to compute something and provide him some waypoints.

Are there any good suggestions that I could make some improvements on this.

Should I just slow down the cpf thread, make him produce less waypoints,

and the mainthread will keep on interpolating on his current waypoints?

PS: A path point is a cell that the TimeAStar has reserved for the current window

And also, I am looking into something like conditional variables and futures of the std library.. right? :)

Thanks

Jack

cpf_thread_start:
cpf thread -> delete all pathpoints
cpf thread -> create waypoints  1,2,3,4,5,6

main:
mainthread -> consume next waypoint (wait for cpf thread to provide some)
mainthread -> Intepolating between 2 waypoints
goto main:

main)
waypoints empty
waypoints 1,2,3,4,5,6
waypoints empty
waypoints 2,3,4,5,6
waypoints empty
waypoints 3,4,5,6

The mainthread has to wait for the cpf thread to provide some waypoints
from each iteration

Edited by lucky6969b

Share on other sites

Use a double buffer?

You have 2 buffers for way points. The main thread has the most current one.

The other buffer is scratch space for the A* thread.

When the A* thread has a new set of points, you swap both buffers (using pointers, so it's really quick).

The main thread then has the new points, and the A* thread has new scratch space it can delete, and recompute.

In this way, the main thread always has the next point to go to.

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5

• 10
• 21
• 9
• 31
• 16
• Forum Statistics

• Total Topics
632618
• Total Posts
3007464
• Who's Online (See full list)

There are no registered users currently online

×