- Timestamp:
- Nov 25, 2005, 3:37:11 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/physics/physics_engine.h
r5776 r5777 14 14 #include "field.h" 15 15 #include <list> 16 17 16 18 17 // Forward Declaration -
trunk/src/util/animation/animation.cc
r4836 r5777 31 31 // initialize a beginning KeyFrame, that will be deleted afterwards 32 32 this->keyFrameCount = 0; 33 this->bHandled = true;34 33 this->bDelete = false; 35 34 this->baseObject = NULL; … … 50 49 Animation::~Animation() 51 50 { 52 this->doNotHandle();51 AnimationPlayer::getInstance()->removeAnimation(this); 53 52 } 54 53 55 /**56 * tells the AnimationPlayer, that we do not wish to handle this animation57 automatically.58 59 This means that it will not be ticked, and not be deleted with the AnimationPlayer60 */61 void Animation::doNotHandle()62 {63 if (this->bHandled)64 AnimationPlayer::getInstance()->removeAnimation(this);65 }66 54 67 55 /** -
trunk/src/util/animation/animation.h
r5405 r5777 76 76 public: 77 77 virtual ~Animation(); 78 void doNotHandle();79 78 80 79 void setInfinity(ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT); … … 110 109 unsigned int keyFrameCount; //!< The Count of KeyFrames. 111 110 int keyFramesToPlay; //!< How many more Keyframes to play. if negative it will be ignored if 0 stop. 112 bool bHandled; //!< If this Animation is handled by the AnimationPlayer.113 111 bool bRunning; //!< If the animation is running 114 112 bool bDelete; //!< If true, the animation will be deleted through the AnimationPlayer. -
trunk/src/util/animation/animation_player.cc
r5115 r5777 31 31 this->setName("AnimationPlayer"); 32 32 33 this->animationList = new tList<Animation>();34 33 this->play(); 35 34 } … … 52 51 // deleting the Animation List AND all the elements of the List 53 52 this->flush(); 54 delete this->animationList;55 53 56 54 AnimationPlayer::singletonRef = NULL; … … 67 65 void AnimationPlayer::addAnimation(Animation* animation) 68 66 { 69 this->animationList ->add(animation);67 this->animationList.push_back(animation); 70 68 } 71 69 … … 76 74 void AnimationPlayer::removeAnimation(Animation* animation) 77 75 { 78 this->animationList ->remove(animation);76 this->animationList.remove(animation); 79 77 } 80 78 … … 85 83 { 86 84 // deleting the Animation List AND all the elements of the List 87 tIterator<Animation>* animIt = this->animationList->getIterator(); 88 Animation* anim = animIt->firstElement(); 89 while( anim != NULL) 90 { 91 delete anim; 92 this->animationList->remove(anim); 93 anim = animIt->nextElement(); 94 } 95 delete animIt; 96 97 delete this->animationList; 98 this->animationList = new tList<Animation>(); 85 while(this->animationList.size() > 0) 86 { 87 Animation* anim = this->animationList.front(); 88 this->animationList.pop_front(); 89 delete anim; 90 } 99 91 } 100 92 … … 102 94 * Ticks all the animations in animationList 103 95 * @param timePassed the time passed since the last tick. 104 */96 */ 105 97 void AnimationPlayer::tick(float timePassed) 106 98 { 107 99 if (this->bRunning) 100 { 101 // iterate through all the animations and tick them. 102 list<Animation*>::iterator anim; 103 for (anim = this->animationList.begin(); anim != this->animationList.end(); anim++) 108 104 { 109 // iterate through all the animations and tick them. 110 tIterator<Animation>* animIt = this->animationList->getIterator(); 111 Animation* anim = animIt->firstElement(); 112 while( anim != NULL) 113 { 114 anim->tick(timePassed); 115 if(unlikely(anim->ifDelete())) 116 { 117 this->animationList->remove(anim); 118 delete anim; 119 } 120 anim = animIt->nextElement(); 121 } 122 delete animIt; 105 (*anim)->tick(timePassed); 106 if(unlikely((*anim)->ifDelete())) 107 { 108 this->animationList.remove(*anim); 109 delete *anim; 110 } 123 111 } 112 } 124 113 } 125 114 /** 126 115 * starts playing the AnimationPlayer 127 */116 */ 128 117 void AnimationPlayer::play() 129 118 { … … 133 122 /** 134 123 * pauses playing of the AnimationPlayer 135 */124 */ 136 125 void AnimationPlayer::pause() 137 126 { … … 146 135 Animation* AnimationPlayer::getAnimationFromBaseObject(const BaseObject* baseObject) const 147 136 { 148 tIterator<Animation>* animIt = this->animationList->getIterator(); 149 Animation* anim = animIt->firstElement(); 150 while( anim != NULL) 151 { 152 if(anim->getBaseObject() == baseObject) 153 { 154 delete animIt; 155 return anim; 156 } 157 anim = animIt->nextElement(); 158 } 159 delete animIt; 137 list<Animation*>::const_iterator anim; 138 for (anim = this->animationList.begin(); anim != this->animationList.end(); anim++) 139 if((*anim)->getBaseObject() == baseObject) 140 return *anim; 160 141 return NULL; 161 142 } … … 172 153 PRINT(0)("+------------------------------------+\n"); 173 154 PRINT(0)("| Reference: %p\n", this); 174 PRINT(0)("| CountOfAnims %d\n", this->animationList ->getSize());155 PRINT(0)("| CountOfAnims %d\n", this->animationList.size()); 175 156 PRINT(0)("-Animation Information---------------+\n"); 176 157 // Per ANIMATION DEBUG 177 tIterator<Animation>* animIt = this->animationList->getIterator(); 178 Animation* anim = animIt->firstElement(); 179 while( anim != NULL) 158 list<Animation*>::iterator anim; 159 for (anim = this->animationList.begin(); anim != this->animationList.end(); anim++) 180 160 { 181 161 // anim->debug(); 182 anim = animIt->nextElement();183 162 } 184 delete animIt;185 186 163 PRINT(0)("+--------------------------------AP--+\n"); 187 164 } -
trunk/src/util/animation/animation_player.h
r5405 r5777 8 8 #include "base_object.h" 9 9 #include "animation.h" 10 11 #include <list> 10 12 11 13 /* FORWARD DECLARATION */ … … 54 56 55 57 /* class specific */ 56 tList<Animation>*animationList; //!< A List of Animations to be handled.58 std::list<Animation*> animationList; //!< A List of Animations to be handled. 57 59 bool bRunning; //!< If the AnimationPlayer is running. 58 60 };
Note: See TracChangeset
for help on using the changeset viewer.