Skip to content

Commit

Permalink
Merge pull request #4 from andrewkaufman/agentIdStr
Browse files Browse the repository at this point in the history
AtomsCrowdReader : Add a hack for agentId as a string.
  • Loading branch information
andrewkaufman authored Dec 19, 2018
2 parents 548631d + 2f15ae3 commit 46a8819
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/AtomsGaffer/AtomsCrowdReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -730,4 +739,4 @@ void AtomsCrowdReader::compute( Gaffer::ValuePlug *output, const Gaffer::Context
}

ObjectSource::compute( output, context );
}
}

0 comments on commit 46a8819

Please sign in to comment.