00001 // Filename: animPreloadTable.I 00002 // Created by: drose (05Aug08) 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 //////////////////////////////////////////////////////////////////// 00017 // Function: AnimPreloadTable::AnimRecord::Constructor 00018 // Access: Public 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE AnimPreloadTable::AnimRecord:: 00022 AnimRecord() { 00023 } 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: AnimPreloadTable::AnimRecord::operator < 00027 // Access: Public 00028 // Description: 00029 //////////////////////////////////////////////////////////////////// 00030 INLINE bool AnimPreloadTable::AnimRecord:: 00031 operator < (const AnimRecord &other) const { 00032 return _basename < other._basename; 00033 } 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Function: AnimPreloadTable::get_basename 00037 // Access: Published 00038 // Description: Returns the basename stored for the nth animation 00039 // record. See find_anim(). 00040 //////////////////////////////////////////////////////////////////// 00041 INLINE string AnimPreloadTable:: 00042 get_basename(int n) const { 00043 nassertr(n >= 0 && n < (int)_anims.size(), string()); 00044 consider_sort(); 00045 return _anims[n]._basename; 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: AnimPreloadTable::get_base_frame_rate 00050 // Access: Published 00051 // Description: Returns the frame rate stored for the nth animation 00052 // record. 00053 //////////////////////////////////////////////////////////////////// 00054 INLINE PN_stdfloat AnimPreloadTable:: 00055 get_base_frame_rate(int n) const { 00056 nassertr(n >= 0 && n < (int)_anims.size(), 0.0f); 00057 consider_sort(); 00058 return _anims[n]._base_frame_rate; 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function: AnimPreloadTable::get_num_frames 00063 // Access: Published 00064 // Description: Returns the number of frames stored for the nth 00065 // animation record. 00066 //////////////////////////////////////////////////////////////////// 00067 INLINE int AnimPreloadTable:: 00068 get_num_frames(int n) const { 00069 nassertr(n >= 0 && n < (int)_anims.size(), 0); 00070 consider_sort(); 00071 return _anims[n]._num_frames; 00072 } 00073 00074 //////////////////////////////////////////////////////////////////// 00075 // Function: AnimPreloadTable::consider_sort 00076 // Access: Private 00077 // Description: Ensures the table is kept in alphabetical order by 00078 // basename. 00079 //////////////////////////////////////////////////////////////////// 00080 INLINE void AnimPreloadTable:: 00081 consider_sort() const { 00082 if (_needs_sort) { 00083 ((AnimPreloadTable *)this)->_anims.sort(); 00084 ((AnimPreloadTable *)this)->_needs_sort = false; 00085 } 00086 }