Debian Codegraph @

src/scene/load/collada/x3dloadinternalcollada_childrenlist.inc

raw
1 {
2 Copyright 2017-2018 Michalis Kamburelis.
3
4 This file is part of "Castle Game Engine".
5
6 "Castle Game Engine" is free software; see the file COPYING.txt,
7 included in this distribution, for details about the copyright.
8
9 "Castle Game Engine" is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 ----------------------------------------------------------------------------
14 }
15
16 {$ifdef read_interface}
17
18 type
19 TX3DChildrenList = class({$ifdef FPC}specialize{$endif} TObjectList<TAbstractChildNode>)
20 { Find node by name, @nil if not found. }
21 function FindName(const Name: string): TAbstractChildNode;
22 end;
23
24 procedure X3DChildrenList_FreeUnusedAndNil(var List: TX3DChildrenList); forward;
25
26 {$endif read_interface}
27
28 {$ifdef read_implementation}
29
30 function TX3DChildrenList.FindName(const Name: string): TAbstractChildNode;
31 var
32 I: Integer;
33 begin
34 if Name = '' then
35 Exit(nil);
36
37 for I := 0 to Count - 1 do
38 begin
39 Result := Items[I];
40 if Result.X3DName = Name then
41 Exit;
42 end;
43 Result := nil;
44 end;
45
46 procedure X3DChildrenList_FreeUnusedAndNil(var List: TX3DChildrenList);
47 var
48 I: Integer;
49 begin
50 if List <> nil then
51 begin
52 for I := 0 to List.Count - 1 do
53 if List.Items[I].VRML1ParentsCount + List.Items[I].ParentFieldsCount = 0 then
54 List.Items[I].Free;
55 FreeAndNil(List);
56 end;
57 end;
58
59 {$endif read_implementation}