From ce4f84702968bcd5bcf69a9d06fdb299517d910c Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 29 Oct 2003 23:41:49 +0000 Subject: [PATCH] define output operators --- panda/src/collide/collisionEntry.I | 6 +++ panda/src/collide/collisionEntry.cxx | 58 ++++++++++++++++++++++++++++ panda/src/collide/collisionEntry.h | 5 +++ 3 files changed, 69 insertions(+) diff --git a/panda/src/collide/collisionEntry.I b/panda/src/collide/collisionEntry.I index ec2c7c15b2..151f4c54fd 100644 --- a/panda/src/collide/collisionEntry.I +++ b/panda/src/collide/collisionEntry.I @@ -498,3 +498,9 @@ test_intersection(CollisionHandler *record, record->add_entry(result); } } + +INLINE ostream & +operator << (ostream &out, const CollisionEntry &entry) { + entry.output(out); + return out; +} diff --git a/panda/src/collide/collisionEntry.cxx b/panda/src/collide/collisionEntry.cxx index e68798d65c..5086f3f416 100644 --- a/panda/src/collide/collisionEntry.cxx +++ b/panda/src/collide/collisionEntry.cxx @@ -18,6 +18,7 @@ #include "collisionEntry.h" #include "dcast.h" +#include "indent.h" TypeHandle CollisionEntry::_type_handle; @@ -155,6 +156,63 @@ get_all(const NodePath &space, LPoint3f &surface_point, return true; } +//////////////////////////////////////////////////////////////////// +// Function: CollisionEntry::output +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +void CollisionEntry:: +output(ostream &out) const { + out << _from_node_path; + if (!_into_node_path.is_empty()) { + out << " into " << _into_node_path; + } + if (has_surface_point()) { + out << " at " << get_surface_point(NodePath()); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: CollisionEntry::write +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +void CollisionEntry:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << "CollisionEntry:\n"; + if (!_from_node_path.is_empty()) { + indent(out, indent_level + 2) + << "from " << _from_node_path << "\n"; + } + if (!_into_node_path.is_empty()) { + indent(out, indent_level + 2) + << "into " << _into_node_path; + const ClipPlaneAttrib *cpa = get_into_clip_planes(); + if (cpa != (ClipPlaneAttrib *)NULL) { + out << " (clipped)"; + } + out << "\n"; + } + if (has_surface_point()) { + indent(out, indent_level + 2) + << "at " << get_surface_point(NodePath()) << "\n"; + } + if (has_surface_normal()) { + indent(out, indent_level + 2) + << "normal " << get_surface_normal(NodePath()) << "\n"; + } + if (has_interior_point()) { + indent(out, indent_level + 2) + << "interior " << get_interior_point(NodePath()) + << " (depth " + << (get_interior_point(NodePath()) - get_surface_point(NodePath())).length() + << ")\n"; + } + indent(out, indent_level + 2) + << "respect_prev_transform = " << get_respect_prev_transform() << "\n"; +} + //////////////////////////////////////////////////////////////////// // Function: CollisionEntry::check_clip_planes // Access: Private diff --git a/panda/src/collide/collisionEntry.h b/panda/src/collide/collisionEntry.h index 2e19f7ec6b..57110f3d2f 100644 --- a/panda/src/collide/collisionEntry.h +++ b/panda/src/collide/collisionEntry.h @@ -103,6 +103,9 @@ PUBLISHED: INLINE bool has_from_depth() const; INLINE float get_from_depth() const; + void output(ostream &out) const; + void write(ostream &out, int indent_level = 0) const; + public: INLINE CPT(TransformState) get_wrt_space() const; INLINE CPT(TransformState) get_inv_wrt_space() const; @@ -162,6 +165,8 @@ private: friend class CollisionTraverser; }; +INLINE ostream &operator << (ostream &out, const CollisionEntry &entry); + #include "collisionEntry.I" #endif