| 195 | |
| 196 | |
| 197 | void MeshFit::initSourceGeometry( const String& target ) |
| 198 | { |
| 199 | mMeshes.clear(); |
| 200 | mVerts.clear(); |
| 201 | mIndices.clear(); |
| 202 | |
| 203 | if ( target.equal( "bounds", String::NoCase ) ) |
| 204 | { |
| 205 | // Add all geometry in the highest detail level |
| 206 | S32 dl = 0; |
| 207 | S32 ss = mShape->details[dl].subShapeNum; |
| 208 | if ( ss < 0 ) |
| 209 | return; |
| 210 | |
| 211 | S32 od = mShape->details[dl].objectDetailNum; |
| 212 | S32 start = mShape->subShapeFirstObject[ss]; |
| 213 | S32 end = start + mShape->subShapeNumObjects[ss]; |
| 214 | |
| 215 | for ( S32 i = start; i < end; i++ ) |
| 216 | { |
| 217 | const TSShape::Object &obj = mShape->objects[i]; |
| 218 | const TSMesh* mesh = ( od < obj.numMeshes ) ? mShape->meshes[obj.startMeshIndex + od] : NULL; |
| 219 | if ( mesh ) |
| 220 | addSourceMesh( obj, mesh ); |
| 221 | } |
| 222 | } |
| 223 | else |
| 224 | { |
| 225 | // Add highest detail mesh from this object |
| 226 | S32 objIndex = mShape->findObject( target ); |
| 227 | if ( objIndex == -1 ) |
| 228 | return; |
| 229 | |
| 230 | const TSShape::Object &obj = mShape->objects[objIndex]; |
| 231 | for ( S32 i = 0; i < obj.numMeshes; i++ ) |
| 232 | { |
| 233 | const TSMesh* mesh = mShape->meshes[obj.startMeshIndex + i]; |
| 234 | if ( mesh ) |
| 235 | { |
| 236 | addSourceMesh( obj, mesh ); |
| 237 | break; |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | mIsReady = ( !mVerts.empty() && !mIndices.empty() ); |
| 243 | } |
| 244 | |
| 245 | void MeshFit::addSourceMesh( const TSShape::Object& obj, const TSMesh* mesh ) |
| 246 | { |
no test coverage detected