shift-C reveals collision solids

This commit is contained in:
David Rose 2002-07-02 21:05:10 +00:00
parent 808d469b01
commit 4551aa04a7
2 changed files with 78 additions and 0 deletions

View File

@ -22,6 +22,7 @@
#include "eventQueue.h"
#include "dataGraphTraverser.h"
#include "interactiveGraphicsPipe.h"
#include "collisionNode.h"
#include "config_framework.h"
////////////////////////////////////////////////////////////////////
@ -356,6 +357,58 @@ set_lighting(bool enable) {
_lighting_enabled = enable;
}
////////////////////////////////////////////////////////////////////
// Function: PandaFramework::hide_collision_solids
// Access: Public
// Description: Hides any collision solids which are visible in the
// indicated scene graph. Returns the number of
// collision solids hidden.
////////////////////////////////////////////////////////////////////
int PandaFramework::
hide_collision_solids(NodePath node) {
int num_changed = 0;
if (node.node()->is_of_type(CollisionNode::get_class_type())) {
if (!node.is_hidden()) {
node.hide();
num_changed++;
}
}
int num_children = node.get_num_children();
for (int i = 0; i < num_children; i++) {
num_changed += hide_collision_solids(node.get_child(i));
}
return num_changed;
}
////////////////////////////////////////////////////////////////////
// Function: PandaFramework::show_collision_solids
// Access: Public
// Description: Shows any collision solids which are directly hidden
// in the indicated scene graph. Returns the number of
// collision solids shown.
////////////////////////////////////////////////////////////////////
int PandaFramework::
show_collision_solids(NodePath node) {
int num_changed = 0;
if (node.node()->is_of_type(CollisionNode::get_class_type())) {
if (node.get_hidden_ancestor() == node) {
node.show();
num_changed++;
}
}
int num_children = node.get_num_children();
for (int i = 0; i < num_children; i++) {
num_changed += show_collision_solids(node.get_child(i));
}
return num_changed;
}
////////////////////////////////////////////////////////////////////
// Function: PandaFramework::set_highlight
// Access: Public
@ -488,6 +541,7 @@ do_enable_default_keys() {
_event_handler.add_hook("b", event_b, this);
_event_handler.add_hook("l", event_l, this);
_event_handler.add_hook("c", event_c, this);
_event_handler.add_hook("shift-c", event_C, this);
_event_handler.add_hook("shift-l", event_L, this);
_event_handler.add_hook("h", event_h, this);
_event_handler.add_hook("arrow_up", event_arrow_up, this);
@ -589,6 +643,26 @@ event_c(CPT_Event, void *data) {
}
}
////////////////////////////////////////////////////////////////////
// Function: PandaFramework::event_C
// Access: Protected, Static
// Description: Default handler for shift-C key: toggle the showing
// of collision solids.
////////////////////////////////////////////////////////////////////
void PandaFramework::
event_C(CPT_Event, void *data) {
PandaFramework *self = (PandaFramework *)data;
NodePath node = self->get_highlight();
if (node.is_empty()) {
node = self->get_models();
}
if (self->hide_collision_solids(node) == 0) {
self->show_collision_solids(node);
}
}
////////////////////////////////////////////////////////////////////
// Function: PandaFramework::event_L
// Access: Protected, Static

View File

@ -78,6 +78,9 @@ public:
INLINE bool get_two_sided() const;
INLINE bool get_lighting() const;
static int hide_collision_solids(NodePath node);
static int show_collision_solids(NodePath node);
void set_highlight(const NodePath &node);
void clear_highlight();
INLINE bool has_highlight() const;
@ -102,6 +105,7 @@ protected:
static void event_b(CPT_Event, void *data);
static void event_l(CPT_Event, void *data);
static void event_c(CPT_Event, void *data);
static void event_C(CPT_Event, void *data);
static void event_L(CPT_Event, void *data);
static void event_h(CPT_Event, void *data);
static void event_arrow_up(CPT_Event, void *data);