MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _compileList

Method _compileList

Engine/source/sfx/sfxController.cpp:122–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120//-----------------------------------------------------------------------------
121
122void SFXController::_compileList( SFXPlayList* playList )
123{
124 mInsns.clear();
125 const bool isLooping = playList->getDescription()->mIsLooping;
126
127 // Create a slot list that determines the order the slots will be
128 // played in.
129
130 U32 slotList[ SFXPlayList::NUM_SLOTS ];
131 bool isOrderedRandom = false;
132 switch( playList->getRandomMode() )
133 {
134 case SFXPlayList::RANDOM_OrderedRandom:
135 isOrderedRandom = true;
136 /* fallthrough */
137
138 case SFXPlayList::RANDOM_NotRandom:
139 // Generate sequence 1-NUM_SLOTS.
140 for( U32 i = 0; i < SFXPlayList::NUM_SLOTS; ++ i )
141 slotList[ i ] = i;
142
143 if( isOrderedRandom )
144 {
145 // Randomly exchange slots in the list.
146 for( U32 i = 0; i < SFXPlayList::NUM_SLOTS; ++ i )
147 T3D::swap( slotList[ gRandGen.randI( 0, SFXPlayList::NUM_SLOTS - 1 ) ], slotList[ i ] );
148 }
149 break;
150
151 case SFXPlayList::RANDOM_StrictRandom:
152 // Randomly generate NUM_SLOTS slot indices.
153 for( U32 i = 0; i < SFXPlayList::NUM_SLOTS; ++ i )
154 slotList[ i ] = gRandGen.randI( 0, SFXPlayList::NUM_SLOTS - 1 );
155 break;
156 }
157
158 // Generate the instruction list.
159
160 U32 slotCount = 0;
161 for( U32 i = 0; i < SFXPlayList::NUM_SLOTS; ++ i )
162 {
163 const U32 slotIndex = slotList[ i ];
164 const U32 slotStartIp = mInsns.size();
165
166 SFXState* state = playList->getSlots().mState[ slotIndex ];
167
168 // If there's no track in this slot, ignore it.
169
170 if( !playList->getTrackProfile(slotIndex))
171 continue;
172
173 // If this is a looped slot and the list is not set to loop
174 // indefinitly on single slots, start a loop.
175
176 S32 loopStartIp = -1;
177 if( playList->getSlots().mRepeatCount[ slotIndex ] > 0
178 && ( !isLooping || playList->getLoopMode() != SFXPlayList::LOOP_Single ) )
179 {

Callers

nothing calls this directly

Calls 7

randIMethod · 0.60
swapFunction · 0.50
clearMethod · 0.45
getDescriptionMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected