From 10c3b4e7bf900a4f68894ee0f5639f91178c237e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 14 May 2002 10:20:55 +0000 Subject: [PATCH] Fixes to new flipVertical/flipHorizontal. --- include/osg/MemoryManager | 8 ++-- include/osgUtil/CullVisitor | 76 ++++++++++++++++++------------------- src/osg/Image.cpp | 8 ++-- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/include/osg/MemoryManager b/include/osg/MemoryManager index 9afd1d57a..62e1f3a20 100644 --- a/include/osg/MemoryManager +++ b/include/osg/MemoryManager @@ -141,12 +141,12 @@ SG_EXPORT extern sMStats m_getMemoryStatistics(); #else - #define osgNew new - #define osgDelete delete + #define osgNew new + #define osgDelete delete #define osgMalloc(sz) malloc(sz) #define osgCalloc(sz) calloc(sz) - #define osgRealloc(ptr,sz) realloc(sz) - #define osgFree(ptr) free(sz) + #define osgRealloc(ptr,sz) realloc(ptr,sz) + #define osgFree(ptr) free(ptr) #endif diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index 39ab2351c..c74e224fb 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -127,6 +127,8 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor /** Returns the current CullingMode.*/ CullingMode getCullingMode() const; + void setSmallFeatureCullingPixelSize(float s) { _smallFeatureCullingPixelSize=s; } + float getSmallFeatureCullingPixelSize() const { return _smallFeatureCullingPixelSize; } void pushViewport(osg::Viewport* viewport); void popViewport(); @@ -235,8 +237,42 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor return !_modelviewClippingVolumeStack.back().contains(bb,mode); } - void setSmallFeatureCullingPixelSize(float s) { _smallFeatureCullingPixelSize=s; } - float getSmallFeatureCullingPixelSize() const { return _smallFeatureCullingPixelSize; } + void updateCalculatedNearFar(const osg::Matrix& matrix,const osg::Drawable& drawable); + void updateCalculatedNearFar(const osg::Vec3& pos); + + /** Add a drawable to current render graph.*/ + inline void addDrawable(osg::Drawable* drawable,osg::Matrix* matrix) + { + if (_currentRenderGraph->leaves_empty()) + { + // this is first leaf to be added to RenderGraph + // and therefore should not already know to current render bin, + // so need to add it. + _currentRenderBin->addRenderGraph(_currentRenderGraph); + } + //_currentRenderGraph->addLeaf(new RenderLeaf(drawable,matrix)); + _currentRenderGraph->addLeaf(createOrReuseRenderLeaf(drawable,_projectionStack.back().get(),matrix)); + } + + /** Add a drawable and depth to current render graph.*/ + inline void addDrawableAndDepth(osg::Drawable* drawable,osg::Matrix* matrix,const float depth) + { + if (_currentRenderGraph->leaves_empty()) + { + // this is first leaf to be added to RenderGraph + // and therefore should not already know to current render bin, + // so need to add it. + _currentRenderBin->addRenderGraph(_currentRenderGraph); + } + //_currentRenderGraph->addLeaf(new RenderLeaf(drawable,matrix,depth)); + _currentRenderGraph->addLeaf(createOrReuseRenderLeaf(drawable,_projectionStack.back().get(),matrix,depth)); + } + + /** Add an attribute which is positioned related to the modelview matrix.*/ + inline void addPositionedAttribute(osg::Matrix* matrix,const osg::StateAttribute* attr) + { + _currentRenderBin->_stage->addPositionedAttribute(matrix,attr); + } protected: @@ -275,42 +311,6 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor - void updateCalculatedNearFar(const osg::Matrix& matrix,const osg::Drawable& drawable); - void updateCalculatedNearFar(const osg::Vec3& pos); - - /** Add a drawable to current render graph.*/ - inline void addDrawable(osg::Drawable* drawable,osg::Matrix* matrix) - { - if (_currentRenderGraph->leaves_empty()) - { - // this is first leaf to be added to RenderGraph - // and therefore should not already know to current render bin, - // so need to add it. - _currentRenderBin->addRenderGraph(_currentRenderGraph); - } - //_currentRenderGraph->addLeaf(new RenderLeaf(drawable,matrix)); - _currentRenderGraph->addLeaf(createOrReuseRenderLeaf(drawable,_projectionStack.back().get(),matrix)); - } - - /** Add a drawable and depth to current render graph.*/ - inline void addDrawableAndDepth(osg::Drawable* drawable,osg::Matrix* matrix,const float depth) - { - if (_currentRenderGraph->leaves_empty()) - { - // this is first leaf to be added to RenderGraph - // and therefore should not already know to current render bin, - // so need to add it. - _currentRenderBin->addRenderGraph(_currentRenderGraph); - } - //_currentRenderGraph->addLeaf(new RenderLeaf(drawable,matrix,depth)); - _currentRenderGraph->addLeaf(createOrReuseRenderLeaf(drawable,_projectionStack.back().get(),matrix,depth)); - } - - /** Add an attribute which is positioned related to the modelview matrix.*/ - inline void addPositionedAttribute(osg::Matrix* matrix,const osg::StateAttribute* attr) - { - _currentRenderBin->_stage->addPositionedAttribute(matrix,attr); - } /** create an impostor sprite by setting up a pre-rendering stage diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 195484859..a1a04a7ef 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -208,7 +208,7 @@ void Image::createImage(int s,int t,int r, if (_data) ::free(_data); if (newTotalSize) - _data = (unsigned char *)osgMalloc (newTotalSize); + _data = (unsigned char *)malloc (newTotalSize); else _data = 0L; } @@ -293,7 +293,7 @@ void Image::scaleImage(const int s,const int t,const int r) unsigned int newTotalSize = computeRowWidthInBytes(s,_pixelFormat,_dataType,_packing)*t; // need to sort out what size to really use... - unsigned char* newData = (unsigned char *)osgMalloc(newTotalSize); + unsigned char* newData = (unsigned char *)malloc(newTotalSize); if (!newData) { // should we throw an exception??? Just return for time being. @@ -338,7 +338,7 @@ void Image::flipHorizontal(int image) { if (_data==NULL) { - notify(WARN) << "Error Image::flipVertical() do not succeed : cannot flip NULL image."<