mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
support subclassing CollisionNode properly
This commit is contained in:
parent
2d4170963b
commit
c67fb27206
@ -113,7 +113,7 @@ end_group() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void CollisionHandlerPhysical::
|
||||
add_collider(const NodePath &collider, const NodePath &target) {
|
||||
nassertv(!collider.is_empty() && collider.node()->is_of_type(CollisionNode::get_class_type()));
|
||||
nassertv(!collider.is_empty() && collider.node()->is_collision_node());
|
||||
nassertv(validate_target(target));
|
||||
_colliders[collider].set_target(target);
|
||||
}
|
||||
@ -134,7 +134,7 @@ add_collider(const NodePath &collider, const NodePath &target) {
|
||||
void CollisionHandlerPhysical::
|
||||
add_collider(const NodePath &collider, const NodePath &target,
|
||||
DriveInterface *drive_interface) {
|
||||
nassertv(!collider.is_empty() && collider.node()->is_of_type(CollisionNode::get_class_type()));
|
||||
nassertv(!collider.is_empty() && collider.node()->is_collision_node());
|
||||
nassertv(validate_target(target));
|
||||
_colliders[collider].set_target(target, drive_interface);
|
||||
}
|
||||
|
@ -269,6 +269,21 @@ is_renderable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CollisionNode::is_collision_node
|
||||
// Access: Published, Virtual
|
||||
// Description: A simple downcast check. Returns true if this kind
|
||||
// of node happens to inherit from CollisionNode, false
|
||||
// otherwise.
|
||||
//
|
||||
// This is provided as a a faster alternative to calling
|
||||
// is_of_type(CollisionNode::get_class_type()).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool CollisionNode::
|
||||
is_collision_node() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CollisionNode::output
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
|
||||
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
|
||||
virtual bool is_renderable() const;
|
||||
virtual bool is_collision_node() const;
|
||||
|
||||
virtual void output(ostream &out) const;
|
||||
|
||||
|
@ -109,7 +109,7 @@ CollisionTraverser::
|
||||
void CollisionTraverser::
|
||||
add_collider(const NodePath &collider, CollisionHandler *handler) {
|
||||
nassertv(_ordered_colliders.size() == _colliders.size());
|
||||
nassertv(!collider.is_empty() && collider.node()->is_of_type(CollisionNode::get_class_type()));
|
||||
nassertv(!collider.is_empty() && collider.node()->is_collision_node());
|
||||
nassertv(handler != (CollisionHandler *)NULL);
|
||||
|
||||
Colliders::iterator ci = _colliders.find(collider);
|
||||
@ -500,8 +500,7 @@ write(ostream &out, int indent_level) const {
|
||||
out << " ignored\n";
|
||||
}
|
||||
|
||||
if (!cnode_path.is_empty() && cnode_path.node()->is_of_type(
|
||||
CollisionNode::get_class_type())) {
|
||||
if (!cnode_path.is_empty() && cnode_path.node()->is_collision_node()) {
|
||||
CollisionNode *cnode = DCAST(CollisionNode, cnode_path.node());
|
||||
|
||||
int num_solids = cnode->get_num_solids();
|
||||
@ -608,7 +607,7 @@ r_traverse_single(CollisionLevelStateSingle &level_state, size_t pass) {
|
||||
}
|
||||
|
||||
PandaNode *node = level_state.node();
|
||||
if (node->is_exact_type(CollisionNode::get_class_type())) {
|
||||
if (node->is_collision_node()) {
|
||||
CollisionNode *cnode;
|
||||
DCAST_INTO_V(cnode, node);
|
||||
CPT(BoundingVolume) node_bv = cnode->get_bounds();
|
||||
@ -827,7 +826,7 @@ r_traverse_double(CollisionLevelStateDouble &level_state, size_t pass) {
|
||||
}
|
||||
|
||||
PandaNode *node = level_state.node();
|
||||
if (node->is_exact_type(CollisionNode::get_class_type())) {
|
||||
if (node->is_collision_node()) {
|
||||
CollisionNode *cnode;
|
||||
DCAST_INTO_V(cnode, node);
|
||||
CPT(BoundingVolume) node_bv = cnode->get_bounds();
|
||||
@ -1046,7 +1045,7 @@ r_traverse_quad(CollisionLevelStateQuad &level_state, size_t pass) {
|
||||
}
|
||||
|
||||
PandaNode *node = level_state.node();
|
||||
if (node->is_exact_type(CollisionNode::get_class_type())) {
|
||||
if (node->is_collision_node()) {
|
||||
CollisionNode *cnode;
|
||||
DCAST_INTO_V(cnode, node);
|
||||
CPT(BoundingVolume) node_bv = cnode->get_bounds();
|
||||
|
@ -210,7 +210,7 @@
|
||||
#if $[ne $[PLATFORM], FreeBSD]
|
||||
#define UNIX_SYS_LIBS dl
|
||||
#endif
|
||||
#define WIN_SYS_LIBS shell32.lib
|
||||
#define WIN_SYS_LIBS shell32.lib $[WIN_SYS_LIBS]
|
||||
#define OSX_SYS_FRAMEWORKS Foundation $[if $[not $[BUILD_IPHONE]],AppKit]
|
||||
|
||||
#end lib_target
|
||||
|
@ -498,7 +498,16 @@ PRC_DESC("If this is nonzero, it represents an artificial delay, "
|
||||
"delay is per-model, and all aync loads will be queued "
|
||||
"up behind the delay--it is as if the time it takes to read a "
|
||||
"file is increased by this amount per read."));
|
||||
|
||||
|
||||
ConfigVariableInt lens_geom_segments
|
||||
("lens-geom-segments", 50,
|
||||
PRC_DESC("This is the number of times to subdivide the visualization "
|
||||
"wireframe created when Lens::make_geometry() (or "
|
||||
"LensNode::show_frustum()) is called, for representing accurate "
|
||||
"curves. Note that this is only "
|
||||
"used for a nonlinear lens such as a cylindrical or fisheye "
|
||||
"lens; for a normal perspective or orthographic lens, the "
|
||||
"wireframe is not subdivided."));
|
||||
|
||||
ConfigureFn(config_gobj) {
|
||||
AnimateVerticesRequest::init_type();
|
||||
|
@ -97,6 +97,7 @@ extern EXPCL_PANDA_GOBJ ConfigVariableInt graphics_memory_limit;
|
||||
extern EXPCL_PANDA_GOBJ ConfigVariableDouble adaptive_lru_weight;
|
||||
extern EXPCL_PANDA_GOBJ ConfigVariableInt adaptive_lru_max_updates_per_frame;
|
||||
extern EXPCL_PANDA_GOBJ ConfigVariableDouble async_load_delay;
|
||||
extern EXPCL_PANDA_GOBJ ConfigVariableInt lens_geom_segments;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1723,7 +1723,7 @@ int Lens::
|
||||
do_define_geom_data(CData *cdata) {
|
||||
int num_segments = 1;
|
||||
if (!is_linear()) {
|
||||
num_segments = 10;
|
||||
num_segments = lens_geom_segments;
|
||||
}
|
||||
|
||||
if (cdata->_geom_data == (GeomVertexData *)NULL) {
|
||||
|
@ -2661,6 +2661,21 @@ is_lod_node() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PandaNode::is_collision_node
|
||||
// Access: Published, Virtual
|
||||
// Description: A simple downcast check. Returns true if this kind
|
||||
// of node happens to inherit from CollisionNode, false
|
||||
// otherwise.
|
||||
//
|
||||
// This is provided as a a faster alternative to calling
|
||||
// is_of_type(CollisionNode::get_class_type()).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PandaNode::
|
||||
is_collision_node() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PandaNode::as_light
|
||||
// Access: Published, Virtual
|
||||
|
@ -292,6 +292,7 @@ PUBLISHED:
|
||||
|
||||
virtual bool is_geom_node() const;
|
||||
virtual bool is_lod_node() const;
|
||||
virtual bool is_collision_node() const;
|
||||
virtual Light *as_light();
|
||||
virtual bool is_ambient_light() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user