+ struct rsim_spring *spr = rope->springs;
+
+ /* accumulate forces from springs */
+ for(i=0; i<rope->num_springs; i++) {
+ dir = spr->mass[1]->p;
+ cgm_vsub(&dir, &spr->mass[0]->p);
+
+ len = cgm_vlength(&dir);
+ if(len != 0.0f) {
+ float s = 1.0f / len;
+ dir.x *= s;
+ dir.y *= s;
+ dir.z *= s;
+ }
+ fmag = (len - spr->rest_len) * spr->k;
+
+ spr->mass[0]->f.x += dir.x * fmag / spr->mass[0]->m;
+ spr->mass[0]->f.y += dir.y * fmag / spr->mass[0]->m;
+ spr->mass[0]->f.z += dir.z * fmag / spr->mass[0]->m;
+
+ spr->mass[1]->f.x -= dir.x * fmag / spr->mass[1]->m;
+ spr->mass[1]->f.y -= dir.y * fmag / spr->mass[1]->m;
+ spr->mass[1]->f.z -= dir.z * fmag / spr->mass[1]->m;