Browse Source

mathutil: Add proper `__repr__` for LPlane class

Fixes #1248
rdb 3 years ago
parent
commit
287b0d5a74
2 changed files with 15 additions and 0 deletions
  1. 14 0
      panda/src/mathutil/plane_src.cxx
  2. 1 0
      panda/src/mathutil/plane_src.h

+ 14 - 0
panda/src/mathutil/plane_src.cxx

@@ -158,3 +158,17 @@ void FLOATNAME(LPlane)::
 write(std::ostream &out, int indent_level) const {
   indent(out, indent_level) << *this << "\n";
 }
+
+/**
+ * Returns a string representation of this LPlane.
+ */
+std::string FLOATNAME(LPlane)::
+__repr__() const {
+  std::ostringstream out;
+  out << "LPlane" << FLOATTOKEN << "("
+      << MAYBE_ZERO(_v(0)) << ", "
+      << MAYBE_ZERO(_v(1)) << ", "
+      << MAYBE_ZERO(_v(2)) << ", "
+      << MAYBE_ZERO(_v(3)) << ")";
+  return out.str();
+}

+ 1 - 0
panda/src/mathutil/plane_src.h

@@ -61,6 +61,7 @@ PUBLISHED:
 
   void output(std::ostream &out) const;
   void write(std::ostream &out, int indent_level = 0) const;
+  std::string __repr__() const;
 };
 
 INLINE_MATHUTIL std::ostream &