renderitem.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "model/structures/instance.h"
00031 #include "model/metamodel/object.h"
00032 #include "model/metamodel/action.h"
00033 #include "util/resource/pool.h"
00034
00035 #include "visual.h"
00036 #include "renderitem.h"
00037
00038 namespace FIFE {
00039 const int STATIC_IMAGE_NOT_INITIALIZED = -2;
00040
00041 RenderItem::RenderItem():
00042 screenpoint(),
00043 dimensions(),
00044 image(NULL),
00045 m_cached_static_img_id(STATIC_IMAGE_NOT_INITIALIZED),
00046 m_cached_static_img_angle(0) {
00047 }
00048
00049 int RenderItem::getStaticImageIndexByAngle(unsigned int angle, Instance* instance) {
00050 if (static_cast<int>(angle) != m_cached_static_img_angle) {
00051 m_cached_static_img_id = STATIC_IMAGE_NOT_INITIALIZED;
00052 }
00053 if (m_cached_static_img_id != STATIC_IMAGE_NOT_INITIALIZED) {
00054 return m_cached_static_img_id;
00055 }
00056 if(!instance->getObject()->getVisual<ObjectVisual>())
00057 return Pool::INVALID_ID;
00058 m_cached_static_img_id = instance->getObject()->getVisual<ObjectVisual>()->getStaticImageIndexByAngle(angle);
00059 m_cached_static_img_angle = angle;
00060 return m_cached_static_img_id;
00061 }
00062 }