mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-30 12:52:16 -05:00
MML/Finder: FindDTMsRotated rework.
This commit is contained in:
parent
a621a6e8da
commit
1fc33752e4
@ -2122,6 +2122,9 @@ begin
|
|||||||
FillChar(b[i][0], SizeOf(Integer) * (H+1), 0);
|
FillChar(b[i][0], SizeOf(Integer) * (H+1), 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// Retreive Client Data.
|
||||||
|
PtrData := TClient(Client).IOManager.ReturnData(x1, y1, W + 1, H + 1);
|
||||||
|
|
||||||
// C = DTM.C
|
// C = DTM.C
|
||||||
for i := 0 to Len - 1 do
|
for i := 0 to Len - 1 do
|
||||||
begin
|
begin
|
||||||
@ -2133,9 +2136,6 @@ begin
|
|||||||
col_arr, tol_arr, self.hueMod, self.satMod);
|
col_arr, tol_arr, self.hueMod, self.satMod);
|
||||||
compare := Get_CTSCompare(Self.CTS);
|
compare := Get_CTSCompare(Self.CTS);
|
||||||
|
|
||||||
// Retreive Client Data.
|
|
||||||
PtrData := TClient(Client).IOManager.ReturnData(x1, y1, W + 1, H + 1);
|
|
||||||
|
|
||||||
cd := CalculateRowPtrs(PtrData, h + 1);
|
cd := CalculateRowPtrs(PtrData, h + 1);
|
||||||
//CD starts at 0,0.. We must adjust the MA, since this is still based on the xs,ys,xe,ye box.
|
//CD starts at 0,0.. We must adjust the MA, since this is still based on the xs,ys,xe,ye box.
|
||||||
MA.x1 := MA.x1 - x1;
|
MA.x1 := MA.x1 - x1;
|
||||||
@ -2216,14 +2216,15 @@ var
|
|||||||
begin
|
begin
|
||||||
FindDTMsRotated(dtm, P, x1, y1, x2, y2, sAngle, eAngle, aStep, F,Alternating,1);
|
FindDTMsRotated(dtm, P, x1, y1, x2, y2, sAngle, eAngle, aStep, F,Alternating,1);
|
||||||
if Length(P) = 0 then
|
if Length(P) = 0 then
|
||||||
exit(false);
|
exit(False);
|
||||||
aFound := F[0][0];
|
aFound := F[0][0];
|
||||||
x := P[0].x;
|
x := P[0].x;
|
||||||
y := P[0].y;
|
y := P[0].y;
|
||||||
Exit(True);
|
Exit(True);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure RotPoints_DTM(const P: TPointArray;var RotTPA : TPointArray; const A: Extended);
|
procedure RotPoints_DTM(const P: TPointArray;var RotTPA : TPointArray; const A:
|
||||||
|
Extended); inline;
|
||||||
var
|
var
|
||||||
I, L: Integer;
|
I, L: Integer;
|
||||||
begin
|
begin
|
||||||
@ -2242,13 +2243,6 @@ var
|
|||||||
DPoints : PMDTMPoint;
|
DPoints : PMDTMPoint;
|
||||||
DTPA : TPointArray;
|
DTPA : TPointArray;
|
||||||
RotTPA: TPointArray;
|
RotTPA: TPointArray;
|
||||||
// Colours of DTMs
|
|
||||||
clR,clG,clB : array of byte;
|
|
||||||
|
|
||||||
//Similar colors stuff
|
|
||||||
hh,ss,ll: array of extended;
|
|
||||||
hmod,smod: extended;
|
|
||||||
Ccts : integer;
|
|
||||||
|
|
||||||
// Bitwise
|
// Bitwise
|
||||||
b: Array of Array of Integer;
|
b: Array of Array of Integer;
|
||||||
@ -2283,6 +2277,10 @@ var
|
|||||||
goodPoints: Array of Boolean;
|
goodPoints: Array of Boolean;
|
||||||
s: extended;
|
s: extended;
|
||||||
|
|
||||||
|
col_arr, tol_arr: Array of Integer;
|
||||||
|
ctsinfoarray: TCTSInfoArray;
|
||||||
|
compare: TCTSCompareFunction;
|
||||||
|
|
||||||
label theEnd;
|
label theEnd;
|
||||||
label AnotherLoopEnd;
|
label AnotherLoopEnd;
|
||||||
|
|
||||||
@ -2318,20 +2316,6 @@ begin
|
|||||||
FillChar(ch[i][0], SizeOf(Integer) * (H+1), 0);
|
FillChar(ch[i][0], SizeOf(Integer) * (H+1), 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Convert colors to there components
|
|
||||||
SetLength(clR,Len);
|
|
||||||
SetLength(clG,Len);
|
|
||||||
SetLength(clB,Len);
|
|
||||||
for i := 0 to Len - 1 do
|
|
||||||
ColorToRGB(DPoints[i].c,clR[i],clG[i],clB[i]);
|
|
||||||
//Compiler hints
|
|
||||||
|
|
||||||
SetLength(hh,Len);
|
|
||||||
SetLength(ss,Len);
|
|
||||||
SetLength(ll,Len);
|
|
||||||
for i := 0 to Len - 1 do
|
|
||||||
ColorToHSL(DPoints[i].c,hh[i],ss[i],ll[i]);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
When we search for a rotated DTM, everything is the same, except the coordinates..
|
When we search for a rotated DTM, everything is the same, except the coordinates..
|
||||||
Therefore we create a TPA of the 'original' DTM, containing all the Points.
|
Therefore we create a TPA of the 'original' DTM, containing all the Points.
|
||||||
@ -2341,12 +2325,20 @@ begin
|
|||||||
for i := 0 to len-1 do
|
for i := 0 to len-1 do
|
||||||
DTPA[i] := Point(DPoints[i].x,DPoints[i].y);
|
DTPA[i] := Point(DPoints[i].x,DPoints[i].y);
|
||||||
|
|
||||||
GetToleranceSpeed2Modifiers(hMod, sMod);
|
|
||||||
ccts := CTS;
|
|
||||||
|
|
||||||
// Retreive Client Data.
|
// Retreive Client Data.
|
||||||
PtrData := TClient(Client).IOManager.ReturnData(x1, y1, W + 1, H + 1);
|
PtrData := TClient(Client).IOManager.ReturnData(x1, y1, W + 1, H + 1);
|
||||||
|
|
||||||
|
// C = DTM.C
|
||||||
|
for i := 0 to Len - 1 do
|
||||||
|
begin
|
||||||
|
col_arr[i] := DPoints[i].c;
|
||||||
|
tol_arr[i] := DPoints[i].t;
|
||||||
|
end;
|
||||||
|
|
||||||
|
ctsinfoarray := Create_CTSInfoArray(Self.CTS,
|
||||||
|
col_arr, tol_arr, self.hueMod, self.satMod);
|
||||||
|
compare := Get_CTSCompare(Self.CTS);
|
||||||
|
|
||||||
cd := CalculateRowPtrs(PtrData, h + 1);
|
cd := CalculateRowPtrs(PtrData, h + 1);
|
||||||
SetLength(aFound, 0);
|
SetLength(aFound, 0);
|
||||||
SetLength(Points, 0);
|
SetLength(Points, 0);
|
||||||
@ -2392,7 +2384,7 @@ begin
|
|||||||
// Checking point i now. (Store that we matched it)
|
// Checking point i now. (Store that we matched it)
|
||||||
ch[xxx][yyy]:= ch[xxx][yyy] or (1 shl i);
|
ch[xxx][yyy]:= ch[xxx][yyy] or (1 shl i);
|
||||||
|
|
||||||
if ColorSame(ccts,DPoints[i].t,clR[i],clG[i],clB[i],cd[yyy][xxx].R, cd[yyy][xxx].G, cd[yyy][xxx].B,hh[i],ss[i],ll[i],hmod,smod) then
|
if compare(ctsinfoarray[i], cd[yyy][xxx]) then
|
||||||
b[xxx][yyy] := b[xxx][yyy] or (1 shl i);
|
b[xxx][yyy] := b[xxx][yyy] or (1 shl i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2436,7 +2428,10 @@ begin
|
|||||||
s := s + aStep;
|
s := s + aStep;
|
||||||
end;
|
end;
|
||||||
TheEnd:
|
TheEnd:
|
||||||
|
|
||||||
|
Free_CTSInfoArray(ctsinfoarray);
|
||||||
TClient(Client).IOManager.FreeReturnData;
|
TClient(Client).IOManager.FreeReturnData;
|
||||||
|
|
||||||
Result := (pc > 0);
|
Result := (pc > 0);
|
||||||
{ Don't forget to pre calculate the rotated points at the start.
|
{ Don't forget to pre calculate the rotated points at the start.
|
||||||
Saves a lot of rotatepoint() calls. }
|
Saves a lot of rotatepoint() calls. }
|
||||||
|
Loading…
Reference in New Issue
Block a user