Commit a2960549 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - automatic fixture copy procedure added

parent e9e34b04
......@@ -154,6 +154,8 @@ INCLUDE_DIRECTORIES( ${OPENSCENEGRAPH_INCLUDE_DIRS} )
# CXX Test
# See http://cxxtest.tigris.org
INCLUDE( FindPythonInterp )
# Try to find it
FIND_PACKAGE( CxxTest QUIET )
MARK_AS_ADVANCED( CXXTEST_PERL_TESTGEN_EXECUTABLE )
......@@ -194,6 +196,10 @@ ENDIF()
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/ext/libeep )
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/ext )
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR} )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# OWext
......@@ -201,10 +207,6 @@ SET( OWExtNiftiName "OWext_niftiio" )
SET( OWExtEEPName "OWext_eep" )
SET( OWExtBioSigName "OWext_biosig" )
# Needed because libeep has includes of form #include <cnt/cnt.h>
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/ext/libeep )
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/ext )
# build external libs in ext/
ADD_SUBDIRECTORY( ext ) # The needed external libraries
......@@ -213,33 +215,12 @@ ADD_SUBDIRECTORY( ext ) # The needed external libraries
SET( OWCoreName "OWcore" )
# Set the prefix and suffix of dynamically loadable modules to match
# CMAKEs naming of them. The quotes are necessary so the shell doesn't mess
# with these defines. Unfortunately, the Visual Studio has problems handling
# the quotes on the command line. WSharedLib::getSystemPrefix and
# getSystemSuffix hard codes the right strings for VC.
# Maybe you have to spend another 500 bucks to have your VC support quotes.
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
ADD_DEFINITIONS( '-DW_LIB_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}"' )
ADD_DEFINITIONS( '-DW_LIB_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"' )
ENDIF()
# build core
ADD_SUBDIRECTORY( core )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# QT4 Walnut binary
# Collect the compile-files for OWCore
# Kernel
COLLECT_COMPILE_FILES( "${PROJECT_SOURCE_DIR}/kernel" CORE_KERNEL_CPP_FILES CORE_KERNEL_H_FILES CORE_KERNEL_TEST_FILES )
# Common
COLLECT_COMPILE_FILES( "${PROJECT_SOURCE_DIR}/common" CORE_COMMON_CPP_FILES CORE_COMMON_H_FILES CORE_COMMON_TEST_FILES )
# DataHandler
COLLECT_COMPILE_FILES( "${PROJECT_SOURCE_DIR}/dataHandler" CORE_DATAHANDLER_CPP_FILES CORE_DATAHANDLER_H_FILES CORE_DATAHANDLER_TEST_FILES )
# GraphicsEngine
COLLECT_COMPILE_FILES( "${PROJECT_SOURCE_DIR}/graphicsEngine" CORE_GRAPHICSENGINE_CPP_FILES CORE_GRAPHICSENGINE_H_FILES CORE_GRAPHICSENGINE_TEST_FILES )
# Merge them into one big list
SET( CORE_CPP_FILES ${CORE_KERNEL_CPP_FILES} ${CORE_COMMON_CPP_FILES} ${CORE_DATAHANDLER_CPP_FILES} ${CORE_GRAPHICSENGINE_CPP_FILES} )
SET( CORE_H_FILES ${CORE_KERNEL_H_FILES} ${CORE_COMMON_H_FILES} ${CORE_DATAHANDLER_H_FILES} ${CORE_GRAPHICSENGINE_H_FILES} )
SET( CORE_TEST_FILES ${CORE_KERNEL_TEST_FILES} ${CORE_COMMON_TEST_FILES} ${CORE_DATAHANDLER_TEST_FILES} ${CORE_GRAPHICSENGINE_TEST_FILES} )
# Setup the OWCore target
ADD_LIBRARY( ${OWCoreName} SHARED ${CORE_CPP_FILES} ${CORE_H_FILES} )
TARGET_LINK_LIBRARIES( ${OWCoreName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES} ${OWExtBioSigName} ${OWExtEEPName} ${OWExtNiftiName} )
# build core
# ADD_SUBDIRECTORY( qt4gui )
# Set the prefix and suffix of dynamically loadable modules to match
# CMAKEs naming of them. The quotes are necessary so the shell doesn't mess
# with these defines. Unfortunately, the Visual Studio has problems handling
# the quotes on the command line. WSharedLib::getSystemPrefix and
# getSystemSuffix hard codes the right strings for VC.
# Maybe you have to spend another 500 bucks to have your VC support quotes.
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
ADD_DEFINITIONS( '-DW_LIB_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}"' )
ADD_DEFINITIONS( '-DW_LIB_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"' )
ENDIF()
# Collect the compile-files for OWCore
COLLECT_COMPILE_FILES( "${CMAKE_CURRENT_SOURCE_DIR}" CORE_CPP_FILES CORE_H_FILES CORE_TEST_FILES )
# Setup the OWCore target
ADD_LIBRARY( ${OWCoreName} SHARED ${CORE_CPP_FILES} ${CORE_H_FILES} )
TARGET_LINK_LIBRARIES( ${OWCoreName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES} ${OWExtBioSigName} ${OWExtEEPName} ${OWExtNiftiName} )
# Setup tests of this target
# Unit tests
IF( OW_COMPILE_TESTS )
# Add each found test and create a target for it
FOREACH( testfile ${CORE_TEST_FILES} )
# strip path and extension
STRING( REGEX REPLACE "^.*/" "" StrippedTestFile "${testfile}" )
STRING( REGEX REPLACE "\\..*$" "" PlainTestFileName "${StrippedTestFile}" )
STRING( REGEX REPLACE "_test$" "" TestFileClass "${PlainTestFileName}" )
# create some name for the test
SET( UnitTestName "unittest_${TestFileClass}" )
# create the test-target
CXXTEST_ADD_TEST( ${UnitTestName} "${UnitTestName}.cc" ${testfile} )
TARGET_LINK_LIBRARIES( ${UnitTestName} ${OWCoreName} )
ENDFOREACH( testfile )
# direct globbing of files by only knowing a part of the path is not possible -> so get all files and filter later
FILE( GLOB_RECURSE everything "${CMAKE_CURRENT_SOURCE_DIR}/*" )
SET( FixturePaths )
FOREACH( fixture ${everything} )
# is this a fixture?
STRING( REGEX MATCH "test\\/fixtures" IsFixture "${fixture}" )
IF( IsFixture ) # found a fixture.
# strip filename from path and keep only path
STRING( REGEX REPLACE "fixtures/.*$" "fixtures" FixturePath "${fixture}" )
# add it to a list
LIST( APPEND FixturePaths ${FixturePath} )
ENDIF( IsFixture )
ENDFOREACH( fixture )
# the list may contain duplicates
LIST( REMOVE_DUPLICATES FixturePaths )
# for each fixture, copy to build dir
FOREACH( FixtureDir ${FixturePaths} )
# we need a unique name for each fixture dir as target
STRING( REGEX REPLACE "[^A-Za-z0-9]" "" FixtureDirEscaped "${FixtureDir}" )
# finally, create the copy target
ADD_CUSTOM_TARGET( ${OWCoreName}_CopyFixtures_${FixtureDirEscaped}
COMMAND ${CMAKE_COMMAND} -E copy_directory "${FixtureDir}" ${CMAKE_BINARY_DIR}/core/fixtures/
COMMENT "Copy fixtures of ${OWCoreName} from ${FixtureDir}."
)
ADD_DEPENDENCIES( ${OWCoreName} ${OWCoreName}_CopyFixtures_${FixtureDirEscaped} )
ENDFOREACH( FixtureDir )
ENDIF( OW_COMPILE_TESTS )
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WGEManagedRenderNodeCL.h"
WGEManagedRenderNodeCL::WGEManagedRenderNodeCL( boost::shared_ptr< WBoolFlag > active, bool deactivated ):
WGERenderNodeCL( deactivated ),
m_flag( active )
{
// initialize
}
WGEManagedRenderNodeCL::WGEManagedRenderNodeCL( const WGEManagedRenderNodeCL& node, const osg::CopyOp& copyop ):
WGERenderNodeCL( node, copyop ),
m_flag( node.m_flag )
{
// initialize
}
WGEManagedRenderNodeCL::~WGEManagedRenderNodeCL()
{
// initialize
}
osg::Object* WGEManagedRenderNodeCL::cloneType() const
{
return new WGEManagedRenderNodeCL( *this );
}
osg::Object* WGEManagedRenderNodeCL::clone( const osg::CopyOp& copyop ) const
{
return new WGEManagedRenderNodeCL( *this, copyop );
}
bool WGEManagedRenderNodeCL::isSameKindAs( const osg::Object* object ) const
{
return ( dynamic_cast< const WGEManagedRenderNodeCL* >( object ) != 0 );
}
const char* WGEManagedRenderNodeCL::className() const
{
return "WGEManagedRenderNodeCL";
}
void WGEManagedRenderNodeCL::accept( osg::NodeVisitor& nv ) // NOLINT // non-const reference
{
if ( m_flag->get() )
{
WGERenderNodeCL::accept( nv );
}
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WGEMANAGEDRENDERNODECL_H
#define WGEMANAGEDRENDERNODECL_H
#include <boost/shared_ptr.hpp>
#include "../../common/WFlag.h"
#include "../WExportWGE.h"
#include "WGERenderNodeCL.h"
/**
* WGEManagedRenderNodeCL extends WGERenderNodeCL by a flag to switch the node on and off.
* This switch is independent of WGERenderNodeCL's activation state.
*
* \ingroup ge
*/
class WGE_EXPORT WGEManagedRenderNodeCL: public WGERenderNodeCL
{
public:
/**
* Constructor.
*
* \param active The flag denoting the node to be online (true) or offline (false).
* \param deactivated Set whether the node should be set to deactivated state.
*/
explicit WGEManagedRenderNodeCL( boost::shared_ptr< WBoolFlag > active, bool deactivated = false );
/**
* Copy construcor.
*
* \param node The node to copy.
* \param copyop The optional OSG copy operator.
*/
WGEManagedRenderNodeCL( const WGEManagedRenderNodeCL& node, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY );
/**
* Overrides osg::Object::cloneType().
*
* \return The cloned node.
*/
virtual osg::Object* cloneType() const;
/**
* Overrides osg::Object::clone().
*
* \param copyop The optional OSG copy operator.
*
* \return The cloned node.
*/
virtual osg::Object* clone( const osg::CopyOp& copyop ) const;
/**
* Overrides osg::Object::isSameKindAs().
*
* \param object The object to compare with.
*
* \return States whether this node and object are of same type.
*/
virtual bool isSameKindAs( const osg::Object* object ) const;
/**
* Overrides osg::Object::className().
*
* \return Gives the node's class name.
*/
virtual const char* className() const;
/**
* Overrides osg::Node::accept().
*
* \param nv The traversal's NodeVisitor.
*/
virtual void accept( osg::NodeVisitor& nv ); // NOLINT - non const reference. Derived from OSG. We can't change signature.
protected:
/**
* Destructor.
*/
virtual ~WGEManagedRenderNodeCL();
private:
/**
* The flag to control the node's state.
*/
boost::shared_ptr< WBoolFlag > m_flag;
};
#endif // WGEMANAGEDRENDERNODECL_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WGERenderNodeCL.h"
#include "WGEModuleCL.h"
WGEModuleCL::ViewProperties::ViewProperties( const CLViewData& viewData )
{
const osg::Matrix& pm = *viewData.m_projection.get();
double pNear, pFar, pLeft, pRight, pTop, pBottom;
if ( pm( 3, 3 ) == 0.0 )
{
// perspective projection
//
// pm :
//
// -------------------------------------------------------------------------------------------------------------
// ( 2 * near / (right - left) |0 |0 |0 )
// ( 0 |2 * near / (top - bottom) |0 |0 )
// ( (right + left) / (right - left) |(top + bottom) / (top - bottom) |-(far + near) / (far - near) |-1 )
// ( 0 |0 |-2 * far * near / (far - near) |0 )
// -------------------------------------------------------------------------------------------------------------
m_type = PERSPECTIVE;
pNear = pm( 3, 2 ) / ( pm( 2, 2 ) - 1.0 );
pFar = pm( 3, 2 ) / ( pm( 2, 2 ) + 1.0 );
pLeft = pNear * ( pm( 2, 0 ) - 1.0 ) / pm( 0, 0 );
pRight = pNear * ( pm( 2, 0 ) + 1.0 ) / pm( 0, 0 );
pBottom = pNear * ( pm( 2, 1 ) - 1.0 ) / pm( 1, 1 );
pTop = pNear * ( pm( 2, 1 ) + 1.0 ) / pm( 1, 1 );
}
else
{
// orthographic projection
//
// pm :
//
// ------------------------------------------------------------------------------------------------------------
// ( 2 / (right - left) |0 |0 |0 )
// ( 0 |2 / (top - bottom) |0 |0 )
// ( 0 |0 |-2 / (far - near) |0 )
// ( -(right + left) / (right - left) |-(top + bottom) / (top - bottom) |-(far + near) / (far - near) |1 )
// ------------------------------------------------------------------------------------------------------------
m_type = ORTHOGRAPHIC;
pNear = ( pm( 3, 2 ) + 1.0 ) / pm( 2, 2 );
pFar = ( pm( 3, 2 ) - 1.0 ) / pm( 2, 2 );
pLeft = -( 1.0 + pm( 3, 0 ) ) / pm( 0, 0 );
pRight = ( 1.0 - pm( 3, 0 ) ) / pm( 0, 0 );
pBottom = -( 1.0 + pm( 3, 1 ) ) / pm( 1, 1 );
pTop = ( 1.0 - pm( 3, 1 ) ) / pm( 1, 1 );
}
m_planeNear = static_cast< cl_float >( pNear );
m_planeFar = static_cast< cl_float >( pFar );
const osg::Matrix& mvm = *viewData.m_modelView.get();
// mvm :
//
// ----------------------------------------
// ( RS[0][0] |RS[0][1] |RS[0][2] |0 )
// ( RS[1][0] |RS[1][1] |RS[1][2] |0 )
// ( RS[2][0] |RS[2][2] |RS[2][2] |0 )
// ( tx |ty |tz |1 )
// ----------------------------------------
//
// Inverse(mvm) :
//
// ----------------------------------------------------------------
// ( Inverse(RS)[0][0] |Inverse(RS)[0][1] |Inverse(RS)[0][2] |0 )
// ( Inverse(RS)[1][0] |Inverse(RS)[1][1] |Inverse(RS)[1][2] |0 )
// ( Inverse(RS)[2][0] |Inverse(RS)[2][2] |Inverse(RS)[2][2] |0 )
// ( invTx |invTy |invTz |1 )
// ----------------------------------------------------------------
double invMvm[ 4 ][ 3 ];
double invDet;
invMvm[ 0 ][ 0 ] = mvm( 1, 1 ) * mvm( 2, 2 ) - mvm( 1, 2 ) * mvm( 2, 1 );
invMvm[ 0 ][ 1 ] = mvm( 0, 2 ) * mvm( 2, 1 ) - mvm( 0, 1 ) * mvm( 2, 2 );
invMvm[ 0 ][ 2 ] = mvm( 0, 1 ) * mvm( 1, 2 ) - mvm( 0, 2 ) * mvm( 1, 1 );
invMvm[ 1 ][ 0 ] = mvm( 1, 2 ) * mvm( 2, 0 ) - mvm( 1, 0 ) * mvm( 2, 2 );
invMvm[ 1 ][ 1 ] = mvm( 0, 0 ) * mvm( 2, 2 ) - mvm( 0, 2 ) * mvm( 2, 0 );
invMvm[ 1 ][ 2 ] = mvm( 0, 2 ) * mvm( 1, 0 ) - mvm( 0, 0 ) * mvm( 1, 2 );
invMvm[ 2 ][ 0 ] = mvm( 1, 0 ) * mvm( 2, 1 ) - mvm( 1, 1 ) * mvm( 2, 0 );
invMvm[ 2 ][ 1 ] = mvm( 0, 1 ) * mvm( 2, 0 ) - mvm( 0, 0 ) * mvm( 2, 1 );
invMvm[ 2 ][ 2 ] = mvm( 0, 0 ) * mvm( 1, 1 ) - mvm( 0, 1 ) * mvm( 1, 0 );
invDet = 1.0 / ( mvm( 0, 0 ) * invMvm[ 0 ][ 0 ] + mvm( 1, 0 ) * invMvm[ 0 ][ 1 ] + mvm( 2, 0 ) * invMvm[ 0 ][ 2 ] );
invMvm[ 0 ][ 0 ] *= invDet;
invMvm[ 0 ][ 1 ] *= invDet;
invMvm[ 0 ][ 2 ] *= invDet;
invMvm[ 1 ][ 0 ] *= invDet;
invMvm[ 1 ][ 1 ] *= invDet;
invMvm[ 1 ][ 2 ] *= invDet;
invMvm[ 2 ][ 0 ] *= invDet;
invMvm[ 2 ][ 1 ] *= invDet;
invMvm[ 2 ][ 2 ] *= invDet;
// (invTx,invTy,invTz) = -(tx,ty,tz) * Inverse(RS) ----------------------------------------------------------------
invMvm[ 3 ][ 0 ] = -( mvm( 3, 0 ) * invMvm[ 0 ][ 0 ] + mvm( 3, 1 ) * invMvm[ 1 ][ 0 ] + mvm( 3, 2 ) * invMvm[ 2 ][ 0 ] );
invMvm[ 3 ][ 1 ] = -( mvm( 3, 0 ) * invMvm[ 0 ][ 1 ] + mvm( 3, 1 ) * invMvm[ 1 ][ 1 ] + mvm( 3, 2 ) * invMvm[ 2 ][ 1 ] );
invMvm[ 3 ][ 2 ] = -( mvm( 3, 0 ) * invMvm[ 0 ][ 2 ] + mvm( 3, 1 ) * invMvm[ 1 ][ 2 ] + mvm( 3, 2 ) * invMvm[ 2 ][ 2 ] );
if ( m_type == PERSPECTIVE )
{
// origin = (0,0,0,1) * Inverse(mvm) --------------------------------------------------------------------------
m_origin.s[ 0 ] = static_cast< cl_float >( invMvm[ 3 ][ 0 ] );
m_origin.s[ 1 ] = static_cast< cl_float >( invMvm[ 3 ][ 1 ] );
m_origin.s[ 2 ] = static_cast< cl_float >( invMvm[ 3 ][ 2 ] );
m_origin.s[ 3 ] = static_cast< cl_float >( 1.0f );
// originToLowerLeft = (left,bottom,-near,0) * Inverse(mvm) ---------------------------------------------------
m_originToLowerLeft.s[ 0 ] = static_cast< cl_float >( pLeft * invMvm[ 0 ][ 0 ] + pBottom * invMvm[ 1 ][ 0 ] - pNear * invMvm[ 2 ][ 0 ] );
m_originToLowerLeft.s[ 1 ] = static_cast< cl_float >( pLeft * invMvm[ 0 ][ 1 ] + pBottom * invMvm[ 1 ][ 1 ] - pNear * invMvm[ 2 ][ 1 ] );
m_originToLowerLeft.s[ 2 ] = static_cast< cl_float >( pLeft * invMvm[ 0 ][ 2 ] + pBottom * invMvm[ 1 ][ 2 ] - pNear * invMvm[ 2 ][ 2 ] );
m_originToLowerLeft.s[ 3 ] = static_cast< cl_float >( 0.0f );
}
else
{
// origin = (left,bottom,0,1) * Inverse(mvm) ------------------------------------------------------------------
m_origin.s[ 0 ] = static_cast< cl_float >( pLeft * invMvm[ 0 ][ 0 ] + pBottom * invMvm[ 1 ][ 0 ] + invMvm[ 3 ][ 0 ] );
m_origin.s[ 1 ] = static_cast< cl_float >( pLeft * invMvm[ 0 ][ 1 ] + pBottom * invMvm[ 1 ][ 1 ] + invMvm[ 3 ][ 1 ] );
m_origin.s[ 2 ] = static_cast< cl_float >( pLeft * invMvm[ 0 ][ 2 ] + pBottom * invMvm[ 1 ][ 2 ] + invMvm[ 3 ][ 2 ] );
m_origin.s[ 3 ] = static_cast< cl_float >( 0.0f );
// originToLowerLeft = (0,0,-near,0) * Inverse(mvm) -----------------------------------------------------------
m_originToLowerLeft.s[ 0 ] = static_cast< cl_float >( -pNear * invMvm[ 2 ][ 0 ] );
m_originToLowerLeft.s[ 1 ] = static_cast< cl_float >( -pNear * invMvm[ 2 ][ 1 ] );
m_originToLowerLeft.s[ 2 ] = static_cast< cl_float >( -pNear * invMvm[ 2 ][ 2 ] );
m_originToLowerLeft.s[ 3 ] = static_cast< cl_float >( 0.0f );
}
// edgeX = (right - left,0,0,0) * Inverse(mvm) --------------------------------------------------------------------
m_edgeX.s[ 0 ] = static_cast< cl_float >( ( pRight - pLeft ) * invMvm[ 0 ][ 0 ] );
m_edgeX.s[ 1 ] = static_cast< cl_float >( ( pRight - pLeft ) * invMvm[ 0 ][ 1 ] );
m_edgeX.s[ 2 ] = static_cast< cl_float >( ( pRight - pLeft ) * invMvm[ 0 ][ 2 ] );
m_edgeX.s[ 3 ] = static_cast< cl_float >( 0.0f );
// edgeY = (0,top - bottom,0,0) * Inverse(mvm) --------------------------------------------------------------------
m_edgeY.s[ 0 ] = static_cast< cl_float >( ( pTop - pBottom ) * invMvm[ 1 ][ 0 ] );
m_edgeY.s[ 1 ] = static_cast< cl_float >( ( pTop - pBottom ) * invMvm[ 1 ][ 1 ] );
m_edgeY.s[ 2 ] = static_cast< cl_float >( ( pTop - pBottom ) * invMvm[ 1 ][ 2 ] );
m_edgeY.s[ 3 ] = static_cast< cl_float >( 0.0f );
}
WGEModuleCL::CLViewData::CLViewData(): m_width( 0 ), m_height( 0 ), m_buffers( 2 )
{
// initialize
}
WGEModuleCL::WGEModuleCL(): Referenced(), m_node( 0 ), m_boundComputed( false )
{
// initialize
}
WGEModuleCL::~WGEModuleCL()
{
// clean up
}
void WGEModuleCL::dirtyBound()
{
m_boundComputed = false;
if ( m_node != 0 )
{
m_node->dirtyBound();
}
}
osg::BoundingBox WGEModuleCL::computeBoundingBox() const
{
return osg::BoundingBox();
}
void WGEModuleCL::changeCLData( const CLDataChangeCallback& callback )
{
osg::buffered_object< WGERenderNodeCL::PerContextInformation >& perContextInfos = m_node->m_perContextInformation;
unsigned int size = perContextInfos.size();
for ( unsigned int i = 0; i < size; i++ )
{
WGERenderNodeCL::PerContextInformation& perContextInfo = perContextInfos[ i ];
if ( !perContextInfo.m_invalid )
{
callback.change( perContextInfo.m_clViewData, *perContextInfo.m_clData );
}
}
}
cl::NDRange WGEModuleCL::computeGlobalWorkSize( const cl::NDRange& localWorkSize, const cl::NDRange& workItems ) const
{
if ( localWorkSize.dimensions() != workItems.dimensions() )
{
return cl::NDRange();
}
size_t dimensions = localWorkSize.dimensions();
// check validity -------------------------------------------------------------------------------------------------
for ( unsigned int i = 0; i < dimensions; i++ )
{
if ( ( localWorkSize[ i ] == 0 ) || ( workItems[ i ] == 0 ) )
{
return cl::NDRange();
}
}
// compute global work size ---------------------------------------------------------------------------------------
size_t globalSize[ 3 ];
for ( unsigned int i = 0; i < dimensions; i++ )
{
globalSize[ i ] = workItems[ i ] - workItems[ i ] % localWorkSize[ i ];
if ( globalSize[ i ] != workItems[ i ] )
{
globalSize[ i ] += localWorkSize[ i ];
}
}