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
00034 #include "visual.h"
00035 #include "renderitem.h"
00036
00037 namespace FIFE {
00038 const int32_t STATIC_IMAGE_NOT_INITIALIZED = -2;
00039
00040 RenderItem::RenderItem():
00041 screenpoint(),
00042 dimensions(),
00043 instance_z(0.0),
00044 m_cached_static_img_id(STATIC_IMAGE_NOT_INITIALIZED),
00045 m_cached_static_img_angle(0) {
00046 }
00047
00048 int32_t RenderItem::getStaticImageIndexByAngle(uint32_t angle, Instance* instance) {
00049 if (static_cast<int32_t>(angle) != m_cached_static_img_angle) {
00050 m_cached_static_img_id = STATIC_IMAGE_NOT_INITIALIZED;
00051 }
00052 if (m_cached_static_img_id != STATIC_IMAGE_NOT_INITIALIZED) {
00053 return m_cached_static_img_id;
00054 }
00055 if(!instance->getObject()->getVisual<ObjectVisual>()) {
00056 return -1;
00057 }
00058
00059 m_cached_static_img_id = instance->getObject()->getVisual<ObjectVisual>()->getStaticImageIndexByAngle(angle);
00060 m_cached_static_img_angle = angle;
00061 return m_cached_static_img_id;
00062 }
00063 }