76 lines
2.8 KiB
Plaintext
76 lines
2.8 KiB
Plaintext
// Filename: LinearNoiseForce.I
|
|
// Created by: charles (19Jun00)
|
|
//
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function : prn_lookup
|
|
// Access : Private
|
|
// Description : Returns a valid entry in the prn table
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE unsigned char LinearNoiseForce::
|
|
prn_lookup(int index) const {
|
|
return _prn_table[index & 255];
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function : get_prn_entry
|
|
// Access : Private
|
|
// Description : Hashes a point, returns a prn
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE unsigned char LinearNoiseForce::
|
|
get_prn_entry(const LPoint3f& point) const {
|
|
return prn_lookup(point[0] + prn_lookup(point[1] + prn_lookup(point[2])));
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function : get_prn_entry
|
|
// Access : Private
|
|
// Description : Hashes a point, returns a prn (piecewise)
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE unsigned char LinearNoiseForce::
|
|
get_prn_entry(const float x, const float y, const float z) const {
|
|
return prn_lookup(x + prn_lookup(y + prn_lookup(z)));
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function : get_lattice_entry
|
|
// Access : Private
|
|
// Description : Hashes a point, returns a gradient vector
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE LVector3f& LinearNoiseForce::
|
|
get_lattice_entry(const LPoint3f& point) {
|
|
return _gradient_table[get_prn_entry(point)];
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function : get_lattice_entry
|
|
// Access : Private
|
|
// Description : Hashes a point, returns a gradient vector (piecewise)
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE LVector3f& LinearNoiseForce::
|
|
get_lattice_entry(const float x, const float y, const float z) {
|
|
return _gradient_table[get_prn_entry(x, y, z)];
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function : cubic_step
|
|
// Access : Private
|
|
// Description : Smooths a parameterized interpolation using
|
|
// 2x^3 - 3x^2
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE float LinearNoiseForce::
|
|
cubic_step(const float x) const {
|
|
return x * x * ((2 * x) - 3);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function : vlerp
|
|
// Access : Private
|
|
// Description : Vector linear interpolation
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE LVector3f LinearNoiseForce::
|
|
vlerp(const float t, const LVector3f& v0, const LVector3f& v1) const {
|
|
return v0 + ((v1 - v0) * t);
|
|
}
|