forked from bit/DotRecastNetSim
refactor: added test RcVec3f.CopyTo
This commit is contained in:
parent
e4dc81b027
commit
a9888bd281
|
@ -456,11 +456,17 @@ namespace DotRecast.Core.Numerics
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Copy(float[] @out, int n, RcVec3f @in)
|
public readonly void CopyTo(float[] array)
|
||||||
{
|
{
|
||||||
@out[n + 0] = @in.X;
|
CopyTo(array, 0);
|
||||||
@out[n + 1] = @in.Y;
|
}
|
||||||
@out[n + 2] = @in.Z;
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public readonly void CopyTo(float[] array, int n)
|
||||||
|
{
|
||||||
|
array[n + 0] = X;
|
||||||
|
array[n + 1] = Y;
|
||||||
|
array[n + 2] = Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
|
|
@ -1088,7 +1088,7 @@ namespace DotRecast.Recast
|
||||||
// Mark sample as added.
|
// Mark sample as added.
|
||||||
samples[besti * 4 + 3] = 1;
|
samples[besti * 4 + 3] = 1;
|
||||||
// Add the new sample point.
|
// Add the new sample point.
|
||||||
RcVec3f.Copy(verts, nverts * 3, bestpt);
|
bestpt.CopyTo(verts, nverts * 3);
|
||||||
nverts++;
|
nverts++;
|
||||||
|
|
||||||
// Create new triangulation.
|
// Create new triangulation.
|
||||||
|
|
|
@ -91,5 +91,22 @@ public class Vector3Tests
|
||||||
Assert.That(v3.X, Is.EqualTo(v33.X));
|
Assert.That(v3.X, Is.EqualTo(v33.X));
|
||||||
Assert.That(v3.Y, Is.EqualTo(v33.Y));
|
Assert.That(v3.Y, Is.EqualTo(v33.Y));
|
||||||
Assert.That(v3.Z, Is.EqualTo(v33.Z));
|
Assert.That(v3.Z, Is.EqualTo(v33.Z));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[Repeat(100000)]
|
||||||
|
public void TestVectorCopyTo()
|
||||||
|
{
|
||||||
|
var v1 = new Vector3(Random.Shared.NextSingle(), Random.Shared.NextSingle(), Random.Shared.NextSingle());
|
||||||
|
var array1 = new float[3];
|
||||||
|
v1.CopyTo(array1);
|
||||||
|
|
||||||
|
var v11 = new RcVec3f(v1.X, v1.Y, v1.Z);
|
||||||
|
var array11 = new float[3];
|
||||||
|
v11.CopyTo(array11);
|
||||||
|
|
||||||
|
Assert.That(array1, Is.EqualTo(array11));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue