linearDistanceForce.I 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 linearDistanceForce.I
  10. * @author charles
  11. * @date 2000-06-21
  12. */
  13. /**
  14. * falloff_type encapsulating wrap
  15. */
  16. INLINE void LinearDistanceForce::
  17. set_falloff_type(FalloffType ft) {
  18. _falloff = ft;
  19. }
  20. /**
  21. * set the radius
  22. */
  23. INLINE void LinearDistanceForce::
  24. set_radius(PN_stdfloat r) {
  25. _radius = r;
  26. }
  27. /**
  28. * set the force center
  29. */
  30. INLINE void LinearDistanceForce::
  31. set_force_center(const LPoint3& p) {
  32. _force_center = p;
  33. }
  34. /**
  35. * falloff_type query
  36. */
  37. INLINE LinearDistanceForce::FalloffType LinearDistanceForce::
  38. get_falloff_type() const {
  39. return _falloff;
  40. }
  41. /**
  42. * radius query
  43. */
  44. INLINE PN_stdfloat LinearDistanceForce::
  45. get_radius() const {
  46. return _radius;
  47. }
  48. /**
  49. * force_center query
  50. */
  51. INLINE LPoint3 LinearDistanceForce::
  52. get_force_center() const {
  53. return _force_center;
  54. }
  55. /**
  56. * calculate the term based on falloff
  57. */
  58. INLINE PN_stdfloat LinearDistanceForce::
  59. get_scalar_term() const {
  60. PN_stdfloat r = _radius;
  61. if (_falloff == FT_ONE_OVER_R_SQUARED)
  62. r = r * r;
  63. else if (_falloff == FT_ONE_OVER_R_CUBED)
  64. r = r * r * r;
  65. return (1.0f / r);
  66. }