本文整理汇总了C++中FVector类的典型用法代码示例。如果您正苦于以下问题:C++ FVector类的具体用法?C++ FVector怎么用?C++ FVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
void FAnimNode_Trail::EvaluateBoneTransforms(USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases, TArray<FBoneTransform>& OutBoneTransforms)
{
check(OutBoneTransforms.Num() == 0);
if( ChainLength < 2 )
{
return;
}
// The incoming BoneIndex is the 'end' of the spline chain. We need to find the 'start' by walking SplineLength bones up hierarchy.
// Fail if we walk past the root bone.
const FBoneContainer& BoneContainer = MeshBases.GetPose().GetBoneContainer();
FCompactPoseBoneIndex WalkBoneIndex = TrailBone.GetCompactPoseIndex(BoneContainer);
TArray<FCompactPoseBoneIndex> ChainBoneIndices;
ChainBoneIndices.AddZeroed(ChainLength);
ChainBoneIndices[ChainLength - 1] = WalkBoneIndex;
for (int32 i = 1; i < ChainLength; i++)
{
// returns to avoid a crash
// @TODO : shows an error message why failed
if (WalkBoneIndex == 0)
{
return;
}
// Get parent bone.
WalkBoneIndex = BoneContainer.GetParentBoneIndex(WalkBoneIndex);
//Insert indices at the start of array, so that parents are before children in the array.
int32 TransformIndex = ChainLength - (i + 1);
ChainBoneIndices[TransformIndex] = WalkBoneIndex;
}
OutBoneTransforms.AddZeroed(ChainLength);
// If we have >0 this frame, but didn't last time, record positions of all the bones.
// Also do this if number has changed or array is zero.
bool bHasValidStrength = (Alpha > 0.f);
if(TrailBoneLocations.Num() != ChainLength || (bHasValidStrength && !bHadValidStrength))
{
TrailBoneLocations.Empty();
TrailBoneLocations.AddZeroed(ChainLength);
for(int32 i=0; i<ChainBoneIndices.Num(); i++)
{
FCompactPoseBoneIndex ChildIndex = ChainBoneIndices[i];
const FTransform& ChainTransform = MeshBases.GetComponentSpaceTransform(ChildIndex);
TrailBoneLocations[i] = ChainTransform.GetTranslation();
}
OldLocalToWorld = SkelComp->GetTransformMatrix();
}
bHadValidStrength = bHasValidStrength;
// transform between last frame and now.
FMatrix OldToNewTM = OldLocalToWorld * SkelComp->GetTransformMatrix().InverseFast();
// Add fake velocity if present to all but root bone
if(!FakeVelocity.IsZero())
{
FVector FakeMovement = -FakeVelocity * ThisTimstep;
if (bActorSpaceFakeVel && SkelComp->GetOwner())
{
const FTransform BoneToWorld(SkelComp->GetOwner()->GetActorQuat(), SkelComp->GetOwner()->GetActorLocation());
FakeMovement = BoneToWorld.TransformVector(FakeMovement);
}
FakeMovement = SkelComp->GetTransformMatrix().InverseTransformVector(FakeMovement);
// Then add to each bone
for(int32 i=1; i<TrailBoneLocations.Num(); i++)
{
TrailBoneLocations[i] += FakeMovement;
}
}
// Root bone of trail is not modified.
FCompactPoseBoneIndex RootIndex = ChainBoneIndices[0];
const FTransform& ChainTransform = MeshBases.GetComponentSpaceTransform(RootIndex);
OutBoneTransforms[0] = FBoneTransform(RootIndex, ChainTransform);
TrailBoneLocations[0] = ChainTransform.GetTranslation();
// Starting one below head of chain, move bones.
for(int32 i=1; i<ChainBoneIndices.Num(); i++)
{
// Parent bone position in component space.
FCompactPoseBoneIndex ParentIndex = ChainBoneIndices[i - 1];
FVector ParentPos = TrailBoneLocations[i-1];
FVector ParentAnimPos = MeshBases.GetComponentSpaceTransform(ParentIndex).GetTranslation();
// Child bone position in component space.
FCompactPoseBoneIndex ChildIndex = ChainBoneIndices[i];
FVector ChildPos = OldToNewTM.TransformPosition(TrailBoneLocations[i]); // move from 'last frames component' frame to 'this frames component' frame
FVector ChildAnimPos = MeshBases.GetComponentSpaceTransform(ChildIndex).GetTranslation();
// Desired parent->child offset.
FVector TargetDelta = (ChildAnimPos - ParentAnimPos);
//.........这里部分代码省略.........
示例2: GridSnap
FVector UTKMathFunctionLibrary::GridSnap(FVector A, float Grid)
{
return A.GridSnap(Grid);
}
示例3: direction
FVector ABxtAsteroidSpawner::GetRandomSpawnDirection() const
{
const FVector direction(-1.0f, 0.0, 0.0f);
const float angle = FMath::FRandRange(-45.0f, 45.0f);
return direction.RotateAngleAxis(angle, FVector(0.0f, 0.0f, 1.0f));
}
示例4: PrintString
void AGameplayDebuggingHUDComponent::DrawEQSData(APlayerController* PC, class UGameplayDebuggingComponent *DebugComponent)
{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) && WITH_EQS
PrintString(DefaultContext, TEXT("\n{green}EQS {white}[Use + key to switch query]\n"));
if (DebugComponent->EQSLocalData.Num() == 0)
{
return;
}
const int32 EQSIndex = DebugComponent->EQSLocalData.Num() > 0 ? FMath::Clamp(DebugComponent->CurrentEQSIndex, 0, DebugComponent->EQSLocalData.Num() - 1) : INDEX_NONE;
if (!DebugComponent->EQSLocalData.IsValidIndex(EQSIndex))
{
return;
}
{
int32 Index = 0;
PrintString(DefaultContext, TEXT("{white}Queries: "));
for (auto CurrentQuery : DebugComponent->EQSLocalData)
{
if (EQSIndex == Index)
{
PrintString(DefaultContext, FString::Printf(TEXT("{green}%s, "), *CurrentQuery.Name));
}
else
{
PrintString(DefaultContext, FString::Printf(TEXT("{yellow}%s, "), *CurrentQuery.Name));
}
Index++;
}
PrintString(DefaultContext, TEXT("\n"));
}
auto& CurrentLocalData = DebugComponent->EQSLocalData[EQSIndex];
/** find and draw item selection */
int32 BestItemIndex = INDEX_NONE;
{
APlayerController* const MyPC = Cast<APlayerController>(PlayerOwner);
FVector CamLocation;
FVector FireDir;
if (!MyPC->GetSpectatorPawn())
{
FRotator CamRotation;
MyPC->GetPlayerViewPoint(CamLocation, CamRotation);
FireDir = CamRotation.Vector();
}
else
{
FireDir = DefaultContext.Canvas->SceneView->GetViewDirection();
CamLocation = DefaultContext.Canvas->SceneView->ViewMatrices.ViewOrigin;
}
float bestAim = 0;
for (int32 Index = 0; Index < CurrentLocalData.RenderDebugHelpers.Num(); ++Index)
{
auto& CurrentItem = CurrentLocalData.RenderDebugHelpers[Index];
const FVector AimDir = CurrentItem.Location - CamLocation;
float FireDist = AimDir.SizeSquared();
FireDist = FMath::Sqrt(FireDist);
float newAim = FireDir | AimDir;
newAim = newAim / FireDist;
if (newAim > bestAim)
{
BestItemIndex = Index;
bestAim = newAim;
}
}
if (BestItemIndex != INDEX_NONE)
{
DrawDebugSphere(World, CurrentLocalData.RenderDebugHelpers[BestItemIndex].Location, CurrentLocalData.RenderDebugHelpers[BestItemIndex].Radius, 8, FColor::Red, false);
int32 FailedTestIndex = CurrentLocalData.RenderDebugHelpers[BestItemIndex].FailedTestIndex;
if (FailedTestIndex != INDEX_NONE)
{
PrintString(DefaultContext, FString::Printf(TEXT("{red}Selected item failed with test %d: {yellow}%s {LightBlue}(%s)\n")
, FailedTestIndex
, *CurrentLocalData.Tests[FailedTestIndex].ShortName
, *CurrentLocalData.Tests[FailedTestIndex].Detailed
));
PrintString(DefaultContext, FString::Printf(TEXT("{white}'%s' with score %3.3f\n\n"), *CurrentLocalData.RenderDebugHelpers[BestItemIndex].AdditionalInformation, CurrentLocalData.RenderDebugHelpers[BestItemIndex].FailedScore));
}
}
}
PrintString(DefaultContext, FString::Printf(TEXT("{white}Timestamp: {yellow}%.3f (%.2fs ago)\n")
, CurrentLocalData.Timestamp, PC->GetWorld()->GetTimeSeconds() - CurrentLocalData.Timestamp
));
PrintString(DefaultContext, FString::Printf(TEXT("{white}Query ID: {yellow}%d\n")
, CurrentLocalData.Id
));
PrintString(DefaultContext, FString::Printf(TEXT("{white}Query contains %d options: "), CurrentLocalData.Options.Num()));
for (int32 OptionIndex = 0; OptionIndex < CurrentLocalData.Options.Num(); ++OptionIndex)
{
if (OptionIndex == CurrentLocalData.UsedOption)
{
//.........这里部分代码省略.........
示例5: dLogSum
static void
dLogSum(double g, const FVector &v, FVector &r)
{
assert(v.size() <= r.size());
dLogSum(g, v, r, v.size());
}
示例6: GLevelEditorModeTools
/**
* @return true if the delta was handled by this editor mode tool.
*/
bool FModeTool_Texture::InputDelta(FEditorViewportClient* InViewportClient,FViewport* InViewport,FVector& InDrag,FRotator& InRot,FVector& InScale)
{
if( InViewportClient->GetCurrentWidgetAxis() == EAxisList::None )
{
return false;
}
// calculate delta drag for this tick for the call to GEditor->polyTexPan below which is using relative (delta) mode
FVector deltaDrag = InDrag;
if (true == InViewportClient->IsPerspective())
{
// perspective viewports pass the absolute drag so subtract the last tick's drag value to get the delta
deltaDrag -= PreviousInputDrag;
}
PreviousInputDrag = InDrag;
if( !deltaDrag.IsZero() )
{
// Ensure each polygon has a unique base point index.
for( FConstLevelIterator Iterator = InViewportClient->GetWorld()->GetLevelIterator(); Iterator; ++Iterator )
{
UModel* Model = (*Iterator)->Model;
for(int32 SurfaceIndex = 0;SurfaceIndex < Model->Surfs.Num();SurfaceIndex++)
{
FBspSurf& Surf = Model->Surfs[SurfaceIndex];
if(Surf.PolyFlags & PF_Selected)
{
const FVector Base = Model->Points[Surf.pBase];
Surf.pBase = Model->Points.Add(Base);
}
}
FMatrix Mat = GLevelEditorModeTools().GetCustomDrawingCoordinateSystem();
FVector UVW = Mat.InverseTransformVector( deltaDrag ); // InverseTransformNormal because Mat is the transform from the surface/widget's coords to world coords
GEditor->polyTexPan( Model, UVW.X, UVW.Y, 0 ); // 0 is relative mode because UVW is made from deltaDrag - the user input since the last tick
}
}
if( !InRot.IsZero() )
{
const FRotationMatrix RotationMatrix( InRot );
// Ensure each polygon has unique texture vector indices.
for ( TSelectedSurfaceIterator<> It(InViewportClient->GetWorld()) ; It ; ++It )
{
FBspSurf* Surf = *It;
UModel* Model = It.GetModel();
FVector TextureU = Model->Vectors[Surf->vTextureU];
FVector TextureV = Model->Vectors[Surf->vTextureV];
TextureU = RotationMatrix.TransformPosition( TextureU );
TextureV = RotationMatrix.TransformPosition( TextureV );
Surf->vTextureU = Model->Vectors.Add(TextureU);
Surf->vTextureV = Model->Vectors.Add(TextureV);
const bool bUpdateTexCoords = true;
const bool bOnlyRefreshSurfaceMaterials = true;
GEditor->polyUpdateMaster(Model, It.GetSurfaceIndex(), bUpdateTexCoords, bOnlyRefreshSurfaceMaterials);
}
}
if( !InScale.IsZero() )
{
float ScaleU = InScale.X / GEditor->GetGridSize();
float ScaleV = InScale.Y / GEditor->GetGridSize();
ScaleU = 1.f - (ScaleU / 100.f);
ScaleV = 1.f - (ScaleV / 100.f);
// Ensure each polygon has unique texture vector indices.
for( FConstLevelIterator Iterator = InViewportClient->GetWorld()->GetLevelIterator(); Iterator; ++Iterator )
{
UModel* Model = (*Iterator)->Model;
for(int32 SurfaceIndex = 0;SurfaceIndex < Model->Surfs.Num();SurfaceIndex++)
{
FBspSurf& Surf = Model->Surfs[SurfaceIndex];
if(Surf.PolyFlags & PF_Selected)
{
const FVector TextureU = Model->Vectors[Surf.vTextureU];
const FVector TextureV = Model->Vectors[Surf.vTextureV];
Surf.vTextureU = Model->Vectors.Add(TextureU);
Surf.vTextureV = Model->Vectors.Add(TextureV);
}
}
GEditor->polyTexScale( Model, ScaleU, 0.f, 0.f, ScaleV, false );
}
}
return true;
}
示例7: OnCollision
void UFlareSpacecraftDamageSystem::OnCollision(class AActor* Other, FVector HitLocation, FVector NormalImpulse)
{
// If receive hit from over actor, like a ship we must apply collision damages.
// The applied damage energy is 0.2% of the kinetic energy of the other actor. The kinetic
// energy is calculated from the relative speed between the 2 actors, and only with the relative
// speed projected in the axis of the collision normal: if 2 very fast ship only slightly touch,
// only few energy will be decipated by the impact.
//
// The damages are applied only to the current actor, the ReceiveHit method of the other actor
// will also call an it will apply its collision damages itself.
// If the other actor is a projectile, specific weapon damage code is done in the projectile hit
// handler: in this case we ignore the collision
AFlareShell* OtherProjectile = Cast<AFlareShell>(Other);
if (OtherProjectile)
{
return;
}
// No primitive component, ignore
UPrimitiveComponent* OtherRoot = Cast<UPrimitiveComponent>(Other->GetRootComponent());
if (!OtherRoot)
{
return;
}
// Ignore debris
AStaticMeshActor* OtherActor = Cast<AStaticMeshActor>(Other);
if (OtherActor)
{
if (OtherActor->GetName().StartsWith("Debris"))
{
return;
}
}
// Relative velocity
FVector DeltaVelocity = ((OtherRoot->GetPhysicsLinearVelocity() - Spacecraft->Airframe->GetPhysicsLinearVelocity()) / 100);
// Compute the relative velocity in the impact axis then compute kinetic energy
/*float ImpactSpeed = DeltaVelocity.Size();
float ImpactMass = FMath::Min(Spacecraft->GetSpacecraftMass(), OtherRoot->GetMass());
*/
//200 m /s -> 6301.873047 * 20000 -> 300 / 2 damage
float ImpactSpeed = 0;
float ImpactEnergy = 0;
float ImpactMass = Spacecraft->GetSpacecraftMass();
// Check if the mass was set and is valid
if (ImpactMass > KINDA_SMALL_NUMBER)
{
ImpactSpeed = NormalImpulse.Size() / (ImpactMass * 100.f);
ImpactEnergy = ImpactMass * ImpactSpeed / 8402.f;
}
float Radius = 0.2 + FMath::Sqrt(ImpactEnergy) * 0.11;
//FLOGV("OnCollision %s", *Spacecraft->GetImmatriculation().ToString());
//FLOGV(" OtherRoot->GetPhysicsLinearVelocity()=%s", *OtherRoot->GetPhysicsLinearVelocity().ToString());
//FLOGV(" OtherRoot->GetPhysicsLinearVelocity().Size()=%f", OtherRoot->GetPhysicsLinearVelocity().Size());
//FLOGV(" Spacecraft->Airframe->GetPhysicsLinearVelocity()=%s", *Spacecraft->Airframe->GetPhysicsLinearVelocity().ToString());
//FLOGV(" Spacecraft->Airframe->GetPhysicsLinearVelocity().Size()=%f", Spacecraft->Airframe->GetPhysicsLinearVelocity().Size());
//FLOGV(" dot=%f", FVector::DotProduct(DeltaVelocity.GetUnsafeNormal(), HitNormal.GetUnsafeNormal()));
/*FLOGV(" DeltaVelocity=%s", *DeltaVelocity.ToString());
FLOGV(" ImpactSpeed=%f", ImpactSpeed);
FLOGV(" ImpactMass=%f", ImpactMass);
FLOGV(" ImpactEnergy=%f", ImpactEnergy);
FLOGV(" Radius=%f", Radius);*/
bool HasHit = false;
FHitResult BestHitResult;
float BestHitDistance = 0;
for (int32 ComponentIndex = 0; ComponentIndex < Components.Num(); ComponentIndex++)
{
UFlareSpacecraftComponent* Component = Cast<UFlareSpacecraftComponent>(Components[ComponentIndex]);
if (Component)
{
FHitResult HitResult(ForceInit);
FCollisionQueryParams TraceParams(FName(TEXT("Fragment Trace")), true);
TraceParams.bTraceComplex = true;
TraceParams.bReturnPhysicalMaterial = false;
Component->LineTraceComponent(HitResult, HitLocation, HitLocation + Spacecraft->GetLinearVelocity().GetUnsafeNormal() * 10000, TraceParams);
if (HitResult.Actor.IsValid()){
float HitDistance = (HitResult.Location - HitLocation).Size();
if (!HasHit || HitDistance < BestHitDistance)
{
BestHitDistance = HitDistance;
BestHitResult = HitResult;
}
//FLOGV("Collide hit %s at a distance=%f", *Component->GetReadableName(), HitDistance);
HasHit = true;
}
}
//.........这里部分代码省略.........
示例8: FindTriMeshOpposingNormal
static FVector FindTriMeshOpposingNormal(const PxLocationHit& PHit, const FVector& TraceDirectionDenorm, const FVector InNormal)
{
if (IsInvalidFaceIndex(PHit.faceIndex))
{
return InNormal;
}
PxTriangleMeshGeometry PTriMeshGeom;
bool bSuccess = PHit.shape->getTriangleMeshGeometry(PTriMeshGeom);
check(bSuccess); //this function should only be called when we have a trimesh
if (PTriMeshGeom.triangleMesh)
{
check(PHit.faceIndex < PTriMeshGeom.triangleMesh->getNbTriangles());
const PxU32 TriIndex = PHit.faceIndex;
const void* Triangles = PTriMeshGeom.triangleMesh->getTriangles();
// Grab triangle indices that we hit
int32 I0, I1, I2;
if (PTriMeshGeom.triangleMesh->getTriangleMeshFlags() & PxTriangleMeshFlag::eHAS_16BIT_TRIANGLE_INDICES)
{
PxU16* P16BitIndices = (PxU16*)Triangles;
I0 = P16BitIndices[(TriIndex * 3) + 0];
I1 = P16BitIndices[(TriIndex * 3) + 1];
I2 = P16BitIndices[(TriIndex * 3) + 2];
}
else
{
PxU32* P32BitIndices = (PxU32*)Triangles;
I0 = P32BitIndices[(TriIndex * 3) + 0];
I1 = P32BitIndices[(TriIndex * 3) + 1];
I2 = P32BitIndices[(TriIndex * 3) + 2];
}
// Get verts we hit (local space)
const PxVec3* PVerts = PTriMeshGeom.triangleMesh->getVertices();
const PxVec3 V0 = PVerts[I0];
const PxVec3 V1 = PVerts[I1];
const PxVec3 V2 = PVerts[I2];
// Find normal of triangle (local space), and account for non-uniform scale
const PxVec3 PTempNormal = ((V1 - V0).cross(V2 - V0)).getNormalized();
const PxVec3 PLocalTriNormal = TransformNormalToShapeSpace(PTriMeshGeom.scale, PTempNormal);
// Convert to world space
const PxTransform PShapeWorldPose = PxShapeExt::getGlobalPose(*PHit.shape, *PHit.actor);
const PxVec3 PWorldTriNormal = PShapeWorldPose.rotate(PLocalTriNormal);
FVector OutNormal = P2UVector(PWorldTriNormal);
if (PTriMeshGeom.meshFlags & PxMeshGeometryFlag::eDOUBLE_SIDED)
{
//double sided mesh so we need to consider direction of query
const float sign = FVector::DotProduct(OutNormal, TraceDirectionDenorm) > 0.f ? -1.f : 1.f;
OutNormal *= sign;
}
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
if (!OutNormal.IsNormalized())
{
UE_LOG(LogPhysics, Warning, TEXT("Non-normalized Normal (Hit shape is TriangleMesh): %s (V0:%s, V1:%s, V2:%s)"), *OutNormal.ToString(), *P2UVector(V0).ToString(), *P2UVector(V1).ToString(), *P2UVector(V2).ToString());
UE_LOG(LogPhysics, Warning, TEXT("WorldTransform \n: %s"), *P2UTransform(PShapeWorldPose).ToString());
}
#endif
return OutNormal;
}
return InNormal;
}
示例9: CheckHitResultNormal
/* Validate Normal of OutResult. We're on hunt for invalid normal */
static void CheckHitResultNormal(const FHitResult& OutResult, const TCHAR* Message, const FVector& Start=FVector::ZeroVector, const FVector& End = FVector::ZeroVector, const PxGeometry* const Geom=NULL)
{
if(!OutResult.bStartPenetrating && !OutResult.Normal.IsNormalized())
{
UE_LOG(LogPhysics, Warning, TEXT("(%s) Non-normalized OutResult.Normal from hit conversion: %s (Component- %s)"), Message, *OutResult.Normal.ToString(), *GetNameSafe(OutResult.Component.Get()));
UE_LOG(LogPhysics, Warning, TEXT("Start Loc(%s), End Loc(%s), Hit Loc(%s), ImpactNormal(%s)"), *Start.ToString(), *End.ToString(), *OutResult.Location.ToString(), *OutResult.ImpactNormal.ToString() );
if (Geom != NULL)
{
if (Geom->getType() == PxGeometryType::eCAPSULE)
{
const PxCapsuleGeometry * Capsule = (PxCapsuleGeometry*)Geom;
UE_LOG(LogPhysics, Warning, TEXT("Capsule radius (%f), Capsule Halfheight (%f)"), Capsule->radius, Capsule->halfHeight);
}
}
ensure(OutResult.Normal.IsNormalized());
}
}
示例10: AddControlPointPosition
void UInterpToMovementComponent::AddControlPointPosition(FVector Pos)
{
UE_LOG(LogInterpToMovementComponent, Warning, TEXT("Pos:%s"),*Pos.ToString());
ControlPoints.Add( FInterpControlPoint(Pos));
}
示例11: IsDebugOnForAll
//RickH - We could probably significantly improve speed if we put separate Z checks in place and did everything else in 2D.
FVector UAvoidanceManager::GetAvoidanceVelocity_Internal(const FNavAvoidanceData& inAvoidanceData, float DeltaTime, int32* inIgnoreThisUID)
{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
if (!bSystemActive)
{
return inAvoidanceData.Velocity;
}
#endif
if (DeltaTime <= 0.0f)
{
return inAvoidanceData.Velocity;
}
FVector ReturnVelocity = inAvoidanceData.Velocity * DeltaTime;
float MaxSpeed = ReturnVelocity.Size2D();
float CurrentTime;
UWorld* MyWorld = Cast<UWorld>(GetOuter());
if (MyWorld)
{
CurrentTime = MyWorld->TimeSeconds;
}
else
{
//No world? OK, just quietly back out and don't alter anything.
return inAvoidanceData.Velocity;
}
bool Unobstructed = true;
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
bool DebugMode = IsDebugOnForAll() || (inIgnoreThisUID ? IsDebugOnForUID(*inIgnoreThisUID) : false);
#endif
//If we're moving very slowly, just push forward. Not sure it's worth avoiding at this speed, though I could be wrong.
if (MaxSpeed < 0.01f)
{
return inAvoidanceData.Velocity;
}
AllCones.Empty(AllCones.Max());
//DrawDebugDirectionalArrow(GetWorld(), inAvoidanceData.Center, inAvoidanceData.Center + inAvoidanceData.Velocity, 2.5f, FColor(0,255,255), true, 0.05f, SDPG_MAX);
for (auto& AvoidanceObj : AvoidanceObjects)
{
if ((inIgnoreThisUID) && (*inIgnoreThisUID == AvoidanceObj.Key))
{
continue;
}
FNavAvoidanceData& OtherObject = AvoidanceObj.Value;
//
//Start with a few fast-rejects
//
//If the object has expired, ignore it
if (OtherObject.ShouldBeIgnored())
{
continue;
}
//If other object is not in avoided group, ignore it
if (inAvoidanceData.ShouldIgnoreGroup(OtherObject.GroupMask))
{
continue;
}
//RickH - We should have a max-radius parameter/option here, so I'm just going to hardcode one for now.
//if ((OtherObject.Radius + _AvoidanceData.Radius + MaxSpeed + OtherObject.Velocity.Size2D()) < FVector::Dist(OtherObject.Center, _AvoidanceData.Center))
if (FVector2D(OtherObject.Center - inAvoidanceData.Center).SizeSquared() > FMath::Square(TestRadius2D))
{
continue;
}
if (FMath::Abs(OtherObject.Center.Z - inAvoidanceData.Center.Z) > TestHeightDifference)
{
continue;
}
//If we are moving away from the obstacle, ignore it. Even if we're the slower one, let the other obstacle path around us.
if ((ReturnVelocity | (OtherObject.Center - inAvoidanceData.Center)) <= 0.0f)
{
continue;
}
//Create data for the avoidance routine
{
FVector PointAWorld = inAvoidanceData.Center;
FVector PointBRelative = OtherObject.Center - PointAWorld;
FVector TowardB, SidewaysFromB;
FVector VelAdjustment;
FVector VelAfterAdjustment;
float RadiusB = OtherObject.Radius + inAvoidanceData.Radius;
PointBRelative.Z = 0.0f;
TowardB = PointBRelative.SafeNormal2D(); //Don't care about height for this game. Rough height-checking will come in later, but even then it will be acceptable to do this.
if (TowardB.IsZero())
{
//Already intersecting, or aligned vertically, scrap this whole object.
continue;
//.........这里部分代码省略.........
示例12: check
bool FInstancedStaticMeshSCSEditorCustomization::HandleViewportDrag(class USceneComponent* InSceneComponent, class USceneComponent* InComponentTemplate, const FVector& InDeltaTranslation, const FRotator& InDeltaRotation, const FVector& InDeltaScale, const FVector& InPivot)
{
check(InSceneComponent->IsA(UInstancedStaticMeshComponent::StaticClass()));
UInstancedStaticMeshComponent* InstancedStaticMeshComponentScene = CastChecked<UInstancedStaticMeshComponent>(InSceneComponent);
UInstancedStaticMeshComponent* InstancedStaticMeshComponentTemplate = CastChecked<UInstancedStaticMeshComponent>(InComponentTemplate);
// transform pivot into component's space
const FVector LocalPivot = InstancedStaticMeshComponentScene->GetComponentToWorld().InverseTransformPosition(InPivot);
// Ensure that selected instances are up-to-date
ValidateSelectedInstances(InstancedStaticMeshComponentScene);
bool bMovedInstance = false;
check(InstancedStaticMeshComponentScene->SelectedInstances.Num() == InstancedStaticMeshComponentScene->PerInstanceSMData.Num());
for(int32 InstanceIndex = 0; InstanceIndex < InstancedStaticMeshComponentScene->SelectedInstances.Num(); InstanceIndex++)
{
if (InstancedStaticMeshComponentScene->SelectedInstances[InstanceIndex] && InstancedStaticMeshComponentTemplate->PerInstanceSMData.IsValidIndex(InstanceIndex))
{
const FMatrix& MatrixScene = InstancedStaticMeshComponentScene->PerInstanceSMData[InstanceIndex].Transform;
FVector Translation = MatrixScene.GetOrigin();
FRotator Rotation = MatrixScene.Rotator();
FVector Scale = MatrixScene.GetScaleVector();
FVector NewTranslation = Translation;
FRotator NewRotation = Rotation;
FVector NewScale = Scale;
if( !InDeltaRotation.IsZero() )
{
NewRotation = FRotator( InDeltaRotation.Quaternion() * Rotation.Quaternion() );
NewTranslation -= LocalPivot;
NewTranslation = FRotationMatrix( InDeltaRotation ).TransformPosition( NewTranslation );
NewTranslation += LocalPivot;
}
NewTranslation += InDeltaTranslation;
if( !InDeltaScale.IsNearlyZero() )
{
const FScaleMatrix ScaleMatrix( InDeltaScale );
FVector DeltaScale3D = ScaleMatrix.TransformPosition( Scale );
NewScale = Scale + DeltaScale3D;
NewTranslation -= LocalPivot;
NewTranslation += ScaleMatrix.TransformPosition( NewTranslation );
NewTranslation += LocalPivot;
}
InstancedStaticMeshComponentScene->UpdateInstanceTransform(InstanceIndex, FTransform(NewRotation, NewTranslation, NewScale));
InstancedStaticMeshComponentTemplate->UpdateInstanceTransform(InstanceIndex, FTransform(NewRotation, NewTranslation, NewScale));
bMovedInstance = true;
}
}
return bMovedInstance;
}
示例13: GetWorldDirectionAtTime
FRotator USplineComponent::GetWorldRotationAtTime(float Time, bool bUseConstantVelocity) const
{
FVector WorldDir = GetWorldDirectionAtTime(Time, bUseConstantVelocity);
return WorldDir.Rotation();
}
示例14: GetWorldDirectionAtDistanceAlongSpline
FRotator USplineComponent::GetWorldRotationAtDistanceAlongSpline(float Distance) const
{
const FVector Dir = GetWorldDirectionAtDistanceAlongSpline(Distance);
return Dir.Rotation();
}
示例15: Conv_VectorToString
FString UKismetStringLibrary::Conv_VectorToString(FVector InVec)
{
return InVec.ToString();
}