DavidArayan / ezy-slice

An open source mesh slicer framework for Unity3D Game Engine. Written in C#.
MIT License
1.88k stars 248 forks source link

Slicing Unity's sphere results in meshes with uncovered holes #36

Open davl3232 opened 4 years ago

davl3232 commented 4 years ago

Slicing a sphere created with Unity's right click>3D Object>Sphere, with identity transform with planeWorldPosition = Vector3.zero and planeWorldDirection = Vector3.right results in hemisphere meshes with holes.

image

When I rotate the sphere 5 degrees along the y axis, it doesn't happen.

image

This happens in master at commit https://github.com/DavidArayan/ezy-slice/commit/b93d68c24371a1fc7c7f0c3b70bd85ac28d950b0 Unity Version 2019.3.5f1 (d691e07d38ef) Personal

This doesn't happen on release 1.0.0

Script used for slicing:

using EzySlice;
using UnityEngine;

public class SliceOnClick : MonoBehaviour
{

  public Material innerMaterial;

  // Start is called before the first frame update
  void Start()
  {

  }

  // Update is called once per frame
  void Update()
  {

  }

  void OnMouseDown()
  {
    Debug.Log("CUTTING");
    if (this.Slice(Vector3.zero, Vector3.right) == null)
    {
      Debug.Log("FAILED");
    }
    Debug.Log("WORKED");
  }

  public GameObject[] Slice(Vector3 planeWorldPosition, Vector3 planeWorldDirection)
  {
    return this.gameObject.SliceInstantiate(planeWorldPosition, planeWorldDirection, CalculateCustomRegion(0, 0, 512, 512), this.innerMaterial);
  }

  public TextureRegion CalculateCustomRegion(int px, int py, int width, int height)
  {
    return this.innerMaterial.GetTextureRegion(px, py, width, height);
  }
}

PD: Thank you for making this project!

DavidArayan commented 4 years ago

Thank you for the bug report and extensive information! I will investigate to see whats going on.

pruebasssaa commented 4 years ago

I also have this problem, it doesn't happen with threading branch. Check the List<Vector3> intPoints and with the same model, the master branch has a count of 0. It mainly happens with complex geometry.

It may also be processing well, but you have forgotten to place a material. That is, not even this slot is available in the MeshRenderer, only 1, (the visible material).

PurpleSlayerFish commented 2 years ago

Hey, guys. I also have the same problem and i found the reason, why this happens. @DavidArayan, Maybe it will help you fix them. This happens, when cutting plane exactly crosses one or more vertexes of a mesh. For example, i have a fruit cutting game, and i replaced my mesh with unity standard primitive cube. I turned my cube mesh to 45 degrees and set cutting plane position exactly in the middle of a cube just like on screenshot. And i sliced this.

UP: i use last framework version with my Unity 2020.3.1f1 UP2: We love your framework so much, David. image image image image

mihailpettas commented 1 year ago

anyone fixed this?

XaHDpE commented 5 months ago

Anybody?)