Skip to content

Commit

Permalink
Ran merge with svn/trunk:
Browse files Browse the repository at this point in the history
  • Loading branch information
robertosfield committed Nov 29, 2008
1 parent 642847d commit ca6fd46
Show file tree
Hide file tree
Showing 28 changed files with 605 additions and 221 deletions.
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Expand Up @@ -18,6 +18,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)

ADD_SUBDIRECTORY(osg2cpp)
ADD_SUBDIRECTORY(osganimate)
ADD_SUBDIRECTORY(osgautocapture)
ADD_SUBDIRECTORY(osgautotransform)
ADD_SUBDIRECTORY(osgbillboard)
ADD_SUBDIRECTORY(osgblendequation)
Expand Down
74 changes: 60 additions & 14 deletions examples/osgpackeddepthstencil/osgpackeddepthstencil.cpp
@@ -1,3 +1,21 @@
/* OpenSceneGraph example, osgpackeddepthstencil.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include <osg/GLExtensions>
#include <osg/Node>
#include <osg/Geometry>
Expand All @@ -6,10 +24,12 @@
#include <osg/Stencil>
#include <osg/ColorMask>
#include <osg/Geode>
#include <osg/FrameBufferObject>

#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>

#include <iostream>

osg::Geode* createMask()
{
Expand Down Expand Up @@ -97,12 +117,36 @@ int main( int argc, char **argv )
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);

arguments.getApplicationUsage()->addCommandLineOption("--fbo","Use Frame Buffer Object for render to texture, where supported.");
arguments.getApplicationUsage()->addCommandLineOption("--pbuffer-rtt","Use Pixel Buffer for render to texture, where supported.");
arguments.getApplicationUsage()->addCommandLineOption("--nopds", "Don't use packed depth stencil.");
arguments.getApplicationUsage()->addCommandLineOption("--fbo-samples","");
arguments.getApplicationUsage()->addCommandLineOption("--color-samples", "");

// construct the viewer.
osgViewer::Viewer viewer(arguments);

// add stats
viewer.addEventHandler( new osgViewer::StatsHandler() );

// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}

osg::Camera::RenderTargetImplementation renderImplementation = osg::Camera::FRAME_BUFFER_OBJECT;
int colorSamples = 0, samples = 0;
bool usePDS = true;

while (arguments.read("--fbo")) { renderImplementation = osg::Camera::FRAME_BUFFER_OBJECT; }
while (arguments.read("--pbuffer-rtt")) { renderImplementation = osg::Camera::PIXEL_BUFFER_RTT; }
while (arguments.read("--nopds")) { usePDS = false; }
while (arguments.read("--fbo-samples", samples)) {}
while (arguments.read("--color-samples", colorSamples)) {}


osg::Group* rootNode = new osg::Group;
rootNode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

Expand All @@ -125,27 +169,29 @@ int main( int argc, char **argv )
rttCamera->setViewMatrix(osg::Matrixd::identity());
rttCamera->setViewport(0, 0, 1024, 1024);
rttCamera->setRenderOrder(osg::Camera::PRE_RENDER);
rttCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

#define USE_PACKED_DEPTH_STENCIL

#ifdef USE_PACKED_DEPTH_STENCIL
rttCamera->attach(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER, GL_DEPTH_STENCIL_EXT);
#else
// this doesn't work on NVIDIA/Vista 64bit
// FBO status = 0x8cd6 (FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT)
rttCamera->attach(osg::Camera::DEPTH_BUFFER, GL_DEPTH_COMPONENT);
rttCamera->attach(osg::Camera::STENCIL_BUFFER, GL_STENCIL_INDEX_EXT);
#endif
rttCamera->attach(osg::Camera::COLOR_BUFFER, texture);
rttCamera->setRenderTargetImplementation(renderImplementation);

if(usePDS)
{
rttCamera->attach(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER, GL_DEPTH_STENCIL_EXT);
}
else
{
// this doesn't work on NVIDIA/Vista 64bit
// FBO status = 0x8cd6 (FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT)
rttCamera->attach(osg::Camera::DEPTH_BUFFER, GL_DEPTH_COMPONENT);
rttCamera->attach(osg::Camera::STENCIL_BUFFER, GL_STENCIL_INDEX8_EXT);
}

rttCamera->attach(osg::Camera::COLOR_BUFFER, texture, 0, 0, false, samples, colorSamples);
rttCamera->setCullingMode(osg::Camera::VIEW_FRUSTUM_SIDES_CULLING);

// creates rtt subtree
osg::Group* g0 = new osg::Group;
g0->addChild(createMask());
g0->addChild(createGeometry());
rttCamera->addChild(g0);
rootNode->addChild(rttCamera);
rootNode->addChild(rttCamera.get());

// creates textured quad with result
rootNode->addChild(createTextureQuad(texture));
Expand Down
2 changes: 1 addition & 1 deletion examples/osgwidgetmessagebox/osgwidgetmessagebox.cpp
Expand Up @@ -223,7 +223,7 @@ osgWidget::Frame* MessageBox::createButtonOk(const std::string& theme,
frame->resizeFrame(box->getWidth(), box->getHeight());
frame->resizeAdd(0, 0);

EventOK* event = new EventOK(frame);
EventOK* event = new EventOK(frame.get());
frame->setUpdateCallback(event);
frame->addCallback(event);

Expand Down
3 changes: 1 addition & 2 deletions include/osgAnimation/Timeline
Expand Up @@ -19,7 +19,6 @@
#include <osg/Object>
#include <map>
#include <vector>
#include <cmath>
#include <osg/Notify>
#include <osg/Group>
#include <osgAnimation/Animation>
Expand Down Expand Up @@ -214,7 +213,7 @@ namespace osgAnimation
// process all pending remove action operation
while( !_removeActionOperations.empty())
{
internalRemoveAction(_removeActionOperations.back().second);
internalRemoveAction(_removeActionOperations.back().second.get());
_removeActionOperations.pop_back();
}
}
Expand Down
19 changes: 18 additions & 1 deletion include/osgDB/DatabasePager
Expand Up @@ -100,6 +100,9 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl

void setDone(bool done) { _done = done; }
bool getDone() const { return _done; }

void setActive(bool active) { _active = active; }
bool getActive() const { return _active; }

virtual int cancel();

Expand All @@ -110,6 +113,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
virtual ~DatabaseThread();

bool _done;
bool _active;
DatabasePager* _pager;
Mode _mode;
std::string _name;
Expand Down Expand Up @@ -202,6 +206,15 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
unsigned int getMaximumNumOfObjectsToCompilePerFrame() const { return _maximumNumOfObjectsToCompilePerFrame; }


/** Set the target maximum number of PagedLOD to maintain in memory.
* Note, if more than the target number are required for rendering of a frame then these active PagedLOD are excempt from being expiried.
* But once the number of active drops back below the target the inactive PagedLOD will be trimmed back to the target number.*/
void setTargetMaximumNumberOfPageLOD(unsigned int target) { _targetMaximumNumberOfPageLOD = target; }

/** Get the target maximum number of PagedLOD to maintain in memory.*/
unsigned int getTargetMaximumNumberOfPageLOD() const { return _targetMaximumNumberOfPageLOD; }


/** Set the amount of time that a subgraph will be kept without being visited in the cull traversal
* before being removed.*/
void setExpiryDelay(double expiryDelay) { _expiryDelay = expiryDelay; }
Expand Down Expand Up @@ -311,7 +324,11 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
/** Report how many items are in the _dataToCompileList queue */
unsigned int getDataToCompileListSize() const { return _dataToCompileList->_requestList.size(); }

/** Report how many items are in the _dataToCompileList queue */
unsigned int getDataToMergeListSize() const { return _dataToMergeList->_requestList.size(); }

/** Report whether any requests are in the pager.*/
bool getRequestsInProgress() const;

/** Get the minimum time between the first request for a tile to be loaded and the time of its merge into the main scene graph.*/
double getMinimumTimeToMergeTile() const { return _minimumTimeToMergeTile; }
Expand Down Expand Up @@ -558,7 +575,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
PagedLODList _activePagedLODList;
PagedLODList _inactivePagedLODList;

unsigned int _maximumNumberOfPageLOD;
unsigned int _targetMaximumNumberOfPageLOD;

double _expiryDelay;
int _expiryFrames;
Expand Down
2 changes: 1 addition & 1 deletion include/osgWidget/Input
Expand Up @@ -40,7 +40,7 @@ class OSGWIDGET_EXPORT Input: public Label
virtual bool keyDown (int, int, WindowManager*);

void setCursor (Widget*);
unsigned int calculateBestYOffset (const std::string& = DESCENT_STRING);
unsigned int calculateBestYOffset (const std::string& = "qgl");

void setXOffset(point_type xo) {
_xoff = xo;
Expand Down
42 changes: 34 additions & 8 deletions src/osgDB/DatabasePager.cpp
Expand Up @@ -339,6 +339,7 @@ void DatabasePager::ReadQueue::takeFirst(osg::ref_ptr<DatabaseRequest>& database
//
DatabasePager::DatabaseThread::DatabaseThread(DatabasePager* pager, Mode mode, const std::string& name):
_done(false),
_active(false),
_pager(pager),
_mode(mode),
_name(name)
Expand All @@ -347,6 +348,7 @@ DatabasePager::DatabaseThread::DatabaseThread(DatabasePager* pager, Mode mode, c

DatabasePager::DatabaseThread::DatabaseThread(const DatabaseThread& dt, DatabasePager* pager):
_done(false),
_active(false),
_pager(pager),
_mode(dt._mode),
_name(dt._name)
Expand Down Expand Up @@ -442,9 +444,12 @@ void DatabasePager::DatabaseThread::run()

do
{
_active = false;

read_queue->block();

_active = true;

osg::notify(osg::INFO)<<_name<<": _pager->_requestList.size()= "<<read_queue->_requestList.size()<<" to delete = "<<read_queue->_childrenToDeleteList.size()<<std::endl;


Expand Down Expand Up @@ -907,11 +912,11 @@ DatabasePager::DatabasePager()
}


_maximumNumberOfPageLOD = 0;
_targetMaximumNumberOfPageLOD = 0;
if( (ptr = getenv("OSG_MAX_PAGEDLOD")) != 0)
{
_maximumNumberOfPageLOD = atoi(ptr);
osg::notify(osg::NOTICE)<<"_maximumNumberOfPageLOD = "<<_maximumNumberOfPageLOD<<std::endl;
_targetMaximumNumberOfPageLOD = atoi(ptr);
osg::notify(osg::NOTICE)<<"_targetMaximumNumberOfPageLOD = "<<_targetMaximumNumberOfPageLOD<<std::endl;
}


Expand Down Expand Up @@ -987,7 +992,7 @@ DatabasePager::DatabasePager(const DatabasePager& rhs)
_releaseDelay = rhs._releaseDelay;
_releaseFrames = rhs._releaseFrames;

_maximumNumberOfPageLOD = rhs._maximumNumberOfPageLOD;
_targetMaximumNumberOfPageLOD = rhs._targetMaximumNumberOfPageLOD;

_doPreCompile = rhs._doPreCompile;
_targetFrameRate = rhs._targetFrameRate;
Expand Down Expand Up @@ -1193,6 +1198,27 @@ void DatabasePager::resetStats()
_numTilesMerges = 0;
}

bool DatabasePager::getRequestsInProgress() const
{
if (getFileRequestListSize()>0) return true;

if (getDataToCompileListSize()>0)
{
return true;
}

if (getDataToMergeListSize()>0) return true;

for(DatabaseThreadList::const_iterator itr = _databaseThreads.begin();
itr != _databaseThreads.begin();
++itr)
{
if ((*itr)->getActive()) return true;
}
return false;
}


void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* group,
float priority, const osg::FrameStamp* framestamp,
osg::ref_ptr<osg::Referenced>& databaseRequest)
Expand Down Expand Up @@ -1233,7 +1259,7 @@ void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* grou
DatabaseRequest* databaseRequest = dynamic_cast<DatabaseRequest*>(databaseRequestRef.get());
if (databaseRequest)
{
osg::notify(osg::INFO)<<"DatabasePager::fileRequest("<<fileName<<") updating alraedy assigned."<<std::endl;
osg::notify(osg::INFO)<<"DatabasePager::fileRequest("<<fileName<<") updating already assigned."<<std::endl;

RequestQueue* requestQueue = databaseRequest->_requestQueue;
if (requestQueue)
Expand Down Expand Up @@ -1477,7 +1503,7 @@ class DatabasePager::MarkPagedLODsVisitor : public osg::NodeVisitor

void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp)
{
if (_maximumNumberOfPageLOD>0)
if (_targetMaximumNumberOfPageLOD>0)
{
capped_removeExpiredSubgraphs(frameStamp);
}
Expand Down Expand Up @@ -1564,13 +1590,13 @@ void DatabasePager::capped_removeExpiredSubgraphs(const osg::FrameStamp& frameSt
if (s_total_max_stage_a<time_a) s_total_max_stage_a = time_a;


if (numPagedLODs <= _maximumNumberOfPageLOD)
if (numPagedLODs <= _targetMaximumNumberOfPageLOD)
{
// nothing to do
return;
}

int numToPrune = numPagedLODs - _maximumNumberOfPageLOD;
int numToPrune = numPagedLODs - _targetMaximumNumberOfPageLOD;
if (numToPrune > inactivePLOD)
{
numToPrune = inactivePLOD;
Expand Down
3 changes: 3 additions & 0 deletions src/osgPlugins/CMakeLists.txt
Expand Up @@ -86,6 +86,9 @@ ENDIF(JPEG_FOUND)
IF(JASPER_FOUND)
ADD_SUBDIRECTORY(jp2)
ENDIF(JASPER_FOUND)
IF(OPENEXR_FOUND)
ADD_SUBDIRECTORY(exr)
ENDIF(OPENEXR_FOUND)
IF(GIFLIB_FOUND)
ADD_SUBDIRECTORY(gif)
ENDIF(GIFLIB_FOUND)
Expand Down
22 changes: 19 additions & 3 deletions src/osgPlugins/bsp/VBSPGeometry.cpp
Expand Up @@ -250,6 +250,8 @@ void VBSPGeometry::createDispSurface(Face & face, DisplaceInfo & dispInfo)
float texVOffset;
float texVScale;
unsigned int i, j, k;
double dist, minDist;
int minIndex;
osg::Vec3 temp;
int edgeIndex;
int currentSurfEdge;
Expand Down Expand Up @@ -322,9 +324,23 @@ void VBSPGeometry::createDispSurface(Face & face, DisplaceInfo & dispInfo)

// Rotate the base coordinates for the surface until the first vertex
// matches the start position
while ((fabs(vertices[0].x() - dispInfo.start_position.x()) > 0.1) ||
(fabs(vertices[0].y() - dispInfo.start_position.y()) > 0.1) ||
(fabs(vertices[0].z() - dispInfo.start_position.z()) > 0.1))
minDist = 1.0e9;
for (i = 0; i < 4; i++)
{
// Calculate the distance of the start position from this vertex
dist = (vertices[i] - dispInfo.start_position).length();

// If this is the smallest distance we've seen, remember it
if (dist < minDist)
{
minDist = dist;
minIndex = i;
}
}

// Rotate the displacement surface quad until we get the starting vertex
// in the 0th position
for (i = 0; i < minIndex; i++)
{
temp = vertices[0];
vertices[0] = vertices[1];
Expand Down

0 comments on commit ca6fd46

Please sign in to comment.