File indexing completed on 2024-04-14 14:08:22

0001 /*
0002  * box2dcontact.cpp
0003  * Copyright (c) 2014 Moukhlynin Ruslan <ruslan@khvmntk.ru>
0004  *
0005  * This file is part of the Box2D QML plugin.
0006  *
0007  * This software is provided 'as-is', without any express or implied warranty.
0008  * In no event will the authors be held liable for any damages arising from
0009  * the use of this software.
0010  *
0011  * Permission is granted to anyone to use this software for any purpose,
0012  * including commercial applications, and to alter it and redistribute it
0013  * freely, subject to the following restrictions:
0014  *
0015  * 1. The origin of this software must not be misrepresented; you must not
0016  *    claim that you wrote the original software. If you use this software in
0017  *    a product, an acknowledgment in the product documentation would be
0018  *    appreciated but is not required.
0019  *
0020  * 2. Altered source versions must be plainly marked as such, and must not be
0021  *    misrepresented as being the original software.
0022  *
0023  * 3. This notice may not be removed or altered from any source distribution.
0024  */
0025 
0026 #include "box2dcontact.h"
0027 
0028 #include "box2dworld.h"
0029 #include "box2dfixture.h"
0030 
0031 
0032 Box2DContact::Box2DContact(b2Contact *contact) :
0033     mContact(contact)
0034 {
0035 }
0036 
0037 void Box2DContact::setContact(b2Contact *contact)
0038 {
0039     mContact = contact;
0040 }
0041 
0042 bool Box2DContact::isTouching()
0043 {
0044     return mContact->IsTouching();
0045 }
0046 
0047 bool Box2DContact::isEnabled() const
0048 {
0049     return mContact->IsEnabled();
0050 }
0051 
0052 void Box2DContact::setEnabled(bool enabled)
0053 {
0054     mContact->SetEnabled(enabled);
0055 }
0056 
0057 Box2DFixture *Box2DContact::fixtureA() const
0058 {
0059     b2Fixture *fixture = mContact->GetFixtureA();
0060     if(fixture)
0061         return toBox2DFixture(fixture);
0062     return NULL;
0063 }
0064 
0065 Box2DFixture *Box2DContact::fixtureB() const
0066 {
0067     b2Fixture *fixture = mContact->GetFixtureB();
0068     if(fixture)
0069         return toBox2DFixture(fixture);
0070     return NULL;
0071 }
0072 
0073 int Box2DContact::childIndexA() const
0074 {
0075     return mContact->GetChildIndexA();
0076 }
0077 
0078 int Box2DContact::childIndexB() const
0079 {
0080     return mContact->GetChildIndexB();
0081 }
0082 
0083 qreal Box2DContact::getFriction() const
0084 {
0085     return mContact->GetFriction();
0086 }
0087 
0088 void Box2DContact::setFriction(qreal friction)
0089 {
0090     mContact->SetFriction(friction);
0091 }
0092 
0093 void Box2DContact::resetFriction()
0094 {
0095     mContact->ResetFriction();
0096 }
0097 
0098 qreal Box2DContact::getRestitution() const
0099 {
0100     return mContact->GetRestitution();
0101 }
0102 
0103 void Box2DContact::setRestitution(qreal restitution)
0104 {
0105     mContact->SetRestitution(restitution);
0106 }
0107 
0108 void Box2DContact::resetRestitution()
0109 {
0110     mContact->ResetRestitution();
0111 }
0112 
0113 qreal Box2DContact::getTangentSpeed() const
0114 {
0115     return mContact->GetTangentSpeed();
0116 }
0117 
0118 void Box2DContact::setTangentSpeed(qreal speed)
0119 {
0120     mContact->SetTangentSpeed(speed);
0121 }