MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / runRandom

Method runRandom

extern/partio/src/lib/PartioSe.cpp:206–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206bool PartioSe::runRandom(){
207 countVar.val=parts->numParticles();
208 if(!isValid()){
209 std::cerr<<"Not running expression because it is invalid"<<std::endl;
210 std::cerr<<parseError()<<std::endl;
211 return false;
212 }
213 std::vector<int> order(parts->numParticles());
214 for(size_t i=0;i<order.size();i++) order[i]=i;
215 for(size_t i=0;i<order.size();i++){
216 size_t other=float(rand())/RAND_MAX*order.size();
217 if(other>=order.size()) other=order.size()-1;
218 std::swap(order[i],order[other]);
219 }
220 for(size_t i=0;i<order.size();i++){
221 run(order[i]);
222 }
223 return true;
224}
225
226SeExprVarRef* PartioSe::resolveVar(const std::string& s) const{
227 {

Callers

nothing calls this directly

Calls 4

numParticlesMethod · 0.80
swapFunction · 0.50
runFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected