ampersand38 / ride-where-you-look

Select vehicle seat in Arma 3
Other
3 stars 2 forks source link

Possible reduction of intersections #6

Closed kuloodporny closed 3 years ago

kuloodporny commented 4 years ago

I think that the mod doesn't need to do intersections. I achieved similar results by getting nearby vehicles using following code:

private _vehicles = player nearEntities ["AllVehicles", 5];
{_vehicles pushBackUnique _x} forEach [vehicle player, cursorObject];

I skip vehicles that are further away than their bounding sphere, but not less than 3 meters away, and then do the simple distance check to individual seats before I process them further.

Note that detecting near entities will make it easier to interact with small or thin objects as player won't need to aim precisely at the object.

ampersand38 commented 4 years ago

I figured one intersect per key press would not be a big deal. It was conceptually simpler than trying to qualify bounding boxes with long, narrow vehicles like Huron, where touching ramp distance is over 7 m, and same distance off the side would look goofy. I'll keep thinking about alternatives to intersect, and also implement nearEntities, which should reduce the number cases where iintersect is used. https://github.com/ampersand38/ride-where-you-look/commit/8caac1eeba2e7e32f8d1770ee4a3b6d9c4241828