|
|
|
|
|
|
vE0 = p1-p0; |
|
|
|
} |
|
|
|
|
|
|
|
void GetQuad(out float3 p0, out float3 p1, out float3 p2, out float3 p3, const float3 boxX, const float3 boxY, const float3 boxZ, const float3 center, const float2 scaleXY, const int sideIndex) |
|
|
|
void GetHullQuad(out float3 p0, out float3 p1, out float3 p2, out float3 p3, const float3 boxX, const float3 boxY, const float3 boxZ, const float3 center, const float2 scaleXY, const int sideIndex) |
|
|
|
{ |
|
|
|
//const int iAbsSide = (sideIndex == 0 || sideIndex == 1) ? 0 : ((sideIndex == 2 || sideIndex == 3) ? 1 : 2); |
|
|
|
const int iAbsSide = min(sideIndex>>1, 2); |
|
|
|
|
|
|
p3 = center + (vA2 + vB2 + vC); |
|
|
|
} |
|
|
|
|
|
|
|
void GetPlane(out float3 p0, out float3 vN, const float3 boxX, const float3 boxY, const float3 boxZ, const float3 center, const float2 scaleXY, const int sideIndex) |
|
|
|
void GetHullPlane(out float3 p0, out float3 n0, const float3 boxX, const float3 boxY, const float3 boxZ, const float3 center, const float2 scaleXY, const int sideIndex) |
|
|
|
{ |
|
|
|
//const int iAbsSide = (sideIndex == 0 || sideIndex == 1) ? 0 : ((sideIndex == 2 || sideIndex == 3) ? 1 : 2); |
|
|
|
const int iAbsSide = min(sideIndex>>1, 2); |
|
|
|
|
|
|
|
|
|
|
if (bIsSideQuad) { vA2 *= (iAbsSide == 0 ? scaleXY.x : scaleXY.y); vB2 *= (iAbsSide == 0 ? scaleXY.y : scaleXY.x); } |
|
|
|
|
|
|
|
float3 vN = cross(vB2, 0.5 * (vA - vA2) - vC); // +/- normal |
|
|
|
|
|
|
|
float3 n0 = cross(vB2, 0.5 * (vA - vA2) - vC); |
|
|
|
float3 vNout = dot(n0,v0) < 0.0 ? (-n0) : n0; |
|
|
|
|
|
|
|
vN = vNout; |
|
|
|
n0 = dot(vN,v0) < 0.0 ? (-vN) : vN; |
|
|
|
float4 GetPlaneEq(const float3 boxX, const float3 boxY, const float3 boxZ, const float3 center, const float2 scaleXY, const int sideIndex) |
|
|
|
float4 GetHullPlaneEq(const float3 boxX, const float3 boxY, const float3 boxZ, const float3 center, const float2 scaleXY, const int sideIndex) |
|
|
|
GetPlane(p0, vN, boxX, boxY, boxZ, center, scaleXY, sideIndex); |
|
|
|
GetHullPlane(p0, vN, boxX, boxY, boxZ, center, scaleXY, sideIndex); |
|
|
|
|
|
|
|
return float4(vN, -dot(vN,p0)); |
|
|
|
} |
|
|
|