当前位置: 首页>>代码示例>>C++>>正文


C++ Segment::Intersects方法代码示例

本文整理汇总了C++中Segment::Intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ Segment::Intersects方法的具体用法?C++ Segment::Intersects怎么用?C++ Segment::Intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Segment的用法示例。


在下文中一共展示了Segment::Intersects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TraceMesh

bool MeshCompiler::TraceMesh( const Segment& s )
{
	if( m_RawTris.Size() )
	{
		if( s.Intersects( m_AABB ) )
		{
			for( uint j = 0; j < m_RawTris.Size(); ++j )
			{
				if(	s.Intersects( m_RawTris[j] ) ||
					( m_TraceTriangleBacks && s.Intersects( m_RawTris[j].GetFlipped() ) ) )
				{
					return true;
				}
			}
		}
	}
	return false;
}
开发者ID:MinorKeyGames,项目名称:Eldritch,代码行数:18,代码来源:meshcompiler.cpp

示例2: Intersects

bool AABB::Intersects(const Segment& s) const { return s.Intersects(*this); }
开发者ID:ptitSeb,项目名称:Eldritch,代码行数:1,代码来源:aabb.cpp

示例3: Intersects

bool Plane::Intersects(const Segment& s,
                       CollisionInfo* const pInfo /*= NULL*/) const {
  return s.Intersects(*this, pInfo);
}
开发者ID:ptitSeb,项目名称:Eldritch,代码行数:4,代码来源:plane.cpp

示例4: FindTargetFrobbable

WBEntity* WBCompEldFrobber::FindTargetFrobbable() const {
  if (m_FrobDisabled) {
    return nullptr;
  }

  InputSystem* const pInputSystem = GetFramework()->GetInputSystem();
  STATIC_HASHED_STRING(Frob);
  if (pInputSystem->IsSuppressed(sFrob)) {
    return nullptr;
  }

  const Array<WBCompEldFrobbable*>* const pFrobbablesArrays =
      WBComponentArrays::GetComponents<WBCompEldFrobbable>();
  if (!pFrobbablesArrays) {
    return nullptr;
  }

  WBEntity* const pEntity = GetEntity();
  DEVASSERT(pEntity);

  WBCompEldTransform* const pTransform =
      pEntity->GetTransformComponent<WBCompEldTransform>();
  DEVASSERT(pTransform);

  WBCompEldCamera* const pCamera = GET_WBCOMP(pEntity, EldCamera);

  const Vector StartOffset =
      pCamera ? pCamera->GetViewTranslationOffset(WBCompEldCamera::EVM_All)
              : Vector();
  const Vector StartLocation = pTransform->GetLocation() + StartOffset;
  const Vector Direction = pTransform->GetOrientation().ToVector();
  const Vector EndLocation = StartLocation + Direction * m_FrobDistance;
  const Segment FrobTraceSegment = Segment(StartLocation, EndLocation);

  // First, trace against world and collidables as a baseline for our trace
  // distance.
  CollisionInfo CollidableInfo;
  CollidableInfo.m_CollideWorld = true;
  CollidableInfo.m_CollideEntities = true;
  CollidableInfo.m_UserFlags = EECF_EntityCollision;

  GetWorld()->Trace(FrobTraceSegment, CollidableInfo);
  const float CollidableT = CollidableInfo.m_HitT;

  const Array<WBCompEldFrobbable*>& Frobbables = *pFrobbablesArrays;

  WBEntity* pNearestEntity = nullptr;
  float NearestT = 0.0f;

  const uint NumFrobbables = Frobbables.Size();
  for (uint FrobbableIndex = 0; FrobbableIndex < NumFrobbables;
       ++FrobbableIndex) {
    WBCompEldFrobbable* const pFrobbable = Frobbables[FrobbableIndex];
    ASSERT(pFrobbable);

    if (!pFrobbable->IsFrobbable()) {
      continue;
    }

    WBEntity* const pFrobbableEntity = pFrobbable->GetEntity();
    ASSERT(pFrobbableEntity);

    if (pFrobbableEntity->IsDestroyed()) {
      continue;
    }

    const AABB FrobbableBox = pFrobbable->GetBound();

    CollisionInfo Info;
    if (FrobTraceSegment.Intersects(FrobbableBox, &Info)) {
      if (Info.m_HitT <=
          CollidableT)  // Check if trace was blocked by some collision
      {
        if (Info.m_HitT < NearestT || pNearestEntity == nullptr) {
          pNearestEntity = pFrobbableEntity;
          NearestT = Info.m_HitT;
        }
      }
    }
  }

  return pNearestEntity;
}
开发者ID:ptitSeb,项目名称:Eldritch,代码行数:83,代码来源:wbcompeldfrobber.cpp


注:本文中的Segment::Intersects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。