Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Commit

Permalink
Fix problem of rendering child nodes with parent
Browse files Browse the repository at this point in the history
- Cleanup code
  • Loading branch information
Ahmet Bilgili committed Jul 23, 2015
1 parent f92d53b commit 33639e6
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 143 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ any other issue with this release.

* [#62](https://github.com/BlueBrain/Livre/issues/62):
Missing bricks in first frame after load_equalizer change
* [LIV-157](https://bbpteam.epfl.ch/project/issues/browse/LIV-157):
Livre renders overlapping LOD nodes from different levels

## About

Expand Down
3 changes: 3 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Changelog {#Changelog}
extension, based on the format used by ImageVis3D)
* [#75](https://github.com/BlueBrain/Livre/pull/75):
Separate ZeroEQ communication to class zeq::Communicator
* [#88](https://github.com/BlueBrain/Livre/pull/88):
Fix [LIV-157)](https://bbpteam.epfl.ch/project/issues/browse/LIV-157)
rendering of overlapping LOD nodes from different levels

# Release 0.3 (2015-07-07) {#Release030}

Expand Down
32 changes: 21 additions & 11 deletions livre/Lib/Render/AvailableSetGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,30 @@ void AvailableSetGenerator::generateRenderingSet( const Frustum&,
CollectionTraversal colTraverser;
colTraverser.traverse( frameInfo.allNodesList, collector );

NodeIdDashNodeMap::const_iterator it = nodeIdDashNodeMap.begin();
while( it != nodeIdDashNodeMap.end() )
if( !frameInfo.notAvailableRenderNodeList.empty( ))
{
DashRenderNode childNode( it->second );
if( !frameInfo.notAvailableRenderNodeList.empty() &&
hasParentInMap( childNode, nodeIdDashNodeMap ))
NodeIdDashNodeMap::const_iterator it = nodeIdDashNodeMap.begin();
size_t previousMapSize = 0;
do
{
it = nodeIdDashNodeMap.erase( it );
}
else
{
frameInfo.renderNodeList.push_back( it->second );
++it;
previousMapSize = nodeIdDashNodeMap.size();
while( it != nodeIdDashNodeMap.end( ))
{
DashRenderNode childNode( it->second );
if( hasParentInMap( childNode, nodeIdDashNodeMap ))
it = nodeIdDashNodeMap.erase( it );
else
++it;
}
}
while( previousMapSize != nodeIdDashNodeMap.size( ));
}

frameInfo.renderNodeList.reserve( nodeIdDashNodeMap.size( ));
for( NodeIdDashNodeMap::const_iterator it = nodeIdDashNodeMap.begin();
it != nodeIdDashNodeMap.end(); ++it )
{
frameInfo.renderNodeList.push_back( it->second );
}
}

Expand Down
1 change: 0 additions & 1 deletion livre/core/Files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ set(LIVRECORE_HEADERS
Events/EventHandlerFactory.h
Events/EventInfo.h
Events/EventMapper.h
Maths/BinarySearch.h
Maths/Maths.h
Maths/Plane.h
Maths/Quantizer.h
Expand Down
75 changes: 0 additions & 75 deletions livre/core/Maths/BinarySearch.h

This file was deleted.

14 changes: 1 addition & 13 deletions livre/core/Maths/Plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,7 @@ Vector3f Plane::getNormal( ) const

Vector3f Plane::getAbsNormal( ) const
{
return Vector3f( fabs( a_ ), fabs( b_ ), fabs( c_ ) );
}

bool Plane::intersectOrUnder(const Boxf& bb) const
{
const Vector3f halfExtents = bb.getDimension() * 0.5f;
const Vector3f& center = bb.getCenter( );

const float distToCenter = center.dot( getNormal() );
const float radius = halfExtents.dot( getAbsNormal() );

const float dMax = distToCenter + radius;
return dMax >= -d_;
return Vector3f( std::abs( a_ ), std::abs( b_ ), std::abs( c_ ) );
}

void Plane::set( const float a, const float b, const float c, const float d )
Expand Down
55 changes: 36 additions & 19 deletions livre/core/Render/Frustum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ const Plane& Frustum::getMVPlane( const PlaneId id ) const

bool Frustum::boxInFrustum( const Boxf &worldBox ) const
{
for (uint32_t i = 0; i < 6; i++)
{
if( !wPlanes_[ i ].intersectOrUnder( worldBox ) )
{
return false;
}
}
return true;
const Vector3f& min = worldBox.getMin();
const Vector3f& max = worldBox.getMax();
const Vector2f x( min[0], max[0] );
const Vector2f y( min[1], max[1] );
const Vector2f z( min[2], max[2] );

const vmml::Visibility vis = vmmlFrustumCuller_.test_aabb( x, y, z );
return vis != vmml::VISIBILITY_NONE;
}

bool Frustum::isInitialized( ) const
Expand Down Expand Up @@ -151,8 +151,10 @@ void Frustum::initialize( const Matrix4f& modelViewMatrix,
viewDir_[ 2 ] = column[ 2 ];

// Meaningful for only symmetric frusta
fovx_ = std::atan( std::abs( vmmlFrustum_.array[ PL_LEFT ] ) / fabs( vmmlFrustum_.array[ PL_NEAR ] ) ) * 2.0f;
fovy_ = std::atan( std::abs( vmmlFrustum_.array[ PL_TOP ] ) / fabs( vmmlFrustum_.array[ PL_NEAR ] ) ) * 2.0f;
fovx_ = std::atan( std::abs( vmmlFrustum_.array[ PL_LEFT ] )
/ std::abs( vmmlFrustum_.array[ PL_NEAR ] ) ) * 2.0f;
fovy_ = std::atan( std::abs( vmmlFrustum_.array[ PL_TOP ] )
/ std::abs( vmmlFrustum_.array[ PL_NEAR ] ) ) * 2.0f;
isInitialized_ = true;
}

Expand Down Expand Up @@ -183,8 +185,10 @@ void Frustum::initialize( const Matrix4f &modelViewMatrix,
initializePlaneCenters_( );

// Meaningful for only symmetric frusta
fovx_ = std::atan( std::abs( vmmlFrustum_.array[ PL_LEFT ] ) / fabs( vmmlFrustum_.array[ PL_NEAR ] ) ) * 2.0f;
fovy_ = std::atan( std::abs( vmmlFrustum_.array[ PL_TOP ] ) / fabs( vmmlFrustum_.array[ PL_NEAR ] ) ) * 2.0f;
fovx_ = std::atan( std::abs( vmmlFrustum_.array[ PL_LEFT ] ) /
std::abs( vmmlFrustum_.array[ PL_NEAR ] ) ) * 2.0f;
fovy_ = std::atan( std::abs( vmmlFrustum_.array[ PL_TOP ] ) /
std::abs( vmmlFrustum_.array[ PL_NEAR ] ) ) * 2.0f;
isInitialized_ = true;
}

Expand Down Expand Up @@ -238,7 +242,8 @@ void Frustum::initializePlaneCenters_()
planeCenters_[ PL_BOTTOM ] = planeCenters_[ PL_BOTTOM ] / planeCenters_[ PL_BOTTOM ][ 3 ];
}

void Frustum::computeFrustumVertices_( Vector3f frustumVertices[], Vector3f frustumNormals[] ) const
void Frustum::computeFrustumVertices_( Vector3f frustumVertices[],
Vector3f frustumNormals[] ) const
{
float farLeft;
float farRight;
Expand Down Expand Up @@ -300,22 +305,34 @@ void Frustum::computeFrustumVertices_( Vector3f frustumVertices[], Vector3f frus
frustumVertices[7][2] = -f;

// compute normals
frustumNormals[0] = (frustumVertices[5] - frustumVertices[1]).cross(frustumVertices[2] - frustumVertices[1]);
frustumNormals[0] = (frustumVertices[5]
- frustumVertices[1]).cross(frustumVertices[2]
- frustumVertices[1]);
frustumNormals[0].normalize();

frustumNormals[1] = (frustumVertices[3] - frustumVertices[0]).cross(frustumVertices[4] - frustumVertices[0]);
frustumNormals[1] = (frustumVertices[3]
- frustumVertices[0]).cross(frustumVertices[4]
- frustumVertices[0]);
frustumNormals[1].normalize();

frustumNormals[2] = (frustumVertices[6] - frustumVertices[2]).cross(frustumVertices[3] - frustumVertices[2]);
frustumNormals[2] = (frustumVertices[6]
- frustumVertices[2]).cross(frustumVertices[3]
- frustumVertices[2]);
frustumNormals[2].normalize();

frustumNormals[3] = (frustumVertices[4] - frustumVertices[0]).cross(frustumVertices[1] - frustumVertices[0]);
frustumNormals[3] = (frustumVertices[4]
- frustumVertices[0]).cross(frustumVertices[1]
- frustumVertices[0]);
frustumNormals[3].normalize();

frustumNormals[4] = (frustumVertices[1] - frustumVertices[0]).cross(frustumVertices[3] - frustumVertices[0]);
frustumNormals[4] = (frustumVertices[1]
- frustumVertices[0]).cross(frustumVertices[3]
- frustumVertices[0]);
frustumNormals[4].normalize();

frustumNormals[5] = (frustumVertices[7] - frustumVertices[4]).cross(frustumVertices[5] - frustumVertices[4]);
frustumNormals[5] = (frustumVertices[7]
- frustumVertices[4]).cross(frustumVertices[5]
- frustumVertices[4]);
frustumNormals[5].normalize();
}

Expand Down
18 changes: 0 additions & 18 deletions livre/core/Render/Frustum.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,43 +166,25 @@ class Frustum

void computeFrustumVertices_( Vector3f frustumVertices[],
Vector3f frustumNormals[] ) const;

void computeLimitsFromProjectionMatrix_( );

void initializePlanes_( const Matrix4f &matrix, Plane *planes );

void initialize_( );

void initializePlaneCenters_( );

Plane wPlanes_[ 6 ];

Plane mvPlanes_[ 6 ];

Matrix4f mvpMatrix_;

Matrix4f modelViewMatrix_;

Matrix4f invModelViewMatrix_;

Matrix4f projectionMatrix_;

Matrix4f invProjectionMatrix_;

bool isInitialized_;

float fovy_;

float fovx_;

Vector3f eye_;

Vector3f viewDir_;

Vector4f planeCenters_[ 6 ];

Frustumf vmmlFrustum_;

FrustumCullerf vmmlFrustumCuller_;
};

Expand Down
13 changes: 9 additions & 4 deletions livre/core/Render/RenderBrick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

#include <livre/core/Render/Frustum.h>
#include <livre/core/Data/LODNode.h>
#include <livre/core/Maths/Maths.h>
#include <eq/gl.h>

namespace livre
Expand Down Expand Up @@ -128,10 +129,14 @@ void RenderBrick::getScreenCoordinates( const Frustum& frustum,
}
}

xMin = std::max( (int)floor( xMin + 0.5 ), pvp[0] );
yMin = std::max( (int)floor( yMin + 0.5 ), pvp[1] );
xMax = std::min( (int)floor( xMax + 0.5 ), pvp[0] + pvp[2] );
yMax = std::min( (int)floor( yMax + 0.5 ), pvp[1] + pvp[3] );
xMin = maths::clamp( xMin + 0.5, (double)pvp[0],
(double)pvp[0] + (double)pvp[2] );
yMin = maths::clamp( yMin + 0.5, (double)pvp[1],
(double)pvp[1] + (double)pvp[3] );
xMax = maths::clamp( xMax + 0.5, (double)pvp[0],
(double)pvp[0] + (double)pvp[2] );
yMax = maths::clamp( yMax + 0.5, (double)pvp[1],
(double)pvp[1] + (double)pvp[3] );

minScreenPos = Vector2i( xMin, yMin );
maxScreenPos = Vector2i( xMax, yMax );
Expand Down

0 comments on commit 33639e6

Please sign in to comment.