ElasticSea / unity-fracture

Fracture any mesh at runtime
MIT License
1.11k stars 128 forks source link

Using Custom Mesh #3

Closed mitoand9 closed 1 year ago

mitoand9 commented 4 years ago

Hi,

I am trying to adapt the code to use my own custom mesh with NvBlast. I imported in Unity a mesh made with an external 3D modelling package and then I fed it to the CreateWall object in the scene (basically my own mesh is fed as the cubeMesh in the script). Unfortunately Unity crashes. On the other hand, if I try to feed one of Unity's built-in meshes (cube, sphere, capsule..), everything works fine.

After debugging for a while I realised that the crash occurs when the Fracture object calls setSourceMesh(nvMesh), so exactly inside the Bake method.

Any idea what is preventing my own meshes from working?

Thanks in advance

ElasticSea commented 4 years ago

Hi no idea, I remember I had problem with meshes with holes or disconnected vertices (faces did not share vertices)

On Fri, 10 Apr 2020 at 13:53, mitoand9 notifications@github.com wrote:

Hi,

I am trying to adapt the code to use my own custom mesh with NvBlast. I imported in Unity a mesh made with an external 3D modelling package and then I fed it to the CreateWall object in the scene (basically my own mesh is fed as the cubeMesh in the script). Unfortunately Unity crashes. On the other hand, if I try to feed one of Unity's built-in meshes (cube, sphere, capsule..), everything works fine.

After debugging for a while I realised that the crash occurs when the Fracture object calls setSourceMesh(nvMesh), so exactly inside the Bake method.

Any idea what is preventing my own meshes from working?

Thanks in advance

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ElasticSea/Destructible-Walls/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI2G5AIM777LNZVAH6354DDRL4CDZANCNFSM4MFM4VFA .

mitoand9 commented 4 years ago

Thanks for the feedback. So I noticed that any mesh built in Unity works fine, even those with holes inside them (I made a few with ProBuilder). However, when it comes to any FBX made outside Unity, it won't work. For my project, ProBuilder is all I need, so I am happy. But for more complex shapes it currently does not work.

ElasticSea commented 4 years ago

Could you attach a simple .fbx model that I could take a look at?

mitoand9 commented 4 years ago

WallWindow.zip

Here you go. It's just a simple wall with a hole inside, mesh should be airtight. I also tried with a simple cube made in Blender, the default one.. that also does not work,

ElasticSea commented 4 years ago

So I just quickly assigned your mesh to the cubemesh field at CreateWalls:32 and it works as expected. I just changed the import scale factor to 50.

mitoand9 commented 4 years ago

Mmn okay strange. Not sure why scale would be have to be changed. Could be a Unity version issue..? 2019.3.0f3

ElasticSea commented 4 years ago

No issue in 2019.3.0f1. You could send me the whole project and I could take a look.

mitoand9 commented 4 years ago

Ok, I'll try to isolate the issue in a single scene and send it through because it's quite a big project. Thanks for that!

I also have another question, but this is about batching of each chunk. I'll open a new thread for that.