| 98 | } |
| 99 | |
| 100 | PxConvexMesh* PxToolkit::createConvexMeshSafe(PxPhysics& physics, PxCooking& cooking, const PxVec3* verts, PxU32 vertCount, PxConvexFlags flags, PxU32 vLimit) |
| 101 | { |
| 102 | PxConvexMeshDesc convexDesc; |
| 103 | convexDesc.points.count = vertCount; |
| 104 | convexDesc.points.stride = sizeof(PxVec3); |
| 105 | convexDesc.points.data = verts; |
| 106 | convexDesc.flags = flags; |
| 107 | convexDesc.vertexLimit = vLimit; |
| 108 | |
| 109 | PxDefaultMemoryOutputStream buf; |
| 110 | bool retVal = cooking.cookConvexMesh(convexDesc, buf); |
| 111 | if(!retVal) |
| 112 | { |
| 113 | // create AABB |
| 114 | PxBounds3 aabb; |
| 115 | aabb.setEmpty(); |
| 116 | for (PxU32 i = 0; i < vertCount; i++) |
| 117 | { |
| 118 | aabb.include(verts[i]); |
| 119 | } |
| 120 | |
| 121 | PxVec3 aabbVerts[8]; |
| 122 | aabbVerts[0] = PxVec3(aabb.minimum.x,aabb.minimum.y,aabb.minimum.z); |
| 123 | aabbVerts[1] = PxVec3(aabb.maximum.x,aabb.minimum.y,aabb.minimum.z); |
| 124 | aabbVerts[2] = PxVec3(aabb.maximum.x,aabb.maximum.y,aabb.minimum.z); |
| 125 | aabbVerts[3] = PxVec3(aabb.minimum.x,aabb.maximum.y,aabb.minimum.z); |
| 126 | |
| 127 | aabbVerts[4] = PxVec3(aabb.minimum.x,aabb.minimum.y,aabb.maximum.z); |
| 128 | aabbVerts[5] = PxVec3(aabb.maximum.x,aabb.minimum.y,aabb.maximum.z); |
| 129 | aabbVerts[6] = PxVec3(aabb.maximum.x,aabb.maximum.y,aabb.maximum.z); |
| 130 | aabbVerts[7] = PxVec3(aabb.minimum.x,aabb.maximum.y,aabb.maximum.z); |
| 131 | |
| 132 | convexDesc.points.count = 8; |
| 133 | convexDesc.points.stride = sizeof(PxVec3); |
| 134 | convexDesc.points.data = &aabbVerts[0]; |
| 135 | convexDesc.flags = flags; |
| 136 | |
| 137 | retVal = cooking.cookConvexMesh(convexDesc, buf); |
| 138 | } |
| 139 | |
| 140 | if(!retVal) |
| 141 | { |
| 142 | return NULL; |
| 143 | } |
| 144 | |
| 145 | PxDefaultMemoryInputData input(buf.getData(), buf.getSize()); |
| 146 | return physics.createConvexMesh(input); |
| 147 | } |
| 148 | |
| 149 |
nothing calls this directly
no test coverage detected