- // Get the point of ground contact
- float pos[3], cmpr[3];
- g->getPosition(pos);
- g->getCompression(cmpr);
- Math::mul3(g->getCompressFraction(), cmpr, cmpr);
- Math::add3(cmpr, pos, pos);
-
- // The plane transformed to local coordinates.
- double global_ground[4];
- g->getGlobalGround(global_ground);
- float ground[4];
- s->planeGlobalToLocal(global_ground, ground);
- float dist = ground[3] - Math::dot3(pos, ground);
-
- // Find the lowest one
- if(dist < min)
- min = dist;
+ if (!g->getSubmergable())
+ {
+ // Get the point of ground contact
+ float pos[3], cmpr[3];
+ g->getPosition(pos);
+ g->getCompression(cmpr);
+ Math::mul3(g->getCompressFraction(), cmpr, cmpr);
+ Math::add3(cmpr, pos, pos);
+
+ // The plane transformed to local coordinates.
+ double global_ground[4];
+ g->getGlobalGround(global_ground);
+ float ground[4];
+ s->planeGlobalToLocal(global_ground, ground);
+ float dist = ground[3] - Math::dot3(pos, ground);
+
+ // Find the lowest one
+ if(dist < min)
+ min = dist;
+ }