Cleanup: Use C++ random number generator
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_rand.h"
|
||||
#include "BLI_rand.hh"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_layer.hh"
|
||||
@@ -41,7 +41,6 @@ static bool object_rand_transverts(TransVertStore *tvs,
|
||||
const uint seed)
|
||||
{
|
||||
bool use_normal = (normal_factor != 0.0f);
|
||||
RNG *rng;
|
||||
TransVert *tv;
|
||||
int a;
|
||||
|
||||
@@ -49,13 +48,12 @@ static bool object_rand_transverts(TransVertStore *tvs,
|
||||
return false;
|
||||
}
|
||||
|
||||
rng = BLI_rng_new(seed);
|
||||
RandomNumberGenerator rng(seed);
|
||||
|
||||
tv = tvs->transverts;
|
||||
for (a = 0; a < tvs->transverts_tot; a++, tv++) {
|
||||
const float t = max_ff(0.0f, uniform + ((1.0f - uniform) * BLI_rng_get_float(rng)));
|
||||
float vec[3];
|
||||
BLI_rng_get_float_unit_v3(rng, vec);
|
||||
const float t = max_ff(0.0f, uniform + ((1.0f - uniform) * rng.get_float()));
|
||||
float3 vec = rng.get_unit_float3();
|
||||
|
||||
if (use_normal && (tv->flag & TX_VERT_USE_NORMAL)) {
|
||||
float no[3];
|
||||
@@ -74,8 +72,6 @@ static bool object_rand_transverts(TransVertStore *tvs,
|
||||
madd_v3_v3fl(tv->loc, vec, offset * t);
|
||||
}
|
||||
|
||||
BLI_rng_free(rng);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_linklist_stack.h"
|
||||
#include "BLI_rand.h"
|
||||
#include "BLI_rand.hh"
|
||||
#include "BLI_string_utils.hh"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
@@ -498,6 +498,7 @@ void ED_region_do_layout(bContext *C, ARegion *region)
|
||||
|
||||
void ED_region_do_draw(bContext *C, ARegion *region)
|
||||
{
|
||||
using namespace blender;
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
ARegionType *at = region->runtime->type;
|
||||
@@ -546,7 +547,8 @@ void ED_region_do_draw(bContext *C, ARegion *region)
|
||||
GPUVertFormat *format = immVertexFormat();
|
||||
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
immUniformColor4f(BLI_thread_frand(0), BLI_thread_frand(0), BLI_thread_frand(0), 0.1f);
|
||||
RandomNumberGenerator rng = RandomNumberGenerator::from_random_seed();
|
||||
immUniformColor4f(rng.get_float(), rng.get_float(), rng.get_float(), 0.1f);
|
||||
immRectf(pos,
|
||||
region->drawrct.xmin - region->winrct.xmin,
|
||||
region->drawrct.ymin - region->winrct.ymin,
|
||||
|
||||
Reference in New Issue
Block a user