struct GridGeneric_std430_0
{
@align(4) num_active_blocks_0 : u32,
@align(4) cell_width_0 : f32,
@align(4) hmap_capacity_0 : u32,
@align(4) capacity_0 : u32,
};
@binding(0) @group(0) var<storage, read> entryPointParams_grid_0 : array<GridGeneric_std430_0>;
struct BlockVirtualId_std430_0
{
@align(16) id_0 : vec3<i32>,
};
struct ActiveBlockHeaderGeneric_std430_0
{
@align(16) virtual_id_0 : BlockVirtualId_std430_0,
@align(16) first_particle_0 : u32,
@align(4) num_particles_0 : u32,
};
@binding(1) @group(0) var<storage, read> entryPointParams_active_blocks_0 : array<ActiveBlockHeaderGeneric_std430_0>;
struct Shape_std430_0
{
@align(16) a_0 : vec4<f32>,
@align(16) b_0 : vec4<f32>,
};
@binding(2) @group(0) var<storage, read> entryPointParams_collision_shapes_0 : array<Shape_std430_0>;
struct Quat_std430_0
{
@align(16) coords_0 : vec4<f32>,
};
struct Sim3_std430_0
{
@align(16) rotation_0 : Quat_std430_0,
@align(16) translation_scale_0 : vec4<f32>,
};
@binding(3) @group(0) var<storage, read> entryPointParams_collision_shape_poses_0 : array<Sim3_std430_0>;
struct NodeCdf_std430_0
{
@align(4) distance_0 : f32,
@align(4) affinities_0 : u32,
@align(4) closest_id_0 : u32,
};
struct Node_std430_0
{
@align(16) momentum_velocity_mass_0 : vec4<f32>,
@align(16) cdf_0 : NodeCdf_std430_0,
};
@binding(4) @group(0) var<storage, read_write> entryPointParams_nodes_0 : array<Node_std430_0>;
struct BlockHeaderId_0
{
id_1 : u32,
};
fn BlockHeaderId_x24init_0( i_0 : u32) -> BlockHeaderId_0
{
var _S1 : BlockHeaderId_0;
_S1.id_1 = i_0;
return _S1;
}
struct BlockPhysicalId_0
{
id_2 : u32,
};
fn BlockPhysicalId_x24init_0( i_1 : u32) -> BlockPhysicalId_0
{
var _S2 : BlockPhysicalId_0;
_S2.id_2 = i_1;
return _S2;
}
fn block_header_id_to_physical_id_0( hid_0 : BlockHeaderId_0) -> BlockPhysicalId_0
{
return BlockPhysicalId_x24init_0(hid_0.id_1 * u32(64));
}
struct NodePhysicalId_0
{
id_3 : u32,
};
fn NodePhysicalId_x24init_0( i_2 : u32) -> NodePhysicalId_0
{
var _S3 : NodePhysicalId_0;
_S3.id_3 = i_2;
return _S3;
}
fn node_id_0( pid_0 : BlockPhysicalId_0, shift_in_block_0 : vec3<u32>) -> NodePhysicalId_0
{
return NodePhysicalId_x24init_0(pid_0.id_2 + shift_in_block_0.x + shift_in_block_0.y * u32(4) + shift_in_block_0.z * u32(4) * u32(4));
}
struct NodeCdf_0
{
@align(4) distance_0 : f32,
@align(4) affinities_0 : u32,
@align(4) closest_id_0 : u32,
};
fn NodeCdf_x24init_0( distance_1 : f32, affinities_1 : u32, closest_id_1 : u32) -> NodeCdf_0
{
var _S4 : NodeCdf_0;
_S4.distance_0 = distance_1;
_S4.affinities_0 = affinities_1;
_S4.closest_id_0 = closest_id_1;
return _S4;
}
struct Shape_0
{
@align(16) a_0 : vec4<f32>,
@align(16) b_0 : vec4<f32>,
};
fn Shape_shape_type_0( this_0 : Shape_0) -> u32
{
return bitcast<u32>(this_0.a_0.w);
}
struct Ball_0
{
radius_0 : f32,
};
fn Ball_x24init_0( radius_1 : f32) -> Ball_0
{
var _S5 : Ball_0;
_S5.radius_0 = radius_1;
return _S5;
}
fn Shape_to_ball_0( this_1 : Shape_0) -> Ball_0
{
return Ball_x24init_0(this_1.a_0.x);
}
struct Quat_0
{
@align(16) coords_0 : vec4<f32>,
};
fn Quat_inv_mul_vec_0( this_2 : Quat_0, v_0 : vec3<f32>) -> vec3<f32>
{
var _S6 : vec3<f32> = this_2.coords_0.xyz;
var _S7 : vec3<f32> = cross(_S6, v_0) * vec3<f32>(2.0f);
return _S7 * vec3<f32>(- this_2.coords_0.w) + cross(_S6, _S7) + v_0;
}
struct Sim3_0
{
@align(16) rotation_0 : Quat_0,
@align(16) translation_scale_0 : vec4<f32>,
};
fn Sim3_inv_mul_pt_0( this_3 : Sim3_0, pt_0 : vec3<f32>) -> vec3<f32>
{
return Quat_inv_mul_vec_0(this_3.rotation_0, pt_0 - this_3.translation_scale_0.xyz) / vec3<f32>(this_3.translation_scale_0.w);
}
struct ProjectionResult_0
{
point_0 : vec3<f32>,
is_inside_0 : bool,
};
fn ProjectionResult_x24init_0( point_1 : vec3<f32>, is_inside_1 : bool) -> ProjectionResult_0
{
var _S8 : ProjectionResult_0;
_S8.point_0 = point_1;
_S8.is_inside_0 = is_inside_1;
return _S8;
}
fn Ball_project_local_point_on_boundary_0( this_4 : Ball_0, pt_1 : vec3<f32>) -> ProjectionResult_0
{
var _S9 : f32 = length(pt_1);
return ProjectionResult_x24init_0(select(vec3<f32>(0.0f, this_4.radius_0, 0.0f), pt_1 * vec3<f32>((this_4.radius_0 / _S9)), _S9 != 0.0f), _S9 <= (this_4.radius_0));
}
fn x2A_0( q_0 : Quat_0, v_1 : vec3<f32>) -> vec3<f32>
{
var _S10 : vec3<f32> = q_0.coords_0.xyz;
var _S11 : vec3<f32> = cross(_S10, v_1) * vec3<f32>(2.0f);
return _S11 * vec3<f32>(q_0.coords_0.w) + cross(_S10, _S11) + v_1;
}
fn Sim3_mul_pt_0( this_5 : Sim3_0, pt_2 : vec3<f32>) -> vec3<f32>
{
return x2A_0(this_5.rotation_0, pt_2 * vec3<f32>(this_5.translation_scale_0.w)) + this_5.translation_scale_0.xyz;
}
fn Ball_project_point_on_boundary_0( this_6 : Ball_0, pose_0 : Sim3_0, pt_3 : vec3<f32>) -> ProjectionResult_0
{
var result_0 : ProjectionResult_0 = Ball_project_local_point_on_boundary_0(this_6, Sim3_inv_mul_pt_0(pose_0, pt_3));
result_0.point_0 = Sim3_mul_pt_0(pose_0, result_0.point_0);
return result_0;
}
struct Cuboid_0
{
halfExtents_0 : vec3<f32>,
};
fn Cuboid_x24init_0( halfExtents_1 : vec3<f32>) -> Cuboid_0
{
var _S12 : Cuboid_0;
_S12.halfExtents_0 = halfExtents_1;
return _S12;
}
fn Shape_to_cuboid_0( this_7 : Shape_0) -> Cuboid_0
{
return Cuboid_x24init_0(this_7.a_0.xyz);
}
fn Cuboid_project_local_point_0( this_8 : Cuboid_0, pt_4 : vec3<f32>) -> vec3<f32>
{
var _S13 : vec3<f32> = vec3<f32>(0.0f);
return pt_4 + (max(- this_8.halfExtents_0 - pt_4, _S13) - max(pt_4 - this_8.halfExtents_0, _S13));
}
fn Cuboid_project_local_point_on_boundary_0( this_9 : Cuboid_0, pt_5 : vec3<f32>) -> ProjectionResult_0
{
var _S14 : vec3<f32> = Cuboid_project_local_point_0(this_9, pt_5);
var _S15 : vec3<f32> = vec3<f32>(sign(pt_5));
var _S16 : vec3<f32> = _S15 + (abs(_S15) - vec3<f32>(1.0f));
var _S17 : vec3<f32> = this_9.halfExtents_0 - _S16 * pt_5;
var _S18 : f32 = _S17.x;
var _S19 : f32 = _S17.y;
var _S20 : bool;
if(_S18 <= _S19)
{
_S20 = _S18 <= (_S17.z);
}
else
{
_S20 = false;
}
var _S21 : bool;
if(_S19 <= _S18)
{
_S21 = _S19 <= (_S17.z);
}
else
{
_S21 = false;
}
var _S22 : bool = all(pt_5 == _S14);
return ProjectionResult_x24init_0(select(_S14, pt_5 + select(select(vec3<f32>(0.0f, 0.0f, _S17.z * _S16.z), vec3<f32>(0.0f, _S19 * _S16.y, 0.0f), _S21), vec3<f32>(_S18 * _S16.x, 0.0f, 0.0f), _S20), _S22), _S22);
}
fn Cuboid_project_point_on_boundary_0( this_10 : Cuboid_0, pose_1 : Sim3_0, pt_6 : vec3<f32>) -> ProjectionResult_0
{
var result_1 : ProjectionResult_0 = Cuboid_project_local_point_on_boundary_0(this_10, Sim3_inv_mul_pt_0(pose_1, pt_6));
result_1.point_0 = Sim3_mul_pt_0(pose_1, result_1.point_0);
return result_1;
}
struct Segment_0
{
a_1 : vec3<f32>,
b_1 : vec3<f32>,
};
fn Segment_x24init_0( a_2 : vec3<f32>, b_2 : vec3<f32>) -> Segment_0
{
var _S23 : Segment_0;
_S23.a_1 = a_2;
_S23.b_1 = b_2;
return _S23;
}
struct Capsule_0
{
segment_0 : Segment_0,
radius_2 : f32,
};
fn Capsule_x24init_0( segment_1 : Segment_0, radius_3 : f32) -> Capsule_0
{
var _S24 : Capsule_0;
_S24.segment_0 = segment_1;
_S24.radius_2 = radius_3;
return _S24;
}
fn Shape_to_capsule_0( this_11 : Shape_0) -> Capsule_0
{
return Capsule_x24init_0(Segment_x24init_0(this_11.a_0.xyz, this_11.b_0.xyz), this_11.b_0.w);
}
fn Segment_project_local_point_0( this_12 : Segment_0, pt_7 : vec3<f32>) -> vec3<f32>
{
var _S25 : vec3<f32> = this_12.b_1 - this_12.a_1;
var _S26 : f32 = dot(_S25, pt_7 - this_12.a_1);
var _S27 : f32 = dot(_S25, _S25);
if(_S26 <= 0.0f)
{
return this_12.a_1;
}
else
{
if(_S26 >= _S27)
{
return this_12.b_1;
}
else
{
return this_12.a_1 + _S25 * vec3<f32>((_S26 / _S27));
}
}
}
fn orthonormal_basis3_0( v_2 : vec3<f32>, _S28 : ptr<function, array<vec3<f32>, i32(2)>>)
{
var _S29 : f32 = v_2.z;
var _S30 : f32 = select(-1.0f, 1.0f, _S29 >= 0.0f);
var _S31 : f32 = -1.0f / (_S30 + _S29);
var _S32 : f32 = v_2.x;
var _S33 : f32 = v_2.y;
var _S34 : f32 = _S32 * _S33 * _S31;
var _S35 : vec3<f32> = vec3<f32>(_S34, _S30 + _S33 * _S33 * _S31, - _S33);
(*_S28)[i32(0)] = vec3<f32>(1.0f + _S30 * _S32 * _S32 * _S31, _S30 * _S34, - _S30 * _S32);
(*_S28)[i32(1)] = _S35;
return;
}
fn any_orthogonal_vector_0( v_3 : vec3<f32>) -> vec3<f32>
{
var _S36 : array<vec3<f32>, i32(2)>;
orthonormal_basis3_0(v_3, &(_S36));
return _S36[i32(0)];
}
fn Capsule_project_local_point_on_boundary_0( this_13 : Capsule_0, pt_8 : vec3<f32>) -> ProjectionResult_0
{
var _S37 : vec3<f32> = Segment_project_local_point_0(this_13.segment_0, pt_8);
var _S38 : vec3<f32> = pt_8 - _S37;
var _S39 : f32 = length(_S38);
if(_S39 > 0.0f)
{
return ProjectionResult_x24init_0(_S37 + _S38 * vec3<f32>((this_13.radius_2 / _S39)), _S39 <= (this_13.radius_2));
}
else
{
var _S40 : vec3<f32> = this_13.segment_0.b_1 - this_13.segment_0.a_1;
return ProjectionResult_x24init_0(_S37 + any_orthogonal_vector_0(_S40 / vec3<f32>(length(_S40))) * vec3<f32>(this_13.radius_2), true);
}
}
fn Capsule_project_point_on_boundary_0( this_14 : Capsule_0, pose_2 : Sim3_0, pt_9 : vec3<f32>) -> ProjectionResult_0
{
var result_2 : ProjectionResult_0 = Capsule_project_local_point_on_boundary_0(this_14, Sim3_inv_mul_pt_0(pose_2, pt_9));
result_2.point_0 = Sim3_mul_pt_0(pose_2, result_2.point_0);
return result_2;
}
struct Cone_0
{
half_height_0 : f32,
radius_4 : f32,
};
fn Cone_x24init_0( half_height_1 : f32, radius_5 : f32) -> Cone_0
{
var _S41 : Cone_0;
_S41.half_height_0 = half_height_1;
_S41.radius_4 = radius_5;
return _S41;
}
fn Shape_to_cone_0( this_15 : Shape_0) -> Cone_0
{
return Cone_x24init_0(this_15.a_0.x, this_15.a_0.y);
}
fn Cone_project_local_point_on_boundary_0( this_16 : Cone_0, pt_10 : vec3<f32>) -> ProjectionResult_0
{
var _S42 : vec2<f32> = pt_10.xz;
var _S43 : f32 = length(_S42);
var _S44 : vec2<f32> = select(vec2<f32>(1.0f, 0.0f), _S42 / vec2<f32>(_S43), _S43 > 0.0f);
var _S45 : f32 = - this_16.half_height_0;
var _S46 : vec3<f32> = vec3<f32>(pt_10.x, _S45, pt_10.z);
var _S47 : f32 = pt_10.y;
var _S48 : bool;
if(_S47 < _S45)
{
_S48 = _S43 <= (this_16.radius_4);
}
else
{
_S48 = false;
}
if(_S48)
{
return ProjectionResult_x24init_0(_S46, false);
}
var _S49 : vec2<f32> = _S44 * vec2<f32>(this_16.radius_4);
var _S50 : vec3<f32> = vec3<f32>(0.0f, this_16.half_height_0, 0.0f);
var _S51 : Segment_0 = Segment_x24init_0(_S50, vec3<f32>(_S49[i32(0)], _S45, _S49[i32(1)]));
var _S52 : vec3<f32> = _S51.b_1 - _S51.a_1;
var _S53 : vec3<f32> = Segment_project_local_point_0(_S51, pt_10);
var _S54 : vec3<f32> = vec3<f32>(0.0f, -2.0f * this_16.half_height_0, 0.0f);
if(_S47 >= _S45)
{
_S48 = _S47 <= (this_16.half_height_0);
}
else
{
_S48 = false;
}
if(_S48)
{
_S48 = (dot(cross(_S52, pt_10 - _S50), cross(_S52, _S54))) >= 0.0f;
}
else
{
_S48 = false;
}
if(_S48)
{
var _S55 : vec3<f32> = _S53 - pt_10;
var _S56 : vec3<f32> = _S46 - pt_10;
if((dot(_S55, _S55)) > (dot(_S56, _S56)))
{
return ProjectionResult_x24init_0(_S46, true);
}
else
{
return ProjectionResult_x24init_0(_S53, true);
}
}
else
{
return ProjectionResult_x24init_0(_S53, false);
}
}
fn Cone_project_point_on_boundary_0( this_17 : Cone_0, pose_3 : Sim3_0, pt_11 : vec3<f32>) -> ProjectionResult_0
{
var result_3 : ProjectionResult_0 = Cone_project_local_point_on_boundary_0(this_17, Sim3_inv_mul_pt_0(pose_3, pt_11));
result_3.point_0 = Sim3_mul_pt_0(pose_3, result_3.point_0);
return result_3;
}
struct Cylinder_0
{
half_height_2 : f32,
radius_6 : f32,
};
fn Cylinder_x24init_0( half_height_3 : f32, radius_7 : f32) -> Cylinder_0
{
var _S57 : Cylinder_0;
_S57.half_height_2 = half_height_3;
_S57.radius_6 = radius_7;
return _S57;
}
fn Shape_to_cylinder_0( this_18 : Shape_0) -> Cylinder_0
{
return Cylinder_x24init_0(this_18.a_0.x, this_18.a_0.y);
}
fn Cylinder_project_local_point_on_boundary_0( this_19 : Cylinder_0, pt_12 : vec3<f32>) -> ProjectionResult_0
{
var _S58 : vec2<f32> = pt_12.xz;
var _S59 : f32 = length(_S58);
var _S60 : vec2<f32> = select(vec2<f32>(1.0f, 0.0f), _S58 / vec2<f32>(_S59), _S59 > 0.0f) * vec2<f32>(this_19.radius_6);
var _S61 : f32 = pt_12.y;
var _S62 : f32 = - this_19.half_height_2;
var _S63 : bool;
if(_S61 >= _S62)
{
_S63 = _S61 <= (this_19.half_height_2);
}
else
{
_S63 = false;
}
if(_S63)
{
_S63 = _S59 <= (this_19.radius_6);
}
else
{
_S63 = false;
}
if(_S63)
{
var _S64 : f32 = this_19.half_height_2 - _S61;
var _S65 : f32 = _S61 - _S62;
var _S66 : f32 = this_19.radius_6 - _S59;
if(_S64 < _S65)
{
_S63 = _S64 < _S66;
}
else
{
_S63 = false;
}
if(_S63)
{
return ProjectionResult_x24init_0(vec3<f32>(pt_12.x, this_19.half_height_2, pt_12.z), true);
}
else
{
if(_S65 < _S64)
{
_S63 = _S65 < _S66;
}
else
{
_S63 = false;
}
if(_S63)
{
return ProjectionResult_x24init_0(vec3<f32>(pt_12.x, _S62, pt_12.z), true);
}
else
{
return ProjectionResult_x24init_0(vec3<f32>(_S60[i32(0)], _S61, _S60[i32(1)]), true);
}
}
}
else
{
if(_S61 > (this_19.half_height_2))
{
if(_S59 <= (this_19.radius_6))
{
return ProjectionResult_x24init_0(vec3<f32>(pt_12.x, this_19.half_height_2, pt_12.z), false);
}
else
{
return ProjectionResult_x24init_0(vec3<f32>(_S60[i32(0)], this_19.half_height_2, _S60[i32(1)]), false);
}
}
else
{
if(_S61 < _S62)
{
if(_S59 <= (this_19.radius_6))
{
return ProjectionResult_x24init_0(vec3<f32>(pt_12.x, _S62, pt_12.z), false);
}
else
{
return ProjectionResult_x24init_0(vec3<f32>(_S60[i32(0)], _S62, _S60[i32(1)]), false);
}
}
else
{
return ProjectionResult_x24init_0(vec3<f32>(_S60[i32(0)], _S61, _S60[i32(1)]), false);
}
}
}
}
fn Cylinder_project_point_on_boundary_0( this_20 : Cylinder_0, pose_4 : Sim3_0, pt_13 : vec3<f32>) -> ProjectionResult_0
{
var result_4 : ProjectionResult_0 = Cylinder_project_local_point_on_boundary_0(this_20, Sim3_inv_mul_pt_0(pose_4, pt_13));
result_4.point_0 = Sim3_mul_pt_0(pose_4, result_4.point_0);
return result_4;
}
fn Shape_project_point_on_boundary_0( this_21 : Shape_0, pose_5 : Sim3_0, pt_14 : vec3<f32>) -> ProjectionResult_0
{
var _S67 : u32 = Shape_shape_type_0(this_21);
if(_S67 == u32(0))
{
return Ball_project_point_on_boundary_0(Shape_to_ball_0(this_21), pose_5, pt_14);
}
if(_S67 == u32(1))
{
return Cuboid_project_point_on_boundary_0(Shape_to_cuboid_0(this_21), pose_5, pt_14);
}
if(_S67 == u32(2))
{
return Capsule_project_point_on_boundary_0(Shape_to_capsule_0(this_21), pose_5, pt_14);
}
if(_S67 == u32(3))
{
return Cone_project_point_on_boundary_0(Shape_to_cone_0(this_21), pose_5, pt_14);
}
if(_S67 == u32(4))
{
return Cylinder_project_point_on_boundary_0(Shape_to_cylinder_0(this_21), pose_5, pt_14);
}
return ProjectionResult_x24init_0(pt_14, false);
}
fn getCount_0() -> i32
{
var _S68 : vec2<u32> = vec2<u32>(arrayLength(&entryPointParams_collision_shapes_0), 32);
return i32(_S68.x);
}
fn collide_0( _S69 : f32, _S70 : vec3<f32>) -> NodeCdf_0
{
var cdf_1 : NodeCdf_0 = NodeCdf_x24init_0(1.0e+10f, u32(0), u32(4294967295));
var _S71 : vec3<f32> = vec3<f32>((_S69 * 1.5f));
var i_3 : u32 = u32(0);
for(;;)
{
var _S72 : i32 = getCount_0();
if(i_3 < u32(_S72))
{
}
else
{
break;
}
var _S73 : Shape_0 = Shape_0( entryPointParams_collision_shapes_0[i_3].a_0, entryPointParams_collision_shapes_0[i_3].b_0 );
var _S74 : Quat_0 = Quat_0( entryPointParams_collision_shape_poses_0[i_3].rotation_0.coords_0 );
var _S75 : Sim3_0 = Sim3_0( _S74, entryPointParams_collision_shape_poses_0[i_3].translation_scale_0 );
var _S76 : u32 = Shape_shape_type_0(_S73);
var _S77 : bool;
if(_S76 != u32(5))
{
_S77 = _S76 != u32(6);
}
else
{
_S77 = false;
}
if(_S77)
{
var _S78 : ProjectionResult_0 = Shape_project_point_on_boundary_0(_S73, _S75, _S70);
var _S79 : vec3<f32> = _S78.point_0 - _S70;
var _S80 : bool;
if(_S78.is_inside_0)
{
_S80 = true;
}
else
{
_S80 = all((abs(_S79)) <= _S71);
}
if(_S80)
{
var _S81 : f32 = length(_S79);
cdf_1.closest_id_0 = select(cdf_1.closest_id_0, i_3, _S81 < (cdf_1.distance_0));
cdf_1.distance_0 = min(cdf_1.distance_0, _S81);
cdf_1.affinities_0 = ((cdf_1.affinities_0) | (((select(u32(1), u32(65537), _S78.is_inside_0) << (i_3)))));
}
}
i_3 = i_3 + u32(1);
}
return cdf_1;
}
@compute
@workgroup_size(4, 4, 4)
fn grid_update(@builtin(workgroup_id) block_id_0 : vec3<u32>, @builtin(local_invocation_id) tid_0 : vec3<u32>, @builtin(local_invocation_index) tid_flat_0 : u32)
{
var _S82 : u32 = block_id_0.x;
var _S83 : NodeCdf_0 = collide_0(entryPointParams_grid_0[i32(0)].cell_width_0, vec3<f32>(entryPointParams_active_blocks_0[_S82].virtual_id_0.id_0 * vec3<i32>(i32(4)) + vec3<i32>(tid_0)) * vec3<f32>(entryPointParams_grid_0[i32(0)].cell_width_0));
entryPointParams_nodes_0[node_id_0(block_header_id_to_physical_id_0(BlockHeaderId_x24init_0(_S82)), tid_0).id_3].cdf_0.distance_0 = _S83.distance_0;
entryPointParams_nodes_0[node_id_0(block_header_id_to_physical_id_0(BlockHeaderId_x24init_0(_S82)), tid_0).id_3].cdf_0.affinities_0 = _S83.affinities_0;
entryPointParams_nodes_0[node_id_0(block_header_id_to_physical_id_0(BlockHeaderId_x24init_0(_S82)), tid_0).id_3].cdf_0.closest_id_0 = _S83.closest_id_0;
return;
}