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

Method SetupLayout

trinity/Eve/SpaceObjectFactory/EveSOF.cpp:3030–3092  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3028}
3029
3030void EveSOF::SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutContainer, EveChildInstancedMeshesPtr& sharedMeshes, const EveSOFDNAPtr dna, const std::vector<Matrix>& offsets, uint32_t seedOverwrite )
3031{
3032 CCP_STATS_ZONE( __FUNCTION__ );
3033
3034 std::map<BlueSharedString, std::vector<EveSOFDataMgr::LocatorDirectionData>> locatorSets;
3035 // map out all possible locators that the layouts can utilize
3036 for( size_t hullIdx = 0; hullIdx < dna->GetMultiHullCount(); ++hullIdx )
3037 {
3038 const std::vector<BlueSharedString> locatorSetNames = dna->GetHullLocatorSetNames( hullIdx );
3039
3040 for( const auto& locatorSetName : locatorSetNames )
3041 {
3042 const std::vector<EveSOFDataMgr::LocatorDirectionData>* locators = dna->GetHullLocators( locatorSetName.c_str(), hullIdx );
3043 std::vector<EveSOFDataMgr::LocatorDirectionData> locatorsCopy( *locators );
3044
3045 auto existingSet = locatorSets.find( locatorSetName );
3046 if( existingSet == locatorSets.end() )
3047 {
3048 locatorSets.insert( { locatorSetName, locatorsCopy } );
3049 }
3050 else
3051 {
3052 locatorSets[locatorSetName].reserve( locatorSets[locatorSetName].size() + locatorsCopy.size() );
3053 locatorSets[locatorSetName].insert( locatorSets[locatorSetName].end(), locatorsCopy.begin(), locatorsCopy.end() );
3054 }
3055 }
3056 }
3057
3058 if( dna->GetLayoutCount() == 0 )
3059 {
3060 return;
3061 }
3062
3063 // dna can have multiple layouts
3064 for( size_t layoutIdx = 0; layoutIdx < dna->GetLayoutCount(); ++layoutIdx )
3065 {
3066 auto layout = dna->GetLayoutData( layoutIdx );
3067 size_t placementIdx = 0;
3068
3069 uint32_t oldSeed = TriRandGetSeed();
3070 uint32_t trinitySeed = layout->seed;
3071
3072 if( layout->scrambleSeed )
3073 {
3074 trinitySeed += uint32_t( BeOS->GetActualTime() );
3075 }
3076
3077 trinitySeed += seedOverwrite;
3078
3079 TriSrand( trinitySeed );
3080
3081 // Go over all the placements (each layout can have multiple mesh attachments)
3082 for( auto placement : layout->placements )
3083 {
3084 ProcessPlacementDistributionOrGroup( placement, obj, sharedMeshes, dna, locatorSets, layoutIdx, placementIdx, offsets, layoutContainer );
3085 }
3086
3087 if( layout->scrambleSeed )

Callers

nothing calls this directly

Calls 10

TriRandGetSeedFunction · 0.85
TriSrandFunction · 0.85
GetMultiHullCountMethod · 0.80
GetHullLocatorsMethod · 0.80
sizeMethod · 0.80
GetLayoutCountMethod · 0.80
endMethod · 0.45
beginMethod · 0.45
GetLayoutDataMethod · 0.45

Tested by

no test coverage detected