MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Create

Method Create

Source/Engine/ContentImporters/CreateAnimationGraph.cpp:10–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include "Engine/Serialization/MemoryWriteStream.h"
9
10CreateAssetResult CreateAnimationGraph::Create(CreateAssetContext& context)
11{
12 // Base
13 IMPORT_SETUP(AnimationGraph, 1);
14
15 AnimGraph graph(nullptr);
16
17 // Create empty surface with animation output node
18 graph.Nodes.Resize(1);
19 auto& rootNode = graph.Nodes[0];
20 rootNode.Type = GRAPH_NODE_MAKE_TYPE(9, 1);
21 rootNode.ID = 1;
22 rootNode.Values.Resize(1);
23 rootNode.Values[0] = (int32)RootMotionExtraction::NoExtraction;
24 rootNode.Boxes.Resize(1);
25 rootNode.Boxes[0] = AnimGraphBox(&rootNode, 0, VariantType::Void);
26
27 // Add parameter (hidden) used to pass the skinned model asset (skeleton source)
28 graph.Parameters.Resize(1);
29 AnimGraphParameter& baseModelParam = graph.Parameters[0];
30 baseModelParam.Identifier = ANIM_GRAPH_PARAM_BASE_MODEL_ID;
31 baseModelParam.Type = VariantType::Asset;
32 baseModelParam.IsPublic = false;
33 baseModelParam.Value = Guid::Empty;
34
35 // Serialize
36 MemoryWriteStream stream(256);
37 if (graph.Save(&stream, true))
38 return CreateAssetResult::Error;
39
40 // Copy to asset chunk
41 if (context.AllocateChunk(0))
42 return CreateAssetResult::CannotAllocateChunk;
43 context.Data.Header.Chunks[0]->Data.Copy(ToSpan(stream));
44
45 return CreateAssetResult::Ok;
46}
47
48#endif

Callers

nothing calls this directly

Calls 5

ToSpanFunction · 0.50
ResizeMethod · 0.45
SaveMethod · 0.45
AllocateChunkMethod · 0.45
CopyMethod · 0.45

Tested by

no test coverage detected