From 8cdea5949cf119dd2b482f7b4230def3ead6adaf Mon Sep 17 00:00:00 2001 From: zueuk Date: Wed, 6 Sep 2006 12:46:52 +0000 Subject: [PATCH] added one "optimized" calcfunction --- 2.10/Source/varPerspective.pas | 42 ++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/2.10/Source/varPerspective.pas b/2.10/Source/varPerspective.pas index d928aeb..307aac7 100644 --- a/2.10/Source/varPerspective.pas +++ b/2.10/Source/varPerspective.pas @@ -9,12 +9,16 @@ const var_a_name = 'perspective_angle'; var_f_name = 'perspective_dist'; +{$define _ASM_} + type TVariationPerspective = class(TBaseVariation) private angle, focus: double; vsin, vf, vfcos: double; + procedure CalcLinear; + public constructor Create; @@ -28,8 +32,9 @@ type function GetVariable(const Name: string; var value: double): boolean; override; function ResetVariable(const Name: string): boolean; override; - procedure CalcFunction; override; procedure Prepare; override; + procedure CalcFunction; override; + procedure GetCalcFunction(var f: TCalcFunction); override; end; implementation @@ -47,14 +52,22 @@ begin vfcos := vf * cos(angle*pi/2); end; +/////////////////////////////////////////////////////////////////////////////// +procedure TVariationPerspective.GetCalcFunction(var f: TCalcFunction); +begin + if IsZero(angle) then f := CalcLinear + else f := CalcFunction; +end; + +/////////////////////////////////////////////////////////////////////////////// procedure TVariationPerspective.CalcFunction; {$if false} var t: double; begin - t := (focus - fty^*vsin); - FPx^ := FPx^ + vf * ftx^ / t; - FPy^ := FPy^ + vfcos * fty^ / t; + t := (focus - vsin * FTy^); + FPx^ := FPx^ + vf * FTx^ / t; + FPy^ := FPy^ + vfcos * FTy^ / t; {$else} asm mov ecx, [eax + FTy] @@ -78,6 +91,27 @@ asm {$ifend} 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; begin