MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / Read

Method Read

Source/Graphics/skeleton.cpp:682–900  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680}
681
682int Skeleton::Read(const std::string &path, float scale, float mass_scale, const FZXAssetRef &fzx_ref) {
683 // skeleton_asset_ref = SkeletonAssets::Instance()->ReturnRef(path);
684 skeleton_asset_ref = Engine::Instance()->GetAssetManager()->LoadSync<SkeletonAsset>(path);
685 const SkeletonFileData &data = skeleton_asset_ref->GetData();
686
687 RiggingStage rigging_stage = data.rigging_stage;
688
689 // Load points
690 int num_points = data.points.size();
691 for (int i = 0; i < num_points; i++) {
692 points.push_back(data.points[i] * scale);
693 }
694
695 // Load bones that connect points
696 int num_bones = data.bone_ends.size() / 2;
697 bones.resize(num_bones);
698 for (int i = 0; i < num_bones; i++) {
699 bones[i].points[0] = data.bone_ends[i * 2 + 0];
700 bones[i].points[1] = data.bone_ends[i * 2 + 1];
701 }
702
703 // Load mass of each bone
704 if (!data.bone_mass.empty()) {
705 for (int i = 0; i < num_bones; i++) {
706 bones[i].mass = data.bone_mass[i] * mass_scale * mass_scale * mass_scale;
707 }
708 }
709
710 // Load center of mass for each bone
711 if (!data.bone_com.empty()) {
712 for (int i = 0; i < num_bones; i++) {
713 bones[i].center_of_mass = data.bone_com[i] * scale;
714 }
715 }
716
717 simple_ik_bones = data.simple_ik_bones;
718
719 if (rigging_stage == _control_joints) {
720 PhysicsDispose();
721 col_bullet_world.reset(new BulletWorld());
722 col_bullet_world->Init();
723 physics_bones.resize(bones.size());
724
725 has_verts_assigned.clear();
726 has_verts_assigned.resize(physics_bones.size(), false);
727 for (unsigned i = 0; i < data.model_bone_ids.size(); ++i) {
728 for (int j = 0; j < 4; ++j) {
729 if (data.model_bone_weights[i][j] > 0.0f) {
730 has_verts_assigned[int(data.model_bone_ids[i][j])] = true;
731 }
732 }
733 }
734
735 parents = data.hier_parents;
736
737 for (unsigned i = 0; i < physics_bones.size(); ++i) {
738 physics_bones[i].physics_mass = bones[i].mass;
739 }

Callers 1

LoadMethod · 0.45

Calls 13

GetAssetManagerMethod · 0.80
UnlinkObjectPermanentMethod · 0.80
vec3Class · 0.50
GetDataMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
resizeMethod · 0.45
emptyMethod · 0.45
resetMethod · 0.45
InitMethod · 0.45
clearMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected