@@ -306,21 +306,26 @@ namespace Ogre {
306
306
return mWorldMatrixArray + int (MeshManager::getBonesUseObjectSpace ());
307
307
}
308
308
// -----------------------------------------------------------------------------
309
- const Affine3& AutoParamDataSource::getViewMatrix (void ) const
309
+ Affine3 AutoParamDataSource::getViewMatrix (const Camera* cam ) const
310
310
{
311
- if (mViewMatrixDirty )
311
+ Affine3 view;
312
+ if (mCurrentRenderable && mCurrentRenderable ->getUseIdentityView ())
313
+ view = Affine3::IDENTITY;
314
+ else
312
315
{
313
- if (mCurrentRenderable && mCurrentRenderable ->getUseIdentityView ())
314
- mViewMatrix = Affine3::IDENTITY;
315
- else
316
+ view = cam->getViewMatrix (true );
317
+ if (mCameraRelativeRendering )
316
318
{
317
- mViewMatrix = mCurrentCamera ->getViewMatrix (true );
318
- if (mCameraRelativeRendering )
319
- {
320
- mViewMatrix .setTrans (Vector3::ZERO);
321
- }
322
-
319
+ view.setTrans (Vector3::ZERO);
323
320
}
321
+ }
322
+ return view;
323
+ }
324
+ const Affine3& AutoParamDataSource::getViewMatrix (void ) const
325
+ {
326
+ if (mViewMatrixDirty )
327
+ {
328
+ mViewMatrix = getViewMatrix (mCurrentCamera );
324
329
mViewMatrixDirty = false ;
325
330
}
326
331
return mViewMatrix ;
@@ -336,31 +341,40 @@ namespace Ogre {
336
341
return mViewProjMatrix ;
337
342
}
338
343
// -----------------------------------------------------------------------------
344
+ Matrix4 AutoParamDataSource::getProjectionMatrix (const Camera* cam) const
345
+ {
346
+ Matrix4 proj;
347
+
348
+ // NB use API-independent projection matrix since GPU programs
349
+ // bypass the API-specific handedness and use right-handed coords
350
+ if (mCurrentRenderable && mCurrentRenderable ->getUseIdentityProjection ())
351
+ {
352
+ // Use identity projection matrix, still need to take RS depth into account.
353
+ RenderSystem* rs = Root::getSingleton ().getRenderSystem ();
354
+ rs->_convertProjectionMatrix (Matrix4::IDENTITY, proj, true );
355
+ }
356
+ else
357
+ {
358
+ proj = mCurrentCamera ->getProjectionMatrixWithRSDepth ();
359
+ }
360
+
361
+ if (mCurrentRenderTarget && mCurrentRenderTarget ->requiresTextureFlipping ())
362
+ {
363
+ // Because we're not using setProjectionMatrix, this needs to be done here
364
+ // Invert transformed y
365
+ proj[1 ][0 ] = -proj[1 ][0 ];
366
+ proj[1 ][1 ] = -proj[1 ][1 ];
367
+ proj[1 ][2 ] = -proj[1 ][2 ];
368
+ proj[1 ][3 ] = -proj[1 ][3 ];
369
+ }
370
+
371
+ return proj;
372
+ }
339
373
const Matrix4& AutoParamDataSource::getProjectionMatrix (void ) const
340
374
{
341
375
if (mProjMatrixDirty )
342
376
{
343
- // NB use API-independent projection matrix since GPU programs
344
- // bypass the API-specific handedness and use right-handed coords
345
- if (mCurrentRenderable && mCurrentRenderable ->getUseIdentityProjection ())
346
- {
347
- // Use identity projection matrix, still need to take RS depth into account.
348
- RenderSystem* rs = Root::getSingleton ().getRenderSystem ();
349
- rs->_convertProjectionMatrix (Matrix4::IDENTITY, mProjectionMatrix , true );
350
- }
351
- else
352
- {
353
- mProjectionMatrix = mCurrentCamera ->getProjectionMatrixWithRSDepth ();
354
- }
355
- if (mCurrentRenderTarget && mCurrentRenderTarget ->requiresTextureFlipping ())
356
- {
357
- // Because we're not using setProjectionMatrix, this needs to be done here
358
- // Invert transformed y
359
- mProjectionMatrix [1 ][0 ] = -mProjectionMatrix [1 ][0 ];
360
- mProjectionMatrix [1 ][1 ] = -mProjectionMatrix [1 ][1 ];
361
- mProjectionMatrix [1 ][2 ] = -mProjectionMatrix [1 ][2 ];
362
- mProjectionMatrix [1 ][3 ] = -mProjectionMatrix [1 ][3 ];
363
- }
377
+ mProjectionMatrix = getProjectionMatrix (mCurrentCamera );
364
378
mProjMatrixDirty = false ;
365
379
}
366
380
return mProjectionMatrix ;
0 commit comments