Skip to content

Commit

Permalink
Fix waypoint moving
Browse files Browse the repository at this point in the history
  • Loading branch information
ForserX committed Oct 28, 2024
1 parent 3ac2936 commit 1303129
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
25 changes: 25 additions & 0 deletions src/Editors/LevelEditor/Editor/Entry/WayPoint/WayPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,31 @@ bool CWayObject::FrustumSelect(int flag, const CFrustum& frustum)
}else return inherited::FrustumSelect(flag,frustum);
}

Fmatrix CWayObject::GetTransform() const
{
if (IsPointMode())
{
Fmatrix Result = FTransform;
int SelectCount = 0;

for (CWayPoint* Point : m_WayPoints)
{
if (Point->m_bSelected)
{
SelectCount++;
Result.c = Point->m_vPosition;
}

if (SelectCount > 1)
return FTransform;
}

return Result;
}

return FTransform;
}

bool CWayObject::GetBox( Fbox& box )
{
box.invalidate();
Expand Down
2 changes: 2 additions & 0 deletions src/Editors/LevelEditor/Editor/Entry/WayPoint/WayPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class CWayObject: public CCustomObject
virtual bool RaySelect (int flag, const Fvector& start, const Fvector& dir, bool bRayTest=false); // flag 1,0,-1 (-1 invert)
virtual bool FrustumSelect (int flag, const CFrustum& frustum);

virtual Fmatrix GetTransform () const;

CWayPoint* AppendWayPoint ();
CWayPoint* GetFirstSelected();
int GetSelectedPoints(WPVec& lst);
Expand Down
13 changes: 8 additions & 5 deletions src/Editors/LevelEditor/Editor/Utils/Gizmo/IM_Manipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,24 @@ void IM_Manipulator::Render(float canvasX, float canvasY, float canvasWidth, flo
if (PtrMoveSnap)
std::fill_n(MoveSnap, std::size(MoveSnap), Tools->m_MoveSnap);

if (lst.size() == 1)
{
CWayObject* WayPtr = smart_cast<CWayObject*>(lst.front());
ObjectMatrix = WayPtr->GetTransform();
}

const bool IsManipulated = ImGuizmo::Manipulate((float*)&Device.mView, (float*)&Device.mProject, ImGuizmo::TRANSLATE, ImGuizmo::WORLD, (float*)&ObjectMatrix, (float*)&DeltaMatrix, PtrMoveSnap);

if (IsManipulated)
{
for (CCustomObject* ObjPtr : lst)
{
ObjPtr->Move(DeltaMatrix.c);

if (CWayObject* WayPtr = smart_cast<CWayObject*>(ObjPtr))
{
ObjPtr->Move(DeltaMatrix.c);
ObjPtr->UpdateTransform();
}
else
{
ObjPtr->Move(DeltaMatrix.c);
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Editors/xrECore/Editor/ELog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ inline TMsgDlgButtons MessageDlg(const char*text, TMsgDlgType mt, int btn)
{
SDL_ShowMessageBox(&messageboxYes, &buttonid);
}
if (btn == mbOK)
else if (btn == mbOK)
{
SDL_ShowMessageBox(&messageboxOk, &buttonid);
}
if (btn == (mbOK | mbSkip))
else if (btn == (mbOK | mbSkip))
{
SDL_ShowMessageBox(&messageboxOkSkip, &buttonid);
}
Expand Down

0 comments on commit 1303129

Please sign in to comment.