Octtree, bounding
This commit is contained in:
@@ -24,6 +24,40 @@ void HydraMeshSystem::InitialiseComponent(HydraID entity_id)
|
||||
|
||||
HydraMeshManager* mesh_man = GetEngine()->MeshManager();
|
||||
HydraMesh* mesh = mesh_man->GetMesh(mesh_comp.mesh_id);
|
||||
|
||||
if(mesh->vertexes.size() > 0)
|
||||
{
|
||||
mesh_comp.origin = glm::vec3(mesh->vertexes[0].position[0], mesh->vertexes[0].position[1], mesh->vertexes[0].position[2]);
|
||||
mesh_comp.extent = mesh_comp.origin;
|
||||
for(StandardVertex vert : mesh->vertexes)
|
||||
{
|
||||
if(vert.position[0] < mesh_comp.origin.x)
|
||||
{
|
||||
mesh_comp.origin.x = vert.position[0];
|
||||
}
|
||||
if(vert.position[1] < mesh_comp.origin.y)
|
||||
{
|
||||
mesh_comp.origin.y = vert.position[1];
|
||||
}
|
||||
if(vert.position[2] < mesh_comp.origin.z)
|
||||
{
|
||||
mesh_comp.origin.z = vert.position[2];
|
||||
}
|
||||
if(vert.position[0] > mesh_comp.extent.x)
|
||||
{
|
||||
mesh_comp.extent.x = vert.position[0];
|
||||
}
|
||||
if(vert.position[1] > mesh_comp.extent.y)
|
||||
{
|
||||
mesh_comp.extent.y = vert.position[1];
|
||||
}
|
||||
if(vert.position[2] > mesh_comp.extent.z)
|
||||
{
|
||||
mesh_comp.extent.z = vert.position[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t vertex_buffer_size = sizeof(StandardVertex) * mesh->vertexes.size();
|
||||
uint32_t index_buffer_size = sizeof(uint32_t) * mesh->indexes.size();
|
||||
|
||||
Reference in New Issue
Block a user