Debian Codegraph @

src/scene/x3d/x3dnodes_clipplane.inc

raw
1 {%MainUnit x3dnodes.pas}
2 {
3 Copyright 2002-2018 Michalis Kamburelis.
4
5 This file is part of "Castle Game Engine".
6
7 "Castle Game Engine" is free software; see the file COPYING.txt,
8 included in this distribution, for details about the copyright.
9
10 "Castle Game Engine" is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 ----------------------------------------------------------------------------
15 }
16
17 {$ifdef read_interface}
18
19 { Clipping plane, along with a transformation. }
20 TClipPlane = record
21 Node: TClipPlaneNode;
22 Transform: TMatrix4;
23 end;
24 PClipPlane = ^TClipPlane;
25
26 TClipPlaneList = class({$ifdef FPC}specialize{$endif} TStructList<TClipPlane>)
27 public
28 { Find record with given TClipPlaneNode, returns -1 if not found. }
29 function IndexOfNode(Node: TClipPlaneNode): Integer;
30 function Equals(SecondValue: TObject): boolean; {$ifdef TOBJECT_HAS_EQUALS} override; {$endif}
31 end;
32
33 {$endif read_interface}
34
35 {$ifdef read_implementation}
36
37 { TClipPlaneList --------------------------------------------------------- }
38
39 function TClipPlaneList.IndexOfNode(Node: TClipPlaneNode): Integer;
40 begin
41 for Result := 0 to Count - 1 do
42 if L[Result].Node = Node then
43 Exit;
44 Result := -1;
45 end;
46
47 function TClipPlaneList.Equals(SecondValue: TObject): boolean;
48 var
49 I: Integer;
50 begin
51 Result :=
52 (SecondValue <> nil) and
53 (SecondValue is TClipPlaneList) and
54 (TClipPlaneList(SecondValue).Count = Count);
55
56 if Result then
57 for I := 0 to Count - 1 do
58 if (L[I].Node <> TClipPlaneList(SecondValue).L[I].Node) or
59 TMatrix4.PerfectlyEquals(
60 L[I].Transform,
61 TClipPlaneList(SecondValue).L[I].Transform) then
62 Exit(false);
63 end;
64
65 {$endif read_implementation}