In the box2d alchemy port how do I manually test two shapes or fixtures to see if they overlap, I can't find the relevant functions in either class.
Alchemy Port test two shapes?
FlashAre you talking about simply detecting contacts? See the "Contact Events" section on this page:
http://github.com/jesses/wck/wiki/box2d ... chemy-port
Or are you referring to some feature that's in the native port but it missing from the Alchemy port?
http://github.com/jesses/wck/wiki/box2d ... chemy-port
Or are you referring to some feature that's in the native port but it missing from the Alchemy port?
I don't know if its in the native version since I have never used box2d in c++ (only C# and AS3) but I want to be able to test for overlap between fixtures in different collision groups. In some ports the world has a function to query a fixture and the fixtures have a function to test against another fixture.
By native I meant native AS3. It must not be part of the original C++ code or I would've seen it. If you can copy / paste the function here or point me to where it exists I can consider it for inclusion in the alchemy port.
This is from a fairly old version, its handy but if theirs already a better way to make box2d report collisions but ignore them on the physics side don't bother. I suppose I could try creating a sensor over every shape.
Code:
/*
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
public function QueryShape(callback:Function, shape:b2Shape, transform:b2Transform = null):void
{
if (transform == null)
{
transform = new b2Transform();
transform.SetIdentity();
}
var broadPhase:IBroadPhase = m_contactManager.m_broadPhase;
function WorldQueryWrapper(proxy:*):Boolean
{
var fixture:b2Fixture = broadPhase.GetUserData(proxy) as b2Fixture
if(b2Shape.TestOverlap(shape, transform, fixture.GetShape(), fixture.GetBody().GetTransform()))
return callback(fixture);
return true;
}
var aabb:b2AABB = new b2AABB();
shape.ComputeAABB(aabb, transform);
broadPhase.Query(WorldQueryWrapper, aabb);
}
public function QueryAABB(callback:Function, aabb:b2AABB):void
{
var broadPhase:IBroadPhase = m_contactManager.m_broadPhase;
function WorldQueryWrapper(proxy:*):Boolean
{
return callback(broadPhase.GetUserData(proxy));
}
broadPhase.Query(WorldQueryWrapper, aabb);
}
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
public function QueryShape(callback:Function, shape:b2Shape, transform:b2Transform = null):void
{
if (transform == null)
{
transform = new b2Transform();
transform.SetIdentity();
}
var broadPhase:IBroadPhase = m_contactManager.m_broadPhase;
function WorldQueryWrapper(proxy:*):Boolean
{
var fixture:b2Fixture = broadPhase.GetUserData(proxy) as b2Fixture
if(b2Shape.TestOverlap(shape, transform, fixture.GetShape(), fixture.GetBody().GetTransform()))
return callback(fixture);
return true;
}
var aabb:b2AABB = new b2AABB();
shape.ComputeAABB(aabb, transform);
broadPhase.Query(WorldQueryWrapper, aabb);
}
public function QueryAABB(callback:Function, aabb:b2AABB):void
{
var broadPhase:IBroadPhase = m_contactManager.m_broadPhase;
function WorldQueryWrapper(proxy:*):Boolean
{
return callback(broadPhase.GetUserData(proxy));
}
broadPhase.Query(WorldQueryWrapper, aabb);
}
Original thread: https://box2d.org/forum/viewtopic.php?t=5798