37 lines
		
	
	
		
			876 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			876 B
		
	
	
	
		
			C++
		
	
	
	
	
	
// Copyright (c) 2023 Dominic Masters
 | 
						|
// 
 | 
						|
// This software is released under the MIT License.
 | 
						|
// https://opensource.org/licenses/MIT
 | 
						|
 | 
						|
#include "UIComponent.hpp"
 | 
						|
 | 
						|
using namespace Dawn;
 | 
						|
 | 
						|
std::vector<std::shared_ptr<UIComponent>> UIComponent::getChildren() {
 | 
						|
  return {};
 | 
						|
}
 | 
						|
 | 
						|
std::vector<struct UIShaderQuad> UIComponent::getQuads(
 | 
						|
  const glm::mat4 parent
 | 
						|
) {
 | 
						|
  // Get self transform
 | 
						|
  glm::mat4 transform = glm::translate(
 | 
						|
    glm::mat4(1.0f),
 | 
						|
    glm::vec3(position, 0.0f)
 | 
						|
  );
 | 
						|
 | 
						|
  // Add parent transform
 | 
						|
  transform = parent * transform;
 | 
						|
 | 
						|
  // Get self quads and insert new transform.
 | 
						|
  std::vector<struct UIShaderQuad> quads = this->getSelfQuads(transform);
 | 
						|
 | 
						|
  // Get children
 | 
						|
  auto children = getChildren();
 | 
						|
  for(auto &c : children) {
 | 
						|
    auto childQuads = c->getQuads(transform);
 | 
						|
    quads.insert(quads.end(), childQuads.begin(), childQuads.end());
 | 
						|
  }
 | 
						|
 | 
						|
  return quads;
 | 
						|
} |