From 5e9b7bef880dfb1614ea0ae7dfc2062cc2632dd1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 12 Jul 2006 09:40:03 +0000 Subject: [PATCH] From Brede Johansen, "I found some artifacts on some models and traced it back to the external palette override feature. There are some changes in the layout of the external record the loader have to take into consideration. The other fix is to remove the OF pools from the user data of the external ProxyNode when it is no longer needed." --- src/osgPlugins/OpenFlight/PrimaryRecords.cpp | 29 ++++++++++++++----- src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp | 2 ++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/osgPlugins/OpenFlight/PrimaryRecords.cpp b/src/osgPlugins/OpenFlight/PrimaryRecords.cpp index c1a5128f7..6e3e448a8 100644 --- a/src/osgPlugins/OpenFlight/PrimaryRecords.cpp +++ b/src/osgPlugins/OpenFlight/PrimaryRecords.cpp @@ -626,14 +626,27 @@ protected: _external->setFileName(0,strFile); // Set parent pools as user data - in.forward(4); - unsigned int mask = in.readUInt32(); - _external->setUserData( static_cast( new ParentPools( - ((mask & COLOR_PALETTE_OVERRIDE) ? NULL : document.getColorPool()), - ((mask & MATERIAL_PALETTE_OVERRIDE) ? NULL : document.getOrCreateMaterialPool()), - ((mask & TEXTURE_PALETTE_OVERRIDE) ? NULL : document.getOrCreateTexturePool()), - ((mask & LIGHT_POINT_PALETTE_OVERRIDE) ? NULL : document.getOrCreateLightPointAppearancePool()), - ((mask & SHADER_PALETTE_OVERRIDE) ? NULL : document.getOrCreateShaderPool()) ))); + if (document.version() >= VERSION_14_2) + { + in.forward(2); + + if (document.version() >= VERSION_15_1) + in.forward(2); + + uint32 mask = in.readUInt32(~0); + + // Possible bug in models with version number 15.4.1 ? + // Symptoms: Black trees in VegaPlayer town. + if (document.version() == 1541) + mask = ~0; + + _external->setUserData(new ParentPools( + ((mask & COLOR_PALETTE_OVERRIDE) ? NULL : document.getColorPool()), + ((mask & MATERIAL_PALETTE_OVERRIDE) ? NULL : document.getOrCreateMaterialPool()), + ((mask & TEXTURE_PALETTE_OVERRIDE) ? NULL : document.getOrCreateTexturePool()), + ((mask & LIGHT_POINT_PALETTE_OVERRIDE) ? NULL : document.getOrCreateLightPointAppearancePool()), + ((mask & SHADER_PALETTE_OVERRIDE) ? NULL : document.getOrCreateShaderPool()) )); + } // Add this implementation to parent implementation. if (_parent.valid()) diff --git a/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp b/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp index 4c816150c..8273fd611 100644 --- a/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp +++ b/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp @@ -41,7 +41,9 @@ public: virtual void apply(ProxyNode& node) { + // Transfer ownership of pools. _options->setUserData( node.getUserData() ); + node.setUserData(NULL); for (unsigned int pos=0; pos