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

Method setSeed

Engine/source/util/noise2d.cpp:51–82  ·  view source on GitHub ↗

--------------------------------------

Source from the content-addressed store, hash-verified

49
50//--------------------------------------
51void Noise2D::setSeed(U32 seed)
52{
53 if (mSeed == seed)
54 return;
55 mSeed = seed;
56 mRandom.setSeed(mSeed);
57
58 S32 i, j, k;
59
60 for (i = 0 ; i < SIZE ; i++) {
61 mPermutation[i] = i;
62
63 for (j = 0 ; j < 2 ; j++)
64 mGradient[i][j] = mRandom.randF( -1.0f, 1.0f );
65 normalize(mGradient[i]);
66 }
67
68 while (--i) {
69 k = mPermutation[i];
70 j = mRandom.randI(0, SIZE-1);
71 mPermutation[i] = mPermutation[j];
72 mPermutation[j] = k;
73 }
74
75 // extend the size of the arrays x2 to get rid of a bunch of MODs
76 // we'd have to do later in the code
77 for (i = 0 ; i < SIZE + 2 ; i++) {
78 mPermutation[SIZE + i] = mPermutation[i];
79 for (j = 0 ; j < 2 ; j++)
80 mGradient[SIZE + i][j] = mGradient[i][j];
81 }
82}
83
84
85//--------------------------------------

Callers

nothing calls this directly

Calls 3

randFMethod · 0.80
randIMethod · 0.60
normalizeFunction · 0.50

Tested by

no test coverage detected