MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / project

Method project

physx/samples/samplebase/Picking.cpp:265–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263//----------------------------------------------------------------------------//
264
265void Picking::project(const physx::PxVec3& v, int& xi, int& yi, float& depth) const
266{
267 SampleRenderer::Renderer* renderer = mFrame.getRenderer();
268 SampleRenderer::RendererProjection projection = mFrame.getCamera().getProjMatrix();
269 const PxTransform view = mFrame.getCamera().getViewMatrix().getInverse();
270
271 PxVec3 pos = SampleRenderer::project(projection, view, v);
272 ///* Map x, y and z to range 0-1 */
273 pos.x = (pos.x + 1 ) * 0.5f;
274 pos.y = (pos.y + 1 ) * 0.5f;
275 pos.z = (pos.z + 1 ) * 0.5f;
276
277 PxU32 windowWidth = 0;
278 PxU32 windowHeight = 0;
279 renderer->getWindowSize(windowWidth, windowHeight);
280
281 /* Map x,y to viewport */
282 pos.x *= windowWidth;
283 pos.y *= windowHeight;
284
285 depth = (float)pos.z;
286
287 xi = (int)(pos.x + 0.5);
288 yi = (int)(pos.y + 0.5);
289}

Callers 1

outputPlaneToStreamFunction · 0.45

Calls 5

projectFunction · 0.85
getRendererMethod · 0.80
getCameraMethod · 0.45
getInverseMethod · 0.45
getWindowSizeMethod · 0.45

Tested by

no test coverage detected