Skip to content

Instantly share code, notes, and snippets.

@sixman9
Last active December 11, 2015 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sixman9/4539053 to your computer and use it in GitHub Desktop.
Save sixman9/4539053 to your computer and use it in GitHub Desktop.
Pre-February 2013 Marmalade Quick Box2d physics CPP "patch"
//See https://devnet.madewithmarmalade.com/questions/3701/kinematic-bodies-in-marmalade-quick.html
//Basically in QPhysics.cpp, the NodeProps::sync() function needs to be as follows:
if (!m_Body)
return;
// Box2D stuff
if (m_IsSensor == false) // sensor object transforms aren't dictated by the simulation
{
// Body dictates transform
const b2Transform t = m_Body->GetTransform();
m_Node->x = g_Sim->scaleP2D(t.p.x);
m_Node->y = g_Sim->scaleP2D(t.p.y);
m_Node->rotation = g_Sim->angleP2D(t.q.GetAngle());
}
else
{
// Node x/y should be copied to Box2D body
b2Vec2 pos(g_Sim->scaleD2P(m_Node->x), g_Sim->scaleD2P(m_Node->y));
float angle = g_Sim->angleD2P(m_Node->rotation);
m_Body->SetTransform(pos, angle);
}
//Note that we've renamed a few things since the Beta drop, so I believe "g_Sim" should be g_QPhysics" or something. You'll figure it out. :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment