Getting Rebuild working for Object3D

This commit is contained in:
Lars Brubaker 2018-05-22 14:13:43 -07:00
parent ca438aba4b
commit 28b55b73a5
9 changed files with 28 additions and 9 deletions

View file

@ -326,19 +326,18 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
return positionToAlignTo + extraOffset;
}
bool inRebuild;
protected override void OnInvalidate()
{
if (!inRebuild)
if (!Rebuilding)
{
Rebuild(null);
}
base.OnInvalidate();
}
public void Rebuild(UndoBuffer undoBuffer)
public override void Rebuild(UndoBuffer undoBuffer)
{
inRebuild = true;
Rebuilding = true;
var aabb = this.GetAxisAlignedBoundingBox();
// TODO: check if the has code for the children
@ -435,7 +434,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
}
});
inRebuild = false;
Rebuilding = false;
base.Rebuild(undoBuffer);
}
public override void Remove(UndoBuffer undoBuffer)

View file

@ -52,6 +52,7 @@ namespace MatterHackers.MatterControl.DesignTools
public override void Rebuild(UndoBuffer undoBuffer)
{
Rebuilding = true;
ResetMeshWrappers();
var meshWrapper = this.Descendants()
@ -122,6 +123,7 @@ namespace MatterHackers.MatterControl.DesignTools
}
}
Rebuilding = false;
// Let the base know it needs to rebuild
base.Rebuild(undoBuffer);
}

View file

@ -131,8 +131,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
return fitToBounds;
}
public void Rebuild(UndoBuffer undoBuffer)
public override void Rebuild(UndoBuffer undoBuffer)
{
Rebuilding = true;
var aabb = this.GetAxisAlignedBoundingBox();
AdjustChildSize(null, null);
@ -142,6 +143,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
Rebuilding = false;
base.Rebuild(undoBuffer);
}
private void AdjustChildSize(object sender, EventArgs e)

View file

@ -47,8 +47,11 @@ namespace MatterHackers.MatterControl.DesignTools
{
}
public void Rebuild(UndoBuffer undoBuffer)
public override void Rebuild(UndoBuffer undoBuffer)
{
Rebuilding = true;
ResetMeshWrappers();
var meshWrapper = this.Descendants()
.Where((obj) => obj.OwnerID == this.ID).ToList();
@ -107,6 +110,9 @@ namespace MatterHackers.MatterControl.DesignTools
transformedMesh.MarkAsChanged();
transformedMesh.CalculateNormals();
Rebuilding = false;
base.Rebuild(undoBuffer);
}
}
}