Panda3D
findApproxLevelEntry.I
1 // Filename: findApproxLevelEntry.I
2 // Created by: drose (13Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: FindApproxLevelEntry::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE FindApproxLevelEntry::
22 FindApproxLevelEntry(const WorkingNodePath &node_path, FindApproxPath &approx_path) :
23  _node_path(node_path),
24  _approx_path(approx_path)
25 {
26  _i = 0;
27  _next = NULL;
28  nassertv(_node_path.is_valid());
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: FindApproxLevelEntry::Constructor
33 // Access: Public
34 // Description: This constructor is used to construct the next entry
35 // based on a child node of the previous entry's node.
36 ////////////////////////////////////////////////////////////////////
37 INLINE FindApproxLevelEntry::
38 FindApproxLevelEntry(const FindApproxLevelEntry &parent,
39  PandaNode *child_node, int i,
40  FindApproxLevelEntry *next) :
41  _node_path(parent._node_path, child_node),
42  _i(i),
43  _approx_path(parent._approx_path),
44  _next(next)
45 {
46  nassertv(validate_ptr(this) && validate_ptr(&parent));
47  nassertv(_node_path.is_valid());
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: FindApproxLevelEntry::Copy Constructor
52 // Access: Public
53 // Description:
54 ////////////////////////////////////////////////////////////////////
55 INLINE FindApproxLevelEntry::
56 FindApproxLevelEntry(const FindApproxLevelEntry &copy) :
57  _node_path(copy._node_path),
58  _i(copy._i),
59  _approx_path(copy._approx_path)
60 {
61  _next = NULL;
62  nassertv(_node_path.is_valid());
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: FindApproxLevelEntry::Copy Assignment Operator
67 // Access: Public
68 // Description:
69 ////////////////////////////////////////////////////////////////////
70 INLINE void FindApproxLevelEntry::
71 operator = (const FindApproxLevelEntry &copy) {
72  _node_path = copy._node_path;
73  _i = copy._i;
74  nassertv(&_approx_path == &copy._approx_path);
75  nassertv(_node_path.is_valid());
76 }
77 
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: FindApproxLevelEntry::next_is_stashed
81 // Access: Public
82 // Description: Returns true if the next node matched by this entry
83 // must be a stashed node, false otherwise.
84 ////////////////////////////////////////////////////////////////////
85 INLINE bool FindApproxLevelEntry::
86 next_is_stashed(int increment) const {
87  return _approx_path.matches_stashed(_i + increment);
88 }
89 
90 ////////////////////////////////////////////////////////////////////
91 // Function: FindApproxLevelEntry::is_solution
92 // Access: Public
93 // Description: Returns true if this entry represents a solution to
94 // the search; i.e. all the components of the path have
95 // been successfully matched.
96 ////////////////////////////////////////////////////////////////////
97 INLINE bool FindApproxLevelEntry::
98 is_solution(int increment) const {
99  return (_i + increment >= _approx_path.get_num_components());
100 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
bool is_solution(int increment) const
Returns true if this entry represents a solution to the search; i.e.
This class is local to this package only; it doesn't get exported.
bool matches_stashed(int index) const
Returns true if the nth component of the path matches a stashed node only, false otherwise.
This class is local to this package only; it doesn't get exported.
bool next_is_stashed(int increment) const
Returns true if the next node matched by this entry must be a stashed node, false otherwise...
This is a class designed to support low-overhead traversals of the complete scene graph...
int get_num_components() const
Returns the number of components in the path.
bool is_valid() const
Returns true if the WorkingNodePath object appears to be a valid NodePath reference, false otherwise.