-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPlanePacket.cs
More file actions
35 lines (30 loc) · 1.27 KB
/
PlanePacket.cs
File metadata and controls
35 lines (30 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
using System.Runtime.Intrinsics.X86;
using static System.Runtime.Intrinsics.X86.Avx;
using System.Runtime.Intrinsics;
using System.Runtime.CompilerServices;
internal sealed class PlanePacket256 : ObjectPacket256
{
public VectorPacket256 Norms;
public Vector256<float> Offsets;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PlanePacket256(VectorPacket256 norms, Vector256<float> offsets, Surface surface) : base(surface)
{
Norms = norms;
Offsets = offsets;
}
public override VectorPacket256 Normals(VectorPacket256 pos)
{
return Norms;
}
public override Vector256<float> Intersect(RayPacket256 rayPacket256)
{
var denom = VectorPacket256.DotProduct(Norms, rayPacket256.Dirs);
var dist = Divide(Add(VectorPacket256.DotProduct(Norms, rayPacket256.Starts), Offsets), Subtract(Vector256<float>.Zero, denom));
var gtMask = Compare(denom, Vector256<float>.Zero, FloatComparisonMode.OrderedGreaterThanNonSignaling);
return BlendVariable(dist, Intersections.NullDistance, gtMask);
}
}