Skip to content

Commit

Permalink
Fixed bug in selection tool
Browse files Browse the repository at this point in the history
  • Loading branch information
fLindahl committed Mar 14, 2024
1 parent 8b2ae63 commit 0874b1f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion toolkit/editor/editor/tools/selectiontool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ SelectionTool::Update(Math::vec2 const& viewPortPosition, Math::vec2 const& view
bvh.Build(bboxes.Begin(), bboxes.Size());
Util::Array<uint32_t> intersectionIndices = bvh.Intersect(ray);

Util::Array<Editor::Entity> newSelection;

for (IndexT i = 0; i < intersectionIndices.Size(); i++)
{
uint32_t const idx = intersectionIndices[i];
Expand All @@ -106,9 +108,10 @@ SelectionTool::Update(Math::vec2 const& viewPortPosition, Math::vec2 const& view
float t;
if (bbox.intersects(ray, t))
{
selection.Append(editorEntity.id);
newSelection.Append(editorEntity.id);
}
}
Edit::SetSelection(newSelection);
}

Game::DestroyFilter(filter);
Expand All @@ -121,6 +124,16 @@ SelectionTool::Update(Math::vec2 const& viewPortPosition, Math::vec2 const& view
void
SelectionTool::RenderGizmo()
{
for (size_t i = 0; i < selection.Size(); i++)
{
if (!Editor::state.editorWorld->IsValid(selection[i]) || !Editor::state.editorWorld->HasInstance(selection[i]))
{
selection.EraseIndex(i);
i--;
continue;
}
}

if (selection.IsEmpty())
return;

Expand Down
2 changes: 2 additions & 0 deletions toolkit/editor/editor/ui/windows/toolbar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ Toolbar::Run()
if (ImGui::Button("Create"))
{
if (selected != nullptr)
{
Edit::CreateEntity(selected);
}
}

IMGUI_VERTICAL_SEPARATOR;
Expand Down

0 comments on commit 0874b1f

Please sign in to comment.