Example #1
0
    public unsafe void Box_IsCreated()
    {
        using (var box = HullFactory.CreateBox(BoxSize))
        {
            Assert.IsTrue(box.IsCreated);
            Assert.IsFalse(box.IsDisposed);

            Assert.IsTrue((IntPtr)box.Faces != IntPtr.Zero);
            Assert.IsTrue((IntPtr)box.Vertices != IntPtr.Zero);
            Assert.IsTrue((IntPtr)box.Planes != IntPtr.Zero);
            Assert.IsTrue((IntPtr)box.Faces != IntPtr.Zero);
            Assert.IsTrue((IntPtr)box.Edges != IntPtr.Zero);
        }
    }
    private NativeHull CreateHull(Transform v)
    {
        var collider = v.GetComponent <Collider>();

        if (collider is BoxCollider boxCollider)
        {
            return(HullFactory.CreateBox(boxCollider.size));
        }
        if (collider is MeshCollider meshCollider)
        {
            return(HullFactory.CreateFromMesh(meshCollider.sharedMesh));
        }
        var mf = v.GetComponent <MeshFilter>();

        if (mf != null && mf.sharedMesh != null)
        {
            return(HullFactory.CreateFromMesh(mf.sharedMesh));
        }
        throw new InvalidOperationException($"Unable to create a hull from the GameObject '{v?.name}'");
    }
Example #3
0
 public static NativeHull CreateBox() => HullFactory.CreateBox(BoxSize);