------------------------------------------------------------------------------------------------
| 226 | |
| 227 | // ------------------------------------------------------------------------------------------------ |
| 228 | void LWOImporter::LoadLWOBSurface(unsigned int size) { |
| 229 | LE_NCONST uint8_t* const end = mFileBuffer + size; |
| 230 | |
| 231 | mSurfaces->push_back( LWO::Surface () ); |
| 232 | LWO::Surface& surf = mSurfaces->back(); |
| 233 | LWO::Texture *pTex = nullptr; |
| 234 | |
| 235 | GetS0(surf.mName,size); |
| 236 | bool running = true; |
| 237 | while (running) { |
| 238 | if (mFileBuffer + 6 >= end) |
| 239 | break; |
| 240 | |
| 241 | IFF::SubChunkHeader head = IFF::LoadSubChunk(mFileBuffer); |
| 242 | |
| 243 | /* A single test file (sonycam.lwo) seems to have invalid surface chunks. |
| 244 | * I'm assuming it's the fault of a single, unknown exporter so there are |
| 245 | * probably THOUSANDS of them. Here's a dirty workaround: |
| 246 | * |
| 247 | * We don't break if the chunk limit is exceeded. Instead, we're computing |
| 248 | * how much storage is actually left and work with this value from now on. |
| 249 | */ |
| 250 | if (mFileBuffer + head.length > end) { |
| 251 | ASSIMP_LOG_ERROR("LWOB: Invalid surface chunk length. Trying to continue."); |
| 252 | head.length = (uint16_t) (end - mFileBuffer); |
| 253 | } |
| 254 | |
| 255 | uint8_t* const next = mFileBuffer+head.length; |
| 256 | switch (head.type) { |
| 257 | // diffuse color |
| 258 | case AI_LWO_COLR: |
| 259 | { |
| 260 | AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,COLR,3); |
| 261 | surf.mColor.r = GetU1() / 255.0f; |
| 262 | surf.mColor.g = GetU1() / 255.0f; |
| 263 | surf.mColor.b = GetU1() / 255.0f; |
| 264 | break; |
| 265 | } |
| 266 | // diffuse strength ... |
| 267 | case AI_LWO_DIFF: |
| 268 | { |
| 269 | AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,DIFF,2); |
| 270 | surf.mDiffuseValue = GetU2() / 255.0f; |
| 271 | break; |
| 272 | } |
| 273 | // specular strength ... |
| 274 | case AI_LWO_SPEC: |
| 275 | { |
| 276 | AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SPEC,2); |
| 277 | surf.mSpecularValue = GetU2() / 255.0f; |
| 278 | break; |
| 279 | } |
| 280 | // luminosity ... |
| 281 | case AI_LWO_LUMI: |
| 282 | { |
| 283 | AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,LUMI,2); |
| 284 | surf.mLuminosity = GetU2() / 255.0f; |
| 285 | break; |
nothing calls this directly
no test coverage detected