Skip to content

Commit 456f9b4

Browse files
committed
Replacing getRangeByValue with the most obvious implementation.
On a large asset (1500 shapes, 3 million polys), this improves loading time as follows for the following geometry types: Cortex: 3.476s to 0.664s Houdini: 8m 23s to 3m 20s BoundingBox: 4.272s to 0.763s PointCloud: 3.256s to 0.426s
1 parent 1cc3ee5 commit 456f9b4

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/IECoreHoudini/SOP_SceneCacheSource.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,31 @@ bool SOP_SceneCacheSource::convertObject( const IECore::Object *object, const st
487487
return false;
488488
}
489489

490-
// attempt to optimize the conversion by re-using animated primitive variables
491490
const Primitive *primitive = IECore::runTimeCast<const Primitive>( object );
491+
492+
// attempt to optimize the conversion by re-using animated primitive variables
493+
/// \todo: This offset loop is only used because GU_Detail::getRangeByValue is
494+
/// terribly slow. Replace this if SideFx improves that function.
495+
GA_OffsetList offsets;
492496
GA_ROAttributeRef nameAttrRef = gdp->findStringTuple( GA_ATTRIB_PRIMITIVE, "name" );
493-
GA_Range primRange = gdp->getRangeByValue( nameAttrRef, name.c_str() );
497+
if ( nameAttrRef.isValid() )
498+
{
499+
const GA_Attribute *nameAttr = nameAttrRef.getAttribute();
500+
const GA_AIFSharedStringTuple *tuple = nameAttr->getAIFSharedStringTuple();
501+
502+
GA_Range range = gdp->getPrimitiveRange();
503+
for ( GA_Iterator it = range.begin(); !it.atEnd(); ++it )
504+
{
505+
const char *currentName = tuple->getString( nameAttr, it.getOffset(), 0 );
506+
if ( UT_String( currentName ).equal( name.c_str() ) )
507+
{
508+
offsets.append( it.getOffset() );
509+
}
510+
}
511+
}
512+
513+
GA_Range primRange( gdp->getPrimitiveMap(), offsets );
514+
494515
if ( primitive && !params.hasAnimatedTopology && params.hasAnimatedPrimVars && nameAttrRef.isValid() && !primRange.isEmpty() )
495516
{
496517
// this means constant topology and primitive variables, even though multiple samples were written

0 commit comments

Comments
 (0)