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(8) id_0 : vec2<i32>,
};
struct ActiveBlockHeaderGeneric_std430_0
{
@align(8) virtual_id_0 : BlockVirtualId_std430_0,
@align(8) 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 Rot2_std430_0
{
@align(8) cos_sin_0 : vec2<f32>,
};
struct Sim2_std430_0
{
@align(8) rotation_0 : Rot2_std430_0,
@align(8) translation_0 : vec2<f32>,
@align(8) scale_0 : f32,
};
@binding(3) @group(0) var<storage, read> entryPointParams_collision_shape_poses_0 : array<Sim2_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 : vec3<f32>,
@align(4) 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 : vec2<u32>) -> NodePhysicalId_0
{
return NodePhysicalId_x24init_0(pid_0.id_2 + shift_in_block_0.x + shift_in_block_0.y * u32(8));
}
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 Rot2_0
{
@align(8) cos_sin_0 : vec2<f32>,
};
fn Rot2_inv_mul_vec_0( this_2 : Rot2_0, v_0 : vec2<f32>) -> vec2<f32>
{
var _S6 : f32 = this_2.cos_sin_0.x;
var _S7 : f32 = v_0.x;
var _S8 : f32 = this_2.cos_sin_0.y;
var _S9 : f32 = v_0.y;
return vec2<f32>(_S6 * _S7 + _S8 * _S9, - _S8 * _S7 + _S6 * _S9);
}
struct Sim2_0
{
@align(8) rotation_0 : Rot2_0,
@align(8) translation_0 : vec2<f32>,
@align(8) scale_0 : f32,
};
fn Sim2_inv_mul_pt_0( this_3 : Sim2_0, pt_0 : vec2<f32>) -> vec2<f32>
{
return Rot2_inv_mul_vec_0(this_3.rotation_0, pt_0 - this_3.translation_0) / vec2<f32>(this_3.scale_0);
}
struct ProjectionResult_0
{
point_0 : vec2<f32>,
is_inside_0 : bool,
};
fn ProjectionResult_x24init_0( point_1 : vec2<f32>, is_inside_1 : bool) -> ProjectionResult_0
{
var _S10 : ProjectionResult_0;
_S10.point_0 = point_1;
_S10.is_inside_0 = is_inside_1;
return _S10;
}
fn Ball_project_local_point_on_boundary_0( this_4 : Ball_0, pt_1 : vec2<f32>) -> ProjectionResult_0
{
var _S11 : f32 = length(pt_1);
return ProjectionResult_x24init_0(select(vec2<f32>(0.0f, this_4.radius_0), pt_1 * vec2<f32>((this_4.radius_0 / _S11)), _S11 != 0.0f), _S11 <= (this_4.radius_0));
}
fn x2A_0( r_0 : Rot2_0, v_1 : vec2<f32>) -> vec2<f32>
{
var _S12 : f32 = r_0.cos_sin_0.x;
var _S13 : f32 = v_1.x;
var _S14 : f32 = r_0.cos_sin_0.y;
var _S15 : f32 = v_1.y;
return vec2<f32>(_S12 * _S13 - _S14 * _S15, _S14 * _S13 + _S12 * _S15);
}
fn Sim2_mul_pt_0( this_5 : Sim2_0, pt_2 : vec2<f32>) -> vec2<f32>
{
return x2A_0(this_5.rotation_0, pt_2 * vec2<f32>(this_5.scale_0)) + this_5.translation_0;
}
fn Ball_project_point_on_boundary_0( this_6 : Ball_0, pose_0 : Sim2_0, pt_3 : vec2<f32>) -> ProjectionResult_0
{
var result_0 : ProjectionResult_0 = Ball_project_local_point_on_boundary_0(this_6, Sim2_inv_mul_pt_0(pose_0, pt_3));
result_0.point_0 = Sim2_mul_pt_0(pose_0, result_0.point_0);
return result_0;
}
struct Cuboid_0
{
halfExtents_0 : vec2<f32>,
};
fn Cuboid_x24init_0( halfExtents_1 : vec2<f32>) -> Cuboid_0
{
var _S16 : Cuboid_0;
_S16.halfExtents_0 = halfExtents_1;
return _S16;
}
fn Shape_to_cuboid_0( this_7 : Shape_0) -> Cuboid_0
{
return Cuboid_x24init_0(this_7.a_0.xy);
}
fn Cuboid_project_local_point_0( this_8 : Cuboid_0, pt_4 : vec2<f32>) -> vec2<f32>
{
var _S17 : vec2<f32> = vec2<f32>(0.0f);
return pt_4 + (max(- this_8.halfExtents_0 - pt_4, _S17) - max(pt_4 - this_8.halfExtents_0, _S17));
}
fn Cuboid_project_local_point_on_boundary_0( this_9 : Cuboid_0, pt_5 : vec2<f32>) -> ProjectionResult_0
{
var _S18 : vec2<f32> = Cuboid_project_local_point_0(this_9, pt_5);
var _S19 : vec2<f32> = vec2<f32>(sign(pt_5));
var _S20 : vec2<f32> = _S19 + (abs(_S19) - vec2<f32>(1.0f));
var _S21 : vec2<f32> = this_9.halfExtents_0 - _S20 * pt_5;
var _S22 : f32 = _S21.x;
var _S23 : f32 = _S21.y;
var _S24 : bool = all(pt_5 == _S18);
return ProjectionResult_x24init_0(select(_S18, pt_5 + select(vec2<f32>(0.0f, _S23 * _S20.y), vec2<f32>(_S22 * _S20.x, 0.0f), _S22 <= _S23), _S24), _S24);
}
fn Cuboid_project_point_on_boundary_0( this_10 : Cuboid_0, pose_1 : Sim2_0, pt_6 : vec2<f32>) -> ProjectionResult_0
{
var result_1 : ProjectionResult_0 = Cuboid_project_local_point_on_boundary_0(this_10, Sim2_inv_mul_pt_0(pose_1, pt_6));
result_1.point_0 = Sim2_mul_pt_0(pose_1, result_1.point_0);
return result_1;
}
struct Segment_0
{
a_1 : vec2<f32>,
b_1 : vec2<f32>,
};
fn Segment_x24init_0( a_2 : vec2<f32>, b_2 : vec2<f32>) -> Segment_0
{
var _S25 : Segment_0;
_S25.a_1 = a_2;
_S25.b_1 = b_2;
return _S25;
}
struct Capsule_0
{
segment_0 : Segment_0,
radius_2 : f32,
};
fn Capsule_x24init_0( segment_1 : Segment_0, radius_3 : f32) -> Capsule_0
{
var _S26 : Capsule_0;
_S26.segment_0 = segment_1;
_S26.radius_2 = radius_3;
return _S26;
}
fn Shape_to_capsule_0( this_11 : Shape_0) -> Capsule_0
{
return Capsule_x24init_0(Segment_x24init_0(this_11.a_0.xy, this_11.b_0.xy), this_11.b_0.w);
}
fn Segment_project_local_point_0( this_12 : Segment_0, pt_7 : vec2<f32>) -> vec2<f32>
{
var _S27 : vec2<f32> = this_12.b_1 - this_12.a_1;
var _S28 : f32 = dot(_S27, pt_7 - this_12.a_1);
var _S29 : f32 = dot(_S27, _S27);
if(_S28 <= 0.0f)
{
return this_12.a_1;
}
else
{
if(_S28 >= _S29)
{
return this_12.b_1;
}
else
{
return this_12.a_1 + _S27 * vec2<f32>((_S28 / _S29));
}
}
}
fn any_orthogonal_vector_0( v_2 : vec2<f32>) -> vec2<f32>
{
return vec2<f32>(v_2.y, - v_2.x);
}
fn Capsule_project_local_point_on_boundary_0( this_13 : Capsule_0, pt_8 : vec2<f32>) -> ProjectionResult_0
{
var _S30 : vec2<f32> = Segment_project_local_point_0(this_13.segment_0, pt_8);
var _S31 : vec2<f32> = pt_8 - _S30;
var _S32 : f32 = length(_S31);
if(_S32 > 0.0f)
{
return ProjectionResult_x24init_0(_S30 + _S31 * vec2<f32>((this_13.radius_2 / _S32)), _S32 <= (this_13.radius_2));
}
else
{
var _S33 : vec2<f32> = this_13.segment_0.b_1 - this_13.segment_0.a_1;
return ProjectionResult_x24init_0(_S30 + any_orthogonal_vector_0(_S33 / vec2<f32>(length(_S33))) * vec2<f32>(this_13.radius_2), true);
}
}
fn Capsule_project_point_on_boundary_0( this_14 : Capsule_0, pose_2 : Sim2_0, pt_9 : vec2<f32>) -> ProjectionResult_0
{
var result_2 : ProjectionResult_0 = Capsule_project_local_point_on_boundary_0(this_14, Sim2_inv_mul_pt_0(pose_2, pt_9));
result_2.point_0 = Sim2_mul_pt_0(pose_2, result_2.point_0);
return result_2;
}
fn Shape_project_point_on_boundary_0( this_15 : Shape_0, pose_3 : Sim2_0, pt_10 : vec2<f32>) -> ProjectionResult_0
{
var _S34 : u32 = Shape_shape_type_0(this_15);
if(_S34 == u32(0))
{
return Ball_project_point_on_boundary_0(Shape_to_ball_0(this_15), pose_3, pt_10);
}
if(_S34 == u32(1))
{
return Cuboid_project_point_on_boundary_0(Shape_to_cuboid_0(this_15), pose_3, pt_10);
}
if(_S34 == u32(2))
{
return Capsule_project_point_on_boundary_0(Shape_to_capsule_0(this_15), pose_3, pt_10);
}
return ProjectionResult_x24init_0(pt_10, false);
}
fn getCount_0() -> i32
{
var _S35 : vec2<u32> = vec2<u32>(arrayLength(&entryPointParams_collision_shapes_0), 32);
return i32(_S35.x);
}
fn collide_0( _S36 : f32, _S37 : vec2<f32>) -> NodeCdf_0
{
var cdf_1 : NodeCdf_0 = NodeCdf_x24init_0(1.0e+10f, u32(0), u32(4294967295));
var _S38 : vec2<f32> = vec2<f32>((_S36 * 1.5f));
var i_3 : u32 = u32(0);
for(;;)
{
var _S39 : i32 = getCount_0();
if(i_3 < u32(_S39))
{
}
else
{
break;
}
var _S40 : Shape_0 = Shape_0( entryPointParams_collision_shapes_0[i_3].a_0, entryPointParams_collision_shapes_0[i_3].b_0 );
var _S41 : Rot2_0 = Rot2_0( entryPointParams_collision_shape_poses_0[i_3].rotation_0.cos_sin_0 );
var _S42 : Sim2_0 = Sim2_0( _S41, entryPointParams_collision_shape_poses_0[i_3].translation_0, entryPointParams_collision_shape_poses_0[i_3].scale_0 );
var _S43 : u32 = Shape_shape_type_0(_S40);
var _S44 : bool;
if(_S43 != u32(5))
{
_S44 = _S43 != u32(6);
}
else
{
_S44 = false;
}
if(_S44)
{
var _S45 : ProjectionResult_0 = Shape_project_point_on_boundary_0(_S40, _S42, _S37);
var _S46 : vec2<f32> = _S45.point_0 - _S37;
var _S47 : bool;
if(_S45.is_inside_0)
{
_S47 = true;
}
else
{
_S47 = all((abs(_S46)) <= _S38);
}
if(_S47)
{
var _S48 : f32 = length(_S46);
cdf_1.closest_id_0 = select(cdf_1.closest_id_0, i_3, _S48 < (cdf_1.distance_0));
cdf_1.distance_0 = min(cdf_1.distance_0, _S48);
cdf_1.affinities_0 = ((cdf_1.affinities_0) | (((select(u32(1), u32(65537), _S45.is_inside_0) << (i_3)))));
}
}
i_3 = i_3 + u32(1);
}
return cdf_1;
}
@compute
@workgroup_size(8, 8, 1)
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 _S49 : u32 = block_id_0.x;
var _S50 : vec2<u32> = tid_0.xy;
var _S51 : NodeCdf_0 = collide_0(entryPointParams_grid_0[i32(0)].cell_width_0, vec2<f32>(entryPointParams_active_blocks_0[_S49].virtual_id_0.id_0 * vec2<i32>(i32(8)) + vec2<i32>(_S50)) * vec2<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(_S49)), _S50).id_3].cdf_0.distance_0 = _S51.distance_0;
entryPointParams_nodes_0[node_id_0(block_header_id_to_physical_id_0(BlockHeaderId_x24init_0(_S49)), _S50).id_3].cdf_0.affinities_0 = _S51.affinities_0;
entryPointParams_nodes_0[node_id_0(block_header_id_to_physical_id_0(BlockHeaderId_x24init_0(_S49)), _S50).id_3].cdf_0.closest_id_0 = _S51.closest_id_0;
return;
}