65 for(std::vector<Instance*>::iterator i = instances.begin();
66 i != instances.end(); ++i) {
100 if ((rotation >= 0) && (rotation <= 60)) {
105 }
else if ((rotation >= 60) && (rotation <= 120)) {
110 }
else if ((rotation >= 120) && (rotation <= 180)) {
115 }
else if ((rotation >= 180) && (rotation <= 240)) {
120 }
else if ((rotation >= 240) && (rotation <= 300)) {
125 }
else if ((rotation >= 300) && (rotation <= 360)) {
136 lpos.
x += lpos.
y / 2;
137 rpos.
x += rpos.
y / 2;
141 int32_t rvc = ceil(
xtox*rpos.
x +
ytox*rpos.
y) + ceil(
xtoy*rpos.
x +
ytoy*rpos.
y) + riv->getStackPosition();
146 return lpos.
z < rpos.
z;
168 return lpos.
z < rpos.
z;
194 for (std::vector<Entry*>::iterator it =
m_entries.begin(); it !=
m_entries.end(); ++it) {
221 for (std::vector<Entry*>::iterator it =
m_entries.begin(); it !=
m_entries.end(); ++it) {
238 for(std::vector<Instance*>::const_iterator i = instances.begin();
239 i != instances.end(); ++i) {
264 item->instance = instance;
284 assert(entry->instanceIndex == m_instance_map[instance]);
293 entry->node->data().erase(entry->entryIndex);
296 entry->instanceIndex = -1;
297 entry->forceUpdate =
false;
298 m_instance_map.erase(instance);
302 for (RenderList::iterator it = renderList.begin(); it != renderList.end(); ++it) {
303 if ((*it)->instance == instance) {
304 renderList.erase(it);
364 collector.
visit(node);
386 std::set<int32_t> entryToRemove;
389 if (!entryToRemove.empty()) {
390 std::set<int32_t>::iterator entry_it = entryToRemove.begin();
391 for (; entry_it != entryToRemove.end(); ++entry_it) {
413 Rect screenViewport = viewport;
416 viewport.
x =
static_cast<int32_t
>(std::min(viewport_a.
x, viewport_b.
x));
417 viewport.
y =
static_cast<int32_t
>(std::min(viewport_a.
y, viewport_b.
y));
418 viewport.
w =
static_cast<int32_t
>(std::max(viewport_a.
x, viewport_b.
x) - viewport.
x);
419 viewport.
h =
static_cast<int32_t
>(std::max(viewport_a.
y, viewport_b.
y) - viewport.
y);
424 std::vector<int32_t> index_list;
427 for (
uint32_t i = 0; i != index_list.size(); ++i) {
435 renderlist.push_back(item);
444 std::vector<ExactModelCoordinate> coords;
449 for (
uint8_t i = 0; i < 4; ++i) {
512 removes.insert(*entry_it);
521 if (positionUpdate) {
525 if (onScreenA != onScreenB) {
528 renderlist.push_back(item);
529 needSorting.push_back(item);
532 for (RenderList::iterator it = renderlist.begin(); it != renderlist.end(); ++it) {
533 if ((*it)->instance == item->
instance) {
534 renderlist.erase(it);
539 }
else if (onScreenA && onScreenB && positionUpdate) {
541 needSorting.push_back(item);
547 removes.insert(*entry_it);
553 if (!needSorting.empty()) {
574 if (layerTrans != 0) {
575 if (instanceTrans != 0) {
576 uint8_t calcTrans = layerTrans - instanceTrans;
577 if (calcTrans >= 0) {
578 instanceTrans = calcTrans;
583 instanceTrans = layerTrans;
596 if (image_id == -1) {
612 std::map<int32_t, AnimationPtr>::iterator it = animations.begin();
613 std::vector<ImagePtr>* animOverlays =
new std::vector<ImagePtr>();
614 std::vector<OverlayColors*>* animationColorOverlays = colorOverlay ?
new std::vector<OverlayColors*>() : 0;
615 for (; it != animations.end(); ++it) {
617 image = it->second->getFrameByTimestamp(animationTime);
618 animOverlays->push_back(image);
627 animationColorOverlays->push_back(co);
630 int32_t actionFrame = it->second->getActionFrame();
631 if (actionFrame != -1) {
632 int32_t newFrame = it->second->getFrameIndex(animationTime);
634 if (actionFrame == newFrame) {
637 }
else if (newFrame > actionFrame && item->
currentFrame < actionFrame) {
665 if (actionFrame != -1) {
666 if (item->
image != image) {
668 if (actionFrame == newFrame) {
671 }
else if (newFrame > actionFrame && item->
currentFrame < actionFrame) {
680 bool newPosition =
false;
681 if (image != item->
image) {
682 if (!item->
image || !image) {
705 screenPosition.
x = (screenPosition.
x - w / 2) + image->
getXShift();
706 screenPosition.
y = (screenPosition.
y - h / 2) + image->
getYShift();
714 item->
bbox.
x =
static_cast<int32_t
>(screenPosition.
x);
715 item->
bbox.
y =
static_cast<int32_t
>(screenPosition.
y);
721 if (node != entry->
node) {
753 if (renderlist.empty()) {
767 if (fabs(det) > FLT_EPSILON) {
768 static const float globalrange = 200.0;
769 static const float stackdelta = (FLT_EPSILON * 100.0);
772 float lmax = lmin + globalrange/numlayers;
773 float a = (lmin - lmax) / det;
776 RenderList::iterator it = renderlist.begin();
777 for ( ; it != renderlist.end(); ++it) {
779 float& z = (*it)->vertexZ;
788 std::stable_sort(renderlist.begin(), renderlist.end(), ids);
792 std::stable_sort(renderlist.begin(), renderlist.end(), ids);
796 std::stable_sort(renderlist.begin(), renderlist.end(), ids);
800 std::stable_sort(renderlist.begin(), renderlist.end(), ids);
virtual ~CacheLayerChangeListener()
void setColorOverlay(OverlayColors *co)
Sets single ColorOverlay.
bool operator()(RenderItem *const &lhs, RenderItem *const &rhs)
void fullUpdate(Camera::Transform transform)
std::vector< RenderItem * > RenderList
void updatePosition(Entry *entry)
void setLayer(Layer *layer)
QuadNode * parent()
Return the parent node.
int32_t getStaticImageIndexByAngle(uint32_t angle, Instance *instance)
Returns closest matching static image for given angle.
QuadTree< std::set< int32_t > > CacheTree
int32_t getStackPosition()
Gets current stack position of instance.
Node * find_container(int32_t x, int32_t y, int32_t w, int32_t h)
Find a container node for a given rectangle.
T h
Height of the rectangle.
void fullCoordinateUpdate(Camera::Transform transform)
virtual ImagePtr get(const std::string &name)
Gets a shared pointer to the Image.
Instance visual contains data that is needed to visualize the instance on screen. ...
void callOnActionFrame(Action *action, int32_t frame)
Auxiliary function to inform ActionListeners about the active ActionFrame.
int32_t getXShift() const
void reset(T *ptr=0)
reset this pointer to a null shared pointer this can be used to lower the reference count of the shar...
void updateScreenCoordinate(RenderItem *item, bool changedZoom=true)
uint32_t getLayerCount() const
Get the overall number of layers.
RenderList & getRenderListRef(Layer *layer)
Returns reference to RenderList.
DoublePoint3D toVirtualScreenCoordinates(const ExactModelCoordinate &map_coords)
Transforms given point from map coordinates to virtual screen coordinates.
DoublePoint3D screenpoint
Action visual contains data that is needed to visualize different actions on screen.
bool isStatic() const
Gets if object moves.
uint32_t getDuration() const
Gets the total duration for the whole animation.
InstanceChangeInfo getChangeInfo()
Returns a bitmask of changes of the last update.
T * getVisual() const
Gets used visualization.
void deleteOverlayData()
Deletes OverlayData.
int32_t getYShift() const
static Logger _log(LM_AUDIO)
PointType3D< int32_t > Point3D
DataType & data()
Return a reference to the data of the node.
uint32_t getActionRuntime()
Gets the time in milliseconds how long action has been active In case there is no current action...
bool operator()(RenderItem *const &lhs, RenderItem *const &rhs)
Action * getCurrentAction() const
Gets the currently active action.
bool areInstancesVisible() const
Check object visibility.
virtual void onInstanceCreate(Layer *layer, Instance *instance)
Called when some instance gets created on layer.
Camera describes properties of a view port shown in the main screen Main screen can have multiple cam...
static RenderBackend * instance()
Location & getLocationRef()
Gets reference of current location of instance.
std::deque< int32_t > m_freeEntries
void apply_visitor(Visitor &visitor, int32_t d=0)
Apply a visitor recursively to the QuadTree A visitor is an object which has a visit method which tak...
void sortRenderList(RenderList &renderlist)
void setAnimationOverlay(std::vector< ImagePtr > *ao, std::vector< OverlayColors * > *aco)
Sets AnimationOverlay and if available AnimationOverlayColors.
virtual void onLayerChanged(Layer *layer, std::vector< Instance * > &instances)
Called when some instance is changed on layer.
RenderEntryUpdate updateInfo
int32_t getActionFrame() const
Gets the action frame.
uint32_t getHeight() const
OverlayColors * getColorOverlay(int32_t angle)
Gets OverlayColors for given angle (degrees).
bool isVisible()
Is instance visible or not.
const Rect & getViewPort() const
Gets the viewport for camera in pixel coordinates.
Comparison functions for sorting.
void setColorOverlayImage(ImagePtr image)
ImagePtr getFrameByTimestamp(uint32_t timestamp)
Gets the frame image that matches the given timestamp.
T bottom() const
The Y coordinate of the bottom edge.
void removeChangeListener(LayerChangeListener *listener)
Removes associated change listener.
static bool Equal(T _val1, T _val2)
Object * getObject()
Gets object where this instance is instantiated from.
std::vector< RenderItem * > m_renderItems
uint32_t InstanceChangeInfo
int32_t getRotation() const
Get the rotation offset of this instance Returns direction where instance is heading.
uint32_t getFrameCount() const
Get the number of frames.
double getZoom() const
Gets camera zoom.
CacheTreeCollector(std::vector< int32_t > &indices, const Rect &viewport)
Listener interface for changes happening on a layer.
CacheLayerChangeListener * m_layerObserver
int32_t getFrameIndex(uint32_t timestamp)
Get the frame index that matches given timestamp.
void addChangeListener(LayerChangeListener *listener)
Adds new change listener.
void setCacheImage(ImagePtr image)
bool isStatic()
Returns true, if layer is static.
ExactModelCoordinate & getExactLayerCoordinatesRef()
Gets reference to exact layer coordinates.
uint32_t getWidth() const
CacheLayerChangeListener(LayerCache *cache)
const Rect & getMapViewPort()
Gets the viewport for camera in map coordinates.
virtual void onInstanceDelete(Layer *layer, Instance *instance)
Called when some instance gets deleted on layer.
std::vector< Entry * > m_entries
void collect(const Rect &viewport, std::vector< int32_t > &indices)
std::vector< int32_t > & m_indices
T right() const
The X coordinate of the right edge.
DoublePoint3D ExactModelCoordinate
bool intersects(const RectType< T > &rect) const
Check whether two rectangles share some area.
bool visit(LayerCache::CacheTree::Node *node, int32_t d=-1)
LayerCache(Camera *camera)
uint8_t getTransparency()
Gets current transparency value (0-255)
SortingStrategy getSortingStrategy() const
Gets sorting strategy for the layer.
bool operator()(RenderItem *const &lhs, RenderItem *const &rhs)
int32_t y() const
Return the Y position of the node.
void update(Camera::Transform transform, RenderList &renderlist)
float getZOffset() const
Calculates z offset for the layer.
const std::vector< Instance * > & getInstances() const
Get the list of instances on this layer.
void removeInstance(Instance *instance)
InstanceDistanceSortLocation(double rotation)
void updateEntries(std::set< int32_t > &removes, RenderList &renderlist)
AnimationPtr getColorOverlayAnimation()
void addInstance(Instance *instance)
int32_t size() const
Return the size (width and height) of the node.
DoublePoint3D screenToVirtualScreen(const ScreenPoint &p)
Transforms given point from screen coordinates to virtual screen coordinates.
int32_t x() const
Return the X position of the node.
Action * getDefaultAction() const
Gets default action assigned to this object.
bool updateVisual(Entry *entry)
uint8_t getLayerTransparency()
Returns the layer's transparency value.
ExactModelCoordinate getExactLayerCoordinates() const
Gets exact layer coordinates set to this location.
T w
Width of the rectangle.
#define FL_DBG(logger, msg)
std::map< Instance *, int32_t > m_instance_map
std::set< int32_t > m_entriesToUpdate
An Instance is an "instantiation" of an Object at a Location.
ScreenPoint virtualScreenToScreen(const DoublePoint3D &p)
Transforms given point from virtual screen coordinates to screen coordinates.
std::map< int32_t, AnimationPtr > getAnimationOverlay(int32_t angle)
Gets map with animations closest to given angle.
ExactModelCoordinate getMapCoordinates() const
Gets map coordinates set to this location.
bool isAnimationOverlay()
Returns true if it exists a animation overlay, otherwise false.
void reset()
Resets the important values.
bool isColorOverlay()
Returns true if it exists a color overlay, otherwise false.
void updateInstance(Instance *instance)
double getRotation() const
Gets camera rotation.