예제 #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);
                }
            }
        }
예제 #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);
                    }
                }
            }
        }
예제 #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);
                    }
                }
            }
        }
예제 #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);
                    }
                }
            }
        }
예제 #5
0
 public BoneCollisionView(BoneCollisionModel boneCollision)
 {
     this.bone   = boneCollision.bone.view;
     this.points = boneCollision.points;
 }