Skip to content

Commit

Permalink
Fix model tranformation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
UnrealKaraulov committed Feb 14, 2024
1 parent 05d9673 commit 6d7f7f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/bsp/Bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ std::vector<ScalableTexinfo> Bsp::getScalableTexinfos(int modelIdx)

bool Bsp::vertex_manipulation_sync(int modelIdx, const std::vector<TransformVert>& hullVerts, bool convexCheckOnly)
{
if (modelIdx < 0)
if (modelIdx < 0 || hullVerts.size() < 4)
return false;

std::set<int> affectedPlanes;
Expand Down
21 changes: 5 additions & 16 deletions src/editor/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,31 +575,20 @@ void Renderer::renderLoop()
}
}

modelUsesSharedStructures = modelIdx == 0 || modelIdx > 0 && SelectedMap->does_model_use_shared_structures(modelIdx);
modelUsesSharedStructures = modelIdx > 0 && SelectedMap->does_model_use_shared_structures(modelIdx);

isScalingObject = transformMode == TRANSFORM_MODE_SCALE && transformTarget == TRANSFORM_OBJECT;
isMovingOrigin = transformMode == TRANSFORM_MODE_MOVE && transformTarget == TRANSFORM_ORIGIN && modelIdx >= 0;
isTransformingValid = (!modelUsesSharedStructures || (transformMode == TRANSFORM_MODE_MOVE && transformTarget != TRANSFORM_VERTEX))
|| (isTransformableSolid && isScalingObject);
isTransformingWorld = ent && ent->isWorldSpawn() && transformTarget != TRANSFORM_OBJECT;
isTransformingWorld = modelIdx == 0 || ent && ent->isWorldSpawn();

if (ent && modelIdx < 0)
invalidSolid = false;
else if (modelIdx == 0)
invalidSolid = false;
else
{
invalidSolid = !modelVerts.size() || !SelectedMap->vertex_manipulation_sync(modelIdx, modelVerts, false);
if (!invalidSolid)
{
std::vector<TransformVert> tmpVerts;
SelectedMap->getModelPlaneIntersectVerts(modelIdx, tmpVerts); // for vertex manipulation + scaling

Solid modelSolid;
if (!getModelSolid(tmpVerts, SelectedMap, modelSolid))
{
invalidSolid = true;
}
}
}
invalidSolid = !SelectedMap->vertex_manipulation_sync(modelIdx, modelVerts, false);
}

setupView();
Expand Down

0 comments on commit 6d7f7f3

Please sign in to comment.