MCPcopy Create free account
hub / github.com/baldurk/renderdoc / PickVertex

Method PickVertex

renderdoc/driver/gl/gl_debug.cpp:2478–3030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2476}
2477
2478uint32_t GLReplay::PickVertex(uint32_t eventId, int32_t width, int32_t height,
2479 const MeshDisplay &cfg, uint32_t x, uint32_t y)
2480{
2481 WrappedOpenGL &drv = *m_pDriver;
2482
2483 if(!HasExt[ARB_compute_shader] || !HasExt[ARB_shading_language_420pack])
2484 return ~0U;
2485
2486 MakeCurrentReplayContext(m_DebugCtx);
2487
2488 drv.glUseProgram(DebugData.meshPickProgram);
2489
2490 float nearPlane = cfg.cam ? ((Camera *)cfg.cam)->GetNear() : 0.1f;
2491 float farPlane = cfg.cam ? ((Camera *)cfg.cam)->GetFar() : 100000.0f;
2492
2493 Matrix4f projMat = Matrix4f::Perspective(90.0f, nearPlane, farPlane, float(width) / float(height));
2494
2495 Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity();
2496 Matrix4f pickMVP = projMat.Mul(camMat);
2497 if(!cfg.position.unproject)
2498 {
2499 pickMVP = pickMVP.Mul(Matrix4f(cfg.axisMapping));
2500 }
2501
2502 bool reverseProjection = false;
2503 Matrix4f guessProj;
2504 Matrix4f guessProjInverse;
2505 if(cfg.position.unproject)
2506 {
2507 // the derivation of the projection matrix might not be right (hell, it could be an
2508 // orthographic projection). But it'll be close enough likely.
2509 if(cfg.position.farPlane != FLT_MAX)
2510 {
2511 guessProj =
2512 Matrix4f::Perspective(cfg.fov, cfg.position.nearPlane, cfg.position.farPlane, cfg.aspect);
2513 }
2514 else
2515 {
2516 reverseProjection = true;
2517 guessProj = Matrix4f::ReversePerspective(cfg.fov, cfg.position.nearPlane, cfg.aspect);
2518 }
2519
2520 if(cfg.ortho)
2521 guessProj = Matrix4f::Orthographic(cfg.position.nearPlane, cfg.position.farPlane);
2522
2523 if(cfg.position.flipY)
2524 guessProj[5] *= -1.0f;
2525
2526 guessProjInverse = guessProj.Inverse();
2527 }
2528
2529 Vec3f rayPos;
2530 Vec3f rayDir;
2531 // convert mouse pos to world space ray
2532 {
2533 float pickX = ((float)x) / ((float)width);
2534 float pickXCanonical = RDCLERP(-1.0f, 1.0f, pickX);
2535

Callers 2

render_clickedMethod · 0.45
check_vertexMethod · 0.45

Calls 15

IdentityFunction · 0.85
RDCLERPFunction · 0.85
RDCMINFunction · 0.85
RDCMAXFunction · 0.85
GetNearMethod · 0.80
GetFarMethod · 0.80
MulMethod · 0.80
InverseMethod · 0.80
TransformMethod · 0.80
glNamedBufferDataEXTMethod · 0.80
glMapNamedBufferEXTMethod · 0.80

Tested by

no test coverage detected