// NOTE: An overload of this method with a similar signature exists! wxPoint MapTerrainT::TraceRay(const Vector3fT& Source, const Vector3fT& Direction) const { VB_Trace3T<double> TraceResult(1.0); m_Terrain.TraceBoundingBox(BoundingBox3T<double>(Vector3dT(), Vector3dT()), Source.AsVectorOfDouble(), Direction.AsVectorOfDouble(), TraceResult); if (TraceResult.Fraction==1.0) return wxPoint(-1, -1); Vector3fT HitPos(Source+Direction*TraceResult.Fraction); float TerrainXLength=m_TerrainBounds.Max.x-m_TerrainBounds.Min.x; float TerrainYLength=m_TerrainBounds.Max.y-m_TerrainBounds.Min.y; Vector3fT HitPosRelative(HitPos.x-m_TerrainBounds.Min.x, HitPos.y-m_TerrainBounds.Min.y, 0.0f); wxPoint HeightDataPos(Round(HitPosRelative.x/float(TerrainXLength)*float(m_Resolution-1)), Round(HitPosRelative.y/float(TerrainYLength)*float(m_Resolution-1))); // Flip tools y position. HeightDataPos.y=m_Resolution-1-HeightDataPos.y; // If height data position lies outside height data boundaries return undefined position. if (HeightDataPos.x<0 || HeightDataPos.y<0 || (unsigned long)HeightDataPos.x>m_Resolution-1 || (unsigned long)HeightDataPos.y>m_Resolution-1) return wxPoint(-1, -1); return HeightDataPos; }
AMapTile * AMapPlayerController::GetTileUnderCursor() { AMapTile * tile = NULL; FHitResult TraceResult(ForceInit); GetHitResultUnderCursorByChannel(UEngineTypes::ConvertToTraceType(COLLISION_MAP_TILE), false, TraceResult); if (TraceResult.GetActor() != NULL) { if (Cast<AMapTile>(TraceResult.GetActor())) { tile = Cast<AMapTile>(TraceResult.GetActor()); } if (Cast<AMapBasicEntity>(TraceResult.GetActor())) { tile = Cast<AMapBasicEntity>(TraceResult.GetActor())->AssignedTiles[0]; } } return tile; }
TArray<AMapBasicEntity*> AMapPlayerController::GetEntitiesInTrace() { TArray<AMapBasicEntity*> R; FHitResult TraceResult(ForceInit); GetHitResultUnderCursorByChannel(UEngineTypes::ConvertToTraceType(ECC_Pawn), false, TraceResult); if (TraceResult.GetActor() != nullptr) { if (Cast<AMapBasicEntity>(TraceResult.GetActor()) != NULL) { R.Add(Cast<AMapBasicEntity>(TraceResult.GetActor())); } if (Cast<AMapTile>(TraceResult.GetActor())) { R.Append(Cast<AMapTile>(TraceResult.GetActor())->AssignedEntity); } } return R; }