• Advertisement
Sign in to follow this  

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

This topic is 3322 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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);
				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
Sign in to follow this  

  • Advertisement