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

Method Cook

modules/tools/animation_tool/src/skeleton_asset.cpp:16–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14namespace skd::asset
15{
16bool 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}

Callers

nothing calls this directly

Calls 6

moveFunction · 0.50
DestroyMethod · 0.45
c_strMethod · 0.45
GetAssetRecordMethod · 0.45
SaveMethod · 0.45

Tested by

no test coverage detected