Fork + Time
everyone, i an earlier post i said i was going to share where i made the modifications to the code, so i drew a couple of pictures explaining the way i think the code works, and where i made the modifications, this is just a tool for newcomers and people with no so advanced coding abilities, like me.
In the most simple way, the FOW in this project works using two arrays, a Boolean array and a FColor array, the picture above shows those arrays in Two different states, before an actor movement and after.
The bool array is black and white, and the FColor in the picture is light blue
If anyone is trying to understand the code, i think that a good start is in the FogOfWarWorker.cpp where most of the operations are performed, and the picture above is a simple (simple) representation of the code in that file.
The modifications made (purple color in the picture) by me are just a few IF statements that prevent or allow execution of code or data storage . The first one is made before the code checks the vectors in the sight of the actor, this is
if (isWriteUnFog) {
The second modification prevents/allows writing new values to the Bool Array named UnfoggedData
if (isWriteTerraIncog){
The other changes made, like the ability to load images as masks, and checking if the actor is “in some part of the texture” are easy to follow once one understand, and in my case if one draws what is happening with these two arrays.
Also…
I have made a new modification to this project thinking in the FOW mechanic, and in a new way to play with it. It is something simple, a timer recording the FOW “age” or how long ago the registered actors were in a particular position
for this i created two additional arrays, a boolean array tagging positions that should have a timer, this array is used inside the Worker thread, a second array containing the time values, this array is outside the worker thread and it gets the delta time after the last tick. Here is a video showing the timer with a limit, after the limit time has been reached the unveiled values that are not in sight (FOW) will return to black (What i call TerraIncognita)
And the picture explaining what is happening inside the code
The project files are here <=======
I hope anyone trying to program their own FOW solution finds this ideas useful, by doing this modifications I was thinking on how the fog of war is also a type of representation of memory, and with the timer the part of forgetting the information of a place. Well, that’s it.
Also thanks to for the FOW manager, as said by others before, it is also a good source of information on how to use threads.