
New way -

The columns in those screenshots are as follows, in order Left to Right -
Visits to function
% of root time
Time
Avg Time
and the rest don't matter.
The problem was in CCameraSceneNode.cpp, recalculateViewArea function -
Code: Select all
void CCameraSceneNode::recalculateViewArea()
{
core::matrix4 mat = Projection * View;
ViewArea = SViewFrustrum(mat);
ViewArea.cameraPosition = getAbsolutePosition();
ViewArea.recalculateBoundingBox();
}
Code: Select all
//! Sets the frustrum based on a projection and/or view matrix and a camera position.
//! \param mat: View and/or Projection Matrix.
//! \param camPos: Position of the camera.
inline void SViewFrustrum::set(const core::matrix4& mat, const core::vector3df& camPos)
{
cameraPosition = camPos;
// left clipping plane
planes[SViewFrustrum::VF_LEFT_PLANE].Normal.X = mat(3,0) + mat(0,0);
planes[SViewFrustrum::VF_LEFT_PLANE].Normal.Y = mat(3,1) + mat(0,1);
planes[SViewFrustrum::VF_LEFT_PLANE].Normal.Z = mat(3,2) + mat(0,2);
planes[SViewFrustrum::VF_LEFT_PLANE].D = mat(3,3) + mat(0,3);
// right clipping plane
planes[SViewFrustrum::VF_RIGHT_PLANE].Normal.X = mat(3,0) - mat(0,0);
planes[SViewFrustrum::VF_RIGHT_PLANE].Normal.Y = mat(3,1) - mat(0,1);
planes[SViewFrustrum::VF_RIGHT_PLANE].Normal.Z = mat(3,2) - mat(0,2);
planes[SViewFrustrum::VF_RIGHT_PLANE].D = mat(3,3) - mat(0,3);
// top clipping plane
planes[SViewFrustrum::VF_TOP_PLANE].Normal.X = mat(3,0) - mat(1,0);
planes[SViewFrustrum::VF_TOP_PLANE].Normal.Y = mat(3,1) - mat(1,1);
planes[SViewFrustrum::VF_TOP_PLANE].Normal.Z = mat(3,2) - mat(1,2);
planes[SViewFrustrum::VF_TOP_PLANE].D = mat(3,3) - mat(1,3);
// bottom clipping plane
planes[SViewFrustrum::VF_BOTTOM_PLANE].Normal.X = mat(3,0) + mat(1,0);
planes[SViewFrustrum::VF_BOTTOM_PLANE].Normal.Y = mat(3,1) + mat(1,1);
planes[SViewFrustrum::VF_BOTTOM_PLANE].Normal.Z = mat(3,2) + mat(1,2);
planes[SViewFrustrum::VF_BOTTOM_PLANE].D = mat(3,3) + mat(1,3);
// near clipping plane
planes[SViewFrustrum::VF_NEAR_PLANE].Normal.X = mat(2,0);
planes[SViewFrustrum::VF_NEAR_PLANE].Normal.Y = mat(2,1);
planes[SViewFrustrum::VF_NEAR_PLANE].Normal.Z = mat(2,2);
planes[SViewFrustrum::VF_NEAR_PLANE].D = mat(2,3);
// far clipping plane
planes[SViewFrustrum::VF_FAR_PLANE].Normal.X = mat(3,0) - mat(2,0);
planes[SViewFrustrum::VF_FAR_PLANE].Normal.Y = mat(3,1) - mat(2,1);
planes[SViewFrustrum::VF_FAR_PLANE].Normal.Z = mat(3,2) - mat(2,2);
planes[SViewFrustrum::VF_FAR_PLANE].D = mat(3,3) - mat(2,3);
// normalize normals
f32 len;
len = (f32)( 1.0f / planes[0].Normal.getLength() );
planes[0].Normal *= len;
planes[0].D *= len;
len = (f32)( 1.0f / planes[1].Normal.getLength() );
planes[1].Normal *= len;
planes[1].D *= len;
len = (f32)( 1.0f / planes[2].Normal.getLength() );
planes[2].Normal *= len;
planes[2].D *= len;
len = (f32)( 1.0f / planes[3].Normal.getLength() );
planes[3].Normal *= len;
planes[3].D *= len;
len = (f32)( 1.0f / planes[4].Normal.getLength() );
planes[4].Normal *= len;
planes[4].D *= len;
len = (f32)( 1.0f / planes[5].Normal.getLength() );
planes[5].Normal *= len;
planes[5].D *= len;
// make bounding box
recalculateBoundingBox();
}
Code: Select all
void CCameraSceneNode::recalculateViewArea()
{
ViewArea.set( Projection * View, getAbsolutePosition() );
}
EDIT: Sorry, those time are in microseconds not milliseconds.
EDIT2: Had 1 typo in the matrix stuff, when getting rid of the sw macro stuff, edited the code above.
