mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 22:39:09 -05:00
Fixed blinking (precision) problems.
This commit is contained in:
@@ -418,6 +418,24 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) {
|
||||
0 :
|
||||
_primaryRenderInformation.first;
|
||||
|
||||
// Culling
|
||||
const double scaledRadius = glm::length(
|
||||
glm::dmat3(modelTransform) * glm::dvec3(_boundingSphere, 0.0, 0.0)
|
||||
);
|
||||
|
||||
glm::dvec3 trailPosWorld = glm::dvec3(
|
||||
modelTransform * _primaryRenderInformation._localTransform *
|
||||
glm::dvec4(0.0, 0.0, 0.0, 1.0)
|
||||
);
|
||||
const double distance = glm::distance(
|
||||
trailPosWorld,
|
||||
data.camera.eyePositionVec3()
|
||||
);
|
||||
|
||||
if (distance > scaledRadius * DISTANCE_CULLING_RADII) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Render the primary batch of vertices
|
||||
render(_primaryRenderInformation, totalNumber, primaryOffset);
|
||||
|
||||
|
||||
@@ -72,6 +72,8 @@ class Translation;
|
||||
class RenderableTrail : public Renderable {
|
||||
public:
|
||||
|
||||
const double DISTANCE_CULLING_RADII = 800.0;
|
||||
|
||||
struct Appearance : properties::PropertyOwner {
|
||||
Appearance();
|
||||
/// Specifies the base color of the line before fading
|
||||
|
||||
@@ -356,6 +356,25 @@ void RenderableTrailOrbit::update(const UpdateData& data) {
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
// Updating bounding sphere
|
||||
glm::vec3 maxVertex(std::numeric_limits<float>::min());
|
||||
glm::vec3 minVertex(std::numeric_limits<float>::max());
|
||||
|
||||
auto setMax = [&maxVertex, &minVertex](TrailVBOLayout &vertexData)
|
||||
{
|
||||
maxVertex.x = maxVertex.x < vertexData.x ? vertexData.x : maxVertex.x;
|
||||
maxVertex.y = maxVertex.y < vertexData.y ? vertexData.y : maxVertex.y;
|
||||
maxVertex.z = maxVertex.z < vertexData.z ? vertexData.z : maxVertex.z;
|
||||
|
||||
minVertex.x = minVertex.x > vertexData.x ? vertexData.x : minVertex.x;
|
||||
minVertex.y = minVertex.y > vertexData.y ? vertexData.y : minVertex.y;
|
||||
minVertex.z = minVertex.z > vertexData.z ? vertexData.z : minVertex.z;
|
||||
};
|
||||
|
||||
std::for_each(_vertexArray.begin(), _vertexArray.end(), setMax);
|
||||
|
||||
setBoundingSphere(glm::distance(maxVertex, minVertex) / 2.0);
|
||||
}
|
||||
|
||||
RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
|
||||
|
||||
Reference in New Issue
Block a user