18 TypeHandle CollisionHandlerQueue::_type_handle;
21 class CollisionEntrySorter {
28 entry->
get_from()->get_collision_origin();
29 _dist2 = vec.length_squared();
32 _dist2 = make_inf((PN_stdfloat)0);
35 bool operator < (
const CollisionEntrySorter &other)
const {
36 return _dist2 < other._dist2;
46 CollisionHandlerQueue::
47 CollisionHandlerQueue() {
66 nassertv(entry !=
nullptr);
67 _entries.push_back(entry);
82 sorter.reserve(_entries.size());
84 Entries::const_iterator ei;
85 for (ei = _entries.begin(); ei != _entries.end(); ++ei) {
86 sorter.push_back(CollisionEntrySorter(*ei));
89 sort(sorter.begin(), sorter.end());
90 nassertv(sorter.size() == _entries.size());
96 sorted_entries.reserve(sorter.size());
97 Sorter::const_iterator si;
98 for (si = sorter.begin(); si != sorter.end(); ++si) {
99 sorted_entries.push_back((*si)._entry);
102 _entries.swap(sorted_entries);
116 int CollisionHandlerQueue::
117 get_num_entries()
const {
118 return _entries.size();
126 nassertr(n >= 0 && n < (
int)_entries.size(),
nullptr);
133 void CollisionHandlerQueue::
134 output(std::ostream &out)
const {
135 out <<
"CollisionHandlerQueue, " << _entries.size() <<
" entries";
141 void CollisionHandlerQueue::
142 write(std::ostream &out,
int indent_level)
const {
144 <<
"CollisionHandlerQueue, " << _entries.size() <<
" entries:\n";
146 Entries::const_iterator ei;
147 for (ei = _entries.begin(); ei != _entries.end(); ++ei) {
148 (*ei)->write(out, indent_level + 2);
bool has_surface_point() const
Returns true if the surface point has been specified, false otherwise.
get_from_node_path
Returns the NodePath that represents the CollisionNode that contains the CollisionSolid that triggere...
LPoint3 get_surface_point(const NodePath &space) const
Returns the point, on the surface of the "into" object, at which a collision is detected.
void sort_entries()
Sorts all the detected collisions front-to-back by from_intersection_point() so that those intersecti...
This is our own Panda specialization on the default STL vector.
virtual void add_entry(CollisionEntry *entry)
Called between a begin_group() .
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Defines a single collision event.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_from
Returns the CollisionSolid pointer for the particular solid that triggered this collision.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void clear_entries()
Removes all the entries from the queue.
TypeHandle is the identifier used to differentiate C++ class types.
get_entry
Returns the nth CollisionEntry detected last pass.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void begin_group()
Will be called by the CollisionTraverser before a new traversal is begun.