40CollisionNode(
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),
61 _collider_sort(copy._collider_sort),
80 return new CollisionNode(*
this);
97xform(
const LMatrix4 &mat) {
98 nassertv(!mat.is_nan());
100 if (mat.almost_equal(LMatrix4::ident_mat())) {
105 for (si = _solids.begin(); si != _solids.end(); ++si) {
124 if (flatten_collision_nodes) {
130 CollisionNode *cother = DCAST(CollisionNode, other);
131 if (get_name() == cother->get_name() &&
135 const COWPT(
CollisionSolid) *solids_end = solids_begin + cother->_solids.size();
136 _solids.insert(_solids.end(), solids_begin, solids_end);
184 Solids::const_iterator si;
185 for (si = _solids.begin(); si != _solids.end(); ++si) {
187 PT(PandaNode) node = solid->get_viz(trav, data,
false);
188 if (node !=
nullptr) {
189 CullTraverserData next_data(data, node);
192 next_data._state = RenderState::make_empty();
197 if (respect_prev_transform) {
200 NodePath node_path = data.get_node_path();
201 CPT(
TransformState) transform = node_path.get_net_transform()->invert_compose(node_path.get_net_prev_transform());
203 if (!transform->is_identity()) {
207 for (si = _solids.begin(); si != _solids.end(); ++si) {
209 PT(PandaNode) node = solid->get_viz(trav, data,
false);
210 if (node !=
nullptr) {
211 CullTraverserData next_data(data, node);
213 next_data._net_transform =
214 next_data._net_transform->compose(transform);
215 next_data._state = get_last_pos_state();
256output(std::ostream &out)
const {
257 PandaNode::output(out);
258 out <<
" (" << _solids.size() <<
" solids)";
268 _from_collide_mask = mask;
278 int &internal_vertices,
280 Thread *current_thread)
const {
281 pvector<CPT(BoundingVolume) > child_volumes_ref;
282 pvector<const BoundingVolume *> child_volumes;
285 Solids::const_iterator gi;
286 for (gi = _solids.begin(); gi != _solids.end(); ++gi) {
287 CPT(CollisionSolid) solid = (*gi).get_read_pointer();
288 CPT(BoundingVolume) volume = solid->get_bounds();
290 if (!volume->is_empty()) {
291 child_volumes_ref.push_back(volume);
292 child_volumes.push_back(volume);
293 if (!volume->is_exact_type(BoundingBox::get_class_type())) {
299 PT(GeometricBoundingVolume) gbv =
new BoundingBox;
302 if (btype == BoundingVolume::BT_default) {
306 if (btype == BoundingVolume::BT_box ||
307 (btype != BoundingVolume::BT_sphere && all_box)) {
310 gbv =
new BoundingBox;
313 gbv =
new BoundingSphere;
316 if (child_volumes.size() > 0) {
317 const BoundingVolume **child_begin = &child_volumes[0];
318 const BoundingVolume **child_end = child_begin + child_volumes.size();
319 ((BoundingVolume *)gbv)->around(child_begin, child_end);
322 internal_bounds = gbv;
323 internal_vertices = 0;
332get_last_pos_state() {
335 static CPT(RenderState) state =
nullptr;
336 if (state ==
nullptr) {
362 int num_solids = _solids.size();
363 if (num_solids >= 0xffff) {
369 for(
int i = 0; i < num_solids; i++) {
384 int num_solids = _solids.size();
385 for (
int i = 0; i < num_solids; i++) {
404 node->fillin(scan, manager);
415 PandaNode::fillin(scan, manager);
418 if (num_solids == 0xffff) {
422 _solids.reserve(num_solids);
423 for(
int i = 0; i < num_solids; i++) {
426 _solids.push_back(
nullptr);
429 _from_collide_mask.set_word(scan.
get_uint32());
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
static BitMask< uint32_t, nbits > all_on()
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A node in the scene graph that can hold any number of CollisionSolids.
get_into_collide_mask
Returns the current "into" CollideMask.
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
virtual bool preserve_name() const
Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operatio...
static void register_with_read_factory()
Tells the BamReader how to create objects of type CollisionNode.
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
get_from_collide_mask
Returns the current "from" CollideMask.
virtual bool is_collision_node() const
A simple downcast check.
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this node by the indicated matrix, if it means anything to do so.
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 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.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
virtual PandaNode * combine_with(PandaNode *other)
Collapses this node with the other node, if possible, and returns a pointer to the combined node,...
virtual void output(std::ostream &out) const
Writes a brief description of the node to the indicated output stream.
set_from_collide_mask
Sets the "from" CollideMask.
The abstract base class for all things that can collide with other things in the world,...
static ConstPointerTo< RenderAttrib > make(const LVecBase4 &scale)
Constructs a new ColorScaleAttrib object that indicates geometry should be scaled by the indicated fa...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
void traverse(const NodePath &root)
Begins the traversal from the indicated node.
A class to retrieve the individual data elements previously stored in a Datagram.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
uint32_t get_uint32()
Extracts an unsigned 32-bit integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the datagram.
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
A basic node of the scene graph or data graph.
void mark_internal_bounds_stale(Thread *current_thread=Thread::get_current_thread())
Should be called by a derived class to mark the internal bounding volume stale, so that compute_inter...
get_bounds_type
Returns the bounding volume type set with set_bounds_type().
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
static ConstPointerTo< RenderState > make(const RenderAttrib *attrib, int override=0)
Returns a RenderState with one attribute set.
A thread; that is, a lightweight process.
static ConstPointerTo< RenderAttrib > make(Mode mode)
Constructs a new TransparencyAttrib object.
TypeHandle is the identifier used to differentiate C++ class types.
bool is_exact_type(TypeHandle handle) const
Returns true if the current object is the indicated type exactly.
Base class for objects that can be written to and read from Bam files.
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().
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.