Terrain picking solved
Guess I spoke too soon about wondering how to go about picking parts of the terrain, because I figured it out! As I'm going to be using BEPU for the physics engine, I just let BEPU do the dirty work. Using it to create a terrain height field and doing ray intersection testing is pretty intuitive. Storing 4 million points is no problem for it, but I may look into its source code to see how it's doing the intersection tests so efficiently.
In the meantime, though, I can move on to creating the brush and mesh placement tools. Mesh placement should be easy, as I want most objects to be touching the ground. Placing meshes will also be treated as brushes so you can fill the landscape with loads of objects quickly. For now I have this video as a proof of concept for testing.
Some ideas on the placement tools:
- Mesh brushes will likely be done the way of Poisson Disk sampling as demonstrated here, so the spacing of objects looks natural and you don't have to think much about how their placement looks.
- Objects can still be changed individually if you wish. A single Selection tool will make it possible to change an object's scaling and location.
- Rotation can be done on a basis of either having all objects orient towards the surface normal, or ignore the Y component. Rocks, for example are fine for rotating in all directions, but trees and buildings should generally point up.
- A toggle switch for each object so you can snap its vertical position to the ground surface in one click.
Physical interactions with the objects will come a bit later. I will at least need a wrapper class to associate mesh instances with BEPU Entities.