godot-trackball-camera icon indicating copy to clipboard operation
godot-trackball-camera copied to clipboard

Feature request: Yaw and Pitch limits

Open alketii opened this issue 4 years ago • 7 comments

it could be nice if you want to rotate an object to prevent it from rotating all the way to bottom or top, also left-right.

alketii avatar Nov 03 '20 21:11 alketii

Hello ! It would be nice, yeah.

I started doing similar work for Octron Mania, it's in the master if you're in a hurry : https://github.com/Goutte/godot-trackball-camera/commit/dc35f21080ea73753f622c66c5aaafedc7144e6a

The idea is to keep maximum flexibility when defining movement constraints, and yet provide tools to set up 'preset' constraints, such as yaw and pitch as you suggested.

Any ideas and reviews are welcome, software only gets better when we're all over it together ;)

I'll be online today if you want to peer-hack this. :busts_in_silhouette:

Goutte avatar Nov 04 '20 10:11 Goutte

Even though I used Godot for years, I am new to 3D and its concepts. But why not, I will try my best.

alketii avatar Nov 04 '20 12:11 alketii

@alketii I've got some preliminary results ! It's jittery when we insist on the limit (it teleports back in the allowed area), I've got to smoothen things out, and separate yaw and pitch, but I'm going forward.

Goutte avatar Nov 04 '20 12:11 Goutte

If I add both a pitch_up_limit and a pitch_down_limit, which is for when the camera is up, looking downwards at the target ?

Could you help me find less ambiguous variable names ?

Goutte avatar Nov 04 '20 14:11 Goutte

Check out 2c5ea00818ccbb88035b3c52a1e856b8c904a643 !

It's only got pitch and, for something so basic, it took me all day, I'm a bit ashamed to admit. It needs more tweaking, but it's something.

I wanted to make a branch about this but I messed up. Oh well…

Goutte avatar Nov 04 '20 19:11 Goutte

I gave this a test and it works great! Thanks for you effort, much appreciated!

alketii avatar Nov 05 '20 12:11 alketii

In v9 the way we handle pitch limits substantially changed, to account for the mode without inertia.

There are two limitation methods : hard and soft.

Hard

Projects/Rotates the camera back into allowed space immediately.

Soft

Adds a growing (quadratic) inertia incentive to go back into allowed space.

Limitations

Pitch constraint axis is (parent's) Vector3.UP

A Pitch constraint is a cone starting at the origin, wrapped around an axis, where the camera may not go. We have two such cones, one up and one down.

We could make the pitch constraint axis configurable, but that would incur some more multiplications ; so I'm pondering on whether we truly need this at all.

Especially since the camera behaves relatively to its parent, and the parent may be itself rotated for about the same effect.

Yaw

Yaw constraint looks more like a half-moon melon slice.

Same rules and configuration woes apply. The implementation is still to do.

Goutte avatar May 10 '23 08:05 Goutte