Fixed shadows warnings

This commit is contained in:
Robert Osfield 2016-05-26 11:13:56 +01:00
parent 80e318ce15
commit dbce12842e
12 changed files with 50 additions and 56 deletions

View File

@ -500,9 +500,9 @@ osg::Image* createSpotLightImage(const osg::Vec4& centerColour, const osg::Vec4&
{ {
float dx = (float(c) - mid)*div; float dx = (float(c) - mid)*div;
float dy = (float(r) - mid)*div; float dy = (float(r) - mid)*div;
float r = powf(1.0f - sqrtf(dx*dx + dy*dy), power); float pr = powf(1.0f - sqrtf(dx*dx + dy*dy), power);
if (r < 0.0f) r = 0.0f; if (pr < 0.0f) pr = 0.0f;
osg::Vec4 color = centerColour*r + backgroudColour*(1.0f - r); osg::Vec4 color = centerColour*pr + backgroudColour*(1.0f - pr);
*ptr++ = (unsigned char)((color[0])*255.0f); *ptr++ = (unsigned char)((color[0])*255.0f);
*ptr++ = (unsigned char)((color[1])*255.0f); *ptr++ = (unsigned char)((color[1])*255.0f);
*ptr++ = (unsigned char)((color[2])*255.0f); *ptr++ = (unsigned char)((color[2])*255.0f);

View File

@ -108,7 +108,7 @@ typedef vector<BufferConfig> BufferConfigList;
vector<FboConfig> validConfigs; vector<FboConfig> validConfigs;
// Ugly global variables for the viewport width and height // Ugly global variables for the viewport width and height
int width, height; // int width, height;
// This is only used when testing possible frame buffer configurations // This is only used when testing possible frame buffer configurations
// to find valid ones. // to find valid ones.
@ -406,10 +406,10 @@ AppState::AppState(osgViewer::Viewer* viewer_)
void AppState::setStateFromConfig(const FboConfig& config) void AppState::setStateFromConfig(const FboConfig& config)
{ {
Camera* camera = viewer->getSlave(0)._camera.get(); Camera* cam = viewer->getSlave(0)._camera.get();
setAttachmentsFromConfig(camera, config); setAttachmentsFromConfig(cam, config);
osgViewer::Renderer* renderer osgViewer::Renderer* renderer
= dynamic_cast<osgViewer::Renderer*>(camera->getRenderer()); = dynamic_cast<osgViewer::Renderer*>(cam->getRenderer());
if (renderer) if (renderer)
renderer->setCameraRequiresSetUp(true); renderer->setCameraRequiresSetUp(true);
if (configText.valid()) if (configText.valid())
@ -954,8 +954,8 @@ int main(int argc, char **argv)
return 1; return 1;
gc->setResizedCallback(new ResizedCallback(appState.get())); gc->setResizedCallback(new ResizedCallback(appState.get()));
const GraphicsContext::Traits* traits = gc->getTraits(); const GraphicsContext::Traits* traits = gc->getTraits();
width = traits->width; int width = traits->width;
height = traits->height; int height = traits->height;
if (arguments.argc()<=1) if (arguments.argc()<=1)
{ {
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);

View File

@ -437,11 +437,11 @@ int main(int argv, char **argc)
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments); osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
if (loadedModel.valid()) group->addChild(loadedModel); if (loadedModel.valid()) group->addChild(loadedModel);
for(Tracks::iterator itr = tracks.begin(); for(Tracks::iterator titr = tracks.begin();
itr != tracks.end(); titr != tracks.end();
++itr) ++titr)
{ {
Track* track = itr->get(); Track* track = titr->get();
group->addChild(createTrackModel(track, osg::Vec4(1.0,1.0,1.0,1.0))); group->addChild(createTrackModel(track, osg::Vec4(1.0,1.0,1.0,1.0)));
@ -547,11 +547,11 @@ int main(int argv, char **argc)
fout<<"<?xml version=\"1.0\" encoding=\"utf-8\"?><gpx version=\"1.0\" creator=\"osggpx\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.topografix.com/GPX/1/0\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd\">"<<std::endl; fout<<"<?xml version=\"1.0\" encoding=\"utf-8\"?><gpx version=\"1.0\" creator=\"osggpx\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.topografix.com/GPX/1/0\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd\">"<<std::endl;
for(Tracks::iterator itr = tracks.begin(); for(Tracks::iterator titr = tracks.begin();
itr != tracks.end(); titr != tracks.end();
++itr) ++titr)
{ {
Track* track = itr->get(); Track* track = titr->get();
fout<<"<trk>"<<std::endl; fout<<"<trk>"<<std::endl;
fout<<"<desc>The track description</desc>"<<std::endl; fout<<"<desc>The track description</desc>"<<std::endl;

View File

@ -174,10 +174,10 @@ osg::Camera* createHUD()
geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4)); geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4));
osg::StateSet* stateset = geom->getOrCreateStateSet(); osg::StateSet* ss = geom->getOrCreateStateSet();
stateset->setMode(GL_BLEND,osg::StateAttribute::ON); ss->setMode(GL_BLEND,osg::StateAttribute::ON);
//stateset->setAttribute(new osg::PolygonOffset(1.0f,1.0f),osg::StateAttribute::ON); //ss->setAttribute(new osg::PolygonOffset(1.0f,1.0f),osg::StateAttribute::ON);
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); ss->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
geode->addDrawable(geom); geode->addDrawable(geom);
} }

View File

@ -411,8 +411,8 @@ void DepthPeeling::createPeeling()
_compositeCamera->setViewMatrix(osg::Matrix()); _compositeCamera->setViewMatrix(osg::Matrix());
_compositeCamera->setProjectionMatrix(osg::Matrix::ortho2D(0, 1, 0, 1)); _compositeCamera->setProjectionMatrix(osg::Matrix::ortho2D(0, 1, 0, 1));
_compositeCamera->setCullCallback(new CullCallback(0, 0)); _compositeCamera->setCullCallback(new CullCallback(0, 0));
osg::StateSet* stateSet = _compositeCamera->getOrCreateStateSet(); osg::StateSet* ss = _compositeCamera->getOrCreateStateSet();
stateSet->setRenderBinDetails(100, "TraversalOrderBin", osg::StateSet::OVERRIDE_RENDERBIN_DETAILS); ss->setRenderBinDetails(100, "TraversalOrderBin", osg::StateSet::OVERRIDE_RENDERBIN_DETAILS);
_root->addChild(_compositeCamera.get()); _root->addChild(_compositeCamera.get());
// solid geometry is blended first, transparency layers are blended in back to front order. // solid geometry is blended first, transparency layers are blended in back to front order.

View File

@ -127,9 +127,9 @@ osg::Image* createBillboardImage(const osg::Vec4& centerColour, unsigned int siz
{ {
float dx = (float(c) - mid)*div; float dx = (float(c) - mid)*div;
float dy = (float(r) - mid)*div; float dy = (float(r) - mid)*div;
float r = powf(1.0f-sqrtf(dx*dx+dy*dy),power); float pr = powf(1.0f-sqrtf(dx*dx+dy*dy),power);
if (r<0.0f) r=0.0f; if (pr<0.0f) r=0.0f;
osg::Vec4 color = centerColour*r+backgroundColour*(1.0f-r); osg::Vec4 color = centerColour*pr+backgroundColour*(1.0f-pr);
// color.set(1.0f,1.0f,1.0f,0.5f); // color.set(1.0f,1.0f,1.0f,0.5f);
*ptr++ = (unsigned char)((color[0])*255.0f); *ptr++ = (unsigned char)((color[0])*255.0f);
*ptr++ = (unsigned char)((color[1])*255.0f); *ptr++ = (unsigned char)((color[1])*255.0f);

View File

@ -371,19 +371,19 @@ int main( int argc, char** argv )
} }
else else
{ {
osg::Camera* camera = viewer.getCamera(); osg::Camera* viewer_camera = viewer.getCamera();
if ( !useLatLongHeight ) computeViewMatrix( camera, eye, hpr ); if ( !useLatLongHeight ) computeViewMatrix( viewer_camera, eye, hpr );
else computeViewMatrixOnEarth( camera, scene.get(), latLongHeight, hpr ); else computeViewMatrixOnEarth( viewer_camera, scene.get(), latLongHeight, hpr );
osg::ref_ptr<CustomRenderer> renderer = new CustomRenderer( camera ); osg::ref_ptr<CustomRenderer> renderer = new CustomRenderer( viewer_camera );
camera->setRenderer( renderer.get() ); viewer_camera->setRenderer( renderer.get() );
viewer.setThreadingModel( osgViewer::Viewer::SingleThreaded ); viewer.setThreadingModel( osgViewer::Viewer::SingleThreaded );
// Realize and initiate the first PagedLOD request // Realize and initiate the first PagedLOD request
viewer.realize(); viewer.realize();
viewer.frame(); viewer.frame();
printer->init( camera ); printer->init( viewer_camera );
while ( !printer->done() ) while ( !printer->done() )
{ {
viewer.advance(); viewer.advance();

View File

@ -1108,7 +1108,7 @@ int main(int argc, char** argv)
if (fov!=0.0) if (fov!=0.0)
{ {
double fovy, aspectRatio, zNear, zFar; double fovy, aspectRatio;
viewer.getCamera()->getProjectionMatrix().getPerspective(fovy, aspectRatio, zNear, zFar); viewer.getCamera()->getProjectionMatrix().getPerspective(fovy, aspectRatio, zNear, zFar);
std::cout << "Setting FOV to " << fov << std::endl; std::cout << "Setting FOV to " << fov << std::endl;
@ -1144,8 +1144,6 @@ int main(int argc, char** argv)
while (!viewer.done()) while (!viewer.done())
{ {
{ {
osgShadow::MinimalShadowMap * msm = dynamic_cast<osgShadow::MinimalShadowMap*>( shadowedScene->getShadowTechnique() );
if( msm ) { if( msm ) {
// If scene decorated by CoordinateSystemNode try to find localToWorld // If scene decorated by CoordinateSystemNode try to find localToWorld
@ -1198,8 +1196,6 @@ int main(int argc, char** argv)
char filename[256]; char filename[256];
std::sprintf( filename, "shadowDump%d.osgt", dumpFileNo ); std::sprintf( filename, "shadowDump%d.osgt", dumpFileNo );
osgShadow::MinimalShadowMap * msm = dynamic_cast<osgShadow::MinimalShadowMap*>( shadowedScene->getShadowTechnique() );
if( msm ) msm->setDebugDump( filename ); if( msm ) msm->setDebugDump( filename );
} }

View File

@ -54,9 +54,9 @@ osg::Image* createSpotLightImage(const osg::Vec4& centerColour, const osg::Vec4&
{ {
float dx = (float(c) - mid)*div; float dx = (float(c) - mid)*div;
float dy = (float(r) - mid)*div; float dy = (float(r) - mid)*div;
float r = powf(1.0f-sqrtf(dx*dx+dy*dy),power); float pr = powf(1.0f-sqrtf(dx*dx+dy*dy),power);
if (r<0.0f) r=0.0f; if (pr<0.0f) pr=0.0f;
osg::Vec4 color = centerColour*r+backgroudColour*(1.0f-r); osg::Vec4 color = centerColour*r+backgroudColour*(1.0f-pr);
*ptr++ = (unsigned char)((color[0])*255.0f); *ptr++ = (unsigned char)((color[0])*255.0f);
*ptr++ = (unsigned char)((color[1])*255.0f); *ptr++ = (unsigned char)((color[1])*255.0f);
*ptr++ = (unsigned char)((color[2])*255.0f); *ptr++ = (unsigned char)((color[2])*255.0f);

View File

@ -55,8 +55,6 @@
#include <iostream> #include <iostream>
typedef std::vector< osg::ref_ptr<osg::GraphicsThread> > GraphicsThreads;
struct ReleaseBlockOnCompileCompleted : public osgUtil::IncrementalCompileOperation::CompileCompletedCallback struct ReleaseBlockOnCompileCompleted : public osgUtil::IncrementalCompileOperation::CompileCompletedCallback
{ {

View File

@ -22,10 +22,10 @@ VirtualProgram::VirtualProgram( unsigned int mask ) : _mask( mask )
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
VirtualProgram::VirtualProgram VirtualProgram::VirtualProgram
( const VirtualProgram& VirtualProgram, const osg::CopyOp& copyop ): ( const VirtualProgram& vp, const osg::CopyOp& copyop ):
osg::Program( VirtualProgram, copyop ), osg::Program( vp, copyop ),
_shaderMap( VirtualProgram._shaderMap ), _shaderMap( vp._shaderMap ),
_mask( VirtualProgram._mask ) _mask( vp._mask )
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -84,9 +84,9 @@ void VirtualProgram::apply( osg::State & state ) const
#endif #endif
ShaderMap shaderMap; ShaderMap shaderMap;
for( State::AttributeVec::iterator i = av->begin(); i != av->end(); ++i ) for( State::AttributeVec::iterator ai = av->begin(); ai != av->end(); ++ai )
{ {
const osg::StateAttribute * sa = i->first; const osg::StateAttribute * sa = ai->first;
const VirtualProgram * vp = dynamic_cast< const VirtualProgram *>( sa ); const VirtualProgram * vp = dynamic_cast< const VirtualProgram *>( sa );
if( vp && ( vp->_mask & _mask ) ) { if( vp && ( vp->_mask & _mask ) ) {

View File

@ -766,7 +766,7 @@ int main( int argc, char **argv )
{ {
if (!arguments.isOption(pos)) if (!arguments.isOption(pos))
{ {
std::string filename = arguments[pos]; filename = arguments[pos];
if (osgDB::getLowerCaseFileExtension(filename)=="dicom") if (osgDB::getLowerCaseFileExtension(filename)=="dicom")
{ {
// not an option so assume string is a filename. // not an option so assume string is a filename.