MCPcopy Create free account
hub / github.com/carbonengine/trinity / GetHashValue

Method GetHashValue

trinity/Shader/Tr2Effect.cpp:1523–1550  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description: This method computes a hash value for the effect based on its path name and parameters. It is not without faults: the method doen't check which parameters are actually used by the effect, doesn't do anything with values coming from a variable store. The method is not light-weight and should not be c

Source from the content-addressed store, hash-verified

1521// Hash value for the effect
1522// --------------------------------------------------------------------------------------
1523unsigned Tr2Effect::GetHashValue() const
1524{
1525 unsigned hash = 0;
1526 if( m_effectResource )
1527 {
1528 hash = CcpHashFNV1( m_effectResource->GetPath(), wcslen( m_effectResource->GetPath() ) * sizeof( wchar_t ) );
1529 }
1530 for( auto& option : m_options )
1531 {
1532 hash = CcpHashFNV1( &option, sizeof( option ), hash );
1533 }
1534 for( auto it = m_constParameters.begin(); it != m_constParameters.end(); ++it )
1535 {
1536 auto name = it->name.c_str();
1537 // looks scary, but it's a constant string, so the pointer is unique
1538 hash = CcpHashFNV1( &name, sizeof( name ), hash );
1539 hash = CcpHashFNV1( &it->value, sizeof( it->value ), hash );
1540 }
1541 for( auto it = m_parameters.begin(); it != m_parameters.end(); ++it )
1542 {
1543 hash = ( *it )->GetHashValue( hash );
1544 }
1545 for( auto it = m_resources.begin(); it != m_resources.end(); ++it )
1546 {
1547 hash = ( *it )->GetHashValue( hash );
1548 }
1549 return hash;
1550}
1551
1552ITriEffectParameter* Tr2Effect::FindParameterByName( const char* name ) const
1553{

Callers 2

Tr2ImpostorManagerMethod · 0.45

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected