Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8abdeda authored by Jason Sams's avatar Jason Sams
Browse files

Fix physics bug causing balls to stack.

Change-Id: I681905cf7499bb92db47ba2a4cca10d0834cf425
parent c60df506
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import android.renderscript.*;
import android.util.Log;

public class BallsRS {
    public static final int PART_COUNT = 800;
    public static final int PART_COUNT = 1000;

    public BallsRS() {
    }
+14 −1
Original line number Diff line number Diff line
@@ -41,8 +41,21 @@ void root(const Ball_t *ballIn, Ball_t *ballOut, const BallControl_t *ctl, uint3
                fv -= (vec / (len * len * len)) * 20000.f;
            } else {
                if (len2 < 0.1) {
                    if (xin == x) {
                        continue;
                    }
                    ballOut->delta = 0.f;
                    ballOut->position = ballIn->position;
                    if (xin > x) {
                        ballOut->position.x += 1.f;
                    } else {
                        ballOut->position.x -= 1.f;
                    }
                    ballOut->color.rgb = 1.f;
                    ballOut->arcID = -1;
                    ballOut->arcStr = 0;
                    return;
                }
                // Collision
                float2 axis = normalize(vec);
                float e1 = dot(axis, ballIn->delta);