Skyrim

Cobb Positioner uses a custom SKSE plug-in to let players select objects more accurately than in any other Skyrim mod. In this article, I'll be going over the technical details of how exactly that works.

Typically, Skyrim mods are only able to find the nearest object to a given position... using a blind origin check that doesn't take objects' sizes and offsets into account. However, when one has access to the game's code and to all loaded data for a given form, one can implement something a little more precise. See, most objects in Skyrim have OBND data; this is a precomputed oriented bounding box, and it allows us to construct a rather interesting heuristic. (An oriented bounding box, or OBB, is just the smallest box that can fully contain a shape.)

You select references by casting a spell. We take the hit position of the spell and check that against the OBBs of every reference in the containing cell (or loaded outdoor area). References can have OBBs that overlap, but most of the time, the smallest OBB that contains your hit position will belong to the reference you were trying to select. (Say you have a bottle of wine on the ground right next to a statue of Nocturnal, inches away from its feet. When you try to select the bottle, both of those objects' OBBs will contain your hit position, but one will be massive and the other rather small, see?)

We determine whether an OBB contains the hit position by using some rotation math and the separating axis theorem. OBND data is actually a little inaccurate, but we compensate for that by inflating every OBB we find by a given "tolerance" value. And thus, we have the most accurate selection method in Skyrim, short of reverse-engineering Havok from the ground up and building a raycast API.

There are two main caveats to this approach. The first is that not every object has OBND data. Even many vanilla objects, such as the massive statues in Sovngarde, lack the data. The second problem is that we're unable to select some objects because we're more precise. For example, there are wicker wall baskets hanging on the walls in Whiterun's Hall of the Dead. It's impossible to select these because they're actually placed inside the collision mesh for the walls: the selection spell will always stop short of those particular baskets, and the hit position will never lie inside of any of them.

Fortunately, you can grab these objects using Skyrim's command-line debugger, and then use Cobb Positioner's MCM to pick them up from there. That workaround works in both of these cases (because the debugger relies on graphics, not physics, to pick objects).

Article information

Added on

Edited on

Written by

DavidJCobb