public void Point_should_be_outside_the_triangle_since_the_horizontal_raycast_touches_a_single_vertex() { var mesh = meshA; var point = new Vector3(mesh.EdgeVertices[1].x + 0.1f, 0, mesh.EdgeVertices[1].z); Assert.IsFalse(JMeshOverlap.IsPointInsideMesh(point, mesh)); }
public void Point_should_be_outside_the_triangle_on_its_right() { var mesh = JMeshPhysicsMeshes.triangleMeshIdentity; Vector3 point = new Vector3(1.25f, 0, 0.25f); Assert.IsFalse(JMeshOverlap.IsPointInsideMesh(point, mesh)); }
public void Point_should_be_inside_triangle() { var mesh = JMeshPhysicsMeshes.triangleMeshIdentity; Vector3 point = new Vector3(0.5f, 0, 0.25f); Assert.IsTrue(JMeshOverlap.IsPointInsideMesh(point, mesh)); Assert.IsTrue(JMeshOverlap.IsPointInsideMesh(new Vector3(1f, 0, 0), mesh)); }
public void Point_shold_be_inside_mesh_when_point_is_on_a_mesh_edge() { var mesh = JMeshPhysicsMeshes.squareMeshIdentity; Assert.IsTrue(JMeshOverlap.IsPointInsideMesh(new Vector3(0.5f, 0, 0), mesh)); Assert.IsTrue(JMeshOverlap.IsPointInsideMesh(new Vector3(1f, 0, 0.5f), mesh)); Assert.IsTrue(JMeshOverlap.IsPointInsideMesh(new Vector3(0.5f, 0, 1), mesh)); Assert.IsTrue(JMeshOverlap.IsPointInsideMesh(new Vector3(0, 0, 0.5f), mesh)); }
public void Point_should_be_inside_the_transformed_square_mesh() { var mesh = JMeshPhysicsMeshes.squareMeshIdentity; var meshFrameInstance = JMesh.FromMeshAndTransform(mesh, Matrix4x4.TRS( new Vector3(1, 0, 1), Quaternion.Euler(Vector3.up * 45), Vector3.one * 2 )); Assert.IsTrue(JMeshOverlap.IsPointInsideMesh(new Vector3(1.001f, 0, 1f), meshFrameInstance)); Assert.IsTrue(JMeshOverlap.IsPointInsideMesh(new Vector3(1f, 0, 1f), meshFrameInstance)); }
public void Point_shold_be_inside_mesh_when_point_is_exactly_on_a_mesh_edge_vertex() { var mesh = JMeshPhysicsMeshes.squareMeshIdentity; var meshFrameInstance = JMesh.FromMeshAndTransform(mesh, Matrix4x4.TRS( new Vector3(1, 0, 1), Quaternion.Euler(Vector3.up * 45), Vector3.one * 2 )); var instanceMesh = meshFrameInstance; Assert.IsTrue(JMeshOverlap.IsPointInsideMesh(instanceMesh.EdgeVertices[0], meshFrameInstance)); Assert.IsTrue(JMeshOverlap.IsPointInsideMesh(instanceMesh.EdgeVertices[1], meshFrameInstance)); Assert.IsTrue(JMeshOverlap.IsPointInsideMesh(instanceMesh.EdgeVertices[2], meshFrameInstance)); Assert.IsTrue(JMeshOverlap.IsPointInsideMesh(instanceMesh.EdgeVertices[3], meshFrameInstance)); }