void AEyeXPlayerController::GetEyeXActorsSortedByDistance(TArray<AEyeXActorBase*>& EyeXActorsOut) const
{
	UWorld* World = GetWorld();
	const float Time = World->GetTimeSeconds() - World->GetDeltaSeconds() - 0.1f; // Allow render time to be at least one frame behind.
	const float MaxDistanceSquared = MaxDistance * MaxDistance;
	FEyeXUtils::ActorDistanceComparer Comparer(PlayerCameraManager);
	for (TActorIterator<AEyeXActorBase> ActorItr(World); ActorItr; ++ActorItr)
	{
		if (ActorItr->GetLastRenderTime() < Time) // Ignore if the actor is not rendered to the screen
			continue;

		if (Comparer.DistanceSquaredToCamera(*ActorItr) > MaxDistanceSquared) // Ignore if further away than max distance
			continue;

		if (!FEyeXUtils::ActorBlocksOnChannel(*ActorItr, CollisionChannels)) // Ignore actors that aren't blocking any of the channels
			continue;

		EyeXActorsOut.Add(*ActorItr);
	}

	EyeXActorsOut.Sort(Comparer);
}
void SimpleCounter::requestShutdown() {
  Lock lock(s_outputMutex);
  for (CounterMap::const_iterator it = m_counters.begin();
       it != m_counters.end(); ++it) {
    fprintf(stderr, "====================\n");
    fprintf(stderr, "%s : %d\n", it->first.c_str(), it->second);
    if (SampleStackCount > 0) {
      CounterMap cm;
      vector<string> &stackVec = m_stacks[it->first];
      for (size_t i = 0; i < stackVec.size(); i++) {
        cm[stackVec[i]]++;
      }
      vector<string> unique;
      for (CounterMap::const_iterator jt = cm.begin(); jt != cm.end(); ++jt) {
        unique.push_back(jt->first);
      }
      sort(unique.begin(), unique.end(), Comparer(cm));
      for (size_t i = 0; i < unique.size(); i++) {
        fprintf(stderr, "Stack #%d: %d/%d\n",
                (int)(i + 1), cm[unique[i]], (int)stackVec.size());
        StackTrace st(unique[i]);
        fprintf(stderr, "%s", st.toString().c_str());
      }
    }
  }
}
Beispiel #3
0
std::list<Scientist> ScientistRepository::list(std::string col, std::string mod) {
    std::list<Scientist> outList = std::list<Scientist>();
    outList = deepCopy();
    Comparer comp = Comparer(col,mod);
    outList.sort(comp);
    return outList;
}
AEyeXActorBase* AEyeXPlayerController::FindByBoxedLineTrace(FHitResult& OutHit, const FSceneView* const View, const FVector2D& GazePoint,
	const FCollisionObjectQueryParams& ObjectParams, const FCollisionQueryParams& TraceParams)
{
	UWorld* World = GetWorld();
	if (!World) return nullptr;

	// Set up a box around the gaze point
	FVector2D Corners[4];
	GetBoxCorners(GazePoint, BoxSize * GetApproximatePixelsPerMillimeter(), Corners);

	// First check center point
	AEyeXActorBase* EyeXActor = nullptr;
	FVector Start, End;
	FEyeXUtils::GetStartAndEndOfLineTrace(View, MaxDistance, GazePoint, /*out*/ Start, /*out*/ End);
	if (World->LineTraceSingleByObjectType(OutHit, Start, End, ObjectParams, TraceParams))
	{
		EyeXActor = Cast<AEyeXActorBase>(OutHit.GetActor());
	}
	else
	{
		// If center point missed we perform traces in a box around the gaze point
		// and choose the closest EyeXActor hit by the traces
		TArray<AEyeXActorBase*> EyeXActors;
		for (int i = 0; i < 4; ++i)
		{
			FVector BoxStart, BoxEnd;
			FEyeXUtils::GetStartAndEndOfLineTrace(View, MaxDistance, Corners[i], /*out*/ BoxStart, /*out*/ BoxEnd);
			if (World->LineTraceSingleByObjectType(OutHit, BoxStart, BoxEnd, ObjectParams, TraceParams))
			{
				AEyeXActorBase* Actor = Cast<AEyeXActorBase>(OutHit.GetActor());
				if (!Actor) continue;
				EyeXActors.Add(Actor);
			}

			VisualizeHitTestPoint(bVisualizeDetection, World, BoxStart);
		}

		if (EyeXActors.Num() > 0)
		{
			FEyeXUtils::ActorDistanceComparer Comparer(PlayerCameraManager);
			EyeXActors.Sort(Comparer);
			EyeXActor = EyeXActors[0];
		}
	}

	VisualizeHit(bVisualizeDetection, World, OutHit);
	VisualizeGazePoint(bVisualizeDetection, World, Start);

	return EyeXActor;
}
	FORCEINLINE bool operator()( const TSharedRef< IPropertyTableRow >& Lhs, const TSharedRef< IPropertyTableRow >& Rhs ) const
	{
		return !Comparer( Lhs, Rhs );
	}