diff options
| author | git perforce import user <a@b> | 2016-10-25 12:29:14 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees> | 2016-10-25 18:56:37 -0500 |
| commit | 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch) | |
| tree | fa6485c169e50d7415a651bf838f5bcd0fd3bfbd /PhysX_3.4/Include/cooking | |
| download | physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip | |
Initial commit:
PhysX 3.4.0 Update @ 21294896
APEX 1.4.0 Update @ 21275617
[CL 21300167]
Diffstat (limited to 'PhysX_3.4/Include/cooking')
| -rw-r--r-- | PhysX_3.4/Include/cooking/PxBVH33MidphaseDesc.h | 110 | ||||
| -rw-r--r-- | PhysX_3.4/Include/cooking/PxBVH34MidphaseDesc.h | 90 | ||||
| -rw-r--r-- | PhysX_3.4/Include/cooking/PxConvexMeshDesc.h | 313 | ||||
| -rw-r--r-- | PhysX_3.4/Include/cooking/PxCooking.h | 628 | ||||
| -rw-r--r-- | PhysX_3.4/Include/cooking/PxMidphaseDesc.h | 119 | ||||
| -rw-r--r-- | PhysX_3.4/Include/cooking/PxTriangleMeshDesc.h | 120 | ||||
| -rw-r--r-- | PhysX_3.4/Include/cooking/Pxc.h | 55 |
7 files changed, 1435 insertions, 0 deletions
diff --git a/PhysX_3.4/Include/cooking/PxBVH33MidphaseDesc.h b/PhysX_3.4/Include/cooking/PxBVH33MidphaseDesc.h new file mode 100644 index 00000000..c8a62684 --- /dev/null +++ b/PhysX_3.4/Include/cooking/PxBVH33MidphaseDesc.h @@ -0,0 +1,110 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_BVH_33_MIDPHASE_DESC_H +#define PX_BVH_33_MIDPHASE_DESC_H +/** \addtogroup cooking +@{ +*/ + +#include "foundation/PxPreprocessor.h" +#include "foundation/PxSimpleTypes.h" + +#if !PX_DOXYGEN +namespace physx +{ +#endif + +/** \brief Enumeration for mesh cooking hints. */ +struct PxMeshCookingHint +{ + enum Enum + { + eSIM_PERFORMANCE = 0, //!< Default value. Favors higher quality hierarchy with higher runtime performance over cooking speed. + eCOOKING_PERFORMANCE = 1 //!< Enables fast cooking path at the expense of somewhat lower quality hierarchy construction. + }; +}; + +/** + +\brief Structure describing parameters affecting BVH33 midphase mesh structure. + +@see PxCookingParams, PxMidphaseDesc +*/ +struct PxBVH33MidphaseDesc +{ + /** + \brief Controls the trade-off between mesh size and runtime performance. + + Using a value of 1.0 will produce a larger cooked mesh with generally higher runtime performance, + using 0.0 will produce a smaller cooked mesh, with generally lower runtime performance. + + Values outside of [0,1] range will be clamped and cause a warning when any mesh gets cooked. + + <b>Default value:</b> 0.55 + <b>Range:</b> [0.0f, 1.0f] + */ + PxF32 meshSizePerformanceTradeOff; + + /** + \brief Mesh cooking hint. Used to specify mesh hierarchy construction preference. + + <b>Default value:</b> PxMeshCookingHint::eSIM_PERFORMANCE + */ + PxMeshCookingHint::Enum meshCookingHint; + + /** + \brief Desc initialization to default value. + */ + void setToDefault() + { + meshSizePerformanceTradeOff = 0.55f; + meshCookingHint = PxMeshCookingHint::eSIM_PERFORMANCE; + } + + /** + \brief Returns true if the descriptor is valid. + \return true if the current settings are valid. + */ + bool isValid() const + { + if(meshSizePerformanceTradeOff < 0.0f || meshSizePerformanceTradeOff > 1.0f) + return false; + return true; + } +}; + +#if !PX_DOXYGEN +} // namespace physx +#endif + + + /** @} */ +#endif // PX_BVH_33_MIDPHASE_DESC_H diff --git a/PhysX_3.4/Include/cooking/PxBVH34MidphaseDesc.h b/PhysX_3.4/Include/cooking/PxBVH34MidphaseDesc.h new file mode 100644 index 00000000..0cb0dd5f --- /dev/null +++ b/PhysX_3.4/Include/cooking/PxBVH34MidphaseDesc.h @@ -0,0 +1,90 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_BVH_34_MIDPHASE_DESC_H +#define PX_BVH_34_MIDPHASE_DESC_H +/** \addtogroup cooking +@{ +*/ + +#include "foundation/PxPreprocessor.h" +#include "foundation/PxSimpleTypes.h" + +#if !PX_DOXYGEN +namespace physx +{ +#endif + +/** + +\brief Structure describing parameters affecting BVH34 midphase mesh structure. + +@see PxCookingParams, PxMidphaseDesc +*/ +struct PxBVH34MidphaseDesc +{ + /** + \brief Mesh cooking hint for max triangles per leaf limit. + Less triangles per leaf produces larger meshes with better runtime performance + and worse cooking performance. More triangles per leaf results in faster cooking speed and + smaller mesh sizes, but with worse runtime performance. + + <b>Default value:</b> 4 + <b>Range:</b> <4, 15> + */ + PxU32 numTrisPerLeaf; + + /** + \brief Desc initialization to default value. + */ + void setToDefault() + { + numTrisPerLeaf = 4; + } + + /** + \brief Returns true if the descriptor is valid. + \return true if the current settings are valid. + */ + bool isValid() const + { + if(numTrisPerLeaf < 4 || numTrisPerLeaf > 15) + return false; + return true; + } +}; + +#if !PX_DOXYGEN +} // namespace physx +#endif + + + /** @} */ +#endif // PX_BVH_34_MIDPHASE_DESC_H diff --git a/PhysX_3.4/Include/cooking/PxConvexMeshDesc.h b/PhysX_3.4/Include/cooking/PxConvexMeshDesc.h new file mode 100644 index 00000000..d9de60f6 --- /dev/null +++ b/PhysX_3.4/Include/cooking/PxConvexMeshDesc.h @@ -0,0 +1,313 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_COLLISION_NXCONVEXMESHDESC +#define PX_COLLISION_NXCONVEXMESHDESC +/** \addtogroup cooking +@{ +*/ + +#include "foundation/PxVec3.h" +#include "foundation/PxFlags.h" +#include "common/PxCoreUtilityTypes.h" +#include "geometry/PxConvexMesh.h" + +#if !PX_DOXYGEN +namespace physx +{ +#endif + +/** +\brief Flags which describe the format and behavior of a convex mesh. +*/ +struct PxConvexFlag +{ + enum Enum + { + /** + Denotes the use of 16-bit vertex indices in PxConvexMeshDesc::triangles or PxConvexMeshDesc::polygons. + (otherwise, 32-bit indices are assumed) + @see #PxConvexMeshDesc.indices + */ + e16_BIT_INDICES = (1<<0), + + /** + Automatically recomputes the hull from the vertices. If this flag is not set, you must provide the entire geometry manually. + + \note There are two different algorithms for hull computation, please see PxConvexMeshCookingType. + + @see PxConvexMeshCookingType + */ + eCOMPUTE_CONVEX = (1<<1), + + /** + \brief Checks and removes almost zero-area triangles during convex hull computation. + The rejected area size is specified in PxCookingParams::areaTestEpsilon + + \note This flag is only used in combination with eCOMPUTE_CONVEX. + + \note If this flag is used in combination with eINFLATE_CONVEX, the newly added triangles + by the inflation algorithm are not checked (size of the triangles depends on PxCooking::skinWidth). + + @see PxCookingParams PxCookingParams::areaTestEpsilon + */ + eCHECK_ZERO_AREA_TRIANGLES = (1<<2), + + /** + \brief Inflates the convex points according to skin width. + + \note eINFLATE_CONVEX flag has been deprecated. The flag is automatically used when + PxConvexMeshCookingType::eINFLATION_INCREMENTAL_HULL is set. The default algorithm + PxConvexMeshCookingType::eQUICK_HULL ignores this flag, inflation is not used. + + @see PxCookingParams PxConvexMeshCookingType + */ + PX_DEPRECATED eINFLATE_CONVEX = (1<<3), + + /** + \brief Quantizes the input vertices using the k-means clustering + + \note The input vertices are quantized to PxConvexMeshDesc::quantizedCount + see http://en.wikipedia.org/wiki/K-means_clustering + + */ + eQUANTIZE_INPUT = (1 << 4), + + /** + \brief Disables the convex mesh validation to speed-up hull creation. Please use separate validation + function in checked/debug builds. Creating a convex mesh with invalid input data without prior validation + may result in undefined behavior. + + @see PxCooking::validateConvexMesh + */ + eDISABLE_MESH_VALIDATION = (1 << 5), + + /** + \brief Enables plane shifting vertex limit algorithm. + + Plane shifting is an alternative algorithm for the case when the computed hull has more vertices + than the specified vertex limit. + + The default algorithm computes the full hull, and an OBB around the input vertices. This OBB is then sliced + with the hull planes until the vertex limit is reached.The default algorithm requires the vertex limit + to be set to at least 8, and typically produces results that are much better quality than are produced + by plane shifting. + + When plane shifting is enabled, the hull computation stops when vertex limit is reached. The hull planes + are then shifted to contain all input vertices, and the new plane intersection points are then used to + generate the final hull with the given vertex limit.Plane shifting may produce sharp edges to vertices + very far away from the input cloud, and does not guarantee that all input vertices are inside the resulting + hull.However, it can be used with a vertex limit as low as 4. + */ + ePLANE_SHIFTING = (1 << 6), + + /** + \brief Inertia tensor computation is faster using SIMD code, but the precision is lower, which may result + in incorrect inertia for very thin hulls. + */ + eFAST_INERTIA_COMPUTATION = (1 << 7), + + /** + \brief Convex hulls are created with respect to GPU simulation limitations. Vertex limit is set to 64 and + vertex limit per face is internally set to 32. + \note Can be used only with eCOMPUTE_CONVEX flag. + */ + eGPU_COMPATIBLE = (1 << 8) + }; +}; + +/** +\brief collection of set bits defined in PxConvexFlag. + +@see PxConvexFlag +*/ +typedef PxFlags<PxConvexFlag::Enum,PxU16> 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. + +@see PxConvexMesh PxConvexMeshGeometry PxShape PxPhysics.createConvexMesh() + +*/ +class PxConvexMeshDesc +{ +public: + + /** + \brief Vertex positions data in PxBoundedData format. + + <b>Default:</b> NULL + */ + PxBoundedData points; + + /** + \brief Polygons data in PxBoundedData format. + <p>Pointer to first polygon. </p> + + <b>Default:</b> NULL + + @see PxHullPolygon + */ + PxBoundedData polygons; + + /** + \brief Polygon indices data in PxBoundedData format. + <p>Pointer to first index.</p> + + <b>Default:</b> NULL + + <p>This is declared as a void pointer because it is actually either an PxU16 or a PxU32 pointer.</p> + + @see PxHullPolygon PxConvexFlag::e16_BIT_INDICES + */ + PxBoundedData indices; + + /** + \brief Flags bits, combined from values of the enum ::PxConvexFlag + + <b>Default:</b> 0 + */ + PxConvexFlags flags; + + /** + \brief Limits the number of vertices of the result convex mesh. Hard maximum limit is 256 + and minimum limit is 4 if PxConvexFlag::ePLANE_SHIFTING is used, otherwise the minimum + limit is 8. + + \note Vertex limit is only used when PxConvexFlag::eCOMPUTE_CONVEX is specified. + \note The please see PxConvexFlag::ePLANE_SHIFTING for algorithm explanation + + @see PxConvexFlag::ePLANE_SHIFTING + + <b>Range:</b> [4, 255]<br> + <b>Default:</b> 255 + */ + PxU16 vertexLimit; + + /** + \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 + + <b>Range:</b> [4, 65535]<br> + <b>Default:</b> 255 + */ + PxU16 quantizedCount; + + /** + \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), quantizedCount(255) +{ +} + +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 > 256) + { + return false; + } + return true; +} + +#if !PX_DOXYGEN +} // namespace physx +#endif + +/** @} */ +#endif diff --git a/PhysX_3.4/Include/cooking/PxCooking.h b/PhysX_3.4/Include/cooking/PxCooking.h new file mode 100644 index 00000000..4d635cf6 --- /dev/null +++ b/PhysX_3.4/Include/cooking/PxCooking.h @@ -0,0 +1,628 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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 +/** \addtogroup cooking +@{ +*/ +#include "common/PxPhysXCommonConfig.h" +#include "common/PxTolerancesScale.h" +#include "cooking/Pxc.h" + +#include "cooking/PxConvexMeshDesc.h" +#include "cooking/PxTriangleMeshDesc.h" +#include "cooking/PxMidphaseDesc.h" +#include "geometry/PxTriangleMesh.h" + +#if !PX_DOXYGEN +namespace physx +{ +#endif + +class PxBinaryConverter; +class PxPhysicsInsertionCallback; +class PxFoundation; + +struct PX_DEPRECATED PxPlatform +{ + enum Enum + { + ePC, + eARM + }; +}; + +PX_DEPRECATED PX_FORCE_INLINE PxU32 PxGetGaussMapVertexLimitForPlatform(PxPlatform::Enum targetPlatform) +{ + PX_ASSERT_WITH_MESSAGE( (targetPlatform >= PxPlatform::ePC) && + (targetPlatform <= PxPlatform::eARM), + "Unexpected platform in PxGetGaussMapVertexLimitForPlatform"); + + PxU32 limit = 0; + switch(targetPlatform) + { + case PxPlatform::ePC: + limit = 32; break; + case PxPlatform::eARM: + limit = 32; break; + } + return limit; +} + +/** +\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 Enumeration for convex mesh cooking algorithms. */ +struct PxConvexMeshCookingType +{ + enum Enum + { + /** + \brief Legacy incremental algorithm using the inflation skinWidth parameter. + + The algorithm produces a hull with inflated planes. The hull's vertices are not the input vertices; + new vertices are created from the inflated plane's intersections. + + \note This algorithm is less stable and produces worse results than eQUICK_HULL; it is recommended to use + the eQUICKHULL algorithm. + + \note This legacy algorithm will be removed in future releases. + + */ + eINFLATION_INCREMENTAL_HULL PX_DEPRECATED = 0, + + /** + \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 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. Clean mesh must be enabled. + */ + eWELD_VERTICES = 1 << 0, + + /** + \brief When set, mesh cleaning is disabled. This makes cooking faster. + + When clean mesh is not performed, mesh welding is also not performed. + + It is recommended to use only meshes that passed during validateTriangleMesh. + + */ + eDISABLE_CLEAN_MESH = 1 << 1, + + /** + \brief When set, active edges are set for each triangle edge. This makes cooking faster but slow up contact generation. + */ + 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 + }; +}; + +typedef PxFlags<PxMeshPreprocessingFlag::Enum,PxU32> PxMeshPreprocessingFlags; + +/** + +\brief Structure describing parameters affecting mesh cooking. + +@see PxSetCookingParams() PxGetCookingParams() +*/ +struct PxCookingParams +{ + /** + \brief Target platform + + Should be set to the platform which you intend to load the cooked mesh data on. This allows + the SDK to optimize the mesh data in an appropriate way for the platform and make sure that + endianness issues are accounted for correctly. + + <b>Default value:</b> Same as the platform on which the SDK is running. + */ + PxPlatform::Enum targetPlatform; + /** + \brief Skin width for convexes. + + Specifies the amount to inflate the convex mesh when the inflation algorithm is used. + + The value is used for moving planes outward, and beveling sharp edges. This helps the hull generator + code produce more stable convexes for collision detection. Please note that the resulting hull will + increase its size, so contact generation may produce noticeable separation between shapes. The separation + distance can be reduced by decreasing the contactOffset and restOffset. See the user's manual on + 'Shapes - Tuning Shape Collision Behavior' for details. + + Change the value if the produced hulls are too thin or improper for your usage. Increasing the value + too much will result in incorrect hull size and a large separation between shapes. + + \note skinWidth is only used when PxConvexMeshCookingType::eINFLATION_INCREMENTAL_HULL is enabled. + + @see PxConvexMeshCookingType PxConvexFlag::eINFLATE_CONVEX + + <b>Default value:</b> 0.025f*PxTolerancesScale.length + + <b>Range:</b> (0.0f, PX_MAX_F32) + */ + PX_DEPRECATED float skinWidth; + + /** + \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 + + <b>Default value:</b> 0.06f*PxTolerancesScale.length*PxTolerancesScale.length + + <b>Range:</b> (0.0f, PX_MAX_F32) + */ + float areaTestEpsilon; + + /** + \brief Convex hull creation algorithm. + + <b>Default value:</b> 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. + + <b>Default value:</b> false + */ + bool suppressTriangleMeshRemapTable; + + /** + \brief When true, the triangle adjacency information is created. You can get the adjacency triangles + for a given triangle from getTriangle. + + <b>Default value:</b> false + */ + bool buildTriangleAdjacencies; + + /** + \brief When true, addigional information required for GPU-accelerated rigid body simulation is created. This can increase memory usage and cooking times for convex meshes and triangle meshes. + + <b>Default value:</b> 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. + + <b>Default value:</b> 0 + */ + PxMeshPreprocessingFlags meshPreprocessParams; + + /** + \brief Mesh cooking hint. Used to specify mesh hierarchy construction preference. + + \note Deprecated in 3.4, parameter moved to PxBVH33MidphaseDesc. + + @see PxBVH33MidphaseDesc, PxMidphaseDescUnion + + <b>Default value:</b> PxMeshCookingHint::eSIM_PERFORMANCE + */ + PX_DEPRECATED PxMeshCookingHint::Enum meshCookingHint; + + /** + \brief Controls the trade-off between mesh size and runtime performance. + + Using a value of 1.0 will produce a larger cooked mesh with generally higher runtime performance, + using 0.0 will produce a smaller cooked mesh, with generally lower runtime performance. + + Values outside of [0,1] range will be clamped and cause a warning when any mesh gets cooked. + + \note Deprecated in 3.4, parameter moved to PxBVH33MidphaseDesc. + + <b>Default value:</b> 0.55 + <b>Range:</b> [0.0f, 1.0f] + */ + PX_DEPRECATED PxF32 meshSizePerformanceTradeOff; + + /** + \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. + + <b>Default value:</b> 0.0 + */ + PxReal meshWeldTolerance; + + /** + \brief Controls the desired midphase desc structure for triangle meshes. + + \note If PxMeshMidPhase::eINVALID is used, the default PxMeshMidPhase::eBVH33 is used and the deprecated parameters PxCookingParams::meshCookingHint and + PxCookingParams::meshSizePerformanceTradeOff are used. + + @see PxBVH33MidphaseDesc, PxBVH34MidphaseDesc, PxMidphaseDesc + + <b>Default value:</b> PxMeshMidPhase::eINVALID + */ + 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. + + <b>Default value:</b> 32 + */ + PxU32 gaussMapLimit; + + PxCookingParams(const PxTolerancesScale& sc): + skinWidth (0.025f*sc.length), + areaTestEpsilon (0.06f*sc.length*sc.length), + convexMeshCookingType (PxConvexMeshCookingType::eQUICKHULL), + suppressTriangleMeshRemapTable (false), + buildTriangleAdjacencies (false), + buildGPUData (false), + scale (sc), + meshPreprocessParams (0), + meshCookingHint (PxMeshCookingHint::eSIM_PERFORMANCE), + meshSizePerformanceTradeOff (0.55f), + meshWeldTolerance (0.f) + { +#if PX_INTEL_FAMILY + targetPlatform = PxPlatform::ePC; +#elif PX_ARM_FAMILY + targetPlatform = PxPlatform::eARM; +#else +#error Unknown platform +#endif + gaussMapLimit = PxGetGaussMapVertexLimitForPlatform(targetPlatform); + } +}; + +class PxCooking +{ +public: + /** + \brief Closes this instance of the interface. + + This function should be called to cleanly shut down the Cooking library before application exit. + + \note This function is required to be called to release foundation usage. + + */ + virtual void release() = 0; + + /** + \brief Sets cooking parameters + + \param[in] params Cooking parameters + + @see getParams() + */ + virtual void setParams(const PxCookingParams& params) = 0; + + /** + \brief Gets cooking parameters + + \return Current cooking parameters. + + @see PxCookingParams setParams() + */ + virtual const PxCookingParams& getParams() = 0; + + /** + \brief Checks endianness is the same between cooking & target platforms + + \return True if there is and endian mismatch. + */ + virtual bool platformMismatch() = 0; + + /** + \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. + + cookTriangleMesh() allows a mesh description to be cooked into a binary stream + suitable for loading and performing collision detection at runtime. + + Example + + \include PxCookTriangleMesh_Example.cpp + + \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 cookConvexMesh() setParams() PxPhysics.createTriangleMesh() PxTriangleMeshCookingResult::Enum + */ + virtual bool cookTriangleMesh(const PxTriangleMeshDesc& desc, PxOutputStream& stream, PxTriangleMeshCookingResult::Enum* condition = NULL) = 0; + + /** + \brief Cooks and creates a triangle mesh and inserts it into PxPhysics. + + \note PxPhysicsInsertionCallback can be obtained through PxPhysics::getPhysicsInsertionCallback(). + + \param[in] desc The triangle mesh descriptor to read the mesh from. + \param[in] insertionCallback The insertion interface from PxPhysics. + \return PxTriangleMesh pointer on success. + + @see cookTriangleMesh() setParams() PxPhysics.createTriangleMesh() PxPhysicsInsertionCallback + */ + virtual PxTriangleMesh* createTriangleMesh(const PxTriangleMeshDesc& desc, PxPhysicsInsertionCallback& insertionCallback) = 0; + + /** + \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] desc The triangle mesh descriptor to read the mesh from. + + \return true if all the validity conditions hold, false otherwise. + + @see cookTriangleMesh() + */ + virtual bool validateTriangleMesh(const PxTriangleMeshDesc& desc) = 0; + + /** + \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. + + cookConvexMesh() allows a mesh description to be cooked into a binary stream + suitable for loading and performing collision detection at runtime. + + Example + + \include PxCookConvexMesh_Example.cpp + + \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] 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 cookTriangleMesh() setParams() PxConvexMeshCookingResult::Enum + */ + virtual bool cookConvexMesh(const PxConvexMeshDesc& desc, PxOutputStream& stream, PxConvexMeshCookingResult::Enum* condition = NULL) = 0; + + /** + \brief Cooks and creates a convex mesh and inserts it into PxPhysics. + + \note This method does the same as cookConvexMesh, but the produced convex mesh is not stored + into a stream but is directly inserted in PxPhysics. Use this method if you are unable to cook offline. + + \note PxPhysicsInsertionCallback can be obtained through PxPhysics::getPhysicsInsertionCallback(). + + \param[in] desc The convex mesh descriptor to read the mesh from. + \param[in] insertionCallback The insertion interface from PxPhysics. + \return PxConvexMesh pointer on success + + @see cookConvexMesh() setParams() PxPhysicsInsertionCallback + */ + virtual PxConvexMesh* createConvexMesh(const PxConvexMeshDesc& desc, PxPhysicsInsertionCallback& insertionCallback) = 0; + + /** + \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] desc The convex mesh descriptor to read the mesh from. + + \return true if all the validity conditions hold, false otherwise. + + @see cookConvexMesh() + */ + virtual bool validateConvexMesh(const PxConvexMeshDesc& desc) = 0; + + + /** + \brief Computed 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 array's. It is the user responsibility to deallocated those + array's. + + \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 cookConvexMesh() PxConvexFlags PxConvexMeshDesc PxSimpleTriangleMesh + */ + virtual bool computeHullPolygons(const PxSimpleTriangleMesh& mesh, PxAllocatorCallback& inCallback, PxU32& nbVerts, PxVec3*& vertices, + PxU32& nbIndices, PxU32*& indices, PxU32& nbPolygons, PxHullPolygon*& hullPolygons) = 0; + + /** + \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. + + cookHeightField() 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() + */ + virtual bool cookHeightField(const PxHeightFieldDesc& desc, PxOutputStream& stream) = 0; + + /** + \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 cookConvexMesh() setParams() PxPhysics.createTriangleMesh() PxPhysicsInsertionCallback + */ + virtual PxHeightField* createHeightField(const PxHeightFieldDesc& desc, PxPhysicsInsertionCallback& insertionCallback) = 0; + + +protected: + virtual ~PxCooking(){} +}; + +#if !PX_DOXYGEN +} // namespace physx +#endif + +/** +\brief Create an instance of the cooking interface. + +Note that the foundation object is handled as an application-wide singleton in statically linked executables +and a DLL-wide singleton in dynamically linked executables. Therefore, if you are using the runtime SDK in the +same executable as cooking, you should pass the Physics's copy of foundation (acquired with +PxPhysics::getFoundation()) to the cooker. This will also ensure correct handling of memory for objects +passed from the cooker to the SDK. + +To use cooking in standalone mode, create an instance of the Foundation object with PxCreateCookingFoundation. +You should pass the same foundation object to all instances of the cooking interface. + +\param[in] version the SDK version number +\param[in] foundation the foundation object associated with this instance of the cooking interface. +\param[in] params the parameters for this instance of the cooking interface +\return true on success. +*/ +PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxCooking* PX_CALL_CONV PxCreateCooking(physx::PxU32 version, + physx::PxFoundation& foundation, + const physx::PxCookingParams& params); + +/** @} */ +#endif diff --git a/PhysX_3.4/Include/cooking/PxMidphaseDesc.h b/PhysX_3.4/Include/cooking/PxMidphaseDesc.h new file mode 100644 index 00000000..280e4353 --- /dev/null +++ b/PhysX_3.4/Include/cooking/PxMidphaseDesc.h @@ -0,0 +1,119 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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 +/** \addtogroup cooking +@{ +*/ + +#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(): mType(PxMeshMidPhase::eINVALID) { } + + /** + \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 true; + } + + PX_FORCE_INLINE PxMidphaseDesc& operator=(PxMeshMidPhase::Enum descType) + { + setToDefault(descType); + return *this; + } + +protected: + PxMeshMidPhase::Enum mType; +}; + +#if !PX_DOXYGEN +} // namespace physx +#endif + + + /** @} */ +#endif // PX_MIDPHASE_DESC_UNION_H diff --git a/PhysX_3.4/Include/cooking/PxTriangleMeshDesc.h b/PhysX_3.4/Include/cooking/PxTriangleMeshDesc.h new file mode 100644 index 00000000..185f8aa5 --- /dev/null +++ b/PhysX_3.4/Include/cooking/PxTriangleMeshDesc.h @@ -0,0 +1,120 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_COLLISION_NXTRIANGLEMESHDESC +#define PX_COLLISION_NXTRIANGLEMESHDESC +/** \addtogroup cooking +@{ +*/ + +#include "PxPhysXConfig.h" +#include "geometry/PxSimpleTriangleMesh.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. + + <b>Default:</b> NULL + + @see materialIndexStride + */ + PxTypedStridedData<PxMaterialTableIndex> materialIndices; + + /** + \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(); +} + +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; + return PxSimpleTriangleMesh::isValid(); +} + +#if !PX_DOXYGEN +} // namespace physx +#endif + +/** @} */ +#endif diff --git a/PhysX_3.4/Include/cooking/Pxc.h b/PhysX_3.4/Include/cooking/Pxc.h new file mode 100644 index 00000000..bb703634 --- /dev/null +++ b/PhysX_3.4/Include/cooking/Pxc.h @@ -0,0 +1,55 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_NX +#define PX_COOKING_NX + +#include "foundation/Px.h" + +// define API function declaration +#if PX_WINDOWS + #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 + +#if !defined(PX_PHYSX_COOKING_API) + #define PX_PHYSX_COOKING_API +#endif + +#ifndef PX_C_EXPORT + #define PX_C_EXPORT extern "C" +#endif + +#endif |