Easy way to keep model on top of the current floor height?

My virtual world is not completely flat. There are inclines and raised areas that the animation models and the player (camera) have to traverse. Therefore, I need to adjust the model or cameras Y position so that it the object stays above the current height of the floor as it moves about.

Determining this value is actually trickier than it appears, at least to me. I thought about raycasting in the negative Y direction for intersecting objects, but what happens if the model ends up below the floor? I thought about then raycasting in the positive and negative Y directions and taking the largest Y value as the floor value across the values found, but then I can’t have any ceilings or upper levels.

Is there a known technique or strategy that isn’t a CPU hog for dealing with the problem of determining the proper Y value, when moving an animation model or the camera, so that it always is at the right elevation depending on the current height of the floor?

I haven’t done this before, just a few thoughts:

I would:

  1. calculate the model’s lowest point,
  2. find the nearest height of surface to that point -either higher or lower - up to a certain threshold to exclude ceilings and basements.
  3. align the model based on the nearest surface height and lowest model point - problem solved.

Also:

  • ceilings of buildings are not, and don’t have to be considered “ground” so you could exclude them in most cases and only when the model enters another story of a building should the floor be considered ground.
  • If the ground does not form caves, you only need the 2D coordinates of the model’s position to find the polygon underneath, that’s a very simple calculation - nothing sort of raytracing.