------------------------------------------------------------------------------------------------ Load envelope description
| 1236 | // ------------------------------------------------------------------------------------------------ |
| 1237 | // Load envelope description |
| 1238 | void LWOImporter::LoadLWO2Envelope(unsigned int length) { |
| 1239 | LE_NCONST uint8_t *const end = mFileBuffer + length; |
| 1240 | AI_LWO_VALIDATE_CHUNK_LENGTH(length, ENVL, 4); |
| 1241 | |
| 1242 | mEnvelopes.emplace_back(); |
| 1243 | LWO::Envelope &envelope = mEnvelopes.back(); |
| 1244 | |
| 1245 | // Get the index of the envelope |
| 1246 | envelope.index = ReadVSizedIntLWO2(mFileBuffer); |
| 1247 | |
| 1248 | // It looks like there might be an extra U4 right after the index, |
| 1249 | // at least in modo (LXOB) files: we'll ignore it if it's zero, |
| 1250 | // otherwise it represents the start of a subchunk, so we backtrack. |
| 1251 | if (mIsLXOB) { |
| 1252 | uint32_t extra = GetU4(); |
| 1253 | if (extra) { |
| 1254 | mFileBuffer -= 4; |
| 1255 | } |
| 1256 | } |
| 1257 | |
| 1258 | // ... and read all subchunks |
| 1259 | while (true) { |
| 1260 | if (mFileBuffer + 6 >= end) break; |
| 1261 | LE_NCONST IFF::SubChunkHeader head = IFF::LoadSubChunk(mFileBuffer); |
| 1262 | |
| 1263 | if (mFileBuffer + head.length > end) |
| 1264 | throw DeadlyImportError("LWO2: Invalid envelope chunk length"); |
| 1265 | |
| 1266 | uint8_t *const next = mFileBuffer + head.length; |
| 1267 | switch (head.type) { |
| 1268 | // Type & representation of the envelope |
| 1269 | case AI_LWO_TYPE: |
| 1270 | AI_LWO_VALIDATE_CHUNK_LENGTH(head.length, TYPE, 2); |
| 1271 | mFileBuffer++; // skip user format |
| 1272 | |
| 1273 | // Determine type of envelope |
| 1274 | envelope.type = (LWO::EnvelopeType)*mFileBuffer; |
| 1275 | ++mFileBuffer; |
| 1276 | break; |
| 1277 | |
| 1278 | // precondition |
| 1279 | case AI_LWO_PRE: |
| 1280 | AI_LWO_VALIDATE_CHUNK_LENGTH(head.length, PRE, 2); |
| 1281 | envelope.pre = (LWO::PrePostBehaviour)GetU2(); |
| 1282 | break; |
| 1283 | |
| 1284 | // postcondition |
| 1285 | case AI_LWO_POST: |
| 1286 | AI_LWO_VALIDATE_CHUNK_LENGTH(head.length, POST, 2); |
| 1287 | envelope.post = (LWO::PrePostBehaviour)GetU2(); |
| 1288 | break; |
| 1289 | |
| 1290 | // keyframe |
| 1291 | case AI_LWO_KEY: { |
| 1292 | AI_LWO_VALIDATE_CHUNK_LENGTH(head.length, KEY, 8); |
| 1293 | |
| 1294 | envelope.keys.emplace_back(); |
| 1295 | LWO::Key &key = envelope.keys.back(); |
nothing calls this directly
no test coverage detected