Exemplo n.º 1
0
        void OnRbTouchStart(Collision collision, BoneModel bone)
        {
            ContactableView contactable = collision.rigidbody.GetComponent <ContactableView>();

            if (contactable)
            {
                Contact contact = model.contacts.Find(c => c.contactable == contactable);

                BoneCollisionModel boneCollision;

                if (contact != null)
                {
                    // Existing contact

                    boneCollision = contact.bonesTouching.Find(bc => bc.bone == bone);

                    if (boneCollision == null)
                    {
                        boneCollision = new BoneCollisionModel(bone);
                        collision.GetContacts(boneCollision.points);
                        contact.bonesTouching.Add(boneCollision);
                    }
                }
                else
                {
                    // New valid contact
                    contact      = AddContact(contactable);
                    contact.type = ContactType.None;

                    boneCollision = new BoneCollisionModel(bone);
                    collision.GetContacts(boneCollision.points);
                    contact.bonesTouching.Add(boneCollision);
                }
            }
        }
Exemplo n.º 2
0
        void OnRbTouchStay(Collision collision, BoneModel bone)
        {
            stayedContact = model.contacts.Find(c => c.contactable.pheasy.rb == collision.rigidbody);

            if (stayedContact == null || stayedContact.contactable == null)
            {
                return;
            }

            stayedContactable = stayedContact.contactable;

            if (stayedContactable)
            {
                Contact contact = model.contacts.Find(c => c.contactable == stayedContactable);

                if (contact != null)
                {
                    BoneCollisionModel boneCollision = contact.bonesTouching.Find(bc => bc.bone == bone);

                    if (boneCollision != null)
                    {
                        collision.GetContacts(boneCollision.points);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void OnDrawGizmosSelected()
        {
            if (model.drawCollidedBones)
            {
                for (int c = 0; c < model.contacts.Count; c++)
                {
                    for (int bc = 0; bc < model.contacts[c].bonesTouching.Count; bc++)
                    {
                        BoneCollisionModel boneCollision = model.contacts[c].bonesTouching[bc];

                        Gizmos.color = Color.yellow;
                        Gizmos.DrawSphere(boneCollision.bone.reprs[PuppetModel.key].transformRef.position, 0.01f);
                    }
                }
            }
        }
Exemplo n.º 4
0
        void OnRbTouchEnd(Collision collision, BoneModel bone)
        {
            ContactableView contactable = collision.rigidbody.GetComponent <ContactableView>();

            if (contactable)
            {
                Contact contact = model.contacts.Find(c => c.contactable == contactable);

                if (contact != null)
                {
                    BoneCollisionModel boneCollision = contact.bonesTouching.Find(bc => bc.bone == bone);

                    if (boneCollision != null)
                    {
                        contact.bonesTouching.Remove(boneCollision);
                    }
                }
            }
        }
Exemplo n.º 5
0
 public BoneCollisionView(BoneCollisionModel boneCollision)
 {
     this.bone   = boneCollision.bone.view;
     this.points = boneCollision.points;
 }