struct SimulationParams_std140_0
{
@align(16) gravity_0 : vec2<f32>,
@align(8) padding_0 : f32,
@align(4) dt_0 : f32,
};
@binding(0) @group(0) var<uniform> entryPointParams_params_0 : SimulationParams_std140_0;
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(1) @group(0) var<storage, read> entryPointParams_grid_0 : array<GridGeneric_std430_0>;
struct BodyMassProperties_std430_0
{
@align(8) inv_inertia_0 : f32,
@align(8) inv_mass_0 : vec2<f32>,
@align(8) com_0 : vec2<f32>,
};
@binding(2) @group(0) var<storage, read> entryPointParams_local_mprops_0 : array<BodyMassProperties_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_write> entryPointParams_poses_0 : array<Sim2_std430_0>;
struct BodyVelocity_std430_0
{
@align(8) linear_0 : vec2<f32>,
@align(8) angular_0 : f32,
};
@binding(4) @group(0) var<storage, read_write> entryPointParams_vels_0 : array<BodyVelocity_std430_0>;
@binding(5) @group(0) var<storage, read_write> entryPointParams_mprops_0 : array<BodyMassProperties_std430_0>;
struct IntegerImpulse_std430_0
{
@align(8) com_1 : vec2<f32>,
@align(8) linear_1 : vec2<i32>,
@align(8) angular_1 : i32,
};
@binding(6) @group(0) var<storage, read_write> entryPointParams_incremental_impulses_0 : array<IntegerImpulse_std430_0>;
@binding(7) @group(0) var<storage, read> entryPointParams_poses_1 : array<Sim2_std430_0>;
@binding(8) @group(0) var<storage, read> entryPointParams_local_mprops_1 : array<BodyMassProperties_std430_0>;
@binding(9) @group(0) var<storage, read_write> entryPointParams_mprops_1 : array<BodyMassProperties_std430_0>;
@binding(10) @group(0) var<storage, read_write> entryPointParams_incremental_impulses_1 : array<IntegerImpulse_std430_0>;
fn int2flt_0( i_0 : i32) -> f32
{
return f32(i_0) / 1.0e+05f;
}
struct Impulse_0
{
linear_2 : vec2<f32>,
angular_2 : f32,
};
fn Impulse_x24init_0( linear_3 : vec2<f32>, angular_3 : f32) -> Impulse_0
{
var _S1 : Impulse_0;
_S1.linear_2 = linear_3;
_S1.angular_2 = angular_3;
return _S1;
}
struct IntegerImpulse_0
{
@align(8) com_1 : vec2<f32>,
@align(8) linear_1 : vec2<i32>,
@align(8) angular_1 : i32,
};
fn int_impulse_to_float_0( imp_0 : IntegerImpulse_0) -> Impulse_0
{
return Impulse_x24init_0(vec2<f32>(int2flt_0(imp_0.linear_1.x), int2flt_0(imp_0.linear_1.y)), int2flt_0(imp_0.angular_1));
}
fn IntegerImpulse_x24init_0( com_2 : vec2<f32>, linear_4 : vec2<i32>, angular_4 : i32) -> IntegerImpulse_0
{
var _S2 : IntegerImpulse_0;
_S2.com_1 = com_2;
_S2.linear_1 = linear_4;
_S2.angular_1 = angular_4;
return _S2;
}
struct BodyVelocity_0
{
@align(8) linear_0 : vec2<f32>,
@align(8) angular_0 : f32,
};
fn BodyVelocity_x24init_0( linear_5 : vec2<f32>, angular_5 : f32) -> BodyVelocity_0
{
var _S3 : BodyVelocity_0;
_S3.linear_0 = linear_5;
_S3.angular_0 = angular_5;
return _S3;
}
struct BodyMassProperties_0
{
@align(8) inv_inertia_0 : f32,
@align(8) inv_mass_0 : vec2<f32>,
@align(8) com_0 : vec2<f32>,
};
fn apply_impulse_0( mprops_0 : BodyMassProperties_0, velocity_0 : BodyVelocity_0, imp_1 : Impulse_0) -> BodyVelocity_0
{
return BodyVelocity_x24init_0(velocity_0.linear_0 + mprops_0.inv_mass_0 * imp_1.linear_2, velocity_0.angular_0 + imp_1.angular_2 * mprops_0.inv_inertia_0);
}
struct Rot2_0
{
@align(8) cos_sin_0 : vec2<f32>,
};
fn x2A_0( r_0 : Rot2_0, v_0 : vec2<f32>) -> vec2<f32>
{
var _S4 : f32 = r_0.cos_sin_0.x;
var _S5 : f32 = v_0.x;
var _S6 : f32 = r_0.cos_sin_0.y;
var _S7 : f32 = v_0.y;
return vec2<f32>(_S4 * _S5 - _S6 * _S7, _S6 * _S5 + _S4 * _S7);
}
struct Sim2_0
{
@align(8) rotation_0 : Rot2_0,
@align(8) translation_0 : vec2<f32>,
@align(8) scale_0 : f32,
};
fn Sim2_mul_pt_0( this_0 : Sim2_0, pt_0 : vec2<f32>) -> vec2<f32>
{
return x2A_0(this_0.rotation_0, pt_0 * vec2<f32>(this_0.scale_0)) + this_0.translation_0;
}
fn Rot2_x24init_0( cos_sin_1 : vec2<f32>) -> Rot2_0
{
var _S8 : Rot2_0;
_S8.cos_sin_0 = cos_sin_1;
return _S8;
}
fn Rot2_from_angle_0( angle_0 : f32) -> Rot2_0
{
return Rot2_x24init_0(vec2<f32>(cos(angle_0), sin(angle_0)));
}
fn x2A_1( lhs_0 : Rot2_0, rhs_0 : Rot2_0) -> Rot2_0
{
var _S9 : f32 = lhs_0.cos_sin_0.x;
var _S10 : f32 = rhs_0.cos_sin_0.x;
var _S11 : f32 = lhs_0.cos_sin_0.y;
var _S12 : f32 = rhs_0.cos_sin_0.y;
return Rot2_x24init_0(vec2<f32>(_S9 * _S10 - _S11 * _S12, _S11 * _S10 + _S9 * _S12));
}
fn Sim2_x24init_0( rotation_1 : Rot2_0, translation_1 : vec2<f32>, scale_1 : f32) -> Sim2_0
{
var _S13 : Sim2_0;
_S13.rotation_0 = rotation_1;
_S13.translation_0 = translation_1;
_S13.scale_0 = scale_1;
return _S13;
}
fn integrate_velocity_0( pose_0 : Sim2_0, vels_0 : BodyVelocity_0, local_com_0 : vec2<f32>, dt_1 : f32) -> Sim2_0
{
var _S14 : vec2<f32> = Sim2_mul_pt_0(pose_0, local_com_0);
var _S15 : Rot2_0 = Rot2_from_angle_0(vels_0.angular_0 * dt_1);
return Sim2_x24init_0(x2A_1(_S15, pose_0.rotation_0), _S14 + x2A_0(_S15, pose_0.translation_0 - _S14) * vec2<f32>(pose_0.scale_0) + vels_0.linear_0 * vec2<f32>(dt_1), pose_0.scale_0);
}
fn getCount_0() -> i32
{
var _S16 : vec2<u32> = vec2<u32>(arrayLength(&entryPointParams_vels_0), 16);
return i32(_S16.x);
}
@compute
@workgroup_size(16, 1, 1)
fn update(@builtin(global_invocation_id) invocation_id_0 : vec3<u32>)
{
var _S17 : u32 = invocation_id_0.x;
var _S18 : i32 = getCount_0();
if(_S17 < u32(_S18))
{
var _S19 : IntegerImpulse_0 = IntegerImpulse_0( entryPointParams_incremental_impulses_0[_S17].com_1, entryPointParams_incremental_impulses_0[_S17].linear_1, entryPointParams_incremental_impulses_0[_S17].angular_1 );
var inc_impulse_0 : Impulse_0 = int_impulse_to_float_0(_S19);
var _S20 : vec2<f32> = vec2<f32>(0.0f);
var _S21 : IntegerImpulse_0 = IntegerImpulse_x24init_0(_S20, vec2<i32>(i32(0)), i32(0));
entryPointParams_incremental_impulses_0[_S17].com_1 = _S21.com_1;
entryPointParams_incremental_impulses_0[_S17].linear_1 = _S21.linear_1;
entryPointParams_incremental_impulses_0[_S17].angular_1 = _S21.angular_1;
var _S22 : BodyMassProperties_0 = BodyMassProperties_0( entryPointParams_mprops_0[_S17].inv_inertia_0, entryPointParams_mprops_0[_S17].inv_mass_0, entryPointParams_mprops_0[_S17].com_0 );
var _S23 : BodyVelocity_0 = BodyVelocity_0( entryPointParams_vels_0[_S17].linear_0, entryPointParams_vels_0[_S17].angular_0 );
var new_vel_0 : BodyVelocity_0 = apply_impulse_0(_S22, _S23, inc_impulse_0);
var _S24 : f32 = length(new_vel_0.linear_0);
var _S25 : f32 = length(new_vel_0.angular_0);
var _S26 : f32 = 0.10000000149011612f * entryPointParams_grid_0[i32(0)].cell_width_0 / entryPointParams_params_0.dt_0;
var _S27 : bool;
if((length(inc_impulse_0.linear_2)) != 0.0f)
{
_S27 = true;
}
else
{
var _S28 : f32 = length(inc_impulse_0.angular_2);
_S27 = _S28 != 0.0f;
}
if(_S27)
{
if(_S24 > _S26)
{
new_vel_0.linear_0 = new_vel_0.linear_0 * vec2<f32>((_S26 / _S24));
}
if(_S25 > 1.0f)
{
new_vel_0.angular_0 = new_vel_0.angular_0 * (1.0f / _S25);
}
}
var _S29 : Rot2_0 = Rot2_0( entryPointParams_poses_0[_S17].rotation_0.cos_sin_0 );
var _S30 : Sim2_0 = Sim2_0( _S29, entryPointParams_poses_0[_S17].translation_0, entryPointParams_poses_0[_S17].scale_0 );
var new_pose_0 : Sim2_0 = integrate_velocity_0(_S30, new_vel_0, entryPointParams_local_mprops_0[_S17].com_0, entryPointParams_params_0.dt_0);
new_vel_0.linear_0 = new_vel_0.linear_0 + entryPointParams_params_0.gravity_0 * vec2<f32>((entryPointParams_mprops_0[_S17].inv_mass_0) != _S20) * vec2<f32>(entryPointParams_params_0.dt_0);
var _S31 : BodyVelocity_0 = new_vel_0;
entryPointParams_vels_0[_S17].linear_0 = new_vel_0.linear_0;
entryPointParams_vels_0[_S17].angular_0 = _S31.angular_0;
entryPointParams_poses_0[_S17].rotation_0.cos_sin_0 = new_pose_0.rotation_0.cos_sin_0;
entryPointParams_poses_0[_S17].translation_0 = new_pose_0.translation_0;
entryPointParams_poses_0[_S17].scale_0 = new_pose_0.scale_0;
}
return;
}
fn BodyMassProperties_x24init_0( inv_inertia_1 : f32, inv_mass_1 : vec2<f32>, com_3 : vec2<f32>) -> BodyMassProperties_0
{
var _S32 : BodyMassProperties_0;
_S32.inv_inertia_0 = inv_inertia_1;
_S32.inv_mass_0 = inv_mass_1;
_S32.com_0 = com_3;
return _S32;
}
fn update_mprops_0( pose_1 : Sim2_0, local_mprops_0 : BodyMassProperties_0) -> BodyMassProperties_0
{
return BodyMassProperties_x24init_0(local_mprops_0.inv_inertia_0, local_mprops_0.inv_mass_0, Sim2_mul_pt_0(pose_1, local_mprops_0.com_0));
}
fn getCount_1() -> i32
{
var _S33 : vec2<u32> = vec2<u32>(arrayLength(&entryPointParams_mprops_1), 24);
return i32(_S33.x);
}
@compute
@workgroup_size(64, 1, 1)
fn update_world_mass_properties(@builtin(global_invocation_id) invocation_id_1 : vec3<u32>)
{
var _S34 : u32 = invocation_id_1.x;
var _S35 : i32 = getCount_1();
if(_S34 < u32(_S35))
{
var _S36 : Rot2_0 = Rot2_0( entryPointParams_poses_1[_S34].rotation_0.cos_sin_0 );
var _S37 : Sim2_0 = Sim2_0( _S36, entryPointParams_poses_1[_S34].translation_0, entryPointParams_poses_1[_S34].scale_0 );
var _S38 : BodyMassProperties_0 = BodyMassProperties_0( entryPointParams_local_mprops_1[_S34].inv_inertia_0, entryPointParams_local_mprops_1[_S34].inv_mass_0, entryPointParams_local_mprops_1[_S34].com_0 );
var _S39 : BodyMassProperties_0 = update_mprops_0(_S37, _S38);
entryPointParams_incremental_impulses_1[_S34].com_1 = _S39.com_0;
entryPointParams_mprops_1[_S34].inv_inertia_0 = _S39.inv_inertia_0;
entryPointParams_mprops_1[_S34].inv_mass_0 = _S39.inv_mass_0;
entryPointParams_mprops_1[_S34].com_0 = _S39.com_0;
}
return;
}