optimized renderer
added drag-edit controls in forms: editor, adjust, postprocess
This commit is contained in:
@ -40,9 +40,6 @@ type
|
||||
Buckets: TBucketArray;
|
||||
ColorMap: TColorMapArray;
|
||||
|
||||
FinalXform: ^TXform;
|
||||
UseFinalXform: boolean;
|
||||
|
||||
camX0, camX1, camY0, camY1, // camera bounds
|
||||
camW, camH, // camera sizes
|
||||
bws, bhs, cosa, sina, rcX, rcY: double;
|
||||
@ -59,8 +56,6 @@ type
|
||||
|
||||
procedure AddPointsToBuckets(const points: TPointsArray);
|
||||
procedure AddPointsToBucketsAngle(const points: TPointsArray);
|
||||
procedure AddPointsWithFX(const points: TPointsArray);
|
||||
procedure AddPointsWithAngleFX(const points: TPointsArray);
|
||||
|
||||
procedure SetPixels;
|
||||
public
|
||||
@ -215,14 +210,15 @@ end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
procedure TRenderer64.InitValues;
|
||||
var
|
||||
i, n: integer;
|
||||
begin
|
||||
InitBuffers;
|
||||
CreateCamera;
|
||||
|
||||
CreateColorMap;
|
||||
|
||||
FinalXForm := @fcp.xform[fcp.NumXForms];
|
||||
UseFinalXForm := fcp.finalXformEnabled and fcp.HasFinalXform;
|
||||
|
||||
fcp.Prepare;
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -251,86 +247,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRenderer64.AddPointsWithFX(const points: TPointsArray);
|
||||
const
|
||||
const255: single = 255;
|
||||
var
|
||||
i: integer;
|
||||
px, py: double;
|
||||
Bucket: PBucket;
|
||||
MapColor: PColorMapColor;
|
||||
begin
|
||||
try
|
||||
for i := SUB_BATCH_SIZE - 1 downto 0 do begin
|
||||
// if FStop then Exit;
|
||||
|
||||
FinalXform.NextPoint(points[i]);
|
||||
|
||||
{$if true}
|
||||
px := points[i].x - camX0;
|
||||
if (px < 0) or (px > camW) then continue;
|
||||
py := points[i].y - camY0;
|
||||
if (py < 0) or (py > camH) then continue;
|
||||
|
||||
Bucket := @buckets[Round(bws * px) + Round(bhs * py) * BucketWidth];
|
||||
MapColor := @ColorMap[Round(points[i].c * 255)];
|
||||
|
||||
Inc(Bucket.Red, MapColor.Red);
|
||||
Inc(Bucket.Green, MapColor.Green);
|
||||
Inc(Bucket.Blue, MapColor.Blue);
|
||||
Inc(Bucket.Count);
|
||||
{$else}
|
||||
asm
|
||||
mov eax, [points]
|
||||
lea edx, [eax + edi*8] // assert: "i" in edi
|
||||
// fld qword ptr [edx + edi*8] // assert: "i" in edi
|
||||
fld qword ptr [edx]
|
||||
fsub qword ptr [bx]
|
||||
fldz
|
||||
fcomp st(1), st
|
||||
fnstsw ax
|
||||
sahf
|
||||
jb @skip1
|
||||
fld qword ptr [wx]
|
||||
fcomp
|
||||
fnstsw ax
|
||||
sahf
|
||||
jnbe @skip1
|
||||
|
||||
fld qword ptr [edx + 8]
|
||||
fsub qword ptr [by]
|
||||
fldz
|
||||
fcomp
|
||||
fnstsw ax
|
||||
sahf
|
||||
jb @skip2
|
||||
fld qword ptr [wy]
|
||||
fcomp
|
||||
fnstsw ax
|
||||
sahf
|
||||
jnbe @skip2
|
||||
|
||||
fmul qword ptr [bhs]
|
||||
fimul [BucketWidth]
|
||||
|
||||
fld qword ptr [edx + 16]
|
||||
fmul dword ptr [const255]
|
||||
sub esp, 4
|
||||
fistp dword ptr [esp]
|
||||
pop eax
|
||||
|
||||
@skip2:
|
||||
fstp st
|
||||
@skip1:
|
||||
fstp st
|
||||
@continue:
|
||||
end;
|
||||
{$ifend}
|
||||
end
|
||||
except
|
||||
end
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
procedure TRenderer64.AddPointsToBucketsAngle(const points: TPointsArray);
|
||||
var
|
||||
@ -357,36 +273,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRenderer64.AddPointsWithAngleFX(const points: TPointsArray);
|
||||
var
|
||||
i: integer;
|
||||
px, py: double;
|
||||
Bucket: PBucket;
|
||||
MapColor: PColorMapColor;
|
||||
begin
|
||||
try
|
||||
for i := SUB_BATCH_SIZE - 1 downto 0 do
|
||||
begin
|
||||
// if FStop then Exit;
|
||||
FinalXform.NextPoint(points[i]);
|
||||
|
||||
px := points[i].x * cosa + points[i].y * sina + rcX;
|
||||
if (px < 0) or (px > camW) then continue;
|
||||
py := points[i].y * cosa - points[i].x * sina + rcY;
|
||||
if (py < 0) or (py > camH) then continue;
|
||||
|
||||
Bucket := @buckets[Round(bws * px) + Round(bhs * py) * BucketWidth];
|
||||
MapColor := @ColorMap[Round(points[i].c * 255)];
|
||||
|
||||
Inc(Bucket.Red, MapColor.Red);
|
||||
Inc(Bucket.Green, MapColor.Green);
|
||||
Inc(Bucket.Blue, MapColor.Blue);
|
||||
Inc(Bucket.Count);
|
||||
end;
|
||||
except
|
||||
end
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
procedure TRenderer64.SetPixels;
|
||||
var
|
||||
@ -401,18 +287,10 @@ begin
|
||||
|
||||
// AssignFile(F, 'c:\temp\flame.txt');
|
||||
// Rewrite(F);
|
||||
if FCP.FAngle = 0 then begin
|
||||
if UseFinalXForm then
|
||||
AddPointsProc := AddPointsWithFX
|
||||
else
|
||||
AddPointsProc := AddPointsToBuckets;
|
||||
end
|
||||
else begin
|
||||
if UseFinalXForm then
|
||||
AddPointsProc := AddPointsWithAngleFX
|
||||
else
|
||||
AddPointsProc := AddPointsToBucketsAngle;
|
||||
end;
|
||||
if FCP.FAngle = 0 then
|
||||
AddPointsProc := AddPointsToBuckets
|
||||
else
|
||||
AddPointsProc := AddPointsToBucketsAngle;
|
||||
|
||||
SetLength(Points, SUB_BATCH_SIZE);
|
||||
|
||||
|
Reference in New Issue
Block a user