| 14 | namespace skd::asset |
| 15 | { |
| 16 | bool SSkelCooker::Cook(SCookContext *ctx) |
| 17 | { |
| 18 | SkrZoneScopedNS("SSkelCooker::Cook", 4); |
| 19 | |
| 20 | using namespace ozz::animation::offline; |
| 21 | //-----load config |
| 22 | simdjson::ondemand::parser parser; |
| 23 | //-----import resource object |
| 24 | RawSkeleton* rawSkeleton = (RawSkeleton*)ctx->Import<RawSkeleton>(); |
| 25 | if (!rawSkeleton) |
| 26 | { |
| 27 | return false; |
| 28 | } |
| 29 | SKR_DEFER({ctx->Destroy(rawSkeleton);}); |
| 30 | if(!ValidateJointNamesUniqueness(*rawSkeleton)) |
| 31 | { |
| 32 | return false; |
| 33 | } |
| 34 | //-----emit dependencies |
| 35 | // no static dependencies |
| 36 | //-----cook resource |
| 37 | skr::anim::SkeletonResource resource; |
| 38 | { |
| 39 | SkeletonBuilder builder; |
| 40 | ozz::unique_ptr<ozz::animation::Skeleton> skeleton = builder(*rawSkeleton); |
| 41 | if (!skeleton) { |
| 42 | SKR_LOG_ERROR(u8"Failed to build skeleton for asset %s.", ctx->GetAssetRecord()->path.c_str()); |
| 43 | return false; |
| 44 | } |
| 45 | resource.skeleton = std::move(*skeleton); |
| 46 | } |
| 47 | //-----fetch runtime dependencies |
| 48 | // no runtime dependencies |
| 49 | //-----save resource |
| 50 | ctx->Save(resource); |
| 51 | return true; |
| 52 | } |
| 53 | } |
nothing calls this directly
no test coverage detected