Huge changes for 3d

This commit is contained in:
2026-09-30 18:53:16 -07:00
parent cd2e80cfca
commit b5b0eb9497
53 changed files with 1313 additions and 457 deletions
+2 -17
View File
@@ -81,22 +81,7 @@ void ViewportPanel::onUpdate(const sophia::FrameInfo&) {
ImGui::TextDisabled("%.0f x %.0f", size.x, size.y);
}
void ViewportPanel::drawToolbar() {
const struct {
const char* label;
GizmoMode mode;
} modes[] = {{"Move", GizmoMode::Move},
{"Rotate", GizmoMode::Rotate},
{"Scale", GizmoMode::Scale}};
for (const auto& entry : modes) {
if (ImGui::RadioButton(entry.label, gizmoMode == entry.mode)) {
gizmoMode = entry.mode;
}
ImGui::SameLine();
}
ImGui::Checkbox("Grid", &showGrid);
}
void ViewportPanel::drawToolbar() { ImGui::Checkbox("Grid", &showGrid); }
void ViewportPanel::drawGrid(ImVec2 origin, ImVec2 size) {
constexpr float GRID_STEP = 40.0f;
@@ -119,7 +104,7 @@ void ViewportPanel::handleInput(const ViewportTransform& viewport) {
if (ImGui::IsItemActivated()) {
selected = pick(viewport.screenToWorld(io.MousePos));
dragging = selected && gizmoMode == GizmoMode::Move;
dragging = selected;
}
if (!ImGui::IsItemActive()) {
-3
View File
@@ -55,9 +55,6 @@ class ViewportPanel : public sophia::Panel {
sophia::Scene& scene;
sophia::Entity& selected;
enum class GizmoMode { Move, Rotate, Scale };
GizmoMode gizmoMode = GizmoMode::Move;
bool showGrid = true;
// Set while a drag that started on the selected entity is moving it.
bool dragging = false;