diff --git a/testsuite/test_1331/README b/testsuite/test_1331/README new file mode 100644 index 0000000000..51294e524c --- /dev/null +++ b/testsuite/test_1331/README @@ -0,0 +1,7 @@ +Motion blur with skinned instances + +Fixes #1331 + +author: sebastien ortega + +PARAMS: {'scene':'test.usda'} \ No newline at end of file diff --git a/testsuite/test_1331/data/skin.usd b/testsuite/test_1331/data/skin.usd new file mode 100644 index 0000000000..3301ea079b Binary files /dev/null and b/testsuite/test_1331/data/skin.usd differ diff --git a/testsuite/test_1331/data/test.usda b/testsuite/test_1331/data/test.usda new file mode 100644 index 0000000000..d8a30cd74e --- /dev/null +++ b/testsuite/test_1331/data/test.usda @@ -0,0 +1,132 @@ +#usda 1.0 +( + customLayerData = { + timecode[] timeCodeArray = [18] + } + defaultPrim = "persp" + endFrame = 28 + startFrame = 18 +) + +def ArnoldOptions "options" +{ + int arnold:AA_samples = 3 + int arnold:AA_seed = 18 + string arnold:camera = "/persp/perspShape" + float arnold:frame = 18 + int arnold:GI_diffuse_depth = 1 + int arnold:GI_specular_depth = 1 + int arnold:GI_transmission_depth = 8 + float arnold:meters_per_unit = 0.01 + string arnold:name = "options" + string[] arnold:outputs = ["RGBA RGBA defaultArnoldFilter/gaussian_filter defaultArnoldDriver/driver_exr.RGBA"] + bool arnold:texture_automip = 0 + bool arnold:texture_per_file_stats = 1 + int arnold:threads = 64 + int arnold:xres = 960 + int arnold:yres = 540 + string primvars:render_layer = "defaultRenderLayer" ( + elementSize = 1 + interpolation = "constant" + ) +} + +def "defaultArnoldFilter" +{ + def ArnoldGaussianFilter "gaussian_filter" + { + string arnold:name = "defaultArnoldFilter/gaussian_filter" + } +} + +def "defaultArnoldDriver" +{ + def ArnoldDriverTiff "driver_exr_RGBA" + { + string arnold:color_space = "" + string arnold:filename = "testrender.tif" + string arnold:name = "defaultArnoldDriver/driver_exr.RGBA" + } +} + +def Xform "persp" +{ + def Camera "perspShape" + { + float2 clippingRange = (0.1, 10000) + float focusDistance = 1 + float horizontalAperture = 51.428566 + float[] primvars:arnold:aperture_size = [0] + float[] primvars:arnold:fov.timeSamples = { + 17.5: [54.432224], + 18.5: [54.432224], + } + float2[] primvars:arnold:lens_shift.timeSamples = { + 17.5: [(0, 0)], + 18.5: [(0, 0)], + } + float2[] primvars:arnold:lens_tilt_angle.timeSamples = { + 17.5: [(0, 0)], + 18.5: [(0, 0)], + } + vector3f[] primvars:arnold:look_at = [(0, 0, -1)] + float primvars:arnold:motion_end = 0.5 + float primvars:arnold:motion_start = -0.5 + vector3f[] primvars:arnold:position = [(0, 0, 0)] + float2[] primvars:arnold:screen_window_max = [(1, 1)] + float2[] primvars:arnold:screen_window_min = [(-1, -1)] + vector3f[] primvars:arnold:up = [(0, 1, 0)] + color4f primvars:arnold:uv_remap = (0, 0, 0, 1) + string primvars:dcc_name = "perspShape" ( + elementSize = 1 + interpolation = "constant" + ) + token projection = "perspective" + double shutter:close = 0.95 + double shutter:open = -0.95 + float verticalAperture = 28.928568 + matrix4d xformOp:transform.timeSamples = { + 17.5: ( (0.9876883625984192, 0, 0.15643446147441864, 0), (-0.012169312685728073, 0.9969696402549744, 0.07683401554822922, 0), (-0.15596041083335876, -0.07779175788164139, 0.9846952557563782, 0), (-116.20807647705078, 5.309322834014893, 66.05921936035156, 1) ), + 18.5: ( (0.9876883625984192, 0, 0.15643446147441864, 0), (-0.012169312685728073, 0.9969696402549744, 0.07683401554822922, 0), (-0.15596041083335876, -0.07779175788164139, 0.9846952557563782, 0), (-116.20807647705078, 5.309322834014893, 66.05921936035156, 1) ), + } + uniform token[] xformOpOrder = ["xformOp:transform"] + } +} + +def Xform "directionalLight1" +{ + def DistantLight "directionalLightShape1" + { + float inputs:angle = 0 + color3f inputs:color = (1, 1, 1) + float inputs:diffuse = 1 + float inputs:exposure = 0 + float inputs:intensity = 1 + float inputs:specular = 1 + vector3f[] primvars:arnold:direction = [(0, 0, -1)] + float primvars:arnold:motion_end = 0.5 + float primvars:arnold:motion_start = -0.5 + bool primvars:arnold:normalize = 1 + string primvars:dcc_name = "directionalLightShape1" ( + elementSize = 1 + interpolation = "constant" + ) + } +} + +def Xform "debug_mb_v3" +{ + def ArnoldUsd "debug_mb_v3Shape" + { + string arnold:filename = "skin.usd" + float arnold:frame = 18 + float arnold:motion_end = 1 + float arnold:motion_start = -1 + float3[] extent = [(-0.02561806, -0.0003810035, -0.0042395806), (0.025619365, 0.061435837, 0.00855701)] + string primvars:dcc_name = "debug_mb_v3Shape" ( + elementSize = 1 + interpolation = "constant" + ) + } +} + diff --git a/testsuite/test_1331/ref/reference.log b/testsuite/test_1331/ref/reference.log new file mode 100644 index 0000000000..9fccca32e0 --- /dev/null +++ b/testsuite/test_1331/ref/reference.log @@ -0,0 +1,237 @@ +00:00:00 90MB | log started Tue Oct 25 23:19:37 2022 +00:00:00 90MB | Arnold 7.1.4.0 [af215a92] windows clang-10.0.1 oiio-2.4.1 osl-1.12.0 vdb-7.1.1 adlsdk-7.4.2.47 clmhub-3.1.0.27 rlm-14.1.3 optix-6.6.0 2022/10/20 18:08:08 +00:00:00 90MB | running on REMS4QL1726, pid=63700 +00:00:00 90MB | 2 x Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz (32 cores, 64 logical) with 65154MB +00:00:00 103MB | NVIDIA driver version 511.65 (Optix 60802) +00:00:00 103MB | GPU 0: Quadro RTX 4000 @ 1545MHz (compute 7.5) with 8191MB (6468MB available) (NVLink:0) +00:00:00 103MB | Windows 10 (version 10.0, build 19044) +00:00:00 103MB | soft limit for open files is set at 2048 +00:00:00 103MB | +00:00:00 120MB | [color_manager_ocio] default ocio.config found in C:\arnold\sdk\latest\bin\../ocio/configs/arnold/config.ocio +00:00:00 120MB | loading plugins from C:\arnold\arnold-usd\build\windows_x86_64\msvc_opt\usd-0.21.8_arnold-7.1.4.0\procedural ... +00:00:00 124MB | usd_proc.dll: usd uses Arnold 7.1.4.0 +00:00:00 124MB | loaded 1 plugins from 1 lib(s) in 0:00.07 +00:00:00 124MB | loading plugins from C:\arnold\sdk\latest\bin\..\plugins ... +00:00:00 124MB | alembic_proc.dll: alembic uses Arnold 7.1.4.0 +00:00:00 124MB | cryptomatte.dll: cryptomatte uses Arnold 7.1.4.0 +00:00:00 124MB | cryptomatte.dll: cryptomatte_filter uses Arnold 7.1.4.0 +00:00:00 124MB | cryptomatte.dll: cryptomatte_manifest_driver uses Arnold 7.1.4.0 +00:00:00 124MB | skipping already loaded plugin: C:\arnold\sdk\latest\bin\..\plugins\usd_proc.dll ... +00:00:00 124MB | loaded 4 plugins from 2 lib(s) in 0:00.00 +00:00:00 124MB | [color_manager_ocio] default ocio.config found in C:\arnold\sdk\latest\bin\../ocio/configs/arnold/config.ocio +00:00:00 140MB | [kick] command: C:\arnold\sdk\latest\bin\kick test.usda -dw -r 160 120 -sm lambert -bs 16 -o testrender.tif -set driver_tiff.dither false -nocrashpopup -dp -v 6 +00:00:00 140MB | loading plugins from . ... +00:00:00 140MB | no plugins loaded +00:00:00 174MB WARNING | USD arnold attribute extent not recognized in usd for /debug_mb_v3/debug_mb_v3Shape +00:00:00 174MB | [kick] applying 2 attr value overrides +00:00:00 174MB | +00:00:00 174MB | authorizing with license manager: network ... +00:00:00 175MB WARNING | rendering with watermarks because of failed authorization: +00:00:00 175MB | [clm.v1] license server was not set (51) +00:00:00 175MB | environment variables: +00:00:00 175MB | ARNOLD_LICENSE_ORDER = (not set) +00:00:00 175MB | ARNOLD_LICENSE_MANAGER = (not set) +00:00:00 175MB | [rlm] solidangle_LICENSE = (not set) +00:00:00 175MB | [rlm] RLM_LICENSE = (not set) +00:00:00 175MB | [clm] ADSKFLEX_LICENSE_FILE = (not set) +00:00:00 175MB | [clm] LM_LICENSE_FILE = (not set) +00:00:00 175MB | +00:00:00 175MB | [color_manager] using color manager of type "color_manager_ocio" +00:00:00 176MB | [color_manager_ocio] using config file C:/maya/runtimes/maya2023/resources/OCIO-configs/Maya2022-default/config.ocio +00:00:00 176MB | [color_manager] rendering color space is "ACEScg" +00:00:00 190MB | +00:00:00 190MB | there are 1 light and 2 objects: +00:00:00 190MB | 1 persp_camera +00:00:00 190MB | 1 distant_light +00:00:00 190MB | 2 utility +00:00:00 190MB | 1 driver_tiff +00:00:00 190MB | 1 gaussian_filter +00:00:00 190MB | 2 list_aggregate +00:00:00 190MB | 3 color_manager_ocio +00:00:00 190MB | 1 usd +00:00:00 190MB | +00:00:00 190MB | rendering image at 160 x 120, 3 AA samples +00:00:00 190MB | AA samples max +00:00:00 190MB | AA sample clamp +00:00:00 190MB | diffuse samples 2 / depth 1 +00:00:00 190MB | specular samples 2 / depth 1 +00:00:00 190MB | transmission samples 2 / depth 8 +00:00:00 190MB | volume indirect +00:00:00 190MB | total depth 10 +00:00:00 190MB | bssrdf samples 2 +00:00:00 190MB | transparency depth 10 +00:00:00 190MB | initializing 10 nodes +!!!! 50 +!!!! 50 +!!!! 50 +!!!! 50 +!!!! 50 +!!!! 50 +!!!! 50 +!!!! 50 +00:00:00 253MB | [proc] /debug_mb_v3/debug_mb_v3Shape: loaded 10 nodes (8 objects, 2 shaders) +00:00:00 252MB | creating root object list ... +00:00:00 252MB | node initialization done in 0:00.21 (multithreaded) +00:00:00 252MB | updating 21 nodes +00:00:00 253MB | /directionalLight1/directionalLightShape1: distant_light using 1 sample, 2 volume samples +00:00:00 253MB | [color_manager_ocio] using config file C:\arnold\sdk\latest\bin\../ocio/configs/arnold/config.ocio +00:00:00 253MB | scene bounds: (-114.347862 3.39233994 52.529705) -> (-111.77037 9.50286484 54.6970367) +00:00:00 253MB | node update done in 0:00.00 (multithreaded) +00:00:00 253MB | [aov] parsing 1 output statements ... +00:00:00 253MB | [aov] registered driver: "defaultArnoldDriver/driver_exr.RGBA" (driver_tiff) +00:00:00 253MB | [aov] * "RGBA" of type RGBA filtered by "defaultArnoldFilter/gaussian_filter" (gaussian_filter) +00:00:00 253MB | [aov] done preparing 2 AOVs for 1 output to 1 driver (0 deep AOVs) +00:00:00 254MB | starting 64 bucket workers of size 16x16 ... +00:00:00 265MB | [accel] procedural bvh4_motion3p done - 0:00.00 - 8 prims, 3 keys +00:00:00 279MB | 0% done - 85 rays/pixel +00:00:00 281MB | 5% done - 32 rays/pixel +00:00:00 281MB | 10% done - 12 rays/pixel +00:00:00 281MB | 15% done - 5 rays/pixel +00:00:00 281MB | 20% done - 29 rays/pixel +00:00:00 281MB | 25% done - 15 rays/pixel +00:00:00 282MB | 30% done - 10 rays/pixel +00:00:00 282MB | 35% done - 4 rays/pixel +00:00:00 282MB | 40% done - 6 rays/pixel +00:00:00 282MB | 45% done - 4 rays/pixel +00:00:00 282MB | 50% done - 2 rays/pixel +00:00:00 283MB | 55% done - 2 rays/pixel +00:00:00 283MB | 60% done - 1 rays/pixel +00:00:00 283MB | 65% done - 2 rays/pixel +00:00:00 292MB | [accel] polymesh bvh4_motion3p done - 0:00.01 - 18106 prims, 3 keys +00:00:00 297MB | 70% done - 8 rays/pixel +00:00:00 296MB | [accel] polymesh bvh4_motion3p done - 0:00.02 - 9022 prims, 3 keys +00:00:00 297MB | [accel] polymesh bvh4_motion3p done - 0:00.00 - 840 prims, 3 keys +00:00:00 297MB | 75% done - 7 rays/pixel +00:00:00 297MB | [accel] polymesh bvh4_motion3p done - 0:00.00 - 1150 prims, 3 keys +00:00:00 299MB | [accel] polymesh bvh4_motion3p done - 0:00.00 - 1472 prims, 3 keys +00:00:00 300MB | [accel] polymesh bvh4_motion3p done - 0:00.01 - 38246 prims, 3 keys +00:00:00 310MB | 80% done - 15 rays/pixel +00:00:00 305MB | [accel] polymesh bvh4_motion3p done - 0:00.01 - 15502 prims, 3 keys +00:00:00 307MB | [accel] polymesh bvh4_motion3p done - 0:00.02 - 42590 prims, 3 keys +00:00:00 314MB | 85% done - 43 rays/pixel +00:00:00 317MB | 90% done - 29 rays/pixel +00:00:00 318MB | 95% done - 16 rays/pixel +00:00:00 319MB | 100% done - 28 rays/pixel +00:00:00 319MB | render done in 0:00.100 +00:00:00 319MB | [driver_tiff] writing file `testrender.tif' +00:00:00 320MB | render done +00:00:00 320MB | +00:00:00 320MB | ----------------------------------------------------------------------------------- +00:00:00 320MB | scene creation time 0:00.22 machine utilization (6.29%) +00:00:00 320MB | unaccounted 0:00.22 +00:00:00 320MB | ----------------------------------------------------------------------------------- +00:00:00 320MB | frame time 0:00.36 machine utilization (61.08%) +00:00:00 320MB | node init 0:00.21 +00:00:00 320MB | driver init/close 0:00.01 +00:00:00 320MB | rendering 0:00.10 +00:00:00 320MB | subdivision 0:00.02 +00:00:00 320MB | threads blocked 0:00.02 +00:00:00 320MB | threads blocked 0:00.02 +00:00:00 320MB | accel building 0:00.05 +00:00:00 320MB | pixel rendering 0:00.02 +00:00:00 320MB | unaccounted 0:00.03 +00:00:00 320MB | ----------------------------------------------------------------------------------- +00:00:00 320MB | top session self-times by category +00:00:00 320MB | InitializeNodes 0:00.17 (57.12%) +00:00:00 320MB | BVH_motion::build 0:00.05 (16.56%) +00:00:00 320MB | thread blocked 0:00.02 ( 8.49%) +00:00:00 320MB | UpdateNodes 0:00.01 ( 4.68%) +00:00:00 320MB | BVH_motion::intersect 0:00.00 ( 2.38%) +00:00:00 320MB | /debug_mb_v3/debug_mb_v3Shape 0:00.00 ( 0.95%) +00:00:00 320MB | /crowds/civilianCrowd_1137/FLB_C_Body_large_STEP1_B1DMAPShape/mesh_0 0:00.00 ( 0.56%) +00:00:00 320MB | TraceCameraRay 0:00.00 ( 1.75%) +00:00:00 320MB | ----------------------------------------------------------------------------------- +00:00:00 320MB | top session self-times by node +00:00:00 320MB | InitializeNodes 0:00.17 (57.12%) +00:00:00 320MB | polymesh:/crowds/civilianCrowd_1137/FLB_C_FullShirt_FLB_CSDMShape/mesh_0 0:00.04 (13.16%) +00:00:00 320MB | BVH_motion::build 0:00.02 ( 9.51%) +00:00:00 320MB | thread blocked 0:00.00 ( 2.54%) +00:00:00 320MB | polymesh:/crowds/civilianCrowd_1137/FLB_C_Body_large_STEP1_B1DMAPShape/mesh_0 0:00.03 (11.18%) +00:00:00 320MB | thread blocked 0:00.01 ( 5.41%) +00:00:00 320MB | BVH_motion::build 0:00.01 ( 4.75%) +00:00:00 320MB | BVH_motion::intersect 0:00.00 ( 0.56%) +00:00:00 320MB | UpdateNodes 0:00.01 ( 4.68%) +00:00:00 320MB | polymesh:/crowds/civilianCrowd_1137/FLB_C_Pants_FLB_CSDMShape/mesh_0 0:00.01 ( 3.23%) +00:00:00 320MB | BVH_motion::build 0:00.00 ( 2.14%) +00:00:00 320MB | usd:/debug_mb_v3/debug_mb_v3Shape 0:00.00 ( 1.81%) +00:00:00 320MB | BVH_motion::intersect 0:00.00 ( 0.95%) +00:00:00 320MB | node_init 0:00.00 ( 0.86%) +00:00:00 320MB | ----------------------------------------------------------------------------------- +00:00:00 320MB | peak CPU memory used 320.90MB +00:00:00 320MB | at startup 103.09MB +00:00:00 320MB | AOV samples 2.94MB +00:00:00 320MB | output buffers 0.33MB +00:00:00 320MB | framebuffers 0.31MB +00:00:00 320MB | node overhead 0.01MB +00:00:00 320MB | message passing 0.13MB +00:00:00 320MB | memory pools 71.05MB +00:00:00 320MB | geometry 20.76MB +00:00:00 320MB | polymesh 20.76MB +00:00:00 320MB | accel structs 14.90MB +00:00:00 320MB | strings 24.25MB +00:00:00 320MB | profiler 0.05MB +00:00:00 320MB | unaccounted 83.09MB +00:00:00 320MB | ----------------------------------------------------------------------------------- +00:00:00 320MB | ray counts ( /pixel, /sample) (% total) (avg. hits) (max hits) +00:00:00 320MB | camera 194080 ( 10.11, 1.00) ( 70.43%) ( 0.04) ( 2) +00:00:00 320MB | shadow 13957 ( 0.73, 0.07) ( 5.07%) ( 0.06) ( 1) +00:00:00 320MB | diffuse_reflect 35353 ( 1.84, 0.18) ( 12.83%) ( 0.14) ( 2) +00:00:00 320MB | specular_reflect 32165 ( 1.68, 0.17) ( 11.67%) ( 0.11) ( 2) +00:00:00 321MB | total 275555 ( 14.35, 1.42) (100.00%) ( 0.06) ( 2) +00:00:00 321MB | by ray depth: 0 1 2 +00:00:00 321MB | total 73.3% 25.1% 1.6% +00:00:00 321MB | ----------------------------------------------------------------------------------- +00:00:00 321MB | shader calls ( /pixel, /sample) (% total) +00:00:00 321MB | primary 33520 ( 1.75, 0.17) (100.00%) +00:00:00 321MB | total 33520 ( 1.75, 0.17) (100.00%) +00:00:00 321MB | by ray depth: 0 1 2 +00:00:00 321MB | total 48.2% 44.5% 7.3% +00:00:00 321MB | ----------------------------------------------------------------------------------- +00:00:00 321MB | geometry (% hit ) (instances) ( init mem, final mem) +00:00:00 321MB | lists 1 (100.0%) ( 0) ( 0.00, 0.00) +00:00:00 321MB | procs 1 (100.0%) ( 0) ( 0.00, 0.00) +00:00:00 321MB | polymeshes 8 (100.0%) ( 0) ( 19.84, 20.76) +00:00:00 321MB | ----------------------------------------------------------------------------------- +00:00:00 321MB | geometric elements ( min) ( avg.) ( max) +00:00:00 321MB | objects (procs) 8 ( 8) ( 8.0) ( 8) +00:00:00 321MB | polygons 126928 ( 840) ( 15866.0) ( 42590) +00:00:00 321MB | ----------------------------------------------------------------------------------- +00:00:00 321MB | triangle tessellation ( min) ( avg.) ( max) (/ element) (% total) +00:00:00 321MB | polymeshes 157006 ( 1440) ( 19625.8) ( 42590) ( 1.24) (100.00%) +00:00:00 321MB | unique triangles 157006 +00:00:00 321MB | visible triangles 314012 +00:00:00 321MB | CPU memory use 20.76MB +00:00:00 321MB | vertices 2.74MB +00:00:00 321MB | vertex indices 0.75MB +00:00:00 321MB | packed normals 0.91MB +00:00:00 321MB | normal indices 0.00MB +00:00:00 321MB | uv coords 0.34MB +00:00:00 321MB | uv coords idxs 0.75MB +00:00:00 321MB | uniform indices 0.23MB +00:00:00 321MB | userdata 15.02MB +00:00:00 321MB | largest polymeshes by triangle count +00:00:00 321MB | 42590 tris -- /crowds/civilianCrowd_1137/FLB_C_FullShirt_FLB_CSDMShape/mesh_0 +00:00:00 321MB | 38246 tris -- /crowds/civilianCrowd_1137/FLB_C_Pants_FLB_CSDMShape/mesh_0 +00:00:00 321MB | 36212 tris -- /crowds/civilianCrowd_1137/FLB_C_Body_large_STEP1_B1DMAPShape/mesh_0 +00:00:00 321MB | 17772 tris -- /crowds/civilianCrowd_1137/FLB_C_Shoes_FLB_CSDMShape/mesh_0 +00:00:00 321MB | 15502 tris -- /crowds/civilianCrowd_1137/FLB_C_Shirt_FLB_CSDMShape/mesh_0 +00:00:00 321MB | ----------------------------------------------------------------------------------- +00:00:00 321MB | acceleration structures: (% total) +00:00:00 321MB | list 1 ( 10.00%) +00:00:00 321MB | bvh motion (3+ keys) 9 ( 90.00%) +00:00:00 321MB | total 10 (100.00%) +00:00:00 321MB | ----------------------------------------------------------------------------------- +00:00:00 321MB | number of warnings, warning type: +00:00:00 321MB | 1: USD arnold attribute %s not recognized in %s for %s +00:00:00 321MB | 1: rendering with watermarks because of failed authorization: +00:00:00 321MB | ----------------------------------------------------------------------------------- +00:00:00 320MB | +00:00:00 320MB | releasing resources +00:00:00 207MB | +00:00:00 207MB | releasing resources +00:00:00 187MB | unloading 3 plugins +00:00:00 187MB | closing usd_proc.dll ... +00:00:00 187MB | closing alembic_proc.dll ... +00:00:00 187MB | closing cryptomatte.dll ... +00:00:00 186MB | unloading plugins done +00:00:00 187MB | Arnold shutdown diff --git a/testsuite/test_1331/ref/reference.tif b/testsuite/test_1331/ref/reference.tif new file mode 100644 index 0000000000..68152257e9 Binary files /dev/null and b/testsuite/test_1331/ref/reference.tif differ diff --git a/translator/reader/read_skinning.cpp b/translator/reader/read_skinning.cpp index 82625ec689..8568dcbecf 100644 --- a/translator/reader/read_skinning.cpp +++ b/translator/reader/read_skinning.cpp @@ -402,6 +402,42 @@ _WorldTransformMightBeTimeVarying(const UsdPrim& prim, return false; } +// We don't want to only use time samples included in a given interval, +// so we can't rely on USD builtin functions (e.g. GetTimeSamplesInInterval, etc..) +// If an attribute has time sample outside of the interval bounds, we want to consider +// these interval bounds in our evaluation. Otherwise an animated attribute will show as static +void _InsertTimesInInterval(const GfInterval &interval, + std::vector& allTimes, std::vector* outTimes) +{ + bool foundTimes = false; + double minTime = interval.GetMin(); + double maxTime = interval.GetMax(); + outTimes->reserve(outTimes->size() + allTimes.size()); + + for (size_t i = 0; i < allTimes.size(); ++i) { + double val = allTimes[i]; + if (val > maxTime) { + // time value is higher than the interval. + // If we already found times so far, we want + // to add the max interval bound time + if (foundTimes) + outTimes->push_back(maxTime); + return; + } else if (val >= minTime) { + // The value is inside the time interval. + // If it's the first time sample we want, and if other + // samples were lower than the interval's minimum, + // we want to ensure we add the min time to our time samples + if (!foundTimes && i > 0 && val != minTime) { + outTimes->push_back(minTime); + } + outTimes->push_back(val); + foundTimes = true; + if (val == maxTime) + return; + } + } +} void _ExtendWorldTransformTimeSamples(const UsdPrim& prim, @@ -409,12 +445,13 @@ _ExtendWorldTransformTimeSamples(const UsdPrim& prim, std::vector* times) { std::vector tmpTimes; + for (UsdPrim p = prim; !p.IsPseudoRoot(); p = p.GetParent()) { if (p.IsA()) { const UsdGeomXformable xformable(prim); const UsdGeomXformable::XformQuery query(xformable); - if (query.GetTimeSamplesInInterval(interval, &tmpTimes)) { - times->insert(times->end(), tmpTimes.begin(), tmpTimes.end()); + if (query.GetTimeSamples(&tmpTimes)) { + _InsertTimesInInterval(interval, tmpTimes, times); } if (query.GetResetXformStack()) { break; @@ -497,17 +534,15 @@ _SkelAdapter::ExtendTimeSamples(const GfInterval& interval, std::vector tmpTimes; if (_skinningXformsTask) { if (const auto& animQuery = _skelQuery.GetAnimQuery()) { - if (animQuery.GetJointTransformTimeSamplesInInterval( - interval, &tmpTimes)) { - times->insert(times->end(), tmpTimes.begin(), tmpTimes.end()); + if (animQuery.GetJointTransformTimeSamples(&tmpTimes)) { + _InsertTimesInInterval(interval, tmpTimes, times); } } } if (_blendShapeWeightsTask) { if (const auto& animQuery = _skelQuery.GetAnimQuery()) { - if (animQuery.GetBlendShapeWeightTimeSamplesInInterval( - interval, &tmpTimes)) { - times->insert(times->end(), tmpTimes.begin(), tmpTimes.end()); + if (animQuery.GetBlendShapeWeightTimeSamples(&tmpTimes)) { + _InsertTimesInInterval(interval, tmpTimes, times); } } } @@ -989,29 +1024,25 @@ _SkinningAdapter::ExtendTimeSamples(const GfInterval& interval, { std::vector tmpTimes; if (_restPointsTask) { - if (_restPointsQuery.GetTimeSamplesInInterval( - interval, &tmpTimes)) { - times->insert(times->end(), tmpTimes.begin(), tmpTimes.end()); + if (_restPointsQuery.GetTimeSamples(&tmpTimes)) { + _InsertTimesInInterval(interval, tmpTimes, times); } } if (_restNormalsTask) { - if (_restNormalsQuery.GetTimeSamplesInInterval( - interval, &tmpTimes)) { - times->insert(times->end(), tmpTimes.begin(), tmpTimes.end()); + if (_restNormalsQuery.GetTimeSamples(&tmpTimes)) { + _InsertTimesInInterval(interval, tmpTimes, times); } } if (_geomBindXformTask && _geomBindXformQuery) { - if (_geomBindXformQuery.GetTimeSamplesInInterval( - interval, &tmpTimes)) { - times->insert(times->end(), tmpTimes.begin(), tmpTimes.end()); + if (_geomBindXformQuery.GetTimeSamples(&tmpTimes)) { + _InsertTimesInInterval(interval, tmpTimes, times); } } if (_jointInfluencesTask) { for (const auto& pv : {_skinningQuery.GetJointIndicesPrimvar(), _skinningQuery.GetJointWeightsPrimvar()}) { - if (pv.GetTimeSamplesInInterval( - interval, &tmpTimes)) { - times->insert(times->end(), tmpTimes.begin(), tmpTimes.end()); + if (pv.GetTimeSamples(&tmpTimes)) { + _InsertTimesInInterval(interval, tmpTimes, times); } } } @@ -1763,44 +1794,50 @@ bool UsdArnoldSkelData::ApplyPointsSkinning(const UsdPrim &prim, const VtArraytimes.size(); ++ti) { const UsdTimeCode t = _impl->times[ti]; - if (t.GetValue() != time) - continue; + if (t.GetValue() == time) + { + timeIndex = ti; + break; + } + } + if (timeIndex < 0) + return false; + + UsdGeomXformCache *xfCache = _FindXformCache(context, time, localXfCache); + const UsdTimeCode t = _impl->times[timeIndex]; - UsdGeomXformCache *xfCache = _FindXformCache(context, time, localXfCache); + // FIXME Ensure that we're only updating the adapters for what we need (points/normals) + for (const auto& skelAdapter : _impl->skelAdapters) { + skelAdapter->UpdateTransform(timeIndex, xfCache); + } - // FIXME Ensure that we're only updating the adapters for what we need (points/normals) - for (const auto& skelAdapter : _impl->skelAdapters) { - skelAdapter->UpdateTransform(ti, xfCache); - } + for (const auto& skinningAdapter : _impl->skinningAdapters) { + skinningAdapter->UpdateTransform(timeIndex, xfCache); + } - for (const auto& skinningAdapter : _impl->skinningAdapters) { - skinningAdapter->UpdateTransform(ti, xfCache); - } + for (const auto& skelAdapter : _impl->skelAdapters) { + skelAdapter->UpdateAnimation(t, timeIndex); + } - for (const auto& skelAdapter : _impl->skelAdapters) { - skelAdapter->UpdateAnimation(t, ti); - } + for (const auto& skinningAdapter : _impl->skinningAdapters) { + skinningAdapter->Update(t, timeIndex); + } - for (const auto& skinningAdapter : _impl->skinningAdapters) { - skinningAdapter->Update(t, ti); - } - - // Apply the results from each skinning adapter. - for (const auto& skinningAdapter : _impl->skinningAdapters) { - if (s == SKIN_POINTS) { - if (skinningAdapter->GetPoints(output, ti)) - return true; - } else if (s == SKIN_NORMALS) { - if (skinningAdapter->GetNormals(output, ti)) - return true; - } + // Apply the results from each skinning adapter. + for (const auto& skinningAdapter : _impl->skinningAdapters) { + if (s == SKIN_POINTS) { + if (skinningAdapter->GetPoints(output, timeIndex)) + return true; + } else if (s == SKIN_NORMALS) { + if (skinningAdapter->GetNormals(output, timeIndex)) + return true; } - break; - } + return false; } diff --git a/translator/reader/utils.cpp b/translator/reader/utils.cpp index 4e45ffe190..f1902e061a 100644 --- a/translator/reader/utils.cpp +++ b/translator/reader/utils.cpp @@ -503,7 +503,6 @@ size_t ReadTopology(UsdAttribute& usdAttr, AtNode* node, const char* attrName, c bool animated = time.motionBlur && usdAttr.ValueMightBeTimeVarying(); UsdArnoldSkelData *skelData = context.GetSkelData(); - const std::vector *skelTimes = (skelData) ? &(skelData->GetTimes()) : nullptr; if (skelTimes && skelTimes->size() > 1) animated = true; @@ -532,7 +531,6 @@ size_t ReadTopology(UsdAttribute& usdAttr, AtNode* node, const char* attrName, c return 1; // return the amount of keys } else { - // Animated array GfInterval interval(time.start(), time.end(), false, false); size_t numKeys = 0; @@ -544,10 +542,10 @@ size_t ReadTopology(UsdAttribute& usdAttr, AtNode* node, const char* attrName, c std::vector timeSamples; usdAttr.GetTimeSamplesInInterval(interval, &timeSamples); numKeys = timeSamples.size(); + // need to add the start end end keys (interval has open bounds) + numKeys += 2; } - // need to add the start end end keys (interval has open bounds) - numKeys += 2; - + float timeStep = float(interval.GetMax() - interval.GetMin()) / int(numKeys - 1); float timeVal = interval.GetMin();