MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / request

Method request

modules/render/live2d/src/l2d_model_resource.cpp:45–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45void 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());

Callers 5

InstallImplMethod · 0.45
InstallImplMethod · 0.45

Calls 15

GetModelFileNameMethod · 0.80
GetPhysicsFileNameMethod · 0.80
GetPoseFileNameMethod · 0.80
GetUserDataFileMethod · 0.80
open_requestMethod · 0.80
LoadModelMethod · 0.80
partial_finishedMethod · 0.80
use_async_completeMethod · 0.80
LoadPhysicsMethod · 0.80
LoadPoseMethod · 0.80
LoadUserDataMethod · 0.80

Tested by

no test coverage detected