Panda3D
|
00001 // Filename: linearDistanceForce.I 00002 // Created by: charles (21Jun00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 //////////////////////////////////////////////////////////////////// 00016 // Function : set_falloff_type 00017 // Access : Public 00018 // Description : falloff_type encapsulating wrap 00019 //////////////////////////////////////////////////////////////////// 00020 INLINE void LinearDistanceForce:: 00021 set_falloff_type(FalloffType ft) { 00022 _falloff = ft; 00023 } 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function : set_radius 00027 // Access : Public 00028 // Description : set the radius 00029 //////////////////////////////////////////////////////////////////// 00030 INLINE void LinearDistanceForce:: 00031 set_radius(PN_stdfloat r) { 00032 _radius = r; 00033 } 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Function : set_force_center 00037 // Access : Public 00038 // Description : set the force center 00039 //////////////////////////////////////////////////////////////////// 00040 INLINE void LinearDistanceForce:: 00041 set_force_center(const LPoint3& p) { 00042 _force_center = p; 00043 } 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function : get_falloff_type 00047 // Access : public 00048 // Description : falloff_type query 00049 //////////////////////////////////////////////////////////////////// 00050 INLINE LinearDistanceForce::FalloffType LinearDistanceForce:: 00051 get_falloff_type() const { 00052 return _falloff; 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function : get_radius 00057 // Access : public 00058 // Description : radius query 00059 //////////////////////////////////////////////////////////////////// 00060 INLINE PN_stdfloat LinearDistanceForce:: 00061 get_radius() const { 00062 return _radius; 00063 } 00064 00065 //////////////////////////////////////////////////////////////////// 00066 // Function : get_force_center 00067 // Access : public 00068 // Description : force_center query 00069 //////////////////////////////////////////////////////////////////// 00070 INLINE LPoint3 LinearDistanceForce:: 00071 get_force_center() const { 00072 return _force_center; 00073 } 00074 00075 //////////////////////////////////////////////////////////////////// 00076 // Function : get_scalar_term 00077 // Access : private 00078 // Description : calculate the term based on falloff 00079 //////////////////////////////////////////////////////////////////// 00080 INLINE PN_stdfloat LinearDistanceForce:: 00081 get_scalar_term() const { 00082 PN_stdfloat r = _radius; 00083 if (_falloff == FT_ONE_OVER_R_SQUARED) 00084 r = r * r; 00085 else if (_falloff == FT_ONE_OVER_R_CUBED) 00086 r = r * r * r; 00087 00088 return (1.0f / r); 00089 }