For collision, the raycasting algorithm simplifies to an iterative bounding box algorithm. This starts by checking the full extents of the volume, it then checks the Z component of each segment until and intersection is found. If required it will check the Y and finally the X component. As soon a segment is found to be above the test bounds, we know that no further intersections will be found.
For creation/destruction, a new segment can replace all or part of one or more existing segments. To do this is quite simple. First, we find the first and last intersecting segments and remove any segments between them. The decide which of the following to do.
- If the first and last segments are the same segment and the same type as the replacement, there is no change.
- If the first and last segments are the same segment but not the same type as the replacement, two new last segments are created and the first segment shrinks.
- If the first and last segment are the same type as the replacement, the first segment grows and the last segment is removed.
- If only the first segment is the same type as the replacement, the first segment grows and the last segment shrinks.
- If only the last segment is the same type as the replacement, the last segment grows and the first segment shrinks.
- Otherwise, both the first and last segments shrink.
No comments:
Post a Comment