For some weird reason after the last GLScene update, there seems to be a problem with the TGLLines when a PFXSourceFX is spawning particles.
I havn't figured out exactly what yet, but maybe you know a solution?
This code stops working on a TGLLines object while a sourceFX is creating particles:
for i := 0 to Lines1.Nodes.Count - 1 do
begin
Lines1.Nodes.Items[i].Y := 0 + (random(50) - 22 * 10);
end;
end;
I see now that it is the random function which is not working while a PFXSource is creating particles.
Is this a bug, or I'm I doing something wrong?
If I call Randomize;
I works a little better, but not good...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Daniel yes it's related Random function in Lazarus is not thread safe.Instead of Randomize/Random try to use TGLRandomNumGenerator in GLRandomGenerator unit.
First try using preinit object
uses GLRandomGenerator;
// GLS_RNG.Randomize; normally not needed try if not work properly
for i := 0 to Lines1.Nodes.Count - 1 do
begin
Lines1.Nodes.Items[i].Y := 0 + (GLS_RNG.Random(50) - 22 * 10);
end;
end;
if it not work
Var
MyRandomGen : TGLRandomGenerator.Create;
MyRandomGen := TGLRandomGenerator.Create;
//MyRandomGen.Randomize; // not needed it automatically call in create. call it a new time for regenerate new seed
for i := 0 to Lines1.Nodes.Count - 1 do
begin
Lines1.Nodes.Items[i].Y := 0 + (MyRandomGen.Random(50) - 22 * 10);
end;
end;
Last edit: Jerome.D (BeanzMaster) 2018-06-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey!
For some weird reason after the last GLScene update, there seems to be a problem with the TGLLines when a PFXSourceFX is spawning particles.
I havn't figured out exactly what yet, but maybe you know a solution?
This code stops working on a TGLLines object while a sourceFX is creating particles:
Can it be related to the RandSeed bug as in this case: ?
https://sourceforge.net/p/glscene/discussion/lazarus/thread/cc4be901/
Cheers!
I see now that it is the random function which is not working while a PFXSource is creating particles.
Is this a bug, or I'm I doing something wrong?
If I call Randomize;
I works a little better, but not good...
Hi Daniel yes it's related Random function in Lazarus is not thread safe.Instead of Randomize/Random try to use TGLRandomNumGenerator in GLRandomGenerator unit.
First try using preinit object
if it not work
Last edit: Jerome.D (BeanzMaster) 2018-06-27
Thanks Jerome!
That solved quite a few more bugs I had, that I didn't understand.
Cheers!!