From 3ed40cdab52228f6da311b8020481aecdb075a51 Mon Sep 17 00:00:00 2001 From: Aron Bierbaum Date: Fri, 18 Nov 2011 09:34:19 -0600 Subject: [PATCH 01/15] Process newparams that are declared in the technique. --- Source/System/FileIO/Collada/OSGColladaEffect.cpp | 12 ++++++++---- Source/System/FileIO/Collada/OSGColladaEffect.h | 1 + Source/System/FileIO/Collada/OSGColladaGeometry.cpp | 5 +++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Source/System/FileIO/Collada/OSGColladaEffect.cpp b/Source/System/FileIO/Collada/OSGColladaEffect.cpp index e64d3cac5..205427490 100644 --- a/Source/System/FileIO/Collada/OSGColladaEffect.cpp +++ b/Source/System/FileIO/Collada/OSGColladaEffect.cpp @@ -276,9 +276,16 @@ ColladaEffect::readProfileCommon(domProfile_COMMON *prof) } readImageArray(prof->getImage_array()); + readNewParams(prof->getNewparam_array()); - const domCommon_newparam_type_Array &newParams = prof->getNewparam_array(); + domProfile_COMMON::domTechniqueRef tech = prof->getTechnique(); + readNewParams(tech->getNewparam_array()); + readImageArray(tech->getImage_array()); +} +void +ColladaEffect::readNewParams(const domCommon_newparam_type_Array& newParams) +{ for(UInt32 i = 0; i < newParams.getCount(); ++i) { // must read surface params before sampler params, because their @@ -326,9 +333,6 @@ ColladaEffect::readProfileCommon(domProfile_COMMON *prof) << std::endl; } - domProfile_COMMON::domTechniqueRef tech = prof->getTechnique(); - - readImageArray(tech->getImage_array()); } void diff --git a/Source/System/FileIO/Collada/OSGColladaEffect.h b/Source/System/FileIO/Collada/OSGColladaEffect.h index 91b560cec..3cadb751c 100644 --- a/Source/System/FileIO/Collada/OSGColladaEffect.h +++ b/Source/System/FileIO/Collada/OSGColladaEffect.h @@ -166,6 +166,7 @@ class OSG_FILEIO_DLLMAPPING ColladaEffect : public ColladaInstantiableElement virtual void readProfileCommon(domProfile_COMMON *prof); virtual void readProfileGLSL (domProfile_GLSL *prof); virtual void readProfileCG (domProfile_CG *prof); + virtual void readNewParams (const domCommon_newparam_type_Array& newParams); virtual MaterialTransitPtr createInstanceProfileCommon( domProfile_COMMON *prof, domEffect *effect, diff --git a/Source/System/FileIO/Collada/OSGColladaGeometry.cpp b/Source/System/FileIO/Collada/OSGColladaGeometry.cpp index 4883e4bcb..0b161a9d1 100644 --- a/Source/System/FileIO/Collada/OSGColladaGeometry.cpp +++ b/Source/System/FileIO/Collada/OSGColladaGeometry.cpp @@ -944,6 +944,11 @@ ColladaGeometry::setupGeometry(const domInputLocal_Array &vertInputs, } } + // TODO: Clean up the texcood property indices by ensuring that if we have + // at least one texture coordinate property, that it is assigned to + // the first texture coordinate slot. This should be a safe assumption + // since we are in the common profile. + #ifdef OSG_DEBUG // check for holes in idxStore - which is not supported IndexStoreConstIt idxIt = idxStore.begin(); From 92a7010aaef750cd59201a4ad6ff23ceef6d74b4 Mon Sep 17 00:00:00 2001 From: Aron Bierbaum Date: Fri, 18 Nov 2011 15:36:27 -0600 Subject: [PATCH 02/15] Work around models that have texcoords in the wrong slot. Add code that detects the case that we do not have a texture coordinates in the first slot. In that case we search the remaining slots looking for the first property that contains texture coordinates. If we find texture coordinates, we move the texture coordinate properties into the first slot so that they will work with fixed function OpenGL. --- .../FileIO/Collada/OSGColladaGeometry.cpp | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/Source/System/FileIO/Collada/OSGColladaGeometry.cpp b/Source/System/FileIO/Collada/OSGColladaGeometry.cpp index 0b161a9d1..a697d180f 100644 --- a/Source/System/FileIO/Collada/OSGColladaGeometry.cpp +++ b/Source/System/FileIO/Collada/OSGColladaGeometry.cpp @@ -944,11 +944,6 @@ ColladaGeometry::setupGeometry(const domInputLocal_Array &vertInputs, } } - // TODO: Clean up the texcood property indices by ensuring that if we have - // at least one texture coordinate property, that it is assigned to - // the first texture coordinate slot. This should be a safe assumption - // since we are in the common profile. - #ifdef OSG_DEBUG // check for holes in idxStore - which is not supported IndexStoreConstIt idxIt = idxStore.begin(); @@ -1104,6 +1099,34 @@ ColladaGeometry::handleBindMaterial( } } + // Clean up the texcood property indices by ensuring that if we have at + // least one texture coordinate property, that it is assigned to the first + // texture coordinate slot. This should be a safe assumption since we are + // in the common profile. + GeoVectorProperty* tex_coord0(geo->getProperty(Geometry::TexCoordsIndex)); + if (NULL == tex_coord0) + { + + for (UInt16 idx = Geometry::TexCoords1Index; idx <= Geometry::TexCoords7Index; ++idx) + { + GeoVectorProperty* tex_coord(geo->getProperty(idx)); + if (NULL != tex_coord) + { + OSG_COLLADA_LOG(("ColladaGeometry::handleBindMaterial: " + "Manual switch texture coords from [%d] to [%s].\n", + idx, Geometry::TexCoords1Index)); + + geo->setProperty(tex_coord, Geometry::TexCoordsIndex); + geo->setProperty(NULL, idx); + + GeoIntegralProperty* index(geo->getIndex(idx)); + geo->setIndex(index, Geometry::TexCoordsIndex); + geo->setIndex(NULL, idx); + break; + } + } + } + if(material != NULL) { geo->setMaterial(material); From 609ab515487b10d637d478b91fe9d8dc5e5d2bab Mon Sep 17 00:00:00 2001 From: Patrick Hartling Date: Mon, 28 Nov 2011 08:49:14 -0600 Subject: [PATCH 03/15] Fix shaders on ATI cards. Apply the following OpenSG change: https://github.com/vossg/OpenSGDevMaster/commit/b98fe367b5feb40dab7822f0f66b2092add8ee31 --- Source/System/NodeCores/Drawables/Geometry/Base/OSGGeometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/System/NodeCores/Drawables/Geometry/Base/OSGGeometry.cpp b/Source/System/NodeCores/Drawables/Geometry/Base/OSGGeometry.cpp index 5139fb47b..fc83c4497 100644 --- a/Source/System/NodeCores/Drawables/Geometry/Base/OSGGeometry.cpp +++ b/Source/System/NodeCores/Drawables/Geometry/Base/OSGGeometry.cpp @@ -385,7 +385,7 @@ void Geometry::drawPrimitives(DrawEnv *pEnv) { bool usesShader = false; - usesShader = (pEnv->getActiveShader() != 0); +// usesShader = (pEnv->getActiveShader() != 0); // store glColor. Color4f color; From be2caaed5483affd2a00ad3e7dfd38c7b59648d2 Mon Sep 17 00:00:00 2001 From: Patrick Hartling Date: Mon, 28 Nov 2011 08:51:04 -0600 Subject: [PATCH 04/15] Fixed a crash that would occur when loading an animated GIF. This occurred when the first frame had the smallest dimensions. This addresses what seems to be the most common cause of crashes associated with loading animated GIFs. --- .../Image/FileIO/OSGGIFImageFileType.cpp | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Source/System/Image/FileIO/OSGGIFImageFileType.cpp b/Source/System/Image/FileIO/OSGGIFImageFileType.cpp index 1caa32e22..5e4f65fa5 100644 --- a/Source/System/Image/FileIO/OSGGIFImageFileType.cpp +++ b/Source/System/Image/FileIO/OSGGIFImageFileType.cpp @@ -198,7 +198,8 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), int i, j, destI, lineSize, lineEnd; unsigned red, green, blue; int transparentIndex; - int width = 0, height = 0, channel = 0; + int streamWidth = 0, streamHeight = 0; + int curWidth = 0, curHeight = 0, channel = 0; int xOff = 0, yOff = 0; unsigned char *srcData = 0, *destData = 0; int colorIndex; @@ -224,6 +225,9 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), if(gifStream) { + streamWidth = gifStream->width; + streamHeight = gifStream->height; + for(gifData = gifStream->data; gifData; gifData = gifData->next) { switch(gifData->type) @@ -238,10 +242,10 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), // get the att. transparentIndex = gifData->info.transparent; frameDelay = float(gifData->info.delayTime) / 100.0f; - width = gifData->width; - height = gifData->height; - xOff = gifData->x; - yOff = gifData->y; + curWidth = gifData->width; + curHeight = gifData->height; + xOff = gifData->x; + yOff = gifData->y; // check if the movie is color or greyscale isColor = false; @@ -294,8 +298,8 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), { // is not the first frame if((channel == pImage->getBpp()) && - (width == pImage->getWidth()) && - (height == pImage->getHeight())) + (streamWidth == pImage->getWidth()) && + (streamHeight == pImage->getHeight())) { destData = pImage->editData(0, currentFrame); } @@ -380,8 +384,8 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), break; }; pImage->set(pixelFormat, - width, - height, + streamWidth, + streamHeight, 1, 1, frameCount, frameDelay); @@ -390,7 +394,7 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), // copy the image data) lineSize = pImage->getWidth() * channel; - lineEnd = width * channel + xOff * channel; + lineEnd = streamWidth * channel + xOff * channel; srcData = gifData->data.image.data; destData = destData + ((pImage->getHeight() - yOff - 1)*lineSize); @@ -399,7 +403,7 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), { case 1: // Greyscale without Alpha destI = 0; - for(i = width * height; i--;) + for(i = curWidth * curHeight; i--;) { destData[destI++] = colorMap[*srcData++ *3]; if(destI >= lineSize) @@ -412,7 +416,7 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), case 2: // Greyscale with Alpha destI = 0; - for(i = width * height; i--;) + for(i = curWidth * curHeight; i--;) { colorIndex = *srcData++; if(colorIndex == transparentIndex) @@ -436,7 +440,7 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), case 3: // RGB without Alpha destI = 0; - for(i = width * height; i--;) + for(i = curWidth * curHeight; i--;) { colorIndex = *srcData++; for(j = 0; j < 3; j++) @@ -456,7 +460,7 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), case 4: // RGB with Alpha destI = xOff * 4; - for(i = width * height; i--;) + for(i = curWidth * curHeight; i--;) { colorIndex = *srcData++; if(colorIndex == transparentIndex) From ec4286d56877a544475b2a5d1869cbec30335f71 Mon Sep 17 00:00:00 2001 From: Patrick Hartling Date: Mon, 28 Nov 2011 08:52:44 -0600 Subject: [PATCH 05/15] Utilize const pointers. This is done in an effort to get the compiler to help identify places where the code might modify source data. This does not technically fix anything. Instead, it serves to give me a sanity check regarding the extraction of data being copied from GIF image to an OSG::Image. --- .../Image/FileIO/OSGGIFImageFileType.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/System/Image/FileIO/OSGGIFImageFileType.cpp b/Source/System/Image/FileIO/OSGGIFImageFileType.cpp index 5e4f65fa5..782e31a1d 100644 --- a/Source/System/Image/FileIO/OSGGIFImageFileType.cpp +++ b/Source/System/Image/FileIO/OSGGIFImageFileType.cpp @@ -160,7 +160,7 @@ static GIFStream *GIFRead (std::istream &is); int GIFTest (char *); int GIFWrite (char *, GIFStream *, int); static int GIFWriteFP(FILE *, GIFStream *, int); -static int GIFFree (GIFStream *); +static int GIFFree (const GIFStream *); #endif @@ -192,8 +192,8 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), #ifdef OSG_WITH_GIF Image::PixelFormat pixelFormat = Image::OSG_INVALID_PF; - GIFStream *gifStream = GIFRead(is); - GIFData *gifData = 0; + const GIFStream *gifStream = GIFRead(is); + const GIFData *gifData = 0; bool isColor; int i, j, destI, lineSize, lineEnd; unsigned red, green, blue; @@ -201,10 +201,11 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), int streamWidth = 0, streamHeight = 0; int curWidth = 0, curHeight = 0, channel = 0; int xOff = 0, yOff = 0; - unsigned char *srcData = 0, *destData = 0; + const unsigned char *srcData = 0; + unsigned char *destData = 0; int colorIndex; unsigned frameCount = 0, currentFrame = 0; - unsigned char *colorMap = 0; + const unsigned char *colorMap = 0; // int imageSize = 0; int colorMapSize; @@ -253,7 +254,7 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), { colorMapSize = gifData->data.image.cmapSize; colorMap = - reinterpret_cast( + reinterpret_cast( gifData->data.image.cmapData); // cout << "INFO: Use gifData colorMap" << endl; @@ -262,7 +263,7 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), { colorMapSize = gifStream->cmapSize; colorMap = - reinterpret_cast( + reinterpret_cast( gifStream->cmapData); // cout << "INFO: Use gifStream colorMap" << endl; @@ -902,7 +903,7 @@ static GIFStream *GIFRead(std::istream &is) } /* */ -static int GIFFreeData(GIFData *gifData) +static int GIFFreeData(const GIFData *gifData) { int retCode = 0; @@ -939,7 +940,7 @@ static int GIFFreeData(GIFData *gifData) } /* */ -static int GIFFree(GIFStream *gifStream) +static int GIFFree(const GIFStream *gifStream) { int retCode = 1; GIFData *gifData, *gifNext; From a9fe8915550a020e6df52ce6c1811ce459c0d978 Mon Sep 17 00:00:00 2001 From: Patrick Hartling Date: Mon, 28 Nov 2011 08:53:20 -0600 Subject: [PATCH 06/15] Fixed more memory corruption problems. At this point, there are no known crashes related to animated GIFs. --- Source/System/Image/FileIO/OSGGIFImageFileType.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/System/Image/FileIO/OSGGIFImageFileType.cpp b/Source/System/Image/FileIO/OSGGIFImageFileType.cpp index 782e31a1d..d4d28f035 100644 --- a/Source/System/Image/FileIO/OSGGIFImageFileType.cpp +++ b/Source/System/Image/FileIO/OSGGIFImageFileType.cpp @@ -393,9 +393,9 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), destData = pImage->editData(); } - // copy the image data) + // copy the image data lineSize = pImage->getWidth() * channel; - lineEnd = streamWidth * channel + xOff * channel; + lineEnd = curWidth * channel + xOff * channel; srcData = gifData->data.image.data; destData = destData + ((pImage->getHeight() - yOff - 1)*lineSize); @@ -407,7 +407,7 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), for(i = curWidth * curHeight; i--;) { destData[destI++] = colorMap[*srcData++ *3]; - if(destI >= lineSize) + if(destI >= lineEnd) { destI = 0; destData -= lineSize; @@ -431,7 +431,7 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), destData[destI++] = 255; } - if(destI >= lineSize) + if(destI >= lineEnd) { destI = 0; destData -= lineSize; @@ -450,7 +450,7 @@ bool GIFImageFileType::read( Image *OSG_GIF_ARG(pImage), colorMap[colorIndex * 3 + j]; } - if(destI >= lineSize) + if(destI >= lineEnd) { destI = 0; destData -= lineSize; From b7d6e3e4a5a7b8d12761c3383e12b6cb2c7f010e Mon Sep 17 00:00:00 2001 From: Patrick Hartling Date: Mon, 28 Nov 2011 08:55:12 -0600 Subject: [PATCH 07/15] Fixed the use of OSG_ENABLE_DOUBLE_MATRIX_STACK. --- OSGConfigured.h.cmake | 2 ++ Source/System/Action/RenderAction/OSGRenderPartition.h | 3 ++- Source/System/Action/RenderAction/OSGRenderPartition.inl | 4 ++-- .../RenderingBackend/OSGOcclusionCullingTreeBuilder.cpp | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/OSGConfigured.h.cmake b/OSGConfigured.h.cmake index 39d8e07c9..a8fa0b132 100644 --- a/OSGConfigured.h.cmake +++ b/OSGConfigured.h.cmake @@ -20,6 +20,8 @@ #cmakedefine OSG_ENABLE_MEMORY_DEBUGGING 1 +#cmakedefine OSG_ENABLE_DOUBLE_MATRIX_STACK 1 + #cmakedefine OSG_WITH_GDAL 1 /* Do not use GL subdir for glut */ diff --git a/Source/System/Action/RenderAction/OSGRenderPartition.h b/Source/System/Action/RenderAction/OSGRenderPartition.h index b2d307426..585473a4c 100644 --- a/Source/System/Action/RenderAction/OSGRenderPartition.h +++ b/Source/System/Action/RenderAction/OSGRenderPartition.h @@ -283,7 +283,8 @@ class OSG_SYSTEM_DLLMAPPING RenderPartition : public RenderPartitionBase const Matrix &topMatrix ( void ); const Matrix &getModelMatrix ( void ) const; - const Matrix &getModelViewMatrix( void ) const; + + const MatrixStore::second_type &getModelViewMatrix( void ) const; const MatrixStore &getMatrixStackTop ( void ) const; diff --git a/Source/System/Action/RenderAction/OSGRenderPartition.inl b/Source/System/Action/RenderAction/OSGRenderPartition.inl index 6a92a68a8..1938fe2d6 100644 --- a/Source/System/Action/RenderAction/OSGRenderPartition.inl +++ b/Source/System/Action/RenderAction/OSGRenderPartition.inl @@ -282,8 +282,8 @@ const Matrix &RenderPartition::getModelMatrix(void) const return _modelMatrix; } -inline -const Matrix &RenderPartition::getModelViewMatrix(void) const +inline const RenderPartition::MatrixStore::second_type & +RenderPartition::getModelViewMatrix(void) const { return _modelViewMatrix.second; } diff --git a/Source/System/RenderingBackend/OSGOcclusionCullingTreeBuilder.cpp b/Source/System/RenderingBackend/OSGOcclusionCullingTreeBuilder.cpp index dae49946e..a182fe006 100644 --- a/Source/System/RenderingBackend/OSGOcclusionCullingTreeBuilder.cpp +++ b/Source/System/RenderingBackend/OSGOcclusionCullingTreeBuilder.cpp @@ -799,7 +799,7 @@ OcclusionCullingTreeBuilder::createNode(RenderActionBase *pAction, Pnt3d objPos(TypeTraits::getMax(), TypeTraits::getMax(), TypeTraits::getMax() ); - Pnt3f volVert[8]; + Pnt3d volVert[8]; #endif Pnt3f volMin; From 7187bd0ebb1784e94ce640a7c38499853d3b59c0 Mon Sep 17 00:00:00 2001 From: Patrick Hartling Date: Mon, 28 Nov 2011 08:57:08 -0600 Subject: [PATCH 08/15] Lock accesses to the field container change field. Enable the use of a spin lock in order to ensure that multiple threads don't try to change a given field container's container change field at the same time. --- .../FieldContainer/Base/OSGFieldContainer.cpp | 23 +++++++++++++++++-- .../FieldContainer/Base/OSGFieldContainer.inl | 6 +++++ .../Base/OSGReflexiveContainer.inl | 6 +++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Source/Base/FieldContainer/Base/OSGFieldContainer.cpp b/Source/Base/FieldContainer/Base/OSGFieldContainer.cpp index 5cc4f695e..b62247404 100644 --- a/Source/Base/FieldContainer/Base/OSGFieldContainer.cpp +++ b/Source/Base/FieldContainer/Base/OSGFieldContainer.cpp @@ -47,6 +47,7 @@ #include "OSGFieldContainer.h" #include "OSGContainerPtrFuncs.h" +#include "OSGNameAttachment.h" #include #include @@ -272,7 +273,7 @@ void FieldContainer::registerChangedContainer(void) _pContainerChanges, _bvChanged); #endif -// osgSpinLock(&_uiContainerId, SpinLockBit); + osgSpinLock(&_uiContainerId, SpinLockBit); if(_pContainerChanges == NULL) { @@ -283,10 +284,28 @@ void FieldContainer::registerChangedContainer(void) _pContainerChanges->uiContainerId = this->getId(); _pContainerChanges->bvUncommittedChanges = &_bvChanged; } + else + { + if(_pContainerChanges->pList != Thread::getCurrentChangeList()) + { + std::string name("Unknown Name"); + AttachmentContainer* attachment_container(dynamic_cast(this)); + if (NULL != attachment_container) + { + const Char8* temp_name(OSG::getName(attachment_container)); + if (NULL != temp_name) + { + name = temp_name; + } + } + SWARNING << "Unsafe change from multiple threads for FieldContainer [" + << getType().getCName() << "]: " << name << std::endl; + } + } Thread::getCurrentChangeList()->addUncommited(_pContainerChanges); -// osgSpinLockRelease(&_uiContainerId, SpinLockClearMask); + osgSpinLockRelease(&_uiContainerId, SpinLockClearMask); } void FieldContainer::registerChangedContainerV(void) diff --git a/Source/Base/FieldContainer/Base/OSGFieldContainer.inl b/Source/Base/FieldContainer/Base/OSGFieldContainer.inl index ed79cec49..851b45d68 100644 --- a/Source/Base/FieldContainer/Base/OSGFieldContainer.inl +++ b/Source/Base/FieldContainer/Base/OSGFieldContainer.inl @@ -213,12 +213,16 @@ FieldContainer::~FieldContainer(void) _pFieldFlags = NULL; } + osgSpinLock(&_uiContainerId, SpinLockBit); + if(_pContainerChanges != NULL) { _pContainerChanges->release(); _pContainerChanges = NULL; } + + osgSpinLockRelease(&_uiContainerId, SpinLockClearMask); } inline @@ -382,11 +386,13 @@ void FieldContainer::editMField(ConstFieldMaskArg whichField, inline void FieldContainer::clearUncommited(ConstFieldMaskArg whichField) { + osgSpinLock(&_uiContainerId, SpinLockBit); if(_pContainerChanges != NULL) { _pContainerChanges->whichField |= whichField; *(_pContainerChanges->bvUncommittedChanges) &= ~whichField; } + osgSpinLockRelease(&_uiContainerId, SpinLockClearMask); } #ifdef OSG_MT_CPTR_ASPECT diff --git a/Source/Base/FieldContainer/Base/OSGReflexiveContainer.inl b/Source/Base/FieldContainer/Base/OSGReflexiveContainer.inl index 551b50b42..b97fc9193 100644 --- a/Source/Base/FieldContainer/Base/OSGReflexiveContainer.inl +++ b/Source/Base/FieldContainer/Base/OSGReflexiveContainer.inl @@ -133,7 +133,9 @@ void ReflexiveContainer::onDestroyAspect(UInt32, inline void ReflexiveContainer::execEndEdit(ConstFieldMaskArg whichField) { + osgSpinLock(&_uiContainerId, SpinLockBit); _pContainerChanges->whichField |= whichField; + osgSpinLockRelease(&_uiContainerId, SpinLockClearMask); } #if 0 @@ -147,7 +149,7 @@ ContainerChangeEntry *ReflexiveContainer::getChangeEntry(void) inline void ReflexiveContainer::clearChangeEntry(ContainerChangeEntry *pRef) { -// osgSpinLock(&_uiContainerId, SpinLockBit); + osgSpinLock(&_uiContainerId, SpinLockBit); if(_pContainerChanges == pRef) { @@ -155,7 +157,7 @@ void ReflexiveContainer::clearChangeEntry(ContainerChangeEntry *pRef) _bvChanged = 0x0000; } -// osgSpinLockRelease(&_uiContainerId, SpinLockClearMask); + osgSpinLockRelease(&_uiContainerId, SpinLockClearMask); } inline From 6860afe975560fed2c2c614b86242d3e8786366f Mon Sep 17 00:00:00 2001 From: Patrick Hartling Date: Mon, 28 Nov 2011 09:00:17 -0600 Subject: [PATCH 09/15] Fixed OSG::getenv() on Windows. Do not define OSG_STATIC_MEMEBER_NEEDS_COPY_ASIGN_INIT when using Visual C++. I suspect that this was necessary with Visual C++ 7.1, but it definitely isn't needed with 9.0. It looks like type object registration has changed in a way that causes registration to occur on OSG::TypeBase construction, and if that happens twice (once for a temporary and once for the actual static data member), then that leads to crashes when the type factory is initialized. --- Source/Base/Base/OSGBaseFunctions.inl | 3 +-- Source/Base/Base/OSGConfig.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/Base/Base/OSGBaseFunctions.inl b/Source/Base/Base/OSGBaseFunctions.inl index c6d4fe7d4..123782b47 100644 --- a/Source/Base/Base/OSGBaseFunctions.inl +++ b/Source/Base/Base/OSGBaseFunctions.inl @@ -2697,9 +2697,8 @@ OSG::Int32 putenv(Char8 *string) inline Char8 *getenv(const Char8 *string) { - return NULL; + return ::getenv(string); } -#else #endif /*! Pause program execution for the given number of milliseconds. diff --git a/Source/Base/Base/OSGConfig.h b/Source/Base/Base/OSGConfig.h index a44fb5534..e2b6b888b 100644 --- a/Source/Base/Base/OSGConfig.h +++ b/Source/Base/Base/OSGConfig.h @@ -618,7 +618,7 @@ # define OSG_TMPL_STATIC_MEMBER_NEEDS_CLASS_INSTANTIATION -# define OSG_STATIC_MEMEBER_NEEDS_COPY_ASIGN_INIT +//# define OSG_STATIC_MEMEBER_NEEDS_COPY_ASIGN_INIT # define OSG_MICROSOFT_DOTNET_COMPILER_HACKS From 58c5697231bff6906c61afe811f88a7e28c42161 Mon Sep 17 00:00:00 2001 From: Patrick Hartling Date: Mon, 28 Nov 2011 09:05:14 -0600 Subject: [PATCH 10/15] Fix GDAL includes. --- Source/Base/Base/OSGBaseFunctions.inl | 3 ++- Source/System/Image/FileIO/OSGGDALImageFileType.cpp | 6 +++--- Source/System/Image/FileIO/OSGGDALImageFileType.h | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/Base/Base/OSGBaseFunctions.inl b/Source/Base/Base/OSGBaseFunctions.inl index 123782b47..c6d4fe7d4 100644 --- a/Source/Base/Base/OSGBaseFunctions.inl +++ b/Source/Base/Base/OSGBaseFunctions.inl @@ -2697,8 +2697,9 @@ OSG::Int32 putenv(Char8 *string) inline Char8 *getenv(const Char8 *string) { - return ::getenv(string); + return NULL; } +#else #endif /*! Pause program execution for the given number of milliseconds. diff --git a/Source/System/Image/FileIO/OSGGDALImageFileType.cpp b/Source/System/Image/FileIO/OSGGDALImageFileType.cpp index 8cfbb9119..cfe31aaec 100644 --- a/Source/System/Image/FileIO/OSGGDALImageFileType.cpp +++ b/Source/System/Image/FileIO/OSGGDALImageFileType.cpp @@ -48,9 +48,9 @@ #include "OSGGeoReferenceAttachment.h" #ifdef OSG_WITH_GDAL -#include "gdal/gdal_priv.h" -#include "gdal/ogr_srs_api.h" -#include "gdal/cpl_multiproc.h" +#include "gdal_priv.h" +#include "ogr_srs_api.h" +#include "cpl_multiproc.h" #endif diff --git a/Source/System/Image/FileIO/OSGGDALImageFileType.h b/Source/System/Image/FileIO/OSGGDALImageFileType.h index 1b9b92dc4..ac0549d0c 100644 --- a/Source/System/Image/FileIO/OSGGDALImageFileType.h +++ b/Source/System/Image/FileIO/OSGGDALImageFileType.h @@ -48,8 +48,8 @@ #include "boost/shared_ptr.hpp" #ifdef OSG_WITH_GDAL -#include "gdal/gdal_priv.h" -#include "gdal/ogr_srs_api.h" +#include "gdal_priv.h" +#include "ogr_srs_api.h" #endif OSG_BEGIN_NAMESPACE From 8b8b455ab135ed19081deb4bd13c1181c398cccb Mon Sep 17 00:00:00 2001 From: Patrick Hartling Date: Mon, 28 Nov 2011 09:24:29 -0600 Subject: [PATCH 11/15] Fixed OSG::getenv() on Windows. --- Source/Base/Base/OSGBaseFunctions.inl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Base/Base/OSGBaseFunctions.inl b/Source/Base/Base/OSGBaseFunctions.inl index c6d4fe7d4..123782b47 100644 --- a/Source/Base/Base/OSGBaseFunctions.inl +++ b/Source/Base/Base/OSGBaseFunctions.inl @@ -2697,9 +2697,8 @@ OSG::Int32 putenv(Char8 *string) inline Char8 *getenv(const Char8 *string) { - return NULL; + return ::getenv(string); } -#else #endif /*! Pause program execution for the given number of milliseconds. From 15658ef1594ed4f9c52220a2e262816b5d798c35 Mon Sep 17 00:00:00 2001 From: Allen Bierbaum Date: Fri, 22 Feb 2013 19:57:30 -0600 Subject: [PATCH 12/15] Fix compile issues. See: 5c04cbbba This changes over to this->setValue to comply with gcc 4.7 --- Source/Base/Base/OSGColor.inl | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Source/Base/Base/OSGColor.inl b/Source/Base/Base/OSGColor.inl index 73fcc5e93..58f0db44d 100644 --- a/Source/Base/Base/OSGColor.inl +++ b/Source/Base/Base/OSGColor.inl @@ -224,9 +224,9 @@ UInt32 Color3::minPart(const ValueType *rgbP) template inline Color3::Color3(void) { - setValues(TypeTraits::getZeroElement(), - TypeTraits::getZeroElement(), - TypeTraits::getZeroElement()); + this->setValues(TypeTraits::getZeroElement(), + TypeTraits::getZeroElement(), + TypeTraits::getZeroElement()); } @@ -243,7 +243,7 @@ Color3::Color3(const ValueType red, const ValueType green, const ValueType blue) { - setValues(red, green, blue); + this->setValues(red, green, blue); } @@ -255,9 +255,9 @@ Color3::~Color3(void) template inline void Color3::clear(void) { - setValues(TypeTraits::getZeroElement(), - TypeTraits::getZeroElement(), - TypeTraits::getZeroElement()); + this->setValues(TypeTraits::getZeroElement(), + TypeTraits::getZeroElement(), + TypeTraits::getZeroElement()); } @@ -266,7 +266,7 @@ void Color3::setValuesRGB(const ValueType red, const ValueType green, const ValueType blue) { - setValues(red, green, blue); + this->setValues(red, green, blue); } @@ -284,9 +284,9 @@ void Color3::setRandom(void) { Real32 rf = 1.0 / Real32(RAND_MAX); - setValuesRGB(TypeTraits::getPortion(rf * rand()), - TypeTraits::getPortion(rf * rand()), - TypeTraits::getPortion(rf * rand())); + this->setValuesRGB(TypeTraits::getPortion(rf * rand()), + TypeTraits::getPortion(rf * rand()), + TypeTraits::getPortion(rf * rand())); } /*! method to set the rgb values (BBGGRR) @@ -399,10 +399,10 @@ const Color4 Color4::Null; template inline Color4::Color4(void) { - setValues(TypeTraits::getZeroElement(), - TypeTraits::getZeroElement(), - TypeTraits::getZeroElement(), - TypeTraits::getZeroElement()); + this->setValues(TypeTraits::getZeroElement(), + TypeTraits::getZeroElement(), + TypeTraits::getZeroElement(), + TypeTraits::getZeroElement()); } @@ -420,7 +420,7 @@ Color4::Color4(const ValueType red, const ValueType blue, const ValueType alpha) { - setValues(red, green, blue, alpha); + this->setValues(red, green, blue, alpha); } @@ -432,10 +432,10 @@ Color4::~Color4(void) template inline void Color4::clear(void) { - setValues(TypeTraits::getZeroElement(), - TypeTraits::getZeroElement(), - TypeTraits::getZeroElement(), - TypeTraits::getZeroElement()); + this->setValues(TypeTraits::getZeroElement(), + TypeTraits::getZeroElement(), + TypeTraits::getZeroElement(), + TypeTraits::getZeroElement()); } @@ -445,7 +445,7 @@ void Color4::setValuesRGBA(const ValueType red, const ValueType blue, const ValueType alpha) { - setValues(red, green, blue, alpha); + this->setValues(red, green, blue, alpha); } template inline From c1c414105d56506932f9c383d14c790a64ba0d11 Mon Sep 17 00:00:00 2001 From: Allen Bierbaum Date: Sun, 24 Feb 2013 12:59:00 -0600 Subject: [PATCH 13/15] Fix compiler issues for gcc 4.7 related to method lookup. --- .../FieldContainer/Mixins/OSGDynamicAttachmentMixin.inl | 6 +++--- .../ComplexSceneManager/VRMLNodes/OSGLimitedCounters.inl | 6 +++--- Source/System/FileIO/Base/OSGZStream.inl | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Base/FieldContainer/Mixins/OSGDynamicAttachmentMixin.inl b/Source/Base/FieldContainer/Mixins/OSGDynamicAttachmentMixin.inl index 7d6af56bb..4b97a3daa 100644 --- a/Source/Base/FieldContainer/Mixins/OSGDynamicAttachmentMixin.inl +++ b/Source/Base/FieldContainer/Mixins/OSGDynamicAttachmentMixin.inl @@ -359,9 +359,9 @@ typename DynFieldAttachment::ObjCPtr { ObjCPtr returnValue; - newAspectCopy(returnValue, - dynamic_cast(pRefAspect), - dynamic_cast(this)); + this->newAspectCopy(returnValue, + dynamic_cast(pRefAspect), + dynamic_cast(this)); return returnValue; } diff --git a/Source/Contrib/ComplexSceneManager/VRMLNodes/OSGLimitedCounters.inl b/Source/Contrib/ComplexSceneManager/VRMLNodes/OSGLimitedCounters.inl index b62e8ef25..84660efd8 100644 --- a/Source/Contrib/ComplexSceneManager/VRMLNodes/OSGLimitedCounters.inl +++ b/Source/Contrib/ComplexSceneManager/VRMLNodes/OSGLimitedCounters.inl @@ -543,9 +543,9 @@ FieldContainer *LimitedCounterImpl::createAspectCopy( { Self *returnValue; - newAspectCopy(returnValue, - dynamic_cast(pRefAspect), - dynamic_cast(this)); + this->newAspectCopy(returnValue, + dynamic_cast(pRefAspect), + dynamic_cast(this)); return returnValue; } diff --git a/Source/System/FileIO/Base/OSGZStream.inl b/Source/System/FileIO/Base/OSGZStream.inl index 6e309d00b..d078d8944 100644 --- a/Source/System/FileIO/Base/OSGZStream.inl +++ b/Source/System/FileIO/Base/OSGZStream.inl @@ -94,7 +94,7 @@ basic_zip_streambuf::overflow(int_type c) } if (zip_to_stream(this->pbase(), w)) { - setp(this->pbase(), this->epptr() - 1); + this->setp(this->pbase(), this->epptr() - 1); return c; } else From 41aec08c1f250bae697dad0bdc37c9465f916b4b Mon Sep 17 00:00:00 2001 From: Aron Bierbaum Date: Mon, 29 Dec 2014 09:31:13 -0600 Subject: [PATCH 14/15] fixed: png compile problems (deprecated png_set_gray_1_2_4_to_8), thanks to J.Ehnes for the report (cherry picked from commit 39c42e9f8e17a6a7bbc7972912f5124fb8f7349b) --- Source/System/Image/FileIO/OSGPNGImageFileType.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/System/Image/FileIO/OSGPNGImageFileType.cpp b/Source/System/Image/FileIO/OSGPNGImageFileType.cpp index cd6b63d88..347d569e3 100644 --- a/Source/System/Image/FileIO/OSGPNGImageFileType.cpp +++ b/Source/System/Image/FileIO/OSGPNGImageFileType.cpp @@ -204,7 +204,7 @@ bool PNGImageFileType::read( Image *OSG_PNG_ARG(pImage ), // Convert < 8 bit to 8 bit if(color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { - png_set_gray_1_2_4_to_8(png_ptr); + png_set_expand_gray_1_2_4_to_8(png_ptr); bit_depth = 8; } @@ -681,7 +681,7 @@ UInt64 PNGImageFileType::restoreData( Image *OSG_PNG_ARG (pImage ), // Convert < 8 bit to 8 bit if(color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { - png_set_gray_1_2_4_to_8(png_ptr); + png_set_expand_gray_1_2_4_to_8(png_ptr); bit_depth = 8; } From 61e1394b768729d7f7aa1484c1cc6c4b0eb99277 Mon Sep 17 00:00:00 2001 From: gerrit Date: Fri, 29 Apr 2011 16:11:18 +0800 Subject: [PATCH 15/15] fixed: deprecated jumpbuf (thanks to A. Halm for the patch) (cherry picked from commit 11b206bf344dd4f1686d19f006047198704a7e1f) --- Source/System/Image/FileIO/OSGPNGImageFileType.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/System/Image/FileIO/OSGPNGImageFileType.cpp b/Source/System/Image/FileIO/OSGPNGImageFileType.cpp index 347d569e3..0a1ddb48c 100644 --- a/Source/System/Image/FileIO/OSGPNGImageFileType.cpp +++ b/Source/System/Image/FileIO/OSGPNGImageFileType.cpp @@ -125,7 +125,7 @@ static void errorOutput (png_structp png_ptr, const char *message) { FFATAL (("PNG: %s\n", message )); - longjmp(png_ptr->jmpbuf, 1); + longjmp(png_jmpbuf(png_ptr), 1); } static void warningOutput (png_structp OSG_CHECK_ARG(png_ptr), @@ -175,7 +175,7 @@ bool PNGImageFileType::read( Image *OSG_PNG_ARG(pImage ), return false; } - if(setjmp(png_ptr->jmpbuf)) + if(setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, 0); return false; @@ -651,7 +651,7 @@ UInt64 PNGImageFileType::restoreData( Image *OSG_PNG_ARG (pImage ), return 0; } - if(setjmp(png_ptr->jmpbuf)) + if(setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, 0); return 0;