Cleanup: USD: Use the SdfPath type rather than a std::string
Instead of converting to a string immediately, only convert to a string when necessary, like for trace logging. This reduces the size of the `USDPrimReader` base class by 24 bytes, makes several Vectors and Maps smaller at runtime, and reduces some unnecessary string allocations and conversions in various other places. The recently added python Hook `get_prim_path` dictionary will now contain `SdfPath` objects rather than strings; removing the string conversion cost when calling other USD APIs like `GetPrimAtPath` which take in `SdfPath` objects to begin with. This also makes the code a bit more self explanatory since the type makes it clear what kind of path you are dealing with. Pull Request: https://projects.blender.org/blender/blender/pulls/133954
This commit is contained in:
committed by
Jesse Yurkovich
parent
35a4b2ca69
commit
6c11811710
@@ -1698,13 +1698,13 @@ class USDImportTest(AbstractUSDTest):
|
||||
bpy.utils.unregister_class(GetPrimMapUsdImportHook)
|
||||
|
||||
expected_prim_map = {
|
||||
"/Cube": [bpy.data.objects["Cube.002"], bpy.data.meshes["Cube.002"]],
|
||||
"/XformThenCube": [bpy.data.objects["XformThenCube"]],
|
||||
"/XformThenCube/Cube": [bpy.data.objects["Cube"], bpy.data.meshes["Cube"]],
|
||||
"/XformThenXformCube": [bpy.data.objects["XformThenXformCube"]],
|
||||
"/XformThenXformCube/XformIntermediate": [bpy.data.objects["XformIntermediate"]],
|
||||
"/XformThenXformCube/XformIntermediate/Cube": [bpy.data.objects["Cube.001"], bpy.data.meshes["Cube.001"]],
|
||||
"/Material": [bpy.data.materials["Material"]],
|
||||
Sdf.Path('/Cube'): [bpy.data.objects["Cube.002"], bpy.data.meshes["Cube.002"]],
|
||||
Sdf.Path('/XformThenCube'): [bpy.data.objects["XformThenCube"]],
|
||||
Sdf.Path('/XformThenCube/Cube'): [bpy.data.objects["Cube"], bpy.data.meshes["Cube"]],
|
||||
Sdf.Path('/XformThenXformCube'): [bpy.data.objects["XformThenXformCube"]],
|
||||
Sdf.Path('/XformThenXformCube/XformIntermediate'): [bpy.data.objects["XformIntermediate"]],
|
||||
Sdf.Path('/XformThenXformCube/XformIntermediate/Cube'): [bpy.data.objects["Cube.001"], bpy.data.meshes["Cube.001"]],
|
||||
Sdf.Path('/Material'): [bpy.data.materials["Material"]],
|
||||
}
|
||||
|
||||
self.assertDictEqual(prim_map, expected_prim_map)
|
||||
@@ -1716,13 +1716,13 @@ class USDImportTest(AbstractUSDTest):
|
||||
bpy.utils.unregister_class(GetPrimMapUsdImportHook)
|
||||
|
||||
expected_prim_map = {
|
||||
"/Cube": [bpy.data.objects["Cube.002"], bpy.data.meshes["Cube.002"]],
|
||||
"/XformThenCube": [bpy.data.objects["Cube"]],
|
||||
"/XformThenCube/Cube": [bpy.data.meshes["Cube"]],
|
||||
"/XformThenXformCube": [bpy.data.objects["XformThenXformCube"]],
|
||||
"/XformThenXformCube/XformIntermediate": [bpy.data.objects["Cube.001"]],
|
||||
"/XformThenXformCube/XformIntermediate/Cube": [bpy.data.meshes["Cube.001"]],
|
||||
"/Material": [bpy.data.materials["Material"]],
|
||||
Sdf.Path('/Cube'): [bpy.data.objects["Cube.002"], bpy.data.meshes["Cube.002"]],
|
||||
Sdf.Path('/XformThenCube'): [bpy.data.objects["Cube"]],
|
||||
Sdf.Path('/XformThenCube/Cube'): [bpy.data.meshes["Cube"]],
|
||||
Sdf.Path('/XformThenXformCube'): [bpy.data.objects["XformThenXformCube"]],
|
||||
Sdf.Path('/XformThenXformCube/XformIntermediate'): [bpy.data.objects["Cube.001"]],
|
||||
Sdf.Path('/XformThenXformCube/XformIntermediate/Cube'): [bpy.data.meshes["Cube.001"]],
|
||||
Sdf.Path('/Material'): [bpy.data.materials["Material"]],
|
||||
}
|
||||
|
||||
self.assertDictEqual(prim_map, expected_prim_map)
|
||||
|
||||
Reference in New Issue
Block a user