From 2f15ae388dedd1b18c355bbc6c14a33eeb435048 Mon Sep 17 00:00:00 2001 From: Andrew Kaufman Date: Thu, 6 Dec 2018 11:01:52 -0800 Subject: [PATCH] AtomsCrowdReader : Add a hacky for agentId as a string. In order to use the agentId for cryptomattes we need a string attribute, but we don't currently have a way of changing attribute data type in Gaffer. This is just a hack until that functionality exists. --- src/AtomsGaffer/AtomsCrowdReader.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/AtomsGaffer/AtomsCrowdReader.cpp b/src/AtomsGaffer/AtomsCrowdReader.cpp index b8185ff..00a7d34 100644 --- a/src/AtomsGaffer/AtomsCrowdReader.cpp +++ b/src/AtomsGaffer/AtomsCrowdReader.cpp @@ -431,6 +431,10 @@ ConstObjectPtr AtomsCrowdReader::computeSource( const Gaffer::Context *context ) IntVectorDataPtr agentCacheIdsData = new IntVectorData; agentCacheIdsData->writable() = agentIds; + StringVectorDataPtr agentCacheIdsStrData = new StringVectorData; + auto &agentCacheIdsStr = agentCacheIdsStrData->writable(); + agentCacheIdsStr.resize( numAgents ); + StringVectorDataPtr agentTypesData = new StringVectorData; auto &agentTypes = agentTypesData->writable(); agentTypes.resize( numAgents ); @@ -474,6 +478,10 @@ ConstObjectPtr AtomsCrowdReader::computeSource( const Gaffer::Context *context ) CompoundDataPtr agentCompoundData = new CompoundData; auto &agentCompound = agentCompoundData->writable(); int agentId = agentIds[i]; + // \todo: In order to use the agentId for cryptomattes we need a string attribute, + // but we don't currently have a way of changing attribute data type in Gaffer. + // This is just a hack until that functionality exists. Remove when possible. + agentCacheIdsStr[i] = std::to_string( agentId ); // load in memory the agent type since the cache need this to interpolate the pose const std::string &agentTypeName = atomsCache.agentType( frame, agentId ); @@ -549,6 +557,7 @@ ConstObjectPtr AtomsCrowdReader::computeSource( const Gaffer::Context *context ) points->variables["atoms:variation"] = PrimitiveVariable( PrimitiveVariable::Vertex, agentVariationData ); points->variables["atoms:lod"] = PrimitiveVariable( PrimitiveVariable::Vertex, agentLodData ); points->variables["atoms:agentId"] = PrimitiveVariable( PrimitiveVariable::Vertex, agentCacheIdsData ); + points->variables["atoms:agentIdStr"] = PrimitiveVariable( PrimitiveVariable::Vertex, agentCacheIdsStrData ); points->variables["atoms:velocity"] = PrimitiveVariable( PrimitiveVariable::Vertex, velocityData ); points->variables["atoms:direction"] = PrimitiveVariable( PrimitiveVariable::Vertex, directionData ); points->variables["atoms:scale"] = PrimitiveVariable( PrimitiveVariable::Vertex, scaleData ); @@ -730,4 +739,4 @@ void AtomsCrowdReader::compute( Gaffer::ValuePlug *output, const Gaffer::Context } ObjectSource::compute( output, context ); -} \ No newline at end of file +}