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

Function ExtractLodingAnnotations

trinity/Shader/Tr2Effect.cpp:1376–1431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1374}
1375
1376bool ExtractLodingAnnotations( std::array<float, ITriEffectTextureParameter::UV_SET_MAX_COUNT>& densityScale, const char* name, const Tr2EffectAnnotationMap& effectAnnotations, const Tr2ConstantEffectParameterStructureList& constParams )
1377{
1378 std::fill( begin( densityScale ), end( densityScale ), 0.f );
1379
1380 auto annotations = find_if( begin( effectAnnotations ), end( effectAnnotations ), [name]( auto& x ) { return strcmp( name, x.first ) == 0; } );
1381 if( annotations == end( effectAnnotations ) )
1382 {
1383 return false;
1384 }
1385 bool enabled = false;
1386 uint32_t uvSet = 0;
1387 float scale = 1;
1388 const char* prefix = "LodUvScale";
1389 auto length = strlen( prefix );
1390 for( auto& annotation : annotations->second )
1391 {
1392 if( strncmp( annotation.name, prefix, length ) == 0 )
1393 {
1394 char* strEnd;
1395 auto uvIndex = strtol( annotation.name + length, &strEnd, 10 );
1396 if( *strEnd != 0 || uvIndex < 0 || uvIndex + 1 >= ITriEffectTextureParameter::UV_SET_MAX_COUNT )
1397 {
1398 continue;
1399 }
1400
1401 if( auto paramScale = GetUvScaleFromAnnotation( name, annotation, constParams ) )
1402 {
1403 densityScale[uvIndex + 1] = *paramScale;
1404 if( *paramScale > 0 )
1405 {
1406 enabled = true;
1407 }
1408 }
1409 else
1410 {
1411 return false;
1412 }
1413 }
1414 else if( strcmp( annotation.name, "LodPositionScale" ) == 0 )
1415 {
1416 if( auto paramScale = GetUvScaleFromAnnotation( name, annotation, constParams ) )
1417 {
1418 densityScale[0] = *paramScale;
1419 if( *paramScale > 0 )
1420 {
1421 enabled = true;
1422 }
1423 }
1424 else
1425 {
1426 return false;
1427 }
1428 }
1429 }
1430 return enabled;
1431}
1432
1433}

Callers 1

AddLoddableMethod · 0.85

Calls 3

GetUvScaleFromAnnotationFunction · 0.85
beginFunction · 0.50
endFunction · 0.50

Tested by

no test coverage detected