| 99 | } |
| 100 | |
| 101 | PxCollection* PxCollectionExt::createCollection(PxPhysics& physics) |
| 102 | { |
| 103 | PxCollection* collection = PxCreateCollection(); |
| 104 | if (!collection) |
| 105 | return NULL; |
| 106 | |
| 107 | // Collect convexes |
| 108 | { |
| 109 | shdfnd::Array<PxConvexMesh*> objects(physics.getNbConvexMeshes()); |
| 110 | const PxU32 nb = physics.getConvexMeshes(objects.begin(), objects.size()); |
| 111 | PX_ASSERT(nb == objects.size()); |
| 112 | PX_UNUSED(nb); |
| 113 | |
| 114 | for(PxU32 i=0;i<objects.size();i++) |
| 115 | collection->add(*objects[i]); |
| 116 | } |
| 117 | |
| 118 | // Collect triangle meshes |
| 119 | { |
| 120 | shdfnd::Array<PxTriangleMesh*> objects(physics.getNbTriangleMeshes()); |
| 121 | const PxU32 nb = physics.getTriangleMeshes(objects.begin(), objects.size()); |
| 122 | |
| 123 | PX_ASSERT(nb == objects.size()); |
| 124 | PX_UNUSED(nb); |
| 125 | |
| 126 | for(PxU32 i=0;i<objects.size();i++) |
| 127 | collection->add(*objects[i]); |
| 128 | } |
| 129 | |
| 130 | // Collect heightfields |
| 131 | { |
| 132 | shdfnd::Array<PxHeightField*> objects(physics.getNbHeightFields()); |
| 133 | const PxU32 nb = physics.getHeightFields(objects.begin(), objects.size()); |
| 134 | |
| 135 | PX_ASSERT(nb == objects.size()); |
| 136 | PX_UNUSED(nb); |
| 137 | |
| 138 | for(PxU32 i=0;i<objects.size();i++) |
| 139 | collection->add(*objects[i]); |
| 140 | } |
| 141 | |
| 142 | // Collect materials |
| 143 | { |
| 144 | shdfnd::Array<PxMaterial*> objects(physics.getNbMaterials()); |
| 145 | const PxU32 nb = physics.getMaterials(objects.begin(), objects.size()); |
| 146 | |
| 147 | PX_ASSERT(nb == objects.size()); |
| 148 | PX_UNUSED(nb); |
| 149 | |
| 150 | for(PxU32 i=0;i<objects.size();i++) |
| 151 | collection->add(*objects[i]); |
| 152 | } |
| 153 | |
| 154 | // Collect shapes |
| 155 | { |
| 156 | shdfnd::Array<PxShape*> objects(physics.getNbShapes()); |
| 157 | const PxU32 nb = physics.getShapes(objects.begin(), objects.size()); |
| 158 |
no test coverage detected