MCPcopy Create free account
hub / github.com/carbonengine/trinity / SetupTransformsForPicking

Method SetupTransformsForPicking

trinity/Interior/Tr2InteriorScene.cpp:1172–1203  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1170
1171// ------------------------------------------------------------------------------------------------------
1172void Tr2InteriorScene::SetupTransformsForPicking( float fx, float fy, TriProjection* proj, TriView* view, TriViewport* viewport )
1173{
1174 USE_MAIN_THREAD_RENDER_CONTEXT();
1175
1176 Tr2Renderer::SetViewTransform( view->GetTransform() );
1177 proj->SetProjection();
1178
1179 if( Tr2Renderer::GetCurrentProjectionType() == PT_ORTHOGONAL )
1180 {
1181 fx *= ( Tr2Renderer::GetOrthoWidth() / 2.0f );
1182 fy *= ( Tr2Renderer::GetOrthoHeight() / 2.0f );
1183 float metersPerPixel = ( Tr2Renderer::GetOrthoWidth() / viewport->width ) / 2.0f;
1184 Tr2Renderer::SetOrthoProjection( fx - metersPerPixel,
1185 fx + metersPerPixel,
1186 fy - metersPerPixel,
1187 fy + metersPerPixel,
1188 Tr2Renderer::GetFrontClip(),
1189 Tr2Renderer::GetBackClip() );
1190 }
1191 else
1192 {
1193 //
1194 // Projection is set up to scale the image such that the viewport is covered by one pixel.
1195 Vector2 scaling( float( viewport->width ), float( viewport->height ) );
1196 // translate the projection so that we center around the pick ray origin,
1197 // while remembering to scale this value as well:
1198 Vector2 translation;
1199 translation.x = -fx * scaling.x;
1200 translation.y = -fy * scaling.y;
1201 Tr2Renderer::AdjustProjection( scaling, translation );
1202 }
1203}
1204
1205const std::vector<ITr2Renderable*>& Tr2InteriorScene::GetPickingObjectsToRender( const Vector3& dirWorld )
1206{

Callers

nothing calls this directly

Calls 5

SetViewTransformFunction · 0.85
GetFrontClipFunction · 0.85
GetBackClipFunction · 0.85
GetTransformMethod · 0.45
SetProjectionMethod · 0.45

Tested by

no test coverage detected