MCPcopy Create free account
hub / github.com/crownengine/crown / find_unit_index

Function find_unit_index

src/resource/unit_compiler.cpp:731–769  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729 }
730
731 u32 find_unit_index(UnitCompiler &c, Guid unit_id, u32 root_unit_index)
732 {
733 Unit *root = find_root_unit(c, root_unit_index);
734 if (root != NULL) {
735 auto cur = hash_map::begin(c._units);
736 auto end = hash_map::end(c._units);
737 for (; cur != end; ++cur) {
738 HASH_MAP_SKIP_HOLE(c._units, cur);
739
740 if (cur->second != root)
741 continue;
742
743 if (cur->first == unit_id) {
744 return cur->second->_index;
745 }
746
747 const u32 child_index = find_child_unit_index(root, unit_id);
748 if (child_index != UINT32_MAX)
749 return child_index;
750
751 break;
752 }
753 }
754
755 auto cur = hash_map::begin(c._units);
756 auto end = hash_map::end(c._units);
757 for (; cur != end; ++cur) {
758 HASH_MAP_SKIP_HOLE(c._units, cur);
759
760 if (cur->first == unit_id)
761 return cur->second->_index;
762
763 const u32 child_index = find_child_unit_index(cur->second, unit_id);
764 if (child_index != UINT32_MAX)
765 return child_index;
766 }
767
768 return UINT32_MAX;
769 }
770
771 Unit *find_unit(UnitCompiler &c, u32 unit_index)
772 {

Callers 2

joint_common_parseFunction · 0.85
compile_lod_groupFunction · 0.85

Calls 4

find_root_unitFunction · 0.85
find_child_unit_indexFunction · 0.85
beginFunction · 0.50
endFunction · 0.50

Tested by

no test coverage detected