interested in XWeld

quick question about C++ to as3 conversion.


private function SolveVelocityContraints(step:b2TimeStep):void
{
B2_NOT_USED(step);
...



not sure how B2_NOT_USED translates...


*edit

also there is an assert function
// Assert that angle is still the same so the effective joint mass is still valid
assert(b1->m_sweep.a == m_a1);

would this be the same as telling it to skip this function if the condition is not met?
if( not condition ) return;
Cut out b2_not_used, it's a macro to avoid compiler warnings.
Translate assert to b2Settings.Assert();
asserts are zero overhead if the compiler flag is off in C++. This is emulated by commenting them out. So it's important you use the same statement, so find and replace works!
example: but the question effects quite a few parts of the port.

in C++ version
Quote:
m_dp = b2MulT(b1->GetXForm().R, b2->GetXForm().position - b1->GetXForm().position);


what i come up with in Flash
Quote:
m_dp = b2Math.b2MulTMV(GetBody1().GetXForm().R, GetBody2().GetXForm().position.Subtract(GetBody1().GetXForm().position));


the return type of the Subtract method is null.
so if i were to use Subtract, i would have to subtract before calling this function, then send the function the modified variable.

also, performing Subtract effects the variable... I could use Copy if I was sure that they didn't want it to effect it...




also

c++
Quote:
if (b2Abs(b1->m_sweep.a - m_a1) > 1e-3f)


flash
Quote:
if (b2Abs(GetBody1().GetAngle() - m_a1) > 1e-3){


what is 1e?
and is 3f meant to be a number, like i see 0.0f other times?



also, I've been writing this as if it were external code. (replacing internal parameter references with Get/Set methods...) is that bad? it just occurred to me that this class is internal.
Use b2Math.SubtractVV, not b2Vec.Subtract. The latter is for better performance, but it's harder to use. Pointless if you are going to have to copy anyway.

The f suffix in C++ just means float. 5f == 5.0 in AS3. I.e. just skip it.
The e is scientific notation, it works in AS3 as well. So just copy verbatim. For the record: 5e-3 == 5 x 10^-3.

Internal or not is your choice. The performance is slightly worse, I'm guessing, for external code. But it'll help prevent code rot a bit, if you don't maintain the code.

Original thread: https://box2d.org/forum/viewtopic.php?t=3560