Very cool stuff!
swokes wrote:
Within the terrain volume collider, I assume you just use the same mesh that is generated for the renderer in a mesh collider, or is it done some over way?
Yes. In the future I would like to use a lower LOD mesh for physics but so now it uses the same one as for rendering.
swokes wrote:
To answer your question from your post, the issue is that unity 5 can't have non-kinematic rigid bodies with non-convex colliders. The collider must be made convex, or the rigid body must be kinematic.
Ok, well the terrain is generally non-convex but should be kinematic (you may want to check this). Trying to approximate the terrain with convex colliders will be difficult and probably not the right approach. What about the piece which you split off? I assume that is a normal Unity mesh, or are you creating a new smaller terrain volume? A normal mesh would be preferable, unless you need users to be able to further edit the split-off piece (this will get complex!).
For the split-off piece I think you have two main options for the collider.
1) Apply some for of convex decomposition to create a number of convex meshes from the non-convex one. I'm sure there are known algorithms for this and I expect they are complicated :-)
2) For each voxel in the split-off piece generate a sphere collider, and hold them together with rod /stick constraints (I assume Unity has something like this) to fix the shape. You only need a sphere for the voxels lying on the surface, so your 20x20x20 example would have a lot less than 8000 sphere colliders. Actually the colored cubes example also only generates cubes for voxels on the surface of the destroyed terrain. I don't know how practical this is, or how many sphere colliders you will need, but I feel it would be easier than convex decomposition and is where I would start.
Either way, you now have non-convex but kinematic terrain, with a non-kinematic but convex split-off piece. This is enough for Unity?
swokes wrote:
I appreciate what I am trying to do is a) unusual and b) probably beyond what you had in mind when you designed Cubiquity.
It's certainly been on my mind, but generally I think it is outside the scope of Cubiquity once you have separated the piece off from the terrain. From then on it is your problem :-) That said, if the split-off piece was made into a second volume then this would need to be handled inside Cubiquity, but it's pretty complicated I think. Would be cool to have something like this:
https://www.youtube.com/watch?v=nCpTgfVmhccOf course, when working with cubic voxels we can approximate it with large box colliders (probably what this video does?), but smooth terrain is more complex.
Anyway, I hope that gives you some food for thought...