| 100 | } |
| 101 | |
| 102 | void transform_position_tensor(core::Tensor& positions, const glm::mat4& transform) { |
| 103 | if (!is_float_nx3(positions)) |
| 104 | return; |
| 105 | |
| 106 | const auto point_count = static_cast<size_t>(positions.size(0)); |
| 107 | const auto device = positions.device(); |
| 108 | const auto transform_tensor = |
| 109 | core::Tensor::from_vector(matrix4_tensor_data(transform), core::TensorShape({4, 4}), device); |
| 110 | const auto ones = core::Tensor::ones({point_count, 1}, device); |
| 111 | const auto transformed = transform_tensor.mm(positions.cat(ones, 1).t()).t(); |
| 112 | positions = transformed.slice(1, 0, 3).contiguous(); |
| 113 | } |
| 114 | |
| 115 | void transform_direction_tensor(core::Tensor& directions, const glm::mat3& transform) { |
| 116 | if (!is_float_nx3(directions)) |
no test coverage detected