@@ -49,10 +49,19 @@ namespace Demo
49
49
planeMeshV1->unload ();
50
50
}
51
51
52
+
53
+ {
54
+ // We must alter the AABB because we want to always pass frustum culling
55
+ // Otherwise frustum culling may hide bugs in the projection matrix math
56
+ planeMesh->load ();
57
+ Ogre::Aabb aabb = planeMesh->getAabb ();
58
+ aabb.mHalfSize .z = aabb.mHalfSize .x ;
59
+ planeMesh->_setBounds ( aabb );
60
+ }
61
+
52
62
Ogre::Item *item = sceneManager->createItem ( planeMesh, Ogre::SCENE_DYNAMIC );
53
63
mSceneNode = sceneManager->getRootSceneNode ( Ogre::SCENE_DYNAMIC )
54
64
->createChildSceneNode ( Ogre::SCENE_DYNAMIC );
55
- mSceneNode ->setPosition ( 0 , 0 , -5 );
56
65
mSceneNode ->setScale ( Ogre::Vector3 ( 1000 .0f ) );
57
66
mSceneNode ->attachObject ( item );
58
67
@@ -69,18 +78,18 @@ namespace Demo
69
78
camera->setOrientation ( Ogre::Quaternion::IDENTITY );
70
79
71
80
camera->setNearClipDistance ( 0 .5f );
72
- mSceneNode ->setPosition ( 0 , 0 , -0 .5f );
81
+ mSceneNode ->setPosition ( 0 , 0 , -0 .5f + 1e- 6f );
73
82
74
83
TutorialGameState::createScene01 ();
75
84
}
76
85
// -----------------------------------------------------------------------------------
77
86
void NearFarProjectionGameState::generateDebugText ( float timeSinceLast, Ogre::String &outText )
78
87
{
79
88
TutorialGameState::generateDebugText ( timeSinceLast, outText );
80
- outText += " \n F2 to test at near plane" ;
81
- outText += " \n F3 to test after near plane" ;
82
- outText += " \n F4 to test behind far plane" ;
83
- outText += " \n F5 to test at far plane" ;
89
+ outText += " \n F2 to test behind near plane (should be blue) " ;
90
+ outText += " \n F3 to test after near plane (should be grey) " ;
91
+ outText += " \n F4 to test behind far plane (should be grey) " ;
92
+ outText += " \n F5 to test after far plane (should be blue) " ;
84
93
85
94
char tmpBuffer[256 ];
86
95
Ogre::LwString tmpStr ( Ogre::LwString::FromEmptyPointer ( tmpBuffer, sizeof ( tmpBuffer ) ) );
@@ -107,7 +116,7 @@ namespace Demo
107
116
108
117
if ( arg.keysym .sym == SDLK_F2 )
109
118
{
110
- mSceneNode ->setPosition ( 0 , 0 , -camera->getNearClipDistance () );
119
+ mSceneNode ->setPosition ( 0 , 0 , -camera->getNearClipDistance () + 1e- 6f );
111
120
}
112
121
else if ( arg.keysym .sym == SDLK_F3 )
113
122
{
@@ -119,7 +128,7 @@ namespace Demo
119
128
}
120
129
else if ( arg.keysym .sym == SDLK_F5 )
121
130
{
122
- mSceneNode ->setPosition ( 0 , 0 , -camera->getFarClipDistance () );
131
+ mSceneNode ->setPosition ( 0 , 0 , -camera->getFarClipDistance () - 0 . 5f );
123
132
}
124
133
else
125
134
{
0 commit comments