mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
shift-C reveals collision solids
This commit is contained in:
parent
808d469b01
commit
4551aa04a7
@ -22,6 +22,7 @@
|
|||||||
#include "eventQueue.h"
|
#include "eventQueue.h"
|
||||||
#include "dataGraphTraverser.h"
|
#include "dataGraphTraverser.h"
|
||||||
#include "interactiveGraphicsPipe.h"
|
#include "interactiveGraphicsPipe.h"
|
||||||
|
#include "collisionNode.h"
|
||||||
#include "config_framework.h"
|
#include "config_framework.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -356,6 +357,58 @@ set_lighting(bool enable) {
|
|||||||
_lighting_enabled = 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
|
// Function: PandaFramework::set_highlight
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -488,6 +541,7 @@ do_enable_default_keys() {
|
|||||||
_event_handler.add_hook("b", event_b, this);
|
_event_handler.add_hook("b", event_b, this);
|
||||||
_event_handler.add_hook("l", event_l, this);
|
_event_handler.add_hook("l", event_l, this);
|
||||||
_event_handler.add_hook("c", event_c, 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("shift-l", event_L, this);
|
||||||
_event_handler.add_hook("h", event_h, this);
|
_event_handler.add_hook("h", event_h, this);
|
||||||
_event_handler.add_hook("arrow_up", event_arrow_up, 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
|
// Function: PandaFramework::event_L
|
||||||
// Access: Protected, Static
|
// Access: Protected, Static
|
||||||
|
@ -78,6 +78,9 @@ public:
|
|||||||
INLINE bool get_two_sided() const;
|
INLINE bool get_two_sided() const;
|
||||||
INLINE bool get_lighting() 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 set_highlight(const NodePath &node);
|
||||||
void clear_highlight();
|
void clear_highlight();
|
||||||
INLINE bool has_highlight() const;
|
INLINE bool has_highlight() const;
|
||||||
@ -102,6 +105,7 @@ protected:
|
|||||||
static void event_b(CPT_Event, void *data);
|
static void event_b(CPT_Event, void *data);
|
||||||
static void event_l(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_C(CPT_Event, void *data);
|
||||||
static void event_L(CPT_Event, void *data);
|
static void event_L(CPT_Event, void *data);
|
||||||
static void event_h(CPT_Event, void *data);
|
static void event_h(CPT_Event, void *data);
|
||||||
static void event_arrow_up(CPT_Event, void *data);
|
static void event_arrow_up(CPT_Event, void *data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user