Well, it turns out that secretly ATTR_cockpit was two attributes jammed into one:
- Panel texture - that is, changing the texture from the object texture to the panel texture.
- Panel clickability - that is, mouse clicks are sent to the 2-d panel and act on those instruments.
So how does ATTR_cockpit work in this context? Basically you can think of ATTR_cockpit as two "hidden" attributes:
ATTR_texture_panel
ATTR_manip_panel
and similarly, ATTR_no_cockpit is like
ATTR_texture_object
ATTR_manip_none
With this you can actually get any number of combinations of attributes, but the code is sometimes unexpected. In particular: if you want a manipulator other than the panel or none, you have to specify it again. Example:
# set command manip
ATTR_manip_command hand sim/operation/pause Pause
TRIS 0 3
ATTR_cockpit
# we now have to reset the cmd manipulator!
ATTR_manip_command hand sim/operation/pause Pause
TRIS 3 3
ATTR_no_cockpit
# we have to reset the cmd manipulator again!
ATTR_manip_command hand sim/operation/pause Pause
TRIS 6 3
Similarly, if you want the panel manipulator, you may have to reset the cockpit!
ATTR_cockpit
TRIS 0 3
# now make the mesh not clickable
ATTR_manip_none
TRIS 3 3
# Mesh clickable again
ATTR_cockpit
TRIS 6 3
The good news is: this isn't nearly as wasteful as it seems. X-Plane's object attribute optimizer is smart enough that it will remove the unnecessary attributes in both cases. In the first one, what you end up with is one manipulator change (to the command manipulator), and the panel texture change is done without changing manipulator state at all. In the second case, you end up with the manipulator change, but the panel texture is kept loaded the whole time.
In other words, even though the double-attributes or duplicate attrbibutes might seem to be inefficient, the optimizer will fix them for you.
One reason you might care: the cost of panel texture is one-time - that is, you pay for the size of the panel texture once per frame. But the cost of manipulatable triangles is per-triangle! So having more is bad. With ATTR_manip_none, you can use the panel texture but not have it be clickable, which can be a big performance win.
930 will handle manipulatable triangles a lot faster than 920 -- but that's still not a good reason to have all of your triangles be clickable!
This article is still unfinished, but I am trying to put together some info on how to detect performance problems like too many clickable triangles.
No comments:
Post a Comment