MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / loadMeshData

Function loadMeshData

deps/physx/physx/source/geomutils/src/GuMeshFactory.cpp:135–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

createTriangleMeshMethod · 0.85

Calls 15

readDwordFunction · 0.85
to16Function · 0.85
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
flipFunction · 0.70

Tested by

no test coverage detected