Skip to content

Commit

Permalink
fix added cube/sphere
Browse files Browse the repository at this point in the history
  • Loading branch information
T-rvw committed Sep 21, 2023
1 parent c28a4ee commit 02abbef
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Engine/Source/Editor/UILayers/EntityList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,24 @@ void EntityList::AddEntity(engine::SceneWorld* pSceneWorld)

auto CreateShapeComponents = [&pSceneWorld, &pWorld, &pSceneDatabase](engine::Entity entity, cd::Mesh&& mesh, engine::MaterialType* pMaterialType)
{
mesh.SetName(pSceneWorld->GetNameComponent(entity)->GetName());
mesh.SetID(cd::MeshID(pSceneDatabase->GetMeshCount()));

uint32_t currentMeshCount = pSceneDatabase->GetMeshCount();
pSceneDatabase->AddMesh(cd::MoveTemp(mesh));
const cd::Mesh& newAddedShape = pSceneDatabase->GetMesh(currentMeshCount);

auto& collisionMeshComponent = pWorld->CreateComponent<engine::CollisionMeshComponent>(entity);
collisionMeshComponent.SetType(engine::CollisonMeshType::AABB);
collisionMeshComponent.SetAABB(mesh.GetAABB());
collisionMeshComponent.SetAABB(newAddedShape.GetAABB());
collisionMeshComponent.Build();

auto& staticMeshComponent = pWorld->CreateComponent<engine::StaticMeshComponent>(entity);
staticMeshComponent.SetMeshData(&mesh);
staticMeshComponent.SetMeshData(&newAddedShape);
staticMeshComponent.SetRequiredVertexFormat(&pMaterialType->GetRequiredVertexFormat());
staticMeshComponent.Build();
staticMeshComponent.Submit();

mesh.SetName(pSceneWorld->GetNameComponent(entity)->GetName());
mesh.SetID(cd::MeshID(pSceneDatabase->GetMeshCount()));
pSceneDatabase->AddMesh(cd::MoveTemp(mesh));

auto& materialComponent = pWorld->CreateComponent<engine::MaterialComponent>(entity);
materialComponent.Init();
materialComponent.SetMaterialType(pMaterialType);
Expand Down

0 comments on commit 02abbef

Please sign in to comment.