public virtual bool Act(double x, double y, double z, ref Voxel voxel) { var vpos = new Vector3d(x, y, z); var distanceSquared = position.DistanceSquared(vpos); if (distanceSquared < radiusSquared) { var px = (int)((x - (position.x - radius)) * stepInverse); var py = (int)((y - (position.y - radius)) * stepInverse); var pz = (int)((z - (position.z - radius)) * stepInverse); if (px >= 0 && px < size - 1 && py >= 0 && py < size - 1 && pz >= 0 && pz < size - 1) { var pointInCell = vpos - new Vector3d(px * step + (position.x - radius), py * step + (position.y - radius), pz * step + (position.z - radius)); pointInCell *= stepInverse; var interpolated = UMath.TrilinearInterpolate( GetVoxelValue(voxelValues, px, py, pz), GetVoxelValue(voxelValues, px, py, pz + 1), GetVoxelValue(voxelValues, px, py + 1, pz), GetVoxelValue(voxelValues, px, py + 1, pz + 1), GetVoxelValue(voxelValues, px + 1, py, pz), GetVoxelValue(voxelValues, px + 1, py, pz + 1), GetVoxelValue(voxelValues, px + 1, py + 1, pz), GetVoxelValue(voxelValues, px + 1, py + 1, pz + 1), pointInCell ); voxel.Value = UMath.Lerp(interpolated, voxel.Value, distanceSquared * radiusSquaredInverse); } } return(false); }