• Advertisement


This topic is now archived and is closed to further replies.

Point in poly test

This topic is 6715 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'm trying to write a point in poly function for my lightmap creator.
Before I used a 2d point-in-poly test, but I want to use planes instead.
I tried this:


int CPoly::GetPointInPoly(CVector p)
CVector v1, v2, cNormal, tmp;
CPlane plane;

cNormal = GetNormal( NULL );

for(int i = 0; i < m_iNumVertices; i++)
v1 = m_pPolyVert->m_pVertices[ m_iVertices[i] ].cCoord;
tmp = cNormal.Crossproduct( v1 );
plane.m_cNormal = tmp;
plane.m_fDistance = - ( tmp.Dotproduct( p ) );
if( plane.m_fDistance < 0 )
if( plane.PlaneSide( p ) < 0)
return 0;
return 1;

But that doesn't work at all

Greets Tobias

Share this post

Link to post
Share on other sites

  • Advertisement