mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-28 16:09:46 -06:00
adding bounding sphere to renderabeltrailtrajectory
This commit is contained in:
@@ -333,6 +333,25 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
|
||||
}
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
// Updating bounding sphere
|
||||
glm::vec3 maxVertex(-std::numeric_limits<float>::max());
|
||||
glm::vec3 minVertex(std::numeric_limits<float>::max());
|
||||
|
||||
auto setMax = [&maxVertex, &minVertex](const TrailVBOLayout& vertexData) {
|
||||
maxVertex.x = std::max(maxVertex.x, vertexData.x);
|
||||
maxVertex.y = std::max(maxVertex.y, vertexData.y);
|
||||
maxVertex.z = std::max(maxVertex.z, vertexData.z);
|
||||
|
||||
minVertex.x = std::min(minVertex.x, vertexData.x);
|
||||
minVertex.y = std::min(minVertex.y, vertexData.y);
|
||||
minVertex.z = std::min(minVertex.z, vertexData.z);
|
||||
};
|
||||
|
||||
std::for_each(_vertexArray.begin(), _vertexArray.end(), setMax);
|
||||
|
||||
setBoundingSphere(glm::distance(maxVertex, minVertex) / 2.0);
|
||||
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user