Jelajahi Sumber

Added script-friendly versions of Camera::project.

sgrenier 12 tahun lalu
induk
melakukan
75c6a428df
2 mengubah file dengan 36 tambahan dan 0 penghapusan
  1. 16 0
      gameplay/src/Camera.cpp
  2. 20 0
      gameplay/src/Camera.h

+ 16 - 0
gameplay/src/Camera.cpp

@@ -354,6 +354,22 @@ void Camera::project(const Rectangle& viewport, const Vector3& position, float*
     }
 }
 
+void Camera::project(const Rectangle& viewport, const Vector3& position, Vector2* out) const
+{
+    GP_ASSERT(out);
+    float x, y;
+    project(viewport, position, &x, &y);
+    out->set(x, y);
+}
+
+void Camera::project(const Rectangle& viewport, const Vector3& position, Vector3* out) const
+{
+    GP_ASSERT(out);
+    float x, y, depth;
+    project(viewport, position, &x, &y, &depth);
+    out->set(x, y, depth);
+}
+
 void Camera::unproject(const Rectangle& viewport, float x, float y, float depth, Vector3* dst) const
 {
     GP_ASSERT(dst);

+ 20 - 0
gameplay/src/Camera.h

@@ -240,9 +240,29 @@ public:
      * @param x The returned viewport x coordinate.
      * @param y The returned viewport y coordinate.
      * @param depth The returned pixel depth (can be NULL).
+     *
+     * @script{ignore}
      */
     void project(const Rectangle& viewport, const Vector3& position, float* x, float* y, float* depth = NULL) const;
 
+    /**
+     * Projects the specified world position into the viewport coordinates.
+     *
+     * @param viewport The viewport rectangle to use.
+     * @param position The world space position.
+     * @param out Populated with the resulting screen-space position.
+     */
+    void project(const Rectangle& viewport, const Vector3& position, Vector2* out) const;
+
+    /**
+     * Projects the specified world position into the viewport coordinates.
+     *
+     * @param viewport The viewport rectangle to use.
+     * @param position The world space position.
+     * @param out Populated with the resulting screen-space position, with the pixel depth in the Z coordinate.
+     */
+    void project(const Rectangle& viewport, const Vector3& position, Vector3* out) const;
+
     /**
      * Converts a viewport-space coordinate to a world-space position for the given depth value.
      *