40 CollisionNode(
const std::string &name) :
42 _from_collide_mask(get_default_collide_mask()),
48 set_overall_hidden(
true);
51 set_into_collide_mask(get_default_collide_mask());
60 _from_collide_mask(copy._from_collide_mask),
97 nassertv(!mat.is_nan());
99 if (mat.almost_equal(LMatrix4::ident_mat())) {
104 for (si = _solids.begin(); si != _solids.end(); ++si) {
108 mark_internal_bounds_stale();
123 if (flatten_collision_nodes) {
130 if (get_name() == cother->get_name() &&
134 const COWPT(
CollisionSolid) *solids_end = solids_begin + cother->_solids.size();
135 _solids.insert(_solids.end(), solids_begin, solids_end);
136 mark_internal_bounds_stale();
183 Solids::const_iterator si;
184 for (si = _solids.begin(); si != _solids.end(); ++si) {
186 PT(
PandaNode) node = solid->get_viz(trav, data,
false);
187 if (node !=
nullptr) {
191 next_data._state = RenderState::make_empty();
196 if (respect_prev_transform) {
199 NodePath node_path = data.get_node_path();
200 CPT(
TransformState) transform = node_path.get_net_transform()->invert_compose(node_path.get_net_prev_transform());
206 for (si = _solids.begin(); si != _solids.end(); ++si) {
208 PT(
PandaNode) node = solid->get_viz(trav, data,
false);
209 if (node !=
nullptr) {
212 next_data._net_transform =
213 next_data._net_transform->compose(transform);
214 next_data._state = get_last_pos_state();
256 PandaNode::output(out);
257 out <<
" (" << _solids.size() <<
" solids)";
267 _from_collide_mask = mask;
277 int &internal_vertices,
279 Thread *current_thread)
const {
284 Solids::const_iterator gi;
285 for (gi = _solids.begin(); gi != _solids.end(); ++gi) {
289 if (!volume->is_empty()) {
290 child_volumes_ref.push_back(volume);
291 child_volumes.push_back(volume);
292 if (!volume->is_exact_type(BoundingBox::get_class_type())) {
301 if (btype == BoundingVolume::BT_default) {
305 if (btype == BoundingVolume::BT_box ||
306 (btype != BoundingVolume::BT_sphere && all_box)) {
315 if (child_volumes.size() > 0) {
317 const BoundingVolume **child_end = child_begin + child_volumes.size();
321 internal_bounds = gbv;
322 internal_vertices = 0;
331 get_last_pos_state() {
335 if (state ==
nullptr) {
336 state = RenderState::make
337 (ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)),
338 TransparencyAttrib::make(TransparencyAttrib::M_alpha));
361 int num_solids = _solids.size();
362 if (num_solids >= 0xffff) {
368 for(
int i = 0; i < num_solids; i++) {
383 int num_solids = _solids.size();
384 for (
int i = 0; i < num_solids; i++) {
403 node->fillin(scan, manager);
414 PandaNode::fillin(scan, manager);
417 if (num_solids == 0xffff) {
421 _solids.reserve(num_solids);
422 for(
int i = 0; i < num_solids; i++) {
425 _solids.push_back(
nullptr);
virtual bool preserve_name() const
Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operatio...
A basic node of the scene graph or data graph.
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
bool is_exact_type(TypeHandle handle) const
Returns true if the current object is the indicated type exactly.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual CollideMask get_legal_collide_mask() const
Returns the subset of CollideMask bits that may be set for this particular type of PandaNode.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static BitMask< WType, nbits > all_on()
Returns a BitMask whose bits are all on.
The abstract base class for all things that can collide with other things in the world,...
This defines a bounding sphere, consisting of a center and a radius.
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
Base class for objects that can be written to and read from Bam files.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
void set_word(WordType value)
Sets the entire BitMask to the value indicated by the given word.
void traverse(const NodePath &root)
Begins the traversal from the indicated node.
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the datagram.
This is our own Panda specialization on the default STL vector.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
WordType get_word() const
Returns the entire BitMask as a single word.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
set_from_collide_mask
Sets the "from" CollideMask.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_from_collide_mask
Returns the current "from" CollideMask.
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().
get_into_collide_mask
Returns the current "into" CollideMask.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_bounds_type
Returns the bounding volume type set with set_bounds_type().
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
uint32_t get_uint32()
Extracts an unsigned 32-bit integer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
virtual void output(std::ostream &out) const
Writes a brief description of the node to the indicated output stream.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A thread; that is, a lightweight process.
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
A node in the scene graph that can hold any number of CollisionSolids.
static void register_with_read_factory()
Tells the BamReader how to create objects of type CollisionNode.
CPT(RenderState) CollisionNode
Returns a RenderState for rendering the ghosted collision solid that represents the previous frame's ...
virtual bool is_collision_node() const
A simple downcast check.
A class to retrieve the individual data elements previously stored in a Datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual PandaNode * combine_with(PandaNode *other)
Collapses this node with the other node, if possible, and returns a pointer to the combined node,...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this node by the indicated matrix, if it means anything to do so.
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.