Single entity JointLimit?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
ecosky
Posts: 69
Joined: Fri Nov 04, 2011 7:13 am
Contact:

Single entity JointLimit?

Post by ecosky »

Hi,

I have a situation where a flying character is moving around under the influence of a linear motor and an angular motor. Sometimes, when the goal direction changes dramatically, the character will flip over as it orients to the goal. I'd like the NPC to not do this, and I am still trying to figure out the best approach within Bepu. Some tilt from the up axis is good, but too much and the character movement looks broken. I think that I'd probably like use some kind of single entity constraint similar to the angular motor, except instead of a specific orientation it would be constraining to a maximum angle from some axis. Is there already something like this in Bepu that I have overlooked? If not, would modifying the existing AngularMotor seem like a good place to start implementing this myself?

Thanks for any suggestions,
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Single entity JointLimit?

Post by Norbo »

Is there already something like this in Bepu that I have overlooked? If not, would modifying the existing AngularMotor seem like a good place to start implementing this myself?
You may be able to resort to some two body angular constraint (with one of the connections being null), but there aren't any other single entity constraints which would fit. I would not recommend modifying a constraint; changing the nature of the constraint would require a rederivation of the jacobians.

Angular control in simple structures (a single entity in isolation being the simplest of structures) can usually be handled by modifying angular velocities directly without having to worry about needing the extra stability granted by proper constraints. I would recommend prototyping the desired angular control using simple velocity modifications.

Once the prototype behaving as you desire, you can see if it needs to be constraintified (very unlikely). Having the behavior prototype available will make choosing the constraint structure easier if necessary.
ecosky
Posts: 69
Joined: Fri Nov 04, 2011 7:13 am
Contact:

Re: Single entity JointLimit?

Post by ecosky »

Thanks Norbo. I'll start with manipulating the angular velocities. I expect it will do the trick. It would be nice if there were a constraint or motor suited for this problem but I don't mind a manual solution. Whatever works!

Incidentally, I had been peeking around in various constraint classes looking for any that supported a null connection hoping they would behave as a single entity constrained to the world space as you inferred, but I didn't see any that did that. I didn't look at all of them though; is this something you support in newer code? (My branch is a bit old & selectively updated at this point) If not, did you mean to imply I should look into making the right class support a null connection if it turns out to be necessary to use constraints to get a stable solution to my problem?

Thanks again,
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Single entity JointLimit?

Post by Norbo »

Incidentally, I had been peeking around in various constraint classes looking for any that supported a null connection hoping they would behave as a single entity constrained to the world space as you inferred, but I didn't see any that did that. I didn't look at all of them though; is this something you support in newer code?
All TwoEntityConstraints support it. The ConnectionA and ConnectionB properties explicitly check for null and use a special kinematic 'WorldEntity' if needed. I believe it's been there for a long time (possibly as far back as v0.11.0), so even moderately old versions should have it.
ecosky
Posts: 69
Joined: Fri Nov 04, 2011 7:13 am
Contact:

Re: Single entity JointLimit?

Post by ecosky »

Oh shoot, you are right of course. I was looking for/expecting logic along the lines of "if(connectionA == null)" to be scattered everywhere and I never noticed that logic in the property setters which of course makes perfect sense. Thanks for pointing that out.
BTW adjusting the angular velocities when the entity was oriented outside the desired tilt/roll range solved the problem adequately. It's a bit soft on the correction but it works well enough.
Thanks again!
Post Reply