22 (
"default_noise_force_seed", 665);
24 bool LinearNoiseForce::_initialized =
false;
25 unsigned char LinearNoiseForce::_prn_table[256];
26 LVector3 LinearNoiseForce::_gradient_table[256];
39 LVector3 *gtable = _gradient_table;
40 for (
int i = 0; i < 256; ++i) {
42 _prn_table[i] = rand() & 255;
45 *gtable++ = random_unit_vector();
55 if (_initialized ==
false) {
87 LVector3 LinearNoiseForce::
92 PN_stdfloat int_x, int_y, int_z;
93 PN_stdfloat frac_x, frac_y, frac_z;
95 frac_x = std::modf(p[0], &int_x);
96 frac_y = std::modf(p[1], &int_y);
97 frac_z = std::modf(p[2], &int_z);
100 PN_stdfloat cubic_x, cubic_y, cubic_z;
102 cubic_x = cubic_step(frac_x);
103 cubic_y = cubic_step(frac_y);
104 cubic_z = cubic_step(frac_z);
107 LVector3 temp0, temp1, temp2, temp3;
110 temp0 = vlerp(cubic_x, get_lattice_entry(p),
111 get_lattice_entry(p[0] + 1.0f, p[1], p[2]));
113 temp1 = vlerp(cubic_x, get_lattice_entry(p[0], p[1], p[2] + 1.0f),
114 get_lattice_entry(p[0] + 1.0f, p[1], p[2] + 1.0f));
116 temp2 = vlerp(cubic_x, get_lattice_entry(p[0], p[1] + 1.0f, p[2]),
117 get_lattice_entry(p[0] + 1.0f, p[1] + 1.0f, p[2]));
119 temp3 = vlerp(cubic_x, get_lattice_entry(p[0], p[1] + 1.0f, p[2] + 1.0f),
120 get_lattice_entry(p[0] + 1.0f, p[1] + 1.0f, p[2] + 1.0f));
123 temp0 = vlerp(cubic_z, temp0, temp1);
124 temp1 = vlerp(cubic_z, temp2, temp3);
127 return vlerp(cubic_y, temp0, temp1);
136 out<<
""<<
"LinearNoiseForce";
147 out<<
""<<
"LinearNoiseForce:";
148 out.width(
indent+2); out<<
""; out<<
"_random_seed"<<_random_seed<<
" (class)\n";
149 out.width(
indent+2); out<<
""; out<<
"_initialized"<<_initialized<<
" (class)\n";
150 out.width(
indent+2); out<<
""; out<<
"_gradient_table"<<_gradient_table<<
" (class)\n";
151 out.width(
indent+2); out<<
""; out<<
"_prn_table"<<_prn_table<<
" (class)\n";