Pārlūkot izejas kodu

added get_relative_vector

Dave Schuyler 22 gadi atpakaļ
vecāks
revīzija
0575f75afd
2 mainītis faili ar 14 papildinājumiem un 0 dzēšanām
  1. 13 0
      panda/src/pgraph/nodePath.cxx
  2. 1 0
      panda/src/pgraph/nodePath.h

+ 13 - 0
panda/src/pgraph/nodePath.cxx

@@ -1316,6 +1316,19 @@ get_relative_point(const NodePath &other, const LVecBase3f &point) {
   return rel_point;
   return rel_point;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: NodePath::get_relative_vector
+//       Access: Published
+//  Description: Given that the indicated vector is in the coordinate
+//               system of the other node, returns the same vector in
+//               this node's coordinate system.
+////////////////////////////////////////////////////////////////////
+LVector3f NodePath::
+get_relative_vector(const NodePath &other, const LVecBase3f &vec) {
+  LVector3f rel_vector = LVector3f(vec) * other.get_mat(*this);
+  return rel_vector;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: NodePath::look_at
 //     Function: NodePath::look_at
 //       Access: Published
 //       Access: Published

+ 1 - 0
panda/src/pgraph/nodePath.h

@@ -378,6 +378,7 @@ PUBLISHED:
   void set_mat(const NodePath &other, const LMatrix4f &mat);
   void set_mat(const NodePath &other, const LMatrix4f &mat);
 
 
   LPoint3f get_relative_point(const NodePath &other, const LVecBase3f &point);
   LPoint3f get_relative_point(const NodePath &other, const LVecBase3f &point);
+  LVector3f get_relative_vector(const NodePath &other, const LVecBase3f &vec);
 
 
   INLINE void look_at(const NodePath &other,
   INLINE void look_at(const NodePath &other,
                       float x, float y, float z);
                       float x, float y, float z);