Panda3D
linearNoiseForce.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file linearNoiseForce.I
10  * @author charles
11  * @date 2000-06-19
12  */
13 
14 /**
15  * Returns a valid entry in the prn table
16  */
17 INLINE unsigned char LinearNoiseForce::
18 prn_lookup(int index) const {
19  return _prn_table[index & 255];
20 }
21 
22 /**
23  * Hashes a point, returns a prn
24  */
25 INLINE unsigned char LinearNoiseForce::
26 get_prn_entry(const LPoint3& point) const {
27  return prn_lookup((int)(point[0] + prn_lookup((int)(point[1] + prn_lookup((int)point[2])))));
28 }
29 
30 /**
31  * Hashes a point, returns a prn (piecewise)
32  */
33 INLINE unsigned char LinearNoiseForce::
34 get_prn_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z) const {
35  return prn_lookup((int)(x + prn_lookup((int)(y + prn_lookup((int)z)))));
36 }
37 
38 /**
39  * Hashes a point, returns a gradient vector
40  */
41 INLINE LVector3& LinearNoiseForce::
42 get_lattice_entry(const LPoint3& point) {
43  return _gradient_table[get_prn_entry(point)];
44 }
45 
46 /**
47  * Hashes a point, returns a gradient vector (piecewise)
48  */
49 INLINE LVector3& LinearNoiseForce::
50 get_lattice_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z) {
51  return _gradient_table[get_prn_entry(x, y, z)];
52 }
53 
54 /**
55  * Smooths a parameterized interpolation using 2x^3 - 3x^2
56  */
57 INLINE PN_stdfloat LinearNoiseForce::
58 cubic_step(const PN_stdfloat x) const {
59  return x * x * ((2 * x) - 3);
60 }
61 
62 /**
63  * Vector linear interpolation
64  */
65 INLINE LVector3 LinearNoiseForce::
66 vlerp(const PN_stdfloat t, const LVector3& v0, const LVector3& v1) const {
67  return v0 + ((v1 - v0) * t);
68 }