本文整理汇总了C++中P2UVector函数的典型用法代码示例。如果您正苦于以下问题:C++ P2UVector函数的具体用法?C++ P2UVector怎么用?C++ P2UVector使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了P2UVector函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
void FKConvexElem::AddCachedSolidConvexGeom(TArray<FDynamicMeshVertex>& VertexBuffer, TArray<int32>& IndexBuffer, const FColor VertexColor)
{
#if WITH_PHYSX
if(ConvexMesh)
{
int32 StartVertOffset = VertexBuffer.Num();
// get PhysX data
const PxVec3* PVertices = ConvexMesh->getVertices();
const PxU8* PIndexBuffer = ConvexMesh->getIndexBuffer();
PxU32 NbPolygons = ConvexMesh->getNbPolygons();
for(PxU32 i=0;i<NbPolygons;i++)
{
PxHullPolygon Data;
bool bStatus = ConvexMesh->getPolygonData(i, Data);
check(bStatus);
const PxU8* indices = PIndexBuffer + Data.mIndexBase;
// create tangents from the first and second vertices of each polygon
const FVector TangentX = P2UVector(PVertices[indices[1]]-PVertices[indices[0]]).SafeNormal();
const FVector TangentZ = FVector(Data.mPlane[0], Data.mPlane[1], Data.mPlane[2]).SafeNormal();
const FVector TangentY = (TangentX ^ TangentZ).SafeNormal();
// add vertices
for(PxU32 j=0;j<Data.mNbVerts;j++)
{
int32 VertIndex = indices[j];
FDynamicMeshVertex Vert1;
Vert1.Position = P2UVector(PVertices[VertIndex]);
Vert1.Color = VertexColor;
Vert1.SetTangents(
TangentX,
TangentY,
TangentZ
);
VertexBuffer.Add(Vert1);
}
// Add indices
PxU32 nbTris = Data.mNbVerts - 2;
for(PxU32 j=0;j<nbTris;j++)
{
IndexBuffer.Add(StartVertOffset+0);
IndexBuffer.Add(StartVertOffset+j+2);
IndexBuffer.Add(StartVertOffset+j+1);
}
StartVertOffset += Data.mNbVerts;
}
}
else
{
UE_LOG(LogPhysics, Log, TEXT("FKConvexElem::AddCachedSolidConvexGeom : No ConvexMesh, so unable to draw."));
}
#endif // WITH_PHYSX
}
示例2: ChunkIdxToBoneIdx
void UDestructibleComponent::SetChunkVisible( int32 ChunkIndex, bool bVisible )
{
#if WITH_APEX
// Bone 0 is a dummy root bone
const int32 BoneIndex = ChunkIdxToBoneIdx(ChunkIndex);
if( bVisible )
{
UnHideBone(BoneIndex);
if (NULL != ApexDestructibleActor)
{
physx::PxShape** PShapes;
const physx::PxU32 PShapeCount = ApexDestructibleActor->getChunkPhysXShapes(PShapes, ChunkIndex);
if (PShapeCount > 0)
{
const physx::PxMat44 ChunkPoseRT = ApexDestructibleActor->getChunkPose(ChunkIndex); // Unscaled
const physx::PxTransform Transform(ChunkPoseRT);
SetChunkWorldRT(ChunkIndex, P2UQuat(Transform.q), P2UVector(Transform.p));
}
}
}
else
{
HideBone(BoneIndex, PBO_None);
}
// Mark the transform as dirty, so the bounds are updated and sent to the render thread
MarkRenderTransformDirty();
// New bone positions need to be sent to render thread
MarkRenderDynamicDataDirty();
#endif
}
示例3: ExecuteOnUnbrokenJointReadOnly
void FConstraintInstance::GetConstraintForce(FVector& OutLinearForce, FVector& OutAngularForce)
{
OutLinearForce = FVector::ZeroVector;
OutAngularForce = FVector::ZeroVector;
#if WITH_PHYSX
ExecuteOnUnbrokenJointReadOnly([&] (const PxD6Joint* Joint)
{
PxVec3 PxOutLinearForce;
PxVec3 PxOutAngularForce;
Joint->getConstraint()->getForce(PxOutLinearForce, PxOutAngularForce);
OutLinearForce = P2UVector(PxOutLinearForce);
OutAngularForce = P2UVector(PxOutAngularForce);
});
#endif
}
示例4: FindHeightFieldOpposingNormal
static FVector FindHeightFieldOpposingNormal(const PxLocationHit& PHit, const FVector& TraceDirectionDenorm, const FVector InNormal)
{
if (IsInvalidFaceIndex(PHit.faceIndex))
{
return InNormal;
}
PxHeightFieldGeometry PHeightFieldGeom;
const bool bReadGeomSuccess = PHit.shape->getHeightFieldGeometry(PHeightFieldGeom);
check(bReadGeomSuccess); //we should only call this function when we have a heightfield
if (PHeightFieldGeom.heightField)
{
const PxU32 TriIndex = PHit.faceIndex;
const PxTransform PShapeWorldPose = PxShapeExt::getGlobalPose(*PHit.shape, *PHit.actor);
PxTriangle Tri;
PxMeshQuery::getTriangle(PHeightFieldGeom, PShapeWorldPose, TriIndex, Tri);
PxVec3 TriNormal;
Tri.normal(TriNormal);
return P2UVector(TriNormal);
}
return InNormal;
}
示例5: JointPos
/** Get the position of this constraint in world space. */
FVector FConstraintInstance::GetConstraintLocation()
{
#if WITH_PHYSX
PxD6Joint* Joint = (PxD6Joint*) ConstraintData;
if (!Joint)
{
return FVector::ZeroVector;
}
PxRigidActor* JointActor0, *JointActor1;
Joint->getActors(JointActor0, JointActor1);
PxVec3 JointPos(0);
// get the first anchor point in global frame
if(JointActor0)
{
JointPos = JointActor0->getGlobalPose().transform(Joint->getLocalPose(PxJointActorIndex::eACTOR0).p);
}
// get the second archor point in global frame
if(JointActor1)
{
JointPos += JointActor1->getGlobalPose().transform(Joint->getLocalPose(PxJointActorIndex::eACTOR1).p);
}
JointPos *= 0.5f;
return P2UVector(JointPos);
#else
return FVector::ZeroVector;
#endif
}
示例6: FBoxSphereBounds
FBoxSphereBounds UDestructibleComponent::CalcBounds(const FTransform& LocalToWorld) const
{
#if WITH_APEX
if( ApexDestructibleActor == NULL )
{
// Fallback if we don't have physics
return Super::CalcBounds(LocalToWorld);
}
const PxBounds3& PBounds = ApexDestructibleActor->getBounds();
return FBoxSphereBounds( FBox( P2UVector(PBounds.minimum), P2UVector(PBounds.maximum) ) );
#else // #if WITH_APEX
return Super::CalcBounds(LocalToWorld);
#endif // #if WITH_APEX
}
示例7: PxVec3
void SDestructibleMeshEditorViewport::RefreshViewport()
{
// Update chunk visibilities
#if WITH_APEX
#if WITH_EDITORONLY_DATA
if (DestructibleMesh != NULL && DestructibleMesh->FractureSettings != NULL && DestructibleMesh->ApexDestructibleAsset != NULL && PreviewComponent->IsRegistered())
{
const NxRenderMeshAsset* ApexRenderMeshAsset = DestructibleMesh->ApexDestructibleAsset->getRenderMeshAsset();
if (ApexRenderMeshAsset != NULL)
{
NxExplicitHierarchicalMesh& EHM = DestructibleMesh->FractureSettings->ApexDestructibleAssetAuthoring->getExplicitHierarchicalMesh();
if (DestructibleMesh->ApexDestructibleAsset->getPartIndex(0) < ApexRenderMeshAsset->getPartCount())
{
const PxBounds3& Level0Bounds = ApexRenderMeshAsset->getBounds(DestructibleMesh->ApexDestructibleAsset->getPartIndex(0));
const PxVec3 Level0Center = !Level0Bounds.isEmpty() ? Level0Bounds.getCenter() : PxVec3(0.0f);
for (uint32 ChunkIndex = 0; ChunkIndex < DestructibleMesh->ApexDestructibleAsset->getChunkCount(); ++ChunkIndex)
{
const uint32 PartIndex = DestructibleMesh->ApexDestructibleAsset->getPartIndex(ChunkIndex);
if (PartIndex >= ApexRenderMeshAsset->getPartCount())
{
continue;
}
uint32 ChunkDepth = 0;
for (int32 ParentIndex = DestructibleMesh->ApexDestructibleAsset->getChunkParentIndex(ChunkIndex);
ParentIndex >= 0;
ParentIndex = DestructibleMesh->ApexDestructibleAsset->getChunkParentIndex(ParentIndex))
{
++ChunkDepth;
}
const bool bChunkVisible = ChunkDepth == PreviewDepth;
PreviewComponent->SetChunkVisible(ChunkIndex, bChunkVisible);
if (bChunkVisible)
{
const PxBounds3& ChunkBounds = ApexRenderMeshAsset->getBounds(PartIndex);
const PxVec3 ChunkCenter = !ChunkBounds.isEmpty() ? ChunkBounds.getCenter() : PxVec3(0.0f);
const PxVec3 Displacement = ExplodeAmount*(ChunkCenter - Level0Center);
PreviewComponent->SetChunkWorldRT(ChunkIndex, FQuat(0.0f, 0.0f, 0.0f, 1.0f), P2UVector(Displacement));
}
}
PreviewComponent->BoundsScale = 100;
// Send bounds to render thread at end of frame
PreviewComponent->UpdateComponentToWorld();
// Send bones to render thread right now, so the invalidated display is rerendered with
// uptodate information
PreviewComponent->DoDeferredRenderUpdates_Concurrent();
}
}
}
#endif // WITH_EDITORONLY_DATA
#endif // WITH_APEX
// Invalidate the viewport's display.
SceneViewport->InvalidateDisplay();
}
示例8: GetDestructibleMesh
void UDestructibleComponent::RefreshBoneTransforms()
{
#if WITH_APEX
if(ApexDestructibleActor != NULL && SkeletalMesh)
{
UDestructibleMesh* TheDestructibleMesh = GetDestructibleMesh();
// Save a pointer to the APEX NxDestructibleAsset
physx::NxDestructibleAsset* ApexDestructibleAsset = TheDestructibleMesh->ApexDestructibleAsset;
check(ApexDestructibleAsset);
{
// Lock here so we don't encounter race conditions with the destruction processing
FPhysScene* PhysScene = World->GetPhysicsScene();
check(PhysScene);
const uint32 SceneType = (BodyInstance.bUseAsyncScene && PhysScene->HasAsyncScene()) ? PST_Async : PST_Sync;
PxScene* PScene = PhysScene->GetPhysXScene(SceneType);
check(PScene);
SCOPED_SCENE_WRITE_LOCK(PScene);
SCOPED_SCENE_READ_LOCK(PScene);
// Try to acquire event buffer
const physx::NxDestructibleChunkEvent* EventBuffer;
physx::PxU32 EventBufferSize;
if (ApexDestructibleActor->acquireChunkEventBuffer(EventBuffer, EventBufferSize))
{
// Buffer acquired
while (EventBufferSize--)
{
const physx::NxDestructibleChunkEvent& Event = *EventBuffer++;
// Right now the only events are visibility changes. So as an optimization we won't check for the event type.
// if (Event.event & physx::NxDestructibleChunkEvent::VisibilityChanged)
const bool bVisible = (Event.event & physx::NxDestructibleChunkEvent::ChunkVisible) != 0;
SetChunkVisible(Event.chunkIndex, bVisible);
}
// Release buffer (will be cleared)
ApexDestructibleActor->releaseChunkEventBuffer();
}
}
// Update poses for visible chunks
const physx::PxU16* VisibleChunks = ApexDestructibleActor->getVisibleChunks();
physx::PxU16 VisibleChunkCount = ApexDestructibleActor->getNumVisibleChunks();
while (VisibleChunkCount--)
{
const physx::PxU16 ChunkIndex = *VisibleChunks++;
// BRGTODO : Make a direct method to access the Px objects' quats
const physx::PxMat44 ChunkPoseRT = ApexDestructibleActor->getChunkPose(ChunkIndex); // Unscaled
const physx::PxTransform Transform(ChunkPoseRT);
SetChunkWorldRT(ChunkIndex, P2UQuat(Transform.q), P2UVector(Transform.p));
}
// Send bones to render thread at end of frame
MarkRenderDynamicDataDirty();
}
#endif // #if WITH_APEX
}
示例9: PTransform2UMatrix
FMatrix PTransform2UMatrix(const PxTransform& PTM)
{
FQuat UQuat = P2UQuat(PTM.q);
FVector UPos = P2UVector(PTM.p);
FMatrix Result = FQuatRotationTranslationMatrix(UQuat, UPos);
return Result;
}
示例10: P2UTransform
FTransform P2UTransform(const PxTransform& PTM)
{
FQuat UQuat = P2UQuat(PTM.q);
FVector UPos = P2UVector(PTM.p);
FTransform Result = FTransform(UQuat, UPos);
return Result;
}
示例11: BatchPxRenderBufferLines
static void BatchPxRenderBufferLines(class ULineBatchComponent& LineBatcherToUse, const PxRenderBuffer& DebugData)
{
int32 NumPoints = DebugData.getNbPoints();
if (NumPoints > 0)
{
const PxDebugPoint* Points = DebugData.getPoints();
for (int32 i = 0; i<NumPoints; i++)
{
LineBatcherToUse.DrawPoint(P2UVector(Points->pos), FColor((uint32)Points->color), 2, SDPG_World);
Points++;
}
}
// Build a list of all the lines we want to draw
TArray<FBatchedLine> DebugLines;
// Add all the 'lines' from PhysX
int32 NumLines = DebugData.getNbLines();
if (NumLines > 0)
{
const PxDebugLine* Lines = DebugData.getLines();
for (int32 i = 0; i<NumLines; i++)
{
new(DebugLines)FBatchedLine(P2UVector(Lines->pos0), P2UVector(Lines->pos1), FColor((uint32)Lines->color0), 0.f, 0.0f, SDPG_World);
Lines++;
}
}
// Add all the 'triangles' from PhysX
int32 NumTris = DebugData.getNbTriangles();
if (NumTris > 0)
{
const PxDebugTriangle* Triangles = DebugData.getTriangles();
for (int32 i = 0; i<NumTris; i++)
{
new(DebugLines)FBatchedLine(P2UVector(Triangles->pos0), P2UVector(Triangles->pos1), FColor((uint32)Triangles->color0), 0.f, 0.0f, SDPG_World);
new(DebugLines)FBatchedLine(P2UVector(Triangles->pos1), P2UVector(Triangles->pos2), FColor((uint32)Triangles->color1), 0.f, 0.0f, SDPG_World);
new(DebugLines)FBatchedLine(P2UVector(Triangles->pos2), P2UVector(Triangles->pos0), FColor((uint32)Triangles->color2), 0.f, 0.0f, SDPG_World);
Triangles++;
}
}
// Draw them all in one call.
if (DebugLines.Num() > 0)
{
LineBatcherToUse.DrawLines(DebugLines);
}
}
示例12: FindBoxOpposingNormal
static FVector FindBoxOpposingNormal(const PxLocationHit& PHit, const FVector& TraceDirectionDenorm, const FVector InNormal)
{
// We require normal info for our algorithm.
const bool bNormalData = (PHit.flags & PxHitFlag::eNORMAL);
if (!bNormalData)
{
return InNormal;
}
PxBoxGeometry PxBoxGeom;
const bool bReadGeomSuccess = PHit.shape->getBoxGeometry(PxBoxGeom);
check(bReadGeomSuccess); // This function should only be used for box geometry
const PxTransform LocalToWorld = PxShapeExt::getGlobalPose(*PHit.shape, *PHit.actor);
// Find which faces were included in the contact normal, and for multiple faces, use the one most opposing the sweep direction.
const PxVec3 ContactNormalLocal = LocalToWorld.rotateInv(PHit.normal);
const float* ContactNormalLocalPtr = &ContactNormalLocal.x;
const PxVec3 TraceDirDenormWorld = U2PVector(TraceDirectionDenorm);
const float* TraceDirDenormWorldPtr = &TraceDirDenormWorld.x;
const PxVec3 TraceDirDenormLocal = LocalToWorld.rotateInv(TraceDirDenormWorld);
const float* TraceDirDenormLocalPtr = &TraceDirDenormLocal.x;
PxVec3 BestLocalNormal(ContactNormalLocal);
float* BestLocalNormalPtr = &BestLocalNormal.x;
float BestOpposingDot = FLT_MAX;
for (int32 i=0; i < 3; i++)
{
// Select axis of face to compare to, based on normal.
if (ContactNormalLocalPtr[i] > KINDA_SMALL_NUMBER)
{
const float TraceDotFaceNormal = TraceDirDenormLocalPtr[i]; // TraceDirDenormLocal.dot(BoxFaceNormal)
if (TraceDotFaceNormal < BestOpposingDot)
{
BestOpposingDot = TraceDotFaceNormal;
BestLocalNormal = PxVec3(0.f);
BestLocalNormalPtr[i] = 1.f;
}
}
else if (ContactNormalLocalPtr[i] < -KINDA_SMALL_NUMBER)
{
const float TraceDotFaceNormal = -TraceDirDenormLocalPtr[i]; // TraceDirDenormLocal.dot(BoxFaceNormal)
if (TraceDotFaceNormal < BestOpposingDot)
{
BestOpposingDot = TraceDotFaceNormal;
BestLocalNormal = PxVec3(0.f);
BestLocalNormalPtr[i] = -1.f;
}
}
}
// Fill in result
const PxVec3 WorldNormal = LocalToWorld.rotate(BestLocalNormal);
return P2UVector(WorldNormal);
}
示例13: P2UVector
FVector UVehicleWheel::GetPhysicsLocation()
{
if ( WheelShape )
{
PxVec3 PLocation = VehicleSim->PVehicle->getRigidDynamicActor()->getGlobalPose().transform( WheelShape->getLocalPose() ).p;
return P2UVector( PLocation );
}
return FVector(0.0f);
}
示例14: P2UVector
// NB: ElemTM is assumed to have no scaling in it!
void FKConvexElem::DrawElemWire(FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, const FVector& Scale3D, const FColor Color)
{
#if WITH_PHYSX
FTransform LocalToWorld = ElemTM;
LocalToWorld.SetScale3D(Scale3D);
PxConvexMesh* Mesh = ConvexMesh;
if(Mesh)
{
// Draw each triangle that makes up the convex hull
PxU32 NbVerts = Mesh->getNbVertices();
const PxVec3* Vertices = Mesh->getVertices();
TArray<FVector> TransformedVerts;
TransformedVerts.AddUninitialized(NbVerts);
for(PxU32 i=0; i<NbVerts; i++)
{
TransformedVerts[i] = LocalToWorld.TransformPosition( P2UVector(Vertices[i]) );
}
const PxU8* PIndexBuffer = Mesh->getIndexBuffer();
PxU32 NbPolygons = Mesh->getNbPolygons();
for(PxU32 i=0;i<NbPolygons;i++)
{
PxHullPolygon Data;
bool bStatus = Mesh->getPolygonData(i, Data);
check(bStatus);
const PxU8* PIndices = PIndexBuffer + Data.mIndexBase;
for(PxU16 j=0;j<Data.mNbVerts;j++)
{
// Get the verts that make up this line.
int32 I0 = PIndices[j];
int32 I1 = PIndices[j+1];
// Loop back last and first vertices
if(j==Data.mNbVerts - 1)
{
I1 = PIndices[0];
}
PDI->DrawLine( TransformedVerts[I0], TransformedVerts[I1], Color, SDPG_World );
}
}
}
else
{
UE_LOG(LogPhysics, Log, TEXT("FKConvexElem::DrawElemWire : No ConvexMesh, so unable to draw."));
}
#endif // WITH_PHYSX
}
示例15: P2UVector
void UDestructibleComponent::OnDamageEvent(const NxApexDamageEventReportData& InDamageEvent)
{
FVector HitPosition = P2UVector(InDamageEvent.hitPosition);
FVector HitDirection = P2UVector(InDamageEvent.hitDirection);
OnComponentFracture.Broadcast(HitPosition, HitDirection);
if (ADestructibleActor * DestructibleActor = Cast<ADestructibleActor>(GetOwner()))
{
DestructibleActor->OnActorFracture.Broadcast(HitPosition, HitDirection);
}
SpawnFractureEffectsFromDamageEvent(InDamageEvent);
// After receiving damage, no longer receive decals.
if (bReceivesDecals)
{
bReceivesDecals = false;
MarkRenderStateDirty();
}
}