Skip to content

Commit adfa89b

Browse files
committed
pgraph find
1 parent fc26653 commit adfa89b

17 files changed

+1364
-24
lines changed

direct/src/showbase/qpShowBase.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,6 @@ def setupMouse(self, win):
314314
per application.
315315
"""
316316

317-
print 'setup mouse'
318-
319317
# We create both a MouseAndKeyboard object and a MouseWatcher object
320318
# for the window. The MouseAndKeyboard generates mouse events and
321319
# mouse button/keyboard events; the MouseWatcher passes them through
@@ -341,7 +339,12 @@ def setupMouse(self, win):
341339
self.drive = self.dataUnused.attachNewNode(DriveInterface('drive'))
342340
self.mouse2cam = self.dataUnused.attachNewNode(Transform2SG('mouse2cam'))
343341
self.mouse2cam.node().setNode(self.camera.node())
344-
self.useDrive()
342+
343+
# The default is trackball mode, which is more convenient for
344+
# ad-hoc development in Python using ShowBase. Applications
345+
# can expclitly call base.useDrive() if they prefer a drive
346+
# interface.
347+
self.useTrackball()
345348

346349
# A ButtonThrower to generate events from the mouse and
347350
# keyboard buttons as they are pressed.
@@ -386,8 +389,7 @@ def getCameras(self, chanConfig):
386389
# one.
387390
for i in range(chanConfig.getNumGroups()):
388391
camera = self.camera.attachNewNode(chanConfig.getGroupNode(i))
389-
#cam = camera.find('**/+Camera')
390-
cam = camera.getChild(0)
392+
cam = camera.find('**/+Camera')
391393
lens = cam.node().getLens()
392394

393395
# Enforce our expected aspect ratio, overriding whatever

panda/src/dgraph/qpdataNode.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ reconnect() {
244244
int num_parents = get_num_parents();
245245
_data_connections.clear();
246246
// Look for each input among one of the parents.
247+
int num_datanode_parents = 0;
247248

248249
Wires::const_iterator wi;
249250
for (wi = _input_wires.begin(); wi != _input_wires.end(); ++wi) {
@@ -255,6 +256,7 @@ reconnect() {
255256
PandaNode *parent_node = get_parent(i);
256257
if (parent_node->is_of_type(qpDataNode::get_class_type())) {
257258
qpDataNode *data_node = DCAST(qpDataNode, parent_node);
259+
num_datanode_parents++;
258260
Wires::const_iterator pi;
259261
pi = data_node->_output_wires.find(name);
260262
if (pi != data_node->_output_wires.end()) {
@@ -282,7 +284,8 @@ reconnect() {
282284
}
283285
}
284286

285-
if (_data_connections.empty() && get_num_inputs() != 0 && num_parents != 0) {
287+
if (_data_connections.empty() && get_num_inputs() != 0 &&
288+
num_datanode_parents != 0) {
286289
dgraph_cat.warning()
287290
<< "No data connected to " << *this << "\n";
288291
}

panda/src/pgraph/Sources.pp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
depthTestAttrib.h depthTestAttrib.I \
2828
depthWriteAttrib.h depthWriteAttrib.I \
2929
drawCullHandler.h drawCullHandler.I \
30+
qpfindApproxLevel.I qpfindApproxLevel.h \
31+
qpfindApproxLevelEntry.I qpfindApproxLevelEntry.h \
32+
qpfindApproxPath.I qpfindApproxPath.h \
3033
qpgeomNode.h qpgeomNode.I \
3134
qplensNode.h qplensNode.I \
3235
qplodNode.h qplodNode.I \
@@ -67,6 +70,9 @@
6770
depthTestAttrib.cxx \
6871
depthWriteAttrib.cxx \
6972
drawCullHandler.cxx \
73+
qpfindApproxLevel.cxx \
74+
qpfindApproxLevelEntry.cxx \
75+
qpfindApproxPath.cxx \
7076
qpgeomNode.cxx \
7177
qplensNode.cxx \
7278
qplodNode.cxx \
@@ -129,6 +135,11 @@
129135
transformState.h transformState.I \
130136
transparencyAttrib.h transparencyAttrib.I
131137

138+
// No need to install these.
139+
// qpfindApproxLevel.I qpfindApproxLevel.h \
140+
// qpfindApproxLevelEntry.I qpfindApproxLevelEntry.h \
141+
// qpfindApproxPath.I qpfindApproxPath.h \
142+
132143
#define IGATESCAN all
133144

134145
#end lib_target

panda/src/pgraph/pandaNode.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ fix_path_lengths(const CData *cdata) {
13801380
////////////////////////////////////////////////////////////////////
13811381
void PandaNode::
13821382
r_list_descendants(ostream &out, int indent_level) const {
1383-
write(out, indent_level);
1383+
indent(out, indent_level) << *this << "\n";
13841384

13851385
CDReader cdata(_cycler);
13861386
Down::const_iterator di;

panda/src/pgraph/pgraph_composite2.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#include "depthTestAttrib.cxx"
33
#include "depthWriteAttrib.cxx"
44
#include "drawCullHandler.cxx"
5+
#include "qpfindApproxPath.cxx"
6+
#include "qpfindApproxLevel.cxx"
7+
#include "qpfindApproxLevelEntry.cxx"
58
#include "qpgeomNode.cxx"
69
#include "qplensNode.cxx"
710
#include "qplodNode.cxx"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Filename: qpfindApproxLevel.I
2+
// Created by: drose (13Mar02)
3+
//
4+
////////////////////////////////////////////////////////////////////
5+
//
6+
// PANDA 3D SOFTWARE
7+
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
8+
//
9+
// All use of this software is subject to the terms of the Panda 3d
10+
// Software license. You should have received a copy of this license
11+
// along with this source code; you will also find a current copy of
12+
// the license at http://www.panda3d.org/license.txt .
13+
//
14+
// To contact the maintainers of this program write to
15+
// panda3d@yahoogroups.com .
16+
//
17+
////////////////////////////////////////////////////////////////////
18+
19+
20+
////////////////////////////////////////////////////////////////////
21+
// Function: qpFindApproxLevel::add_entry
22+
// Access: Public
23+
// Description: Adds a new entry to the level.
24+
////////////////////////////////////////////////////////////////////
25+
INLINE void qpFindApproxLevel::
26+
add_entry(const qpFindApproxLevelEntry &entry) {
27+
_v.push_back(entry);
28+
}
29+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Filename: qpfindApproxLevel.cxx
2+
// Created by: drose (13Mar02)
3+
//
4+
////////////////////////////////////////////////////////////////////
5+
//
6+
// PANDA 3D SOFTWARE
7+
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
8+
//
9+
// All use of this software is subject to the terms of the Panda 3d
10+
// Software license. You should have received a copy of this license
11+
// along with this source code; you will also find a current copy of
12+
// the license at http://www.panda3d.org/license.txt .
13+
//
14+
// To contact the maintainers of this program write to
15+
// panda3d@yahoogroups.com .
16+
//
17+
////////////////////////////////////////////////////////////////////
18+
19+
#include "qpfindApproxLevel.h"
20+
21+
////////////////////////////////////////////////////////////////////
22+
// Function: qpFindApproxLevel::write
23+
// Access: Public
24+
// Description: Shows the entire contents of the level, one entry per
25+
// line. For debugging only.
26+
////////////////////////////////////////////////////////////////////
27+
void qpFindApproxLevel::
28+
write(ostream &out) const {
29+
Vec::const_iterator vi;
30+
for (vi = _v.begin(); vi != _v.end(); ++vi) {
31+
(*vi).output(out);
32+
out << "\n";
33+
}
34+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Filename: qpfindApproxLevel.h
2+
// Created by: drose (13Mar02)
3+
//
4+
////////////////////////////////////////////////////////////////////
5+
//
6+
// PANDA 3D SOFTWARE
7+
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
8+
//
9+
// All use of this software is subject to the terms of the Panda 3d
10+
// Software license. You should have received a copy of this license
11+
// along with this source code; you will also find a current copy of
12+
// the license at http://www.panda3d.org/license.txt .
13+
//
14+
// To contact the maintainers of this program write to
15+
// panda3d@yahoogroups.com .
16+
//
17+
////////////////////////////////////////////////////////////////////
18+
19+
#ifndef qpFINDAPPROXLEVEL_H
20+
#define qpFINDAPPROXLEVEL_H
21+
22+
#include "pandabase.h"
23+
24+
#include "qpfindApproxLevelEntry.h"
25+
#include "pvector.h"
26+
27+
////////////////////////////////////////////////////////////////////
28+
// Class : qpFindApproxLevel
29+
// Description : This class is local to this package only; it doesn't
30+
// get exported. It maintains the list of nodes
31+
// find_approx() considers for each level of the scene
32+
// graph it visits, in its breadth-first search.
33+
////////////////////////////////////////////////////////////////////
34+
class qpFindApproxLevel {
35+
public:
36+
INLINE void add_entry(const qpFindApproxLevelEntry &entry);
37+
38+
void write(ostream &out) const;
39+
40+
typedef pvector<qpFindApproxLevelEntry> Vec;
41+
Vec _v;
42+
};
43+
44+
#include "qpfindApproxLevel.I"
45+
46+
#endif
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Filename: qpfindApproxLevelEntry.I
2+
// Created by: drose (13Mar02)
3+
//
4+
////////////////////////////////////////////////////////////////////
5+
//
6+
// PANDA 3D SOFTWARE
7+
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
8+
//
9+
// All use of this software is subject to the terms of the Panda 3d
10+
// Software license. You should have received a copy of this license
11+
// along with this source code; you will also find a current copy of
12+
// the license at http://www.panda3d.org/license.txt .
13+
//
14+
// To contact the maintainers of this program write to
15+
// panda3d@yahoogroups.com .
16+
//
17+
////////////////////////////////////////////////////////////////////
18+
19+
20+
////////////////////////////////////////////////////////////////////
21+
// Function: qpFindApproxLevelEntry::Constructor
22+
// Access: Public
23+
// Description:
24+
////////////////////////////////////////////////////////////////////
25+
INLINE qpFindApproxLevelEntry::
26+
qpFindApproxLevelEntry(const qpNodePath &node_path, qpFindApproxPath &approx_path) :
27+
_node_path(node_path),
28+
_approx_path(approx_path)
29+
{
30+
_i = 0;
31+
}
32+
33+
////////////////////////////////////////////////////////////////////
34+
// Function: qpFindApproxLevelEntry::Copy Constructor
35+
// Access: Public
36+
// Description:
37+
////////////////////////////////////////////////////////////////////
38+
INLINE qpFindApproxLevelEntry::
39+
qpFindApproxLevelEntry(const qpFindApproxLevelEntry &copy) :
40+
_node_path(copy._node_path),
41+
_i(copy._i),
42+
_approx_path(copy._approx_path)
43+
{
44+
}
45+
46+
////////////////////////////////////////////////////////////////////
47+
// Function: qpFindApproxLevelEntry::Copy Assignment Operator
48+
// Access: Public
49+
// Description:
50+
////////////////////////////////////////////////////////////////////
51+
INLINE void qpFindApproxLevelEntry::
52+
operator = (const qpFindApproxLevelEntry &copy) {
53+
_node_path = copy._node_path;
54+
_i = copy._i;
55+
nassertv(&_approx_path == &copy._approx_path);
56+
}
57+
58+
59+
////////////////////////////////////////////////////////////////////
60+
// Function: qpFindApproxLevelEntry::next_is_stashed
61+
// Access: Public
62+
// Description: Returns true if the next node matched by this entry
63+
// must be a stashed node, false otherwise.
64+
////////////////////////////////////////////////////////////////////
65+
INLINE bool qpFindApproxLevelEntry::
66+
next_is_stashed() const {
67+
return _approx_path.matches_stashed(_i);
68+
}
69+
70+
////////////////////////////////////////////////////////////////////
71+
// Function: qpFindApproxLevelEntry::is_solution
72+
// Access: Public
73+
// Description: Returns true if this entry represents a solution to
74+
// the search; i.e. all the components of the path have
75+
// been successfully matched.
76+
////////////////////////////////////////////////////////////////////
77+
INLINE bool qpFindApproxLevelEntry::
78+
is_solution() const {
79+
return (_i >= _approx_path.get_num_components());
80+
}

0 commit comments

Comments
 (0)