Skip to content

Commit

Permalink
Update transform logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Karaulov committed Dec 15, 2022
1 parent 9ec4525 commit 302d4af
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 144 deletions.
2 changes: 2 additions & 0 deletions src/editor/BspRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2343,6 +2343,7 @@ int PickInfo::GetSelectedEnt()
void PickInfo::AddSelectedEnt(int entIdx)
{
selectedEnts.push_back(entIdx);
pickCount++;
}

void PickInfo::SetSelectedEnt(int entIdx)
Expand All @@ -2355,6 +2356,7 @@ void PickInfo::DelSelectedEnt(int entIdx)
{
if (IsSelectedEnt(entIdx))
{
pickCount++;
selectedEnts.erase(std::find(selectedEnts.begin(), selectedEnts.end(), entIdx));
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/editor/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void EditEntityCommand::refresh()
renderer->refreshPointEnt(entIdx);
}
renderer->updateEntityState(entIdx);
g_app->pickCount++; // force GUI update
pickCount++; // force GUI update
g_app->updateModelVerts();
}

Expand Down Expand Up @@ -298,8 +298,8 @@ void DuplicateBspModelCommand::execute()
if (g_app->pickInfo.selectedEnts.size())
g_app->pickInfo.SetSelectedEnt(g_app->pickInfo.selectedEnts[0]);

g_app->pickCount++;
g_app->vertPickCount++;
pickCount++;
vertPickCount++;

g_app->gui->refresh();
/*
Expand Down
41 changes: 21 additions & 20 deletions src/editor/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ void Gui::draw3dContextMenus()
{
app->transformedOrigin = app->getEntOrigin(map, ent);
app->applyTransform();
app->pickCount++; // force gui refresh
pickCount++; // force gui refresh
}

if (ent && ImGui::BeginMenu("Align"))
Expand All @@ -544,39 +544,39 @@ void Gui::draw3dContextMenus()
{
app->transformedOrigin.z = app->oldOrigin.z + model.nMaxs.z;
app->applyTransform();
app->pickCount++;
pickCount++;
}
if (ImGui::MenuItem("Bottom"))
{
app->transformedOrigin.z = app->oldOrigin.z + model.nMins.z;
app->applyTransform();
app->pickCount++;
pickCount++;
}
ImGui::Separator();
if (ImGui::MenuItem("Left"))
{
app->transformedOrigin.x = app->oldOrigin.x + model.nMins.x;
app->applyTransform();
app->pickCount++;
pickCount++;
}
if (ImGui::MenuItem("Right"))
{
app->transformedOrigin.x = app->oldOrigin.x + model.nMaxs.x;
app->applyTransform();
app->pickCount++;
pickCount++;
}
ImGui::Separator();
if (ImGui::MenuItem("Back"))
{
app->transformedOrigin.y = app->oldOrigin.y + model.nMins.y;
app->applyTransform();
app->pickCount++;
pickCount++;
}
if (ImGui::MenuItem("Front"))
{
app->transformedOrigin.y = app->oldOrigin.y + model.nMaxs.y;
app->applyTransform();
app->pickCount++;
pickCount++;
}
ImGui::EndMenu();
}
Expand Down Expand Up @@ -2152,7 +2152,7 @@ void Gui::FaceSelectePressed()
app->deselectObject();

app->pickMode = PICK_FACE;
app->pickCount++; // force texture tool refresh
pickCount++; // force texture tool refresh
}

void Gui::drawFpsOverlay()
Expand Down Expand Up @@ -2180,6 +2180,7 @@ void Gui::drawStatusMessage()
static float loadingWindowHeight = 32;

bool showStatus = app->invalidSolid || !app->isTransformableSolid || badSurfaceExtents || lightmapTooLarge || app->modelUsesSharedStructures;

if (showStatus)
{
ImVec2 window_pos = ImVec2((app->windowWidth - windowWidth) / 2.f, app->windowHeight - 10.f);
Expand All @@ -2204,7 +2205,7 @@ void Gui::drawStatusMessage()
ImGui::EndTooltip();
}
}
if (!app->isTransformableSolid)
if (!app->isTransformableSolid && app->pickInfo.selectedEnts.size() > 0 && app->pickInfo.selectedEnts[0] >= 0)
{
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "CONCAVE SOLID");
if (ImGui::IsItemHovered())
Expand Down Expand Up @@ -2951,7 +2952,7 @@ void Gui::drawKeyvalueEditor_SmartEditTab(int entIdx)
ImGui::NextColumn();
}

lastPickCount = app->pickCount;
lastPickCount = pickCount;
}

ImGui::Columns(1);
Expand Down Expand Up @@ -3131,7 +3132,7 @@ void Gui::drawKeyvalueEditor_RawEditTab(int entIdx)
}
}

if (lastPickCount != app->pickCount)
if (lastPickCount != pickCount)
{
for (int i = 0; i < MAX_KEYS_PER_ENT; i++)
{
Expand Down Expand Up @@ -3198,7 +3199,7 @@ void Gui::drawKeyvalueEditor_RawEditTab(int entIdx)
}

{
bool invalidKey = lastPickCount == app->pickCount;
bool invalidKey = lastPickCount == pickCount;

keyIds[i].idx = i;
keyIds[i].entIdx = app->pickInfo.GetSelectedEnt();
Expand Down Expand Up @@ -3294,7 +3295,7 @@ void Gui::drawKeyvalueEditor_RawEditTab(int entIdx)

wasKeyDragging = keyDragging;

lastPickCount = app->pickCount;
lastPickCount = pickCount;

ImGui::Columns(1);

Expand Down Expand Up @@ -3467,11 +3468,11 @@ void Gui::drawTransformWidget()

if (!shouldUpdateUi)
{
shouldUpdateUi = lastPickCount != app->pickCount ||
shouldUpdateUi = lastPickCount != pickCount ||
app->draggingAxis != -1 ||
app->movingEnt ||
oldSnappingEnabled != app->gridSnappingEnabled ||
lastVertPickCount != app->vertPickCount;
lastVertPickCount != vertPickCount;
}

if (shouldUpdateUi)
Expand Down Expand Up @@ -3515,8 +3516,8 @@ void Gui::drawTransformWidget()
}

oldSnappingEnabled = app->gridSnappingEnabled;
lastVertPickCount = app->vertPickCount;
lastPickCount = app->pickCount;
lastVertPickCount = vertPickCount;
lastPickCount = pickCount;

bool scaled = false;
bool originChanged = false;
Expand Down Expand Up @@ -6400,7 +6401,7 @@ void Gui::drawTextureTool()
return;
}

if (lastPickCount != app->pickCount && app->pickMode == PICK_FACE)
if (lastPickCount != pickCount && app->pickMode == PICK_FACE)
{
edgeVerts.clear();
if (app->pickInfo.selectedFaces.size())
Expand Down Expand Up @@ -6494,7 +6495,7 @@ void Gui::drawTextureTool()

checkFaceErrors();
}
lastPickCount = app->pickCount;
lastPickCount = pickCount;

ImGuiStyle& style = ImGui::GetStyle();
float padding = style.WindowPadding.x * 2 + style.FramePadding.x * 2;
Expand Down Expand Up @@ -6699,7 +6700,7 @@ void Gui::drawTextureTool()
(updatedFaceVec || scaledX || scaledY || shiftedX || shiftedY || textureChanged || stylesChanged || refreshSelectedFaces || toggledFlags || updatedTexVec))
{
unsigned int newMiptex = 0;
app->pickCount++;
pickCount++;
map->getBspRender()->saveLumpState(0xffffffff, false);
if (textureChanged)
{
Expand Down
Loading

0 comments on commit 302d4af

Please sign in to comment.