|
![](/i/fill.gif) |
> How could this be achieved? The highest point could be
> tested for by shooting a series of parallel horizontal
> trace() rays from one edge of the map section, starting
> at a height well above the highest mountains in the whole
> isosurface (for example 15 kilometres), going lower each
> iteration until the first mountain peak is hit. But how
> to this for the lowest point?
>
> And, after all, I'm sure that this method would be
> outstandingly time-consuming - is there any way to do it faster?
It needn't be particular slow at all - you can use an O(LogN) binary
sub-division algorithm:
In pseudo code:
int height = 16384;
int step = height / 2;
while (step >= 0) {
if (hit_object_at_height(height)) {
height += step;
} else {
height -= step;
}
step /= 2;
}
With just 15 trace calls you'd have the maximum height between 0 and 65535m
to 1m resolution.
Ray
Post a reply to this message
|
![](/i/fill.gif) |