Page MenuHome

fix T48167
AbandonedPublic

Authored by Philipp Oeser (lichtwerk) on Apr 17 2016, 11:52 PM.

Details

Summary

selecting random percentage would not reliably garuantee the precise percentage of selected elements
now randomize an index array instead and use the precise number of elements from this array

Diff Detail

Event Timeline

Campbell Barton (campbellbarton) requested changes to this revision.EditedApr 18 2016, 12:56 AM

This wont work correctly with hidden elements.

It could work like this...

  • create an array of pointers the total size of elements.
  • loop over all elements and add visible elements to the array.
  • shuffle the array (only taking into account the total number of elements added).
  • calculate the number of items to select based on the number of items added to the array multiplied by the selection percentage.
  • Loop over and select the first items in the array.
This revision now requires changes to proceed.Apr 18 2016, 12:56 AM