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

Method SetupTransformsForPicking

trinity/Tr2PrimitiveScene.cpp:152–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152void 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
184void Tr2PrimitiveScene::SetupPerFrameData( Tr2RenderContext& renderContext )
185{

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