Eliminate interact_menu fps drops due to high nearby object counts.

Instead of reanalizing every frame which actions points should be rendered based on distance, that job is now done only 5 times per second.
The rest of the frames the action points from the last frame are rerendered..
Close #434
This commit is contained in:
esteldunedain 2015-04-20 01:16:51 -03:00
parent f7d35d5593
commit f928f37e26
3 changed files with 21 additions and 2 deletions

View File

@ -49,4 +49,7 @@ GVAR(expandedTime) = diag_tickTime;
GVAR(iconCtrls) = [];
GVAR(iconCount) = 0;
GVAR(foundActions) = [];
GVAR(lastTimeSearchedActions) = -1000;
ADDON = true;

View File

@ -29,6 +29,7 @@ if (_menuType == 0) then {
};
GVAR(keyDownTime) = diag_tickTime;
GVAR(openedMenuType) = _menuType;
GVAR(lastTimeSearchedActions) = -1000;
GVAR(useCursorMenu) = (vehicle ACE_player != ACE_player) ||
visibleMap ||

View File

@ -24,6 +24,9 @@ _fnc_renderNearbyActions = {
_cameraPos = (positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL);
_cameraDir = ((positionCameraToWorld [0, 0, 1]) call EFUNC(common,positionToASL)) vectorDiff _cameraPos;
GVAR(foundActions) = [];
GVAR(lastTimeSearchedActions) = diag_tickTime;
_numInteractObjects = 0;
_nearestObjects = nearestObjects [ACE_player, ["All"], 13];
{
@ -46,6 +49,7 @@ _fnc_renderNearbyActions = {
_action = _x;
if ([_target, _action] call FUNC(renderBaseMenu)) then {
_numInteractions = _numInteractions + 1;
GVAR(foundActions) pushBack [_target, _action];
};
};
} forEach GVAR(objectActionList);
@ -57,6 +61,7 @@ _fnc_renderNearbyActions = {
// Try to render the menu
if ([_target, _action] call FUNC(renderBaseMenu)) then {
_numInteractions = _numInteractions + 1;
GVAR(foundActions) pushBack [_target, _action];
};
} forEach _classActions;
@ -71,7 +76,11 @@ _fnc_renderNearbyActions = {
} forEach _nearestObjects;
};
_fnc_renderLastFrameActions = {
{
_x call FUNC(renderBaseMenu);
} forEach GVAR(foundActions);
};
_fnc_renderSelfActions = {
_target = _this;
@ -109,7 +118,13 @@ _fnc_renderSelfActions = {
if (GVAR(openedMenuType) == 0) then {
if (vehicle ACE_player == ACE_player) then {
call _fnc_renderNearbyActions;
if (diag_tickTime > GVAR(lastTimeSearchedActions) + 0.20) then {
// Once every 0.2 secs, collect nearby objects active and visible action points and render them
call _fnc_renderNearbyActions;
} else {
// The rest of the frames just draw the same action points rendered the last frame
call _fnc_renderLastFrameActions;
};
} else {
(vehicle ACE_player) call _fnc_renderSelfActions;
};