Ensure Build Bounding Box doesn't collapse
Previously the Bounding Box of a group of building was calculated purely based on the position of each building. Depending on the geometry of the various buildings, this could result in a zero-volume box, which would be culled away. This change ensures that the BB is at least a 20x20x20 volume, by increasing the convex hull size. Fixes https://sourceforge.net/p/flightgear/codetickets/2542/
This commit is contained in:
parent
836ee9a3f0
commit
e50337e36a
@ -79,6 +79,24 @@ struct BuildingBoundingBoxCallback : public Drawable::ComputeBoundingBoxCallback
|
||||
Vec3 pt = (*pos)[v];
|
||||
bb.expandBy(pt);
|
||||
}
|
||||
|
||||
// This BB is the convex hull of the building position - which are a set of points defining the front, center of
|
||||
// the building. We therefore need to expand the BB to account for the buildings have width, depth and height.
|
||||
|
||||
float BUILDING_RADIUS = 10.0;
|
||||
|
||||
bb.expandBy(bb.xMin() - BUILDING_RADIUS, bb.yMin() - BUILDING_RADIUS, bb.zMin() - BUILDING_RADIUS);
|
||||
bb.expandBy(bb.xMin() - BUILDING_RADIUS, bb.yMin() - BUILDING_RADIUS, bb.zMax() + BUILDING_RADIUS);
|
||||
|
||||
bb.expandBy(bb.xMin() - BUILDING_RADIUS, bb.yMax() + BUILDING_RADIUS, bb.zMin() - BUILDING_RADIUS);
|
||||
bb.expandBy(bb.xMin() - BUILDING_RADIUS, bb.yMax() + BUILDING_RADIUS, bb.zMax() + BUILDING_RADIUS);
|
||||
|
||||
bb.expandBy(bb.xMax() + BUILDING_RADIUS, bb.yMin() - BUILDING_RADIUS, bb.zMin() - BUILDING_RADIUS);
|
||||
bb.expandBy(bb.xMax() + BUILDING_RADIUS, bb.yMin() - BUILDING_RADIUS, bb.zMax() + BUILDING_RADIUS);
|
||||
|
||||
bb.expandBy(bb.xMax() + BUILDING_RADIUS, bb.yMax() + BUILDING_RADIUS, bb.zMin() - BUILDING_RADIUS);
|
||||
bb.expandBy(bb.xMax() + BUILDING_RADIUS, bb.yMax() + BUILDING_RADIUS, bb.zMax() + BUILDING_RADIUS);
|
||||
|
||||
return bb;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user