Introduce Camera::s/getRenderer().
This commit is contained in:
parent
f38be8c7a8
commit
6dec61842d
@ -1,6 +1,6 @@
|
||||
SET(TARGET_SRC FOX_OSG.cpp FOX_OSG_MDIView.cpp osgviewerFOX.cpp )
|
||||
|
||||
SET(TARGET_H FOX_OSG_MDIView.h osgviewerFOX.cpp osgviewerFOX.h)
|
||||
SET(TARGET_H FOX_OSG.h FOX_OSG_MDIView.h osgviewerFOX.h)
|
||||
|
||||
INCLUDE_DIRECTORIES( ${FOX_INCLUDE_DIR} )
|
||||
SET(TARGET_EXTERNAL_LIBRARIES ${FOX_LIBRARY} )
|
||||
|
@ -373,13 +373,13 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
|
||||
|
||||
/** Set the Rendering object that is used to implement rendering of the subgraph.*/
|
||||
void setRenderingCache(unsigned int contextID, osg::Object* rc) { _renderingCache[contextID] = rc; }
|
||||
void setRenderer(osg::Object* rc) { _renderer = rc; }
|
||||
|
||||
/** Get the Rendering object that is used to implement rendering of the subgraph.*/
|
||||
osg::Object* getRenderingCache(unsigned int contextID) { return _renderingCache[contextID].get(); }
|
||||
osg::Object* getRenderer() { return _renderer.get(); }
|
||||
|
||||
/** Get the const Rendering object that is used to implement rendering of the subgraph.*/
|
||||
const osg::Object* getRenderingCache(unsigned int contextID) const { return _renderingCache[contextID].get(); }
|
||||
const osg::Object* getRenderer() const { return _renderer.get(); }
|
||||
|
||||
|
||||
/** Draw callback for custom operations.*/
|
||||
@ -467,11 +467,11 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
RenderTargetImplementation _renderTargetFallback;
|
||||
BufferAttachmentMap _bufferAttachmentMap;
|
||||
|
||||
ref_ptr<OperationThread> _cameraThread;
|
||||
ref_ptr<OperationThread> _cameraThread;
|
||||
|
||||
ref_ptr<GraphicsContext> _graphicsContext;
|
||||
|
||||
buffered_object< ref_ptr<Object> > _renderingCache;
|
||||
ref_ptr<Object> _renderer;
|
||||
|
||||
ref_ptr<DrawCallback> _preDrawCallback;
|
||||
ref_ptr<DrawCallback> _postDrawCallback;
|
||||
|
@ -61,7 +61,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings
|
||||
virtual void setDefaults(unsigned int options);
|
||||
|
||||
/** Set the camera used to represent the camera view of this SceneView.*/
|
||||
void setCamera(osg::Camera* camera);
|
||||
void setCamera(osg::Camera* camera, bool assumeOwnershipOfCamera = true);
|
||||
|
||||
/** Get the camera used to represent the camera view of this SceneView.*/
|
||||
osg::Camera* getCamera() { return _camera.get(); }
|
||||
@ -502,7 +502,8 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings
|
||||
|
||||
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
||||
|
||||
osg::ref_ptr<osg::Camera> _camera;
|
||||
osg::observer_ptr<osg::Camera> _camera;
|
||||
osg::ref_ptr<osg::Camera> _cameraWithOwnership;
|
||||
|
||||
osg::ref_ptr<osg::StateSet> _globalStateSet;
|
||||
osg::ref_ptr<osg::Light> _light;
|
||||
|
@ -251,15 +251,20 @@ void Camera::detach(BufferComponent buffer)
|
||||
|
||||
void Camera::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
{
|
||||
_renderingCache.resize(maxSize);
|
||||
if (_renderer.valid())
|
||||
{
|
||||
const_cast<Camera*>(this)->_renderer->resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
|
||||
Transform::resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
|
||||
void Camera::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
if (state) const_cast<Camera*>(this)->_renderingCache[state->getContextID()] = 0;
|
||||
else const_cast<Camera*>(this)->_renderingCache.setAllElementsTo(0);
|
||||
if (_renderer.valid())
|
||||
{
|
||||
const_cast<Camera*>(this)->_renderer->releaseGLObjects(state);
|
||||
}
|
||||
|
||||
Transform::releaseGLObjects(state);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class FLTReaderWriter : public ReaderWriter
|
||||
|
||||
virtual bool acceptsExtension(const std::string& extension) const
|
||||
{
|
||||
return equalCaseInsensitive(extension,"flt");
|
||||
return equalCaseInsensitive(extension,"flt") || extension.empty();
|
||||
}
|
||||
|
||||
virtual ReadResult readObject(const std::string& file, const Options* options) const
|
||||
|
@ -1190,11 +1190,11 @@ void CullVisitor::apply(osg::Camera& camera)
|
||||
|
||||
// use render to texture stage.
|
||||
// create the render to texture stage.
|
||||
osg::ref_ptr<osgUtil::RenderStageCache> rsCache = dynamic_cast<osgUtil::RenderStageCache*>(camera.getRenderingCache(contextID));
|
||||
osg::ref_ptr<osgUtil::RenderStageCache> rsCache = dynamic_cast<osgUtil::RenderStageCache*>(camera.getRenderer());
|
||||
if (!rsCache)
|
||||
{
|
||||
rsCache = new osgUtil::RenderStageCache;
|
||||
camera.setRenderingCache(contextID, rsCache.get());
|
||||
camera.setRenderer(rsCache.get());
|
||||
}
|
||||
|
||||
osg::ref_ptr<osgUtil::RenderStage> rtts = rsCache->getRenderStage(this);
|
||||
|
@ -95,7 +95,7 @@ SceneView::SceneView(DisplaySettings* ds)
|
||||
|
||||
_prioritizeTextures = false;
|
||||
|
||||
_camera = new Camera;
|
||||
setCamera(new Camera);
|
||||
_camera->setViewport(new Viewport);
|
||||
_camera->setClearColor(osg::Vec4(0.2f, 0.2f, 0.4f, 1.0f));
|
||||
|
||||
@ -132,6 +132,7 @@ SceneView::SceneView(const SceneView& rhs, const osg::CopyOp& copyop):
|
||||
_prioritizeTextures = rhs._prioritizeTextures;
|
||||
|
||||
_camera = rhs._camera;
|
||||
_cameraWithOwnership = rhs._cameraWithOwnership;
|
||||
|
||||
_initCalled = rhs._initCalled;
|
||||
|
||||
@ -231,7 +232,7 @@ void SceneView::setDefaults(unsigned int options)
|
||||
_camera->setClearColor(osg::Vec4(0.2f, 0.2f, 0.4f, 1.0f));
|
||||
}
|
||||
|
||||
void SceneView::setCamera(osg::Camera* camera)
|
||||
void SceneView::setCamera(osg::Camera* camera, bool assumeOwnershipOfCamera)
|
||||
{
|
||||
if (camera)
|
||||
{
|
||||
@ -241,6 +242,15 @@ void SceneView::setCamera(osg::Camera* camera)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Warning: attempt to assign a NULL camera to SceneView not permitted."<<std::endl;
|
||||
}
|
||||
|
||||
if (assumeOwnershipOfCamera)
|
||||
{
|
||||
_cameraWithOwnership = _camera.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cameraWithOwnership = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void SceneView::setSceneData(osg::Node* node)
|
||||
|
@ -476,19 +476,19 @@ BEGIN_OBJECT_REFLECTOR(osg::Camera)
|
||||
__C5_GraphicsContext_P1__getGraphicsContext,
|
||||
"Get the const GraphicsContext. ",
|
||||
"");
|
||||
I_Method2(void, setRenderingCache, IN, unsigned int, contextID, IN, osg::Object *, rc,
|
||||
I_Method1(void, setRenderer, IN, osg::Object *, rc,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__setRenderingCache__unsigned_int__osg_Object_P1,
|
||||
__void__setRenderer__osg_Object_P1,
|
||||
"Set the Rendering object that is used to implement rendering of the subgraph. ",
|
||||
"");
|
||||
I_Method1(osg::Object *, getRenderingCache, IN, unsigned int, contextID,
|
||||
I_Method0(osg::Object *, getRenderer,
|
||||
Properties::NON_VIRTUAL,
|
||||
__osg_Object_P1__getRenderingCache__unsigned_int,
|
||||
__osg_Object_P1__getRenderer,
|
||||
"Get the Rendering object that is used to implement rendering of the subgraph. ",
|
||||
"");
|
||||
I_Method1(const osg::Object *, getRenderingCache, IN, unsigned int, contextID,
|
||||
I_Method0(const osg::Object *, getRenderer,
|
||||
Properties::NON_VIRTUAL,
|
||||
__C5_osg_Object_P1__getRenderingCache__unsigned_int,
|
||||
__C5_osg_Object_P1__getRenderer,
|
||||
"Get the const Rendering object that is used to implement rendering of the subgraph. ",
|
||||
"");
|
||||
I_Method1(void, setPreDrawCallback, IN, osg::Camera::DrawCallback *, cb,
|
||||
@ -606,10 +606,9 @@ BEGIN_OBJECT_REFLECTOR(osg::Camera)
|
||||
I_SimpleProperty(osg::Camera::RenderTargetImplementation, RenderTargetImplementation,
|
||||
__RenderTargetImplementation__getRenderTargetImplementation,
|
||||
__void__setRenderTargetImplementation__RenderTargetImplementation);
|
||||
I_IndexedProperty(osg::Object *, RenderingCache,
|
||||
__osg_Object_P1__getRenderingCache__unsigned_int,
|
||||
__void__setRenderingCache__unsigned_int__osg_Object_P1,
|
||||
0);
|
||||
I_SimpleProperty(osg::Object *, Renderer,
|
||||
__osg_Object_P1__getRenderer,
|
||||
__void__setRenderer__osg_Object_P1);
|
||||
I_SimpleProperty(osg::Stats *, Stats,
|
||||
__osg_Stats_P1__getStats,
|
||||
__void__setStats__osg_Stats_P1);
|
||||
|
@ -121,11 +121,11 @@ BEGIN_OBJECT_REFLECTOR(osgUtil::SceneView)
|
||||
__void__setDefaults__unsigned_int,
|
||||
"Set scene view to use default global state, light, camera and render visitor. ",
|
||||
"");
|
||||
I_Method1(void, setCamera, IN, osg::Camera *, camera,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__setCamera__osg_Camera_P1,
|
||||
"Set the camera used to represent the camera view of this SceneView. ",
|
||||
"");
|
||||
I_MethodWithDefaults2(void, setCamera, IN, osg::Camera *, camera, , IN, bool, assumeOwnershipOfCamera, true,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__setCamera__osg_Camera_P1__bool,
|
||||
"Set the camera used to represent the camera view of this SceneView. ",
|
||||
"");
|
||||
I_Method0(osg::Camera *, getCamera,
|
||||
Properties::NON_VIRTUAL,
|
||||
__osg_Camera_P1__getCamera,
|
||||
@ -784,7 +784,7 @@ BEGIN_OBJECT_REFLECTOR(osgUtil::SceneView)
|
||||
__void__setActiveUniforms__int);
|
||||
I_SimpleProperty(osg::Camera *, Camera,
|
||||
__osg_Camera_P1__getCamera,
|
||||
__void__setCamera__osg_Camera_P1);
|
||||
0);
|
||||
I_SimpleProperty(const osg::Vec4 &, ClearColor,
|
||||
__C5_osg_Vec4_R1__getClearColor,
|
||||
__void__setClearColor__C5_osg_Vec4_R1);
|
||||
|
Loading…
Reference in New Issue
Block a user