Add all standard library functions to the IR

This commit is contained in:
Dzmitry Malyshau authored and Dzmitry Malyshau committed 2020-12-09 15:43:36 -05:00
1 parent 66d994566c
commit b35e901249
12 files changed
+744 -462

No files matched your search

+7 -7
View File
@@ -23,10 +23,10 @@ import "GLSL.std.450" as std;
[[stage(vertex)]]
fn main() -> void {
var angle : f32 = -std::atan2(a_particleVel.x, a_particleVel.y);
var angle : f32 = -atan2(a_particleVel.x, a_particleVel.y);
var pos : vec2<f32> = vec2<f32>(
(a_pos.x * std::cos(angle)) - (a_pos.y * std::sin(angle)),
(a_pos.x * std::sin(angle)) + (a_pos.y * std::cos(angle)));
(a_pos.x * cos(angle)) - (a_pos.y * sin(angle)),
(a_pos.x * sin(angle)) + (a_pos.y * cos(angle)));
gl_Position = vec4<f32>(pos + a_particlePos, 0.0, 1.0);
return;
}
@@ -97,14 +97,14 @@ fn main() -> void {
pos = particlesA.particles[i].pos.xy;
vel = particlesA.particles[i].vel.xy;
if (std::distance(pos, vPos) < params.rule1Distance) {
if (distance(pos, vPos) < params.rule1Distance) {
cMass = cMass + pos;
cMassCount = cMassCount + 1;
}
if (std::distance(pos, vPos) < params.rule2Distance) {
if (distance(pos, vPos) < params.rule2Distance) {
colVel = colVel - (pos - vPos);
}
if (std::distance(pos, vPos) < params.rule3Distance) {
if (distance(pos, vPos) < params.rule3Distance) {
cVel = cVel + vel;
cVelCount = cVelCount + 1;
}
@@ -124,7 +124,7 @@ fn main() -> void {
(cVel * params.rule3Scale);
# clamp velocity for a more pleasing simulation
vVel = std::normalize(vVel) * std::fclamp(std::length(vVel), 0.0, 0.1);
vVel = normalize(vVel) * clamp(length(vVel), 0.0, 0.1);
# kinematic update
vPos = vPos + (vVel * params.deltaT);