Panda3D
|
00001 // Filename: cDistributedSmoothNodeBase.h 00002 // Created by: drose (03Sep04) 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 #ifndef CDISTRIBUTEDSMOOTHNODEBASE_H 00016 #define CDISTRIBUTEDSMOOTHNODEBASE_H 00017 00018 #include "directbase.h" 00019 #include "nodePath.h" 00020 #include "dcbase.h" 00021 #include "dcPacker.h" 00022 #include "dcPython.h" // to pick up Python.h 00023 #include "clockObject.h" 00024 00025 class DCClass; 00026 class CConnectionRepository; 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Class : CDistributedSmoothNodeBase 00030 // Description : This class defines some basic methods of 00031 // DistributedSmoothNodeBase which have been moved into 00032 // C++ as a performance optimization. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_DIRECT CDistributedSmoothNodeBase { 00035 PUBLISHED: 00036 CDistributedSmoothNodeBase(); 00037 ~CDistributedSmoothNodeBase(); 00038 00039 INLINE void 00040 set_repository(CConnectionRepository *repository, 00041 bool is_ai, CHANNEL_TYPE ai_id); 00042 00043 #ifdef HAVE_PYTHON 00044 INLINE void 00045 set_clock_delta(PyObject *clock_delta); 00046 #endif 00047 00048 void initialize(const NodePath &node_path, DCClass *dclass, 00049 CHANNEL_TYPE do_id); 00050 00051 void send_everything(); 00052 00053 void broadcast_pos_hpr_full(); 00054 void broadcast_pos_hpr_xyh(); 00055 void broadcast_pos_hpr_xy(); 00056 00057 void set_curr_l(PN_uint64 l); 00058 void print_curr_l(); 00059 00060 private: 00061 INLINE static bool only_changed(int flags, int compare); 00062 00063 INLINE void d_setSmStop(); 00064 INLINE void d_setSmH(PN_stdfloat h); 00065 INLINE void d_setSmZ(PN_stdfloat z); 00066 INLINE void d_setSmXY(PN_stdfloat x, PN_stdfloat y); 00067 INLINE void d_setSmXZ(PN_stdfloat x, PN_stdfloat z); 00068 INLINE void d_setSmPos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); 00069 INLINE void d_setSmHpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); 00070 INLINE void d_setSmXYH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat h); 00071 INLINE void d_setSmXYZH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h); 00072 INLINE void d_setSmPosHpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); 00073 INLINE void d_setSmPosHprL(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_uint64 l); 00074 00075 void begin_send_update(DCPacker &packer, const string &field_name); 00076 void finish_send_update(DCPacker &packer); 00077 00078 enum Flags { 00079 F_new_x = 0x01, 00080 F_new_y = 0x02, 00081 F_new_z = 0x04, 00082 F_new_h = 0x08, 00083 F_new_p = 0x10, 00084 F_new_r = 0x20, 00085 }; 00086 00087 NodePath _node_path; 00088 DCClass *_dclass; 00089 CHANNEL_TYPE _do_id; 00090 00091 CConnectionRepository *_repository; 00092 bool _is_ai; 00093 CHANNEL_TYPE _ai_id; 00094 #ifdef HAVE_PYTHON 00095 PyObject *_clock_delta; 00096 #endif 00097 00098 LPoint3 _store_xyz; 00099 LVecBase3 _store_hpr; 00100 bool _store_stop; 00101 // contains most recently sent location info as 00102 // index 0, index 1 contains most recently set location info 00103 PN_uint64 _currL[2]; 00104 }; 00105 00106 #include "cDistributedSmoothNodeBase.I" 00107 00108 #endif // CDISTRIBUTEDSMOOTHNODEBASE_H