LeeMcQueen / GameDemo

Demo
0 stars 0 forks source link

onlyBallCollisionResponse #30

Closed LeeMcQueen closed 3 years ago

LeeMcQueen commented 3 years ago

void onlyBallCollisionResPonse(Ball *ball){

for(int i = 0; i < nodes.size(); i++){

    Vec3 distVec = getWorldPos(nodes[i]) - ball -> center;
    double disLen = distVec.length();
    double safeDist = ball -> radius * 1.05;

    if(distLen < safeDist){

        distVec.normalize();
        setWorldPos(nodes[i], distVec * safeDist + ball -> center);
        nodes[i] -> velocity = node[i] -> velocity * ball -> friction;
    }
}

}