•      Sign In
• Create Account

### #Actualcozzie

Posted 21 March 2013 - 02:39 PM

Thanks, I understand the logic and just debugged quite a bit again.

I saved the result per plane for 3 situations (without stopping the loop), fully inside, outside and intersecting.

Mesh fully inside = OK:

Plane: 0
d > s: Return INSIDE
Plane: 1
d > s: Return INSIDE
Plane: 2
d > s: Return INSIDE
Plane: 3
d > s: Return INSIDE
Plane: 4
d > s: Return INSIDE
Plane: 5
d > s: Return INSIDE

'Live" it will stop after the 1st plane returning fully INSIDE.

Mesh intersecting = Not OK

Plane: 0
d > s: Return INSIDE

Plane: 1

Plane: 2
d > s: Return INSIDE

Plane: 3
d > s: Return INSIDE

Plane: 4
d > s: Return INSIDE

Plane: 5
d > s: Return INSIDE

'Live' it will stop after the 1st plane returning fully INSIDE, although it isn't, based on the 2nd plane.

Mesh fully outside = Not OK

The results is that only 1 plane returns 'outside'.

Plane: 0
d > s: Return INSIDE
Plane: 1
d > s: Return INSIDE
Plane: 2
d < -s: Return OUTSIDE
Plane: 3
d > s: Return INSIDE
Plane: 4
d > s: Return INSIDE
Plane: 5
d > s: Return INSIDE

Will be debugging more

Most likely it has to do with calculating 's', since it's always 4.9 or 5.0f, which is strange..

### #3cozzie

Posted 21 March 2013 - 02:36 PM

Thanks, I understand the logic and just debugged quite a bit again.

I saved the result per plane for 3 situations (without stopping the loop), fully inside, outside and intersecting.

Mesh fully inside = OK:

Plane: 0
d > s: Return INSIDE
Plane: 1
d > s: Return INSIDE
Plane: 2
d > s: Return INSIDE
Plane: 3
d > s: Return INSIDE
Plane: 4
d > s: Return INSIDE
Plane: 5
d > s: Return INSIDE

'Live" it will stop after the 1st plane returning fully INSIDE.

Mesh intersecting = Not OK

Plane: 0
d > s: Return INSIDE

Plane: 1

Plane: 2
d > s: Return INSIDE

Plane: 3
d > s: Return INSIDE

Plane: 4
d > s: Return INSIDE

Plane: 5
d > s: Return INSIDE

'Live' it will stop after the 1st plane returning fully INSIDE, although it isn't, based on the 2nd plane.

Mesh fully outside = Not OK

The results is that only 1 plane returns 'outside'.

Plane: 0
d > s: Return INSIDE
Plane: 1
d > s: Return INSIDE
Plane: 2
d < -s: Return OUTSIDE
Plane: 3
d > s: Return INSIDE
Plane: 4
d > s: Return INSIDE
Plane: 5
d > s: Return INSIDE

Will be debugging more

### #2cozzie

Posted 21 March 2013 - 02:35 PM

Thanks, I understand the logic and just debugged quite a bit again.

I saved the result per plane for 3 situations (without stopping the loop), fully inside, outside and intersecting.

Mesh fully inside = OK:

Plane: 0
d > s: Return INSIDE
Plane: 1
d > s: Return INSIDE
Plane: 2
d > s: Return INSIDE
Plane: 3
d > s: Return INSIDE
Plane: 4
d > s: Return INSIDE
Plane: 5
d > s: Return INSIDE

'Live" it will stop after the 1st plane returning fully INSIDE.

Mesh intersecting = Not OK

Plane: 0
d > s: Return INSIDE

Plane: 1

Plane: 2
d > s: Return INSIDE

Plane: 3
d > s: Return INSIDE

Plane: 4
d > s: Return INSIDE

Plane: 5
d > s: Return INSIDE

'Live' it will stop after the 1st plane returning fully INSIDE, although it isn't based on the 2nd plane.

Mesh fully outside = Not OK

The results is that only 1 plane returns 'outside'.

Plane: 0
d > s: Return INSIDE
Plane: 1
d > s: Return INSIDE
Plane: 2
d < -s: Return OUTSIDE
Plane: 3
d > s: Return INSIDE
Plane: 4
d > s: Return INSIDE
Plane: 5
d > s: Return INSIDE

Will be debugging more

### #1cozzie

Posted 21 March 2013 - 01:44 PM

Thanks, I understand the logic and will dig into it: debugging.

When I follow the logic, culling is only done correctly for the first plane I process, so probably something's wrong with one of the equations.

Moving the camera so the mesh 'exits the frustum' at the 1st plane (left in my case), the object's correctly culled. Moving the camera so the mesh get's out the frustum at another plane, doesn't make it cull (only when 'far away' from the frustum).

I'll let you know.

int CD3dcam::OBBInFrustum(BOUNDINGBOX *pBoundingBox, D3DXMATRIX *pWorldMatrix)
{
D3DXVec3Normalize(&mAx, &D3DXVECTOR3(pWorldMatrix->_11, pWorldMatrix->_12, pWorldMatrix->_13));
D3DXVec3Normalize(&mAy, &D3DXVECTOR3(pWorldMatrix->_21, pWorldMatrix->_22, pWorldMatrix->_23));
D3DXVec3Normalize(&mAz, &D3DXVECTOR3(pWorldMatrix->_31, pWorldMatrix->_32, pWorldMatrix->_33));

float d, s;

for(int i=0;i<6;++i)
{
D3DXVECTOR3 planevector = D3DXVECTOR3(mFrustumPlane[i].a, mFrustumPlane[i].b, mFrustumPlane[i].c);

d = D3DXPlaneDotCoord(&mFrustumPlane[i], &pBoundingBox->OBBcenter);

s = abs	(D3DXVec3Dot(&mAx, &D3DXVECTOR3(mFrustumPlane[i].a, mFrustumPlane[i].b, mFrustumPlane[i].c))) * pBoundingBox->OBBsize.x / 2.0f +
abs	(D3DXVec3Dot(&mAy, &D3DXVECTOR3(mFrustumPlane[i].a, mFrustumPlane[i].b, mFrustumPlane[i].c))) * pBoundingBox->OBBsize.y / 2.0f +
abs	(D3DXVec3Dot(&mAz, &D3DXVECTOR3(mFrustumPlane[i].a, mFrustumPlane[i].b, mFrustumPlane[i].c))) * pBoundingBox->OBBsize.z / 2.0f;

if(d > s) return INSIDE;
if(d < -s) return OUTSIDE;
}
return INTERSECT;
}



PARTNERS