| 43 | } |
| 44 | |
| 45 | void csmUserModel::request(skr_io_ram_service_t* ioService, L2DRequestCallbackData* data) SKR_NOEXCEPT |
| 46 | { |
| 47 | SkrZoneScopedN("Request Live2D Model"); |
| 48 | |
| 49 | auto settings = _modelSetting = data->live2dRequest->model_resource->model_setting; |
| 50 | auto mFile = settings->GetModelFileName(); |
| 51 | auto phFile = settings->GetPhysicsFileName(); |
| 52 | auto poFile = settings->GetPoseFileName(); |
| 53 | auto udFile = settings->GetUserDataFile(); |
| 54 | |
| 55 | homePath = data->u8HomePath; |
| 56 | cbData = data; |
| 57 | cbData->model_resource = this; |
| 58 | |
| 59 | SKR_LOG_TRACE(u8"Read Live2D From Home %s", data->u8HomePath.c_str()); |
| 60 | auto batch = ioService->open_batch(4); // 4 file requests |
| 61 | // Model Request |
| 62 | { |
| 63 | SkrZoneScopedN("Request Model"); |
| 64 | |
| 65 | modelPath += data->u8HomePath; |
| 66 | modelPath += u8"/"; |
| 67 | modelPath += (const char8_t*)mFile; |
| 68 | |
| 69 | SKR_LOG_TRACE(u8"Live2D Model %s at %s", mFile, modelPath.c_str()); |
| 70 | auto rq = ioService->open_request(); |
| 71 | rq->set_vfs(cbData->live2dRequest->vfs_override); |
| 72 | rq->set_path(modelPath.u8_str()); |
| 73 | rq->add_block({}); // read all |
| 74 | rq->add_callback(SKR_IO_STAGE_COMPLETED, |
| 75 | +[](skr_io_future_t* future, skr_io_request_t* request, void* usrdata) noexcept { |
| 76 | SkrZoneScopedN("Create Model"); |
| 77 | auto _this = (csmUserModel*)usrdata; |
| 78 | auto& blob = _this->modelBlob; |
| 79 | |
| 80 | _this->LoadModel(blob->get_data(), (L2DF::csmSizeInt)blob->get_size()); |
| 81 | blob.reset(); |
| 82 | |
| 83 | skr_atomicu32_add_relaxed(&_this->cbData->finished_models, 1); |
| 84 | _this->cbData->partial_finished(); |
| 85 | }, this); |
| 86 | rq->use_async_complete(); |
| 87 | // modelBlob = ioService->request(rq, &modelFuture); |
| 88 | modelBlob = skr::static_pointer_cast<skr::io::IRAMIOBuffer>(batch->add_request(rq, &modelFuture)); |
| 89 | } |
| 90 | // Physics Request |
| 91 | if (cbData->phys_count) |
| 92 | { |
| 93 | SkrZoneScopedN("Request Physics"); |
| 94 | |
| 95 | pyhsicsPath += data->u8HomePath; |
| 96 | pyhsicsPath += u8"/"; |
| 97 | pyhsicsPath += (const char8_t*)phFile; |
| 98 | |
| 99 | SKR_LOG_TRACE(u8"Live2D Physics %s at %s", phFile, pyhsicsPath.c_str()); |
| 100 | auto rq = ioService->open_request(); |
| 101 | rq->set_vfs(cbData->live2dRequest->vfs_override); |
| 102 | rq->set_path(pyhsicsPath.u8_str()); |
no test coverage detected