public bool IsSegmentInSolid(Vector3 p1, Vector3 p2, float epsilon)
{
if (m_type == BSPNodeType.SolidLeaf)
return true;
if (m_type == BSPNodeType.EmptyLeaf)
return false;
float dist1 = m_partition.DotCoordinate(p1);
float dist2 = m_partition.DotCoordinate(p2);
if (dist1 >= epsilon && dist2 >= epsilon)
return m_front.IsSegmentInSolid(p1, p2, epsilon);
else if (dist1 < -epsilon && dist2 < -epsilon)
return m_back.IsSegmentInSolid(p1, p2, epsilon);
if (Math.Abs(dist1) < epsilon && Math.Abs(dist2) < epsilon && Math.Sign(dist1) == Math.Sign(dist2))
return m_front.IsSegmentInSolid(p1, p2, epsilon) | m_back.IsSegmentInSolid(p1, p2, epsilon);
Vector3 ip;
float dot = dist1 / (dist1 - dist2);
if (dot < 0.0f) dot = 0.0f;
if (dot > 1.0f) dot = 1.0f;
ip = p1 + dot * (p2 - p1);
if (dist1 > 0.0f)
return m_front.IsSegmentInSolid(p1, ip, epsilon) & m_back.IsSegmentInSolid(ip, p2, epsilon);
else
return m_back.IsSegmentInSolid(p1, ip, epsilon) & m_front.IsSegmentInSolid(ip, p2, epsilon);
}
Testing segment for full occlusion with a bsp-tree [Solved]
I have a working portalized solid-bsp compiler (like quake/unreal etc..) and I have implemented standard PVS.
Now that my maps are more detailed I have decided to implement a more effective solution for cell-portal decomposition based on this document
The problem is filtering of valid/non-valid separators.
I need an algo to test if all edges of a separator are fully in solid space.
This is my current aproach:
but this code fails. Some non-valid separators are not removed.
Can anyone help me, or show me what is wrong in my implementation?
Thanks...
[Edited by - Koder4Fun on January 21, 2009 11:05:06 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement