| 1 | // |
| 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions |
| 4 | // are met: |
| 5 | // * Redistributions of source code must retain the above copyright |
| 6 | // notice, this list of conditions and the following disclaimer. |
| 7 | // * Redistributions in binary form must reproduce the above copyright |
| 8 | // notice, this list of conditions and the following disclaimer in the |
| 9 | // documentation and/or other materials provided with the distribution. |
| 10 | // * Neither the name of NVIDIA CORPORATION nor the names of its |
| 11 | // contributors may be used to endorse or promote products derived |
| 12 | // from this software without specific prior written permission. |
| 13 | // |
| 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY |
| 15 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 18 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 | // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | // |
| 26 | // Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved. |
| 27 | // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. |
| 28 | // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. |
| 29 | |
| 30 | |
| 31 | #ifndef PXC_NPWORKUNIT_H |
| 32 | #define PXC_NPWORKUNIT_H |
| 33 | |
| 34 | #include "PxcNpThreadContext.h" |
| 35 | #include "PxcMaterialMethodImpl.h" |
| 36 | #include "PxcNpCache.h" |
| 37 | |
| 38 | namespace physx |
| 39 | { |
| 40 | struct PxsRigidCore; |
| 41 | struct PxsShapeCore; |
| 42 | |
| 43 | struct PxcNpWorkUnitFlag |
| 44 | { |
| 45 | enum Enum |
| 46 | { |
| 47 | eOUTPUT_CONTACTS = 1, |
| 48 | eOUTPUT_CONSTRAINTS = 2, |
| 49 | eDISABLE_STRONG_FRICTION = 4, |
| 50 | eARTICULATION_BODY0 = 8, |
| 51 | eARTICULATION_BODY1 = 16, |
| 52 | eDYNAMIC_BODY0 = 32, |
| 53 | eDYNAMIC_BODY1 = 64, |
| 54 | eMODIFIABLE_CONTACT = 128, |
| 55 | eFORCE_THRESHOLD = 256, |
| 56 | eDETECT_DISCRETE_CONTACT = 512, |
| 57 | eHAS_KINEMATIC_ACTOR = 1024, |
| 58 | eDISABLE_RESPONSE = 2048, |
| 59 | eDETECT_CCD_CONTACTS = 4096 |
| 60 | }; |
| 61 | }; |
| 62 | |
| 63 | struct PxcNpWorkUnitStatusFlag |
| 64 | { |
| 65 | enum Enum |
| 66 | { |
| 67 | eHAS_NO_TOUCH = (1 << 0), |
| 68 | eHAS_TOUCH = (1 << 1), |
| 69 | //eHAS_SOLVER_CONSTRAINTS = (1 << 2), |
| 70 | eREQUEST_CONSTRAINTS = (1 << 3), |
| 71 | eHAS_CCD_RETOUCH = (1 << 4), // Marks pairs that are touching at a CCD pass and were touching at discrete collision or at a previous CCD pass already |
| 72 | // but we can not tell whether they lost contact in a pass before. We send them as pure eNOTIFY_TOUCH_CCD events to the |
| 73 | // contact report callback if requested. |
| 74 | eDIRTY_MANAGER = (1 << 5), |
| 75 | eREFRESHED_WITH_TOUCH = (1 << 6), |
| 76 | eTOUCH_KNOWN = eHAS_NO_TOUCH | eHAS_TOUCH // The touch status is known (if narrowphase never ran for a pair then no flag will be set) |
| 77 | }; |
| 78 | }; |
| 79 | |
| 80 | // PT: TODO: fix the inconsistent namings (mXXX) in this class |
| 81 | struct PxcNpWorkUnit |
| 82 | { |
| 83 | const PxsRigidCore* rigidCore0; // INPUT //4 //8 |
| 84 | const PxsRigidCore* rigidCore1; // INPUT //8 //16 |
| 85 | |
| 86 | const PxsShapeCore* shapeCore0; // INPUT //12 //24 |
| 87 | const PxsShapeCore* shapeCore1; // INPUT //16 //32 |
| 88 | |
| 89 | PxU8* ccdContacts; // OUTPUT //20 //40 |
| 90 | |
| 91 | PxU8* frictionDataPtr; // INOUT //24 //48 |
| 92 | |
| 93 | PxU16 flags; // INPUT //26 //50 |
| 94 | PxU8 frictionPatchCount; // INOUT //27 //51 |
| 95 | PxU8 statusFlags; // OUTPUT (see PxcNpWorkUnitStatusFlag) //28 //52 |
| 96 | |
| 97 | PxU8 dominance0; // INPUT //29 //53 |
| 98 | PxU8 dominance1; // INPUT //30 //54 |
| 99 | PxU8 geomType0; // INPUT //31 //55 |
| 100 | PxU8 geomType1; // INPUT //32 //56 |
| 101 | |
| 102 | PxU32 index; // INPUT //36 //60 |
| 103 | |
| 104 | PxReal restDistance; // INPUT //40 //64 |
| 105 | |
| 106 | PxU32 mTransformCache0; // //44 //68 |
| 107 | PxU32 mTransformCache1; // //48 //72 |
| 108 | |
| 109 | PxU32 mEdgeIndex; //inout the island gen edge index //52 //76 |
| 110 | PxU32 mNpIndex; //INPUT //56 //80 |
| 111 | |
| 112 | PxReal mTorsionalPatchRadius; //60 //84 |
| 113 | PxReal mMinTorsionalPatchRadius; //64 //88 |
| 114 | }; |
| 115 | |
| 116 | /* |
| 117 | * A struct to record the number of work units a particular constraint pointer references. |
| 118 | * This is created at the beginning of the constriant data and is used to bypass constraint preparation when the |
| 119 | * bodies are not moving a lot. In this case, we can recycle the constraints and save ourselves some cycles. |
| 120 | */ |
| 121 | struct PxcNpWorkUnitBatch |
| 122 | { |
| 123 | PxcNpWorkUnit* mUnits[4]; |
| 124 | PxU32 mSize; |
| 125 | }; |
| 126 | |
| 127 | //#if !defined(PX_P64) |
| 128 | //PX_COMPILE_TIME_ASSERT(0 == (sizeof(PxcNpWorkUnit) & 0x0f)); |
| 129 | //#endif |
| 130 | |
| 131 | PX_FORCE_INLINE void PxcNpWorkUnitClearContactState(PxcNpWorkUnit& n) |
| 132 | { |
| 133 | n.ccdContacts = NULL; |
| 134 | } |
| 135 | |
| 136 | PX_FORCE_INLINE void PxcNpWorkUnitClearCachedState(PxcNpWorkUnit& n) |
| 137 | { |
| 138 | n.frictionDataPtr = 0; |
| 139 | n.frictionPatchCount = 0; |
| 140 | n.ccdContacts = NULL; |
| 141 | } |
| 142 | |
| 143 | PX_FORCE_INLINE void PxcNpWorkUnitClearFrictionCachedState(PxcNpWorkUnit& n) |
| 144 | { |
| 145 | n.frictionDataPtr = 0; |
| 146 | n.frictionPatchCount = 0; |
| 147 | n.ccdContacts = NULL; |
| 148 | } |
| 149 | |
| 150 | #if !defined(PX_P64) |
| 151 | //PX_COMPILE_TIME_ASSERT(sizeof(PxcNpWorkUnit)==128); |
| 152 | #endif |
| 153 | } |
| 154 | |
| 155 | #endif |
| 156 | |