added one "optimized" calcfunction
This commit is contained in:
parent
364eceef07
commit
8cdea5949c
@ -9,12 +9,16 @@ const
|
|||||||
var_a_name = 'perspective_angle';
|
var_a_name = 'perspective_angle';
|
||||||
var_f_name = 'perspective_dist';
|
var_f_name = 'perspective_dist';
|
||||||
|
|
||||||
|
{$define _ASM_}
|
||||||
|
|
||||||
type
|
type
|
||||||
TVariationPerspective = class(TBaseVariation)
|
TVariationPerspective = class(TBaseVariation)
|
||||||
private
|
private
|
||||||
angle, focus: double;
|
angle, focus: double;
|
||||||
vsin, vf, vfcos: double;
|
vsin, vf, vfcos: double;
|
||||||
|
|
||||||
|
procedure CalcLinear;
|
||||||
|
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
|
|
||||||
@ -28,8 +32,9 @@ type
|
|||||||
function GetVariable(const Name: string; var value: double): boolean; override;
|
function GetVariable(const Name: string; var value: double): boolean; override;
|
||||||
function ResetVariable(const Name: string): boolean; override;
|
function ResetVariable(const Name: string): boolean; override;
|
||||||
|
|
||||||
procedure CalcFunction; override;
|
|
||||||
procedure Prepare; override;
|
procedure Prepare; override;
|
||||||
|
procedure CalcFunction; override;
|
||||||
|
procedure GetCalcFunction(var f: TCalcFunction); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -47,14 +52,22 @@ begin
|
|||||||
vfcos := vf * cos(angle*pi/2);
|
vfcos := vf * cos(angle*pi/2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
procedure TVariationPerspective.GetCalcFunction(var f: TCalcFunction);
|
||||||
|
begin
|
||||||
|
if IsZero(angle) then f := CalcLinear
|
||||||
|
else f := CalcFunction;
|
||||||
|
end;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
procedure TVariationPerspective.CalcFunction;
|
procedure TVariationPerspective.CalcFunction;
|
||||||
{$if false}
|
{$if false}
|
||||||
var
|
var
|
||||||
t: double;
|
t: double;
|
||||||
begin
|
begin
|
||||||
t := (focus - fty^*vsin);
|
t := (focus - vsin * FTy^);
|
||||||
FPx^ := FPx^ + vf * ftx^ / t;
|
FPx^ := FPx^ + vf * FTx^ / t;
|
||||||
FPy^ := FPy^ + vfcos * fty^ / t;
|
FPy^ := FPy^ + vfcos * FTy^ / t;
|
||||||
{$else}
|
{$else}
|
||||||
asm
|
asm
|
||||||
mov ecx, [eax + FTy]
|
mov ecx, [eax + FTy]
|
||||||
@ -78,6 +91,27 @@ asm
|
|||||||
{$ifend}
|
{$ifend}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TVariationPerspective.CalcLinear;
|
||||||
|
{$if false}
|
||||||
|
begin
|
||||||
|
FPx^ := FPx^ + vvar * FTx^;
|
||||||
|
FPy^ := FPy^ + vvar * FTy^;
|
||||||
|
{$else}
|
||||||
|
asm
|
||||||
|
fld qword ptr [eax + vvar]
|
||||||
|
mov edx, [eax + FTx]
|
||||||
|
fld qword ptr [edx]
|
||||||
|
fmul st, st(1)
|
||||||
|
fadd qword ptr [edx + 16]
|
||||||
|
fstp qword ptr [edx + 16]
|
||||||
|
fld qword ptr [edx + 8]
|
||||||
|
fmulp
|
||||||
|
fadd qword ptr [edx + 24]
|
||||||
|
fstp qword ptr [edx + 24]
|
||||||
|
fwait
|
||||||
|
{$ifend}
|
||||||
|
end;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
constructor TVariationPerspective.Create;
|
constructor TVariationPerspective.Create;
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user