Panda3D
 All Classes Functions Variables Enumerations
linearNoiseForce.I
1 // Filename: linearNoiseForce.I
2 // Created by: charles (19Jun00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 ////////////////////////////////////////////////////////////////////
16 // Function : prn_lookup
17 // Access : Private
18 // Description : Returns a valid entry in the prn table
19 ////////////////////////////////////////////////////////////////////
20 INLINE unsigned char LinearNoiseForce::
21 prn_lookup(int index) const {
22  return _prn_table[index & 255];
23 }
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function : get_prn_entry
27 // Access : Private
28 // Description : Hashes a point, returns a prn
29 ////////////////////////////////////////////////////////////////////
30 INLINE unsigned char LinearNoiseForce::
31 get_prn_entry(const LPoint3& point) const {
32  return prn_lookup((int)(point[0] + prn_lookup((int)(point[1] + prn_lookup((int)point[2])))));
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function : get_prn_entry
37 // Access : Private
38 // Description : Hashes a point, returns a prn (piecewise)
39 ////////////////////////////////////////////////////////////////////
40 INLINE unsigned char LinearNoiseForce::
41 get_prn_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z) const {
42  return prn_lookup((int)(x + prn_lookup((int)(y + prn_lookup((int)z)))));
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function : get_lattice_entry
47 // Access : Private
48 // Description : Hashes a point, returns a gradient vector
49 ////////////////////////////////////////////////////////////////////
50 INLINE LVector3& LinearNoiseForce::
51 get_lattice_entry(const LPoint3& point) {
52  return _gradient_table[get_prn_entry(point)];
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function : get_lattice_entry
57 // Access : Private
58 // Description : Hashes a point, returns a gradient vector (piecewise)
59 ////////////////////////////////////////////////////////////////////
60 INLINE LVector3& LinearNoiseForce::
61 get_lattice_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z) {
62  return _gradient_table[get_prn_entry(x, y, z)];
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function : cubic_step
67 // Access : Private
68 // Description : Smooths a parameterized interpolation using
69 // 2x^3 - 3x^2
70 ////////////////////////////////////////////////////////////////////
71 INLINE PN_stdfloat LinearNoiseForce::
72 cubic_step(const PN_stdfloat x) const {
73  return x * x * ((2 * x) - 3);
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function : vlerp
78 // Access : Private
79 // Description : Vector linear interpolation
80 ////////////////////////////////////////////////////////////////////
81 INLINE LVector3 LinearNoiseForce::
82 vlerp(const PN_stdfloat t, const LVector3& v0, const LVector3& v1) const {
83  return v0 + ((v1 - v0) * t);
84 }
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99