I've been working on taking my procedural generation out of the game thread and giving it its own thread to improve FPS and reduce stuttering. However I appear to be getting some sort of corruption or issue with the values I am setting within the thread.
In my run() i just take the job from the queue store it in a private variable and start this sub method:
bool IsComplete = false;
float PlacementValue = workJob.MinPlacementValue;
while (IsComplete == false)
for (int32 i = 0; i < workJob.PlacementAttempts; i++)
UE_LOG(LogTemp, Error, TEXT("pre calc place XLoc is %i"), workJob.BuildingLocation->XLocation);
// IsComplete = true;
UE_LOG(LogTemp, Error, TEXT("TempTest XLoc is %i"), workJob.BuildingLocation->XLocation);
The SetupParamsForInterestCalc() method basically sets the XLocation on the workJob (taken from the thread queue).
Somehow between the first log and the second log the correct value which is being set in the SetupParamsForInterestCalc(); method is being corrupted or changed to 0. This is very strange given that no other code is running in the thread between these two logs.
The stranger thing is that before I commented out the calculate placement method I used breakpoints upon entering the method for which the variable was fine, and then upon the first line of code it was strangely changing to -2 every time.
I don't understand how this is possible given the private nature of the variable and the lack of other processes. The workJob and buildinglocation variables are simply structs (not even ustructs).
If anyone knows what this issue is or how I can fix it then please help!
Oct 07 '18 at 08:12 PM
in C++ Programming