public void Multiply_10x10n0() { FastUtils utils = new FastUtils(10, 10); double result = utils.Multiply(); Assert.AreNotEqual(result, 0); }
public static unsafe void Xor(byte *stream, byte *source, byte *destination, int length) { if (Avx.IsSupported && Avx2.IsSupported) { while (length >= 32) { Vector256 <byte> v0 = Avx.LoadVector256(stream); Vector256 <byte> v1 = Avx.LoadVector256(source); Avx.Store(destination, Avx2.Xor(v0, v1)); stream += 32; source += 32; destination += 32; length -= 32; } } if (Sse2.IsSupported) { while (length >= 16) { Vector128 <byte> v0 = Sse2.LoadVector128(stream); Vector128 <byte> v1 = Sse2.LoadVector128(source); Sse2.Store(destination, Sse2.Xor(v0, v1)); stream += 16; source += 16; destination += 16; length -= 16; } } FastUtils.Xor(stream, source, destination, length); }
public void Multiply_1x0e0() { double expected = 0; FastUtils utils = new FastUtils(1, 0); double result = utils.Multiply(); Assert.AreEqual(expected, result); }
public void Multiply_5x10e50() { double expected = 50; FastUtils utils = new FastUtils(5, 10); double result = utils.Multiply(); Assert.AreEqual(expected, result); }
public void Multiply_0x1e0() { FastUtils utils = new FastUtils(0, 1); double result = utils.Multiply(); // Assert.AreEqual(0, Utilities.Multiply(0, 1)); Assert.AreEqual(0, result); }
public static unsafe void Xor16(byte *stream, byte *source, byte *destination) { if (Sse2.IsSupported) { Vector128 <byte> v0 = Sse2.LoadVector128(stream); Vector128 <byte> v1 = Sse2.LoadVector128(source); Sse2.Store(destination, Sse2.Xor(v0, v1)); } else { FastUtils.Xor16(stream, source, destination); } }
private void PerformDeathMove(float elapsedTime) { CharacterOnSight = false; DeathTimeCounter -= elapsedTime; var RotationStep = FastMath.PI * 0.4f * elapsedTime; if (FastUtils.GreaterThan(AcumulatedZRotation, Constants.MaxZRotation)) { return; } AcumulatedZRotation += RotationStep; TotalRotation *= TGCMatrix.RotationAxis(director, RotationStep); Mesh.Transform = TotalRotation * TGCMatrix.Translation(new TGCVector3(Body.CenterOfMassPosition)); Body.WorldTransform = Mesh.Transform.ToBulletMatrix(); Body.LinearVelocity = Constants.DirectorY.ToBulletVector3() * 200; }
private bool CanSeekPlayer(out float rotationAngle, out TGCVector3 rotationAxis) { var actualDirector = -1 * director; var directorToPlayer = TGCVector3.Normalize(Camera.Position - new TGCVector3(Body.CenterOfMassPosition)); var NormalVectorFromDirAndPlayer = FastUtils.ObtainNormalVector(actualDirector, directorToPlayer); if (NormalVectorFromDirAndPlayer.Length() > 0.98f) { var RotationToPlayer = FastUtils.AngleBetweenVectors(actualDirector, directorToPlayer); if (RotationToPlayer <= FastMath.QUARTER_PI && RotationToPlayer != 0) { rotationAngle = RotationToPlayer; rotationAxis = NormalVectorFromDirAndPlayer; return(true); } } rotationAngle = 0; rotationAxis = TGCVector3.Empty; return(false); }
protected override unsafe void Xor(byte *stream, byte *source, byte *destination, int length) { FastUtils.Xor(stream, source, destination, length); }
public void Multiply_0x1n1() { FastUtils utils = new FastUtils(0, 1); Assert.AreNotEqual(1, utils.Multiply()); }
public void Multiply_1x10n1000() { FastUtils utils = new FastUtils(1, 10); Assert.AreNotEqual(1000, utils.Multiply()); }
private void PerformNormalMove(float elapsedTime, float speed, TGCVector3 headPosition) { time -= elapsedTime; ChangeDirectionTimeCounter -= elapsedTime; float XRotation = 0f, YRotation = 0f; var meshPosition = GetMeshPosition(); Terrain.world.InterpoledHeight(headPosition.X, headPosition.Z, out float floorHeight); var distanceToFloor = FastUtils.Distance(meshPosition.Y, floorHeight); var XRotationStep = FastMath.PI * 0.1f * elapsedTime; var YRotationStep = FastMath.PI * 0.03f * elapsedTime; if (FastUtils.LessThan(distanceToFloor, Constants.FishHeight.X - 40) && FastUtils.LessThan(acumulatedXRotation, Constants.MaxAxisRotation)) { XRotation = XRotationStep; } else if (FastUtils.IsNumberBetweenInterval(distanceToFloor, Constants.FishHeight) && FastUtils.GreaterThan(acumulatedXRotation, 0.0012f)) { XRotation = -XRotationStep; } if (FastUtils.GreaterThan(distanceToFloor, Constants.FishHeight.Y + 40) && FastUtils.GreaterThan(acumulatedXRotation, -Constants.MaxAxisRotation)) { XRotation = -XRotationStep; } else if (FastUtils.IsNumberBetweenInterval(distanceToFloor, Constants.FishHeight) && FastUtils.LessThan(acumulatedXRotation, -0.0012f)) { XRotation = XRotationStep; } if (ChangeDirectionTimeCounter <= 0) { if (FastUtils.LessThan(FastMath.Abs(acumulatedYRotation), Constants.MaxYRotation)) { YRotation = YRotationStep * RotationYSign(); } else { ChangeDirectionTimeCounter = Constants.CHANGE_DIRECTION_TIME; } } else { acumulatedYRotation = 0; } acumulatedXRotation += XRotation; acumulatedYRotation += YRotation; TGCMatrix rotation = TGCMatrix.Identity; if (XRotation != 0 || FastUtils.GreaterThan(FastMath.Abs(acumulatedXRotation), 0.0012f)) { var rotationAxis = TGCVector3.Cross(TGCVector3.Up, director); director.TransformCoordinate(TGCMatrix.RotationAxis(rotationAxis, XRotation)); rotation = TGCMatrix.RotationAxis(rotationAxis, XRotation); speed /= 1.5f; } else if (YRotation != 0) { director.TransformCoordinate(TGCMatrix.RotationY(YRotation)); rotation = TGCMatrix.RotationY(YRotation); } TotalRotation *= rotation; TGCMatrix traslation = TGCMatrix.Translation(meshPosition + director * -speed * elapsedTime); Mesh.Mesh.Transform = TGCMatrix.Scaling(Constants.Scale) * TotalRotation * traslation; Mesh.Mesh.BoundingBox.transform(Mesh.Mesh.Transform); }
private bool IsNearFromPlayer(TGCVector3 cameraPosition) => FastUtils.IsDistanceBetweenVectorsLessThan(distance: 1000, vectorA: cameraPosition, vectorB: GetFishHeadPosition());
private void PerformNormalMove(float elapsedTime, float speed, TGCVector3 headPosition) { CharacterOnSight = false; var XRotation = 0f; var YRotation = 0f; ChangeDirectionTimeCounter -= elapsedTime; Terrain.world.InterpoledHeight(headPosition.X, headPosition.Z, out float floorHeight); var distanceToFloor = Body.CenterOfMassPosition.Y - floorHeight; var XRotationStep = FastMath.PI * 0.1f * elapsedTime; var YRotationStep = FastMath.PI * 0.4f * elapsedTime; var distanceToWater = Constants.WATER_HEIGHT - floorHeight - 200; TGCVector2 sharkRangePosition = new TGCVector2(Constants.SHARK_HEIGHT.X, FastMath.Min(distanceToWater, Constants.SHARK_HEIGHT.Y)); if (distanceToFloor < sharkRangePosition.X - 150 && AcumulatedXRotation < Constants.MaxAxisRotation) { XRotation = XRotationStep; } else if (FastUtils.IsNumberBetweenInterval(distanceToFloor, sharkRangePosition) && AcumulatedXRotation > 0.0012) { XRotation = -XRotationStep; } else if (distanceToFloor > sharkRangePosition.Y + 150 && AcumulatedXRotation > -Constants.MaxAxisRotation) { XRotation = -XRotationStep; } else if (FastUtils.IsNumberBetweenInterval(distanceToFloor, sharkRangePosition) && AcumulatedXRotation < -0.0012) { XRotation = XRotationStep; } if (ChangeDirectionTimeCounter <= 0) { if (FastMath.Abs(AcumulatedYRotation) < Constants.MaxYRotation) { YRotation = YRotationStep * RotationYSign(); } else { ChangeDirectionTimeCounter = Constants.CHANGE_DIRECTION_TIME; } } else { AcumulatedYRotation = 0; } AcumulatedXRotation += XRotation; AcumulatedYRotation += YRotation; Body.ActivationState = ActivationState.ActiveTag; TGCMatrix rotation = TGCMatrix.Identity; if (XRotation != 0 || FastMath.Abs(AcumulatedXRotation) > 0.0012) { var rotationAxis = TGCVector3.Cross(TGCVector3.Up, director); director.TransformCoordinate(TGCMatrix.RotationAxis(rotationAxis, XRotation)); rotation = TGCMatrix.RotationAxis(rotationAxis, XRotation); speed /= 1.5f; } else if (YRotation != 0) { director.TransformCoordinate(TGCMatrix.RotationY(YRotation)); rotation = TGCMatrix.RotationY(YRotation); } TotalRotation *= rotation; Mesh.Transform = TotalRotation * TGCMatrix.Translation(new TGCVector3(Body.CenterOfMassPosition)); Body.WorldTransform = Mesh.Transform.ToBulletMatrix(); Body.LinearVelocity = director.ToBulletVector3() * -speed; }
private bool IsFish(string name) => FastUtils.Contains(name, "fish");
public bool InPerimeterSkyBox(float posX, float posZ) => FastUtils.IsNumberBetweenInterval(posX, (CurrentPerimeter.xMin, CurrentPerimeter.xMax)) &&