Blender  V2.93
Macros
BLI_utildefines_iter.h File Reference

Go to the source code of this file.

Macros

#define BLI_FOREACH_SPARSE_RANGE(src, dst, i)
 

Detailed Description

General looping helpers, use BLI_FOREACH prefix.

Definition in file BLI_utildefines_iter.h.

Macro Definition Documentation

◆ BLI_FOREACH_SPARSE_RANGE

#define BLI_FOREACH_SPARSE_RANGE (   src,
  dst,
 
)
Value:
for (int _src = (src), _src2 = _src * 2, _dst2 = (dst)*2, _error = _dst2 - _src, i = 0, _delta; \
((void)(_delta = divide_floor_i(_error, _dst2)), (void)(i -= _delta), (i < _src)); \
_error -= (_delta * _dst2) + _src2)
MINLINE int divide_floor_i(int a, int b)

Even value distribution.

src must be larger than dst, dst defines the number of iterations, their values are evenly spaced.

The following pairs represent (src, dst) arguments and the values they loop over.

(19, 4) ->    [2, 7, 11. 16]
(100, 5) ->   [9, 29, 49, 69, 89]
(100, 3) ->   [16, 49, 83]
(100, 100) -> [0..99]
Note
this is mainly useful for numbers that might not divide evenly into eachother.

Definition at line 40 of file BLI_utildefines_iter.h.