improvement of index-calculation



Hi!

I want to improve the speed of the following function

function TMathCloudParticles.GetVoxelFromXYZ(const x, y, z: integer): boolean;
begin
// result := GetArrayBit(pCldFront, GetVoxelIndex(x, y, z));

result := (pCldFront[
x or
(z shl iCloudDimXZ) or
((y and not iBitMaskY) shl ((iCloudDimXZ shl 1)-5))] and
(1 shl (y and iBitMaskY))) <>0;
end;

pCldFront : PDwordArray;
iCloudDimXZ,iBitMaskY : Integer (private fields of the class).

It is possible to pre-calculate ((iCloudDimXZ shl 1)-5) in the
constructor of the class to another private field.

TIA
Guenther


.