Пример #1
0
	void Entity::addToRender(SceneRenderer &out, Color color) const {
		//PROFILE("Entity::addToRender");
		IRect rect = m_sprite.getRect(m_seq_idx, m_frame_idx, m_dir_idx);
		if(!areOverlapping(out.targetRect(), rect + (int2)worldToScreen(m_pos)))
			return;

		FBox bbox = boundingBox() - pos();
		if(shrinkRenderedBBox() && bbox.height() >= 2.0f)
			bbox = {float3(bbox.x(), min(bbox.y() + 1.0f, bbox.ey() - 0.5f), bbox.z()), bbox.max()};

		bool as_overlay = renderAsOverlay();

		FRect tex_rect;
		auto tex = m_sprite.getFrame(m_seq_idx, m_frame_idx, m_dir_idx, tex_rect);
		bool added = out.add(tex, rect, m_pos, bbox, color, tex_rect, as_overlay);
	
	 	if(added && m_oseq_idx != -1 && m_oframe_idx != -1) {
			//TODO: overlay may be visible, while normal sprite is not!
			rect = m_sprite.getRect(m_oseq_idx, m_oframe_idx, m_dir_idx);
			auto ov_tex = m_sprite.getFrame(m_oseq_idx, m_oframe_idx, m_dir_idx, tex_rect);
			out.add(ov_tex, rect, m_pos, bbox, color, tex_rect, true);
		}

//		if(findAny(boundingBox(), {Flags::all | Flags::colliding, ref()}))
//			out.addBox(bbox + pos(), ColorId::red);
	}