Fixing translation error in scale
Added a test
This commit is contained in:
parent
78b7ac0629
commit
16a1a61197
6 changed files with 67 additions and 8 deletions
|
|
@ -79,7 +79,7 @@ namespace MatterControl.Tests.MatterControl
|
|||
-10, -10, -10,
|
||||
20, 10, 10).Equals(rootAabb, .001));
|
||||
}
|
||||
|
||||
|
||||
// Combine has correct results when inner content is changed
|
||||
{
|
||||
var root = new Object3D();
|
||||
|
|
@ -391,6 +391,59 @@ namespace MatterControl.Tests.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
[Test, Category("InteractiveScene")]
|
||||
public void ScaleObjectMantainsCorrectAabb()
|
||||
{
|
||||
// build cube with scale and undo
|
||||
{
|
||||
// create a simple cube with translation
|
||||
var root = new Object3D();
|
||||
var cube = new CubeObject3D(20, 20, 20);
|
||||
cube.Matrix = Matrix4X4.CreateTranslation(50, 60, 10);
|
||||
root.Children.Add(cube);
|
||||
Assert.AreEqual(2, root.DescendantsAndSelf().Count());
|
||||
var preScaleAabb = root.GetAxisAlignedBoundingBox();
|
||||
|
||||
var undoBuffer = new UndoBuffer();
|
||||
|
||||
// add a scale to it (that is not scaled)
|
||||
var scaleObject = new ScaleObject3D();
|
||||
scaleObject.WrapItem(cube, undoBuffer);
|
||||
|
||||
// ensure that the object did not move
|
||||
Assert.IsTrue(scaleObject.ScaleAbout.Equals(new Vector3(50, 60, 0)));
|
||||
Assert.AreEqual(4, root.DescendantsAndSelf().Count());
|
||||
var postScaleAabb = root.GetAxisAlignedBoundingBox();
|
||||
|
||||
Assert.IsTrue(preScaleAabb.Equals(postScaleAabb, .001));
|
||||
|
||||
Assert.AreNotEqual(cube, scaleObject.SourceItem, "There is an undo buffer, there should have been a clone");
|
||||
}
|
||||
|
||||
// build cube with scale
|
||||
{
|
||||
// create a simple cube with translation
|
||||
var root = new Object3D();
|
||||
var cube = new CubeObject3D(20, 20, 20);
|
||||
cube.Matrix = Matrix4X4.CreateTranslation(50, 60, 10);
|
||||
root.Children.Add(cube);
|
||||
Assert.AreEqual(2, root.DescendantsAndSelf().Count());
|
||||
var preScaleAabb = root.GetAxisAlignedBoundingBox();
|
||||
|
||||
// add a scale to it (that is not scaled)
|
||||
var scaleObject = new ScaleObject3D(cube);
|
||||
|
||||
// ensure that the object did not move
|
||||
Assert.IsTrue(scaleObject.ScaleAbout.Equals(new Vector3(50, 60, 0)));
|
||||
Assert.AreEqual(4, root.DescendantsAndSelf().Count());
|
||||
var postScaleAabb = root.GetAxisAlignedBoundingBox();
|
||||
|
||||
Assert.IsTrue(preScaleAabb.Equals(postScaleAabb, .001));
|
||||
|
||||
Assert.AreEqual(cube, scaleObject.SourceItem, "There is no undo buffer, there should not have been a clone");
|
||||
}
|
||||
}
|
||||
|
||||
[Test, Category("InteractiveScene")]
|
||||
public void AabbCalculatedCorrectlyForCurvedFitObjects()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue