22TypeHandle CollisionHandlerPusher::_type_handle;
40CollisionHandlerPusher::
41CollisionHandlerPusher() {
42 _horizontal = pushers_horizontal;
48CollisionHandlerPusher::
49~CollisionHandlerPusher() {
81bool CollisionHandlerPusher::
85 FromEntries::const_iterator fi;
86 for (fi = _from_entries.begin(); fi != _from_entries.end(); ++fi) {
87 const NodePath &from_node_path = (*fi).first;
88 const Entries &entries = (*fi).second;
90 Colliders::iterator ci;
91 ci = _colliders.
find(from_node_path);
92 if (ci == _colliders.end()) {
96 <<
"CollisionHandlerPusher doesn't know about "
97 << from_node_path <<
", disabling.\n";
100 ColliderDef &def = (*ci).second;
109 typedef epvector<ShoveData> Shoves;
112 Entries::const_iterator ei;
113 for (ei = entries.begin(); ei != entries.end(); ++ei) {
115 nassertr(entry !=
nullptr,
false);
118 LPoint3 surface_point;
120 LPoint3 interior_point;
122 if (!entry->
get_all(def._target, surface_point, normal, interior_point)) {
124 if (collide_cat.is_debug()) {
126 <<
"Cannot shove on " << from_node_path <<
" for collision into "
132 if (!surface_point.almost_equal(interior_point)) {
143 sd._length = (surface_point - interior_point).length();
148 if (collide_cat.is_debug()) {
150 <<
"Shove on " << from_node_path <<
" from "
152 <<
" times " << sd._length <<
"\n";
156 shoves.push_back(sd);
161 if (!shoves.empty()) {
168 for (si = shoves.begin(); si != shoves.end(); ++si) {
169 ShoveData &sd = (*si);
171 for (sj = shoves.begin(); sj != si; ++sj) {
172 ShoveData &sd2 = (*sj);
174 PN_stdfloat d = sd._vector.dot(sd2._vector);
175 if (collide_cat.is_debug()) {
177 <<
"Considering dot product " << d <<
"\n";
183 if (sd2._length < sd._length) {
197 s1->
is_of_type(CollisionPolygon::get_class_type()) &&
198 s2->
is_of_type(CollisionPolygon::get_class_type()) &&
209 if (collide_cat.is_debug()) {
211 <<
"Discarding shove from convex corner.\n";
220 if (sd2._length < sd._length) {
233 LVector3 net_shove(0.0f, 0.0f, 0.0f);
234 LVector3 force_normal(0.0f, 0.0f, 0.0f);
235 for (si = shoves.begin(); si != shoves.end(); ++si) {
236 const ShoveData &sd = (*si);
238 net_shove += sd._vector * sd._length;
239 force_normal += sd._vector;
244 if (collide_cat.is_debug()) {
246 <<
"Net shove on " << from_node_path <<
" is: "
247 << net_shove <<
"\n";
253 LVecBase3 pos = trans->get_pos();
254 pos += net_shove * trans->get_mat();
255 def._target.set_transform(trans->set_pos(pos));
256 def.updated_transform();
260 apply_net_shove(def, net_shove, force_normal);
261 apply_linear_force(def, force_normal);
274void CollisionHandlerPusher::
275apply_net_shove(ColliderDef &def,
const LVector3 &net_shove,
276 const LVector3 &force_normal) {
283void CollisionHandlerPusher::
284apply_linear_force(ColliderDef &def,
const LVector3 &force_normal) {
Defines a single collision event.
get_into
Returns the CollisionSolid pointer for the particular solid was collided into.
get_from_node_path
Returns the NodePath that represents the CollisionNode that contains the CollisionSolid that triggere...
get_into_node_path
Returns the NodePath that represents the specific CollisionNode or GeomNode instance that was collide...
bool get_all(const NodePath &space, LPoint3 &surface_point, LVector3 &surface_normal, LPoint3 &interior_point) const
Simultaneously transforms the surface point, surface normal, and interior point of the collision into...
void read_datagram(DatagramIterator &source)
Restores the object state from the given datagram, previously obtained using __getstate__.
void write_datagram(Datagram &destination) const
Serializes this object, to implement pickle support.
void write_datagram(Datagram &destination) const
Serializes this object, to implement pickle support.
void read_datagram(DatagramIterator &source)
Restores the object state from the given datagram, previously obtained using __getstate__.
virtual LPoint3 get_collision_origin() const
Returns the point in space deemed to be the "origin" of the solid for collision purposes.
The abstract base class for all things that can collide with other things in the world,...
A class to retrieve the individual data elements previously stored in a Datagram.
bool get_bool()
Extracts a boolean value.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_bool(bool value)
Adds a boolean value to the datagram.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
NodePath find(const std::string &path) const
Searches for a node below the referenced node that matches the indicated string.
TypeHandle is the identifier used to differentiate C++ class types.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
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.