pymomentum-cpu 0.1.78.post11__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pymomentum-cpu might be problematic. Click here for more details.
- include/axel/BoundingBox.h +58 -0
- include/axel/Bvh.h +708 -0
- include/axel/BvhBase.h +75 -0
- include/axel/BvhCommon.h +43 -0
- include/axel/BvhEmbree.h +86 -0
- include/axel/BvhFactory.h +34 -0
- include/axel/Checks.h +21 -0
- include/axel/DualContouring.h +79 -0
- include/axel/KdTree.h +199 -0
- include/axel/Log.h +22 -0
- include/axel/MeshToSdf.h +123 -0
- include/axel/Profile.h +64 -0
- include/axel/Ray.h +45 -0
- include/axel/SignedDistanceField.h +248 -0
- include/axel/SimdKdTree.h +515 -0
- include/axel/TriBvh.h +157 -0
- include/axel/TriBvhEmbree.h +57 -0
- include/axel/common/Constants.h +27 -0
- include/axel/common/Types.h +21 -0
- include/axel/common/VectorizationTypes.h +58 -0
- include/axel/math/BoundingBoxUtils.h +54 -0
- include/axel/math/ContinuousCollisionDetection.h +48 -0
- include/axel/math/CoplanarityCheck.h +30 -0
- include/axel/math/EdgeEdgeDistance.h +31 -0
- include/axel/math/MeshHoleFilling.h +117 -0
- include/axel/math/PointTriangleProjection.h +34 -0
- include/axel/math/PointTriangleProjectionDefinitions.h +209 -0
- include/axel/math/RayTriangleIntersection.h +36 -0
- include/momentum/character/blend_shape.h +91 -0
- include/momentum/character/blend_shape_base.h +70 -0
- include/momentum/character/blend_shape_skinning.h +96 -0
- include/momentum/character/character.h +272 -0
- include/momentum/character/character_state.h +108 -0
- include/momentum/character/character_utility.h +128 -0
- include/momentum/character/collision_geometry.h +80 -0
- include/momentum/character/collision_geometry_state.h +130 -0
- include/momentum/character/fwd.h +262 -0
- include/momentum/character/inverse_parameter_transform.h +58 -0
- include/momentum/character/joint.h +82 -0
- include/momentum/character/joint_state.h +241 -0
- include/momentum/character/linear_skinning.h +139 -0
- include/momentum/character/locator.h +82 -0
- include/momentum/character/locator_state.h +43 -0
- include/momentum/character/marker.h +48 -0
- include/momentum/character/mesh_state.h +71 -0
- include/momentum/character/parameter_limits.h +144 -0
- include/momentum/character/parameter_transform.h +250 -0
- include/momentum/character/pose_shape.h +65 -0
- include/momentum/character/skeleton.h +85 -0
- include/momentum/character/skeleton_state.h +181 -0
- include/momentum/character/skeleton_utility.h +38 -0
- include/momentum/character/skin_weights.h +67 -0
- include/momentum/character/skinned_locator.h +80 -0
- include/momentum/character/types.h +202 -0
- include/momentum/character_sequence_solver/fwd.h +200 -0
- include/momentum/character_sequence_solver/model_parameters_sequence_error_function.h +65 -0
- include/momentum/character_sequence_solver/multipose_solver.h +65 -0
- include/momentum/character_sequence_solver/multipose_solver_function.h +82 -0
- include/momentum/character_sequence_solver/sequence_error_function.h +104 -0
- include/momentum/character_sequence_solver/sequence_solver.h +144 -0
- include/momentum/character_sequence_solver/sequence_solver_function.h +134 -0
- include/momentum/character_sequence_solver/state_sequence_error_function.h +109 -0
- include/momentum/character_sequence_solver/vertex_sequence_error_function.h +128 -0
- include/momentum/character_solver/aim_error_function.h +112 -0
- include/momentum/character_solver/collision_error_function.h +92 -0
- include/momentum/character_solver/collision_error_function_stateless.h +75 -0
- include/momentum/character_solver/constraint_error_function-inl.h +324 -0
- include/momentum/character_solver/constraint_error_function.h +248 -0
- include/momentum/character_solver/distance_error_function.h +77 -0
- include/momentum/character_solver/error_function_utils.h +60 -0
- include/momentum/character_solver/fixed_axis_error_function.h +139 -0
- include/momentum/character_solver/fwd.h +924 -0
- include/momentum/character_solver/gauss_newton_solver_qr.h +64 -0
- include/momentum/character_solver/limit_error_function.h +57 -0
- include/momentum/character_solver/model_parameters_error_function.h +64 -0
- include/momentum/character_solver/normal_error_function.h +73 -0
- include/momentum/character_solver/orientation_error_function.h +74 -0
- include/momentum/character_solver/plane_error_function.h +102 -0
- include/momentum/character_solver/point_triangle_vertex_error_function.h +141 -0
- include/momentum/character_solver/pose_prior_error_function.h +80 -0
- include/momentum/character_solver/position_error_function.h +75 -0
- include/momentum/character_solver/projection_error_function.h +93 -0
- include/momentum/character_solver/simd_collision_error_function.h +99 -0
- include/momentum/character_solver/simd_normal_error_function.h +157 -0
- include/momentum/character_solver/simd_plane_error_function.h +164 -0
- include/momentum/character_solver/simd_position_error_function.h +165 -0
- include/momentum/character_solver/skeleton_error_function.h +151 -0
- include/momentum/character_solver/skeleton_solver_function.h +94 -0
- include/momentum/character_solver/skinned_locator_error_function.h +166 -0
- include/momentum/character_solver/skinned_locator_triangle_error_function.h +146 -0
- include/momentum/character_solver/skinning_weight_iterator.h +80 -0
- include/momentum/character_solver/state_error_function.h +94 -0
- include/momentum/character_solver/transform_pose.h +80 -0
- include/momentum/character_solver/trust_region_qr.h +80 -0
- include/momentum/character_solver/vertex_error_function.h +155 -0
- include/momentum/character_solver/vertex_projection_error_function.h +126 -0
- include/momentum/character_solver/vertex_vertex_distance_error_function.h +151 -0
- include/momentum/common/aligned.h +155 -0
- include/momentum/common/checks.h +27 -0
- include/momentum/common/exception.h +70 -0
- include/momentum/common/filesystem.h +20 -0
- include/momentum/common/fwd.h +27 -0
- include/momentum/common/log.h +173 -0
- include/momentum/common/log_channel.h +17 -0
- include/momentum/common/memory.h +71 -0
- include/momentum/common/profile.h +79 -0
- include/momentum/common/progress_bar.h +37 -0
- include/momentum/common/string.h +52 -0
- include/momentum/diff_ik/ceres_utility.h +73 -0
- include/momentum/diff_ik/fully_differentiable_body_ik.h +58 -0
- include/momentum/diff_ik/fully_differentiable_distance_error_function.h +69 -0
- include/momentum/diff_ik/fully_differentiable_motion_error_function.h +46 -0
- include/momentum/diff_ik/fully_differentiable_orientation_error_function.h +114 -0
- include/momentum/diff_ik/fully_differentiable_pose_prior_error_function.h +76 -0
- include/momentum/diff_ik/fully_differentiable_position_error_function.h +138 -0
- include/momentum/diff_ik/fully_differentiable_projection_error_function.h +65 -0
- include/momentum/diff_ik/fully_differentiable_skeleton_error_function.h +160 -0
- include/momentum/diff_ik/fully_differentiable_state_error_function.h +54 -0
- include/momentum/diff_ik/fwd.h +385 -0
- include/momentum/diff_ik/union_error_function.h +67 -0
- include/momentum/gui/rerun/eigen_adapters.h +70 -0
- include/momentum/gui/rerun/logger.h +102 -0
- include/momentum/gui/rerun/logging_redirect.h +27 -0
- include/momentum/io/character_io.h +56 -0
- include/momentum/io/common/gsl_utils.h +50 -0
- include/momentum/io/common/stream_utils.h +65 -0
- include/momentum/io/fbx/fbx_io.h +109 -0
- include/momentum/io/fbx/fbx_memory_stream.h +66 -0
- include/momentum/io/fbx/openfbx_loader.h +49 -0
- include/momentum/io/fbx/polygon_data.h +60 -0
- include/momentum/io/gltf/gltf_builder.h +132 -0
- include/momentum/io/gltf/gltf_file_format.h +19 -0
- include/momentum/io/gltf/gltf_io.h +148 -0
- include/momentum/io/gltf/utils/accessor_utils.h +299 -0
- include/momentum/io/gltf/utils/coordinate_utils.h +60 -0
- include/momentum/io/gltf/utils/json_utils.h +102 -0
- include/momentum/io/legacy_json/legacy_json_io.h +70 -0
- include/momentum/io/marker/c3d_io.h +29 -0
- include/momentum/io/marker/conversions.h +57 -0
- include/momentum/io/marker/coordinate_system.h +30 -0
- include/momentum/io/marker/marker_io.h +54 -0
- include/momentum/io/marker/trc_io.h +27 -0
- include/momentum/io/motion/mmo_io.h +97 -0
- include/momentum/io/shape/blend_shape_io.h +70 -0
- include/momentum/io/shape/pose_shape_io.h +21 -0
- include/momentum/io/skeleton/locator_io.h +41 -0
- include/momentum/io/skeleton/mppca_io.h +26 -0
- include/momentum/io/skeleton/parameter_limits_io.h +25 -0
- include/momentum/io/skeleton/parameter_transform_io.h +41 -0
- include/momentum/io/skeleton/parameters_io.h +20 -0
- include/momentum/io/urdf/urdf_io.h +26 -0
- include/momentum/io/usd/usd_io.h +36 -0
- include/momentum/marker_tracking/app_utils.h +62 -0
- include/momentum/marker_tracking/marker_tracker.h +213 -0
- include/momentum/marker_tracking/process_markers.h +58 -0
- include/momentum/marker_tracking/tracker_utils.h +90 -0
- include/momentum/math/constants.h +82 -0
- include/momentum/math/covariance_matrix.h +84 -0
- include/momentum/math/fmt_eigen.h +23 -0
- include/momentum/math/fwd.h +132 -0
- include/momentum/math/generalized_loss.h +61 -0
- include/momentum/math/intersection.h +32 -0
- include/momentum/math/mesh.h +84 -0
- include/momentum/math/mppca.h +67 -0
- include/momentum/math/online_householder_qr.h +516 -0
- include/momentum/math/random-inl.h +404 -0
- include/momentum/math/random.h +310 -0
- include/momentum/math/simd_generalized_loss.h +40 -0
- include/momentum/math/transform.h +229 -0
- include/momentum/math/types.h +461 -0
- include/momentum/math/utility.h +251 -0
- include/momentum/rasterizer/camera.h +453 -0
- include/momentum/rasterizer/fwd.h +102 -0
- include/momentum/rasterizer/geometry.h +83 -0
- include/momentum/rasterizer/image.h +18 -0
- include/momentum/rasterizer/rasterizer.h +583 -0
- include/momentum/rasterizer/tensor.h +140 -0
- include/momentum/rasterizer/utility.h +268 -0
- include/momentum/simd/simd.h +221 -0
- include/momentum/solver/fwd.h +131 -0
- include/momentum/solver/gauss_newton_solver.h +136 -0
- include/momentum/solver/gradient_descent_solver.h +65 -0
- include/momentum/solver/solver.h +155 -0
- include/momentum/solver/solver_function.h +126 -0
- include/momentum/solver/subset_gauss_newton_solver.h +109 -0
- include/rerun/archetypes/annotation_context.hpp +157 -0
- include/rerun/archetypes/arrows2d.hpp +271 -0
- include/rerun/archetypes/arrows3d.hpp +257 -0
- include/rerun/archetypes/asset3d.hpp +262 -0
- include/rerun/archetypes/asset_video.hpp +275 -0
- include/rerun/archetypes/bar_chart.hpp +261 -0
- include/rerun/archetypes/boxes2d.hpp +293 -0
- include/rerun/archetypes/boxes3d.hpp +369 -0
- include/rerun/archetypes/capsules3d.hpp +333 -0
- include/rerun/archetypes/clear.hpp +180 -0
- include/rerun/archetypes/depth_image.hpp +425 -0
- include/rerun/archetypes/ellipsoids3d.hpp +384 -0
- include/rerun/archetypes/encoded_image.hpp +250 -0
- include/rerun/archetypes/geo_line_strings.hpp +166 -0
- include/rerun/archetypes/geo_points.hpp +177 -0
- include/rerun/archetypes/graph_edges.hpp +152 -0
- include/rerun/archetypes/graph_nodes.hpp +206 -0
- include/rerun/archetypes/image.hpp +434 -0
- include/rerun/archetypes/instance_poses3d.hpp +221 -0
- include/rerun/archetypes/line_strips2d.hpp +289 -0
- include/rerun/archetypes/line_strips3d.hpp +270 -0
- include/rerun/archetypes/mesh3d.hpp +387 -0
- include/rerun/archetypes/pinhole.hpp +385 -0
- include/rerun/archetypes/points2d.hpp +333 -0
- include/rerun/archetypes/points3d.hpp +369 -0
- include/rerun/archetypes/recording_properties.hpp +132 -0
- include/rerun/archetypes/scalar.hpp +170 -0
- include/rerun/archetypes/scalars.hpp +153 -0
- include/rerun/archetypes/segmentation_image.hpp +305 -0
- include/rerun/archetypes/series_line.hpp +274 -0
- include/rerun/archetypes/series_lines.hpp +271 -0
- include/rerun/archetypes/series_point.hpp +265 -0
- include/rerun/archetypes/series_points.hpp +251 -0
- include/rerun/archetypes/tensor.hpp +213 -0
- include/rerun/archetypes/text_document.hpp +200 -0
- include/rerun/archetypes/text_log.hpp +211 -0
- include/rerun/archetypes/transform3d.hpp +925 -0
- include/rerun/archetypes/video_frame_reference.hpp +295 -0
- include/rerun/archetypes/view_coordinates.hpp +393 -0
- include/rerun/archetypes.hpp +43 -0
- include/rerun/arrow_utils.hpp +32 -0
- include/rerun/as_components.hpp +90 -0
- include/rerun/blueprint/archetypes/background.hpp +113 -0
- include/rerun/blueprint/archetypes/container_blueprint.hpp +259 -0
- include/rerun/blueprint/archetypes/dataframe_query.hpp +178 -0
- include/rerun/blueprint/archetypes/entity_behavior.hpp +130 -0
- include/rerun/blueprint/archetypes/force_center.hpp +115 -0
- include/rerun/blueprint/archetypes/force_collision_radius.hpp +141 -0
- include/rerun/blueprint/archetypes/force_link.hpp +136 -0
- include/rerun/blueprint/archetypes/force_many_body.hpp +124 -0
- include/rerun/blueprint/archetypes/force_position.hpp +132 -0
- include/rerun/blueprint/archetypes/line_grid3d.hpp +178 -0
- include/rerun/blueprint/archetypes/map_background.hpp +104 -0
- include/rerun/blueprint/archetypes/map_zoom.hpp +103 -0
- include/rerun/blueprint/archetypes/near_clip_plane.hpp +109 -0
- include/rerun/blueprint/archetypes/panel_blueprint.hpp +95 -0
- include/rerun/blueprint/archetypes/plot_legend.hpp +118 -0
- include/rerun/blueprint/archetypes/scalar_axis.hpp +116 -0
- include/rerun/blueprint/archetypes/tensor_scalar_mapping.hpp +146 -0
- include/rerun/blueprint/archetypes/tensor_slice_selection.hpp +167 -0
- include/rerun/blueprint/archetypes/tensor_view_fit.hpp +95 -0
- include/rerun/blueprint/archetypes/view_blueprint.hpp +170 -0
- include/rerun/blueprint/archetypes/view_contents.hpp +142 -0
- include/rerun/blueprint/archetypes/viewport_blueprint.hpp +200 -0
- include/rerun/blueprint/archetypes/visible_time_ranges.hpp +116 -0
- include/rerun/blueprint/archetypes/visual_bounds2d.hpp +109 -0
- include/rerun/blueprint/archetypes/visualizer_overrides.hpp +113 -0
- include/rerun/blueprint/archetypes.hpp +29 -0
- include/rerun/blueprint/components/active_tab.hpp +82 -0
- include/rerun/blueprint/components/apply_latest_at.hpp +79 -0
- include/rerun/blueprint/components/auto_layout.hpp +77 -0
- include/rerun/blueprint/components/auto_views.hpp +77 -0
- include/rerun/blueprint/components/background_kind.hpp +66 -0
- include/rerun/blueprint/components/column_share.hpp +78 -0
- include/rerun/blueprint/components/component_column_selector.hpp +81 -0
- include/rerun/blueprint/components/container_kind.hpp +65 -0
- include/rerun/blueprint/components/corner2d.hpp +64 -0
- include/rerun/blueprint/components/enabled.hpp +77 -0
- include/rerun/blueprint/components/filter_by_range.hpp +74 -0
- include/rerun/blueprint/components/filter_is_not_null.hpp +77 -0
- include/rerun/blueprint/components/force_distance.hpp +82 -0
- include/rerun/blueprint/components/force_iterations.hpp +82 -0
- include/rerun/blueprint/components/force_strength.hpp +82 -0
- include/rerun/blueprint/components/grid_columns.hpp +78 -0
- include/rerun/blueprint/components/grid_spacing.hpp +78 -0
- include/rerun/blueprint/components/included_content.hpp +86 -0
- include/rerun/blueprint/components/lock_range_during_zoom.hpp +82 -0
- include/rerun/blueprint/components/map_provider.hpp +64 -0
- include/rerun/blueprint/components/near_clip_plane.hpp +82 -0
- include/rerun/blueprint/components/panel_state.hpp +61 -0
- include/rerun/blueprint/components/query_expression.hpp +89 -0
- include/rerun/blueprint/components/root_container.hpp +77 -0
- include/rerun/blueprint/components/row_share.hpp +78 -0
- include/rerun/blueprint/components/selected_columns.hpp +76 -0
- include/rerun/blueprint/components/tensor_dimension_index_slider.hpp +90 -0
- include/rerun/blueprint/components/timeline_name.hpp +76 -0
- include/rerun/blueprint/components/view_class.hpp +76 -0
- include/rerun/blueprint/components/view_fit.hpp +61 -0
- include/rerun/blueprint/components/view_maximized.hpp +79 -0
- include/rerun/blueprint/components/view_origin.hpp +81 -0
- include/rerun/blueprint/components/viewer_recommendation_hash.hpp +82 -0
- include/rerun/blueprint/components/visible_time_range.hpp +77 -0
- include/rerun/blueprint/components/visual_bounds2d.hpp +74 -0
- include/rerun/blueprint/components/visualizer_override.hpp +86 -0
- include/rerun/blueprint/components/zoom_level.hpp +78 -0
- include/rerun/blueprint/components.hpp +41 -0
- include/rerun/blueprint/datatypes/component_column_selector.hpp +61 -0
- include/rerun/blueprint/datatypes/filter_by_range.hpp +59 -0
- include/rerun/blueprint/datatypes/filter_is_not_null.hpp +61 -0
- include/rerun/blueprint/datatypes/selected_columns.hpp +62 -0
- include/rerun/blueprint/datatypes/tensor_dimension_index_slider.hpp +63 -0
- include/rerun/blueprint/datatypes.hpp +9 -0
- include/rerun/c/arrow_c_data_interface.h +111 -0
- include/rerun/c/compiler_utils.h +10 -0
- include/rerun/c/rerun.h +627 -0
- include/rerun/c/sdk_info.h +28 -0
- include/rerun/collection.hpp +496 -0
- include/rerun/collection_adapter.hpp +43 -0
- include/rerun/collection_adapter_builtins.hpp +138 -0
- include/rerun/compiler_utils.hpp +61 -0
- include/rerun/component_batch.hpp +163 -0
- include/rerun/component_column.hpp +111 -0
- include/rerun/component_descriptor.hpp +142 -0
- include/rerun/component_type.hpp +35 -0
- include/rerun/components/aggregation_policy.hpp +76 -0
- include/rerun/components/albedo_factor.hpp +74 -0
- include/rerun/components/annotation_context.hpp +102 -0
- include/rerun/components/axis_length.hpp +74 -0
- include/rerun/components/blob.hpp +73 -0
- include/rerun/components/class_id.hpp +71 -0
- include/rerun/components/clear_is_recursive.hpp +75 -0
- include/rerun/components/color.hpp +99 -0
- include/rerun/components/colormap.hpp +99 -0
- include/rerun/components/depth_meter.hpp +84 -0
- include/rerun/components/draw_order.hpp +79 -0
- include/rerun/components/entity_path.hpp +83 -0
- include/rerun/components/fill_mode.hpp +72 -0
- include/rerun/components/fill_ratio.hpp +79 -0
- include/rerun/components/gamma_correction.hpp +80 -0
- include/rerun/components/geo_line_string.hpp +63 -0
- include/rerun/components/graph_edge.hpp +75 -0
- include/rerun/components/graph_node.hpp +79 -0
- include/rerun/components/graph_type.hpp +57 -0
- include/rerun/components/half_size2d.hpp +91 -0
- include/rerun/components/half_size3d.hpp +95 -0
- include/rerun/components/image_buffer.hpp +86 -0
- include/rerun/components/image_format.hpp +84 -0
- include/rerun/components/image_plane_distance.hpp +77 -0
- include/rerun/components/interactive.hpp +76 -0
- include/rerun/components/keypoint_id.hpp +74 -0
- include/rerun/components/lat_lon.hpp +89 -0
- include/rerun/components/length.hpp +77 -0
- include/rerun/components/line_strip2d.hpp +73 -0
- include/rerun/components/line_strip3d.hpp +73 -0
- include/rerun/components/magnification_filter.hpp +63 -0
- include/rerun/components/marker_shape.hpp +82 -0
- include/rerun/components/marker_size.hpp +74 -0
- include/rerun/components/media_type.hpp +157 -0
- include/rerun/components/name.hpp +83 -0
- include/rerun/components/opacity.hpp +77 -0
- include/rerun/components/pinhole_projection.hpp +94 -0
- include/rerun/components/plane3d.hpp +75 -0
- include/rerun/components/pose_rotation_axis_angle.hpp +73 -0
- include/rerun/components/pose_rotation_quat.hpp +71 -0
- include/rerun/components/pose_scale3d.hpp +102 -0
- include/rerun/components/pose_transform_mat3x3.hpp +87 -0
- include/rerun/components/pose_translation3d.hpp +96 -0
- include/rerun/components/position2d.hpp +86 -0
- include/rerun/components/position3d.hpp +90 -0
- include/rerun/components/radius.hpp +98 -0
- include/rerun/components/range1d.hpp +75 -0
- include/rerun/components/resolution.hpp +88 -0
- include/rerun/components/rotation_axis_angle.hpp +72 -0
- include/rerun/components/rotation_quat.hpp +71 -0
- include/rerun/components/scalar.hpp +76 -0
- include/rerun/components/scale3d.hpp +102 -0
- include/rerun/components/series_visible.hpp +76 -0
- include/rerun/components/show_labels.hpp +79 -0
- include/rerun/components/stroke_width.hpp +74 -0
- include/rerun/components/tensor_data.hpp +94 -0
- include/rerun/components/tensor_dimension_index_selection.hpp +77 -0
- include/rerun/components/tensor_height_dimension.hpp +71 -0
- include/rerun/components/tensor_width_dimension.hpp +71 -0
- include/rerun/components/texcoord2d.hpp +101 -0
- include/rerun/components/text.hpp +83 -0
- include/rerun/components/text_log_level.hpp +110 -0
- include/rerun/components/timestamp.hpp +76 -0
- include/rerun/components/transform_mat3x3.hpp +92 -0
- include/rerun/components/transform_relation.hpp +66 -0
- include/rerun/components/translation3d.hpp +96 -0
- include/rerun/components/triangle_indices.hpp +85 -0
- include/rerun/components/value_range.hpp +78 -0
- include/rerun/components/vector2d.hpp +92 -0
- include/rerun/components/vector3d.hpp +96 -0
- include/rerun/components/video_timestamp.hpp +120 -0
- include/rerun/components/view_coordinates.hpp +346 -0
- include/rerun/components/visible.hpp +74 -0
- include/rerun/components.hpp +77 -0
- include/rerun/config.hpp +52 -0
- include/rerun/datatypes/angle.hpp +76 -0
- include/rerun/datatypes/annotation_info.hpp +76 -0
- include/rerun/datatypes/blob.hpp +67 -0
- include/rerun/datatypes/bool.hpp +57 -0
- include/rerun/datatypes/channel_datatype.hpp +87 -0
- include/rerun/datatypes/class_description.hpp +92 -0
- include/rerun/datatypes/class_description_map_elem.hpp +69 -0
- include/rerun/datatypes/class_id.hpp +62 -0
- include/rerun/datatypes/color_model.hpp +68 -0
- include/rerun/datatypes/dvec2d.hpp +76 -0
- include/rerun/datatypes/entity_path.hpp +60 -0
- include/rerun/datatypes/float32.hpp +62 -0
- include/rerun/datatypes/float64.hpp +62 -0
- include/rerun/datatypes/image_format.hpp +107 -0
- include/rerun/datatypes/keypoint_id.hpp +63 -0
- include/rerun/datatypes/keypoint_pair.hpp +65 -0
- include/rerun/datatypes/mat3x3.hpp +105 -0
- include/rerun/datatypes/mat4x4.hpp +119 -0
- include/rerun/datatypes/pixel_format.hpp +142 -0
- include/rerun/datatypes/plane3d.hpp +60 -0
- include/rerun/datatypes/quaternion.hpp +110 -0
- include/rerun/datatypes/range1d.hpp +59 -0
- include/rerun/datatypes/range2d.hpp +55 -0
- include/rerun/datatypes/rgba32.hpp +94 -0
- include/rerun/datatypes/rotation_axis_angle.hpp +67 -0
- include/rerun/datatypes/tensor_buffer.hpp +529 -0
- include/rerun/datatypes/tensor_data.hpp +100 -0
- include/rerun/datatypes/tensor_dimension_index_selection.hpp +58 -0
- include/rerun/datatypes/tensor_dimension_selection.hpp +56 -0
- include/rerun/datatypes/time_int.hpp +62 -0
- include/rerun/datatypes/time_range.hpp +55 -0
- include/rerun/datatypes/time_range_boundary.hpp +175 -0
- include/rerun/datatypes/uint16.hpp +62 -0
- include/rerun/datatypes/uint32.hpp +62 -0
- include/rerun/datatypes/uint64.hpp +62 -0
- include/rerun/datatypes/utf8.hpp +76 -0
- include/rerun/datatypes/utf8pair.hpp +62 -0
- include/rerun/datatypes/uuid.hpp +60 -0
- include/rerun/datatypes/uvec2d.hpp +76 -0
- include/rerun/datatypes/uvec3d.hpp +80 -0
- include/rerun/datatypes/uvec4d.hpp +59 -0
- include/rerun/datatypes/vec2d.hpp +76 -0
- include/rerun/datatypes/vec3d.hpp +80 -0
- include/rerun/datatypes/vec4d.hpp +84 -0
- include/rerun/datatypes/video_timestamp.hpp +67 -0
- include/rerun/datatypes/view_coordinates.hpp +87 -0
- include/rerun/datatypes/visible_time_range.hpp +57 -0
- include/rerun/datatypes.hpp +51 -0
- include/rerun/demo_utils.hpp +75 -0
- include/rerun/entity_path.hpp +20 -0
- include/rerun/error.hpp +180 -0
- include/rerun/half.hpp +10 -0
- include/rerun/image_utils.hpp +187 -0
- include/rerun/indicator_component.hpp +59 -0
- include/rerun/loggable.hpp +54 -0
- include/rerun/recording_stream.hpp +960 -0
- include/rerun/rerun_sdk_export.hpp +25 -0
- include/rerun/result.hpp +86 -0
- include/rerun/rotation3d.hpp +33 -0
- include/rerun/sdk_info.hpp +20 -0
- include/rerun/spawn.hpp +21 -0
- include/rerun/spawn_options.hpp +57 -0
- include/rerun/string_utils.hpp +16 -0
- include/rerun/third_party/cxxopts.hpp +2198 -0
- include/rerun/time_column.hpp +288 -0
- include/rerun/timeline.hpp +38 -0
- include/rerun/type_traits.hpp +40 -0
- include/rerun.hpp +86 -0
- lib/arrow_bundled_dependencies.lib +0 -0
- lib/arrow_static.lib +0 -0
- lib/axel.lib +0 -0
- lib/cmake/axel/axel-config.cmake +45 -0
- lib/cmake/axel/axelTargets-release.cmake +19 -0
- lib/cmake/axel/axelTargets.cmake +108 -0
- lib/cmake/momentum/Findre2.cmake +52 -0
- lib/cmake/momentum/momentum-config.cmake +67 -0
- lib/cmake/momentum/momentumTargets-release.cmake +259 -0
- lib/cmake/momentum/momentumTargets.cmake +377 -0
- lib/cmake/rerun_sdk/rerun_sdkConfig.cmake +70 -0
- lib/cmake/rerun_sdk/rerun_sdkConfigVersion.cmake +83 -0
- lib/cmake/rerun_sdk/rerun_sdkTargets-release.cmake +19 -0
- lib/cmake/rerun_sdk/rerun_sdkTargets.cmake +108 -0
- lib/momentum_app_utils.lib +0 -0
- lib/momentum_character.lib +0 -0
- lib/momentum_character_sequence_solver.lib +0 -0
- lib/momentum_character_solver.lib +0 -0
- lib/momentum_common.lib +0 -0
- lib/momentum_diff_ik.lib +0 -0
- lib/momentum_io.lib +0 -0
- lib/momentum_io_common.lib +0 -0
- lib/momentum_io_fbx.lib +0 -0
- lib/momentum_io_gltf.lib +0 -0
- lib/momentum_io_legacy_json.lib +0 -0
- lib/momentum_io_marker.lib +0 -0
- lib/momentum_io_motion.lib +0 -0
- lib/momentum_io_shape.lib +0 -0
- lib/momentum_io_skeleton.lib +0 -0
- lib/momentum_io_urdf.lib +0 -0
- lib/momentum_marker_tracker.lib +0 -0
- lib/momentum_math.lib +0 -0
- lib/momentum_online_qr.lib +0 -0
- lib/momentum_process_markers.lib +0 -0
- lib/momentum_rerun.lib +0 -0
- lib/momentum_simd_constraints.lib +0 -0
- lib/momentum_simd_generalized_loss.lib +0 -0
- lib/momentum_skeleton.lib +0 -0
- lib/momentum_solver.lib +0 -0
- lib/rerun_c__win_x64.lib +0 -0
- lib/rerun_sdk.lib +0 -0
- pymomentum/axel.cp312-win_amd64.pyd +0 -0
- pymomentum/backend/__init__.py +16 -0
- pymomentum/backend/skel_state_backend.py +614 -0
- pymomentum/backend/trs_backend.py +871 -0
- pymomentum/backend/utils.py +224 -0
- pymomentum/geometry.cp312-win_amd64.pyd +0 -0
- pymomentum/marker_tracking.cp312-win_amd64.pyd +0 -0
- pymomentum/quaternion.py +740 -0
- pymomentum/skel_state.py +514 -0
- pymomentum/solver.cp312-win_amd64.pyd +0 -0
- pymomentum/solver2.cp312-win_amd64.pyd +0 -0
- pymomentum/torch/character.py +809 -0
- pymomentum/torch/parameter_limits.py +494 -0
- pymomentum/torch/utility.py +20 -0
- pymomentum/trs.py +535 -0
- pymomentum_cpu-0.1.78.post11.dist-info/METADATA +121 -0
- pymomentum_cpu-0.1.78.post11.dist-info/RECORD +512 -0
- pymomentum_cpu-0.1.78.post11.dist-info/WHEEL +5 -0
- pymomentum_cpu-0.1.78.post11.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,809 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
# pyre-strict
|
|
7
|
+
|
|
8
|
+
from typing import Tuple
|
|
9
|
+
|
|
10
|
+
import pymomentum.geometry as pym_geometry
|
|
11
|
+
import pymomentum.quaternion as pym_quaternion
|
|
12
|
+
import pymomentum.skel_state as pym_skel_state
|
|
13
|
+
import pymomentum.trs as pym_trs
|
|
14
|
+
import torch
|
|
15
|
+
|
|
16
|
+
from pymomentum.backend import skel_state_backend, trs_backend, utils as backend_utils
|
|
17
|
+
|
|
18
|
+
from pymomentum.torch.parameter_limits import ParameterLimits
|
|
19
|
+
from pymomentum.torch.utility import _unsqueeze_joint_params
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Skeleton(torch.nn.Module):
|
|
23
|
+
def __init__(
|
|
24
|
+
self,
|
|
25
|
+
character: pym_geometry.Character,
|
|
26
|
+
*,
|
|
27
|
+
dtype: torch.dtype = torch.float32,
|
|
28
|
+
) -> None:
|
|
29
|
+
super().__init__()
|
|
30
|
+
|
|
31
|
+
self.register_buffer(
|
|
32
|
+
"joint_translation_offsets",
|
|
33
|
+
torch.tensor(character.skeleton.offsets, dtype=dtype).clone().detach(),
|
|
34
|
+
)
|
|
35
|
+
self.register_buffer(
|
|
36
|
+
"joint_prerotations",
|
|
37
|
+
torch.tensor(character.skeleton.pre_rotations, dtype=dtype)
|
|
38
|
+
.clone()
|
|
39
|
+
.detach(),
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
prefix_multiplication_indices = (
|
|
43
|
+
backend_utils.calc_fk_prefix_multiplication_indices(
|
|
44
|
+
joint_parents=torch.tensor(
|
|
45
|
+
character.skeleton.joint_parents, dtype=torch.int32
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
self.register_buffer("pmi", torch.concat(prefix_multiplication_indices, dim=1))
|
|
51
|
+
self._pmi_buffer_sizes: list[int] = [
|
|
52
|
+
t.shape[1] for t in prefix_multiplication_indices
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
self.joint_names: list[str] = character.skeleton.joint_names
|
|
56
|
+
self.register_buffer(
|
|
57
|
+
"joint_parents",
|
|
58
|
+
torch.tensor(character.skeleton.joint_parents, dtype=torch.int32),
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
def joint_parameters_to_local_skeleton_state(
|
|
62
|
+
self, joint_parameters: torch.Tensor
|
|
63
|
+
) -> torch.Tensor:
|
|
64
|
+
if not hasattr(self, "joint_prerotations"):
|
|
65
|
+
raise RuntimeError("Character has no skeleton")
|
|
66
|
+
|
|
67
|
+
joint_parameters = _unsqueeze_joint_params(joint_parameters)
|
|
68
|
+
|
|
69
|
+
joint_translation_offsets = self.joint_translation_offsets
|
|
70
|
+
while joint_translation_offsets.ndim < joint_parameters.ndim:
|
|
71
|
+
joint_translation_offsets = joint_translation_offsets.unsqueeze(0)
|
|
72
|
+
|
|
73
|
+
joint_prerotations = self.joint_prerotations
|
|
74
|
+
while joint_prerotations.ndim < joint_parameters.ndim:
|
|
75
|
+
joint_prerotations = joint_prerotations.unsqueeze(0)
|
|
76
|
+
|
|
77
|
+
local_state_t = (
|
|
78
|
+
joint_parameters[..., :3] + self.joint_translation_offsets[None, :]
|
|
79
|
+
)
|
|
80
|
+
local_state_q = pym_quaternion.euler_xyz_to_quaternion(
|
|
81
|
+
joint_parameters[..., 3:6]
|
|
82
|
+
)
|
|
83
|
+
local_state_q = pym_quaternion.multiply_assume_normalized(
|
|
84
|
+
self.joint_prerotations[None],
|
|
85
|
+
local_state_q,
|
|
86
|
+
)
|
|
87
|
+
# exp2 is not supported by all of our export formats, so we have to implement
|
|
88
|
+
# it using exp and natural log instead. The constant here is ln(2.0)
|
|
89
|
+
local_state_s = torch.exp(0.6931471824645996 * joint_parameters[..., 6:])
|
|
90
|
+
return torch.cat([local_state_t, local_state_q, local_state_s], dim=-1)
|
|
91
|
+
|
|
92
|
+
def joint_parameters_to_local_trs(
|
|
93
|
+
self, joint_parameters: torch.Tensor
|
|
94
|
+
) -> pym_trs.TRSTransform:
|
|
95
|
+
"""
|
|
96
|
+
Convert joint parameters to local TRS (Translation-Rotation-Scale) state.
|
|
97
|
+
|
|
98
|
+
This function takes joint parameters and converts them to the TRS representation
|
|
99
|
+
as a tuple, consistent with the pymomentum.trs module interface.
|
|
100
|
+
The TRS format is useful for applications that need explicit access to individual
|
|
101
|
+
transformation components and can be more efficient than the skeleton state format.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
joint_parameters: Joint parameters tensor of shape (batch_size, num_joints * 7)
|
|
105
|
+
or (batch_size, num_joints, 7). Each joint has 7 parameters:
|
|
106
|
+
- [0:3] translation offset
|
|
107
|
+
- [3:6] euler xyz rotation angles
|
|
108
|
+
- [6] log2 scale factor
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
TRS transform tuple (translation, rotation_matrix, scale) where:
|
|
112
|
+
- translation: Local joint translations, shape (batch_size, num_joints, 3)
|
|
113
|
+
- rotation_matrix: Local joint rotations as 3x3 matrices, shape (batch_size, num_joints, 3, 3)
|
|
114
|
+
- scale: Local joint scales, shape (batch_size, num_joints, 1)
|
|
115
|
+
|
|
116
|
+
Raises:
|
|
117
|
+
RuntimeError: If the character has no skeleton
|
|
118
|
+
|
|
119
|
+
Note:
|
|
120
|
+
This function is equivalent to joint_parameters_to_local_skeleton_state() but
|
|
121
|
+
returns the TRS format instead of the 8-parameter skeleton state format.
|
|
122
|
+
It uses the TRS backend for efficient computation.
|
|
123
|
+
"""
|
|
124
|
+
if not hasattr(self, "joint_prerotations"):
|
|
125
|
+
raise RuntimeError("Character has no skeleton")
|
|
126
|
+
|
|
127
|
+
joint_parameters = _unsqueeze_joint_params(joint_parameters)
|
|
128
|
+
|
|
129
|
+
# Convert joint_prerotations from quaternions to rotation matrices
|
|
130
|
+
joint_rotation_matrices = pym_quaternion.to_rotation_matrix(
|
|
131
|
+
self.joint_prerotations
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
# Use the TRS backend for efficient conversion
|
|
135
|
+
return trs_backend.get_local_state_from_joint_params(
|
|
136
|
+
joint_params=joint_parameters,
|
|
137
|
+
joint_offset=self.joint_translation_offsets,
|
|
138
|
+
joint_rotation=joint_rotation_matrices,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
def joint_parameters_to_trs(
|
|
142
|
+
self, joint_parameters: torch.Tensor
|
|
143
|
+
) -> pym_trs.TRSTransform:
|
|
144
|
+
"""
|
|
145
|
+
Convert joint parameters directly to global TRS (Translation-Rotation-Scale) state.
|
|
146
|
+
|
|
147
|
+
This function performs the full forward kinematics pipeline using the TRS backend,
|
|
148
|
+
converting joint parameters to local TRS state and then to global TRS state in
|
|
149
|
+
a single call. This is more efficient than calling the two-step process separately.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
joint_parameters: Joint parameters tensor of shape (batch_size, num_joints * 7)
|
|
153
|
+
or (batch_size, num_joints, 7). Each joint has 7 parameters:
|
|
154
|
+
- [0:3] translation offset
|
|
155
|
+
- [3:6] euler xyz rotation angles
|
|
156
|
+
- [6] log2 scale factor
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
TRS transform tuple (translation, rotation_matrix, scale) where:
|
|
160
|
+
- translation: Global joint translations, shape (batch_size, num_joints, 3)
|
|
161
|
+
- rotation_matrix: Global joint rotations as 3x3 matrices, shape (batch_size, num_joints, 3, 3)
|
|
162
|
+
- scale: Global joint scales, shape (batch_size, num_joints, 1)
|
|
163
|
+
|
|
164
|
+
Raises:
|
|
165
|
+
RuntimeError: If the character has no skeleton
|
|
166
|
+
|
|
167
|
+
Note:
|
|
168
|
+
This is equivalent to calling joint_parameters_to_local_trs() followed by
|
|
169
|
+
local_trs_to_global_trs(), but more efficient as it avoids intermediate steps.
|
|
170
|
+
"""
|
|
171
|
+
# Get local TRS state from joint parameters
|
|
172
|
+
local_trs = self.joint_parameters_to_local_trs(joint_parameters)
|
|
173
|
+
local_state_t, local_state_r, local_state_s = local_trs
|
|
174
|
+
|
|
175
|
+
# Convert local TRS to global TRS using forward kinematics
|
|
176
|
+
return trs_backend.global_trs_state_from_local_trs_state(
|
|
177
|
+
local_state_t=local_state_t,
|
|
178
|
+
local_state_r=local_state_r,
|
|
179
|
+
local_state_s=local_state_s,
|
|
180
|
+
prefix_mul_indices=list(
|
|
181
|
+
self.pmi.split(
|
|
182
|
+
split_size=self._pmi_buffer_sizes,
|
|
183
|
+
dim=1,
|
|
184
|
+
)
|
|
185
|
+
),
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
def local_trs_to_global_trs(
|
|
189
|
+
self,
|
|
190
|
+
local_trs: pym_trs.TRSTransform,
|
|
191
|
+
) -> pym_trs.TRSTransform:
|
|
192
|
+
"""
|
|
193
|
+
Convert local TRS state to global TRS state using forward kinematics.
|
|
194
|
+
|
|
195
|
+
This function performs forward kinematics on the local TRS transformations
|
|
196
|
+
to compute the global joint transformations. This is useful when you have
|
|
197
|
+
local TRS states from other sources and need to convert them to global states.
|
|
198
|
+
|
|
199
|
+
Args:
|
|
200
|
+
local_trs: Local TRS transform tuple (translation, rotation_matrix, scale) where:
|
|
201
|
+
- translation: Local joint translations, shape (batch_size, num_joints, 3)
|
|
202
|
+
- rotation_matrix: Local joint rotations as 3x3 matrices, shape (batch_size, num_joints, 3, 3)
|
|
203
|
+
- scale: Local joint scales, shape (batch_size, num_joints, 1)
|
|
204
|
+
|
|
205
|
+
Returns:
|
|
206
|
+
TRS transform tuple (translation, rotation_matrix, scale) where:
|
|
207
|
+
- translation: Global joint translations, shape (batch_size, num_joints, 3)
|
|
208
|
+
- rotation_matrix: Global joint rotations as 3x3 matrices, shape (batch_size, num_joints, 3, 3)
|
|
209
|
+
- scale: Global joint scales, shape (batch_size, num_joints, 1)
|
|
210
|
+
|
|
211
|
+
Note:
|
|
212
|
+
This function uses the TRS backend for efficient forward kinematics computation.
|
|
213
|
+
"""
|
|
214
|
+
local_state_t, local_state_r, local_state_s = local_trs
|
|
215
|
+
return trs_backend.global_trs_state_from_local_trs_state(
|
|
216
|
+
local_state_t=local_state_t,
|
|
217
|
+
local_state_r=local_state_r,
|
|
218
|
+
local_state_s=local_state_s,
|
|
219
|
+
prefix_mul_indices=list(
|
|
220
|
+
self.pmi.split(
|
|
221
|
+
split_size=self._pmi_buffer_sizes,
|
|
222
|
+
dim=1,
|
|
223
|
+
)
|
|
224
|
+
),
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
def local_skeleton_state_to_skeleton_state(
|
|
228
|
+
self, local_skel_state: torch.Tensor
|
|
229
|
+
) -> torch.Tensor:
|
|
230
|
+
return skel_state_backend.global_skel_state_from_local_skel_state(
|
|
231
|
+
local_skel_state=local_skel_state,
|
|
232
|
+
prefix_mul_indices=list(
|
|
233
|
+
self.pmi.split(
|
|
234
|
+
split_size=self._pmi_buffer_sizes,
|
|
235
|
+
dim=1,
|
|
236
|
+
)
|
|
237
|
+
),
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
def skeleton_state_to_local_skeleton_state(
|
|
241
|
+
self, skel_state: torch.Tensor
|
|
242
|
+
) -> torch.Tensor:
|
|
243
|
+
joint_parents = self.joint_parents
|
|
244
|
+
parent_skel_states = skel_state.index_select(
|
|
245
|
+
-2, torch.clamp(joint_parents, min=0)
|
|
246
|
+
)
|
|
247
|
+
# global = parent * local
|
|
248
|
+
local_skel_states = pym_skel_state.multiply(
|
|
249
|
+
pym_skel_state.inverse(parent_skel_states), skel_state
|
|
250
|
+
)
|
|
251
|
+
while joint_parents.ndim + 1 < local_skel_states.ndim:
|
|
252
|
+
joint_parents = joint_parents[None, ...]
|
|
253
|
+
|
|
254
|
+
local_skel_states = torch.where(
|
|
255
|
+
(joint_parents >= 0)[..., None], local_skel_states, skel_state
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
return local_skel_states
|
|
259
|
+
|
|
260
|
+
def local_skeleton_state_to_joint_parameters(
|
|
261
|
+
self,
|
|
262
|
+
local_skel_state: torch.Tensor,
|
|
263
|
+
) -> torch.Tensor:
|
|
264
|
+
joint_translation_offsets = self.joint_translation_offsets
|
|
265
|
+
joint_prerotations = self.joint_prerotations
|
|
266
|
+
|
|
267
|
+
# Compute translation joint parameters
|
|
268
|
+
translation_params = local_skel_state[..., :3] - joint_translation_offsets[None]
|
|
269
|
+
|
|
270
|
+
# Invert out the pre-rotations:
|
|
271
|
+
local_rotations = local_skel_state[..., 3:7]
|
|
272
|
+
adjusted_rotations = pym_quaternion.multiply(
|
|
273
|
+
pym_quaternion.inverse(joint_prerotations[None]),
|
|
274
|
+
local_rotations,
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
# Use the pymomentum.quaternion implementation instead of real_lbs_quaternion's implementation
|
|
278
|
+
# because it's more numerically stable. This is important for backpropagating through this
|
|
279
|
+
# function.
|
|
280
|
+
rotation_joint_params = pym_quaternion.quaternion_to_xyz_euler(
|
|
281
|
+
adjusted_rotations, eps=1e-6
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
# Compute scale joint parameters
|
|
285
|
+
scale_joint_params = torch.log2(local_skel_state[..., 7:8])
|
|
286
|
+
|
|
287
|
+
return torch.cat(
|
|
288
|
+
[translation_params, rotation_joint_params, scale_joint_params], dim=-1
|
|
289
|
+
).flatten(-2, -1)
|
|
290
|
+
|
|
291
|
+
def skeleton_state_to_joint_parameters(
|
|
292
|
+
self, skel_state: torch.Tensor
|
|
293
|
+
) -> torch.Tensor:
|
|
294
|
+
return self.local_skeleton_state_to_joint_parameters(
|
|
295
|
+
self.skeleton_state_to_local_skeleton_state(skel_state)
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
def forward(self, joint_parameters: torch.Tensor) -> torch.Tensor:
|
|
299
|
+
if joint_parameters.ndim == 1:
|
|
300
|
+
joint_parameters = joint_parameters[None, :]
|
|
301
|
+
return self.local_skeleton_state_to_skeleton_state(
|
|
302
|
+
self.joint_parameters_to_local_skeleton_state(joint_parameters)
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
class LinearBlendSkinning(torch.nn.Module):
|
|
307
|
+
def __init__(
|
|
308
|
+
self,
|
|
309
|
+
character: pym_geometry.Character,
|
|
310
|
+
*,
|
|
311
|
+
dtype: torch.dtype = torch.float32,
|
|
312
|
+
) -> None:
|
|
313
|
+
super().__init__()
|
|
314
|
+
|
|
315
|
+
self.register_buffer(
|
|
316
|
+
"inverse_bind_pose",
|
|
317
|
+
pym_skel_state.from_matrix(
|
|
318
|
+
torch.tensor(character.inverse_bind_pose, dtype=dtype)
|
|
319
|
+
)
|
|
320
|
+
.detach()
|
|
321
|
+
.clone(),
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
self.num_vertices: int = character.skin_weights.index.shape[0]
|
|
325
|
+
|
|
326
|
+
(
|
|
327
|
+
skin_indices_flattened,
|
|
328
|
+
skin_weights_flattened,
|
|
329
|
+
vert_indices_flattened,
|
|
330
|
+
) = backend_utils.flatten_skinning_weights_and_indices(
|
|
331
|
+
skin_weights=torch.tensor(character.skin_weights.weight, dtype=dtype),
|
|
332
|
+
skin_indices=torch.tensor(character.skin_weights.index, dtype=torch.int32),
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
self.register_buffer(
|
|
336
|
+
"skin_indices_flattened", skin_indices_flattened.detach().clone()
|
|
337
|
+
)
|
|
338
|
+
self.register_buffer(
|
|
339
|
+
"skin_weights_flattened", skin_weights_flattened.detach().clone()
|
|
340
|
+
)
|
|
341
|
+
self.register_buffer(
|
|
342
|
+
"vert_indices_flattened", vert_indices_flattened.detach().clone()
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
def forward(
|
|
346
|
+
self,
|
|
347
|
+
skel_state: torch.Tensor,
|
|
348
|
+
rest_vertex_positions: torch.Tensor,
|
|
349
|
+
) -> torch.Tensor:
|
|
350
|
+
assert rest_vertex_positions.shape[-1] == 3
|
|
351
|
+
assert rest_vertex_positions.shape[-2] == self.num_vertices
|
|
352
|
+
|
|
353
|
+
inverse_bind_pose = self.inverse_bind_pose
|
|
354
|
+
while inverse_bind_pose.ndim < skel_state.ndim:
|
|
355
|
+
inverse_bind_pose = inverse_bind_pose.unsqueeze(0)
|
|
356
|
+
|
|
357
|
+
return skel_state_backend.skin_points_from_skel_state(
|
|
358
|
+
template=rest_vertex_positions,
|
|
359
|
+
global_skel_state=skel_state,
|
|
360
|
+
binded_skel_state_inv=inverse_bind_pose,
|
|
361
|
+
skin_indices_flattened=self.skin_indices_flattened,
|
|
362
|
+
skin_weights_flattened=self.skin_weights_flattened,
|
|
363
|
+
vert_indices_flattened=self.vert_indices_flattened,
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
def skin_with_trs(
|
|
367
|
+
self,
|
|
368
|
+
global_trs: pym_trs.TRSTransform,
|
|
369
|
+
rest_vertex_positions: torch.Tensor,
|
|
370
|
+
) -> torch.Tensor:
|
|
371
|
+
"""
|
|
372
|
+
Apply skinning using global TRS state (Translation-Rotation-Scale).
|
|
373
|
+
|
|
374
|
+
This method takes global TRS state as a tuple and applies linear blend skinning
|
|
375
|
+
using the TRS backend. This is useful when working directly with TRS representations
|
|
376
|
+
or when you want to avoid conversions to skeleton state format.
|
|
377
|
+
|
|
378
|
+
Args:
|
|
379
|
+
global_trs: Global TRS transform tuple (translation, rotation_matrix, scale) where:
|
|
380
|
+
- translation: Global joint translations, shape (batch_size, num_joints, 3)
|
|
381
|
+
- rotation_matrix: Global joint rotations as 3x3 matrices, shape (batch_size, num_joints, 3, 3)
|
|
382
|
+
- scale: Global joint scales, shape (batch_size, num_joints, 1)
|
|
383
|
+
rest_vertex_positions: Rest vertex positions, shape (batch_size, num_vertices, 3)
|
|
384
|
+
or (num_vertices, 3) which will be expanded to batch size
|
|
385
|
+
|
|
386
|
+
Returns:
|
|
387
|
+
skinned_vertices: Skinned vertex positions, shape (batch_size, num_vertices, 3)
|
|
388
|
+
|
|
389
|
+
Note:
|
|
390
|
+
This method uses the TRS backend skinning function for efficient computation.
|
|
391
|
+
"""
|
|
392
|
+
global_state_t, global_state_r, global_state_s = global_trs
|
|
393
|
+
|
|
394
|
+
inv_bind_pose_rot: torch.Tensor = pym_quaternion.to_rotation_matrix(
|
|
395
|
+
self.inverse_bind_pose[..., 3:7]
|
|
396
|
+
)
|
|
397
|
+
inv_bind_pose_trans: torch.Tensor = self.inverse_bind_pose[..., 0:3]
|
|
398
|
+
|
|
399
|
+
return trs_backend.skinning(
|
|
400
|
+
template=rest_vertex_positions,
|
|
401
|
+
t=global_state_t,
|
|
402
|
+
r=global_state_r,
|
|
403
|
+
s=global_state_s,
|
|
404
|
+
t0=inv_bind_pose_trans,
|
|
405
|
+
r0=inv_bind_pose_rot,
|
|
406
|
+
skin_indices_flattened=self.skin_indices_flattened,
|
|
407
|
+
skin_weights_flattened=self.skin_weights_flattened,
|
|
408
|
+
vert_indices_flattened=self.vert_indices_flattened,
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
def skin_with_transforms(
|
|
412
|
+
self,
|
|
413
|
+
global_state_t: torch.Tensor,
|
|
414
|
+
global_state_r: torch.Tensor,
|
|
415
|
+
global_state_s: torch.Tensor,
|
|
416
|
+
rest_vertex_positions: torch.Tensor,
|
|
417
|
+
) -> torch.Tensor:
|
|
418
|
+
"""
|
|
419
|
+
Apply skinning using individual global TRS tensors (legacy interface).
|
|
420
|
+
|
|
421
|
+
This method provides backward compatibility for code that passes individual
|
|
422
|
+
tensors instead of the TRS tuple format. Internally, it creates a tuple
|
|
423
|
+
and delegates to skin_with_trs().
|
|
424
|
+
|
|
425
|
+
Args:
|
|
426
|
+
global_state_t: Global joint translations, shape (batch_size, num_joints, 3)
|
|
427
|
+
global_state_r: Global joint rotations as 3x3 matrices, shape (batch_size, num_joints, 3, 3)
|
|
428
|
+
global_state_s: Global joint scales, shape (batch_size, num_joints, 1)
|
|
429
|
+
rest_vertex_positions: Rest vertex positions, shape (batch_size, num_vertices, 3)
|
|
430
|
+
or (num_vertices, 3) which will be expanded to batch size
|
|
431
|
+
|
|
432
|
+
Returns:
|
|
433
|
+
skinned_vertices: Skinned vertex positions, shape (batch_size, num_vertices, 3)
|
|
434
|
+
|
|
435
|
+
Note:
|
|
436
|
+
This method is provided for backward compatibility. New code should use
|
|
437
|
+
skin_with_trs() with the TRS tuple interface.
|
|
438
|
+
"""
|
|
439
|
+
global_trs = (global_state_t, global_state_r, global_state_s)
|
|
440
|
+
return self.skin_with_trs(global_trs, rest_vertex_positions)
|
|
441
|
+
|
|
442
|
+
def unpose(
|
|
443
|
+
self, global_joint_state: torch.Tensor, verts: torch.Tensor
|
|
444
|
+
) -> torch.Tensor:
|
|
445
|
+
return skel_state_backend.unpose_from_momentum_global_joint_state(
|
|
446
|
+
verts,
|
|
447
|
+
global_joint_state,
|
|
448
|
+
self.inverse_bind_pose,
|
|
449
|
+
self.skin_indices_flattened,
|
|
450
|
+
self.skin_weights_flattened,
|
|
451
|
+
self.vert_indices_flattened,
|
|
452
|
+
with_high_precision=True,
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
class Mesh(torch.nn.Module):
|
|
457
|
+
def __init__(
|
|
458
|
+
self,
|
|
459
|
+
character: pym_geometry.Character,
|
|
460
|
+
*,
|
|
461
|
+
dtype: torch.dtype = torch.float32,
|
|
462
|
+
) -> None:
|
|
463
|
+
super().__init__()
|
|
464
|
+
|
|
465
|
+
self.register_buffer(
|
|
466
|
+
"rest_vertices",
|
|
467
|
+
torch.tensor(character.mesh.vertices, dtype=dtype).clone().detach(),
|
|
468
|
+
)
|
|
469
|
+
|
|
470
|
+
self.register_buffer(
|
|
471
|
+
"faces",
|
|
472
|
+
torch.tensor(character.mesh.faces, dtype=torch.int32).clone().detach(),
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
self.register_buffer(
|
|
476
|
+
"texcoords",
|
|
477
|
+
torch.tensor(character.mesh.texcoords, dtype=dtype).clone().detach(),
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
self.register_buffer(
|
|
481
|
+
"texcoord_faces",
|
|
482
|
+
torch.tensor(character.mesh.texcoord_faces, dtype=torch.int32)
|
|
483
|
+
.clone()
|
|
484
|
+
.detach(),
|
|
485
|
+
)
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
class ParameterTransform(torch.nn.Module):
|
|
489
|
+
def __init__(
|
|
490
|
+
self,
|
|
491
|
+
character: pym_geometry.Character,
|
|
492
|
+
*,
|
|
493
|
+
dtype: torch.dtype = torch.float32,
|
|
494
|
+
) -> None:
|
|
495
|
+
super().__init__()
|
|
496
|
+
|
|
497
|
+
self.register_buffer(
|
|
498
|
+
"parameter_transform",
|
|
499
|
+
character.parameter_transform.transform.to(dtype=dtype)
|
|
500
|
+
.clone()
|
|
501
|
+
.detach()
|
|
502
|
+
.requires_grad_(False),
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
self.register_buffer(
|
|
506
|
+
"pose_parameters",
|
|
507
|
+
character.parameter_transform.pose_parameters.clone()
|
|
508
|
+
.detach()
|
|
509
|
+
.requires_grad_(False),
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
self.register_buffer(
|
|
513
|
+
"rigid_parameters",
|
|
514
|
+
character.parameter_transform.rigid_parameters.clone()
|
|
515
|
+
.detach()
|
|
516
|
+
.requires_grad_(False),
|
|
517
|
+
)
|
|
518
|
+
|
|
519
|
+
self.register_buffer(
|
|
520
|
+
"scaling_parameters",
|
|
521
|
+
character.parameter_transform.scaling_parameters.clone()
|
|
522
|
+
.detach()
|
|
523
|
+
.requires_grad_(False),
|
|
524
|
+
)
|
|
525
|
+
|
|
526
|
+
self.parameter_names: list[str] = character.parameter_transform.names
|
|
527
|
+
|
|
528
|
+
def forward(self, model_parameters: torch.Tensor) -> torch.Tensor:
|
|
529
|
+
if not hasattr(self, "parameter_transform"):
|
|
530
|
+
raise RuntimeError("Character has no parameter transform")
|
|
531
|
+
return torch.einsum(
|
|
532
|
+
"dn,...n->...d",
|
|
533
|
+
self.parameter_transform,
|
|
534
|
+
model_parameters,
|
|
535
|
+
)
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
class InverseParameterTransform(torch.nn.Module):
|
|
539
|
+
def __init__(
|
|
540
|
+
self, parameter_transform: ParameterTransform, rcond: float = 1e-5
|
|
541
|
+
) -> None:
|
|
542
|
+
super().__init__()
|
|
543
|
+
self.rcond: float = rcond
|
|
544
|
+
|
|
545
|
+
# We tried using torch.linalg.lstsq, but the fully-pivoting and SVD-based
|
|
546
|
+
# versions don't run on the GPU while the non-pivoting version gives bad
|
|
547
|
+
# results for non-unique parameter transforms. Therefore let's precompute
|
|
548
|
+
# the full SVD, this is maybe overkill but we only have to do it once.
|
|
549
|
+
|
|
550
|
+
# Full SVD for general case
|
|
551
|
+
U, S_inv, V = self._compute_svd(parameter_transform.parameter_transform)
|
|
552
|
+
self.register_buffer("svd_U", U)
|
|
553
|
+
self.register_buffer("svd_S_inv", S_inv)
|
|
554
|
+
self.register_buffer("svd_V", V)
|
|
555
|
+
|
|
556
|
+
def _compute_svd(
|
|
557
|
+
self,
|
|
558
|
+
matrix: torch.Tensor,
|
|
559
|
+
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
|
560
|
+
"""
|
|
561
|
+
Compute the Singular Value Decomposition (SVD) of a matrix and return the components needed for pseudoinverse.
|
|
562
|
+
|
|
563
|
+
This function performs SVD on the input matrix and returns the components U, S_inv, and V,
|
|
564
|
+
where S_inv contains the reciprocals of singular values above the threshold defined by self.rcond,
|
|
565
|
+
and zeros for singular values below the threshold to avoid numerical instability.
|
|
566
|
+
|
|
567
|
+
Parameters
|
|
568
|
+
----------
|
|
569
|
+
matrix : torch.Tensor
|
|
570
|
+
The input matrix to decompose using SVD.
|
|
571
|
+
|
|
572
|
+
Returns
|
|
573
|
+
-------
|
|
574
|
+
Tuple[torch.Tensor, torch.Tensor, torch.Tensor]
|
|
575
|
+
A tuple containing:
|
|
576
|
+
- U: Left singular vectors (detached from computation graph)
|
|
577
|
+
- S_inv: Reciprocal of singular values with thresholding (detached from computation graph)
|
|
578
|
+
- V: Right singular vectors (detached from computation graph)
|
|
579
|
+
"""
|
|
580
|
+
U, S, V = torch.linalg.svd(matrix, full_matrices=False)
|
|
581
|
+
# Avoid divide-by-zero
|
|
582
|
+
S_inv = torch.where(S < self.rcond, 0.0, torch.reciprocal(S))
|
|
583
|
+
return U.detach(), S_inv.detach(), V.detach()
|
|
584
|
+
|
|
585
|
+
def _solve_via_svd(
|
|
586
|
+
self, U: torch.Tensor, S_inv: torch.Tensor, V: torch.Tensor, y: torch.Tensor
|
|
587
|
+
) -> torch.Tensor:
|
|
588
|
+
# U * S * V^T * model_params = y
|
|
589
|
+
# model_params = V * S^-1 * U^T * y
|
|
590
|
+
|
|
591
|
+
# First multiply by U^T:
|
|
592
|
+
Ut_y = torch.einsum("jm,...j->...m", U, y)
|
|
593
|
+
while S_inv.ndim < Ut_y.ndim:
|
|
594
|
+
S_inv = S_inv.unsqueeze(0)
|
|
595
|
+
# Next divide by S (a diagonal matrix):
|
|
596
|
+
tmp = Ut_y * S_inv
|
|
597
|
+
# Finally multiply by V^T:
|
|
598
|
+
return torch.einsum("ij,...i->...j", V, tmp)
|
|
599
|
+
|
|
600
|
+
def joint_parameters_to_model_parameters(
|
|
601
|
+
self, joint_parameters: torch.Tensor
|
|
602
|
+
) -> torch.Tensor:
|
|
603
|
+
return self._solve_via_svd(
|
|
604
|
+
self.svd_U, self.svd_S_inv, self.svd_V, joint_parameters
|
|
605
|
+
)
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
class AdvancedInverseParameterTransform(InverseParameterTransform):
|
|
609
|
+
"""
|
|
610
|
+
This is a more advanced version of InverseParameterTransform that can handle
|
|
611
|
+
the case where pose and scale are mutually exclusive (i.e. no joint parameter
|
|
612
|
+
is affected by both pose and scale). In this case, we can compute a pose-only
|
|
613
|
+
SVD and use that to compute the inverse parameter transform.
|
|
614
|
+
"""
|
|
615
|
+
|
|
616
|
+
def __init__(
|
|
617
|
+
self, parameter_transform: ParameterTransform, rcond: float = 1e-5
|
|
618
|
+
) -> None:
|
|
619
|
+
super().__init__(parameter_transform, rcond)
|
|
620
|
+
self.parameter_transform: ParameterTransform = parameter_transform
|
|
621
|
+
|
|
622
|
+
# Pose-only SVD (for partial inverse when scales are known)
|
|
623
|
+
pose_scale_are_mutually_exclusive, affected_by_pose_mask = (
|
|
624
|
+
self.check_if_pose_scale_are_mutually_exclusive()
|
|
625
|
+
)
|
|
626
|
+
self.pose_scale_are_mutually_exclusive: bool = pose_scale_are_mutually_exclusive
|
|
627
|
+
self.register_buffer("affected_by_pose_mask", affected_by_pose_mask)
|
|
628
|
+
if pose_scale_are_mutually_exclusive:
|
|
629
|
+
# If pose and scale are mutually exclusive, we can compute a pose-only SVD
|
|
630
|
+
pose_matrix = parameter_transform.parameter_transform[
|
|
631
|
+
affected_by_pose_mask
|
|
632
|
+
][:, parameter_transform.pose_parameters]
|
|
633
|
+
U_p, S_inv_p, V_p = self._compute_svd(pose_matrix)
|
|
634
|
+
|
|
635
|
+
self.register_buffer("svd_U_poses", U_p)
|
|
636
|
+
self.register_buffer("svd_S_poses_inv", S_inv_p)
|
|
637
|
+
self.register_buffer("svd_V_poses", V_p)
|
|
638
|
+
self.register_buffer("scale_only_parameter_transform", torch.tensor([]))
|
|
639
|
+
|
|
640
|
+
else:
|
|
641
|
+
pose_matrix = parameter_transform.parameter_transform[
|
|
642
|
+
..., parameter_transform.pose_parameters
|
|
643
|
+
]
|
|
644
|
+
scale_matrix = parameter_transform.parameter_transform[
|
|
645
|
+
..., parameter_transform.scaling_parameters
|
|
646
|
+
]
|
|
647
|
+
U_p, S_inv_p, V_p = self._compute_svd(pose_matrix)
|
|
648
|
+
|
|
649
|
+
self.register_buffer(
|
|
650
|
+
"scale_only_parameter_transform", scale_matrix.detach()
|
|
651
|
+
)
|
|
652
|
+
self.register_buffer("svd_U_poses", U_p)
|
|
653
|
+
self.register_buffer("svd_S_poses_inv", S_inv_p)
|
|
654
|
+
self.register_buffer("svd_V_poses", V_p)
|
|
655
|
+
|
|
656
|
+
def check_if_pose_scale_are_mutually_exclusive(self) -> Tuple[bool, torch.Tensor]:
|
|
657
|
+
# Check if pose and scale are mutually exclusive (i.e. no joint parameter is affected
|
|
658
|
+
# by both pose and scale)
|
|
659
|
+
pt = self.parameter_transform
|
|
660
|
+
transform = pt.parameter_transform
|
|
661
|
+
scale_mask = pt.scaling_parameters
|
|
662
|
+
pose_mask = pt.pose_parameters
|
|
663
|
+
|
|
664
|
+
# Compute which joint params are affected by scale vs pose
|
|
665
|
+
affected_by_scale_mask = (transform[:, scale_mask] != 0).any(dim=1)
|
|
666
|
+
affected_by_pose_mask = (transform[:, pose_mask] != 0).any(dim=1)
|
|
667
|
+
|
|
668
|
+
# Mutually exclusive if no joint is affected by both
|
|
669
|
+
return (
|
|
670
|
+
not torch.any(affected_by_scale_mask & affected_by_pose_mask)
|
|
671
|
+
), affected_by_pose_mask
|
|
672
|
+
|
|
673
|
+
def joint_parameters_to_model_parameters_with_known_scales(
|
|
674
|
+
self, joint_parameters: torch.Tensor, scale_parameters: torch.Tensor
|
|
675
|
+
) -> torch.Tensor:
|
|
676
|
+
if self.pose_scale_are_mutually_exclusive:
|
|
677
|
+
adjusted_joint_parameters = joint_parameters[
|
|
678
|
+
..., self.affected_by_pose_mask
|
|
679
|
+
]
|
|
680
|
+
else:
|
|
681
|
+
# y_adjusted = y - M_fixed @ x_fixed
|
|
682
|
+
adjusted_joint_parameters = joint_parameters - torch.einsum(
|
|
683
|
+
"dn,...n->...d", self.scale_only_parameter_transform, scale_parameters
|
|
684
|
+
)
|
|
685
|
+
poses = self._solve_via_svd(
|
|
686
|
+
self.svd_U_poses,
|
|
687
|
+
self.svd_S_poses_inv,
|
|
688
|
+
self.svd_V_poses,
|
|
689
|
+
adjusted_joint_parameters,
|
|
690
|
+
)
|
|
691
|
+
|
|
692
|
+
result = torch.zeros(
|
|
693
|
+
*poses.shape[:-1],
|
|
694
|
+
self.parameter_transform.parameter_transform.shape[-1],
|
|
695
|
+
device=poses.device,
|
|
696
|
+
dtype=poses.dtype,
|
|
697
|
+
)
|
|
698
|
+
result[..., self.parameter_transform.pose_parameters] = poses
|
|
699
|
+
result[..., self.parameter_transform.scaling_parameters] = scale_parameters
|
|
700
|
+
return result
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
class Character(torch.nn.Module):
|
|
704
|
+
def __init__(
|
|
705
|
+
self,
|
|
706
|
+
character: pym_geometry.Character,
|
|
707
|
+
*,
|
|
708
|
+
has_parameter_transform: bool = True,
|
|
709
|
+
has_skeleton: bool = True,
|
|
710
|
+
has_rest_mesh: bool = True,
|
|
711
|
+
has_skinning: bool = True,
|
|
712
|
+
has_limits: bool = True,
|
|
713
|
+
dtype: torch.dtype = torch.float32,
|
|
714
|
+
) -> None:
|
|
715
|
+
super().__init__()
|
|
716
|
+
|
|
717
|
+
if has_skeleton:
|
|
718
|
+
self.skeleton: Skeleton = Skeleton(character, dtype=dtype)
|
|
719
|
+
|
|
720
|
+
if has_rest_mesh:
|
|
721
|
+
self.mesh: Mesh = Mesh(character, dtype=dtype)
|
|
722
|
+
|
|
723
|
+
if has_parameter_transform:
|
|
724
|
+
self.parameter_transform: ParameterTransform = ParameterTransform(
|
|
725
|
+
character, dtype=dtype
|
|
726
|
+
)
|
|
727
|
+
|
|
728
|
+
if has_skinning:
|
|
729
|
+
self.linear_blend_skinning: LinearBlendSkinning = LinearBlendSkinning(
|
|
730
|
+
character, dtype=dtype
|
|
731
|
+
)
|
|
732
|
+
|
|
733
|
+
if has_limits:
|
|
734
|
+
self.parameter_limits: ParameterLimits = ParameterLimits(
|
|
735
|
+
character.parameter_limits, dtype=dtype
|
|
736
|
+
)
|
|
737
|
+
|
|
738
|
+
def joint_parameters_to_local_skeleton_state(
|
|
739
|
+
self, joint_parameters: torch.Tensor
|
|
740
|
+
) -> torch.Tensor:
|
|
741
|
+
if not hasattr(self, "skeleton"):
|
|
742
|
+
raise RuntimeError("Character has no skeleton, please provide one")
|
|
743
|
+
return self.skeleton.joint_parameters_to_local_skeleton_state(joint_parameters)
|
|
744
|
+
|
|
745
|
+
def model_parameters_to_local_skeleton_state(
|
|
746
|
+
self, model_parameters: torch.Tensor
|
|
747
|
+
) -> torch.Tensor:
|
|
748
|
+
if not hasattr(self, "skeleton"):
|
|
749
|
+
raise RuntimeError("Character has no skeleton, please provide one")
|
|
750
|
+
return self.joint_parameters_to_local_skeleton_state(
|
|
751
|
+
self.model_parameters_to_joint_parameters(model_parameters)
|
|
752
|
+
)
|
|
753
|
+
|
|
754
|
+
def local_skeleton_state_to_skeleton_state(
|
|
755
|
+
self, local_skel_state: torch.Tensor
|
|
756
|
+
) -> torch.Tensor:
|
|
757
|
+
if not hasattr(self, "skeleton"):
|
|
758
|
+
raise RuntimeError("Character has no skeleton, please provide one")
|
|
759
|
+
return self.skeleton.local_skeleton_state_to_skeleton_state(local_skel_state)
|
|
760
|
+
|
|
761
|
+
def model_parameters_to_joint_parameters(
|
|
762
|
+
self, model_parameters: torch.Tensor
|
|
763
|
+
) -> torch.Tensor:
|
|
764
|
+
if not hasattr(self, "parameter_transform"):
|
|
765
|
+
raise RuntimeError(
|
|
766
|
+
"Character has no parameter transform, please provide one"
|
|
767
|
+
)
|
|
768
|
+
return self.parameter_transform.forward(model_parameters)
|
|
769
|
+
|
|
770
|
+
def joint_parameters_to_skeleton_state(
|
|
771
|
+
self, joint_parameters: torch.Tensor
|
|
772
|
+
) -> torch.Tensor:
|
|
773
|
+
local_skel_state = self.joint_parameters_to_local_skeleton_state(
|
|
774
|
+
joint_parameters
|
|
775
|
+
)
|
|
776
|
+
return self.local_skeleton_state_to_skeleton_state(local_skel_state)
|
|
777
|
+
|
|
778
|
+
def model_parameters_to_skeleton_state(
|
|
779
|
+
self, model_parameters: torch.Tensor
|
|
780
|
+
) -> torch.Tensor:
|
|
781
|
+
return self.joint_parameters_to_skeleton_state(
|
|
782
|
+
self.model_parameters_to_joint_parameters(model_parameters)
|
|
783
|
+
)
|
|
784
|
+
|
|
785
|
+
def skin_points(
|
|
786
|
+
self,
|
|
787
|
+
skel_state: torch.Tensor,
|
|
788
|
+
rest_vertex_positions: torch.Tensor | None = None,
|
|
789
|
+
) -> torch.Tensor:
|
|
790
|
+
if rest_vertex_positions is None:
|
|
791
|
+
if not hasattr(self, "mesh"):
|
|
792
|
+
raise RuntimeError("Character has no rest mesh, please provide one")
|
|
793
|
+
rest_vertex_positions = self.mesh.rest_vertices
|
|
794
|
+
|
|
795
|
+
if not hasattr(self, "linear_blend_skinning"):
|
|
796
|
+
raise RuntimeError("Character has no skinning information")
|
|
797
|
+
|
|
798
|
+
return self.linear_blend_skinning.forward(
|
|
799
|
+
skel_state,
|
|
800
|
+
rest_vertex_positions,
|
|
801
|
+
)
|
|
802
|
+
|
|
803
|
+
def unpose(
|
|
804
|
+
self, skel_state: torch.Tensor, vertex_positions: torch.Tensor
|
|
805
|
+
) -> torch.Tensor:
|
|
806
|
+
if not hasattr(self, "linear_blend_skinning"):
|
|
807
|
+
raise RuntimeError("Character has no skinning information")
|
|
808
|
+
|
|
809
|
+
return self.linear_blend_skinning.unpose(skel_state, vertex_positions)
|