MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / loadMeshData

Function loadMeshData

physx/source/geomutils/src/GuMeshFactory.cpp:134–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134static TriangleMeshData* loadMeshData(PxInputStream& stream)
135{
136 // Import header
137 PxU32 version;
138 bool mismatch;
139 if(!readHeader('M', 'E', 'S', 'H', version, mismatch, stream))
140 return NULL;
141
142 PxU32 midphaseID = PxMeshMidPhase::eBVH33; // Default before version 14
143 if(version>=14) // this refers to PX_MESH_VERSION
144 {
145 midphaseID = readDword(mismatch, stream);
146 }
147
148 // Check if old (incompatible) mesh format is loaded
149 if (version <= 9) // this refers to PX_MESH_VERSION
150 {
151 Ps::getFoundation().error(PxErrorCode::eINTERNAL_ERROR, __FILE__, __LINE__, "Loading triangle mesh failed: "
152 "Deprecated mesh cooking format. Please recook your mesh in a new cooking format.");
153 PX_ALWAYS_ASSERT_MESSAGE("Obsolete cooked mesh found. Mesh version has been updated, please recook your meshes.");
154 return NULL;
155 }
156
157 // Import serialization flags
158 const PxU32 serialFlags = readDword(mismatch, stream);
159
160 // Import misc values
161 if (version <= 12) // this refers to PX_MESH_VERSION
162 {
163 // convexEdgeThreshold was removed in 3.4.0
164 readFloat(mismatch, stream);
165 }
166
167 TriangleMeshData* data;
168 if(midphaseID==PxMeshMidPhase::eBVH33)
169 data = PX_NEW(RTreeTriangleData);
170 else if(midphaseID==PxMeshMidPhase::eBVH34)
171 data = PX_NEW(BV4TriangleData);
172 else return NULL;
173
174 // Import mesh
175 PxVec3* verts = data->allocateVertices(readDword(mismatch, stream));
176 const PxU32 nbTris = readDword(mismatch, stream);
177 bool force32 = (serialFlags & (IMSF_8BIT_INDICES|IMSF_16BIT_INDICES)) == 0;
178
179 //ML: this will allocate CPU triangle indices and GPU triangle indices if we have GRB data built
180 void* tris = data->allocateTriangles(nbTris, force32, serialFlags & IMSF_GRB_DATA);
181
182 stream.read(verts, sizeof(PxVec3)*data->mNbVertices);
183 if(mismatch)
184 {
185 for(PxU32 i=0;i<data->mNbVertices;i++)
186 {
187 flip(verts[i].x);
188 flip(verts[i].y);
189 flip(verts[i].z);
190 }
191 }

Callers 1

createTriangleMeshMethod · 0.85

Calls 15

readDwordFunction · 0.85
to16Function · 0.85
errorMethod · 0.80
allocateVerticesMethod · 0.80
allocateTrianglesMethod · 0.80
allocateMaterialsMethod · 0.80
allocateFaceRemapMethod · 0.80
allocateAdjacenciesMethod · 0.80
setNbTrianglesMethod · 0.80
setNbVerticesMethod · 0.80
setPointersMethod · 0.80
allocateExtraTrigDataMethod · 0.80

Tested by

no test coverage detected