out is the same as var except the value going in is ignored. const, var and out are only mostly useful when dealing with record types. For objects they have no real benefit.Originally Posted by savage
These vectors are never used.[pascal]
// these are used for moving and changing camera orientation
// through the MoveTo/LookTo methods
initPosition, finalPosition : TVector;
initLookAt, finalLookAt : TVector;[/pascal]
LookAtVelocity is referenced, but never created. LookAtAcceleration is never used.[pascal] LookAtVelocity : TVector; // velocity for looking at objects
LookAtAcceleration : TVector; // acceleration for looking at objects[/pascal]
How are these methods called if they are in the protected section?[pascal] procedure UpdateLookAt;
procedure UpdateMoveTo;[/pascal]
I would provide a LookAt method that functions like most other LookAt functions where you provide the eye, target and up vectors.[pascal] procedure LookAt( aX : TScalar; aY : TScalar; aZ : TScalar ); overload;
procedure LookAt( aLook : TVector ); overload;
procedure MoveTo( aX : TScalar; aY : TScalar; aZ : TScalar ); overload;
procedure MoveTo( aPosition : TVector ); overload;[/pascal]
How about a Rotate(aAngle: TVector) where each element of the vector is the angle in one axis? That is quite common. Instead of (x, y, z), it is (pitch, yaw, roll).[pascal] // right rotation along y-axis (yaw)
procedure RotateYaw( aRadians : TScalar );
procedure RotatePitch( aRadians : TScalar );
procedure RotateRoll( aRadians : TScalar );
end;[/pascal]
You can call Free on a nil object with no ill effect. No need to check for nil before calling Free.[pascal]destructor TCamera.Destroy;
begin
if CameraPosition <> nil then
CameraPosition.Free;
if CameraLookAt <> nil then
CameraLookAt.Free;
if CameraForward <> nil then
CameraForward.Free;
if CameraUp <> nil then
CameraUp.Free;
if CameraRight <> nil then
CameraRight.Free;
if CameraVelocity <> nil then
CameraVelocity.Free;
if CameraAcceleration <> nil then
CameraAcceleration.Free;
if CalcVector <> nil then
CalcVector.Free;
inherited;
end;[/pascal]
The difference is not that great these days with these operations implemented in the FPU. If you do want it to be faster, call SinCos instead of calling Sin and Cos separately.The Sine and Cosine operations should probably be a look-up table to speed things up, if you are so inclined .
Bookmarks