Asmodeus
2004-08-09, 11:33:23
Ich suche nach dem schnellsten Code für das Frustum Culling von Bounding Boxes. Bisher vewende ich die Methode über den Ebenentest.
bool ComputeSurfaceObjectVisibility(float Position[3], float Size[3], const PlaneInfo frustum[6])
{
for(int i = 0; i < 6; i++)
{
if((frustum[i].normal.x * (Position[0] - Size[0]) +
frustum[i].normal.y * (Position[1] - Size[1]) +
frustum[i].normal.z * (Position[2] - Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] + Size[0]) +
frustum[i].normal.y * (Position[1] - Size[1]) +
frustum[i].normal.z * (Position[2] - Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] - Size[0]) +
frustum[i].normal.y * (Position[1] + Size[1]) +
frustum[i].normal.z * (Position[2] - Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] + Size[0]) +
frustum[i].normal.y * (Position[1] + Size[1]) +
frustum[i].normal.z * (Position[2] - Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] - Size[0]) +
frustum[i].normal.y * (Position[1] - Size[1]) +
frustum[i].normal.z * (Position[2] + Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] + Size[0]) +
frustum[i].normal.y * (Position[1] - Size[1]) +
frustum[i].normal.z * (Position[2] + Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] - Size[0]) +
frustum[i].normal.y * (Position[1] + Size[1]) +
frustum[i].normal.z * (Position[2] + Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] + Size[0]) +
frustum[i].normal.y * (Position[1] + Size[1]) +
frustum[i].normal.z * (Position[2] + Size[2]) +
frustum[i].d) > 0)
continue;
return false;
}
return true;
}
Meine Frage ist nun, gibt es noch eine schnellere Methode?
Gruss, Carsten.
bool ComputeSurfaceObjectVisibility(float Position[3], float Size[3], const PlaneInfo frustum[6])
{
for(int i = 0; i < 6; i++)
{
if((frustum[i].normal.x * (Position[0] - Size[0]) +
frustum[i].normal.y * (Position[1] - Size[1]) +
frustum[i].normal.z * (Position[2] - Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] + Size[0]) +
frustum[i].normal.y * (Position[1] - Size[1]) +
frustum[i].normal.z * (Position[2] - Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] - Size[0]) +
frustum[i].normal.y * (Position[1] + Size[1]) +
frustum[i].normal.z * (Position[2] - Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] + Size[0]) +
frustum[i].normal.y * (Position[1] + Size[1]) +
frustum[i].normal.z * (Position[2] - Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] - Size[0]) +
frustum[i].normal.y * (Position[1] - Size[1]) +
frustum[i].normal.z * (Position[2] + Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] + Size[0]) +
frustum[i].normal.y * (Position[1] - Size[1]) +
frustum[i].normal.z * (Position[2] + Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] - Size[0]) +
frustum[i].normal.y * (Position[1] + Size[1]) +
frustum[i].normal.z * (Position[2] + Size[2]) +
frustum[i].d) > 0)
continue;
if((frustum[i].normal.x * (Position[0] + Size[0]) +
frustum[i].normal.y * (Position[1] + Size[1]) +
frustum[i].normal.z * (Position[2] + Size[2]) +
frustum[i].d) > 0)
continue;
return false;
}
return true;
}
Meine Frage ist nun, gibt es noch eine schnellere Methode?
Gruss, Carsten.