Reimplemted the osgUtil::SceneView::setCalcNearFar() functionality to bring
it inline with the CullStack/CullVisitor implementation. Also added the setSmallFeatureCullingPixelSize() method and wired them up inside SceneView.cpp so they set the corresponding CullVisitor paramters. Intergrated pfImage copying change in the Performer plugin, submission sent in by Ulrich Hertlein
This commit is contained in:
@@ -463,7 +463,7 @@ public:
|
||||
{
|
||||
_hudSceneView->getRenderStage()->setClearMask(0);
|
||||
_hudSceneView->getCullVisitor()->setCullingMode(osgUtil::CullVisitor::NO_CULLING);
|
||||
_hudSceneView->setCalcNearFar(false);
|
||||
_hudSceneView->setComputeNearFarMode(osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR);
|
||||
|
||||
_hudCam = osgNew osg::Camera;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ CullStack::CullStack()
|
||||
|
||||
_cullingMode = ENABLE_ALL_CULLING;
|
||||
_LODBias = 1.0f;
|
||||
_smallFeatureCullingPixelSize = 3.0f;
|
||||
_smallFeatureCullingPixelSize = 2.0f;
|
||||
_frustumVolume=-1.0f;
|
||||
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ const bool Geode::replaceDrawable( Drawable *origDrawable, Drawable *newDrawable
|
||||
|
||||
const bool Geode::computeBound() const
|
||||
{
|
||||
BoundingBox bb;
|
||||
_bsphere.init();
|
||||
|
||||
// if (_occluder.valid()) _occluder->computeBound(bb);
|
||||
BoundingBox bb;
|
||||
|
||||
DrawableList::const_iterator itr;
|
||||
for(itr=_drawables.begin();
|
||||
@@ -119,7 +119,6 @@ const bool Geode::computeBound() const
|
||||
}
|
||||
else
|
||||
{
|
||||
_bsphere.init();
|
||||
_bsphere_computed=true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1121,8 +1121,15 @@ osg::Texture* ConvertFromPerformer::visitTexture(osg::StateSet* osgStateSet,pfTe
|
||||
{
|
||||
if (tex==NULL) return NULL;
|
||||
|
||||
osg::Texture* osgTexture = new osg::Texture;
|
||||
_pfToOsgMap[tex] = osgTexture;
|
||||
osg::Texture* osgTexture = dynamic_cast<osg::Texture*>(getOsgObject(tex));
|
||||
if (osgTexture) {
|
||||
if (osgStateSet) osgStateSet->setAttribute(osgTexture);
|
||||
return osgTexture;
|
||||
}
|
||||
|
||||
osgTexture = new osg::Texture;
|
||||
registerPfObjectForOsgObject(tex, osgTexture);
|
||||
//_pfToOsgMap[tex] = osgTexture;
|
||||
|
||||
if (osgStateSet) osgStateSet->setAttribute(osgTexture);
|
||||
|
||||
@@ -1130,24 +1137,30 @@ osg::Texture* ConvertFromPerformer::visitTexture(osg::StateSet* osgStateSet,pfTe
|
||||
int repeat_s = tex->getRepeat(PFTEX_WRAP_S);
|
||||
int repeat_t = tex->getRepeat(PFTEX_WRAP_T);
|
||||
|
||||
if (repeat_r==PFTEX_CLAMP) osgTexture->setWrap(osg::Texture::WRAP_R,osg::Texture::CLAMP);
|
||||
else osgTexture->setWrap(osg::Texture::WRAP_R,osg::Texture::REPEAT);
|
||||
if (repeat_r==PFTEX_CLAMP)
|
||||
osgTexture->setWrap(osg::Texture::WRAP_R,osg::Texture::CLAMP);
|
||||
else
|
||||
osgTexture->setWrap(osg::Texture::WRAP_R,osg::Texture::REPEAT);
|
||||
|
||||
if (repeat_s==PFTEX_CLAMP) osgTexture->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP);
|
||||
else osgTexture->setWrap(osg::Texture::WRAP_S,osg::Texture::REPEAT);
|
||||
if (repeat_s==PFTEX_CLAMP)
|
||||
osgTexture->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP);
|
||||
else
|
||||
osgTexture->setWrap(osg::Texture::WRAP_S,osg::Texture::REPEAT);
|
||||
|
||||
if (repeat_t==PFTEX_CLAMP) osgTexture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP);
|
||||
else osgTexture->setWrap(osg::Texture::WRAP_T,osg::Texture::REPEAT);
|
||||
if (repeat_t==PFTEX_CLAMP)
|
||||
osgTexture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP);
|
||||
else
|
||||
osgTexture->setWrap(osg::Texture::WRAP_T,osg::Texture::REPEAT);
|
||||
|
||||
// filter
|
||||
#if 1
|
||||
#if 1
|
||||
osgTexture->setFilter(osg::Texture::MIN_FILTER,
|
||||
getTexfilter(PFTEX_MINFILTER,
|
||||
tex->getFilter(PFTEX_MINFILTER)));
|
||||
getTexfilter(PFTEX_MINFILTER,
|
||||
tex->getFilter(PFTEX_MINFILTER)));
|
||||
osgTexture->setFilter(osg::Texture::MAG_FILTER,
|
||||
getTexfilter(PFTEX_MAGFILTER,
|
||||
tex->getFilter(PFTEX_MAGFILTER)));
|
||||
#endif
|
||||
getTexfilter(PFTEX_MAGFILTER,
|
||||
tex->getFilter(PFTEX_MAGFILTER)));
|
||||
#endif
|
||||
|
||||
// image
|
||||
std::string texName = tex->getName();
|
||||
@@ -1173,19 +1186,23 @@ osg::Texture* ConvertFromPerformer::visitTexture(osg::StateSet* osgStateSet,pfTe
|
||||
|
||||
unsigned int pixelFormat =
|
||||
comp == 1 ? GL_LUMINANCE :
|
||||
comp == 2 ? GL_LUMINANCE_ALPHA :
|
||||
comp == 3 ? GL_RGB :
|
||||
comp == 4 ? GL_RGBA : (GLenum)-1;
|
||||
comp == 2 ? GL_LUMINANCE_ALPHA :
|
||||
comp == 3 ? GL_RGB :
|
||||
comp == 4 ? GL_RGBA : (GLenum)-1;
|
||||
|
||||
unsigned int dataType = GL_UNSIGNED_BYTE;
|
||||
|
||||
// copy image data
|
||||
int size = s * t * comp;
|
||||
unsigned char* data = (unsigned char*) malloc(size);
|
||||
memcpy(data, imageData, size);
|
||||
|
||||
osg::Image* image = new osg::Image;
|
||||
image->setFileName(texName.c_str());
|
||||
image->setImage(s,t,r,
|
||||
internalFormat,
|
||||
pixelFormat,
|
||||
dataType,
|
||||
(unsigned char*)imageData);
|
||||
internalFormat,
|
||||
pixelFormat,
|
||||
dataType,data);
|
||||
|
||||
osgTexture->setImage(image);
|
||||
|
||||
|
||||
@@ -19,14 +19,13 @@ SceneView::SceneView(DisplaySettings* ds)
|
||||
{
|
||||
_displaySettings = ds;
|
||||
|
||||
_calc_nearfar = true;
|
||||
|
||||
_backgroundColor.set(0.2f, 0.2f, 0.4f, 1.0f);
|
||||
|
||||
_near_plane = 1.0f;
|
||||
_far_plane = 1.0f;
|
||||
_computeNearFar = CullVisitor::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES;
|
||||
|
||||
_lodBias = 1.0f;
|
||||
_cullingMode = osg::CullStack::ENABLE_ALL_CULLING;
|
||||
_LODBias = 1.0f;
|
||||
_smallFeatureCullingPixelSize = 2.0f;
|
||||
|
||||
_lightingMode=HEADLIGHT;
|
||||
|
||||
@@ -315,6 +314,7 @@ void SceneView::cullStage(osg::Matrix* projection,osg::Matrix* modelview,osgUtil
|
||||
if (!_initCalled) init();
|
||||
|
||||
|
||||
|
||||
// collect any occluder in the view frustum.
|
||||
if (_sceneData->containsOccluderNodes())
|
||||
{
|
||||
@@ -363,7 +363,10 @@ void SceneView::cullStage(osg::Matrix* projection,osg::Matrix* modelview,osgUtil
|
||||
cullVisitor->setTraversalNumber(_frameStamp->getFrameNumber());
|
||||
}
|
||||
|
||||
cullVisitor->setLODBias(_lodBias);
|
||||
cullVisitor->setComputeNearFarMode(_computeNearFar);
|
||||
cullVisitor->setLODBias(_LODBias);
|
||||
cullVisitor->setSmallFeatureCullingPixelSize(_smallFeatureCullingPixelSize);
|
||||
|
||||
cullVisitor->setEarthSky(NULL); // reset earth sky on each frame.
|
||||
|
||||
cullVisitor->setRenderGraph(rendergraph);
|
||||
|
||||
Reference in New Issue
Block a user