mirror of
https://github.com/blender/blender
synced 2026-11-22 03:45:13 +03:00
This commit bumps the `ios` branch from 5.0.0 alpha to 5.1.2 release. I merged v5.0-release first then v5.1-release. So it was a sequential merge. I'm just waiting to the approval of continuing development. The stuff that are missing (those are so close to implement): - #145484 iOS: Keyboard Input Support: https://projects.blender.org/blender/blender/pulls/145484 - #145702 iOS: Add clipboard Image: https://projects.blender.org/blender/blender/pulls/145702 - Fix QOS threading - Expose Downloads - UIScene Migration `make deps` needs to run two times. (still hacky....) OSL occurs racing conditions. Disclaimer: I used AI for searching in Documentation of Deps. So the implementation is by hand. **SACRED PINKY FINGER PROMISE** Pull Request: https://projects.blender.org/blender/blender/pulls/161073
53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
# SPDX-FileCopyrightText: 2022-2023 Blender Authors
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
import bpy
|
|
|
|
|
|
__all__ = (
|
|
"get_id_reference_map",
|
|
"get_all_referenced_ids",
|
|
)
|
|
|
|
|
|
def get_id_reference_map():
|
|
"""Return a dictionary of direct data-block references for every data-block in the blend file.
|
|
|
|
:return: Each datablock of the .blend file mapped to the set of IDs they directly reference.
|
|
:rtype: dict[bpy.types.ID, set[bpy.types.ID]]
|
|
"""
|
|
inv_map = {}
|
|
for key, values in bpy.data.user_map().items():
|
|
for value in values:
|
|
if value == key:
|
|
# So an object is not considered to be referencing itself.
|
|
continue
|
|
inv_map.setdefault(value, set()).add(key)
|
|
return inv_map
|
|
|
|
|
|
def get_all_referenced_ids(id, ref_map):
|
|
"""
|
|
Return a set of IDs directly or indirectly referenced by id.
|
|
|
|
:param id: Datablock whose references we're interested in.
|
|
:type id: bpy.types.ID
|
|
:param ref_map: The global ID reference map, retrieved from get_id_reference_map()
|
|
:type ref_map: dict[bpy.types.ID, set[bpy.types.ID]]
|
|
:return: Set of datablocks referenced by `id`.
|
|
:rtype: set[bpy.types.ID]
|
|
"""
|
|
|
|
def recursive_helper(ref_map, id, referenced_ids, visited):
|
|
if id in visited:
|
|
# Avoid infinite recursion from circular references.
|
|
return
|
|
visited.add(id)
|
|
for ref in ref_map.get(id, []):
|
|
referenced_ids.add(ref)
|
|
recursive_helper(ref_map=ref_map, id=ref, referenced_ids=referenced_ids, visited=visited)
|
|
|
|
referenced_ids = set()
|
|
recursive_helper(ref_map=ref_map, id=id, referenced_ids=referenced_ids, visited=set())
|
|
return referenced_ids
|