Skip to content

Commit 07d240a

Browse files
committed
Merge pull request #410 from andrewkaufman/houdiniSCCPath
Houdini SceneCache nodes can load the full path
2 parents 98cfac1 + 2b23e55 commit 07d240a

File tree

8 files changed

+167
-24
lines changed

8 files changed

+167
-24
lines changed

include/IECoreHoudini/OBJ_SceneCacheTransform.h

Lines changed: 2 additions & 1 deletion
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-2015, 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
@@ -105,6 +105,7 @@ class OBJ_SceneCacheTransform : public OBJ_SceneCacheNode<OBJ_SubNet>
105105
UT_String shapeFilter;
106106
UT_String tagFilterStr;
107107
UT_StringMMPattern tagFilter;
108+
UT_String fullPathName;
108109
};
109110

110111
/// Called by expandHierarchy() and doExpandChildren() when the SceneCache contains an object.

include/IECoreHoudini/SOP_SceneCacheSource.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//////////////////////////////////////////////////////////////////////////
22
//
3-
// Copyright (c) 2012-2014, Image Engine Design Inc. All rights reserved.
3+
// Copyright (c) 2012-2015, 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
@@ -79,6 +79,7 @@ class SOP_SceneCacheSource : public SceneCacheNode<SOP_Node>
7979
GeometryType geometryType;
8080
std::string attributeFilter;
8181
std::string attributeCopy;
82+
std::string fullPathName;
8283
UT_StringMMPattern shapeFilter;
8384
UT_StringMMPattern tagFilter;
8485

@@ -94,7 +95,7 @@ class SOP_SceneCacheSource : public SceneCacheNode<SOP_Node>
9495
// Groups, and CoordinateSystems. Updates animatedTopology and animatedPrimVars if appropriate.
9596
IECore::ConstObjectPtr transformObject( const IECore::Object *object, const Imath::M44d &transform, Parameters &params );
9697
// Convert the object to Houdini, optimizing for animated primitive variables if possible.
97-
bool convertObject( const IECore::Object *object, const std::string &name, Parameters &params );
98+
bool convertObject( const IECore::Object *object, const std::string &name, const IECore::SceneInterface *scene, Parameters &params );
9899

99100
void loadObjects( const IECore::SceneInterface *scene, Imath::M44d transform, double time, Space space, Parameters &params, size_t rootSize );
100101
IECore::MatrixTransformPtr matrixTransform( Imath::M44d t );

include/IECoreHoudini/SceneCacheNode.h

Lines changed: 4 additions & 1 deletion
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-2015, 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
@@ -67,6 +67,7 @@ class SceneCacheNode : public BaseType
6767
static PRM_Name pAttributeCopy;
6868
static PRM_Name pTagFilter;
6969
static PRM_Name pShapeFilter;
70+
static PRM_Name pFullPathName;
7071

7172
static PRM_Default rootDefault;
7273
static PRM_Default spaceDefault;
@@ -122,6 +123,8 @@ class SceneCacheNode : public BaseType
122123
void getShapeFilter( UT_String &filter ) const;
123124
void getShapeFilter( UT_StringMMPattern &filter ) const;
124125
void setShapeFilter( const UT_String &filter );
126+
void getFullPathName( UT_String &name ) const;
127+
void setFullPathName( const UT_String &name );
125128
void referenceParent( const char *parmName );
126129

127130
/// Access point to the actual SceneCache. All users should only access the cache

src/IECoreHoudini/OBJ_SceneCacheGeometry.cpp

Lines changed: 7 additions & 3 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-2015, 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
@@ -97,11 +97,12 @@ void OBJ_SceneCacheGeometry::expandHierarchy( const SceneInterface *scene )
9797

9898
void OBJ_SceneCacheGeometry::pushToHierarchy()
9999
{
100-
UT_String attribFilter, attribCopy, tagFilter, shapeFilter;
100+
UT_String attribFilter, attribCopy, tagFilter, shapeFilter, fullPathName;
101101
getAttributeFilter( attribFilter );
102102
getAttributeCopy( attribCopy );
103103
getTagFilter( tagFilter );
104104
getShapeFilter( shapeFilter );
105+
getFullPathName( fullPathName );
105106
GeometryType geomType = getGeometryType();
106107

107108
UT_PtrArray<OP_Node*> children;
@@ -113,6 +114,7 @@ void OBJ_SceneCacheGeometry::pushToHierarchy()
113114
sop->setAttributeCopy( attribCopy );
114115
sop->setTagFilter( tagFilter );
115116
sop->setShapeFilter( shapeFilter );
117+
sop->setFullPathName( fullPathName );
116118
sop->setGeometryType( (SOP_SceneCacheSource::GeometryType)geomType );
117119
}
118120
}
@@ -135,7 +137,7 @@ void OBJ_SceneCacheGeometry::doExpandGeometry( const SceneInterface *scene )
135137
sopSpace = SOP_SceneCacheSource::Path;
136138
}
137139

138-
UT_String attribFilter, attribCopy, tagFilter, shapeFilter;
140+
UT_String attribFilter, attribCopy, tagFilter, shapeFilter, fullPathName;
139141
getAttributeFilter( attribFilter );
140142
sop->setAttributeFilter( attribFilter );
141143
getAttributeCopy( attribCopy );
@@ -144,6 +146,8 @@ void OBJ_SceneCacheGeometry::doExpandGeometry( const SceneInterface *scene )
144146
sop->setTagFilter( tagFilter );
145147
getShapeFilter( shapeFilter );
146148
sop->setShapeFilter( shapeFilter );
149+
getFullPathName( fullPathName );
150+
sop->setFullPathName( fullPathName );
147151

148152
sop->setSpace( sopSpace );
149153
sop->setObjectOnly( objectOnly );

src/IECoreHoudini/OBJ_SceneCacheTransform.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//////////////////////////////////////////////////////////////////////////
22
//
3-
// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved.
3+
// Copyright (c) 2013-2015, 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
@@ -143,6 +143,7 @@ void OBJ_SceneCacheTransform::expandHierarchy( const SceneInterface *scene )
143143
getShapeFilter( params.shapeFilter );
144144
getTagFilter( params.tagFilterStr );
145145
getTagFilter( params.tagFilter );
146+
getFullPathName( params.fullPathName );
146147

147148
if ( params.hierarchy == FlatGeometry )
148149
{
@@ -216,6 +217,7 @@ OBJ_Node *OBJ_SceneCacheTransform::doExpandObject( const SceneInterface *scene,
216217
geo->setAttributeFilter( params.attributeFilter );
217218
geo->setAttributeCopy( params.attributeCopy );
218219
geo->setShapeFilter( params.shapeFilter );
220+
geo->setFullPathName( params.fullPathName );
219221

220222
bool visible = tagged( scene, params.tagFilter );
221223
if ( visible )
@@ -241,6 +243,7 @@ OBJ_Node *OBJ_SceneCacheTransform::doExpandChild( const SceneInterface *scene, O
241243
xform->setAttributeFilter( params.attributeFilter );
242244
xform->setAttributeCopy( params.attributeCopy );
243245
xform->setShapeFilter( params.shapeFilter );
246+
xform->setFullPathName( params.fullPathName );
244247
xform->setInt( pHierarchy.getToken(), 0, 0, params.hierarchy );
245248
xform->setInt( pDepth.getToken(), 0, 0, params.depth );
246249

@@ -342,10 +345,11 @@ void OBJ_SceneCacheTransform::doExpandChildren( const SceneInterface *scene, OP_
342345

343346
void OBJ_SceneCacheTransform::pushToHierarchy()
344347
{
345-
UT_String attribFilter, attribCopy, shapeFilter;
348+
UT_String attribFilter, attribCopy, shapeFilter, fullPathName;
346349
getAttributeFilter( attribFilter );
347350
getAttributeCopy( attribCopy );
348351
getShapeFilter( shapeFilter );
352+
getFullPathName( fullPathName );
349353
GeometryType geometryType = getGeometryType();
350354

351355
UT_String tagFilterStr;
@@ -361,6 +365,7 @@ void OBJ_SceneCacheTransform::pushToHierarchy()
361365
xform->setAttributeFilter( attribFilter );
362366
xform->setAttributeCopy( attribCopy );
363367
xform->setShapeFilter( shapeFilter );
368+
xform->setFullPathName( fullPathName );
364369
xform->setGeometryType( geometryType );
365370

366371
std::string file;
@@ -387,6 +392,7 @@ void OBJ_SceneCacheTransform::pushToHierarchy()
387392
geo->setAttributeFilter( attribFilter );
388393
geo->setAttributeCopy( attribCopy );
389394
geo->setShapeFilter( shapeFilter );
395+
geo->setFullPathName( fullPathName );
390396
geo->setGeometryType( (OBJ_SceneCacheGeometry::GeometryType)geometryType );
391397

392398
std::string file;
@@ -420,6 +426,7 @@ OBJ_SceneCacheTransform::Parameters::Parameters( const Parameters &other )
420426
shapeFilter = other.shapeFilter;
421427
tagFilterStr = other.tagFilterStr;
422428
tagFilter.compile( tagFilterStr );
429+
fullPathName = other.fullPathName;
423430
}
424431

425432
//////////////////////////////////////////////////////////////////////////////////////////

src/IECoreHoudini/SOP_SceneCacheSource.cpp

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//////////////////////////////////////////////////////////////////////////
22
//
3-
// Copyright (c) 2012-2014, Image Engine Design Inc. All rights reserved.
3+
// Copyright (c) 2012-2015, 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
@@ -194,6 +194,9 @@ OP_ERROR SOP_SceneCacheSource::cookMySop( OP_Context &context )
194194
UT_String attributeCopy;
195195
getAttributeCopy( attributeCopy );
196196

197+
UT_String fullPathName;
198+
getFullPathName( fullPathName );
199+
197200
ConstSceneInterfacePtr scene = this->scene( file, path );
198201
if ( !scene )
199202
{
@@ -210,6 +213,7 @@ OP_ERROR SOP_SceneCacheSource::cookMySop( OP_Context &context )
210213
hash.append( shapeFilterStr );
211214
hash.append( attributeFilter );
212215
hash.append( attributeCopy );
216+
hash.append( fullPathName );
213217
hash.append( geometryType );
214218
hash.append( getObjectOnly() );
215219

@@ -237,6 +241,7 @@ OP_ERROR SOP_SceneCacheSource::cookMySop( OP_Context &context )
237241
getAttributeFilter( attribFilter );
238242
params.attributeFilter = attribFilter.toStdString();
239243
params.attributeCopy = attributeCopy.toStdString();
244+
params.fullPathName = fullPathName.toStdString();
240245
params.geometryType = getGeometryType();
241246
getShapeFilter( params.shapeFilter );
242247
getTagFilter( params.tagFilter );
@@ -380,7 +385,7 @@ void SOP_SceneCacheSource::loadObjects( const IECore::SceneInterface *scene, Ima
380385
}
381386

382387
// convert the object to Houdini
383-
if ( !convertObject( object.get(), name, params ) )
388+
if ( !convertObject( object.get(), name, scene, params ) )
384389
{
385390
std::string fullName;
386391
SceneInterface::Path path;
@@ -525,7 +530,7 @@ ConstObjectPtr SOP_SceneCacheSource::transformObject( const IECore::Object *obje
525530
return object;
526531
}
527532

528-
bool SOP_SceneCacheSource::convertObject( const IECore::Object *object, const std::string &name, Parameters &params )
533+
bool SOP_SceneCacheSource::convertObject( const IECore::Object *object, const std::string &name, const SceneInterface *scene, Parameters &params )
529534
{
530535
ToHoudiniGeometryConverterPtr converter = 0;
531536
if ( params.geometryType == Cortex )
@@ -602,7 +607,28 @@ bool SOP_SceneCacheSource::convertObject( const IECore::Object *object, const st
602607

603608
try
604609
{
605-
return converter->convert( myGdpHandle );
610+
GA_Offset firstNewPrim = gdp->getPrimitiveMap().lastOffset() + 1;
611+
612+
bool status = converter->convert( myGdpHandle );
613+
614+
if ( params.fullPathName != "" )
615+
{
616+
// adds the full path in addition to the relative name
617+
const GA_IndexMap &primMap = gdp->getPrimitiveMap();
618+
GA_Range newPrims( primMap, firstNewPrim, primMap.lastOffset() + 1 );
619+
if ( newPrims.isValid() )
620+
{
621+
std::string fullName;
622+
SceneInterface::Path path;
623+
scene->path( path );
624+
SceneInterface::pathToString( path, fullName );
625+
626+
GA_RWAttributeRef pathAttribRef = ToHoudiniStringVectorAttribConverter::convertString( params.fullPathName, fullName, gdp, newPrims );
627+
status = status && pathAttribRef.isValid();
628+
}
629+
}
630+
631+
return status;
606632
}
607633
catch ( std::exception &e )
608634
{

src/IECoreHoudini/SceneCacheNode.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//////////////////////////////////////////////////////////////////////////
22
//
3-
// Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved.
3+
// Copyright (c) 2013-2015, 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
@@ -90,6 +90,9 @@ PRM_Name SceneCacheNode<BaseType>::pTagFilter( "tagFilter", "Tag Filter" );
9090
template<typename BaseType>
9191
PRM_Name SceneCacheNode<BaseType>::pShapeFilter( "shapeFilter", "Shape Filter" );
9292

93+
template<typename BaseType>
94+
PRM_Name SceneCacheNode<BaseType>::pFullPathName( "fullPathName", "Full Path Name" );
95+
9396
template<typename BaseType>
9497
PRM_Name SceneCacheNode<BaseType>::pGeometryType( "geometryType", "Geometry Type" );
9598

@@ -191,7 +194,7 @@ OP_TemplatePair *SceneCacheNode<BaseType>::buildOptionParameters()
191194
static PRM_Template *thisTemplate = 0;
192195
if ( !thisTemplate )
193196
{
194-
thisTemplate = new PRM_Template[6];
197+
thisTemplate = new PRM_Template[7];
195198

196199
thisTemplate[0] = PRM_Template(
197200
PRM_INT, 1, &pGeometryType, &geometryTypeDefault, &geometryTypeList, 0, 0, 0, 0,
@@ -227,6 +230,14 @@ OP_TemplatePair *SceneCacheNode<BaseType>::buildOptionParameters()
227230
"visibility. In FlatGeometry mode they essentially delete the non-tagged geometry. Uses Houdini "
228231
"matching syntax, but matches *any* of the tags."
229232
);
233+
234+
thisTemplate[5] = PRM_Template(
235+
PRM_STRING, 1, &pFullPathName, 0, 0, 0, 0, 0, 0,
236+
"Load the full path of the object as a primitive attribute with this name. This is for user "
237+
"convenience and has no meaning in terms of processing or exporting SceneCaches. If left empty, "
238+
"the full path will not be loaded. It is the user's responsibility to remove this attribute prior "
239+
"to exporting new SceneCaches if necessary."
240+
);
230241
}
231242

232243
static OP_TemplatePair *templatePair = 0;
@@ -518,6 +529,18 @@ void SceneCacheNode<BaseType>::setShapeFilter( const UT_String &filter )
518529
this->setString( filter, CH_STRING_LITERAL, pShapeFilter.getToken(), 0, 0 );
519530
}
520531

532+
template<typename BaseType>
533+
void SceneCacheNode<BaseType>::getFullPathName( UT_String &name ) const
534+
{
535+
this->evalString( name, pFullPathName.getToken(), 0, 0 );
536+
}
537+
538+
template<typename BaseType>
539+
void SceneCacheNode<BaseType>::setFullPathName( const UT_String &name )
540+
{
541+
this->setString( name, CH_STRING_LITERAL, pFullPathName.getToken(), 0, 0 );
542+
}
543+
521544
template<typename BaseType>
522545
void SceneCacheNode<BaseType>::referenceParent( const char *parmName )
523546
{

0 commit comments

Comments
 (0)