VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
void AVR.Phys.AVR_Hand.AVR_Finger.SqueezeOn ( Transform  handVisualTransform,
List< Collider >  colls 
)
inline

Definition at line 282 of file AVR_Hand.cs.

283  {
284  if(colls.Count<1) return;
285  if(colls.Count==1) this.SqueezeOn(handVisualTransform, colls[0]);
286 
287  int i;
288  for (i = 0; i < this.positions.Count; i++)
289  {
290  Vector3 pos = handVisualTransform.TransformPoint(this.positions[i]);
291  if (ColliderContains(colls[0], pos)) break;
292  }
293 
294  if(i>=positions.Count) i--; // Fix: i could be = posiitons.count leading to an out-of-array in the next step.
295 
296  // For each of the other colliders (beyond the first one) un-squeeze the finger until it is no longer inside
297  for(int j=1; j<colls.Count; j++) {
298  while(i>0 && ColliderContains(colls[j], handVisualTransform.TransformPoint(this.positions[i]))) i--;
299  }
300 
301  float offset = Mathf.Clamp((float)(i) / (float)this.positions.Count, 0.0f, 1.0f);
302  this.setState(offset);
303  this.setWeight(1.0f);
304  }
List< Vector3 > positions
Definition: AVR_Hand.cs:198
static bool ColliderContains(Collider c, Vector3 pos)
Definition: AVR_Hand.cs:308