68 for(std::vector<Instance*>::iterator i = instances.begin();
69 i != instances.end(); ++i) {
103 if ((rotation >= 0) && (rotation <= 60)) {
108 }
else if ((rotation >= 60) && (rotation <= 120)) {
113 }
else if ((rotation >= 120) && (rotation <= 180)) {
118 }
else if ((rotation >= 180) && (rotation <= 240)) {
123 }
else if ((rotation >= 240) && (rotation <= 300)) {
128 }
else if ((rotation >= 300) && (rotation <= 360)) {
139 lpos.
x += lpos.
y / 2;
140 rpos.
x += rpos.
y / 2;
144 int32_t rvc = ceil(
xtox*rpos.
x +
ytox*rpos.
y) + ceil(
xtoy*rpos.
x +
ytoy*rpos.
y) + riv->getStackPosition();
149 return lpos.
z < rpos.
z;
171 return lpos.
z < rpos.
z;
196 for (std::vector<Entry*>::iterator it =
m_entries.begin(); it !=
m_entries.end(); ++it) {
223 for (std::vector<Entry*>::iterator it =
m_entries.begin(); it !=
m_entries.end(); ++it) {
240 for(std::vector<Instance*>::const_iterator i = instances.begin();
241 i != instances.end(); ++i) {
266 item->instance = instance;
286 assert(entry->instanceIndex == m_instance_map[instance]);
295 entry->node->data().erase(entry->entryIndex);
298 entry->instanceIndex = -1;
299 entry->forceUpdate =
false;
300 m_instance_map.erase(instance);
304 for (RenderList::iterator it = renderList.begin(); it != renderList.end(); ++it) {
305 if ((*it)->instance == instance) {
306 renderList.erase(it);
365 collector.
visit(node);
379 std::set<int32_t> entryToRemove;
382 if (!entryToRemove.empty()) {
383 std::set<int32_t>::iterator entry_it = entryToRemove.begin();
384 for (; entry_it != entryToRemove.end(); ++entry_it) {
400 Rect screenViewport = viewport;
403 viewport.
x =
static_cast<int32_t
>(std::min(viewport_a.
x, viewport_b.
x));
404 viewport.
y =
static_cast<int32_t
>(std::min(viewport_a.
y, viewport_b.
y));
405 viewport.
w =
static_cast<int32_t
>(std::max(viewport_a.
x, viewport_b.
x) - viewport.
x);
406 viewport.
h =
static_cast<int32_t
>(std::max(viewport_a.
y, viewport_b.
y) - viewport.
y);
411 std::vector<int32_t> index_list;
414 for (
uint32_t i = 0; i != index_list.size(); ++i) {
422 renderlist.push_back(item);
462 removes.insert(*entry_it);
471 if (positionUpdate) {
475 if (onScreenA != onScreenB) {
478 renderlist.push_back(item);
479 needSorting.push_back(item);
482 for (RenderList::iterator it = renderlist.begin(); it != renderlist.end(); ++it) {
483 if ((*it)->instance == item->
instance) {
484 renderlist.erase(it);
489 }
else if (onScreenA && onScreenB && positionUpdate) {
491 needSorting.push_back(item);
497 removes.insert(*entry_it);
503 if (!needSorting.empty()) {
524 if (layerTrans != 0) {
525 if (instanceTrans != 0) {
526 uint8_t calcTrans = layerTrans - instanceTrans;
527 if (calcTrans >= 0) {
528 instanceTrans = calcTrans;
533 instanceTrans = layerTrans;
544 if (image_id == -1) {
560 if (actionFrame != -1) {
561 if (item->
image != image) {
563 if (actionFrame == new_frame) {
566 }
else if (new_frame > actionFrame && item->
currentFrame < actionFrame) {
574 bool newPosition =
false;
575 if (image != item->
image) {
576 if (!item->
image || !image) {
599 screenPosition.
x = (screenPosition.
x - w / 2.0) + image->
getXShift();
600 screenPosition.
y = (screenPosition.
y - h / 2.0) + image->
getYShift();
608 item->
bbox.
x =
static_cast<int32_t
>(screenPosition.
x);
609 item->
bbox.
y =
static_cast<int32_t
>(screenPosition.
y);
645 if (node != entry->
node) {
656 if (renderlist.empty()) {
667 if (fabs(det) > FLT_EPSILON) {
668 double det_a = -10.0 - 10.0;
670 double a =
static_cast<float>(det_a / det);
671 double b =
static_cast<float>(det_b / det);
672 float estimate = sqrtf(static_cast<float>(renderlist.size()));
673 float stack_delta = fabs(-10.0f - 10.0f) / estimate * 0.1f;
675 RenderList::iterator it = renderlist.begin();
676 for ( ; it != renderlist.end(); ++it) {
677 double& z = (*it)->screenpoint.z;
688 std::stable_sort(renderlist.begin(), renderlist.end(), ids);
692 std::stable_sort(renderlist.begin(), renderlist.end(), ids);
696 std::stable_sort(renderlist.begin(), renderlist.end(), ids);
700 std::stable_sort(renderlist.begin(), renderlist.end(), ids);
virtual ~CacheLayerChangeListener()
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.
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...
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.
int32_t getYShift() const
Action * getDefaultAction() const
Gets default action assigned to this object.
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)
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
bool isVisible()
Is instance visible or not.
const Rect & getViewPort() const
Gets the viewport for camera in pixel coordinates.
Comparison functions for sorting.
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.
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)
ExactModelCoordinate & getExactLayerCoordinatesRef()
Gets reference to exact layer coordinates.
uint32_t getWidth() const
CacheLayerChangeListener(LayerCache *cache)
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.
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)
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)
void addInstance(Instance *instance)
int32_t size() const
Return the size (width and height) of the node.
DoublePoint3D screenToVirtualScreen(const ScreenPoint &p)
int32_t x() const
Return the X position of the node.
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)
ExactModelCoordinate getMapCoordinates() const
Gets map coordinates set to this location.
void reset()
Resets the important values.
void updateInstance(Instance *instance)
double getRotation() const
Gets camera rotation.