Lasse Jon Fuglsang Pedersen 2020-12-28 12:47:22 +01:00
Родитель bb8bef1400 da94f63ba3
Коммит 715c0b6a61
1 изменённых файлов: 9 добавлений и 77 удалений

Просмотреть файл

@ -69,31 +69,22 @@ float BoundaryDistance(const float3 p)
float d = 1e+7;
#if 0
// capsules
for (uint i = 0; i != _BoundaryCapsuleCount; i++)
{
for (uint i = 0; i != _BoundaryCapsuleCount; i++)
{
BoundaryCapsule capsule = _BoundaryCapsule[i];
d = min(d, SdCapsule(p, capsule.centerA, capsule.centerB, capsule.radius));
}
BoundaryCapsule capsule = _BoundaryCapsule[i];
d = min(d, SdCapsule(p, capsule.centerA, capsule.centerB, capsule.radius));
}
// spheres
for (uint i = 0; i != _BoundarySphereCount; i++)
{
for (uint i = 0; i != _BoundarySphereCount; i++)
{
BoundarySphere sphere = _BoundarySphere[i];
d = min(d, SdSphere(p, sphere.center, sphere.radius));
}
BoundarySphere sphere = _BoundarySphere[i];
d = min(d, SdSphere(p, sphere.center, sphere.radius));
}
// tori
for (uint i = 0; i != _BoundaryTorusCount; i++)
{
for (uint i = 0; i != _BoundaryTorusCount; i++)
{
BoundaryTorus torus = _BoundaryTorus[i];
d = min(d, SdTorus(p, torus.center, torus.axis, torus.radiusA, torus.radiusB));
}
BoundaryTorus torus = _BoundaryTorus[i];
d = min(d, SdTorus(p, torus.center, torus.axis, torus.radiusA, torus.radiusB));
}
#else
uint i = 0;
@ -156,63 +147,4 @@ float3 BoundaryNormal(const float3 p, const float d)
));
}
/*
float4 BoundaryDistance4(const float3 p0, const float3 p1, const float3 p2, const float3 p3)
{
float4 d = 1e+7;
// capsules
{
for (uint i = 0; i != _BoundaryCapsuleCount; i++)
{
BoundaryCapsule capsule = _BoundaryCapsule[i];
float3 pa0 = p0 - capsule.centerA;
float3 pa1 = p1 - capsule.centerA;
float3 pa2 = p2 - capsule.centerA;
float3 pa3 = p3 - capsule.centerA;
float3 ba = capsule.centerB - capsule.centerA;
float h0 = saturate(dot(pa0, ba) / dot(ba, ba));
float h1 = saturate(dot(pa1, ba) / dot(ba, ba));
float h2 = saturate(dot(pa2, ba) / dot(ba, ba));
float h3 = saturate(dot(pa3, ba) / dot(ba, ba));
float r = capsule.radius;
d.x = min(d.x, length(pa0 - ba * h0) - r);
d.y = min(d.y, length(pa1 - ba * h1) - r);
d.z = min(d.z, length(pa2 - ba * h2) - r);
d.w = min(d.w, length(pa3 - ba * h3) - r);
}
}
// spheres
{
for (uint i = 0; i != _BoundarySphereCount; i++)
{
BoundarySphere sphere = _BoundarySphere[i];
float3 a = sphere.center;
float r = sphere.radius;
d.x = min(d.x, length(a - p0) - r);
d.y = min(d.y, length(a - p1) - r);
d.z = min(d.z, length(a - p2) - r);
d.w = min(d.w, length(a - p3) - r);
}
}
// tori
{
for (uint i = 0; i != _BoundaryTorusCount; i++)
{
BoundaryTorus torus = _BoundaryTorus[i];
//TODO
}
}
return d;
}
//*/
#endif//__HAIRSIMCOMPUTEBOUNDARIES_HLSL__