Integrating up through commit 90f050496
This commit is contained in:
@@ -17,13 +17,11 @@
|
||||
#include <AzFramework/Physics/ShapeConfiguration.h>
|
||||
#include <AzFramework/Physics/Shape.h>
|
||||
|
||||
#include <AzFramework/Physics/RigidBody.h>
|
||||
#include <AzFramework/Physics/WorldBody.h>
|
||||
#include <AzFramework/Physics/SimulatedBodies/RigidBody.h>
|
||||
|
||||
namespace PhysX
|
||||
{
|
||||
class Shape;
|
||||
class RigidBodyStatic;
|
||||
|
||||
//! Messages serviced by a PhysX collider component.
|
||||
//! A PhysX collider component allows collision geometry to be attached to bodies in PhysX.
|
||||
@@ -46,8 +44,8 @@ namespace PhysX
|
||||
: public AZ::ComponentBus
|
||||
{
|
||||
public:
|
||||
virtual Physics::RigidBodyConfiguration GetRigidBodyConfiguration() = 0;
|
||||
virtual Physics::WorldBodyConfiguration GetWorldBodyConfiguration() = 0;
|
||||
virtual AzPhysics::RigidBodyConfiguration GetRigidBodyConfiguration() = 0;
|
||||
virtual AzPhysics::SimulatedBodyConfiguration GetSimulatedBodyConfiguration() = 0;
|
||||
};
|
||||
|
||||
using BodyConfigurationComponentBus = AZ::EBus<BodyConfigurationComponentRequests>;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace PhysX
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR_DECL
|
||||
AZ_TYPE_INFO(WindConfiguration, "{6EA3E646-ECDA-4044-912D-5722D5100066}");
|
||||
AZ_TYPE_INFO(PhysX::WindConfiguration, "{6EA3E646-ECDA-4044-912D-5722D5100066}");
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
/// Tag value that will be used to identify entities that provide global wind value.
|
||||
@@ -49,7 +49,7 @@ namespace PhysX
|
||||
struct PhysXSystemConfiguration : public AzPhysics::SystemConfiguration
|
||||
{
|
||||
AZ_CLASS_ALLOCATOR_DECL;
|
||||
AZ_RTTI(PhysXSystemConfiguration, "{6E25A37B-2109-452C-97C9-B737CC72704F}");
|
||||
AZ_RTTI(PhysX::PhysXSystemConfiguration, "{6E25A37B-2109-452C-97C9-B737CC72704F}");
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
static PhysXSystemConfiguration CreateDefault();
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <PhysX_precompiled.h>
|
||||
|
||||
#include <PhysX/HeightFieldAsset.h>
|
||||
|
||||
namespace PhysX
|
||||
{
|
||||
namespace Pipeline
|
||||
{
|
||||
HeightFieldAsset::~HeightFieldAsset()
|
||||
{
|
||||
ReleaseMemory();
|
||||
}
|
||||
|
||||
physx::PxHeightField* HeightFieldAsset::GetHeightField()
|
||||
{
|
||||
return m_heightField;
|
||||
}
|
||||
|
||||
const physx::PxHeightField* HeightFieldAsset::GetHeightField() const
|
||||
{
|
||||
return m_heightField;
|
||||
}
|
||||
|
||||
void HeightFieldAsset::SetHeightField(physx::PxHeightField* heightField)
|
||||
{
|
||||
ReleaseMemory();
|
||||
|
||||
m_heightField = heightField;
|
||||
m_status = AssetStatus::Ready;
|
||||
}
|
||||
|
||||
float HeightFieldAsset::GetMinHeight() const
|
||||
{
|
||||
return m_minHeight;
|
||||
}
|
||||
|
||||
void HeightFieldAsset::SetMinHeight(float height)
|
||||
{
|
||||
m_minHeight = height;
|
||||
}
|
||||
|
||||
float HeightFieldAsset::GetMaxHeight() const
|
||||
{
|
||||
return m_maxHeight;
|
||||
}
|
||||
|
||||
void HeightFieldAsset::SetMaxHeight(float height)
|
||||
{
|
||||
m_maxHeight = height;
|
||||
}
|
||||
|
||||
void HeightFieldAsset::ReleaseMemory()
|
||||
{
|
||||
if (m_heightField)
|
||||
{
|
||||
m_heightField->release();
|
||||
m_heightField = nullptr;
|
||||
}
|
||||
}
|
||||
} // namespace Pipeline
|
||||
} // namespace PhysX
|
||||
@@ -12,8 +12,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Asset/AssetManager.h>
|
||||
#include <AzCore/Asset/AssetTypeInfoBus.h>
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
|
||||
namespace physx
|
||||
{
|
||||
@@ -35,43 +34,21 @@ namespace PhysX
|
||||
AZ_CLASS_ALLOCATOR(HeightFieldAsset, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(HeightFieldAsset, "{B61189FE-B2D7-4AF1-8951-CB5C0F7834FC}", AZ::Data::AssetData);
|
||||
|
||||
~HeightFieldAsset()
|
||||
{
|
||||
ReleaseMemory();
|
||||
}
|
||||
~HeightFieldAsset();
|
||||
|
||||
physx::PxHeightField* GetHeightField()
|
||||
{
|
||||
return m_heightField;
|
||||
}
|
||||
physx::PxHeightField* GetHeightField();
|
||||
|
||||
const physx::PxHeightField* GetHeightField() const
|
||||
{
|
||||
return m_heightField;
|
||||
}
|
||||
const physx::PxHeightField* GetHeightField() const;
|
||||
|
||||
void SetHeightField(physx::PxHeightField* heightField)
|
||||
{
|
||||
ReleaseMemory();
|
||||
|
||||
m_heightField = heightField;
|
||||
m_status = AssetStatus::Ready;
|
||||
}
|
||||
void SetHeightField(physx::PxHeightField* heightField);
|
||||
|
||||
float GetMinHeight() const { return m_minHeight; }
|
||||
void SetMinHeight(float height) { m_minHeight = height; }
|
||||
float GetMaxHeight() const { return m_maxHeight; }
|
||||
void SetMaxHeight(float height) { m_maxHeight = height; }
|
||||
float GetMinHeight() const;
|
||||
void SetMinHeight(float height);
|
||||
float GetMaxHeight() const;
|
||||
void SetMaxHeight(float height);
|
||||
|
||||
private:
|
||||
void ReleaseMemory()
|
||||
{
|
||||
if (m_heightField)
|
||||
{
|
||||
m_heightField->release();
|
||||
m_heightField = nullptr;
|
||||
}
|
||||
}
|
||||
void ReleaseMemory();
|
||||
|
||||
physx::PxHeightField* m_heightField = nullptr;
|
||||
float m_minHeight = 0.0f;
|
||||
|
||||
@@ -30,11 +30,6 @@ namespace PhysX
|
||||
/// @return Asset pointer to mesh asset.
|
||||
virtual AZ::Data::Asset<Pipeline::MeshAsset> GetMeshAsset() const = 0;
|
||||
|
||||
/// Gets the mesh triangles as a list of verts and indices.
|
||||
/// @param verts The list of verts in the mesh
|
||||
/// @param indices The ordering of the verts into triangles
|
||||
virtual void GetStaticWorldSpaceMeshTriangles(AZStd::vector<AZ::Vector3>& verts, AZStd::vector<AZ::u32>& indices) const = 0;
|
||||
|
||||
/// Gets the material id from the material library for this entity.
|
||||
/// @return The asset ID to set it to.
|
||||
virtual Physics::MaterialId GetMaterialId() const = 0;
|
||||
@@ -54,4 +49,4 @@ namespace PhysX
|
||||
|
||||
/// Bus to service the PhysX Mesh Collider Component event group.
|
||||
using MeshColliderComponentRequestsBus = AZ::EBus<MeshColliderComponentRequests>;
|
||||
} // namespace PhysX
|
||||
} // namespace PhysX
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzFramework/Physics/RigidBody.h>
|
||||
#include <AzFramework/Physics/Shape.h>
|
||||
#include <AzFramework/Physics/SimulatedBodies/RigidBody.h>
|
||||
|
||||
namespace AzPhysics
|
||||
{
|
||||
@@ -48,11 +48,6 @@ namespace PhysX
|
||||
|
||||
virtual ~SystemRequests() = default;
|
||||
|
||||
/// Creates a new scene (world).
|
||||
/// @param sceneDesc Scene descriptor specifying details of scene to be created.
|
||||
/// @return Pointer to the created scene.
|
||||
virtual physx::PxScene* CreateScene(physx::PxSceneDesc& sceneDesc) = 0;
|
||||
|
||||
/// Creates a new convex mesh.
|
||||
/// @param vertices Pointer to beginning of vertex data.
|
||||
/// @param vertexNum Number of vertices in mesh.
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace physx
|
||||
{
|
||||
struct PxTriggerPair;
|
||||
}
|
||||
|
||||
namespace Physics
|
||||
{
|
||||
/// Created to decouple AzFramework/Physics from PhysX internals.
|
||||
class ITriggerEventCallback
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
namespace PhysX
|
||||
{
|
||||
/// A Low Level version of WorldEventHandler. Required for TouchBending
|
||||
/// to detect when actors with colliders touch the proximity trigger.
|
||||
class IPhysxTriggerEventCallback : public Physics::ITriggerEventCallback
|
||||
{
|
||||
public:
|
||||
/** @brief Notifies that something touched a trigger.
|
||||
*
|
||||
* The TouchBending Gem will check if it owns the trigger object.
|
||||
* If so, it will keep track of enter/exit count and kick off the
|
||||
* creation of the Tree.
|
||||
*
|
||||
* @param triggerPair As provided by PhysX
|
||||
* @returns TRUE if the callback is related with touch bending, otherwise
|
||||
* return FALSE for further processing by World.cpp
|
||||
*/
|
||||
virtual bool OnTriggerCallback(physx::PxTriggerPair* triggerPair) = 0;
|
||||
};
|
||||
}
|
||||
@@ -13,12 +13,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/EntityId.h>
|
||||
#include <AzFramework/Physics/WorldBody.h>
|
||||
#include <AzFramework/Physics/RigidBody.h>
|
||||
#include <AzFramework/Physics/Character.h>
|
||||
#include <AzFramework/Physics/Ragdoll.h>
|
||||
#include <AzFramework/Physics/SimulatedBodies/RigidBody.h>
|
||||
#include <AzFramework/Physics/SimulatedBodies/StaticRigidBody.h>
|
||||
#include <PxActor.h>
|
||||
|
||||
namespace AzPhysics
|
||||
{
|
||||
struct SimulatedBody;
|
||||
}
|
||||
|
||||
namespace PhysX
|
||||
{
|
||||
enum class BaseActorType : AZ::u32
|
||||
@@ -69,11 +74,13 @@ namespace PhysX
|
||||
AZ::EntityId GetEntityId() const;
|
||||
void SetEntityId(AZ::EntityId entityId);
|
||||
|
||||
Physics::RigidBody* GetRigidBody() const;
|
||||
void SetRigidBody(Physics::RigidBody* rigidBody);
|
||||
AzPhysics::SimulatedBodyHandle GetBodyHandle() const;
|
||||
|
||||
Physics::RigidBodyStatic* GetRigidBodyStatic() const;
|
||||
void SetRigidBodyStatic(Physics::RigidBodyStatic* rigidBody);
|
||||
AzPhysics::RigidBody* GetRigidBody() const;
|
||||
void SetRigidBody(AzPhysics::RigidBody* rigidBody);
|
||||
|
||||
AzPhysics::StaticRigidBody* GetRigidBodyStatic() const;
|
||||
void SetRigidBodyStatic(AzPhysics::StaticRigidBody* rigidBody);
|
||||
|
||||
Physics::Character* GetCharacter() const;
|
||||
void SetCharacter(Physics::Character* character);
|
||||
@@ -81,7 +88,7 @@ namespace PhysX
|
||||
Physics::RagdollNode* GetRagdollNode() const;
|
||||
void SetRagdollNode(Physics::RagdollNode* ragdollNode);
|
||||
|
||||
Physics::WorldBody* GetWorldBody() const;
|
||||
AzPhysics::SimulatedBody* GetWorldBody() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -89,8 +96,8 @@ namespace PhysX
|
||||
{
|
||||
AZ::EntityId m_entityId;
|
||||
// Possible references, only one of them is not nullptr
|
||||
Physics::RigidBody* m_rigidBody = nullptr;
|
||||
Physics::RigidBodyStatic* m_staticRigidBody = nullptr;
|
||||
AzPhysics::RigidBody* m_rigidBody = nullptr;
|
||||
AzPhysics::StaticRigidBody* m_staticRigidBody = nullptr;
|
||||
Physics::Character* m_character = nullptr;
|
||||
Physics::RagdollNode* m_ragdollNode = nullptr;
|
||||
void* m_externalUserData = nullptr;
|
||||
@@ -100,4 +107,4 @@ namespace PhysX
|
||||
};
|
||||
} // namespace PhysX
|
||||
|
||||
#include <PhysX/UserDataTypes.inl>
|
||||
#include <PhysX/UserDataTypes.inl>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include <AzFramework/Physics/Common/PhysicsSimulatedBody.h>
|
||||
|
||||
namespace PhysX
|
||||
{
|
||||
@@ -74,22 +75,32 @@ namespace PhysX
|
||||
m_payload.m_entityId = entityId;
|
||||
}
|
||||
|
||||
inline Physics::RigidBody* ActorData::GetRigidBody() const
|
||||
inline AzPhysics::SimulatedBodyHandle ActorData::GetBodyHandle() const
|
||||
{
|
||||
AzPhysics::SimulatedBody* body = GetWorldBody();
|
||||
if (body)
|
||||
{
|
||||
return body->m_bodyHandle;
|
||||
}
|
||||
return AzPhysics::InvalidSimulatedBodyHandle;
|
||||
}
|
||||
|
||||
inline AzPhysics::RigidBody* ActorData::GetRigidBody() const
|
||||
{
|
||||
return m_payload.m_rigidBody;
|
||||
}
|
||||
|
||||
inline void ActorData::SetRigidBody(Physics::RigidBody* rigidBody)
|
||||
inline void ActorData::SetRigidBody(AzPhysics::RigidBody* rigidBody)
|
||||
{
|
||||
m_payload.m_rigidBody = rigidBody;
|
||||
}
|
||||
|
||||
inline Physics::RigidBodyStatic* ActorData::GetRigidBodyStatic() const
|
||||
inline AzPhysics::StaticRigidBody* ActorData::GetRigidBodyStatic() const
|
||||
{
|
||||
return m_payload.m_staticRigidBody;
|
||||
}
|
||||
|
||||
inline void ActorData::SetRigidBodyStatic(Physics::RigidBodyStatic* rigidBody)
|
||||
inline void ActorData::SetRigidBodyStatic(AzPhysics::StaticRigidBody* rigidBody)
|
||||
{
|
||||
m_payload.m_staticRigidBody = rigidBody;
|
||||
}
|
||||
@@ -114,7 +125,7 @@ namespace PhysX
|
||||
m_payload.m_ragdollNode = ragdollNode;
|
||||
}
|
||||
|
||||
inline Physics::WorldBody* ActorData::GetWorldBody() const
|
||||
inline AzPhysics::SimulatedBody* ActorData::GetWorldBody() const
|
||||
{
|
||||
if (m_payload.m_rigidBody)
|
||||
{
|
||||
@@ -143,4 +154,4 @@ namespace PhysX
|
||||
}
|
||||
}
|
||||
// ActorData END ********************************************************
|
||||
} //namespace PhysX
|
||||
} //namespace PhysX
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
#include <PxMaterial.h>
|
||||
#include <PxShape.h>
|
||||
#include <PhysX/UserDataTypes.h>
|
||||
#include <AzFramework/Physics/Casts.h>
|
||||
#include <AzFramework/Physics/Shape.h>
|
||||
#include <AzFramework/Physics/Common/PhysicsSceneQueries.h>
|
||||
|
||||
namespace AzPhysics
|
||||
{
|
||||
class CollisionLayer;
|
||||
class CollisionGroup;
|
||||
class Scene;
|
||||
}
|
||||
|
||||
namespace Physics
|
||||
@@ -40,7 +41,7 @@ namespace PhysX
|
||||
ActorData* GetUserData(const physx::PxActor* actor);
|
||||
Physics::Material* GetUserData(const physx::PxMaterial* material);
|
||||
Physics::Shape* GetUserData(const physx::PxShape* shape);
|
||||
Physics::World* GetUserData(physx::PxScene* scene);
|
||||
AzPhysics::Scene* GetUserData(physx::PxScene* scene);
|
||||
|
||||
namespace Collision
|
||||
{
|
||||
@@ -50,13 +51,6 @@ namespace PhysX
|
||||
void SetCollisionLayerAndGroup(physx::PxShape* shape, const AzPhysics::CollisionLayer& layer, const AzPhysics::CollisionGroup& group);
|
||||
bool ShouldCollide(const physx::PxFilterData& filterData0, const physx::PxFilterData& filterData1);
|
||||
}
|
||||
|
||||
namespace RayCast
|
||||
{
|
||||
Physics::RayCastHit GetHitFromPxHit(const physx::PxLocationHit& pxHit);
|
||||
physx::PxHitFlags GetPxHitFlags(Physics::HitFlags hitFlags);
|
||||
Physics::RayCastHit ClosestRayHitAgainstPxRigidActor(const Physics::RayCastRequest& request, physx::PxRigidActor* actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "PhysXLocks.h"
|
||||
|
||||
#include <AzFramework/Physics/PhysicsScene.h>
|
||||
#include <AzFramework/Physics/Collision/CollisionGroups.h>
|
||||
#include <AzFramework/Physics/Collision/CollisionLayers.h>
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace PhysX
|
||||
}
|
||||
|
||||
ActorData* actorData = static_cast<ActorData*>(actor->userData);
|
||||
if (!actorData->IsValid())
|
||||
if (!actorData || !actorData->IsValid())
|
||||
{
|
||||
AZ_Warning("PhysX::Utils::GetUserData", false, "The actor data does not look valid and is not safe to use");
|
||||
return nullptr;
|
||||
@@ -43,9 +43,9 @@ namespace PhysX
|
||||
return (pxShape == nullptr) ? nullptr : static_cast<Physics::Shape*>(pxShape->userData);
|
||||
}
|
||||
|
||||
inline Physics::World* Utils::GetUserData(physx::PxScene* scene)
|
||||
inline AzPhysics::Scene* Utils::GetUserData(physx::PxScene* scene)
|
||||
{
|
||||
return scene ? static_cast<Physics::World*>(scene->userData) : nullptr;
|
||||
return scene ? static_cast<AzPhysics::Scene*>(scene->userData) : nullptr;
|
||||
}
|
||||
|
||||
inline AZ::u64 Utils::Collision::Combine(AZ::u32 word0, AZ::u32 word1)
|
||||
@@ -81,89 +81,4 @@ namespace PhysX
|
||||
AZ::u64 group1 = Combine(filterData1.word2, filterData1.word3);
|
||||
return (layer0 & group1) && (layer1 & group0);
|
||||
}
|
||||
|
||||
inline Physics::RayCastHit Utils::RayCast::GetHitFromPxHit(const physx::PxLocationHit& pxHit)
|
||||
{
|
||||
Physics::RayCastHit hit;
|
||||
|
||||
hit.m_distance = pxHit.distance;
|
||||
hit.m_position = PxMathConvert(pxHit.position);
|
||||
hit.m_normal = PxMathConvert(pxHit.normal);
|
||||
hit.m_body = Utils::GetUserData(pxHit.actor)->GetWorldBody();
|
||||
hit.m_shape = Utils::GetUserData(pxHit.shape);
|
||||
|
||||
if (pxHit.faceIndex != 0xFFFFffff)
|
||||
{
|
||||
PHYSX_SCENE_READ_LOCK(pxHit.actor->getScene());
|
||||
hit.m_material = Utils::GetUserData(pxHit.shape->getMaterialFromInternalFaceIndex(pxHit.faceIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
hit.m_material = hit.m_shape->GetMaterial().get();
|
||||
}
|
||||
|
||||
return hit;
|
||||
}
|
||||
|
||||
inline Physics::RayCastHit Utils::RayCast::ClosestRayHitAgainstPxRigidActor(const Physics::RayCastRequest& worldSpaceRequest, physx::PxRigidActor* actor)
|
||||
{
|
||||
const physx::PxVec3 start = PxMathConvert(worldSpaceRequest.m_start);
|
||||
const physx::PxVec3 unitDir = PxMathConvert(worldSpaceRequest.m_direction);
|
||||
const physx::PxU32 maxHits = 1;
|
||||
const physx::PxHitFlags hitFlags = Utils::RayCast::GetPxHitFlags(worldSpaceRequest.m_hitFlags);
|
||||
|
||||
physx::PxScene* scene = actor->getScene();
|
||||
physx::PxTransform actorTransform;
|
||||
{
|
||||
PHYSX_SCENE_READ_LOCK(scene);
|
||||
actorTransform = actor->getGlobalPose();
|
||||
}
|
||||
|
||||
Physics::RayCastHit closestHit;
|
||||
float closestHitDistance = FLT_MAX;
|
||||
|
||||
int numShapes = actor->getNbShapes();
|
||||
AZStd::vector<physx::PxShape*> shapes(numShapes);
|
||||
actor->getShapes(shapes.data(), numShapes);
|
||||
for (physx::PxShape* shape : shapes)
|
||||
{
|
||||
physx::PxTransform shapeTransform;
|
||||
{
|
||||
PHYSX_SCENE_READ_LOCK(scene);
|
||||
shapeTransform = actorTransform * shape->getLocalPose();
|
||||
}
|
||||
|
||||
physx::PxRaycastHit pxHitInfo;
|
||||
const bool hit = physx::PxGeometryQuery::raycast(start, unitDir, shape->getGeometry().any(), shapeTransform,
|
||||
worldSpaceRequest.m_distance, hitFlags, maxHits, &pxHitInfo);
|
||||
|
||||
if (hit && pxHitInfo.distance < closestHitDistance)
|
||||
{
|
||||
// Fill actor and shape, as they won't be filled from PxGeometryQuery
|
||||
pxHitInfo.actor = actor;
|
||||
pxHitInfo.shape = shape;
|
||||
closestHit = Utils::RayCast::GetHitFromPxHit(pxHitInfo);
|
||||
closestHitDistance = pxHitInfo.distance;
|
||||
}
|
||||
}
|
||||
return closestHit;
|
||||
}
|
||||
|
||||
inline physx::PxHitFlags Utils::RayCast::GetPxHitFlags(Physics::HitFlags hitFlags)
|
||||
{
|
||||
static_assert(
|
||||
static_cast<AZ::u16>(Physics::HitFlags::Position) == static_cast<AZ::u16>(physx::PxHitFlag::ePOSITION) &&
|
||||
static_cast<AZ::u16>(Physics::HitFlags::Normal) == static_cast<AZ::u16>(physx::PxHitFlag::eNORMAL) &&
|
||||
static_cast<AZ::u16>(Physics::HitFlags::UV) == static_cast<AZ::u16>(physx::PxHitFlag::eUV) &&
|
||||
static_cast<AZ::u16>(Physics::HitFlags::AssumeNoInitialOverlap) == static_cast<AZ::u16>(physx::PxHitFlag::eASSUME_NO_INITIAL_OVERLAP) &&
|
||||
static_cast<AZ::u16>(Physics::HitFlags::MeshMultiple) == static_cast<AZ::u16>(physx::PxHitFlag::eMESH_MULTIPLE) &&
|
||||
static_cast<AZ::u16>(Physics::HitFlags::MeshAny) == static_cast<AZ::u16>(physx::PxHitFlag::eMESH_ANY) &&
|
||||
static_cast<AZ::u16>(Physics::HitFlags::MeshBothSides) == static_cast<AZ::u16>(physx::PxHitFlag::eMESH_BOTH_SIDES) &&
|
||||
static_cast<AZ::u16>(Physics::HitFlags::PreciseSweep) == static_cast<AZ::u16>(physx::PxHitFlag::ePRECISE_SWEEP) &&
|
||||
static_cast<AZ::u16>(Physics::HitFlags::MTD) == static_cast<AZ::u16>(physx::PxHitFlag::eMTD) &&
|
||||
static_cast<AZ::u16>(Physics::HitFlags::FaceIndex) == static_cast<AZ::u16>(physx::PxHitFlag::eFACE_INDEX),
|
||||
"Physics::HitFlags values do not match the corresponding PhysX ones.");
|
||||
|
||||
return static_cast<physx::PxHitFlags>(static_cast<AZ::u16>(hitFlags));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user