From 305cccd2630831074347ad9878c371a03b939622 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 23 Feb 2017 18:31:49 +0100 Subject: [PATCH] Don't print Geometry data (vertices, triangles, etc.) in showscenegraph --- components/sceneutil/serialize.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/components/sceneutil/serialize.cpp b/components/sceneutil/serialize.cpp index 969fa6668..64094275c 100644 --- a/components/sceneutil/serialize.cpp +++ b/components/sceneutil/serialize.cpp @@ -78,18 +78,31 @@ osgDB::ObjectWrapper* makeDummySerializer(const std::string& classname) return new osgDB::ObjectWrapper(createInstanceFunc, classname, "osg::Object"); } +class GeometrySerializer : public osgDB::ObjectWrapper +{ +public: + GeometrySerializer() + : osgDB::ObjectWrapper(createInstanceFunc, "osg::Geometry", "osg::Object osg::Drawable osg::Geometry") + { + } +}; void registerSerializers() { static bool done = false; if (!done) { - osgDB::Registry::instance()->getObjectWrapperManager()->addWrapper(new PositionAttitudeTransformSerializer); - osgDB::Registry::instance()->getObjectWrapperManager()->addWrapper(new SkeletonSerializer); - osgDB::Registry::instance()->getObjectWrapperManager()->addWrapper(new FrameSwitchSerializer); - osgDB::Registry::instance()->getObjectWrapperManager()->addWrapper(new RigGeometrySerializer); - osgDB::Registry::instance()->getObjectWrapperManager()->addWrapper(new LightManagerSerializer); - osgDB::Registry::instance()->getObjectWrapperManager()->addWrapper(new CameraRelativeTransformSerializer); + osgDB::ObjectWrapperManager* mgr = osgDB::Registry::instance()->getObjectWrapperManager(); + mgr->addWrapper(new PositionAttitudeTransformSerializer); + mgr->addWrapper(new SkeletonSerializer); + mgr->addWrapper(new FrameSwitchSerializer); + mgr->addWrapper(new RigGeometrySerializer); + mgr->addWrapper(new LightManagerSerializer); + mgr->addWrapper(new CameraRelativeTransformSerializer); + + // Don't serialize Geometry data as we are more interested in the overall structure rather than tons of vertex data that would make the file large and hard to read. + mgr->removeWrapper(mgr->findWrapper("osg::Geometry")); + mgr->addWrapper(new GeometrySerializer); // ignore the below for now to avoid warning spam const char* ignore[] = { @@ -120,7 +133,7 @@ void registerSerializers() }; for (size_t i=0; igetObjectWrapperManager()->addWrapper(makeDummySerializer(ignore[i])); + mgr->addWrapper(makeDummySerializer(ignore[i])); }