Panda3D

Loading...
Searching...
No Matches
collisionNode.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file collisionNode.h
10 * @author drose
11 * @date 2002-03-16
12 */
13
14#ifndef COLLISIONNODE_H
15#define COLLISIONNODE_H
16
17#include "pandabase.h"
18
19#include "collisionSolid.h"
20
21#include "collideMask.h"
22#include "pandaNode.h"
23
24/**
25 * A node in the scene graph that can hold any number of CollisionSolids.
26 * This may either represent a bit of static geometry in the scene that things
27 * will collide with, or an animated object twirling around in the world and
28 * running into things.
29 */
30 class EXPCL_PANDA_COLLIDE CollisionNode : public PandaNode {
31PUBLISHED:
32 explicit CollisionNode(const std::string &name);
33
34 protected:
35 CollisionNode(const CollisionNode &copy);
36
37 public:
38 virtual ~CollisionNode();
39 virtual PandaNode *make_copy() const;
40 virtual bool preserve_name() const;
41 virtual void xform(const LMatrix4 &mat);
42 virtual PandaNode *combine_with(PandaNode *other);
43 virtual CollideMask get_legal_collide_mask() const;
44
45 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
46 virtual bool is_renderable() const;
47 virtual bool is_collision_node() const;
48
49 virtual void output(std::ostream &out) const;
50
51PUBLISHED:
52 INLINE void set_collide_mask(CollideMask mask);
53 void set_from_collide_mask(CollideMask mask);
54 INLINE void set_into_collide_mask(CollideMask mask);
55 INLINE CollideMask get_from_collide_mask() const;
56 INLINE CollideMask get_into_collide_mask() const;
57
58 MAKE_PROPERTY(from_collide_mask, get_from_collide_mask,
59 set_from_collide_mask);
60 MAKE_PROPERTY(into_collide_mask, get_into_collide_mask,
61 set_into_collide_mask);
62
63 INLINE void clear_solids();
64 INLINE size_t get_num_solids() const;
65 INLINE CPT(CollisionSolid) get_solid(size_t n) const;
66 MAKE_SEQ(get_solids, get_num_solids, get_solid);
67 INLINE PT(CollisionSolid) modify_solid(size_t n);
68 INLINE void set_solid(size_t n, CollisionSolid *solid);
69 INLINE void insert_solid(size_t n, const CollisionSolid *solid);
70 INLINE void remove_solid(size_t n);
71 INLINE size_t add_solid(const CollisionSolid *solid);
72 MAKE_SEQ_PROPERTY(solids, get_num_solids, get_solid, set_solid, remove_solid, insert_solid);
73
74 INLINE int get_collider_sort() const;
75 INLINE void set_collider_sort(int sort);
76 MAKE_PROPERTY(collider_sort, get_collider_sort, set_collider_sort);
77
78 INLINE static CollideMask get_default_collide_mask();
79 MAKE_PROPERTY(default_collide_mask, get_default_collide_mask);
80
81 protected:
82 virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
83 int &internal_vertices,
84 int pipeline_stage,
85 Thread *current_thread) const;
86
87 private:
88 CPT(RenderState) get_last_pos_state();
89
90 // This data is not cycled, for now. We assume the collision traversal will
91 // take place in App only. Perhaps we will revisit this later.
92 CollideMask _from_collide_mask;
93 int _collider_sort;
94
95 typedef pvector< COWPT(CollisionSolid) > Solids;
96 Solids _solids;
97
98 friend class CollisionTraverser;
99
100 public:
101 static void register_with_read_factory();
102 virtual void write_datagram(BamWriter *manager, Datagram &dg);
103 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
104
105 protected:
106 static TypedWritable *make_from_bam(const FactoryParams &params);
107 void fillin(DatagramIterator &scan, BamReader *manager);
108
109 public:
110 static TypeHandle get_class_type() {
111 return _type_handle;
112 }
113 static void init_type() {
114 PandaNode::init_type();
115 register_type(_type_handle, "CollisionNode",
116 PandaNode::get_class_type());
117 }
118 virtual TypeHandle get_type() const {
119 return get_class_type();
120 }
121 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
122
123 private:
124 static TypeHandle _type_handle;
125};
126
127#include "collisionNode.I"
128
129#endif
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
BoundingVolume
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
Definition boundingVolume.h:41
CollisionNode::get_into_collide_mask
get_into_collide_mask
Returns the current "into" CollideMask.
Definition collisionNode.h:61
CollisionNode::set_collider_sort
set_collider_sort
Sets a particular collider_sort value on this node.
Definition collisionNode.h:76
CollisionNode::insert_solid
insert_solid
Inserts the indicated solid to the node at the indicated position.
Definition collisionNode.h:72
CollisionNode::set_solid
set_solid
Replaces the solid with the indicated index.
Definition collisionNode.h:72
CollisionNode::set_collide_mask
void set_collide_mask(CollideMask mask)
Simultaneously sets both the "from" and "into" CollideMask values to the same thing.
Definition collisionNode.I:19
CollisionNode::set_into_collide_mask
set_into_collide_mask
Sets the "into" CollideMask.
Definition collisionNode.h:61
CollisionNode::get_from_collide_mask
get_from_collide_mask
Returns the current "from" CollideMask.
Definition collisionNode.h:59
CollisionNode::get_collider_sort
get_collider_sort
Returns the collider_sort value that has been set for this particular node.
Definition collisionNode.h:76
CollisionNode::get_default_collide_mask
get_default_collide_mask
Returns the default into_collide_mask assigned to new CollisionNodes.
Definition collisionNode.h:79
CollisionNode::clear_solids
void clear_solids()
Removes all solids from the node.
Definition collisionNode.I:60
CollisionNode::remove_solid
remove_solid
Removes the solid with the indicated index.
Definition collisionNode.h:72
CollisionNode::output
virtual void output(std::ostream &out) const
Writes a brief description of the node to the indicated output stream.
Definition collisionNode.cxx:256
CollisionNode::set_from_collide_mask
set_from_collide_mask
Sets the "from" CollideMask.
Definition collisionNode.h:59
CollisionNode::add_solid
size_t add_solid(const CollisionSolid *solid)
Adds the indicated solid to the node.
Definition collisionNode.I:130
CollisionSolid
The abstract base class for all things that can collide with other things in the world,...
Definition collisionSolid.h:45
CullTraverser
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Definition cullTraverser.h:45
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
PandaNode::preserve_name
virtual bool preserve_name() const
Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operatio...
Definition pandaNode.cxx:256
PandaNode::cull_callback
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
Definition pandaNode.cxx:386
PandaNode::combine_with
virtual PandaNode * combine_with(PandaNode *other)
Collapses this PandaNode with the other PandaNode, if possible, and returns a pointer to the combined...
Definition pandaNode.cxx:319
PandaNode::is_renderable
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
Definition pandaNode.cxx:462
PandaNode::get_legal_collide_mask
get_legal_collide_mask
Returns the subset of CollideMask bits that may be set for this particular type of PandaNode.
Definition pandaNode.h:265
PandaNode::get_into_collide_mask
get_into_collide_mask
Returns the "into" collide mask for this node.
Definition pandaNode.h:264
PandaNode::register_with_read_factory
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition pandaNode.cxx:3593
PandaNode::xform
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
Definition pandaNode.cxx:304
PandaNode::is_collision_node
virtual bool is_collision_node() const
A simple downcast check.
Definition pandaNode.cxx:2086
PandaNode::make_copy
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition pandaNode.cxx:481
PandaNode::set_into_collide_mask
set_into_collide_mask
Sets the "into" CollideMask.
Definition pandaNode.h:264
PandaNode::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition pandaNode.cxx:3602
RenderState
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
Thread
A thread; that is, a lightweight process.
Definition thread.h:46
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedWritable::complete_pointers
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Definition typedWritable.cxx:81
plist
This is our own Panda specialization on the default STL list.
Definition plist.h:35
collideMask.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
collisionNode.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
collisionSolid.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandaNode.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22