Advertisement
Guest User

Untitled

a guest
Sep 8th, 2016
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. void CPlayer::RaycastView()
  2. {
  3.     int hit = 0;
  4.     Vec3 origin = m_pView->GetViewWorldPosition();
  5.     Vec3 dir = m_pView->GetViewWorldDirection();
  6.     ray_hit rayHit;
  7.  
  8.     const int physSkipNum = 1;
  9.     IPhysicalEntity* physSkip[physSkipNum];
  10.     physSkip[0] = GetEntity()->GetPhysics();
  11.     unsigned int flags = rwi_stop_at_pierceable | rwi_colltype_any | rwi_ignore_back_faces;
  12.  
  13.     float RayMaxDistance = 100.0f;
  14.  
  15.     hit = gEnv->pPhysicalWorld->RayWorldIntersection(origin, dir*RayMaxDistance, entity_query_flags::ent_all, flags, &rayHit, 1, physSkip, physSkipNum);
  16.     if (hit)
  17.     {
  18.         IPersistantDebug* debug = gEnv->pGame->GetIGameFramework()->GetIPersistantDebug();
  19.         debug->Begin("TestAddDirection", false);
  20.  
  21.         Vec3 lineStart = origin;
  22.         Vec3 lineEnd = rayHit.pt;
  23.         float timeOut = 4.0f;
  24.  
  25.         debug->AddLine(lineStart, lineEnd, ColorF(1.0f, 0.0f, 0.0f), timeOut);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement