Skip to content

Commit 7f0dfa3

Browse files
committed
Merge pull request #280 from andrewkaufman/visibileCrash
Fixing crash in SceneCache ROP todo with "scene:visible" attribute
2 parents c2e375d + 53d6e6b commit 7f0dfa3

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

include/IECore/SceneInterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//////////////////////////////////////////////////////////////////////////
22
//
3-
// Copyright (c) 2013, Image Engine Design Inc. All rights reserved.
3+
// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
66
// modification, are permitted provided that the following conditions are
@@ -93,7 +93,7 @@ class SceneInterface : public RunTimeTyped
9393
/// Utility variable that can be used anytime you want to refer to the root path in the Scene.
9494
static const Path &rootPath;
9595
/// Name of the visibility attribute
96-
static const Name visibilityName;
96+
static const Name &visibilityName;
9797

9898
/// Create an instance of a subclass which is able to open the file found at "path".
9999
/// Files can be opened for Read, Write, or Append depending on the derived classes.

include/IECoreHoudini/ROP_SceneCacheWriter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ROP_SceneCacheWriter : public ROP_Node
7979

8080
private :
8181

82-
static const IECore::SceneInterface::Name &visibleAttribute;
82+
static const IECore::SceneInterface::Name &changingHierarchyAttribute;
8383

8484
bool linked( const std::string &file ) const;
8585

src/IECore/SceneInterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//////////////////////////////////////////////////////////////////////////
22
//
3-
// Copyright (c) 2013, Image Engine Design Inc. All rights reserved.
3+
// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
66
// modification, are permitted provided that the following conditions are
@@ -42,7 +42,7 @@ IE_CORE_DEFINERUNTIMETYPEDDESCRIPTION( SceneInterface )
4242

4343
const SceneInterface::Name &SceneInterface::rootName = IndexedIO::rootName;
4444
const SceneInterface::Path &SceneInterface::rootPath = IndexedIO::rootPath;
45-
const SceneInterface::Name SceneInterface::visibilityName( "scene:visible" );
45+
const SceneInterface::Name &SceneInterface::visibilityName( "scene:visible" );
4646

4747
class SceneInterface::CreatorMap : public std::map< std::pair< std::string, IndexedIO::OpenModeFlags >, CreatorFn>
4848
{

src/IECoreHoudini/ROP_SceneCacheWriter.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ PRM_Default ROP_SceneCacheWriter::fileDefault( 0, "$HIP/output.scc" );
7979
PRM_Default ROP_SceneCacheWriter::rootObjectDefault( 0, "/obj" );
8080
PRM_SpareData ROP_SceneCacheWriter::forceObjectsSpareData;
8181

82-
const SceneInterface::Name &ROP_SceneCacheWriter::visibleAttribute( "scene:visible" );
82+
const SceneInterface::Name &ROP_SceneCacheWriter::changingHierarchyAttribute( "sceneInterface:changingHierarchy" );
8383

8484
OP_TemplatePair *ROP_SceneCacheWriter::buildParameters()
8585
{
@@ -387,13 +387,14 @@ ROP_RENDER_CODE ROP_SceneCacheWriter::doWrite( const SceneInterface *liveScene,
387387

388388
if ( time != m_startTime )
389389
{
390-
outChild->writeAttribute( visibleAttribute, new BoolData( false ), time - 1e-6 );
390+
outChild->writeAttribute( changingHierarchyAttribute, new BoolData( true ), time );
391+
outChild->writeAttribute( IECore::SceneInterface::visibilityName, new BoolData( false ), time - 1e-6 );
391392
}
392393
}
393394

394-
if ( outChild->hasAttribute( visibleAttribute ) )
395+
if ( outChild->hasAttribute( changingHierarchyAttribute ) )
395396
{
396-
outChild->writeAttribute( visibleAttribute, new BoolData( true ), time );
397+
outChild->writeAttribute( IECore::SceneInterface::visibilityName, new BoolData( true ), time );
397398
}
398399

399400
ROP_RENDER_CODE status = doWrite( liveChild, outChild, time, progress );
@@ -403,20 +404,21 @@ ROP_RENDER_CODE ROP_SceneCacheWriter::doWrite( const SceneInterface *liveScene,
403404
}
404405
}
405406

406-
// turn visibleAttribute off if the child disappears
407+
// turn visibility off if the child disappears
407408
SceneInterface::NameList outChildren;
408409
outScene->childNames( outChildren );
409410
for ( SceneInterface::NameList::iterator it = outChildren.begin(); it != outChildren.end(); ++it )
410411
{
411412
if ( !liveScene->hasChild( *it ) )
412413
{
413414
SceneInterfacePtr outChild = outScene->child( *it );
414-
if ( !outChild->hasAttribute( visibleAttribute ) )
415+
if ( !outChild->hasAttribute( IECore::SceneInterface::visibilityName ) )
415416
{
416-
outChild->writeAttribute( visibleAttribute, new BoolData( true ), time - 1e-6 );
417+
outChild->writeAttribute( IECore::SceneInterface::visibilityName, new BoolData( true ), time - 1e-6 );
417418
}
418419

419-
outChild->writeAttribute( visibleAttribute, new BoolData( false ), time );
420+
outChild->writeAttribute( changingHierarchyAttribute, new BoolData( true ), time );
421+
outChild->writeAttribute( IECore::SceneInterface::visibilityName, new BoolData( false ), time );
420422
}
421423
}
422424

src/IECorePython/SceneInterfaceBinding.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//////////////////////////////////////////////////////////////////////////
22
//
3-
// Copyright (c) 2013, Image Engine Design Inc. All rights reserved.
3+
// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
66
// modification, are permitted provided that the following conditions are
@@ -268,7 +268,7 @@ void bindSceneInterface()
268268
.def( "create", SceneInterface::create ).staticmethod( "create" )
269269
.def( "supportedExtensions", supportedExtensions, ( arg("modes") = IndexedIO::Read|IndexedIO::Write|IndexedIO::Append ) ).staticmethod( "supportedExtensions" )
270270

271-
.add_static_property( "visibilityName", make_getter(&SceneInterface::visibilityName, return_value_policy<reference_existing_object>() ) )
271+
.def_readonly("visibilityName", &SceneInterface::visibilityName )
272272
;
273273
}
274274

0 commit comments

Comments
 (0)