Minor changes
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
struct Plane
|
||||
{
|
||||
float4 nd;
|
||||
float3 getNormal()
|
||||
{
|
||||
return nd.xyz;
|
||||
}
|
||||
float getDistance()
|
||||
{
|
||||
return nd.w;
|
||||
}
|
||||
bool pointInside(float3 point)
|
||||
{
|
||||
return dot(getNormal(), point) - getDistance() > 0.0f;
|
||||
}
|
||||
};
|
||||
|
||||
struct Frustum
|
||||
{
|
||||
Plane sides[4];
|
||||
bool pointInside(float3 point)
|
||||
{
|
||||
for(int p = 0; p < 4; ++p)
|
||||
{
|
||||
if(!sides[p].pointInside(point))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
Plane computePlane(float3 p0, float3 p1, float3 p2)
|
||||
{
|
||||
Plane plane;
|
||||
|
||||
float3 v0 = p1 - p0;
|
||||
float3 v2 = p2 - p0;
|
||||
|
||||
float3 n = normalize(cross(v0, v2));
|
||||
|
||||
float d = dot(n, p0);
|
||||
|
||||
plane.nd = float4(n, d);
|
||||
|
||||
return plane;
|
||||
}
|
||||
Reference in New Issue
Block a user