Octtree, bounding
This commit is contained in:
@@ -2,13 +2,15 @@
|
|||||||
#define HYDRAECSMESHCOMPONENT
|
#define HYDRAECSMESHCOMPONENT
|
||||||
|
|
||||||
#include "../../engine/HydraObject.h"
|
#include "../../engine/HydraObject.h"
|
||||||
|
#include <GLMIncludes.h>
|
||||||
|
|
||||||
struct HydraMeshComponent
|
struct HydraMeshComponent
|
||||||
{
|
{
|
||||||
HydraID mesh_id = INVALID_HYDRA_ID;
|
HydraID mesh_id = INVALID_HYDRA_ID;
|
||||||
HydraID vertex_buffer_id = INVALID_HYDRA_ID;
|
HydraID vertex_buffer_id = INVALID_HYDRA_ID;
|
||||||
HYDRA_STATE mesh_state = HYDRA_STATE::Empty;
|
HYDRA_STATE mesh_state = HYDRA_STATE::Empty;
|
||||||
|
glm::vec3 origin {};
|
||||||
|
glm::vec3 extent {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,40 @@ void HydraMeshSystem::InitialiseComponent(HydraID entity_id)
|
|||||||
|
|
||||||
HydraMeshManager* mesh_man = GetEngine()->MeshManager();
|
HydraMeshManager* mesh_man = GetEngine()->MeshManager();
|
||||||
HydraMesh* mesh = mesh_man->GetMesh(mesh_comp.mesh_id);
|
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 vertex_buffer_size = sizeof(StandardVertex) * mesh->vertexes.size();
|
||||||
uint32_t index_buffer_size = sizeof(uint32_t) * mesh->indexes.size();
|
uint32_t index_buffer_size = sizeof(uint32_t) * mesh->indexes.size();
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef HYDRAOCTTREE
|
||||||
|
#define HYDRAOCTTREE
|
||||||
|
|
||||||
|
#include "../engine/HydraEngine.h"
|
||||||
|
#include "../engine/HydraObject.h"
|
||||||
|
#include "HydraOcttreeElement.h"
|
||||||
|
|
||||||
|
class HydraOcttree : public HydraObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Intialise();
|
||||||
|
void AddEntity(HydraID entity_id);
|
||||||
|
void RemoveEntity(HydraID entity_id);
|
||||||
|
void UpdateEntity(HydraID entity_id);
|
||||||
|
private:
|
||||||
|
HydraOcttreeElement m_root {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* HYDRAOCTTREE */
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#ifndef HYDRAOCTTREEELEMENT
|
||||||
|
#define HYDRAOCTTREEELEMENT
|
||||||
|
#include "../engine/HydraObject.h"
|
||||||
|
|
||||||
|
struct HydraOcttreeElement
|
||||||
|
{
|
||||||
|
HydraID element_id = INVALID_HYDRA_ID;
|
||||||
|
double origin[4] {};
|
||||||
|
double dimension = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* HYDRAOCTTREEELEMENT */
|
||||||
@@ -2,11 +2,11 @@
|
|||||||
Pos=60,60
|
Pos=60,60
|
||||||
Size=400,400
|
Size=400,400
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
LastUsed=20260830
|
LastUsed=20260831
|
||||||
|
|
||||||
[Window][Hello, world!]
|
[Window][Hello, world!]
|
||||||
Pos=60,60
|
Pos=60,60
|
||||||
Size=338,157
|
Size=338,157
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
LastUsed=20260830
|
LastUsed=20260831
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user