MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / GetViewIntersection

Method GetViewIntersection

CryGame/ScriptObjectPlayer.cpp:432–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432int CScriptObjectPlayer::GetViewIntersection(IFunctionHandler *pH)
433{
434 CHECK_PARAMETERS(0);
435 IEntityCamera *pCam=m_pPlayer->GetEntity()->GetCamera();
436 if (!pCam)
437 return pH->EndFunctionNull();
438 float fMaxDist=m_pPlayer->GetGame()->GetSystem()->GetI3DEngine()->GetMaxViewDist(); //pCam->GetCamera().GetZMax();
439
440 Vec3 pos,angle;
441
442 if (m_pPlayer->GetVehicle())
443 {
444 pos=pCam->GetPos();
445 angle=pCam->GetAngles();
446 }
447 else
448 {
449 //we must always take leaning into account!
450 angle = m_pPlayer->m_vEyeAngles+m_pPlayer->m_vShake;
451 pos = m_pPlayer->m_vEyePos;
452 }
453
454 // [Kirill]- do here same calculations as when finding fireAngles in int CWeaponClass::Fire
455 //------------------------------------------------------------------------------------------------
456 // Marco's change to take leaning into account:
457 // transform the weapons angles using the same as the camera matrix
458 // create a vector pointing down the z-axis
459 //------------------------------------------------------------------------------------------------
460 Vec3d dir(0,-1,0);
461 Matrix44 tm = Matrix44::CreateRotationZYX(-angle*gf_DEGTORAD); //NOTE: angles in radians and negated
462 dir = GetTransposed44(tm)*(dir);
463
464// dir=ConvertToRadAngles(dir);
465 dir*=fMaxDist;
466 ray_hit hit;
467 float fDist=-1.0;
468 if (m_pPlayer->GetGame()->GetSystem()->GetIPhysicalWorld()->RayWorldIntersection(vectorf(pos), vectorf(dir), ent_all,
469 13/*pirceability*/, &hit,1, m_pPlayer->GetEntity()->GetPhysics()))
470 {
471 vectorf vecRay=vectorf(pos)-hit.pt;
472 fDist=vecRay.len();
473 IEntityCamera *pEC=m_pPlayer->GetEntity()->GetCamera();
474 CCamera cam=pEC->GetCamera();
475 Vec3 vAngles=cam.GetAngles();
476
477 //m_pTempAng->BeginSetGetChain();
478 //m_pTempAng->SetValueChain("x",vAngles.x);
479 //m_pTempAng->SetValueChain("y",vAngles.y);
480 //m_pTempAng->SetValueChain("z",vAngles.z);
481 //m_pTempAng->EndSetGetChain();
482 //////////////////////////////////////////
483 m_pTempObj->BeginSetGetChain();
484 m_pTempObj->SetValueChain("x",hit.pt.x);
485 m_pTempObj->SetValueChain("y",hit.pt.y);
486 m_pTempObj->SetValueChain("z",hit.pt.z);
487 m_pTempObj->SetValueChain("angles",m_pTempAng);
488 m_pTempObj->SetValueChain("len",fDist);
489

Callers

nothing calls this directly

Calls 15

GetCameraMethod · 0.80
EndFunctionNullMethod · 0.80
GetI3DEngineMethod · 0.80
GetIPhysicalWorldMethod · 0.80
BeginSetGetChainMethod · 0.80
SetValueChainMethod · 0.80
SetToNullChainMethod · 0.80
EndSetGetChainMethod · 0.80
EndFunctionMethod · 0.80
GetEntityMethod · 0.45
GetMaxViewDistMethod · 0.45
GetSystemMethod · 0.45

Tested by

no test coverage detected