File indexing completed on 2024-04-14 14:08:24
0001 /* 0002 * box2draycast.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 "box2draycast.h" 0027 0028 #include "box2dbody.h" 0029 #include "box2dfixture.h" 0030 #include "box2dworld.h" 0031 0032 Box2DRayCast::Box2DRayCast(QObject *parent) : 0033 QObject(parent), 0034 mMaxFraction(-1.0f) 0035 { 0036 } 0037 0038 float32 Box2DRayCast::ReportFixture(b2Fixture *fixture, 0039 const b2Vec2 &point, 0040 const b2Vec2 &normal, 0041 float32 fraction) 0042 { 0043 mMaxFraction = -1.0f; 0044 0045 Box2DFixture *box2dFixture = toBox2DFixture(fixture); 0046 Box2DWorld *world = box2dFixture->getBody()->world(); 0047 0048 emit fixtureReported(box2dFixture, 0049 world->toPixels(point), 0050 world->toPixels(normal), 0051 fraction); 0052 0053 return mMaxFraction; 0054 }