* @param plane\r
* The plane\r
* @param intersection\r
- * The vector the intersection point is written to\r
- * @return Wheter an intersection is present.\r
+ * The vector the intersection point is written to (optional)\r
+ * @return Whether an intersection is present.\r
*/\r
public static boolean intersectRayPlane(Ray ray, Plane plane,\r
Vector3 intersection) {\r
if (t < 0)\r
return false;\r
\r
- intersection.set(ray.origin).add(ray.direction.tmp().mul(t));\r
+ if (intersection != null)\r
+ intersection.set(ray.origin).add(ray.direction.tmp().mul(t));\r
return true;\r
} else if (plane.testPoint(ray.origin) == Plane.PlaneSide.OnPlane) {\r
- intersection.set(ray.origin);\r
+ if (intersection != null)\r
+ intersection.set(ray.origin);\r
return true;\r
} else\r
return false;\r
* @param t3\r
* The third vertex of the triangle\r
* @param intersection\r
- * The intersection point\r
+ * The intersection point (optional)\r
* @return True in case an intersection is present.\r
*/\r
public static boolean intersectRayTriangle(Ray ray, Vector3 t1, Vector3 t2,\r
float v = (dot00 * dot12 - dot01 * dot02) / denom;\r
\r
if (u >= 0 && v >= 0 && u + v <= 1) {\r
- intersection.set(i);\r
+ if(intersection != null)\r
+ intersection.set(i);\r
return true;\r
} else {\r
return false;\r
* @param radius\r
* The radius of the sphere\r
* @param intersection\r
- * The intersection point\r
- * @return Wheter an interesection is present.\r
+ * The intersection point (optional)\r
+ * @return Whether an intersection is present.\r
*/\r
public static boolean intersectRaySphere(Ray ray, Vector3 center,\r
float radius, Vector3 intersection) {\r
* @param ray\r
* The ray\r
* @param triangles\r
- * The triangles, each succesive 3 elements from a vertex\r
+ * The triangles, each successive 3 elements from a vertex\r
* @param intersection\r
- * The nearest intersection point\r
- * @return Wheter the ray and the triangles intersect.\r
+ * The nearest intersection point (optional)\r
+ * @return Whether the ray and the triangles intersect.\r
*/\r
public static boolean intersectRayTriangles(Ray ray, float[] triangles,\r
Vector3 intersection) {\r
* @param vertexSize\r
* the size of a vertex in floats\r
* @param intersection\r
- * The nearest intersection point\r
- * @return Wheter the ray and the triangles intersect.\r
+ * The nearest intersection point (optional)\r
+ * @return Whether the ray and the triangles intersect.\r
*/\r
public static boolean intersectRayTriangles(Ray ray, float[] vertices,\r
short[] indices, int vertexSize, Vector3 intersection) {\r
* @param triangles\r
* The triangles\r
* @param intersection\r
- * The nearest intersection point\r
- * @return Wheter the ray and the triangles intersect.\r
+ * The nearest intersection point (optional)\r
+ * @return Whether the ray and the triangles intersect.\r
*/\r
public static boolean intersectRayTriangles(Ray ray,\r
List<Vector3> triangles, Vector3 intersection) {\r
* The second point of the second line\r
* @param intersection\r
* The intersection point\r
- * @return Wheter the two lines intersect\r
+ * @return Whether the two lines intersect\r
*/\r
public static boolean intersectLines(Vector2 p1, Vector2 p2, Vector2 p3,\r
Vector2 p4, Vector2 intersection) {\r
* @param p4\r
* The second point of the second line segment\r
* @param intersection\r
- * The intersection point\r
- * @return Wheter the two line segments intersect\r
+ * The intersection point (optional)\r
+ * @return Whether the two line segments intersect\r
*/\r
public static boolean intersectSegments(Vector2 p1, Vector2 p2, Vector2 p3,\r
Vector2 p4, Vector2 intersection) {\r
if (ub < 0 || ub > 1)\r
return false;\r
\r
- intersection.set(x1 + (x2 - x1) * ua, y1 + (y2 - y1) * ua);\r
+ if (intersection != null)\r
+ intersection.set(x1 + (x2 - x1) * ua, y1 + (y2 - y1) * ua);\r
return true;\r
}\r
\r