Beispiel #1
0
 public void AddCapsuleCollider(ref MPGPCapsuleColliderData v)
 {
     if (enabled)
     {
         m_capsule_colliders.Add(v);
     }
 }
    static public void BuildCapsuleCollider(ref MPGPCapsuleColliderData cscol, Transform t, ref Vector3 center, float radius, float length, int dir, int id)
    {
        Vector3 e = Vector3.zero;
        float   h = Mathf.Max(0.0f, length - radius * 2.0f);
        float   r = radius * t.localScale.x;

        switch (dir)
        {
        case 0: e.Set(h * 0.5f, 0.0f, 0.0f); break;

        case 1: e.Set(0.0f, h * 0.5f, 0.0f); break;

        case 2: e.Set(0.0f, 0.0f, h * 0.5f); break;
        }
        Vector4 pos1 = new Vector4(e.x + center.x, e.y + center.y, e.z + center.z, 1.0f);
        Vector4 pos2 = new Vector4(-e.x + center.x, -e.y + center.y, -e.z + center.z, 1.0f);

        pos1 = t.localToWorldMatrix * pos1;
        pos2 = t.localToWorldMatrix * pos2;
        cscol.shape.radius      = r;
        cscol.shape.pos1        = pos1;
        cscol.shape.pos2        = pos2;
        cscol.info.aabb.center  = t.position;
        cscol.info.aabb.extents = Vector3.one * (r + h);
        cscol.info.owner_objid  = id;
    }
Beispiel #3
0
 public void AddCapsuleCollider(ref MPGPCapsuleColliderData v) { if (enabled) m_capsule_colliders.Add(v); }