private void _injectShape(ChVector pos, ChMatrix33 <double> rot, CollisionShape mshape) { bool centered = true;// (pos.IsNull() && rot.IsIdentity()); // FIX THIS !!! // This is needed so later one can access ChModelBullet::GetSafeMargin and ChModelBullet::GetEnvelope mshape.SetUserPointer(this); // start_vector = || -- description is still empty if (shapes.Count == 0) { if (centered) { shapes.Add(mshape); bt_collision_object.SetCollisionShape(mshape); // end_vector= | centered shape | return; } else { CompoundShape mcompound = new CompoundShape(); shapes.Add(mcompound); shapes.Add(mshape); bt_collision_object.SetCollisionShape(mcompound); IndexedMatrix mtransform = new IndexedMatrix(); ChPosMatrToBullet(pos, rot, ref mtransform); mcompound.AddChildShape(ref mtransform, mshape); // vector= | compound | not centered shape | return; } } // start_vector = | centered shape | ----just a single centered shape was added if (shapes.Count == 1) { IndexedMatrix mtransform = new IndexedMatrix(); shapes.Add(shapes[0]); shapes.Add(mshape); CompoundShape mcompound = new CompoundShape(true); shapes[0] = mcompound; bt_collision_object.SetCollisionShape(mcompound); //mtransform.setIdentity(); mcompound.AddChildShape(ref mtransform, shapes[1]); ChPosMatrToBullet(pos, rot, ref mtransform); mcompound.AddChildShape(ref mtransform, shapes[2]); // vector= | compound | old centered shape | new shape | ... return; } // vector= | compound | old | old.. | ----already working with compounds.. if (shapes.Count > 1) { IndexedMatrix mtransform = new IndexedMatrix(); shapes.Add(mshape); ChPosMatrToBullet(pos, rot, ref mtransform); CollisionShape mcom = shapes[0]; ((CompoundShape)mcom).AddChildShape(ref mtransform, mshape); // vector= | compound | old | old.. | new shape | ... return; } }