PxConvexFlags;
+PX_FLAGS_OPERATORS(PxConvexFlag::Enum,PxU16)
+
+/**
+\brief Descriptor class for #PxConvexMesh.
+\note The number of vertices and the number of convex polygons in a cooked convex mesh is limited to 256.
+\note The number of vertices and the number of convex polygons in a GPU compatible convex mesh is limited to 64,
+and the number of faces per vertex is limited to 32.
+
+\see PxConvexMesh PxConvexMeshGeometry PxShape PxPhysics.createConvexMesh()
+
+*/
+class PxConvexMeshDesc
+{
+public:
+
+ /**
+ \brief Vertex positions data in PxBoundedData format.
+
+ Default: NULL
+ */
+ PxBoundedData points;
+
+ /**
+ \brief Polygons data in PxBoundedData format.
+ Pointer to first polygon.
+
+ Default: NULL
+
+ \see PxHullPolygon
+ */
+ PxBoundedData polygons;
+
+ /**
+ \brief Polygon indices data in PxBoundedData format.
+ Pointer to first index.
+
+ Default: NULL
+
+ This is declared as a void pointer because it is actually either an PxU16 or a PxU32 pointer.
+
+ \see PxHullPolygon PxConvexFlag::e16_BIT_INDICES
+ */
+ PxBoundedData indices;
+
+ /**
+ \brief Flags bits, combined from values of the enum ::PxConvexFlag
+
+ Default: 0
+ */
+ PxConvexFlags flags;
+
+ /**
+ \brief Limits the number of vertices of the result convex mesh. Hard maximum limit is 255
+ and minimum limit is 4 if PxConvexFlag::ePLANE_SHIFTING is used, otherwise the minimum
+ limit is 8.
+
+ \note The please see PxConvexFlag::ePLANE_SHIFTING for algorithm explanation
+ \note The maximum limit for GPU compatible convex meshes is 64.
+
+ \see PxConvexFlag::ePLANE_SHIFTING
+
+ Range: [4, 255]
+ Default: 255
+ */
+ PxU16 vertexLimit;
+
+ /**
+ \brief Limits the number of polygons of the result convex mesh. Hard maximum limit is 255
+ and minimum limit is 4.
+
+ \note The maximum limit for GPU compatible convex meshes is 64.
+
+ Range: [4, 255]
+ Default: 255
+ */
+ PxU16 polygonLimit;
+
+ /**
+ \brief Maximum number of vertices after quantization. The quantization is done during the vertex cleaning phase.
+ The quantization is applied when PxConvexFlag::eQUANTIZE_INPUT is specified.
+
+ \see PxConvexFlag::eQUANTIZE_INPUT
+
+ Range: [4, 65535]
+ Default: 255
+ */
+ PxU16 quantizedCount;
+
+ /**
+ \brief SDF descriptor. When this descriptor is set, signed distance field is calculated for this convex mesh.
+
+ Default: NULL
+ */
+ PxSDFDesc* sdfDesc;
+
+ /**
+ \brief constructor sets to default.
+ */
+ PX_INLINE PxConvexMeshDesc();
+ /**
+ \brief (re)sets the structure to the default.
+ */
+ PX_INLINE void setToDefault();
+
+
+ /**
+ \brief Returns true if the descriptor is valid.
+
+ \return True if the current settings are valid
+ */
+ PX_INLINE bool isValid() const;
+};
+
+PX_INLINE PxConvexMeshDesc::PxConvexMeshDesc() //constructor sets to default
+: vertexLimit(255), polygonLimit(255), quantizedCount(255), sdfDesc(NULL)
+{
+
+}
+
+PX_INLINE void PxConvexMeshDesc::setToDefault()
+{
+ *this = PxConvexMeshDesc();
+}
+
+PX_INLINE bool PxConvexMeshDesc::isValid() const
+{
+ // Check geometry
+ if(points.count < 3 || //at least 1 trig's worth of points
+ (points.count > 0xffff && flags & PxConvexFlag::e16_BIT_INDICES))
+ return false;
+ if(!points.data)
+ return false;
+ if(points.stride < sizeof(PxVec3)) //should be at least one point's worth of data
+ return false;
+ if (quantizedCount < 4)
+ return false;
+
+ // Check topology
+ if(polygons.data)
+ {
+ if(polygons.count < 4) // we require 2 neighbors for each vertex - 4 polygons at least
+ return false;
+
+ if(!indices.data) // indices must be provided together with polygons
+ return false;
+
+ PxU32 limit = (flags & PxConvexFlag::e16_BIT_INDICES) ? sizeof(PxU16) : sizeof(PxU32);
+ if(indices.stride < limit)
+ return false;
+
+ limit = sizeof(PxHullPolygon);
+ if(polygons.stride < limit)
+ return false;
+ }
+ else
+ {
+ // We can compute the hull from the vertices
+ if(!(flags & PxConvexFlag::eCOMPUTE_CONVEX))
+ return false; // If the mesh is convex and we're not allowed to compute the hull,
+ // you have to provide it completely (geometry & topology).
+ }
+
+ if((flags & PxConvexFlag::ePLANE_SHIFTING) && vertexLimit < 4)
+ {
+ return false;
+ }
+
+ if (!(flags & PxConvexFlag::ePLANE_SHIFTING) && vertexLimit < 8)
+ {
+ return false;
+ }
+
+ if(vertexLimit > 255)
+ {
+ return false;
+ }
+
+ if (polygonLimit < 4)
+ {
+ return false;
+ }
+
+ if (polygonLimit > 255)
+ {
+ return false;
+ }
+
+ if (sdfDesc && !sdfDesc->isValid())
+ {
+ return false;
+ }
+
+ return true;
+}
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxCooking.h b/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxCooking.h
new file mode 100644
index 000000000..4bfef7c9c
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxCooking.h
@@ -0,0 +1,908 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_COOKING_H
+#define PX_COOKING_H
+#include "common/PxPhysXCommonConfig.h"
+#include "common/PxTolerancesScale.h"
+#include "cooking/Pxc.h"
+
+#include "cooking/PxConvexMeshDesc.h"
+#include "cooking/PxTriangleMeshDesc.h"
+#include "cooking/PxTetrahedronMeshDesc.h"
+#include "cooking/PxMidphaseDesc.h"
+#include "cooking/PxBVHDesc.h"
+#include "geometry/PxTriangleMesh.h"
+#include "geometry/PxTetrahedronMesh.h"
+#include "geometry/PxBVH.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+class PxInsertionCallback;
+class PxFoundation;
+class PxAllocatorCallback;
+class PxHeightFieldDesc;
+
+/**
+\brief Result from convex cooking.
+*/
+struct PxConvexMeshCookingResult
+{
+ enum Enum
+ {
+ /**
+ \brief Convex mesh cooking succeeded.
+ */
+ eSUCCESS,
+
+ /**
+ \brief Convex mesh cooking failed, algorithm couldn't find 4 initial vertices without a small triangle.
+
+ \see PxCookingParams::areaTestEpsilon PxConvexFlag::eCHECK_ZERO_AREA_TRIANGLES
+ */
+ eZERO_AREA_TEST_FAILED,
+
+ /**
+ \brief Convex mesh cooking succeeded, but the algorithm has reached the 255 polygons limit.
+ The produced hull does not contain all input vertices. Try to simplify the input vertices
+ or try to use the eINFLATE_CONVEX or the eQUANTIZE_INPUT flags.
+
+ \see PxConvexFlag::eINFLATE_CONVEX PxConvexFlag::eQUANTIZE_INPUT
+ */
+ ePOLYGONS_LIMIT_REACHED,
+
+ /**
+ \brief Something unrecoverable happened. Check the error stream to find out what.
+ */
+ eFAILURE,
+
+ /**
+ \brief Convex mesh cooking succeeded, but the algorithm could not make the mesh GPU compatible because the
+ in-sphere radius is more than 100x smaller than the largest extent. Collision detection for any pair involving
+ this convex mesh will fall back to CPU.
+ */
+ eNON_GPU_COMPATIBLE
+ };
+};
+
+/** \brief Enumeration for convex mesh cooking algorithms. */
+struct PxConvexMeshCookingType
+{
+ enum Enum
+ {
+ /**
+ \brief The Quickhull algorithm constructs the hull from the given input points. The resulting hull
+ will only contain a subset of the input points.
+
+ */
+ eQUICKHULL
+ };
+};
+
+/**
+\brief Result from triangle mesh cooking
+*/
+struct PxTriangleMeshCookingResult
+{
+ enum Enum
+ {
+ /**
+ \brief Everything is A-OK.
+ */
+ eSUCCESS = 0,
+
+ /**
+ \brief A triangle is too large for well-conditioned results. Tessellate the mesh for better behavior, see the user guide section on cooking for more details.
+ */
+ eLARGE_TRIANGLE,
+
+ /**
+ \brief The mesh cleaning operation removed all triangles, resulting in an empty mesh.
+ */
+ eEMPTY_MESH,
+
+ /**
+ \brief Something unrecoverable happened. Check the error stream to find out what.
+ */
+ eFAILURE
+ };
+};
+
+/**
+\brief Enum for the set of mesh pre-processing parameters.
+*/
+struct PxMeshPreprocessingFlag
+{
+ enum Enum
+ {
+ /**
+ \brief When set, mesh welding is performed. See PxCookingParams::meshWeldTolerance. Mesh cleaning must be enabled.
+ */
+ eWELD_VERTICES = 1 << 0,
+
+ /**
+ \brief When set, mesh cleaning is disabled. This makes cooking faster.
+
+ When mesh cleaning is disabled, mesh welding is also disabled.
+
+ It is recommended to use only meshes that passed during validateTriangleMesh.
+ */
+ eDISABLE_CLEAN_MESH = 1 << 1,
+
+ /**
+ \brief When set, active edges are not computed and just enabled for all edges. This makes cooking faster but contact generation slower.
+ */
+ eDISABLE_ACTIVE_EDGES_PRECOMPUTE = 1 << 2,
+
+ /**
+ \brief When set, 32-bit indices will always be created regardless of triangle count.
+
+ \note By default mesh will be created with 16-bit indices for triangle count <= 0xFFFF and 32-bit otherwise.
+ */
+ eFORCE_32BIT_INDICES = 1 << 3,
+
+ /**
+ \brief When set, a list of triangles will be created for each associated vertex in the mesh.
+ */
+ eENABLE_VERT_MAPPING = 1 << 4,
+
+ /**
+ \brief When set, inertia data is calculated for the mesh, assuming unit density.
+ */
+ eENABLE_INERTIA = 1 << 5
+ };
+};
+
+typedef PxFlags PxMeshPreprocessingFlags;
+
+/**
+\brief Structure describing parameters affecting mesh cooking.
+
+\see PxSetCookingParams() PxGetCookingParams()
+*/
+struct PxCookingParams
+{
+ /**
+ \brief Zero-size area epsilon used in convex hull computation.
+
+ If the area of a triangle of the hull is below this value, the triangle will be rejected. This test
+ is done only if PxConvexFlag::eCHECK_ZERO_AREA_TRIANGLES is used.
+
+ \see PxConvexFlag::eCHECK_ZERO_AREA_TRIANGLES
+
+ Default value: 0.06f*PxTolerancesScale.length*PxTolerancesScale.length
+
+ Range: (0.0f, PX_MAX_F32)
+ */
+ float areaTestEpsilon;
+
+ /**
+ \brief Plane tolerance used in convex hull computation.
+
+ The value is used during hull construction. When a new point is about to be added to the hull it
+ gets dropped when the point is closer to the hull than the planeTolerance. The planeTolerance
+ is increased according to the hull size.
+
+ If 0.0f is set all points are accepted when the convex hull is created. This may lead to edge cases
+ where the new points may be merged into an existing polygon and the polygons plane equation might
+ slightly change therefore. This might lead to failures during polygon merging phase in the hull computation.
+
+ It is recommended to use the default value, however if it is required that all points needs to be
+ accepted or huge thin convexes are created, it might be required to lower the default value.
+
+ \note The plane tolerance is used only within PxConvexMeshCookingType::eQUICKHULL algorithm.
+
+ Default value: 0.0007f
+
+ Range: <0.0f, PX_MAX_F32)
+ */
+ float planeTolerance;
+
+ /**
+ \brief Convex hull creation algorithm.
+
+ Default value: PxConvexMeshCookingType::eQUICKHULL
+
+ \see PxConvexMeshCookingType
+ */
+ PxConvexMeshCookingType::Enum convexMeshCookingType;
+
+ /**
+ \brief When true, the face remap table is not created. This saves a significant amount of memory, but the SDK will
+ not be able to provide the remap information for internal mesh triangles returned by collisions,
+ sweeps or raycasts hits.
+
+ Default value: false
+ */
+ bool suppressTriangleMeshRemapTable;
+
+ /**
+ \brief When true, the triangle adjacency information is created. You can get the adjacency triangles
+ for a given triangle from getTriangle.
+
+ Default value: false
+ */
+ bool buildTriangleAdjacencies;
+
+ /**
+ \brief When true, additional information required for GPU-accelerated rigid body simulation is created. This can increase memory usage and cooking times for convex meshes and triangle meshes.
+
+ Default value: false
+ */
+ bool buildGPUData;
+
+ /**
+ \brief Tolerance scale is used to check if cooked triangles are not too huge. This check will help with simulation stability.
+
+ \note The PxTolerancesScale values have to match the values used when creating a PxPhysics or PxScene instance.
+
+ \see PxTolerancesScale
+ */
+ PxTolerancesScale scale;
+
+ /**
+ \brief Mesh pre-processing parameters. Used to control options like whether the mesh cooking performs vertex welding before cooking.
+
+ Default value: 0
+ */
+ PxMeshPreprocessingFlags meshPreprocessParams;
+
+ /**
+ \brief Mesh weld tolerance. If mesh welding is enabled, this controls the distance at which vertices are welded.
+ If mesh welding is not enabled, this value defines the acceptance distance for mesh validation. Provided no two vertices are within this distance, the mesh is considered to be
+ clean. If not, a warning will be emitted. Having a clean, welded mesh is required to achieve the best possible performance.
+
+ The default vertex welding uses a snap-to-grid approach. This approach effectively truncates each vertex to integer values using meshWeldTolerance.
+ Once these snapped vertices are produced, all vertices that snap to a given vertex on the grid are remapped to reference a single vertex. Following this,
+ all triangles' indices are remapped to reference this subset of clean vertices. It should be noted that the vertices that we do not alter the
+ position of the vertices; the snap-to-grid is only performed to identify nearby vertices.
+
+ The mesh validation approach also uses the same snap-to-grid approach to identify nearby vertices. If more than one vertex snaps to a given grid coordinate,
+ we ensure that the distance between the vertices is at least meshWeldTolerance. If this is not the case, a warning is emitted.
+
+ Default value: 0.0
+ */
+ PxReal meshWeldTolerance;
+
+ /**
+ \brief "Zero-area" epsilon used in mesh cleaning.
+
+ This is similar to areaTestEpsilon, but for the mesh cleaning operation.
+
+ If the area of a triangle is below this value, the triangle will be removed. This is only done when mesh cleaning is enabled,
+ i.e. when PxMeshPreprocessingFlag::eDISABLE_CLEAN_MESH is not set.
+
+ Default value is 0.0f to be consistent with previous PhysX versions, which only removed triangles whose area
+ was exactly zero.
+
+ \see PxMeshPreprocessingFlag::eDISABLE_CLEAN_MESH
+
+ Default value: 0.0f
+
+ Range: (0.0f, PX_MAX_F32)
+ */
+ PxReal meshAreaMinLimit;
+
+ /**
+ \brief Maximum edge length.
+
+ If an edge of a triangle is above this value, a warning is sent to the error stream. This is only a check,
+ corresponding triangles are not removed.
+
+ This is only done when mesh cleaning is enabled, i.e. when PxMeshPreprocessingFlag::eDISABLE_CLEAN_MESH is not set.
+
+ Default value is 500.0f to be consistent with previous PhysX versions. This value is internally multiplied by
+ PxTolerancesScale::length before being used. Use 0.0f to disable the checks.
+
+ \see PxMeshPreprocessingFlag::eDISABLE_CLEAN_MESH
+
+ Default value: 500.0f
+
+ Range: (0.0f, PX_MAX_F32)
+ */
+ PxReal meshEdgeLengthMaxLimit;
+
+ /**
+ \brief Controls the desired midphase desc structure for triangle meshes.
+
+ \see PxBVH33MidphaseDesc, PxBVH34MidphaseDesc, PxMidphaseDesc
+
+ Default value: PxMeshMidPhase::eBVH34
+ */
+ PxMidphaseDesc midphaseDesc;
+
+ /**
+ \brief Vertex limit beyond which additional acceleration structures are computed for each convex mesh. Increase that limit to reduce memory usage.
+ Computing the extra structures all the time does not guarantee optimal performance. There is a per-platform break-even point below which the
+ extra structures actually hurt performance.
+
+ Default value: 32
+ */
+ PxU32 gaussMapLimit;
+
+ /**
+ \brief Maximum mass ratio allowed on vertices touched by a single tet. If a any tetrahedron exceeds the mass ratio, the masses will get smoothed locally
+ until the maximum mass ratio is matched. Value should not be below 1. Smoothing might not fully converge for values <1.5. The smaller the maximum
+ allowed ratio, the better the stability during simulation.
+
+ Default value: FLT_MAX
+ */
+ PxReal maxWeightRatioInTet;
+
+ PxCookingParams(const PxTolerancesScale& sc):
+ areaTestEpsilon (0.06f*sc.length*sc.length),
+ planeTolerance (0.0007f),
+ convexMeshCookingType (PxConvexMeshCookingType::eQUICKHULL),
+ suppressTriangleMeshRemapTable (false),
+ buildTriangleAdjacencies (false),
+ buildGPUData (false),
+ scale (sc),
+ meshPreprocessParams (0),
+ meshWeldTolerance (0.0f),
+ meshAreaMinLimit (0.0f),
+ meshEdgeLengthMaxLimit (500.0f),
+ gaussMapLimit (32),
+ maxWeightRatioInTet (FLT_MAX)
+ {
+ }
+};
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+// Immediate cooking
+
+/**
+\brief Gets standalone object insertion interface.
+
+This interface allows the creation of standalone objects that can exist without a PxPhysics or PxScene object.
+
+\see PxCreateTriangleMesh PxCreateHeightfield PxCreateTetrahedronMesh PxCreateBVH
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxInsertionCallback* PxGetStandaloneInsertionCallback();
+
+// ==== BVH ====
+
+/**
+\brief Cooks a bounding volume hierarchy. The results are written to the stream.
+
+PxCookBVH() allows a BVH description to be cooked into a binary stream
+suitable for loading and performing BVH detection at runtime.
+
+\param[in] desc The BVH descriptor.
+\param[in] stream User stream to output the cooked data.
+\return true on success.
+
+\see PxBVH PxRigidActorExt::getRigidActorShapeLocalBoundsList
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API bool PxCookBVH(const physx::PxBVHDesc& desc, physx::PxOutputStream& stream);
+
+/**
+\brief Cooks and creates a bounding volume hierarchy without going through a stream.
+
+\note This method does the same as PxCookBVH, but the produced BVH is not stored
+into a stream but is either directly inserted in PxPhysics, or created as a standalone
+object. Use this method if you are unable to cook offline.
+
+\note PxInsertionCallback can be obtained through PxPhysics::getPhysicsInsertionCallback()
+or PxGetStandaloneInsertionCallback().
+
+\param[in] desc The BVH descriptor.
+\param[in] insertionCallback The insertion interface.
+\return PxBVH pointer on success
+
+\see PxCookBVH() PxInsertionCallback
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxBVH* PxCreateBVH(const physx::PxBVHDesc& desc, physx::PxInsertionCallback& insertionCallback);
+
+/**
+\brief Cooks and creates a bounding volume hierarchy without going through a stream. Convenience function for standalone objects.
+
+\note This method does the same as PxCookBVH, but the produced BVH is not stored
+into a stream but is either directly inserted in PxPhysics, or created as a standalone
+object. Use this method if you are unable to cook offline.
+
+\param[in] desc The BVH descriptor.
+\return PxBVH pointer on success
+
+\see PxCookBVH() PxInsertionCallback
+*/
+PX_FORCE_INLINE physx::PxBVH* PxCreateBVH(const physx::PxBVHDesc& desc)
+{
+ return PxCreateBVH(desc, *PxGetStandaloneInsertionCallback());
+}
+
+// ==== Heightfield ====
+
+/**
+\brief Cooks a heightfield. The results are written to the stream.
+
+To create a heightfield object there is an option to precompute some of calculations done while loading the heightfield data.
+
+PxCookHeightField() allows a heightfield description to be cooked into a binary stream
+suitable for loading and performing collision detection at runtime.
+
+\param[in] desc The heightfield descriptor to read the HF from.
+\param[in] stream User stream to output the cooked data.
+\return true on success
+
+\see PxPhysics.createHeightField()
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API bool PxCookHeightField(const physx::PxHeightFieldDesc& desc, physx::PxOutputStream& stream);
+
+/**
+\brief Cooks and creates a heightfield mesh and inserts it into PxPhysics.
+
+\param[in] desc The heightfield descriptor to read the HF from.
+\param[in] insertionCallback The insertion interface from PxPhysics.
+\return PxHeightField pointer on success
+
+\see PxCookHeightField() PxPhysics.createHeightField() PxInsertionCallback
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxHeightField* PxCreateHeightField(const physx::PxHeightFieldDesc& desc, physx::PxInsertionCallback& insertionCallback);
+
+/**
+\brief Cooks and creates a heightfield mesh and inserts it into PxPhysics. Convenience function for standalone objects.
+
+\param[in] desc The heightfield descriptor to read the HF from.
+\return PxHeightField pointer on success
+
+\see PxCookHeightField() PxPhysics.createHeightField() PxInsertionCallback
+*/
+PX_FORCE_INLINE physx::PxHeightField* PxCreateHeightField(const physx::PxHeightFieldDesc& desc)
+{
+ return PxCreateHeightField(desc, *PxGetStandaloneInsertionCallback());
+}
+
+// ==== Convex meshes ====
+
+/**
+\brief Cooks a convex mesh. The results are written to the stream.
+
+To create a triangle mesh object it is necessary to first 'cook' the mesh data into
+a form which allows the SDK to perform efficient collision detection.
+
+PxCookConvexMesh() allows a mesh description to be cooked into a binary stream
+suitable for loading and performing collision detection at runtime.
+
+\note The number of vertices and the number of convex polygons in a cooked convex mesh is limited to 255.
+\note If those limits are exceeded in either the user-provided data or the final cooked mesh, an error is reported.
+
+\param[in] params The cooking parameters
+\param[in] desc The convex mesh descriptor to read the mesh from.
+\param[in] stream User stream to output the cooked data.
+\param[out] condition Result from convex mesh cooking.
+\return true on success.
+
+\see PxCookTriangleMesh() PxConvexMeshCookingResult::Enum
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API bool PxCookConvexMesh(const physx::PxCookingParams& params, const physx::PxConvexMeshDesc& desc, physx::PxOutputStream& stream, physx::PxConvexMeshCookingResult::Enum* condition=NULL);
+
+/**
+\brief Cooks and creates a convex mesh without going through a stream.
+
+\note This method does the same as PxCookConvexMesh, but the produced mesh is not stored
+into a stream but is either directly inserted in PxPhysics, or created as a standalone
+object. Use this method if you are unable to cook offline.
+
+\note PxInsertionCallback can be obtained through PxPhysics::getPhysicsInsertionCallback()
+or PxGetStandaloneInsertionCallback().
+
+\param[in] params The cooking parameters
+\param[in] desc The convex mesh descriptor to read the mesh from.
+\param[in] insertionCallback The insertion interface from PxPhysics.
+\param[out] condition Result from convex mesh cooking.
+\return PxConvexMesh pointer on success
+
+\see PxCookConvexMesh() PxInsertionCallback
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxConvexMesh* PxCreateConvexMesh(const physx::PxCookingParams& params, const physx::PxConvexMeshDesc& desc, physx::PxInsertionCallback& insertionCallback, physx::PxConvexMeshCookingResult::Enum* condition=NULL);
+
+/**
+\brief Cooks and creates a convex mesh without going through a stream. Convenience function for standalone objects.
+
+\note This method does the same as cookConvexMesh, but the produced mesh is not stored
+into a stream but is either directly inserted in PxPhysics, or created as a standalone
+object. Use this method if you are unable to cook offline.
+
+\param[in] params The cooking parameters
+\param[in] desc The convex mesh descriptor to read the mesh from.
+\return PxConvexMesh pointer on success
+
+\see PxCookConvexMesh() PxInsertionCallback
+*/
+PX_FORCE_INLINE physx::PxConvexMesh* PxCreateConvexMesh(const physx::PxCookingParams& params, const physx::PxConvexMeshDesc& desc)
+{
+ return PxCreateConvexMesh(params, desc, *PxGetStandaloneInsertionCallback());
+}
+
+/**
+\brief Verifies if the convex mesh is valid. Prints an error message for each inconsistency found.
+
+The convex mesh descriptor must contain an already created convex mesh - the vertices, indices and polygons must be provided.
+
+\note This function should be used if PxConvexFlag::eDISABLE_MESH_VALIDATION is planned to be used in release builds.
+
+\param[in] params The cooking parameters
+\param[in] desc The convex mesh descriptor to read the mesh from.
+
+\return true if all the validity conditions hold, false otherwise.
+
+\see PxCookConvexMesh()
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API bool PxValidateConvexMesh(const physx::PxCookingParams& params, const physx::PxConvexMeshDesc& desc);
+
+/**
+\brief Compute hull polygons from given vertices and triangles. Polygons are needed for PxConvexMeshDesc rather than triangles.
+
+Please note that the resulting polygons may have different number of vertices. Some vertices may be removed.
+The output vertices, indices and polygons must be used to construct a hull.
+
+The provided PxAllocatorCallback does allocate the out arrays. It is the user responsibility to deallocated those arrays.
+
+\param[in] params The cooking parameters
+\param[in] mesh Simple triangle mesh containing vertices and triangles used to compute polygons.
+\param[in] inCallback Memory allocator for out array allocations.
+\param[out] nbVerts Number of vertices used by polygons.
+\param[out] vertices Vertices array used by polygons.
+\param[out] nbIndices Number of indices used by polygons.
+\param[out] indices Indices array used by polygons.
+\param[out] nbPolygons Number of created polygons.
+\param[out] hullPolygons Polygons array.
+\return true on success
+
+\see PxCookConvexMesh() PxConvexFlags PxConvexMeshDesc PxSimpleTriangleMesh
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API bool PxComputeHullPolygons(const physx::PxCookingParams& params, const physx::PxSimpleTriangleMesh& mesh, physx::PxAllocatorCallback& inCallback, physx::PxU32& nbVerts, physx::PxVec3*& vertices,
+ physx::PxU32& nbIndices, physx::PxU32*& indices, physx::PxU32& nbPolygons, physx::PxHullPolygon*& hullPolygons);
+
+// ==== Triangle meshes ====
+
+/**
+\brief Verifies if the triangle mesh is valid. Prints an error message for each inconsistency found.
+
+The following conditions are true for a valid triangle mesh:
+1. There are no duplicate vertices (within specified vertexWeldTolerance. See PxCookingParams::meshWeldTolerance)
+2. There are no large triangles (within specified PxTolerancesScale.)
+
+\param[in] params The cooking parameters
+\param[in] desc The triangle mesh descriptor to read the mesh from.
+
+\return true if all the validity conditions hold, false otherwise.
+
+\see PxCookTriangleMesh()
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API bool PxValidateTriangleMesh(const physx::PxCookingParams& params, const physx::PxTriangleMeshDesc& desc);
+
+/**
+\brief Cooks a triangle mesh. The results are written to the stream.
+
+To create a triangle mesh object it is necessary to first 'cook' the mesh data into
+a form which allows the SDK to perform efficient collision detection.
+
+PxCookTriangleMesh() allows a mesh description to be cooked into a binary stream
+suitable for loading and performing collision detection at runtime.
+
+\param[in] params The cooking parameters
+\param[in] desc The triangle mesh descriptor to read the mesh from.
+\param[in] stream User stream to output the cooked data.
+\param[out] condition Result from triangle mesh cooking.
+\return true on success
+
+\see PxCookConvexMesh() PxPhysics.createTriangleMesh() PxTriangleMeshCookingResult::Enum
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API bool PxCookTriangleMesh(const physx::PxCookingParams& params, const physx::PxTriangleMeshDesc& desc, physx::PxOutputStream& stream, physx::PxTriangleMeshCookingResult::Enum* condition=NULL);
+
+/**
+\brief Cooks and creates a triangle mesh without going through a stream.
+
+\note This method does the same as PxCookTriangleMesh, but the produced mesh is not stored
+into a stream but is either directly inserted in PxPhysics, or created as a standalone
+object. Use this method if you are unable to cook offline.
+
+\note PxInsertionCallback can be obtained through PxPhysics::getPhysicsInsertionCallback()
+or PxGetStandaloneInsertionCallback().
+
+\param[in] params The cooking parameters
+\param[in] desc The triangle mesh descriptor to read the mesh from.
+\param[in] insertionCallback The insertion interface from PxPhysics.
+\param[out] condition Result from triangle mesh cooking.
+\return PxTriangleMesh pointer on success.
+
+\see PxCookTriangleMesh() PxPhysics.createTriangleMesh() PxInsertionCallback
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxTriangleMesh* PxCreateTriangleMesh(const physx::PxCookingParams& params, const physx::PxTriangleMeshDesc& desc, physx::PxInsertionCallback& insertionCallback, physx::PxTriangleMeshCookingResult::Enum* condition=NULL);
+
+/**
+\brief Cooks and creates a triangle mesh without going through a stream. Convenience function for standalone objects.
+
+\note This method does the same as cookTriangleMesh, but the produced mesh is not stored
+into a stream but is either directly inserted in PxPhysics, or created as a standalone
+object. Use this method if you are unable to cook offline.
+\return PxTriangleMesh pointer on success.
+
+\param[in] params The cooking parameters
+\param[in] desc The triangle mesh descriptor to read the mesh from.
+
+\see PxCookTriangleMesh() PxPhysics.createTriangleMesh() PxInsertionCallback
+*/
+PX_FORCE_INLINE physx::PxTriangleMesh* PxCreateTriangleMesh(const physx::PxCookingParams& params, const physx::PxTriangleMeshDesc& desc)
+{
+ return PxCreateTriangleMesh(params, desc, *PxGetStandaloneInsertionCallback());
+}
+
+// ==== Tetrahedron & deformable volume meshes ====
+
+/**
+\brief Cooks a tetrahedron mesh. The results are written to the stream.
+
+To create a tetrahedron mesh object it is necessary to first 'cook' the mesh data into
+a form which allows the SDK to perform efficient collision detection.
+
+PxCookTetrahedronMesh() allows a mesh description to be cooked into a binary stream
+suitable for loading and performing collision detection at runtime.
+
+\param[in] params The cooking parameters
+\param[in] meshDesc The tetrahedron mesh descriptor to read the mesh from.
+\param[in] stream User stream to output the cooked data.
+\return true on success
+
+\see PxCookConvexMesh() PxPhysics.createTetrahedronMesh()
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API bool PxCookTetrahedronMesh(const physx::PxCookingParams& params, const physx::PxTetrahedronMeshDesc& meshDesc, physx::PxOutputStream& stream);
+
+/**
+\brief Cooks and creates a tetrahedron mesh without going through a stream.
+
+\note This method does the same as PxCookTetrahedronMesh, but the produced mesh is not stored
+into a stream but is either directly inserted in PxPhysics, or created as a standalone
+object. Use this method if you are unable to cook offline.
+
+\note PxInsertionCallback can be obtained through PxPhysics::getPhysicsInsertionCallback()
+or PxGetStandaloneInsertionCallback().
+
+\param[in] params The cooking parameters
+\param[in] meshDesc The tetrahedron mesh descriptor to read the mesh from.
+\param[in] insertionCallback The insertion interface from PxPhysics.
+\return PxTetrahedronMesh pointer on success.
+
+\see PxCookTetrahedronMesh() PxInsertionCallback
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxTetrahedronMesh* PxCreateTetrahedronMesh(const physx::PxCookingParams& params, const physx::PxTetrahedronMeshDesc& meshDesc, physx::PxInsertionCallback& insertionCallback);
+
+/**
+\brief Cooks and creates a tetrahedron mesh without going through a stream. Convenience function for standalone objects.
+
+\note This method does the same as PxCookTetrahedronMesh, but the produced mesh is not stored
+into a stream but is either directly inserted in PxPhysics, or created as a standalone
+object. Use this method if you are unable to cook offline.
+
+\param[in] params The cooking parameters
+\param[in] meshDesc The tetrahedron mesh descriptor to read the mesh from.
+\return PxTetrahedronMesh pointer on success.
+
+\see PxCookTetrahedronMesh() PxInsertionCallback
+*/
+PX_FORCE_INLINE physx::PxTetrahedronMesh* PxCreateTetrahedronMesh(const physx::PxCookingParams& params, const physx::PxTetrahedronMeshDesc& meshDesc)
+{
+ return PxCreateTetrahedronMesh(params, meshDesc, *PxGetStandaloneInsertionCallback());
+}
+
+/**
+\brief Cooks a deformable volume mesh. The results are written to the stream.
+
+To create a deformable volume mesh object it is necessary to first 'cook' the mesh data into
+a form which allows the SDK to perform efficient collision detection and to store data
+used during the FEM calculations.
+
+PxCookDeformableVolumeMesh() allows a mesh description to be cooked into a binary stream
+suitable for loading and performing collision detection at runtime.
+
+\param[in] params The cooking parameters
+\param[in] simulationMeshDesc The tetrahedron mesh descriptor to read the simulation mesh from.
+\param[in] collisionMeshDesc The tetrahedron mesh descriptor to read the collision mesh from.
+\param[in] simulationDataDesc The deformable volume data descriptor to read mapping information from.
+\param[in] stream User stream to output the cooked data.
+\return true on success
+
+\see PxCookConvexMesh() PxPhysics.createTriangleMesh() PxTriangleMeshCookingResult::Enum
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API bool PxCookDeformableVolumeMesh(const physx::PxCookingParams& params,
+ const physx::PxTetrahedronMeshDesc& simulationMeshDesc, const physx::PxTetrahedronMeshDesc& collisionMeshDesc,
+ const physx::PxDeformableVolumeSimulationDataDesc& simulationDataDesc, physx::PxOutputStream& stream);
+
+/**
+\brief Deprecated
+\see PxCookDeformableVolumeMesh
+*/
+PX_DEPRECATED PX_FORCE_INLINE bool PxCookSoftBodyMesh(const physx::PxCookingParams& params,
+ const physx::PxTetrahedronMeshDesc& simulationMeshDesc, const physx::PxTetrahedronMeshDesc& collisionMeshDesc,
+ const physx::PxDeformableVolumeSimulationDataDesc& simulationDataDesc, physx::PxOutputStream& stream)
+{
+ return PxCookDeformableVolumeMesh(params, simulationMeshDesc, collisionMeshDesc, simulationDataDesc, stream);
+}
+
+/**
+\brief Cooks and creates a deformable volume mesh without going through a stream.
+
+\note This method does the same as PxCookDeformableVolumeMesh, but the produced mesh is not stored
+into a stream but is either directly inserted in PxPhysics, or created as a standalone
+object. Use this method if you are unable to cook offline.
+
+\note PxInsertionCallback can be obtained through PxPhysics::getPhysicsInsertionCallback()
+or PxGetStandaloneInsertionCallback().
+
+\param[in] params The cooking parameters
+\param[in] simulationMeshDesc The tetrahedron mesh descriptor to read the simulation mesh from.
+\param[in] collisionMeshDesc The tetrahedron mesh descriptor to read the collision mesh from.
+\param[in] simulationDataDesc The deformable volume data descriptor to read mapping information from.
+\param[in] insertionCallback The insertion interface from PxPhysics.
+\return PxDeformableVolumeMesh pointer on success.
+
+\see PxCookTriangleMesh() PxPhysics.createTriangleMesh() PxInsertionCallback
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxDeformableVolumeMesh* PxCreateDeformableVolumeMesh(const physx::PxCookingParams& params,
+ const physx::PxTetrahedronMeshDesc& simulationMeshDesc, const physx::PxTetrahedronMeshDesc& collisionMeshDesc,
+ const physx::PxDeformableVolumeSimulationDataDesc& simulationDataDesc, physx::PxInsertionCallback& insertionCallback);
+
+/**
+\brief Deprecated
+\see PxCreateDeformableVolumeMesh
+*/
+PX_DEPRECATED PX_FORCE_INLINE physx::PxDeformableVolumeMesh* PxCreateSoftBodyMesh(const physx::PxCookingParams& params,
+ const physx::PxTetrahedronMeshDesc& simulationMeshDesc, const physx::PxTetrahedronMeshDesc& collisionMeshDesc,
+ const physx::PxDeformableVolumeSimulationDataDesc& simulationDataDesc, physx::PxInsertionCallback& insertionCallback)
+{
+ return PxCreateDeformableVolumeMesh(params, simulationMeshDesc, collisionMeshDesc, simulationDataDesc, insertionCallback);
+}
+
+/**
+\brief Cooks and creates a deformable volume mesh without going through a stream. Convenience function for standalone objects.
+
+\note This method does the same as PxCreateDeformableVolumeMesh, but the produced mesh is not stored
+into a stream but is either directly inserted in PxPhysics, or created as a standalone
+object. Use this method if you are unable to cook offline.
+
+\param[in] params The cooking parameters
+\param[in] simulationMeshDesc The tetrahedron mesh descriptor to read the simulation mesh from.
+\param[in] collisionMeshDesc The tetrahedron mesh descriptor to read the collision mesh from.
+\param[in] simulationDataDesc The deformable volume data descriptor to read mapping information from.
+\return PxDeformableVolumeMesh pointer on success.
+
+\see PxCookTriangleMesh() PxPhysics.createTriangleMesh() PxInsertionCallback
+*/
+PX_FORCE_INLINE physx::PxDeformableVolumeMesh* PxCreateDeformableVolumeMesh(const physx::PxCookingParams& params,
+ const physx::PxTetrahedronMeshDesc& simulationMeshDesc, const physx::PxTetrahedronMeshDesc& collisionMeshDesc,
+ const physx::PxDeformableVolumeSimulationDataDesc& simulationDataDesc)
+{
+ return PxCreateDeformableVolumeMesh(params, simulationMeshDesc, collisionMeshDesc, simulationDataDesc, *PxGetStandaloneInsertionCallback());
+}
+
+/**
+\brief Deprecated
+\see PxCreateDeformableVolumeMesh
+*/
+PX_DEPRECATED PX_FORCE_INLINE physx::PxDeformableVolumeMesh* PxCreateSoftBodyMesh(const physx::PxCookingParams& params,
+ const physx::PxTetrahedronMeshDesc& simulationMeshDesc, const physx::PxTetrahedronMeshDesc& collisionMeshDesc,
+ const physx::PxDeformableVolumeSimulationDataDesc& simulationDataDesc)
+{
+ return PxCreateDeformableVolumeMesh(params, simulationMeshDesc, collisionMeshDesc, simulationDataDesc, *PxGetStandaloneInsertionCallback());
+}
+
+/**
+\brief Computes the mapping between collision and simulation mesh
+
+The deformable volume deformation is computed on the simulation mesh. To deform the collision mesh accordingly
+it needs to be specified how its vertices need to be placed and updated inside the deformation mesh.
+This method computes that embedding information.
+
+\param[in] params The cooking parameters
+\param[in] simulationMesh A tetrahedral mesh that defines the shape of the simulation mesh which is used to compute the body's deformation
+\param[in] collisionMesh A tetrahedral mesh that defines the shape of the collision mesh which is used for collision detection
+\param[in] collisionData A data container that contains acceleration structures and surface information of the collision mesh
+\param[in] vertexToTet Optional indices (array of integers) that specifies the index of the tetrahedron in the simulation mesh that
+ contains a collision mesh vertex. If not provided, the embedding will be computed internally. If the simulation mesh is obtained from
+ PxTetMaker::createVoxelTetrahedronMesh, then the vertexToTet map createVoxelTetrahedronMesh returned should be used here.
+\return PxCollisionMeshMappingData pointer that describes how the collision mesh is embedded into the simulation mesh
+
+\see PxTetMaker::createVoxelTetrahedronMesh
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxCollisionMeshMappingData* PxComputeModelsMapping(const physx::PxCookingParams& params,
+ physx::PxTetrahedronMeshData& simulationMesh, const physx::PxTetrahedronMeshData& collisionMesh,
+ const physx::PxDeformableVolumeCollisionData& collisionData, const physx::PxBoundedData* vertexToTet = NULL);
+
+/**
+\brief Computes data to accelerate collision detection of tetrahedral meshes
+
+Computes data structures to speed up collision detection with tetrahedral meshes.
+
+\param[in] params The cooking parameters
+\param[in] collisionMeshDesc Raw tetrahedral mesh descriptor which will be used for collision detection
+\return PxCollisionTetrahedronMeshData pointer that describes the collision mesh
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxCollisionTetrahedronMeshData* PxComputeCollisionData(const physx::PxCookingParams& params,
+ const physx::PxTetrahedronMeshDesc& collisionMeshDesc);
+
+/**
+\brief Computes data to accelerate collision detection of tetrahedral meshes
+
+Computes data to compute and store a deformable volume's deformation using FEM.
+
+\param[in] params The cooking parameters
+\param[in] simulationMeshDesc Raw tetrahedral mesh descriptor which will be used for FEM simulation
+\return PxSimulationTetrahedronMeshData pointer that describes the simulation mesh
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxSimulationTetrahedronMeshData* PxComputeSimulationData(const physx::PxCookingParams& params,
+ const physx::PxTetrahedronMeshDesc& simulationMeshDesc);
+
+/**
+\brief Bundles all data required for deformable volume simulation
+
+Creates a container that provides everything to create a PxDeformableVolume
+
+\param[in] simulationMesh The geometry (tetrahedral mesh) to be used as simulation mesh
+\param[in] simulationData Additional non-tetmesh data that contains mass information etc. for the simulation mesh
+\param[in] collisionMesh The geometry (tetrahedral mesh) to be used for collision detection
+\param[in] collisionData Additional non-tetmesh data that contains surface information, acceleration structures etc. for the simulation mesh
+\param[in] mappingData Mapping that describes how the collision mesh's vertices are embedded into the simulation mesh
+\param[in] insertionCallback The insertion interface from PxPhysics.
+\return PxDeformableVolumeMesh pointer that represents a deformable volume mesh bundling all data (simulation mesh, collision mesh etc.)
+
+\see PxDeformableVolume createDeformableVolume()
+*/
+PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxDeformableVolumeMesh* PxAssembleDeformableVolumeMesh(physx::PxTetrahedronMeshData& simulationMesh,
+ physx::PxDeformableVolumeSimulationData& simulationData, physx::PxTetrahedronMeshData& collisionMesh, physx::PxDeformableVolumeCollisionData& collisionData,
+ physx::PxCollisionMeshMappingData& mappingData, physx::PxInsertionCallback& insertionCallback);
+
+/**
+\brief Deprecated
+\see PxAssembleDeformableVolumeMesh
+*/
+PX_DEPRECATED PX_FORCE_INLINE physx::PxDeformableVolumeMesh* PxAssembleSoftBodyMesh(physx::PxTetrahedronMeshData& simulationMesh,
+ physx::PxDeformableVolumeSimulationData& simulationData, physx::PxTetrahedronMeshData& collisionMesh, physx::PxDeformableVolumeCollisionData& collisionData,
+ physx::PxCollisionMeshMappingData& mappingData, physx::PxInsertionCallback& insertionCallback)
+{
+ return PxAssembleDeformableVolumeMesh(simulationMesh, simulationData, collisionMesh, collisionData, mappingData, insertionCallback);
+}
+
+/**
+\brief Deprecated
+\see PxAssembleDeformableVolumeMesh
+*/
+PX_DEPRECATED PX_FORCE_INLINE physx::PxDeformableVolumeMesh* PxAssembleSoftBodyMesh_Sim(physx::PxSimulationTetrahedronMeshData& simulationMesh,
+ physx::PxCollisionTetrahedronMeshData& collisionMesh, physx::PxCollisionMeshMappingData& mappingData, physx::PxInsertionCallback& insertionCallback)
+{
+ return PxAssembleDeformableVolumeMesh(*simulationMesh.getMesh(), *simulationMesh.getData(),
+ *collisionMesh.getMesh(), *collisionMesh.getData(), mappingData, insertionCallback);
+}
+
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxCookingInternal.h b/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxCookingInternal.h
new file mode 100644
index 000000000..27c20ff71
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxCookingInternal.h
@@ -0,0 +1,52 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_COOKING_INTERNAL_H
+#define PX_COOKING_INTERNAL_H
+
+#include "cooking/PxCooking.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+ struct PxTriangleMeshInternalData;
+ struct PxBVHInternalData;
+ class PxTriangleMesh;
+ class PxBVH;
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+ PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxTriangleMesh* PX_CALL_CONV PxCreateTriangleMeshInternal(const physx::PxTriangleMeshInternalData& data);
+
+ PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxBVH* PX_CALL_CONV PxCreateBVHInternal(const physx::PxBVHInternalData& data);
+
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxMidphaseDesc.h b/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxMidphaseDesc.h
new file mode 100644
index 000000000..27741cfae
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxMidphaseDesc.h
@@ -0,0 +1,118 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_MIDPHASE_DESC_H
+#define PX_MIDPHASE_DESC_H
+
+#include "geometry/PxTriangleMesh.h"
+#include "cooking/PxBVH33MidphaseDesc.h"
+#include "cooking/PxBVH34MidphaseDesc.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+
+\brief Structure describing parameters affecting midphase mesh structure.
+
+\see PxCookingParams, PxBVH33MidphaseDesc, PxBVH34MidphaseDesc
+*/
+class PxMidphaseDesc
+{
+public:
+ PX_FORCE_INLINE PxMidphaseDesc() { setToDefault(PxMeshMidPhase::eBVH34); }
+
+ /**
+ \brief Returns type of midphase mesh structure.
+ \return PxMeshMidPhase::Enum
+
+ \see PxMeshMidPhase::Enum
+ */
+ PX_FORCE_INLINE PxMeshMidPhase::Enum getType() const { return mType; }
+
+ /**
+ \brief Midphase descriptors union
+
+ \see PxBV33MidphaseDesc, PxBV34MidphaseDesc
+ */
+ union {
+ PxBVH33MidphaseDesc mBVH33Desc;
+ PxBVH34MidphaseDesc mBVH34Desc;
+ };
+
+ /**
+ \brief Initialize the midphase mesh structure descriptor
+ \param[in] type Midphase mesh structure descriptor
+
+ \see PxBV33MidphaseDesc, PxBV34MidphaseDesc
+ */
+ void setToDefault(PxMeshMidPhase::Enum type)
+ {
+ mType = type;
+ if(type==PxMeshMidPhase::eBVH33)
+ mBVH33Desc.setToDefault();
+ else if(type==PxMeshMidPhase::eBVH34)
+ mBVH34Desc.setToDefault();
+ }
+
+ /**
+ \brief Returns true if the descriptor is valid.
+ \return true if the current settings are valid.
+ */
+ bool isValid() const
+ {
+ if(mType==PxMeshMidPhase::eBVH33)
+ return mBVH33Desc.isValid();
+ else if(mType==PxMeshMidPhase::eBVH34)
+ return mBVH34Desc.isValid();
+ return false;
+ }
+
+ /**
+ \brief Assignment operator
+ \return this
+ */
+ PX_FORCE_INLINE PxMidphaseDesc& operator=(PxMeshMidPhase::Enum descType)
+ {
+ setToDefault(descType);
+ return *this;
+ }
+
+protected:
+ PxMeshMidPhase::Enum mType;
+};
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+
+#endif
+
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxSDFDesc.h b/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxSDFDesc.h
new file mode 100644
index 000000000..36e0ce3da
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxSDFDesc.h
@@ -0,0 +1,207 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_SDF_DESC_H
+#define PX_SDF_DESC_H
+
+#include "PxPhysXConfig.h"
+#include "geometry/PxSimpleTriangleMesh.h"
+#include "foundation/PxBounds3.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+ class PxSDFBuilder;
+
+ /**
+ \brief A helper structure to define dimensions in 3D
+ */
+ struct PxDim3
+ {
+ PxU32 x, y, z;
+ };
+
+ /**
+ \brief Defines the number of bits per subgrid pixel
+ */
+ class PxSdfBitsPerSubgridPixel
+ {
+ public:
+ enum Enum
+ {
+ e8_BIT_PER_PIXEL = 1, //!< 8 bit per subgrid pixel (values will be stored as normalized integers)
+ e16_BIT_PER_PIXEL = 2, //!< 16 bit per subgrid pixel (values will be stored as normalized integers)
+ e32_BIT_PER_PIXEL = 4 //!< 32 bit per subgrid pixel (values will be stored as floats in world scale units)
+ };
+ };
+
+ /**
+ \brief A structure describing signed distance fields (SDF) for triangle meshes. SDF colliders only work when the GPU solver is
+ used to run the simulation. The GPU solver is enabled by setting the flag PxSceneFlag::eENABLE_GPU_DYNAMICS in the scene description.
+ */
+ class PxSDFDesc
+ {
+ public:
+
+ /**
+ \brief Pointer to first sdf array element.
+ */
+ PxBoundedData sdf;
+
+ /**
+ \brief Dimensions of sdf
+ */
+ PxDim3 dims;
+
+ /**
+ \brief The Lower bound of the original mesh
+ */
+ PxVec3 meshLower;
+
+ /**
+ \brief The spacing of each sdf voxel
+ */
+ PxReal spacing;
+
+
+ /**
+ \brief The number of cells in a sparse subgrid block (full block has subgridSize^3 cells and (subgridSize+1)^3 samples). If set to zero, this indicates that only a dense background grid SDF is used without sparse blocks
+ */
+ PxU32 subgridSize;
+
+ /**
+ \brief Enumeration that defines the number of bits per subgrid pixel (either 32, 16 or 8bits)
+ */
+ PxSdfBitsPerSubgridPixel::Enum bitsPerSubgridPixel;
+
+ /**
+ \brief Number of subgrid blocks in the 3d texture. The full texture dimension will be sdfSubgrids3DTexBlockDim*(subgridSize+1).
+ */
+ PxDim3 sdfSubgrids3DTexBlockDim;
+
+ /**
+ \brief The data to create the 3d texture containg the packed subgrid blocks. Stored as PxU8 to support multiple formats (8, 16 and 32 bits per pixel)
+ */
+ PxBoundedData sdfSubgrids;
+
+ /**
+ \brief Array with start indices into the subgrid texture for every subgrid block. 10bits for z coordinate, 10bits for y and 10bits for x. Encoding is as follows: slot = (z << 20) | (y << 10) | x
+ */
+ PxBoundedData sdfStartSlots;
+
+ /**
+ \brief The minimum value over all subgrid blocks. Used if normalized textures are used which is the case for 8 and 16bit formats
+ */
+ PxReal subgridsMinSdfValue;
+
+ /**
+ \brief The maximum value over all subgrid blocks. Used if normalized textures are used which is the case for 8 and 16bit formats
+ */
+ PxReal subgridsMaxSdfValue;
+
+ /**
+ \brief The bounds of the sdf. If left unassigned (empty), the bounds of the mesh will be used
+ */
+ PxBounds3 sdfBounds;
+
+ /**
+ \brief Narrow band thickness as a fraction of the bounds diagonal length. Every subgrid block that
+ overlaps with the narrow band around the mesh surface will be kept providing high resolution around the mesh surface.
+ The valid range of this parameter is (0, 1). The higher the value, the more subgrids will get created, the more memory will be required.
+ */
+ PxReal narrowBandThicknessRelativeToSdfBoundsDiagonal;
+
+ /**
+ \brief The number of threads that are launched to compute the signed distance field
+ */
+ PxU32 numThreadsForSdfConstruction;
+
+ /**
+ \brief Optional pointer to the geometry of the mesh that is used to compute the SDF. If it is not set, the geometry of the mesh, that this descriptor is passed to during cooking, will be taken.
+ The mesh data must only be available during cooking. It can be released once cooking completed.
+ */
+ PxSimpleTriangleMesh baseMesh;
+
+ /**
+ \brief Optional pointer to an instance of a SDF builder. This significantly speeds up the construction of the SDF since the default SDF builder will do almost all computations directly on the GPU.
+ The user must release the instance of the SDF builder once cooking completed.
+ */
+ PxSDFBuilder* sdfBuilder;
+
+ /**
+ \brief Constructor
+ */
+ PX_INLINE PxSDFDesc();
+
+ /**
+ \brief Returns true if the descriptor is valid.
+ \return true if the current settings are valid
+ */
+ PX_INLINE bool isValid() const;
+ };
+
+ PX_INLINE PxSDFDesc::PxSDFDesc()
+ {
+ sdf.data = NULL;
+ dims.x = 0;
+ dims.y = 0;
+ dims.z = 0;
+ spacing = 0;
+ meshLower = PxVec3(PxZero);
+ subgridSize = 0;
+ subgridsMinSdfValue = 0.0f;
+ subgridsMaxSdfValue = 0.0f;
+ sdfBounds = PxBounds3::empty();
+ bitsPerSubgridPixel = PxSdfBitsPerSubgridPixel::e16_BIT_PER_PIXEL;
+ narrowBandThicknessRelativeToSdfBoundsDiagonal = 0.01f;
+ numThreadsForSdfConstruction = 1;
+ sdfBuilder = NULL;
+ }
+
+ PX_INLINE bool PxSDFDesc::isValid() const
+ {
+ // Check validity of user's input(if any)
+ if (sdf.data)
+ {
+ if (dims.x < 1 || dims.y < 1 || dims.z < 1)
+ return false;
+ if (!meshLower.isFinite())
+ return false;
+ if (spacing <= 0)
+ return false;
+ }
+
+ return true;
+ }
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxTetrahedronMeshDesc.h b/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxTetrahedronMeshDesc.h
new file mode 100644
index 000000000..15a426025
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxTetrahedronMeshDesc.h
@@ -0,0 +1,232 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_TETRAHEDRON_MESH_DESC_H
+#define PX_TETRAHEDRON_MESH_DESC_H
+
+#include "PxPhysXConfig.h"
+#include "foundation/PxVec3.h"
+#include "foundation/PxFlags.h"
+#include "common/PxCoreUtilityTypes.h"
+#include "geometry/PxSimpleTriangleMesh.h"
+#include "foundation/PxArray.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+ /**
+ \brief Descriptor class for #PxTetrahedronMesh (contains only pure geometric data).
+
+ \see PxTetrahedronMesh PxShape
+ */
+ class PxTetrahedronMeshDesc
+ {
+ public:
+
+ /**
+ \brief Defines the tetrahedron structure of a mesh.
+ */
+ enum PxMeshFormat
+ {
+ eTET_MESH, //!< Normal tetmesh with arbitrary tetrahedra
+ eHEX_MESH //!< 5 or 6 tetrahedra in a row will form a hexahedron
+ };
+
+
+ /**
+ Optional pointer to first material index, or NULL. There are PxTetrahedronMesh::numTriangles indices in total.
+ Caller may add materialIndexStride bytes to the pointer to access the next triangle.
+
+ When a tetrahedron mesh collides with another object, a material is required at the collision point.
+ If materialIndices is NULL, then the material of the PxShape instance is used.
+ Otherwise, if the point of contact is on a tetrahedron with index i, then the material index is determined as:
+ PxDeformableMaterialTableIndex index = *(PxDeformableMaterialTableIndex *)(((PxU8*)materialIndices) + materialIndexStride * i);
+
+ If the contact point falls on a vertex or an edge, a tetrahedron adjacent to the vertex or edge is selected, and its index
+ used to look up a material. The selection is arbitrary but consistent over time.
+
+ Default: NULL
+
+ \see materialIndexStride
+ */
+ PxTypedBoundedData materialIndices;
+
+ /**
+ \brief Pointer to first vertex point.
+ */
+ PxBoundedData points;
+
+ /**
+ \brief Pointer to first tetrahedron.
+
+ Caller may add tetrhedronStrideBytes bytes to the pointer to access the next tetrahedron.
+
+ These are quadruplets of 0 based indices:
+ vert0 vert1 vert2 vert3
+ vert0 vert1 vert2 vert3
+ vert0 vert1 vert2 vert3
+ ...
+
+ where vertex is either a 32 or 16 bit unsigned integer. There are numTetrahedrons*4 indices.
+
+ This is declared as a void pointer because it is actually either an PxU16 or a PxU32 pointer.
+ */
+ PxBoundedData tetrahedrons;
+
+
+ /**
+ \brief Flags bits, combined from values of the enum ::PxMeshFlag
+ */
+ PxMeshFlags flags;
+
+ /**
+ \brief Used for simulation meshes only. Defines if this tet mesh should be simulated as a tet mesh,
+ or if a set of tetrahedra should be used to represent another shape, e.g. a hexahedral mesh constructed
+ from 5 or 6 elements.
+ */
+ PxU16 tetsPerElement;
+
+ /**
+ \brief Constructor to build an empty tetmesh description
+ */
+ PxTetrahedronMeshDesc()
+ {
+ points.count = 0;
+ points.stride = 0;
+ points.data = NULL;
+
+ tetrahedrons.count = 0;
+ tetrahedrons.stride = 0;
+ tetrahedrons.data = NULL;
+
+ tetsPerElement = 1;
+ }
+
+ /**
+ \brief Constructor to build a tetmeshdescription that links to the vertices and indices provided
+ */
+ PxTetrahedronMeshDesc(physx::PxArray& meshVertices, physx::PxArray& meshTetIndices,
+ const PxTetrahedronMeshDesc::PxMeshFormat meshFormat = eTET_MESH, PxU16 numberOfTetsPerHexElement = 5)
+ {
+ points.count = meshVertices.size();
+ points.stride = sizeof(float) * 3;
+ points.data = meshVertices.begin();
+
+ tetrahedrons.count = meshTetIndices.size() / 4;
+ tetrahedrons.stride = sizeof(int) * 4;
+ tetrahedrons.data = meshTetIndices.begin();
+
+ if (meshFormat == eTET_MESH)
+ tetsPerElement = 1;
+ else
+ tetsPerElement = numberOfTetsPerHexElement;
+ }
+
+ PX_INLINE bool isValid() const
+ {
+ // Check geometry of the collision mesh
+ if (points.count < 4) //at least 1 tetrahedron's worth of points
+ return false;
+ if ((!tetrahedrons.data) && (points.count % 4)) // Non-indexed mesh => we must ensure the geometry defines an implicit number of tetrahedrons // i.e. numVertices can't be divided by 4
+ return false;
+ if (points.count > 0xffff && flags & PxMeshFlag::e16_BIT_INDICES)
+ return false;
+ if (!points.data)
+ return false;
+ if (points.stride < sizeof(PxVec3)) //should be at least one point's worth of data
+ return false;
+
+ //add more validity checks here
+ if (materialIndices.data && materialIndices.stride < sizeof(PxDeformableMaterialTableIndex))
+ return false;
+
+ // The tetrahedrons pointer is not mandatory
+ if (tetrahedrons.data)
+ {
+ // Indexed collision mesh
+ PxU32 limit = (flags & PxMeshFlag::e16_BIT_INDICES) ? sizeof(PxU16) * 4 : sizeof(PxU32) * 4;
+ if (tetrahedrons.stride < limit)
+ return false;
+ }
+
+ //The model can only be either a tetmesh (1 tet per element), or have 5 or 6 tets per hex element, otherwise invalid.
+ if (tetsPerElement != 1 && tetsPerElement != 5 && tetsPerElement != 6)
+ return false;
+
+ return true;
+ }
+ };
+
+ /**
+ \brief Descriptor class for #PxDeformableVolumeMesh (contains only additional data used for deformable volume simulation).
+
+ \see PxDeformableVolumeMesh PxShape
+ */
+ class PxDeformableVolumeSimulationDataDesc
+ {
+ public:
+ /**
+ \brief Pointer to first index of tetrahedron that contains the vertex at the same location in the vertex buffer.
+ if left unassigned it will be computed automatically. If a point is inside multiple tetrahedra (ambiguous case), the frist one found will be taken.
+ */
+ PxBoundedData vertexToTet;
+
+ /**
+ \brief Constructor to build an empty simulation description
+ */
+ PxDeformableVolumeSimulationDataDesc()
+ {
+ vertexToTet.count = 0;
+ vertexToTet.stride = 0;
+ vertexToTet.data = NULL;
+ }
+
+ /**
+ \brief Constructor to build a simulation description with a defined vertex to tetrahedron mapping
+ */
+ PxDeformableVolumeSimulationDataDesc(physx::PxArray& vertToTet)
+ {
+ vertexToTet.count = vertToTet.size();
+ vertexToTet.stride = sizeof(PxI32);
+ vertexToTet.data = vertToTet.begin();
+ }
+
+ PX_INLINE bool isValid() const
+ {
+ return true;
+ }
+ };
+
+ typedef PX_DEPRECATED PxDeformableVolumeSimulationDataDesc PxSoftBodySimulationDataDesc;
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxTriangleMeshDesc.h b/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxTriangleMeshDesc.h
new file mode 100644
index 000000000..68beb7e74
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/cooking/PxTriangleMeshDesc.h
@@ -0,0 +1,131 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_TRIANGLE_MESH_DESC_H
+#define PX_TRIANGLE_MESH_DESC_H
+
+#include "PxPhysXConfig.h"
+#include "geometry/PxSimpleTriangleMesh.h"
+#include "PxSDFDesc.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+
+/**
+\brief Descriptor class for #PxTriangleMesh.
+
+Note that this class is derived from PxSimpleTriangleMesh which contains the members that describe the basic mesh.
+The mesh data is *copied* when an PxTriangleMesh object is created from this descriptor. After the call the
+user may discard the triangle data.
+
+\see PxTriangleMesh PxTriangleMeshGeometry PxShape
+*/
+class PxTriangleMeshDesc : public PxSimpleTriangleMesh
+{
+public:
+
+ /**
+ Optional pointer to first material index, or NULL. There are PxSimpleTriangleMesh::numTriangles indices in total.
+ Caller may add materialIndexStride bytes to the pointer to access the next triangle.
+
+ When a triangle mesh collides with another object, a material is required at the collision point.
+ If materialIndices is NULL, then the material of the PxShape instance is used.
+ Otherwise, if the point of contact is on a triangle with index i, then the material index is determined as:
+ PxMaterialTableIndex index = *(PxMaterialTableIndex *)(((PxU8*)materialIndices) + materialIndexStride * i);
+
+ If the contact point falls on a vertex or an edge, a triangle adjacent to the vertex or edge is selected, and its index
+ used to look up a material. The selection is arbitrary but consistent over time.
+
+ Default: NULL
+
+ \see materialIndexStride
+ */
+ PxTypedBoundedData materialIndices;
+
+ /**
+ \brief SDF descriptor. When this descriptor is set, a signed distance field (SDF) is calculated. SDF collisions only
+ work when the GPU solver is used to run the simulation. The GPU solver is enabled by setting the flag PxSceneFlag::eENABLE_GPU_DYNAMICS in the scene description.
+
+ Default: NULL
+ */
+ PxSDFDesc* sdfDesc;
+
+ /**
+ \brief Constructor sets to default.
+ */
+ PX_INLINE PxTriangleMeshDesc();
+
+ /**
+ \brief (re)sets the structure to the default.
+ */
+ PX_INLINE void setToDefault();
+
+ /**
+ \brief Returns true if the descriptor is valid.
+ \return true if the current settings are valid
+ */
+ PX_INLINE bool isValid() const;
+};
+
+
+PX_INLINE PxTriangleMeshDesc::PxTriangleMeshDesc() //constructor sets to default
+{
+ PxSimpleTriangleMesh::setToDefault();
+ sdfDesc = NULL;
+}
+
+PX_INLINE void PxTriangleMeshDesc::setToDefault()
+{
+ *this = PxTriangleMeshDesc();
+}
+
+PX_INLINE bool PxTriangleMeshDesc::isValid() const
+{
+ if(points.count < 3) //at least 1 trig's worth of points
+ return false;
+ if ((!triangles.data) && (points.count%3)) // Non-indexed mesh => we must ensure the geometry defines an implicit number of triangles // i.e. numVertices can't be divided by 3
+ return false;
+ //add more validity checks here
+ if (materialIndices.data && materialIndices.stride < sizeof(PxMaterialTableIndex))
+ return false;
+
+ if (sdfDesc && !sdfDesc->isValid())
+ return false;
+
+ return PxSimpleTriangleMesh::isValid();
+}
+
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/cooking/Pxc.h b/Jusin154_Team3D/Engine/Public/PhysX/cooking/Pxc.h
new file mode 100644
index 000000000..d0866ca5c
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/cooking/Pxc.h
@@ -0,0 +1,55 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PXC_H
+#define PXC_H
+
+#include "foundation/PxPreprocessor.h"
+
+// define API function declaration
+#if !defined PX_PHYSX_STATIC_LIB
+ #if PX_WINDOWS_FAMILY
+ #if defined PX_PHYSX_COOKING_EXPORTS
+ #define PX_PHYSX_COOKING_API __declspec(dllexport)
+ #else
+ #define PX_PHYSX_COOKING_API __declspec(dllimport)
+ #endif
+ #elif PX_UNIX_FAMILY
+ #define PX_PHYSX_COOKING_API PX_UNIX_EXPORT
+ #endif
+#endif
+
+#if !defined(PX_PHYSX_COOKING_API)
+ #define PX_PHYSX_COOKING_API
+#endif
+
+#ifndef PX_C_EXPORT
+ #define PX_C_EXPORT extern "C"
+#endif
+
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/cudamanager/PxCudaContext.h b/Jusin154_Team3D/Engine/Public/PhysX/cudamanager/PxCudaContext.h
new file mode 100644
index 000000000..fcceea444
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/cudamanager/PxCudaContext.h
@@ -0,0 +1,192 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+
+#ifndef PX_CUDA_CONTEX_H
+#define PX_CUDA_CONTEX_H
+
+#include "foundation/PxPreprocessor.h"
+
+#if PX_SUPPORT_GPU_PHYSX
+
+#include "PxCudaTypes.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+ struct PxCudaKernelParam
+ {
+ void* data;
+ size_t size;
+ };
+
+ // workaround for not being able to forward declare enums in PxCudaTypes.h.
+ // provides different automatic casting depending on whether cuda.h was included beforehand or not.
+ template
+ struct PxCUenum
+ {
+ PxU32 value;
+
+ PxCUenum(CUenum e) { value = PxU32(e); }
+ operator CUenum() const { return CUenum(value); }
+ };
+
+#ifdef CUDA_VERSION
+ typedef PxCUenum PxCUjit_option;
+ typedef PxCUenum PxCUresult;
+#else
+ typedef PxCUenum PxCUjit_option;
+ typedef PxCUenum PxCUresult;
+#endif
+
+#define PX_CUDA_KERNEL_PARAM(X) { (void*)&X, sizeof(X) }
+#define PX_CUDA_KERNEL_PARAM2(X) (void*)&X
+
+ class PxDeviceAllocatorCallback;
+ /**
+ Cuda Context
+ */
+ class PxCudaContext
+ {
+ protected:
+ virtual ~PxCudaContext() {}
+
+ PxDeviceAllocatorCallback* mAllocatorCallback;
+
+ public:
+ virtual void release() = 0;
+
+ virtual PxCUresult memAlloc(CUdeviceptr *dptr, size_t bytesize) = 0;
+
+ virtual PxCUresult memFree(CUdeviceptr dptr) = 0;
+
+ virtual PxCUresult memHostAlloc(void **pp, size_t bytesize, unsigned int Flags) = 0;
+
+ virtual PxCUresult memFreeHost(void *p) = 0;
+
+ virtual PxCUresult memHostGetDevicePointer(CUdeviceptr *pdptr, void *p, unsigned int Flags) = 0;
+
+ virtual PxCUresult moduleLoadDataEx(CUmodule *module, const void *image, unsigned int numOptions, PxCUjit_option *options, void **optionValues) = 0;
+
+ virtual PxCUresult moduleGetFunction(CUfunction *hfunc, CUmodule hmod, const char *name) = 0;
+
+ virtual PxCUresult moduleUnload(CUmodule hmod) = 0;
+
+ virtual PxCUresult streamCreate(CUstream *phStream, unsigned int Flags) = 0;
+
+ virtual PxCUresult streamCreateWithPriority(CUstream *phStream, unsigned int flags, int priority) = 0;
+
+ virtual PxCUresult streamFlush(CUstream hStream) = 0;
+
+ virtual PxCUresult streamWaitEvent(CUstream hStream, CUevent hEvent, unsigned int Flags) = 0;
+
+ virtual PxCUresult streamWaitEvent(CUstream hStream, CUevent hEvent) = 0;
+
+ virtual PxCUresult streamDestroy(CUstream hStream) = 0;
+
+ virtual PxCUresult streamSynchronize(CUstream hStream) = 0;
+
+ virtual PxCUresult eventCreate(CUevent *phEvent, unsigned int Flags) = 0;
+
+ virtual PxCUresult eventRecord(CUevent hEvent, CUstream hStream) = 0;
+
+ virtual PxCUresult eventQuery(CUevent hEvent) = 0;
+
+ virtual PxCUresult eventSynchronize(CUevent hEvent) = 0;
+
+ virtual PxCUresult eventDestroy(CUevent hEvent) = 0;
+
+ virtual PxCUresult launchKernel(
+ CUfunction f,
+ unsigned int gridDimX,
+ unsigned int gridDimY,
+ unsigned int gridDimZ,
+ unsigned int blockDimX,
+ unsigned int blockDimY,
+ unsigned int blockDimZ,
+ unsigned int sharedMemBytes,
+ CUstream hStream,
+ PxCudaKernelParam* kernelParams,
+ size_t kernelParamsSizeInBytes,
+ void** extra,
+ const char* file,
+ int line
+ ) = 0;
+
+ // PT: same as above but without copying the kernel params to a local stack before the launch
+ // i.e. the kernelParams data is passed directly to the kernel.
+ virtual PxCUresult launchKernel(
+ CUfunction f,
+ PxU32 gridDimX, PxU32 gridDimY, PxU32 gridDimZ,
+ PxU32 blockDimX, PxU32 blockDimY, PxU32 blockDimZ,
+ PxU32 sharedMemBytes,
+ CUstream hStream,
+ void** kernelParams,
+ void** extra,
+ const char* file,
+ int line
+ ) = 0;
+
+ virtual PxCUresult memcpyDtoH(void *dstHost, CUdeviceptr srcDevice, size_t ByteCount) = 0;
+
+ virtual PxCUresult memcpyDtoHAsync(void* dstHost, CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream) = 0;
+
+ virtual PxCUresult memcpyHtoD(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount) = 0;
+
+ virtual PxCUresult memcpyHtoDAsync(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount, CUstream hStream) = 0;
+
+ virtual PxCUresult memcpyDtoDAsync(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream) = 0;
+
+ virtual PxCUresult memcpyDtoD(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount) = 0;
+
+ virtual PxCUresult memcpyPeerAsync(CUdeviceptr dstDevice, CUcontext dstContext, CUdeviceptr srcDevice, CUcontext srcContext, size_t ByteCount, CUstream hStream) = 0;
+
+ virtual PxCUresult memsetD32Async(CUdeviceptr dstDevice, unsigned int ui, size_t N, CUstream hStream) = 0;
+
+ virtual PxCUresult memsetD8Async(CUdeviceptr dstDevice, unsigned char uc, size_t N, CUstream hStream) = 0;
+
+ virtual PxCUresult memsetD32(CUdeviceptr dstDevice, unsigned int ui, size_t N) = 0;
+
+ virtual PxCUresult memsetD16(CUdeviceptr dstDevice, unsigned short uh, size_t N) = 0;
+
+ virtual PxCUresult memsetD8(CUdeviceptr dstDevice, unsigned char uc, size_t N) = 0;
+
+ virtual PxCUresult getLastError() = 0;
+
+ PxDeviceAllocatorCallback* getAllocatorCallback() { return mAllocatorCallback; }
+
+ virtual void setAbortMode(bool abort) = 0;
+
+ virtual bool isInAbortMode() = 0;
+ };
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+#endif // PX_SUPPORT_GPU_PHYSX
+#endif
+
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/cudamanager/PxCudaContextManager.h b/Jusin154_Team3D/Engine/Public/PhysX/cudamanager/PxCudaContextManager.h
new file mode 100644
index 000000000..90d7d70f7
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/cudamanager/PxCudaContextManager.h
@@ -0,0 +1,554 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+
+#ifndef PX_CUDA_CONTEXT_MANAGER_H
+#define PX_CUDA_CONTEXT_MANAGER_H
+
+#include "foundation/PxPreprocessor.h"
+
+#if PX_SUPPORT_GPU_PHYSX
+
+#include "foundation/PxSimpleTypes.h"
+#include "foundation/PxErrorCallback.h"
+#include "foundation/PxFlags.h"
+
+#include "PxCudaTypes.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+class PxCudaContext;
+
+struct PxCudaInteropRegisterFlag
+{
+ enum Enum
+ {
+ eNONE = 0x00,
+ eREAD_ONLY = 0x01,
+ eWRITE_DISCARD = 0x02,
+ eSURFACE_LDST = 0x04,
+ eTEXTURE_GATHER = 0x08
+ };
+};
+
+/**
+\brief An interface class that the user can implement in order for PhysX to use a user-defined device memory allocator.
+*/
+class PxDeviceAllocatorCallback
+{
+public:
+
+ /**
+ \brief Allocated device memory.
+ \param[in] ptr Pointer to store the allocated address
+ \param[in] size The amount of memory required
+ \return A boolean indicates the operation succeed or fail
+ */
+ virtual bool memAlloc(void** ptr, size_t size) = 0;
+
+ /**
+ \brief Frees device memory.
+ \param[in] ptr The memory to free
+ \return A boolean indicates the operation succeed or fail
+ */
+ virtual bool memFree(void* ptr) = 0;
+
+protected:
+ virtual ~PxDeviceAllocatorCallback() {}
+};
+/**
+\brief collection of set bits defined in NxCudaInteropRegisterFlag.
+
+\see NxCudaInteropRegisterFlag
+*/
+typedef PxFlags PxCudaInteropRegisterFlags;
+PX_FLAGS_OPERATORS(PxCudaInteropRegisterFlag::Enum, uint32_t)
+
+//! \brief Descriptor used to create a PxCudaContextManager
+class PxCudaContextManagerDesc
+{
+public:
+ /**
+ * \brief The CUDA context to manage
+ *
+ * If left NULL, the PxCudaContextManager will create a new context. If
+ * graphicsDevice is also not NULL, this new CUDA context will be bound to
+ * that graphics device, enabling the use of CUDA/Graphics interop features.
+ *
+ * If ctx is not NULL, the specified context must be applied to the thread
+ * that is allocating the PxCudaContextManager at creation time (aka, it
+ * cannot be popped). The PxCudaContextManager will take ownership of the
+ * context until the manager is released. All access to the context must be
+ * gated by lock acquisition.
+ *
+ * If the user provides a context for the PxCudaContextManager, the context
+ * _must_ have either been created on the GPU ordinal returned by
+ * PxGetSuggestedCudaDeviceOrdinal() or on your graphics device.
+ */
+ CUcontext* ctx;
+
+ /**
+ * \brief D3D device pointer or OpenGl context handle
+ *
+ * Only applicable when ctx is NULL, thus forcing a new context to be
+ * created. In that case, the created context will be bound to this
+ * graphics device.
+ */
+ void* graphicsDevice;
+
+ /**
+ * \brief CUDA device ordinal
+ *
+ * Only applicable when ctx is NULL, thus forcing a new context to be created based on the CUDA device ordinal.
+ * The first CUDA device will have an ordinal value of 0 and so on.
+ * If the CUDA device ordinal is -1, the device selected will be queried from the environment variable PHYSX_GPU_DEVICE.
+ * \note If the environment variable PHYSX_GPU_DEVICE is not found, the CUDA device ordinal will default to 0.
+ */
+ PxI32 deviceOrdinal;
+
+ /**
+ * \brief Application-specific GUID
+ *
+ * If your application employs PhysX modules that use CUDA you need to use a GUID
+ * so that patches for new architectures can be released for your game.You can obtain a GUID for your
+ * application from Nvidia.
+ */
+ const char* appGUID;
+
+ /**
+ * \brief Application-specific device memory allocator
+ *
+ * the application can implement an device memory allocator, which inherites PxDeviceAllocatorCallback, and
+ * pass that to the PxCudaContextManagerDesc. The SDK will use that allocator to allocate device memory instead of
+ * using the defaul CUDA device memory allocator.
+ */
+ PxDeviceAllocatorCallback* deviceAllocator;
+
+ PX_INLINE PxCudaContextManagerDesc() :
+ ctx (NULL),
+ graphicsDevice (NULL),
+ deviceOrdinal (-1),
+ appGUID (NULL),
+ deviceAllocator (NULL)
+ {
+ }
+};
+
+/**
+\brief A cuda kernel index providing an index to the cuda module and the function name
+*/
+struct PxKernelIndex
+{
+ PxU32 moduleIndex;
+ const char* functionName;
+};
+
+/**
+ * \brief Manages thread locks, and task scheduling for a CUDA context
+ *
+ * A PxCudaContextManager manages access to a single CUDA context, allowing it to
+ * be shared between multiple scenes.
+ * The context must be acquired from the manager before using any CUDA APIs unless stated differently.
+ *
+ * The PxCudaContextManager is based on the CUDA driver API and explicitly does not
+ * support the CUDA runtime API (aka, CUDART).
+ */
+class PxCudaContextManager
+{
+public:
+ /**
+ * \brief Schedules clear operation for a device memory buffer on the specified stream
+ *
+ * The cuda context will get acquired automatically
+ * \deprecated The replacement is PxCudaHelpersExt::memsetAsync.
+ */
+ template
+ PX_DEPRECATED void clearDeviceBufferAsync(T* deviceBuffer, PxU32 numElements, CUstream stream, PxI32 value = 0)
+ {
+ clearDeviceBufferAsyncInternal(deviceBuffer, numElements * sizeof(T), stream, value);
+ }
+
+ /**
+ * \brief Copies a device buffer to the host
+ *
+ * The cuda context will get acquired automatically
+ * \deprecated The replacement is PxCudaHelpersExt::copyDToH.
+ */
+ template
+ PX_DEPRECATED void copyDToH(T* hostBuffer, const T* deviceBuffer, PxU32 numElements)
+ {
+ copyDToHInternal(hostBuffer, deviceBuffer, numElements * sizeof(T));
+ }
+
+ /**
+ * \brief Copies a host buffer to the device
+ *
+ * The cuda context will get acquired automatically
+ * \deprecated The replacement is PxCudaHelpersExt::copyHtoD
+ */
+ template
+ PX_DEPRECATED void copyHToD(T* deviceBuffer, const T* hostBuffer, PxU32 numElements)
+ {
+ copyHToDInternal(deviceBuffer, hostBuffer, numElements * sizeof(T));
+ }
+
+ /**
+ * \brief Schedules device to host copy operation on the specified stream
+ *
+ * The cuda context will get acquired automatically
+ * \deprecated Use PxCudaHelpersExt::copyDToHAsync instead.
+ */
+ template
+ PX_DEPRECATED void copyDToHAsync(T* hostBuffer, const T* deviceBuffer, PxU32 numElements, CUstream stream)
+ {
+ copyDToHAsyncInternal(hostBuffer, deviceBuffer, numElements * sizeof(T), stream);
+ }
+
+ /**
+ * \brief Schedules host to device copy operation on the specified stream
+ *
+ * The cuda context will get acquired automatically
+ * \deprecated Use PxCudaHelpersExt::copyHToDAsync instead.
+ */
+ template
+ PX_DEPRECATED void copyHToDAsync(T* deviceBuffer, const T* hostBuffer, PxU32 numElements, CUstream stream)
+ {
+ copyHToDAsyncInternal(deviceBuffer, hostBuffer, numElements * sizeof(T), stream);
+ }
+
+ /**
+ * \brief Schedules device to device copy operation on the specified stream
+ *
+ * The cuda context will get acquired automatically
+ * \deprecated Use PxCudaHelpersExt::copyDToDAsync instead.
+ */
+ template
+ PX_DEPRECATED void copyDToDAsync(T* dstDeviceBuffer, const T* srcDeviceBuffer, PxU32 numElements, CUstream stream)
+ {
+ copyDToDAsyncInternal(dstDeviceBuffer, srcDeviceBuffer, numElements * sizeof(T), stream);
+ }
+
+ /**
+ * \brief Schedules a memset operation on the device on the specified stream. Only supported for 1 byte or 4 byte data types.
+ *
+ * The cuda context will get acquired automatically
+ * \deprecated Use PxCudaHelpersExt::memsetAsync instead.
+ */
+ template
+ PX_DEPRECATED void memsetAsync(T* dstDeviceBuffer, const T& value, PxU32 numElements, CUstream stream)
+ {
+ PX_COMPILE_TIME_ASSERT(sizeof(value) == sizeof(PxU32) || sizeof(value) == sizeof(PxU8));
+
+ if (sizeof(value) == sizeof(PxU32))
+ memsetD32AsyncInternal(dstDeviceBuffer, reinterpret_cast(value), numElements, stream);
+ else
+ memsetD8AsyncInternal(dstDeviceBuffer, reinterpret_cast(value), numElements, stream);
+ }
+
+ /**
+ * \brief Allocates a device buffer
+ *
+ * The cuda context will get acquired automatically
+ * \deprecated - use PxCudaHelpersExt::allocDeviceBuffer instead.
+ */
+ template
+ PX_DEPRECATED void allocDeviceBuffer(T*& deviceBuffer, PxU32 numElements, const char* filename = __FILE__, PxI32 line = __LINE__)
+ {
+ void* ptr = allocDeviceBufferInternal(PxU64(numElements) * sizeof(T), filename, line);
+ deviceBuffer = reinterpret_cast(ptr);
+ }
+
+ /**
+ * \brief Allocates a device buffer and returns the pointer to the memory
+ *
+ * The cuda context will get acquired automatically
+ * \deprecated - use PxCudaHelpersExt::allocDeviceBuffer instead.
+ */
+ template
+ PX_DEPRECATED T* allocDeviceBuffer(PxU32 numElements, const char* filename = __FILE__, PxI32 line = __LINE__)
+ {
+ void* ptr = allocDeviceBufferInternal(PxU64(numElements) * sizeof(T), filename, line);
+ return reinterpret_cast(ptr);
+ }
+
+ /**
+ * \brief Frees a device buffer
+ *
+ * The cuda context will get acquired automatically
+ * \deprecated - use PxCudaHelpersExt::freeDeviceBuffer instead.
+ */
+ template
+ PX_DEPRECATED void freeDeviceBuffer(T*& deviceBuffer)
+ {
+ freeDeviceBufferInternal(deviceBuffer);
+ deviceBuffer = NULL;
+ }
+
+ /**
+ * \brief Allocates a pinned host buffer
+ *
+ * A pinned host buffer can be used on the gpu after getting a mapped device pointer from the pinned host buffer pointer, see getMappedDevicePtr
+ * The cuda context will get acquired automatically
+ * \see getMappedDevicePtr
+ * \deprecated - use PxCudaHelpersExt::allocPinnedHostBuffer instead.
+ */
+ template
+ PX_DEPRECATED void allocPinnedHostBuffer(T*& pinnedHostBuffer, PxU32 numElements, const char* filename = __FILE__, PxI32 line = __LINE__)
+ {
+ void* ptr = allocPinnedHostBufferInternal(PxU64(numElements) * sizeof(T), filename, line);
+ pinnedHostBuffer = reinterpret_cast(ptr);
+ }
+
+ /**
+ * \brief Allocates a pinned host buffer and returns the pointer to the memory
+ *
+ * A pinned host buffer can be used on the gpu after getting a mapped device pointer from the pinned host buffer pointer, see getMappedDevicePtr
+ * The cuda context will get acquired automatically
+ * \deprecated - use PxCudaHelpersExt::allocPinnedHostBuffer instead.
+ * \see getMappedDevicePtr
+ */
+ template
+ PX_DEPRECATED T* allocPinnedHostBuffer(PxU32 numElements, const char* filename = __FILE__, PxI32 line = __LINE__)
+ {
+ void* ptr = allocPinnedHostBufferInternal(PxU64(numElements) * sizeof(T), filename, line);
+ return reinterpret_cast(ptr);
+ }
+
+ /**
+ * \brief Frees a pinned host buffer
+ *
+ * The cuda context will get acquired automatically
+ * \deprecated - use PxCudaHelpersExt::freePinnedHostBuffer instead.
+ */
+ template
+ PX_DEPRECATED void freePinnedHostBuffer(T*& pinnedHostBuffer)
+ {
+ freePinnedHostBufferInternal(pinnedHostBuffer);
+ pinnedHostBuffer = NULL;
+ }
+
+ /**
+ * \brief Gets a mapped pointer from a pinned host buffer that can be used in cuda kernels directly
+ *
+ * Data access performance with a mapped pinned host pointer will be slower than using a device pointer directly
+ * but the changes done in the kernel will be available on the host immediately.
+ * The cuda context will get acquired automatically
+ */
+ virtual CUdeviceptr getMappedDevicePtr(void* pinnedHostBuffer) = 0;
+
+ /**
+ * \brief Acquire the CUDA context for the current thread
+ *
+ * Acquisitions are allowed to be recursive within a single thread.
+ * You can acquire the context multiple times so long as you release
+ * it the same count.
+ *
+ * The context must be acquired before using most CUDA functions.
+ */
+ virtual void acquireContext() = 0;
+
+ /**
+ * \brief Acquire the CUDA context for the current thread
+ *
+ * Acquisitions are allowed to be recursive within a single thread.
+ * You can acquire the context multiple times so long as you release
+ * it the same count.
+ *
+ * The context must be acquired before using most CUDA functions.
+ * The function will return false if context aquisition fails for some reason
+ */
+ virtual bool tryAcquireContext() = 0;
+
+ /**
+ * \brief Release the CUDA context from the current thread
+ *
+ * The CUDA context should be released as soon as practically
+ * possible, to allow other CPU threads to work efficiently.
+ */
+ virtual void releaseContext() = 0;
+
+ /**
+ * \brief Return the CUcontext
+ */
+ virtual CUcontext getContext() = 0;
+
+ /**
+ * \brief Return the CudaContext
+ */
+ virtual PxCudaContext* getCudaContext() = 0;
+
+ /**
+ * \brief Context manager has a valid CUDA context
+ *
+ * This method should be called after creating a PxCudaContextManager,
+ * especially if the manager was responsible for allocating its own
+ * CUDA context (desc.ctx == NULL).
+ */
+ virtual bool contextIsValid() const = 0;
+
+ /* Query CUDA context and device properties, without acquiring context */
+
+ virtual bool supportsArchSM10() const = 0; //!< G80
+ virtual bool supportsArchSM11() const = 0; //!< G92
+ virtual bool supportsArchSM12() const = 0; //!< GT200
+ virtual bool supportsArchSM13() const = 0; //!< GT260
+ virtual bool supportsArchSM20() const = 0; //!< GF100
+ virtual bool supportsArchSM30() const = 0; //!< GK100
+ virtual bool supportsArchSM35() const = 0; //!< GK110
+ virtual bool supportsArchSM50() const = 0; //!< GM100
+ virtual bool supportsArchSM52() const = 0; //!< GM200
+ virtual bool supportsArchSM60() const = 0; //!< GP100
+ virtual bool isIntegrated() const = 0; //!< true if GPU is an integrated (MCP) part
+ virtual bool canMapHostMemory() const = 0; //!< true if GPU map host memory to GPU (0-copy)
+ virtual int getDriverVersion() const = 0; //!< returns cached value of cuGetDriverVersion()
+ virtual size_t getDeviceTotalMemBytes() const = 0; //!< returns cached value of device memory size
+ virtual int getMultiprocessorCount() const = 0; //!< returns cache value of SM unit count
+ virtual unsigned int getClockRate() const = 0; //!< returns cached value of SM clock frequency
+ virtual int getSharedMemPerBlock() const = 0; //!< returns total amount of shared memory available per block in bytes
+ virtual int getSharedMemPerMultiprocessor() const = 0; //!< returns total amount of shared memory available per multiprocessor in bytes
+ virtual unsigned int getMaxThreadsPerBlock() const = 0; //!< returns the maximum number of threads per block
+ virtual const char *getDeviceName() const = 0; //!< returns device name retrieved from driver
+ virtual CUdevice getDevice() const = 0; //!< returns device handle retrieved from driver
+
+ virtual void setUsingConcurrentStreams(bool) = 0; //!< turn on/off using concurrent streams for GPU work
+ virtual bool getUsingConcurrentStreams() const = 0; //!< true if GPU work can run in concurrent streams
+ /* End query methods that don't require context to be acquired */
+
+ virtual void getDeviceMemoryInfo(size_t& free, size_t& total) const = 0; //!< get currently available and total memory
+
+ /**
+ * \brief Get the cuda modules that have been loaded into this context on construction
+ * \return Pointer to the cuda modules
+ */
+ virtual CUmodule* getCuModules() = 0;
+
+ /**
+ * \brief Release the PxCudaContextManager
+ *
+ * If the PxCudaContextManager created the CUDA context it was
+ * responsible for, it also frees that context.
+ *
+ * Do not release the PxCudaContextManager if there are any scenes
+ * using it. Those scenes must be released first.
+ *
+ */
+ virtual void release() = 0;
+
+protected:
+
+ /**
+ * \brief protected destructor, use release() method
+ */
+ virtual ~PxCudaContextManager() {}
+
+ PX_DEPRECATED virtual void* allocDeviceBufferInternal(PxU64 numBytes, const char* filename = NULL, PxI32 line = -1) = 0;
+ PX_DEPRECATED virtual void* allocPinnedHostBufferInternal(PxU64 numBytes, const char* filename = NULL, PxI32 line = -1) = 0;
+
+ PX_DEPRECATED virtual void freeDeviceBufferInternal(void* deviceBuffer) = 0;
+ PX_DEPRECATED virtual void freePinnedHostBufferInternal(void* pinnedHostBuffer) = 0;
+
+ PX_DEPRECATED virtual void clearDeviceBufferAsyncInternal(void* deviceBuffer, PxU32 numBytes, CUstream stream, PxI32 value) = 0;
+
+ PX_DEPRECATED virtual void copyDToHAsyncInternal(void* hostBuffer, const void* deviceBuffer, PxU32 numBytes, CUstream stream) = 0;
+ PX_DEPRECATED virtual void copyHToDAsyncInternal(void* deviceBuffer, const void* hostBuffer, PxU32 numBytes, CUstream stream) = 0;
+ PX_DEPRECATED virtual void copyDToDAsyncInternal(void* dstDeviceBuffer, const void* srcDeviceBuffer, PxU32 numBytes, CUstream stream) = 0;
+
+ PX_DEPRECATED virtual void copyDToHInternal(void* hostBuffer, const void* deviceBuffer, PxU32 numBytes) = 0;
+ PX_DEPRECATED virtual void copyHToDInternal(void* deviceBuffer, const void* hostBuffer, PxU32 numBytes) = 0;
+
+ PX_DEPRECATED virtual void memsetD8AsyncInternal(void* dstDeviceBuffer, const PxU8& value, PxU32 numBytes, CUstream stream) = 0;
+ PX_DEPRECATED virtual void memsetD32AsyncInternal(void* dstDeviceBuffer, const PxU32& value, PxU32 numIntegers, CUstream stream) = 0;
+};
+
+// These macros are deprecated. Please use the functions in extensions/PxCudaHelpersExt.h
+/**
+ \deprecated Please use the functions in extensions/PxCudaHelpersExt.h
+ */
+#define PX_DEVICE_ALLOC(cudaContextManager, deviceBuffer, numElements) cudaContextManager->allocDeviceBuffer(deviceBuffer, numElements, PX_FL)
+
+/**
+ \deprecated Please use the functions in extensions/PxCudaHelpersExt.h
+ */
+#define PX_DEVICE_ALLOC_T(T, cudaContextManager, numElements) cudaContextManager->allocDeviceBuffer(numElements, PX_FL)
+
+/**
+ \deprecated Please use the functions in extensions/PxCudaHelpersExt.h
+ */
+#define PX_DEVICE_FREE(cudaContextManager, deviceBuffer) cudaContextManager->freeDeviceBuffer(deviceBuffer);
+
+/**
+ \deprecated Please use the functions in extensions/PxCudaHelpersExt.h
+ */
+#define PX_PINNED_HOST_ALLOC(cudaContextManager, pinnedHostBuffer, numElements) cudaContextManager->allocPinnedHostBuffer(pinnedHostBuffer, numElements, PX_FL)
+
+/**
+ \deprecated Please use the functions in extensions/PxCudaHelpersExt.h
+ */
+#define PX_PINNED_HOST_ALLOC_T(T, cudaContextManager, numElements) cudaContextManager->allocPinnedHostBuffer(numElements, PX_FL)
+
+/**
+ \deprecated Please use the functions in extensions/PxCudaHelpersExt.h
+ */
+#define PX_PINNED_HOST_FREE(cudaContextManager, pinnedHostBuffer) cudaContextManager->freePinnedHostBuffer(pinnedHostBuffer);
+
+/**
+ * \brief Convenience class for holding CUDA lock within a scope
+ */
+class PxScopedCudaLock
+{
+public:
+ /**
+ * \brief ScopedCudaLock constructor
+ */
+ PxScopedCudaLock(PxCudaContextManager& ctx) : mCtx(&ctx)
+ {
+ mCtx->acquireContext();
+ }
+
+ /**
+ * \brief ScopedCudaLock destructor
+ */
+ ~PxScopedCudaLock()
+ {
+ mCtx->releaseContext();
+ }
+
+protected:
+
+ /**
+ * \brief CUDA context manager pointer (initialized in the constructor)
+ */
+ PxCudaContextManager* mCtx;
+};
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+#endif // PX_SUPPORT_GPU_PHYSX
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/cudamanager/PxCudaTypes.h b/Jusin154_Team3D/Engine/Public/PhysX/cudamanager/PxCudaTypes.h
new file mode 100644
index 000000000..73959a310
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/cudamanager/PxCudaTypes.h
@@ -0,0 +1,71 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+
+#ifndef PX_CUDA_TYPES_H
+#define PX_CUDA_TYPES_H
+
+//type definitions to avoid forced inclusion of cuda.h
+//if cuda.h is needed anyway, please include it before PxCudaContextManager.h, PxCudaContext.h or PxCudaTypes.h
+
+#include "foundation/PxPreprocessor.h"
+
+#if PX_SUPPORT_GPU_PHYSX
+#ifndef CUDA_VERSION
+
+#include "foundation/PxSimpleTypes.h"
+
+#if PX_CLANG
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
+#endif
+
+#if PX_P64_FAMILY
+typedef unsigned long long CUdeviceptr;
+#else
+typedef unsigned int CUdeviceptr;
+#endif
+
+#if PX_CLANG
+#pragma clang diagnostic pop
+#endif
+
+typedef int CUdevice;
+
+typedef struct CUctx_st* CUcontext;
+typedef struct CUmod_st* CUmodule;
+typedef struct CUfunc_st* CUfunction;
+typedef struct CUstream_st* CUstream;
+typedef struct CUevent_st* CUevent;
+typedef struct CUgraphicsResource_st* CUgraphicsResource;
+
+#endif
+
+#else
+typedef struct CUstream_st* CUstream; // We declare some callbacks taking CUstream as an argument even when building with PX_SUPPORT_GPU_PHYSX = 0.
+typedef struct CUevent_st* CUevent;
+#endif // PX_SUPPORT_GPU_PHYSX
+#endif
+
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxBroadPhaseExt.h b/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxBroadPhaseExt.h
new file mode 100644
index 000000000..82ad54a8e
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxBroadPhaseExt.h
@@ -0,0 +1,70 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_BROAD_PHASE_EXT_H
+#define PX_BROAD_PHASE_EXT_H
+
+#include "PxPhysXConfig.h"
+#include "common/PxPhysXCommonConfig.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+class PxBounds3;
+#endif
+
+class PxBroadPhaseExt
+{
+public:
+
+ /**
+ \brief Creates regions for PxSceneDesc, from a global box.
+
+ This helper simply subdivides the given global box into a 2D grid of smaller boxes. Each one of those smaller boxes
+ is a region of interest for the broadphase. There are nbSubdiv*nbSubdiv regions in the 2D grid. The function does not
+ subdivide along the given up axis.
+
+ This is the simplest setup one can use with PxBroadPhaseType::eMBP. A more sophisticated setup would try to cover
+ the game world with a non-uniform set of regions (i.e. not just a grid).
+
+ \param[out] regions Regions computed from the input global box
+ \param[in] globalBounds World-space box covering the game world
+ \param[in] nbSubdiv Grid subdivision level. The function will create nbSubdiv*nbSubdiv regions.
+ \param[in] upAxis Up axis (0 for X, 1 for Y, 2 for Z).
+ \return number of regions written out to the 'regions' array
+
+ \see PxSceneDesc PxBroadPhaseType
+ */
+ static PxU32 createRegionsFromWorldBounds(PxBounds3* regions, const PxBounds3& globalBounds, PxU32 nbSubdiv, PxU32 upAxis=1);
+};
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxCollectionExt.h b/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxCollectionExt.h
new file mode 100644
index 000000000..e29140abb
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxCollectionExt.h
@@ -0,0 +1,115 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_COLLECTION_EXT_H
+#define PX_COLLECTION_EXT_H
+
+#include "PxPhysXConfig.h"
+#include "common/PxCollection.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+ class PxCollection;
+ class PxScene;
+
+ class PxCollectionExt
+ {
+ public:
+ /**
+ \brief Removes and releases all object from a collection.
+
+ The Collection itself is not released.
+
+ If the releaseExclusiveShapes flag is not set to true, release() will not be called on exclusive shapes.
+
+ It is assumed that the application holds a reference to each of the objects in the collection, with the exception of objects that are not releasable
+ (PxBase::isReleasable()). In general, objects that violate this assumption need to be removed from the collection prior to calling releaseObjects.
+
+ \note when a shape is created with PxRigidActorExt::createExclusiveShape(), the only counted reference is held by the actor.
+ If such a shape and its actor are present in the collection, the reference count will be decremented once when the actor is released, and once when the
+ shape is released, resulting in undefined behavior. Shape reference counts can be incremented with PxShape::acquireReference().
+
+ \param[in] collection to remove and release all object from.
+ \param[in] releaseExclusiveShapes if this parameter is set to false, release() will not be called on exclusive shapes.
+ */
+ static void releaseObjects(PxCollection& collection, bool releaseExclusiveShapes = true);
+
+ /**
+ \brief Removes objects of a given type from a collection, potentially adding them to another collection.
+
+ \param[in,out] collection Collection from which objects are removed
+ \param[in] concreteType PxConcreteType of sdk objects that should be removed
+ \param[in,out] to Optional collection to which the removed objects are added
+
+ \see PxCollection, PxConcreteType
+ */
+ static void remove(PxCollection& collection, PxType concreteType, PxCollection* to = NULL);
+
+ /**
+ \brief Collects all objects in PxPhysics that are shareable across multiple scenes.
+
+ This function creates a new collection from all objects that are shareable across multiple
+ scenes. Instances of the following types are included: PxConvexMesh, PxTriangleMesh,
+ PxHeightField, PxShape and PxMaterial.
+
+ This is a helper function to ease the creation of collections for serialization.
+
+ \param[in] physics The physics SDK instance from which objects are collected. See #PxPhysics
+ \return Collection to which objects are added. See #PxCollection
+
+ \see PxCollection, PxPhysics
+ */
+ static PxCollection* createCollection(PxPhysics& physics);
+
+ /**
+ \brief Collects all objects from a PxScene.
+
+ This function creates a new collection from all objects that were added to the specified
+ PxScene. Instances of the following types are included: PxActor, PxAggregate,
+ PxArticulationReducedCoordinate and PxJoint (other PxConstraint types are not included).
+
+ This is a helper function to ease the creation of collections for serialization.
+ The function PxSerialization.complete() can be used to complete the collection with required objects prior to
+ serialization.
+
+ \param[in] scene The PxScene instance from which objects are collected. See #PxScene
+ \return Collection to which objects are added. See #PxCollection
+
+ \see PxCollection, PxScene, PxSerialization.complete()
+ */
+ static PxCollection* createCollection(PxScene& scene);
+ };
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxConstraintExt.h b/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxConstraintExt.h
new file mode 100644
index 000000000..7a63a062e
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxConstraintExt.h
@@ -0,0 +1,63 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_CONSTRAINT_EXT_H
+#define PX_CONSTRAINT_EXT_H
+
+#include "foundation/PxPreprocessor.h"
+
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+/**
+\brief Unique identifiers for extensions classes which implement a constraint based on PxConstraint.
+
+\note Users which want to create their own custom constraint types should choose an ID larger or equal to eNEXT_FREE_ID
+and not eINVALID_ID.
+
+\see PxConstraint PxSimulationEventCallback.onConstraintBreak()
+*/
+struct PxConstraintExtIDs
+{
+ enum Enum
+ {
+ eJOINT,
+ eVEHICLE_JOINT,
+ eNEXT_FREE_ID,
+ eINVALID_ID = 0x7fffffff
+ };
+};
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxConvexCoreExt.h b/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxConvexCoreExt.h
new file mode 100644
index 000000000..0b84e3cd7
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxConvexCoreExt.h
@@ -0,0 +1,76 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_CONVEX_GEOMETRY_EXT_H
+#define PX_CONVEX_GEOMETRY_EXT_H
+
+#include "foundation/PxMat33.h"
+#include "foundation/PxTransform.h"
+#include "geometry/PxConvexCoreGeometry.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+class PxBounds3;
+class PxRenderOutput;
+
+/**
+\brief Convex geometry helpers
+*/
+class PxConvexCoreExt
+{
+public:
+
+ /**
+ \brief Compute mass properties of the convex core geometry.
+ \param convex The convex geometry.
+ \param[out] density1Mass The mass of the geometry assuming unit density.
+ \param[out] inertiaTensor The inertia tensor of the geometry.
+ \param[out] centerOfMass The center of mass of the geometry.
+ */
+ static void computeMassInfo(const PxConvexCoreGeometry& convex, PxReal& density1Mass, PxMat33& inertiaTensor, PxVec3& centerOfMass);
+
+ /**
+ \brief Visualize the convex core geometry
+ \param convex The convex geometry.
+ \param pose The pose of the geometry in world space
+ \param drawCore If true, draw the core inside the full convex geometry including the margin
+ \param cullbox The culling box for visualization
+ \param out The render output object to use for visualization
+ */
+ static void visualize(const PxConvexCoreGeometry& convex, const PxTransform& pose, bool drawCore, const PxBounds3& cullbox, PxRenderOutput& out);
+
+};
+
+#if !PX_DOXYGEN
+}
+#endif
+
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxConvexMeshExt.h b/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxConvexMeshExt.h
new file mode 100644
index 000000000..907e1d9b8
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxConvexMeshExt.h
@@ -0,0 +1,68 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_CONVEX_MESH_EXT_H
+#define PX_CONVEX_MESH_EXT_H
+
+#include "PxPhysXConfig.h"
+#include "common/PxPhysXCommonConfig.h"
+#include "foundation/PxTransform.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+ class PxConvexMeshGeometry;
+
+ /**
+ \brief Computes closest polygon of the convex hull geometry for a given impact point
+ and impact direction. When doing sweeps against a scene, one might want to delay
+ the rather expensive computation of the hit face index for convexes until it is clear
+ the information is really needed and then use this method to get the corresponding
+ face index.
+
+ \param[in] convexGeom The convex mesh geometry.
+ \param[in] geomPose Pose for the geometry object.
+ \param[in] impactPos Impact position.
+ \param[in] unitDir Normalized impact direction.
+
+ \return Closest face index of the convex geometry.
+
+ \see PxTransform PxConvexMeshGeometry
+ */
+ PxU32 PxFindFaceIndex(const PxConvexMeshGeometry& convexGeom,
+ const PxTransform& geomPose,
+ const PxVec3& impactPos,
+ const PxVec3& unitDir);
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+#endif
diff --git a/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxCudaHelpersExt.h b/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxCudaHelpersExt.h
new file mode 100644
index 000000000..03734be7a
--- /dev/null
+++ b/Jusin154_Team3D/Engine/Public/PhysX/extensions/PxCudaHelpersExt.h
@@ -0,0 +1,317 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of NVIDIA CORPORATION nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#ifndef PX_CUDA_HELPERS_EXT_H
+#define PX_CUDA_HELPERS_EXT_H
+
+
+#include "foundation/PxPreprocessor.h"
+
+#if PX_SUPPORT_GPU_PHYSX
+#include "foundation/PxSimpleTypes.h"
+#include "foundation/PxAssert.h"
+#include "foundation/PxFoundation.h"
+#include "cudamanager/PxCudaContextManager.h"
+#include "cudamanager/PxCudaContext.h"
+#include "cudamanager/PxCudaTypes.h"
+
+
+namespace physx
+{
+namespace Ext
+{
+
+class PxCudaHelpersExt
+{
+public:
+
+/**
+* \brief Allocates a device buffer and returns the pointer to the memory
+*
+* The cuda context will get acquired automatically
+*
+* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context the allocation should be attributed to.
+* \param[in] numElements the number of elements of type T to allocate.
+*
+* \return a pointer to the allocated memory.
+*/
+template
+static T* allocDeviceBuffer(PxCudaContextManager& cudaContextManager, PxU64 numElements)
+{
+ PxScopedCudaLock lock(cudaContextManager);
+
+ CUdeviceptr ptr = 0;
+ PxCUresult result = cudaContextManager.getCudaContext()->memAlloc(&ptr, numElements * sizeof(T));
+ if (result != 0)
+ PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "allocDeviceBuffer failed with error code %i!\n", PxI32(result));
+
+ return reinterpret_cast(ptr);
+}
+
+/**
+* \brief Frees a device buffer
+*
+* The cuda context will get acquired automatically
+*
+* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context the device buffer is attributed to.
+* \param[in] deviceBuffer reference to a pointer pointing to the device memory buffer.
+*/
+template
+static void freeDeviceBuffer(PxCudaContextManager& cudaContextManager, T*& deviceBuffer)
+{
+ if (deviceBuffer)
+ {
+ PxScopedCudaLock lock(cudaContextManager);
+ PxCUresult result = cudaContextManager.getCudaContext()->memFree(reinterpret_cast(deviceBuffer));
+ if (result != 0)
+ PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "freeDeviceBuffer failed with error code %i!\n", PxI32(result));
+
+ deviceBuffer = NULL;
+ }
+}
+
+/**
+* \brief Allocates a pinned host buffer and returns the pointer to the memory
+*
+* A pinned host buffer can be used on the gpu after getting a mapped device pointer from the pinned host buffer pointer, see getMappedDevicePtr
+* The cuda context will get acquired automatically
+*
+* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context the allocation should be attributed to.
+* \param[in] numElements the number of elements of type T to allocate.
+*
+* \return a pointer to the allocated memory.
+*/
+template
+static T* allocPinnedHostBuffer(PxCudaContextManager& cudaContextManager, PxU64 numElements)
+{
+ PxScopedCudaLock lock(cudaContextManager);
+
+ void* ptr = NULL;
+ const unsigned int cuMemhostallocDevicemap = 0x02;
+ const unsigned int cuMemhostallocPortable = 0x01;
+ PxCUresult result = cudaContextManager.getCudaContext()->memHostAlloc(&ptr, numElements * sizeof(T), cuMemhostallocDevicemap | cuMemhostallocPortable);
+ if (result != 0)
+ PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "allocPinnedHostBuffer failed with error code %i!\n", PxI32(result));
+
+ return reinterpret_cast(ptr);
+}
+
+/**
+* \brief Frees a pinned host buffer
+*
+* The cuda context will get acquired automatically
+*
+* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context the pinned memory buffer is attributed to.
+* \param[in] pinnedHostBuffer reference to a pointer pointing to the pinned memory buffer.
+*/
+template
+static void freePinnedHostBuffer(PxCudaContextManager& cudaContextManager, T*& pinnedHostBuffer)
+{
+ if (pinnedHostBuffer)
+ {
+ PxScopedCudaLock lock(cudaContextManager);
+ PxCUresult result = cudaContextManager.getCudaContext()->memFreeHost(pinnedHostBuffer);
+ if (result != 0)
+ PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "freePinnedHostBuffer failed with error code %i!\n", PxI32(result));
+
+ pinnedHostBuffer = NULL;
+ }
+}
+
+/**
+* \brief Copies a device buffer to the host
+*
+* The cuda context will get acquired automatically
+*
+* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context executing the operation.
+* \param[in] hostBuffer pointer to the destination (pinned) host memory buffer.
+* \param[in] deviceBuffer pointer to the source device buffer.
+* \param[in] numElements the number of elements of type T to copy.
+*/
+template
+static void copyDToH(PxCudaContextManager& cudaContextManager, T* hostBuffer, const T* deviceBuffer, PxU64 numElements)
+{
+ if (!deviceBuffer || !hostBuffer)
+ return;
+
+ PxScopedCudaLock lock(cudaContextManager);
+ PxU64 numBytes = numElements * sizeof(T);
+
+ PxCUresult result = cudaContextManager.getCudaContext()->memcpyDtoH(hostBuffer, CUdeviceptr(deviceBuffer), numBytes);
+ if (result != 0)
+ PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "copyDToH failed with error code %i!\n", PxI32(result));
+}
+
+/**
+* \brief Copies a host buffer to the device
+*
+* The cuda context will get acquired automatically
+*
+* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context executing the operation.
+* \param[in] deviceBuffer pointer to the destination device buffer.
+* \param[in] hostBuffer pointer to the source (pinned) host memory buffer.
+* \param[in] numElements the number of elements of type T to copy.
+*/
+template
+static void copyHToD(PxCudaContextManager& cudaContextManager, T* deviceBuffer, const T* hostBuffer, PxU64 numElements)
+{
+ if (!deviceBuffer || !hostBuffer)
+ return;
+
+ PxScopedCudaLock lock(cudaContextManager);
+ PxU64 numBytes = numElements * sizeof(T);
+
+ PxCUresult result = cudaContextManager.getCudaContext()->memcpyHtoD(CUdeviceptr(deviceBuffer), hostBuffer, numBytes);
+ if (result != 0)
+ PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "copyHtoD failed with error code %i!\n", PxI32(result));
+}
+
+/**
+* \brief Schedules device to host copy operation on the specified stream
+*
+* The cuda context will get acquired automatically
+*
+* \param[in] cudaContextManager the PxCudaContextManager managing the CUDA context executing the operation.
+* \param[in] hostBuffer pointer to the destination (pinned) host memory buffer.
+* \param[in] deviceBuffer pointer to the source device buffer.
+* \param[in] numElements the number of elements of type T to copy.
+* \param[in] stream the CUDA stream to perform the operation on.
+*/
+template