| 150 | } |
| 151 | |
| 152 | void Tr2PrimitiveScene::SetupTransformsForPicking( float fx, float fy, TriProjection* proj, TriView* view, TriViewport* viewport ) |
| 153 | { |
| 154 | Tr2Renderer::SetViewTransform( view->GetTransform() ); |
| 155 | proj->SetProjection(); |
| 156 | |
| 157 | |
| 158 | if( Tr2Renderer::GetCurrentProjectionType() == PT_ORTHOGONAL ) |
| 159 | { |
| 160 | fx *= ( Tr2Renderer::GetOrthoWidth() / 2.0f ); |
| 161 | fy *= ( Tr2Renderer::GetOrthoHeight() / 2.0f ); |
| 162 | float metersPerPixel = ( Tr2Renderer::GetOrthoWidth() / viewport->width ) / 2.0f; |
| 163 | Tr2Renderer::SetOrthoProjection( fx - metersPerPixel, |
| 164 | fx + metersPerPixel, |
| 165 | fy - metersPerPixel, |
| 166 | fy + metersPerPixel, |
| 167 | Tr2Renderer::GetFrontClip(), |
| 168 | Tr2Renderer::GetBackClip() ); |
| 169 | } |
| 170 | else |
| 171 | { |
| 172 | // |
| 173 | // Projection is set up to scale the image such that the viewport is covered by one pixel. |
| 174 | Vector2 scaling( float( viewport->width ), float( viewport->height ) ); |
| 175 | // translate the projection so that we center around the pick ray origin, |
| 176 | // while remembering to scale this value as well: |
| 177 | Vector2 translation; |
| 178 | translation.x = -fx * scaling.x; |
| 179 | translation.y = -fy * scaling.y; |
| 180 | Tr2Renderer::AdjustProjection( scaling, translation ); |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | void Tr2PrimitiveScene::SetupPerFrameData( Tr2RenderContext& renderContext ) |
| 185 | { |
nothing calls this directly
no test coverage detected