Panda3D
linearDistanceForce.I
1 // Filename: linearDistanceForce.I
2 // Created by: charles (21Jun00)
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 : set_falloff_type
17 // Access : Public
18 // Description : falloff_type encapsulating wrap
19 ////////////////////////////////////////////////////////////////////
20 INLINE void LinearDistanceForce::
21 set_falloff_type(FalloffType ft) {
22  _falloff = ft;
23 }
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function : set_radius
27 // Access : Public
28 // Description : set the radius
29 ////////////////////////////////////////////////////////////////////
30 INLINE void LinearDistanceForce::
31 set_radius(PN_stdfloat r) {
32  _radius = r;
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function : set_force_center
37 // Access : Public
38 // Description : set the force center
39 ////////////////////////////////////////////////////////////////////
40 INLINE void LinearDistanceForce::
42  _force_center = p;
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function : get_falloff_type
47 // Access : public
48 // Description : falloff_type query
49 ////////////////////////////////////////////////////////////////////
50 INLINE LinearDistanceForce::FalloffType LinearDistanceForce::
52  return _falloff;
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function : get_radius
57 // Access : public
58 // Description : radius query
59 ////////////////////////////////////////////////////////////////////
60 INLINE PN_stdfloat LinearDistanceForce::
61 get_radius() const {
62  return _radius;
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function : get_force_center
67 // Access : public
68 // Description : force_center query
69 ////////////////////////////////////////////////////////////////////
72  return _force_center;
73 }
74 
75 ////////////////////////////////////////////////////////////////////
76 // Function : get_scalar_term
77 // Access : private
78 // Description : calculate the term based on falloff
79 ////////////////////////////////////////////////////////////////////
80 INLINE PN_stdfloat LinearDistanceForce::
81 get_scalar_term() const {
82  PN_stdfloat r = _radius;
83  if (_falloff == FT_ONE_OVER_R_SQUARED)
84  r = r * r;
85  else if (_falloff == FT_ONE_OVER_R_CUBED)
86  r = r * r * r;
87 
88  return (1.0f / r);
89 }
PN_stdfloat get_scalar_term() const
calculate the term based on falloff
void set_falloff_type(FalloffType ft)
falloff_type encapsulating wrap
LPoint3 get_force_center() const
force_center query
PN_stdfloat get_radius() const
radius query
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
void set_radius(PN_stdfloat r)
set the radius
void set_force_center(const LPoint3 &p)
set the force center
FalloffType get_falloff_type() const
falloff_type query