lvecBase2_src.cxx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Filename: lvecBase2_src.cxx
  2. // Created by: drose (08Mar00)
  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. TypeHandle FLOATNAME(LVecBase2)::_type_handle;
  15. const FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::_zero =
  16. FLOATNAME(LVecBase2)(0.0f, 0.0f);
  17. const FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::_unit_x =
  18. FLOATNAME(LVecBase2)(1.0f, 0.0f);
  19. const FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::_unit_y =
  20. FLOATNAME(LVecBase2)(0.0f, 1.0f);
  21. #ifdef HAVE_PYTHON
  22. ////////////////////////////////////////////////////////////////////
  23. // Function: LVecBase2::__reduce__
  24. // Access: Published
  25. // Description: This special Python method is implement to provide
  26. // support for the pickle module.
  27. ////////////////////////////////////////////////////////////////////
  28. PyObject *FLOATNAME(LVecBase2)::
  29. __reduce__(PyObject *self) const {
  30. // We should return at least a 2-tuple, (Class, (args)): the
  31. // necessary class object whose constructor we should call
  32. // (e.g. this), and the arguments necessary to reconstruct this
  33. // object.
  34. PyObject *this_class = PyObject_Type(self);
  35. if (this_class == NULL) {
  36. return NULL;
  37. }
  38. PyObject *result = Py_BuildValue("(O(ff))", this_class,
  39. (*this)[0], (*this)[1]);
  40. Py_DECREF(this_class);
  41. return result;
  42. }
  43. #endif // HAVE_PYTHON
  44. ////////////////////////////////////////////////////////////////////
  45. // Function: LVecBase2::init_type
  46. // Access: Public, Static
  47. // Description:
  48. ////////////////////////////////////////////////////////////////////
  49. void FLOATNAME(LVecBase2)::
  50. init_type() {
  51. if (_type_handle == TypeHandle::none()) {
  52. // Format a string to describe the type.
  53. string name = "LVecBase2";
  54. name += FLOATTOKEN;
  55. register_type(_type_handle, name);
  56. }
  57. }