*** empty log message ***

This commit is contained in:
David Rose 2001-02-07 00:22:45 +00:00
parent 8943a2bce4
commit e344a6dc1e
3 changed files with 26 additions and 38 deletions

View File

@ -55,9 +55,13 @@ class ShowBase:
self.win = makeGraphicsWindow(self.pipe, self.win = makeGraphicsWindow(self.pipe,
self.renderTop.node(), self.renderTop.node(),
self.camera.node(), self.camera.node(),
self.dataRoot.node(),
self.initialState) self.initialState)
# This is a placeholder for a CollisionTraverser. If someone
# stores a CollisionTraverser pointer here, we'll traverse it
# in the igloop task.
self.cTrav = 0
# This is a list of cams associated with the display region's cameras # This is a list of cams associated with the display region's cameras
self.camList = [] self.camList = []
for camera in self.cameraList: for camera in self.cameraList:
@ -187,6 +191,9 @@ class ShowBase:
self.tkroot = None self.tkroot = None
def igloop(self, state): def igloop(self, state):
directTraverseDataGraph(self.dataRoot.node())
if self.cTrav:
self.cTrav.traverse(self.render)
self.win.update() self.win.update()
return Task.cont return Task.cont

View File

@ -34,9 +34,9 @@
#include <frustum.h> #include <frustum.h>
#include <orthoProjection.h> #include <orthoProjection.h>
#include <appTraverser.h> #include <appTraverser.h>
#include <collisionTraverser.h>
#include <get_config_path.h> #include <get_config_path.h>
#include <allAttributesWrapper.h> #include <allAttributesWrapper.h>
#include <dataGraphTraversal.h>
ConfigureDef(config_showbase); ConfigureDef(config_showbase);
ConfigureFn(config_showbase) { ConfigureFn(config_showbase) {
@ -48,8 +48,6 @@ get_particle_path() {
return get_config_path("particle-path", particle_path); return get_config_path("particle-path", particle_path);
} }
static CollisionTraverser *collision_traverser = NULL;
// Default channel config // Default channel config
std::string chan_config = "single"; std::string chan_config = "single";
std::string window_title = "Panda3D"; std::string window_title = "Panda3D";
@ -67,35 +65,24 @@ void render_frame(GraphicsPipe *pipe,
class WindowCallback : public GraphicsWindow::Callback { class WindowCallback : public GraphicsWindow::Callback {
public: public:
WindowCallback(GraphicsPipe *pipe, Node *render, Node *data_root, WindowCallback(GraphicsPipe *pipe, Node *render,
NodeAttributes *initial_state) : NodeAttributes *initial_state) :
_pipe(pipe), _pipe(pipe),
_render(render), _render(render),
_data_root(data_root),
_initial_state(initial_state), _initial_state(initial_state),
_app_traverser(RenderRelation::get_class_type()) { } _app_traverser(RenderRelation::get_class_type()) { }
virtual ~WindowCallback() { } virtual ~WindowCallback() { }
virtual void draw(bool) { virtual void draw(bool) {
_app_traverser.traverse(_render); _app_traverser.traverse(_render);
// Initiate the data traversal, to send device data down its
// respective pipelines.
traverse_data_graph(_data_root);
if (collision_traverser != (CollisionTraverser *)NULL) {
collision_traverser->traverse(_render);
}
render_frame(_pipe, *_initial_state); render_frame(_pipe, *_initial_state);
} }
virtual void idle(void) { virtual void idle(void) {
// We used to do the collision traversal here, but it's better to
// do it immediately before the draw, so we don't get one frame of
// lag in collision updates.
} }
PT(GraphicsPipe) _pipe; PT(GraphicsPipe) _pipe;
PT(Node) _render; PT(Node) _render;
PT(Node) _data_root;
NodeAttributes *_initial_state; NodeAttributes *_initial_state;
AppTraverser _app_traverser; AppTraverser _app_traverser;
}; };
@ -127,7 +114,6 @@ PT(GraphicsPipe) make_graphics_pipe() {
PT(GraphicsWindow) make_graphics_window(GraphicsPipe *pipe, PT(GraphicsWindow) make_graphics_window(GraphicsPipe *pipe,
NamedNode *render, NamedNode *render,
NamedNode *camera, NamedNode *camera,
NamedNode *data_root,
NodeAttributes &initial_state) { NodeAttributes &initial_state) {
PT(GraphicsWindow) main_win; PT(GraphicsWindow) main_win;
ChanCfgOverrides override; ChanCfgOverrides override;
@ -152,7 +138,7 @@ PT(GraphicsWindow) make_graphics_window(GraphicsPipe *pipe,
assert(main_win != (GraphicsWindow*)0L); assert(main_win != (GraphicsWindow*)0L);
WindowCallback *wcb = WindowCallback *wcb =
new WindowCallback(pipe, render, data_root, &initial_state); new WindowCallback(pipe, render, &initial_state);
// Set draw and idle callbacks // Set draw and idle callbacks
main_win->set_draw_callback(wcb); main_win->set_draw_callback(wcb);
@ -217,20 +203,18 @@ add_render_layer(GraphicsWindow *win, Node *render_top, Camera *camera) {
dr->set_camera(camera); dr->set_camera(camera);
} }
// Enable the collision traversal using a particular traverser.
void set_collision_traverser(CollisionTraverser *traverser) { // This function is just a simple wrapper around traverse_data_graph()
collision_traverser = traverser; // in Panda. It's just here for the very short term, until everyone
} // can build a fresh Panda with traverse_data_graph() properly
CollisionTraverser *get_collision_traverser() { // exposed.
return collision_traverser; void
} direct_traverse_data_graph(Node *node) {
// Stop the collision traversal. traverse_data_graph(node);
void clear_collision_traverser() {
collision_traverser = NULL;
} }
void
void toggle_wireframe(NodeAttributes &initial_state) { toggle_wireframe(NodeAttributes &initial_state) {
static bool wireframe_mode = false; static bool wireframe_mode = false;
wireframe_mode = !wireframe_mode; wireframe_mode = !wireframe_mode;
@ -255,7 +239,8 @@ void toggle_wireframe(NodeAttributes &initial_state) {
} }
void toggle_backface(NodeAttributes &initial_state) { void
toggle_backface(NodeAttributes &initial_state) {
static bool backface_mode = false; static bool backface_mode = false;
// Toggle the state variable // Toggle the state variable

View File

@ -33,17 +33,13 @@ EXPCL_DIRECT PT(GraphicsWindow)
make_graphics_window(GraphicsPipe *pipe, make_graphics_window(GraphicsPipe *pipe,
NamedNode *render, NamedNode *render,
NamedNode *camera, NamedNode *camera,
NamedNode *data_root, NodeAttributes &initial_state);
NodeAttributes &initial_state
);
EXPCL_DIRECT NodePath setup_panda_2d(GraphicsWindow *win, const string &name); EXPCL_DIRECT NodePath setup_panda_2d(GraphicsWindow *win, const string &name);
EXPCL_DIRECT void add_render_layer(GraphicsWindow *win, Node *render_top, EXPCL_DIRECT void add_render_layer(GraphicsWindow *win, Node *render_top,
Camera *camera); Camera *camera);
EXPCL_DIRECT void set_collision_traverser(CollisionTraverser *traverser); EXPCL_DIRECT void direct_traverse_data_graph(Node *node);
EXPCL_DIRECT CollisionTraverser *get_collision_traverser();
EXPCL_DIRECT void clear_collision_traverser();
EXPCL_DIRECT void toggle_wireframe(NodeAttributes &initial_state); EXPCL_DIRECT void toggle_wireframe(NodeAttributes &initial_state);
EXPCL_DIRECT void toggle_texture(NodeAttributes &initial_state); EXPCL_DIRECT void toggle_texture(NodeAttributes &initial_state);