Performance question

Pyritie

16-02-2010 11:25:31

Alrighty so first off I'm using MogreNewt but I figure I should post in here since it's not a language-specific question I have.
Basically my game uses uses this physics engine but I'm using it for 2D-style physics. So I've used the Custon2DJoint or whatever to keep all of the bodies on one plane. However this also stops them from rotating along all three axes, which I don't want. What I've done instead is have a plane-aligned "invisible" (i.e. no entity) body attached to another body (and its corresponding SceneNode has the model entity attached) using a UniversalJoint.

Here is my question:
Which is more efficient?
- Do what I'm doing at the moment
- Have two invisible planes directly "in front of" and "behind" the bodies so they don't move much on that axis
- Write my own CustomJoint (looks pretty daunting D: )
- Something else?

PJani

18-02-2010 17:17:19

writing your own joint?

Pyritie

18-02-2010 20:39:34

That looks really intense though :0

Have you ever written your own?

PJani

19-02-2010 13:15:37

Yes i did. The new interface for joints in Newton 2.xx is much better.

Right now I aa writing joint for car differential. :D

Pyritie

19-02-2010 21:58:36

oh :0

Where'd you learn how to make them?

PJani

20-02-2010 21:36:49

hmm, good start would be to see code for allready created joints. You have few functions with which you control which axes are locked and other stuff.

Pyritie

27-02-2010 03:27:17

I have no idea what I'm doing <___>


What the hell is a linear/angular row?

PJani

27-02-2010 09:53:22

linear row is that one which does lock movement in some direction.

angular row is lock in rotation.

kallaspriit

27-02-2010 09:57:26

Check out some of the articles in NGD wiki:

http://www.newtondynamics.com/wiki/inde ... tle=Joints
http://www.newtondynamics.com/wiki/inde ... ing_Joints

In a nutshell, a linear row tries to move together two points of two bodies along given pin direction and angular row attempts to rotate a body to given angle.

Pyritie

27-02-2010 19:59:50

uhh... still not sure I get it.

What I basically want to do is prevent any movement along the Y axis. I'm using "null" as my second "body" since it's not attached to anything

Pyritie

02-03-2010 22:05:40

Okay I think I got it now :D

Although it's a bit jittery and sometimes if I push a lot against a wall then I end up moving into another part of the wall a short distance from it >___>

public override void SubmitConstraint(float timeStep, int threadIndex) {
Vector3 globalPos;
Quaternion globalOrient;
// get the global position and orientation
// Not sure if we need the orientation but we need the position at least
this.m_body0.GetPositionOrientation(out globalPos, out globalOrient);
// Set the Y of the new position to 0
// TODO: since we're only constraining it to Y, couldn't this just be 0?
newGlobalPos = globalPos;
newGlobalPos.y = 0f;
// I wonder if there's a way to do this without needing the two rows. Oh well.
// The first argument is the position we'd like to move, the second argument is where we'd like
// to move it to, and the third argument says which vector we want to move it along
addLinearRow(globalPos, newGlobalPos, Vector3.UNIT_Y);
}


Also while I was at it I cleaned up CustomJoint2D a lot. Is there any way I could submit the cleaned up version to mogrenewt?

EDIT: fixed it up a bit