Collisions editing progress

This commit is contained in:
dexy
2020-01-07 20:51:53 +11:00
Unverified
parent edba2cfae9
commit 3c60801e84
12 changed files with 1113 additions and 7 deletions
+56
View File
@@ -103,6 +103,10 @@ namespace CodeWalker.Project
{
bounds[item.CollisionPoly.Owner] = 1;
}
if (item.CollisionVertex?.Owner != null)
{
bounds[item.CollisionVertex.Owner] = 1;
}
}
}
@@ -763,6 +767,58 @@ namespace CodeWalker.Project
}
}
public class CollisionVertexPositionUndoStep : UndoStep
{
public BoundVertex Vertex { get; set; }
public Vector3 StartPosition { get; set; }
public Vector3 EndPosition { get; set; }
public CollisionVertexPositionUndoStep(BoundVertex vertex, Vector3 startpos, WorldForm wf)
{
Vertex = vertex;
StartPosition = startpos;
EndPosition = vertex?.Position ?? Vector3.Zero;
UpdateGraphics(wf);
}
private void Update(WorldForm wf, ref MapSelection sel, Vector3 p)
{
if (Vertex != null)
{
Vertex.Position = p;
}
if (Vertex != sel.CollisionVertex) wf.SelectCollisionVertex(Vertex);
wf.SetWidgetPosition(p);
UpdateGraphics(wf);
}
private void UpdateGraphics(WorldForm wf)
{
if (Vertex?.Owner != null)
{
wf.UpdateCollisionBoundsGraphics(Vertex.Owner);
}
}
public override void Undo(WorldForm wf, ref MapSelection sel)
{
Update(wf, ref sel, StartPosition);
}
public override void Redo(WorldForm wf, ref MapSelection sel)
{
Update(wf, ref sel, EndPosition);
}
public override string ToString()
{
return "Collision Vertex " + (Vertex?.Index.ToString() ?? "") + ": Position";
}
}
public class PathNodePositionUndoStep : UndoStep