Panda3D
 All Classes Functions Variables Enumerations
animPreloadTable.I
1 // Filename: animPreloadTable.I
2 // Created by: drose (05Aug08)
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 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: AnimPreloadTable::AnimRecord::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE AnimPreloadTable::AnimRecord::
22 AnimRecord() {
23 }
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function: AnimPreloadTable::AnimRecord::operator <
27 // Access: Public
28 // Description:
29 ////////////////////////////////////////////////////////////////////
30 INLINE bool AnimPreloadTable::AnimRecord::
31 operator < (const AnimRecord &other) const {
32  return _basename < other._basename;
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function: AnimPreloadTable::get_basename
37 // Access: Published
38 // Description: Returns the basename stored for the nth animation
39 // record. See find_anim().
40 ////////////////////////////////////////////////////////////////////
41 INLINE string AnimPreloadTable::
42 get_basename(int n) const {
43  nassertr(n >= 0 && n < (int)_anims.size(), string());
44  consider_sort();
45  return _anims[n]._basename;
46 }
47 
48 ////////////////////////////////////////////////////////////////////
49 // Function: AnimPreloadTable::get_base_frame_rate
50 // Access: Published
51 // Description: Returns the frame rate stored for the nth animation
52 // record.
53 ////////////////////////////////////////////////////////////////////
54 INLINE PN_stdfloat AnimPreloadTable::
55 get_base_frame_rate(int n) const {
56  nassertr(n >= 0 && n < (int)_anims.size(), 0.0f);
57  consider_sort();
58  return _anims[n]._base_frame_rate;
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function: AnimPreloadTable::get_num_frames
63 // Access: Published
64 // Description: Returns the number of frames stored for the nth
65 // animation record.
66 ////////////////////////////////////////////////////////////////////
67 INLINE int AnimPreloadTable::
68 get_num_frames(int n) const {
69  nassertr(n >= 0 && n < (int)_anims.size(), 0);
70  consider_sort();
71  return _anims[n]._num_frames;
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: AnimPreloadTable::consider_sort
76 // Access: Private
77 // Description: Ensures the table is kept in alphabetical order by
78 // basename.
79 ////////////////////////////////////////////////////////////////////
80 INLINE void AnimPreloadTable::
81 consider_sort() const {
82  if (_needs_sort) {
83  ((AnimPreloadTable *)this)->_anims.sort();
84  ((AnimPreloadTable *)this)->_needs_sort = false;
85  }
86 }
This table records data about a list of animations for a particular model, such as number of frames a...
string get_basename(int n) const
Returns the basename stored for the nth animation record.
PN_stdfloat get_base_frame_rate(int n) const
Returns the frame rate stored for the nth animation record.
size_type_0 size() const
Returns the number of elements in the ordered vector.
int get_num_frames(int n) const
Returns the number of frames stored for the nth animation record.