Wednesday, March 25, 2015

A word about avatar Z offset

Hi !

Lately Linden Lab has been working at adding a new feature to the official SL viewer : "Avatar Hover Z Offset". Or Z-offset as I find more convenient to call it.

You may be thinking "hold on, this has been in the third party viewers for ages !" and you'd be right... and wrong at the same time. Let me explain.

A few years ago, I spotted a feature that was called "avatar Z offset" in the Phoenix viewer and thought "now that is a good idea", and included it in the RLV as an enhancement, under the form of a simple slider in the navigation bar. The idea was to be able to adjust the altitude of the avatar so we'd stop hovering above the floor or sinking into it when being animated (either by attachments or by objects in-world). It was called an offset but internally, what that slider was doing was increasing the height of the bounding box of the avatar from its center. As a result, visually, when you increased the height by X, your avatar seemed to move up by X/2. It was a height increase, but in the user's point of view, it was an offset, hence the name.

It didn't take long for Henri Beauchamp to want to include that kind of feature into the RLV API so that scripts could change the offset (well height, but I'll call it offset from now on, please pardon the technical shorthand) automatically. It was very handy. The RLV command "@adjustheight" was born.

Problem is, the Z offset was nothing more than a hack, a side-effect of the rendering, initially a debug feature. LL certainly regarded it that way.

So when Linden Lab came up with the Server Side Appearance feature, the avatar Z offset one was broken completely. The old way to handle the Z offset was not compatible with the new way the avatar appearance was calculated (server-side as opposed to viewer-side in the past), and there was nothing we could do. Nyx Linden, in his free time, implemented a feature that was looking like what we had before, but in less practical : the Hover value in the avatar shape. Thank you again for that, Nyx.

This was not ideal, but it saved the feature, more or less. Henri Beauchamp came up with a way to link the @adjustheight RLV command to the new Hover slider, on the condition that the shape be modifiable, of course, and with some bizarre calculations (due to a bug that was applying the offset twice), we had something that was working more or less well. He spent a lot of time on it, and I spent a lot of time to adapt it to my RLV as well, optimizing it and trying to make it as painless as possible. It was almost as usable as the old "avatar Z offset". Thank you again for that too, Henri.

Henri never stopped nagging LL to include a proper way of modifying the altitude of the avatar, the Z offset, instead of having to rely on some weird hacks that were working 75% of the time (the sim frequently complained about not being able to solve the appearance request, when alpha layers were included in the process).

Today it paid off and LL decided to bring a solution to this, in the form of a slider ! It is even included in the official SL viewer. Thank you for that, Linden Lab !

Only... other users will see your avatar move up and down only if they are using a viewer that is compatible with this new slider. What the slider does is send a new network message to the sim saying "Hey, retain that my avatar now has an offset of X !" and the sim will notify all the other agents around that "Hey, that avatar now has an offset of X !". But if one of these bystanders uses a viewer that does not understand that new message, then nothing will happen on their side and we will not have a "shared experience" the way LL wants. This is to be expected and that user should update their viewer, and probably will eventually, but there is got to be some time when someone changes their Z offset and a friend of theirs says "well it didn't work, you are still sunk into the floor". To which the inevitable response will be "well you should update your viewer then". Or the more common alternative response known as "well it must be an SL bug".

Now why am I telling you all this ?

I have included the new Z offset into my RLV this morning, and it works well... but only if the other users around are on a viewer that can handle that new network message. For the time being, this means the official viewer, or the RLV that I have not released yet (but will in a short time, maybe today or tomorrow).

This is why I will soon release a RLV with this new feature, but not linked to @adjustheight yet. Don't get me wrong, I can't wait to link it to the RLV command ! But it is still too early. The tipping point will be when enough users will have downloaded a viewer that handles the new Z offset, and that necessarily comes through Firestorm including it into their code. As I don't work on Firestorm, I can't guarantee when this will happen, if ever.

But when that tipping point is crossed, or shortly before, I will link @adjustheight to the new Z offset and we will have a perfectly working avatar Z offset feature again, like in the good old days !

Have fun !

PS : I initially thought I had the idea to create a RLV command for the avatar Z offset, but I forgot that it was Henri who got the idea, not me. Sorry Henri, fixed now !