Sign in to follow this  
Koder4Fun

Testing segment for full occlusion with a bsp-tree [Solved]

Recommended Posts

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:
		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);
		}



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]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this