MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / init

Method init

Source/Node/Model.cpp:53–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51 Path::getExt(filename.toString()).empty() ? filename.toString() + ".model"s : filename.toString())) { }
52
53bool Model::init() {
54 if (!Playable::init()) return false;
55 if (!_modelDef) {
56 setAsManaged();
57 return false;
58 }
59 _resetAnimation.end = std::make_pair(this, &Model::onResetAnimationEnd);
60 _root = Node::create(false);
61 const std::string& clipFile = _modelDef->getClipFile();
62 if (!clipFile.empty()) {
63 ClipDef* clipDef = SharedClipCache.load(_modelDef->getClipFile());
64 Model::visit(_modelDef->getRoot(), _root, clipDef);
65 Model::setupCallback();
66 for (int i = 0; i < s_cast<int>(_animationGroups.size()); i++) {
67 const std::string& name = _modelDef->getAnimationNameByIndex(i);
68 _animationGroups[i]->animationEnd = [this, name](Model* model) {
69 emit("AnimationEnd"_slice, name, s_cast<Playable*>(model));
70 _lastCompletedAnimationName = name;
71 };
72 }
73 }
74 Size size = _modelDef->getSize();
75 Model::setSize(size);
76 _root->setPosition(Vec2{size.width * 0.5f, size.height * 0.5f});
77 addChild(_root);
78 handlers(this);
79 return true;
80}
81
82bool Model::hasAnimation(String name) const {
83 return _modelDef->getAnimationIndexByName(name) != Animation::None;

Callers

nothing calls this directly

Calls 14

make_pairFunction · 0.85
emitFunction · 0.85
setSizeFunction · 0.85
addChildFunction · 0.85
getRootMethod · 0.80
getClipFileMethod · 0.65
loadMethod · 0.65
initFunction · 0.50
createFunction · 0.50
visitFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected