| 1791 | } |
| 1792 | |
| 1793 | NodePath SceneState::get_node_path(int p_idx, bool p_for_parent) const { |
| 1794 | ERR_FAIL_INDEX_V(p_idx, nodes.size(), NodePath()); |
| 1795 | |
| 1796 | if (nodes[p_idx].parent < 0 || nodes[p_idx].parent == NO_PARENT_SAVED) { |
| 1797 | if (p_for_parent) { |
| 1798 | return NodePath(); |
| 1799 | } else { |
| 1800 | return NodePath("."); |
| 1801 | } |
| 1802 | } |
| 1803 | |
| 1804 | Vector<StringName> sub_path; |
| 1805 | NodePath base_path; |
| 1806 | int nidx = p_idx; |
| 1807 | while (true) { |
| 1808 | if (nodes[nidx].parent == NO_PARENT_SAVED || nodes[nidx].parent < 0) { |
| 1809 | sub_path.insert(0, "."); |
| 1810 | break; |
| 1811 | } |
| 1812 | |
| 1813 | if (!p_for_parent || p_idx != nidx) { |
| 1814 | sub_path.insert(0, names[nodes[nidx].name]); |
| 1815 | } |
| 1816 | |
| 1817 | if (nodes[nidx].parent & FLAG_ID_IS_PATH) { |
| 1818 | base_path = node_paths[nodes[nidx].parent & FLAG_MASK]; |
| 1819 | break; |
| 1820 | } else { |
| 1821 | nidx = nodes[nidx].parent & FLAG_MASK; |
| 1822 | } |
| 1823 | } |
| 1824 | |
| 1825 | for (int i = base_path.get_name_count() - 1; i >= 0; i--) { |
| 1826 | sub_path.insert(0, base_path.get_name(i)); |
| 1827 | } |
| 1828 | |
| 1829 | if (sub_path.is_empty()) { |
| 1830 | return NodePath("."); |
| 1831 | } |
| 1832 | |
| 1833 | return NodePath(sub_path, false); |
| 1834 | } |
| 1835 | |
| 1836 | int SceneState::get_node_property_count(int p_idx) const { |
| 1837 | ERR_FAIL_INDEX_V(p_idx, nodes.size(), -1); |