MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / CheckForPicking

Method CheckForPicking

src/Renderer/Renderer.cpp:248–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248Entity *Renderer::CheckForPicking(glm::mat4 ViewMatrix, glm::mat4 ProjectionMatrix, bool *entity_targeted) {
249 glm::vec3 out_origin;
250 glm::vec3 out_direction;
251 ScreenPosToWorldRay(Config::get().resX / 2, Config::get().resY / 2, Config::get().resX, Config::get().resY, ViewMatrix, ProjectionMatrix, out_origin, out_direction);
252 glm::vec3 out_end = out_origin + out_direction * 1000.0f;
253 btCollisionWorld::ClosestRayResultCallback RayCallback(btVector3(out_origin.x, out_origin.y, out_origin.z),
254 btVector3(out_end.x, out_end.y, out_end.z));
255 RayCallback.m_collisionFilterMask = COL_CAR | COL_TRACK;
256 physicsEngine.getDynamicsWorld()->rayTest(btVector3(out_origin.x, out_origin.y, out_origin.z),
257 btVector3(out_end.x, out_end.y, out_end.z), RayCallback);
258 if (RayCallback.hasHit()) {
259 *entity_targeted = true;
260 return static_cast<Entity *>(RayCallback.m_collisionObject->getUserPointer());
261 } else {
262 *entity_targeted = false;
263 return nullptr;
264 }
265}
266
267void Renderer::InitialiseIMGUI() {
268 /*------- ImGui -------*/

Callers

nothing calls this directly

Calls 2

ScreenPosToWorldRayFunction · 0.85
getDynamicsWorldMethod · 0.80

Tested by

no test coverage detected