cDistributedSmoothNodeBase.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 cDistributedSmoothNodeBase.h
  10. * @author drose
  11. * @date 2004-09-03
  12. */
  13. #ifndef CDISTRIBUTEDSMOOTHNODEBASE_H
  14. #define CDISTRIBUTEDSMOOTHNODEBASE_H
  15. #include "directbase.h"
  16. #include "nodePath.h"
  17. #include "dcbase.h"
  18. #include "dcPacker.h"
  19. #include "dcPython.h" // to pick up Python.h
  20. #include "clockObject.h"
  21. class DCClass;
  22. class CConnectionRepository;
  23. /**
  24. * This class defines some basic methods of DistributedSmoothNodeBase which
  25. * have been moved into C++ as a performance optimization.
  26. */
  27. class EXPCL_DIRECT CDistributedSmoothNodeBase {
  28. PUBLISHED:
  29. CDistributedSmoothNodeBase();
  30. ~CDistributedSmoothNodeBase();
  31. INLINE void
  32. set_repository(CConnectionRepository *repository,
  33. bool is_ai, CHANNEL_TYPE ai_id);
  34. #ifdef HAVE_PYTHON
  35. INLINE void
  36. set_clock_delta(PyObject *clock_delta);
  37. #endif
  38. void initialize(const NodePath &node_path, DCClass *dclass,
  39. CHANNEL_TYPE do_id);
  40. void send_everything();
  41. void broadcast_pos_hpr_full();
  42. void broadcast_pos_hpr_xyh();
  43. void broadcast_pos_hpr_xy();
  44. void set_curr_l(uint64_t l);
  45. void print_curr_l();
  46. private:
  47. INLINE static bool only_changed(int flags, int compare);
  48. INLINE void d_setSmStop();
  49. INLINE void d_setSmH(PN_stdfloat h);
  50. INLINE void d_setSmZ(PN_stdfloat z);
  51. INLINE void d_setSmXY(PN_stdfloat x, PN_stdfloat y);
  52. INLINE void d_setSmXZ(PN_stdfloat x, PN_stdfloat z);
  53. INLINE void d_setSmPos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
  54. INLINE void d_setSmHpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r);
  55. INLINE void d_setSmXYH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat h);
  56. INLINE void d_setSmXYZH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h);
  57. INLINE void d_setSmPosHpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r);
  58. INLINE void d_setSmPosHprL(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, uint64_t l);
  59. void begin_send_update(DCPacker &packer, const string &field_name);
  60. void finish_send_update(DCPacker &packer);
  61. enum Flags {
  62. F_new_x = 0x01,
  63. F_new_y = 0x02,
  64. F_new_z = 0x04,
  65. F_new_h = 0x08,
  66. F_new_p = 0x10,
  67. F_new_r = 0x20,
  68. };
  69. NodePath _node_path;
  70. DCClass *_dclass;
  71. CHANNEL_TYPE _do_id;
  72. CConnectionRepository *_repository;
  73. bool _is_ai;
  74. CHANNEL_TYPE _ai_id;
  75. #ifdef HAVE_PYTHON
  76. PyObject *_clock_delta;
  77. #endif
  78. LPoint3 _store_xyz;
  79. LVecBase3 _store_hpr;
  80. bool _store_stop;
  81. // contains most recently sent location info as index 0, index 1 contains
  82. // most recently set location info
  83. uint64_t _currL[2];
  84. };
  85. #include "cDistributedSmoothNodeBase.I"
  86. #endif // CDISTRIBUTEDSMOOTHNODEBASE_H