I think there is no need to normalize on each change.Originally Posted by Nitrogen
Once emit all the particles with the same speed and they will fly nicely.
If you wouldn't to use SSE consider the inverse square root (1/SQRT(x)) :
[pascal]function InvSqrt(x: Single): Single;
var tmp: LongWord;
begin
asm
mov eax, OneAsInt
sub eax, x
add eax, OneAsInt2
shr eax, 1
mov tmp, eax
end;
Result := Single((@tmp)^) * (1.47 - 0.47 * x * Single((@tmp)^) * Single((@tmp)^));
end;[/pascal]
Also you can set velocity in spherical coordinates. Just generate randomly two angle phi and theta and constrruct a velocity vector:Originally Posted by Nitrogen
[pascal]Phi := Random*Pi*2; Theta := Random*Pi;
Velocity := GetVector3s(Cos(Phi)*Sin(Theta)*Speed, Sin(Theta)*Speed, Sin(Phi)*Sin(Theta)*Speed);[/pascal]
Sin/Cose values can be looked-up in a precalculated table.[/pascal]
Bookmarks