Ran script to remove trailing spaces and tabs
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
*
|
||||
* This library 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
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
#include <osgUtil/SceneView>
|
||||
@@ -93,7 +93,7 @@ static const GLubyte patternHorzEven[] = {
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
// 32 x 32 bit array every row is a horizontal line of pixels
|
||||
// and the (bitwise) columns a vertical line
|
||||
// and the (bitwise) columns a vertical line
|
||||
// The following is a checkerboard pattern
|
||||
static const GLubyte patternCheckerboard[] = {
|
||||
0x55, 0x55, 0x55, 0x55,
|
||||
@@ -137,25 +137,25 @@ SceneView::SceneView(DisplaySettings* ds)
|
||||
_fusionDistanceValue = 1.0f;
|
||||
|
||||
_lightingMode=NO_SCENEVIEW_LIGHT;
|
||||
|
||||
|
||||
_prioritizeTextures = false;
|
||||
|
||||
|
||||
setCamera(new Camera);
|
||||
_camera->setViewport(new Viewport);
|
||||
_camera->setClearColor(osg::Vec4(0.2f, 0.2f, 0.4f, 1.0f));
|
||||
|
||||
|
||||
_initCalled = false;
|
||||
|
||||
_camera->setDrawBuffer(GL_BACK);
|
||||
|
||||
_automaticFlush = true;
|
||||
_requiresFlush = false;
|
||||
|
||||
|
||||
_activeUniforms = DEFAULT_UNIFORMS;
|
||||
|
||||
|
||||
_previousFrameTime = 0;
|
||||
_previousSimulationTime = 0;
|
||||
|
||||
|
||||
_redrawInterlacedStereoStencilMask = true;
|
||||
_interlacedStereoStencilWidth = 0;
|
||||
_interlacedStereoStencilHeight = 0;
|
||||
@@ -173,22 +173,22 @@ SceneView::SceneView(const SceneView& rhs, const osg::CopyOp& copyop):
|
||||
_fusionDistanceValue = rhs._fusionDistanceValue;
|
||||
|
||||
_lightingMode = rhs._lightingMode;
|
||||
|
||||
|
||||
_prioritizeTextures = rhs._prioritizeTextures;
|
||||
|
||||
|
||||
_camera = rhs._camera;
|
||||
_cameraWithOwnership = rhs._cameraWithOwnership;
|
||||
|
||||
|
||||
_initCalled = false;
|
||||
|
||||
_automaticFlush = rhs._automaticFlush;
|
||||
_requiresFlush = false;
|
||||
|
||||
|
||||
_activeUniforms = rhs._activeUniforms;
|
||||
|
||||
|
||||
_previousFrameTime = 0;
|
||||
_previousSimulationTime = 0;
|
||||
|
||||
|
||||
_redrawInterlacedStereoStencilMask = rhs._redrawInterlacedStereoStencilMask;
|
||||
_interlacedStereoStencilWidth = rhs._interlacedStereoStencilWidth;
|
||||
_interlacedStereoStencilHeight = rhs._interlacedStereoStencilHeight;
|
||||
@@ -227,7 +227,7 @@ void SceneView::setDefaults(unsigned int options)
|
||||
// enable lighting by default.
|
||||
_globalStateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && defined(OSG_GL_FIXED_FUNCTION_AVAILABLE)
|
||||
osg::LightModel* lightmodel = new osg::LightModel;
|
||||
lightmodel->setAmbientIntensity(osg::Vec4(0.1f,0.1f,0.1f,1.0f));
|
||||
@@ -238,9 +238,9 @@ void SceneView::setDefaults(unsigned int options)
|
||||
{
|
||||
_lightingMode = NO_SCENEVIEW_LIGHT;
|
||||
}
|
||||
|
||||
|
||||
_renderInfo.setState(new State);
|
||||
|
||||
|
||||
_stateGraph = new StateGraph;
|
||||
_renderStage = new RenderStage;
|
||||
|
||||
@@ -248,14 +248,14 @@ void SceneView::setDefaults(unsigned int options)
|
||||
if (options & COMPILE_GLOBJECTS_AT_INIT)
|
||||
{
|
||||
GLObjectsVisitor::Mode dlvMode = GLObjectsVisitor::COMPILE_DISPLAY_LISTS |
|
||||
GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES |
|
||||
GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES |
|
||||
GLObjectsVisitor::CHECK_BLACK_LISTED_MODES;
|
||||
|
||||
#ifdef __sgi
|
||||
dlvMode = GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES;
|
||||
#endif
|
||||
|
||||
// sgi's IR graphics has a problem with lighting and display lists, as it seems to store
|
||||
// sgi's IR graphics has a problem with lighting and display lists, as it seems to store
|
||||
// lighting state with the display list, and the display list visitor doesn't currently apply
|
||||
// state before creating display lists. So will disable the init visitor default, this won't
|
||||
// affect functionality since the display lists will be created as and when needed.
|
||||
@@ -264,7 +264,7 @@ void SceneView::setDefaults(unsigned int options)
|
||||
_initVisitor = dlv;
|
||||
|
||||
}
|
||||
|
||||
|
||||
_updateVisitor = new UpdateVisitor;
|
||||
|
||||
_cullVisitor = CullVisitor::create();
|
||||
@@ -280,7 +280,7 @@ void SceneView::setDefaults(unsigned int options)
|
||||
texenv->setMode(osg::TexEnv::MODULATE);
|
||||
_globalStateSet->setTextureAttributeAndModes(0,texenv, osg::StateAttribute::ON);
|
||||
#endif
|
||||
|
||||
|
||||
_camera->setClearColor(osg::Vec4(0.2f, 0.2f, 0.4f, 1.0f));
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ void SceneView::setCamera(osg::Camera* camera, bool assumeOwnershipOfCamera)
|
||||
{
|
||||
OSG_NOTICE<<"Warning: attempt to assign a NULL camera to SceneView not permitted."<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
if (assumeOwnershipOfCamera)
|
||||
{
|
||||
_cameraWithOwnership = _camera.get();
|
||||
@@ -308,12 +308,12 @@ void SceneView::setCamera(osg::Camera* camera, bool assumeOwnershipOfCamera)
|
||||
void SceneView::setSceneData(osg::Node* node)
|
||||
{
|
||||
// take a temporary reference to node to prevent the possibility
|
||||
// of it getting deleted when when we do the camera clear of children.
|
||||
// of it getting deleted when when we do the camera clear of children.
|
||||
osg::ref_ptr<osg::Node> temporaryRefernce = node;
|
||||
|
||||
|
||||
// remove pre existing children
|
||||
_camera->removeChildren(0, _camera->getNumChildren());
|
||||
|
||||
|
||||
// add the new one in.
|
||||
_camera->addChild(node);
|
||||
}
|
||||
@@ -330,24 +330,24 @@ void SceneView::init()
|
||||
{
|
||||
_initVisitor->reset();
|
||||
_initVisitor->setFrameStamp(_frameStamp.get());
|
||||
|
||||
|
||||
GLObjectsVisitor* dlv = dynamic_cast<GLObjectsVisitor*>(_initVisitor.get());
|
||||
if (dlv) dlv->setState(_renderInfo.getState());
|
||||
|
||||
|
||||
if (_frameStamp.valid())
|
||||
{
|
||||
_initVisitor->setTraversalNumber(_frameStamp->getFrameNumber());
|
||||
}
|
||||
|
||||
|
||||
_camera->accept(*_initVisitor.get());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void SceneView::update()
|
||||
{
|
||||
if (_camera.valid() && _updateVisitor.valid())
|
||||
{
|
||||
{
|
||||
_updateVisitor->reset();
|
||||
|
||||
_updateVisitor->setFrameStamp(_frameStamp.get());
|
||||
@@ -357,9 +357,9 @@ void SceneView::update()
|
||||
{
|
||||
_updateVisitor->setTraversalNumber(_frameStamp->getFrameNumber());
|
||||
}
|
||||
|
||||
|
||||
_camera->accept(*_updateVisitor.get());
|
||||
|
||||
|
||||
// now force a recompute of the bounding volume while we are still in
|
||||
// the read/write app phase, this should prevent the need to recompute
|
||||
// the bounding volumes from within the cull traversal which may be
|
||||
@@ -376,43 +376,43 @@ void SceneView::updateUniforms()
|
||||
}
|
||||
|
||||
if (!_localStateSet) return;
|
||||
|
||||
|
||||
if ((_activeUniforms & FRAME_NUMBER_UNIFORM) && _frameStamp.valid())
|
||||
{
|
||||
osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_FrameNumber",osg::Uniform::UNSIGNED_INT);
|
||||
uniform->set(_frameStamp->getFrameNumber());
|
||||
uniform->set(_frameStamp->getFrameNumber());
|
||||
}
|
||||
|
||||
|
||||
if ((_activeUniforms & FRAME_TIME_UNIFORM) && _frameStamp.valid())
|
||||
{
|
||||
osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_FrameTime",osg::Uniform::FLOAT);
|
||||
uniform->set(static_cast<float>(_frameStamp->getReferenceTime()));
|
||||
}
|
||||
|
||||
|
||||
if ((_activeUniforms & DELTA_FRAME_TIME_UNIFORM) && _frameStamp.valid())
|
||||
{
|
||||
float delta_frame_time = (_previousFrameTime != 0.0) ? static_cast<float>(_frameStamp->getReferenceTime()-_previousFrameTime) : 0.0f;
|
||||
_previousFrameTime = _frameStamp->getReferenceTime();
|
||||
|
||||
|
||||
osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_DeltaFrameTime",osg::Uniform::FLOAT);
|
||||
uniform->set(delta_frame_time);
|
||||
}
|
||||
|
||||
|
||||
if ((_activeUniforms & SIMULATION_TIME_UNIFORM) && _frameStamp.valid())
|
||||
{
|
||||
osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_SimulationTime",osg::Uniform::FLOAT);
|
||||
uniform->set(static_cast<float>(_frameStamp->getSimulationTime()));
|
||||
}
|
||||
|
||||
|
||||
if ((_activeUniforms & DELTA_SIMULATION_TIME_UNIFORM) && _frameStamp.valid())
|
||||
{
|
||||
float delta_simulation_time = (_previousSimulationTime != 0.0) ? static_cast<float>(_frameStamp->getSimulationTime()-_previousSimulationTime) : 0.0f;
|
||||
_previousSimulationTime = _frameStamp->getSimulationTime();
|
||||
|
||||
|
||||
osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_DeltaSimulationTime",osg::Uniform::FLOAT);
|
||||
uniform->set(delta_simulation_time);
|
||||
}
|
||||
|
||||
|
||||
if (_activeUniforms & VIEW_MATRIX_UNIFORM)
|
||||
{
|
||||
osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_ViewMatrix",osg::Uniform::FLOAT_MAT4);
|
||||
@@ -661,7 +661,7 @@ void SceneView::computeRightEyeViewport(const osg::Viewport *viewport)
|
||||
void SceneView::setLightingMode(LightingMode mode)
|
||||
{
|
||||
if (mode==_lightingMode) return;
|
||||
|
||||
|
||||
if (_lightingMode!=NO_SCENEVIEW_LIGHT)
|
||||
{
|
||||
// remove GL_LIGHTING mode
|
||||
@@ -681,7 +681,7 @@ void SceneView::setLightingMode(LightingMode mode)
|
||||
#if defined(OSG_GL_FIXED_FUNCTION_AVAILABLE)
|
||||
// add GL_LIGHTING mode
|
||||
_globalStateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
||||
if (_light.valid())
|
||||
if (_light.valid())
|
||||
{
|
||||
_globalStateSet->setAssociatedModes(_light.get(), osg::StateAttribute::ON);
|
||||
}
|
||||
@@ -691,31 +691,31 @@ void SceneView::setLightingMode(LightingMode mode)
|
||||
|
||||
void SceneView::inheritCullSettings(const osg::CullSettings& settings, unsigned int inheritanceMask)
|
||||
{
|
||||
if (_camera.valid() && _camera->getView())
|
||||
if (_camera.valid() && _camera->getView())
|
||||
{
|
||||
if (inheritanceMask & osg::CullSettings::LIGHTING_MODE)
|
||||
{
|
||||
LightingMode newLightingMode = _lightingMode;
|
||||
|
||||
|
||||
switch(_camera->getView()->getLightingMode())
|
||||
{
|
||||
case(osg::View::NO_LIGHT): newLightingMode = NO_SCENEVIEW_LIGHT; break;
|
||||
case(osg::View::HEADLIGHT): newLightingMode = HEADLIGHT; break;
|
||||
case(osg::View::SKY_LIGHT): newLightingMode = SKY_LIGHT; break;
|
||||
}
|
||||
|
||||
|
||||
if (newLightingMode != _lightingMode)
|
||||
{
|
||||
setLightingMode(newLightingMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (inheritanceMask & osg::CullSettings::LIGHT)
|
||||
{
|
||||
setLight(_camera->getView()->getLight());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
osg::CullSettings::inheritCullSettings(settings, inheritanceMask);
|
||||
}
|
||||
|
||||
@@ -739,17 +739,17 @@ void SceneView::cull()
|
||||
// applications which is ok for most apps, but not multiple context/pipe applications.
|
||||
_renderInfo.setState(new osg::State);
|
||||
}
|
||||
|
||||
|
||||
osg::State* state = _renderInfo.getState();
|
||||
|
||||
if (!_localStateSet)
|
||||
{
|
||||
_localStateSet = new osg::StateSet;
|
||||
}
|
||||
|
||||
|
||||
// we in theory should be able to be able to bypass reset, but we'll call it just incase.
|
||||
//_state->reset();
|
||||
|
||||
|
||||
state->setFrameStamp(_frameStamp.get());
|
||||
state->setDisplaySettings(_displaySettings.get());
|
||||
|
||||
@@ -770,7 +770,7 @@ void SceneView::cull()
|
||||
_renderStage = new RenderStage;
|
||||
}
|
||||
|
||||
if (_displaySettings.valid() && _displaySettings->getStereo())
|
||||
if (_displaySettings.valid() && _displaySettings->getStereo())
|
||||
{
|
||||
|
||||
if (_displaySettings->getStereoMode()==osg::DisplaySettings::LEFT_EYE)
|
||||
@@ -813,7 +813,7 @@ void SceneView::cull()
|
||||
if (!_cullVisitorRight.valid()) _cullVisitorRight = dynamic_cast<CullVisitor*>(_cullVisitor->clone());
|
||||
if (!_stateGraphRight.valid()) _stateGraphRight = dynamic_cast<StateGraph*>(_stateGraph->cloneType());
|
||||
if (!_renderStageRight.valid()) _renderStageRight = dynamic_cast<RenderStage*>(_renderStage->clone(osg::CopyOp::DEEP_COPY_ALL));
|
||||
|
||||
|
||||
_cullVisitorLeft->setDatabaseRequestHandler(_cullVisitor->getDatabaseRequestHandler());
|
||||
_cullVisitorLeft->setClampProjectionMatrixCallback(_cullVisitor->getClampProjectionMatrixCallback());
|
||||
_cullVisitorLeft->setTraversalMask(_cullMaskLeft);
|
||||
@@ -827,7 +827,7 @@ void SceneView::cull()
|
||||
_cullVisitorRight->setTraversalMask(_cullMaskRight);
|
||||
computeRightEyeViewport(getViewport());
|
||||
computeNearFar = cullStage(computeRightEyeProjection(getProjectionMatrix()),computeRightEyeView(getViewMatrix()),_cullVisitorRight.get(),_stateGraphRight.get(),_renderStageRight.get(),_viewportRight.get());
|
||||
|
||||
|
||||
if (computeNearFar)
|
||||
{
|
||||
CullVisitor::value_type zNear = osg::minimum(_cullVisitorLeft->getCalculatedNearPlane(),_cullVisitorRight->getCalculatedNearPlane());
|
||||
@@ -851,7 +851,7 @@ void SceneView::cull()
|
||||
_cullVisitor->clampProjectionMatrix(getProjectionMatrix(),zNear,zFar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -868,14 +868,14 @@ bool SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
if (_camera->containsOccluderNodes())
|
||||
{
|
||||
//std::cout << "Scene graph contains occluder nodes, searching for them"<<std::endl;
|
||||
|
||||
|
||||
|
||||
|
||||
if (!_collectOccludersVisitor) _collectOccludersVisitor = new osg::CollectOccludersVisitor;
|
||||
|
||||
|
||||
_collectOccludersVisitor->inheritCullSettings(*this);
|
||||
|
||||
|
||||
_collectOccludersVisitor->reset();
|
||||
|
||||
|
||||
_collectOccludersVisitor->setFrameStamp(_frameStamp.get());
|
||||
|
||||
// use the frame number for the traversal number.
|
||||
@@ -894,17 +894,17 @@ bool SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
_collectOccludersVisitor->popModelViewMatrix();
|
||||
_collectOccludersVisitor->popProjectionMatrix();
|
||||
_collectOccludersVisitor->popViewport();
|
||||
|
||||
|
||||
// sort the occluder from largest occluder volume to smallest.
|
||||
_collectOccludersVisitor->removeOccludedOccluders();
|
||||
|
||||
|
||||
|
||||
|
||||
OSG_DEBUG << "finished searching for occluder - found "<<_collectOccludersVisitor->getCollectedOccluderSet().size()<<std::endl;
|
||||
|
||||
|
||||
cullVisitor->getOccluderList().clear();
|
||||
std::copy(_collectOccludersVisitor->getCollectedOccluderSet().begin(),_collectOccludersVisitor->getCollectedOccluderSet().end(), std::back_insert_iterator<CullStack::OccluderList>(cullVisitor->getOccluderList()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
cullVisitor->reset();
|
||||
@@ -941,8 +941,8 @@ bool SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
renderStage->setClearAccum(_camera->getClearAccum());
|
||||
renderStage->setClearStencil(_camera->getClearStencil());
|
||||
renderStage->setClearMask(_camera->getClearMask());
|
||||
|
||||
#if 1
|
||||
|
||||
#if 1
|
||||
renderStage->setCamera(_camera.get());
|
||||
#endif
|
||||
|
||||
@@ -959,9 +959,9 @@ bool SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (_globalStateSet.valid()) cullVisitor->pushStateSet(_globalStateSet.get());
|
||||
if (_secondaryStateSet.valid()) cullVisitor->pushStateSet(_secondaryStateSet.get());
|
||||
if (_localStateSet.valid()) cullVisitor->pushStateSet(_localStateSet.get());
|
||||
@@ -971,8 +971,8 @@ bool SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
cullVisitor->pushProjectionMatrix(proj.get());
|
||||
cullVisitor->pushModelViewMatrix(mv.get(),osg::Transform::ABSOLUTE_RF);
|
||||
|
||||
// traverse the scene graph to generate the rendergraph.
|
||||
// If the camera has a cullCallback execute the callback which has the
|
||||
// traverse the scene graph to generate the rendergraph.
|
||||
// If the camera has a cullCallback execute the callback which has the
|
||||
// requirement that it must traverse the camera's children.
|
||||
{
|
||||
osg::NodeCallback* callback = _camera->getCullCallback();
|
||||
@@ -988,7 +988,7 @@ bool SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
if (_localStateSet.valid()) cullVisitor->popStateSet();
|
||||
if (_secondaryStateSet.valid()) cullVisitor->popStateSet();
|
||||
if (_globalStateSet.valid()) cullVisitor->popStateSet();
|
||||
|
||||
|
||||
|
||||
renderStage->sort();
|
||||
|
||||
@@ -998,8 +998,8 @@ bool SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
// a clean has been used instead to try to minimize the amount of
|
||||
// allocation and deleteing of the StateGraph nodes.
|
||||
rendergraph->prune();
|
||||
|
||||
// set the number of dynamic objects in the scene.
|
||||
|
||||
// set the number of dynamic objects in the scene.
|
||||
_dynamicObjectCount += renderStage->computeNumberOfDynamicRenderLeaves();
|
||||
|
||||
|
||||
@@ -1010,9 +1010,9 @@ bool SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
void SceneView::releaseAllGLObjects()
|
||||
{
|
||||
if (!_camera) return;
|
||||
|
||||
|
||||
_camera->releaseGLObjects(_renderInfo.getState());
|
||||
|
||||
|
||||
// we need to reset State as it keeps handles to Program objects.
|
||||
if (_renderInfo.getState()) _renderInfo.getState()->reset();
|
||||
}
|
||||
@@ -1021,14 +1021,14 @@ void SceneView::releaseAllGLObjects()
|
||||
void SceneView::flushAllDeletedGLObjects()
|
||||
{
|
||||
_requiresFlush = false;
|
||||
|
||||
|
||||
osg::flushAllDeletedGLObjects(getState()->getContextID());
|
||||
}
|
||||
|
||||
void SceneView::flushDeletedGLObjects(double& availableTime)
|
||||
{
|
||||
// OSG_NOTICE<<"SceneView::flushDeletedGLObjects(availableTime="<<availableTime<<")"<<std::endl;
|
||||
|
||||
|
||||
osg::State* state = _renderInfo.getState();
|
||||
|
||||
_requiresFlush = false;
|
||||
@@ -1057,7 +1057,7 @@ void SceneView::draw()
|
||||
// and texture objects is deferred until the OpenGL context is the correct
|
||||
// context for when the object were originally created. Here we know what
|
||||
// context we are in so can flush the appropriate caches.
|
||||
|
||||
|
||||
if (_requiresFlush)
|
||||
{
|
||||
double availableTime = 0.005;
|
||||
@@ -1068,9 +1068,9 @@ void SceneView::draw()
|
||||
_requiresFlush = _automaticFlush;
|
||||
|
||||
RenderLeaf* previous = NULL;
|
||||
if (_displaySettings.valid() && _displaySettings->getStereo())
|
||||
if (_displaySettings.valid() && _displaySettings->getStereo())
|
||||
{
|
||||
|
||||
|
||||
switch(_displaySettings->getStereoMode())
|
||||
{
|
||||
case(osg::DisplaySettings::QUAD_BUFFER):
|
||||
@@ -1130,10 +1130,10 @@ void SceneView::draw()
|
||||
}
|
||||
_renderStageLeft->setColorMask(cmask);
|
||||
_renderStageRight->setColorMask(cmask);
|
||||
|
||||
|
||||
_localStateSet->setAttribute(getViewport());
|
||||
|
||||
|
||||
|
||||
_renderStageLeft->drawPreRenderStages(_renderInfo,previous);
|
||||
_renderStageRight->drawPreRenderStages(_renderInfo,previous);
|
||||
|
||||
@@ -1145,7 +1145,7 @@ void SceneView::draw()
|
||||
leftColorMask = new osg::ColorMask();
|
||||
_renderStageLeft->setColorMask(leftColorMask);
|
||||
}
|
||||
|
||||
|
||||
// red
|
||||
leftColorMask->setMask(true,false,false,true);
|
||||
|
||||
@@ -1156,8 +1156,8 @@ void SceneView::draw()
|
||||
|
||||
// draw left eye.
|
||||
_renderStageLeft->draw(_renderInfo,previous);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ensure that right eye color planes are active.
|
||||
osg::ColorMask* rightColorMask = _renderStageRight->getColorMask();
|
||||
@@ -1169,7 +1169,7 @@ void SceneView::draw()
|
||||
|
||||
// cyan
|
||||
rightColorMask->setMask(false,true,true,true);
|
||||
|
||||
|
||||
// blue
|
||||
// rightColorMask->setMask(false,false,true,true);
|
||||
|
||||
@@ -1220,7 +1220,7 @@ void SceneView::draw()
|
||||
static_cast<int>(separation),
|
||||
static_cast<int>(getViewport()->height()),_renderStageLeft->getClearColor());
|
||||
|
||||
|
||||
|
||||
_localStateSet->setAttribute(_viewportLeft.get());
|
||||
_renderStageLeft->draw(_renderInfo,previous);
|
||||
|
||||
@@ -1348,8 +1348,8 @@ void SceneView::draw()
|
||||
glLoadIdentity();
|
||||
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
glLoadIdentity();
|
||||
|
||||
getViewport()->apply(*state);
|
||||
getState()->applyMode(GL_LIGHTING,false);
|
||||
getState()->applyMode(GL_DEPTH_TEST,false);
|
||||
@@ -1374,12 +1374,12 @@ void SceneView::draw()
|
||||
}
|
||||
getState()->applyMode(GL_POLYGON_STIPPLE,true);
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
glRecti(0, 0, 1, 1);
|
||||
glRecti(0, 0, 1, 1);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
getState()->applyMode(GL_POLYGON_STIPPLE,false);
|
||||
getState()->applyMode(GL_LIGHTING,true);
|
||||
getState()->applyMode(GL_DEPTH_TEST,true);
|
||||
|
||||
|
||||
_redrawInterlacedStereoStencilMask = false;
|
||||
_interlacedStereoStencilWidth = static_cast<int>(getViewport()->width());
|
||||
_interlacedStereoStencilHeight = static_cast<int>(getViewport()->height());
|
||||
@@ -1389,9 +1389,9 @@ void SceneView::draw()
|
||||
_renderStageRight->setClearMask(_renderStageRight->getClearMask() & ~(GL_STENCIL_BUFFER_BIT|GL_COLOR_BUFFER_BIT));
|
||||
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
glStencilFunc(GL_EQUAL, 0, ~0u);
|
||||
glStencilFunc(GL_EQUAL, 0, ~0u);
|
||||
_renderStageLeft->draw(_renderInfo,previous);
|
||||
|
||||
|
||||
glStencilFunc(GL_NOTEQUAL, 0, ~0u);
|
||||
_renderStageRight->draw(_renderInfo,previous);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
@@ -1442,7 +1442,7 @@ void SceneView::draw()
|
||||
_renderStage->drawPreRenderStages(_renderInfo,previous);
|
||||
_renderStage->draw(_renderInfo,previous);
|
||||
}
|
||||
|
||||
|
||||
// re apply the defalt OGL state.
|
||||
state->popAllStateSets();
|
||||
state->apply();
|
||||
@@ -1482,9 +1482,9 @@ bool SceneView::projectWindowIntoObject(const osg::Vec3& window,osg::Vec3& objec
|
||||
{
|
||||
osg::Matrix inverseMVPW;
|
||||
inverseMVPW.invert(computeMVPW());
|
||||
|
||||
|
||||
object = window*inverseMVPW;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1498,10 +1498,10 @@ bool SceneView::projectWindowXYIntoObject(int x,int y,osg::Vec3& near_point,osg:
|
||||
{
|
||||
osg::Matrix inverseMVPW;
|
||||
inverseMVPW.invert(computeMVPW());
|
||||
|
||||
|
||||
near_point = osg::Vec3(x,y,0.0f)*inverseMVPW;
|
||||
far_point = osg::Vec3(x,y,1.0f)*inverseMVPW;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1519,7 +1519,7 @@ bool SceneView::projectObjectIntoWindow(const osg::Vec3& object,osg::Vec3& windo
|
||||
const osg::Matrix SceneView::computeMVPW() const
|
||||
{
|
||||
osg::Matrix matrix( getViewMatrix() * getProjectionMatrix());
|
||||
|
||||
|
||||
if (getViewport())
|
||||
matrix.postMult(getViewport()->computeWindowMatrix());
|
||||
else
|
||||
@@ -1534,7 +1534,7 @@ void SceneView::clearArea(int x,int y,int width,int height,const osg::Vec4& colo
|
||||
viewport->setViewport(x,y,width,height);
|
||||
|
||||
_renderInfo.getState()->applyAttribute(viewport.get());
|
||||
|
||||
|
||||
glScissor( x, y, width, height );
|
||||
glEnable( GL_SCISSOR_TEST );
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
|
||||
@@ -1550,7 +1550,7 @@ void SceneView::setProjectionMatrixAsOrtho(double left, double right,
|
||||
setProjectionMatrix(osg::Matrixd::ortho(left, right,
|
||||
bottom, top,
|
||||
zNear, zFar));
|
||||
}
|
||||
}
|
||||
|
||||
void SceneView::setProjectionMatrixAsOrtho2D(double left, double right,
|
||||
double bottom, double top)
|
||||
@@ -1573,7 +1573,7 @@ void SceneView::setProjectionMatrixAsPerspective(double fovy,double aspectRatio,
|
||||
{
|
||||
setProjectionMatrix(osg::Matrixd::perspective(fovy,aspectRatio,
|
||||
zNear, zFar));
|
||||
}
|
||||
}
|
||||
|
||||
bool SceneView::getProjectionMatrixAsOrtho(double& left, double& right,
|
||||
double& bottom, double& top,
|
||||
@@ -1591,13 +1591,13 @@ bool SceneView::getProjectionMatrixAsFrustum(double& left, double& right,
|
||||
return getProjectionMatrix().getFrustum(left, right,
|
||||
bottom, top,
|
||||
zNear, zFar);
|
||||
}
|
||||
}
|
||||
|
||||
bool SceneView::getProjectionMatrixAsPerspective(double& fovy,double& aspectRatio,
|
||||
double& zNear, double& zFar) const
|
||||
{
|
||||
return getProjectionMatrix().getPerspective(fovy, aspectRatio, zNear, zFar);
|
||||
}
|
||||
}
|
||||
|
||||
void SceneView::setViewMatrixAsLookAt(const Vec3& eye,const Vec3& center,const Vec3& up)
|
||||
{
|
||||
@@ -1611,7 +1611,7 @@ void SceneView::getViewMatrixAsLookAt(Vec3& eye,Vec3& center,Vec3& up,float look
|
||||
|
||||
bool SceneView::getStats(Statistics& stats)
|
||||
{
|
||||
if (_displaySettings.valid() && _displaySettings->getStereo())
|
||||
if (_displaySettings.valid() && _displaySettings->getStereo())
|
||||
{
|
||||
switch(_displaySettings->getStereoMode())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user