public void Execute(ref CubeData data, int index, int batch) { //Avoid others in our cell int hash = hasher.Hash(data.Position); int neighbourAmount = cubeLookup.GetBucketSize(hash); for (int i = 0; i < neighbourAmount; i++) { CubeData neighbour = cubeLookup.GetBucketElement(hash, i); //Skip ourselves if (neighbour.ID == data.ID) { continue; } Avoid(ref data, neighbour.Position, CubeRadius, neighbour.Velocity, CubeSeperationForce, CubeVeloInheritance); } //Avoid target 1 if (Avoid(ref data, Target1Position, TargetRadius, Target1Velocity, TargetSeperationForce, TargetVeloInheritance)) { data.TimeNotHitTarget1 = 0f; } else { data.TimeNotHitTarget1 += DeltaTime; } //Avoid target 2 if (Avoid(ref data, Target2Position, TargetRadius, Target2Velocity, TargetSeperationForce, TargetVeloInheritance)) { data.TimeNotHitTarget2 = 0f; } else { data.TimeNotHitTarget2 += DeltaTime; } //Update position data.Position += data.Velocity * DeltaTime; }
public void Execute(ref CubeData cubeData, int index, int batch) { int hash = hasher.Hash(cubeData.Position); bucketSet.Add(hash, cubeData); }