Skip to content

Commit

Permalink
fps fix for tracers
Browse files Browse the repository at this point in the history
  • Loading branch information
James Kingsley committed Mar 15, 2016
1 parent daf22ea commit 7e55f91
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 100 deletions.
15 changes: 1 addition & 14 deletions ARCMF.VR/f/spect/fn_CamInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,9 @@ _this spawn {
f_cam_unitListShow = true;

// Colors
/*
f_cam_blufor_color = [0.278,0.278,0.82,1];
f_cam_opfor_color = [1,0.102,0.102,1];
f_cam_indep_color = [0,0.8,0.4,1];
f_cam_civ_color = [1,0.376,0.906,1];
f_cam_empty_color = [1,0.776,0,1];
*/
// f_cam_blufor_color = [BLUFOR] call BIS_fnc_sideColor;
f_cam_blufor_color = [0.2, 0.2, 1, 1];

// f_cam_opfor_color = [OPFOR] call BIS_fnc_sideColor;
f_cam_opfor_color = [1, 0.2, 0.2, 1];

// f_cam_indep_color = [independent] call BIS_fnc_sideColor;
f_cam_indep_color = [0, 0.702, 0.349, 1];

f_cam_civ_color = [civilian] call BIS_fnc_sideColor;
f_cam_empty_color = [sideUnknown] call BIS_fnc_sideColor;

Expand Down Expand Up @@ -240,4 +227,4 @@ _this spawn {
f_cam_updatevalues_script = [] spawn f_fnc_UpdateValues;
["f_spect_tags", "onEachFrame", {_this call f_fnc_DrawTags}] call BIS_fnc_addStackedEventHandler;
["f_spect_cams", "onEachFrame", {_this call f_fnc_FreeCam}] call BIS_fnc_addStackedEventHandler;
};
};
3 changes: 3 additions & 0 deletions ARCMF.VR/f/spect/fn_EventHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ switch (_type) do
ctrlShow [2110, true];
ctrlShow [2010, true];
ctrlShow [5534, true];
ctrlShow [2236, true];
ctrlShow [1350, false];
ctrlShow [1360, false];
};
Expand All @@ -287,13 +288,15 @@ switch (_type) do
ctrlShow [2010, true];
ctrlShow [1350, true];
ctrlShow [5534, true];
ctrlShow [2236, true];
ctrlShow [1360, false];
};
case 2: {
ctrlShow [2110, false];
ctrlShow [2010, false];
ctrlShow [1350, false];
ctrlShow [5534, false];
ctrlShow [2236, false];
ctrlShow [1360, true];

_displayDialog = (findDisplay 9228);
Expand Down
133 changes: 63 additions & 70 deletions ARCMF.VR/f/spect/fn_FreeCam.sqf
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
private ["_commitTime","_delta","_zLevel","_pos","_visPos","_mode","_currPos","_mX","_mY","_mZ","_accel","_accelshift","_scroll","_rX","_y","_z"];

f_cam_camera camSetFov f_cam_fovZoom;
if(f_cam_mode == 0) then
{
cameraEffectEnableHUD true;
_commitTime = ((1.0 - ((speed vehicle f_cam_curTarget)/65))/3) max 0.1;
_delta = (-(2*(0.3 max f_cam_zoom)));
_zLevel = sin(f_cam_angleY)*(2*(0.3 max f_cam_zoom));
//_pos = getpos f_cam_curTarget;
_visPos = visiblePositionASL f_cam_curTarget;
if(!(surfaceIsWater _visPos)) then {_visPos = ASLtoATL (_visPos)};
f_cam_fakecamera camSetPos [_visPos select 0,_visPos select 1,(_visPos select 2) + 1.5];
f_cam_fakecamera camCommit _commitTime;
f_cam_camera camSetRelPos[(sin(f_cam_angleX)*_delta)*cos(f_cam_angleY), (cos(f_cam_angleX)*_delta)*cos(f_cam_angleY), _zLevel];
f_cam_camera camCommit _commitTime;
if (f_cam_mode == 0) then {
cameraEffectEnableHUD true;
_commitTime = ((1.0 - ((speed vehicle f_cam_curTarget)/65))/3) max 0.1;
_delta = (-(2*(0.3 max f_cam_zoom)));
_zLevel = sin(f_cam_angleY)*(2*(0.3 max f_cam_zoom));
//_pos = getpos f_cam_curTarget;
_visPos = visiblePositionASL f_cam_curTarget;
if(!(surfaceIsWater _visPos)) then {_visPos = ASLtoATL (_visPos)};
f_cam_fakecamera camSetPos [_visPos select 0,_visPos select 1,(_visPos select 2) + 1.5];
f_cam_fakecamera camCommit _commitTime;
f_cam_camera camSetRelPos[(sin(f_cam_angleX)*_delta)*cos(f_cam_angleY), (cos(f_cam_angleX)*_delta)*cos(f_cam_angleY), _zLevel];
f_cam_camera camCommit _commitTime;
};

// first person
if(f_cam_mode == 1) then
{
// player setpos (getpos cameraOn);
if(vehicle cameraOn != cameraOn) then
{
if (f_cam_mode == 1) then {
// player setpos (getpos cameraOn);
if (vehicle cameraOn != cameraOn) then {
_mode = "internal";
if(gunner (vehicle cameraon) == cameraon) then {_mode = "gunner"};
if(driver (vehicle cameraon) == cameraon) then {_mode = "gunner"};
if(commander (vehicle cameraon) == cameraon) then {_mode = "gunner"};
if (gunner (vehicle cameraon) == cameraon) then {_mode = "gunner"};
if (driver (vehicle cameraon) == cameraon) then {_mode = "gunner"};
if (commander (vehicle cameraon) == cameraon) then {_mode = "gunner"};
vehicle cameraOn switchCamera _mode;
};
if(vehicle cameraOn == cameraOn && !f_cam_ads) then
{

if (vehicle cameraOn == cameraOn && !f_cam_ads) then {
cameraon switchCamera "internal";
};
};
if(f_cam_mode == 3) then
{

if (f_cam_mode == 3) then {
_delta = (time - f_cam_timestamp)*10;
f_cam_freecamera camSetFov f_cam_fovZoom;
_currPos = getposASL f_cam_freecamera;
Expand All @@ -43,87 +41,82 @@ if(f_cam_mode == 3) then
_height = 0 max (((getPosATL f_cam_freecamera) select 2));
_accel = 0.2 max (_height/8); // 0.8
_accelshift = _accel*4.25;//2;
if(f_cam_freecam_buttons select 0) then // W
{
if(f_cam_shift_down) then
{

if (f_cam_freecam_buttons select 0) then { // W
if (f_cam_shift_down) then {
_mY = _accelshift;
}
else
{
} else {
_mY = _accel;
};
};
if(f_cam_freecam_buttons select 1) then // S
{
if(f_cam_shift_down) then
{

if (f_cam_freecam_buttons select 1) then { // S
if (f_cam_shift_down) then {
_mY = -_accelshift;
}
else
{
} else {
_mY = -_accel;
};
};
if(f_cam_freecam_buttons select 2) then // A
{
if(f_cam_shift_down) then
{

if (f_cam_freecam_buttons select 2) then { // A
if (f_cam_shift_down) then {
_mX = -_accelshift;
}
else
{
} else {
_mX = -_accel;
};
};

if(f_cam_freecam_buttons select 3) then // D
{
if(f_cam_shift_down) then
{
if (f_cam_freecam_buttons select 3) then { // D
if (f_cam_shift_down) then {
_mX = _accelshift;
}
else
{
} else {
_mX = _accel;
};
};
if(f_cam_freecam_buttons select 4) then // Q
{

if (f_cam_freecam_buttons select 4) then { // Q
_scroll = 1*((sqrt _height)/2)*_delta;
if (abs _scroll < 0.1) then {
if (_scroll < 0) then { _scroll = -0.1;}
else { _scroll = 0.1;};
if (_scroll < 0) then {
_scroll = -0.1;
} else {
_scroll = 0.1;
};
};
_mZ = _scroll;
};
if(f_cam_freecam_buttons select 5) then // Z
{

if (f_cam_freecam_buttons select 5) then { // Z
_scroll = -1*((sqrt _height)/2)*_delta;
if (abs _scroll < 0.1) then {
if (_scroll < 0) then { _scroll = -0.1;}
else { _scroll = 0.1;};
if (_scroll < 0) then {
_scroll = -0.1;
} else {
_scroll = 0.1;
};
};
_mZ = _scroll;
};
if(f_cam_scrollHeight <0 || f_cam_scrollHeight > 0) then
{

if (f_cam_scrollHeight <0 || f_cam_scrollHeight > 0) then {
_scroll = -f_cam_scrollHeight * _delta*3;//was 3 and was positive
f_cam_scrollHeight = _scroll;
if(f_cam_scrollHeight < 0.2 && f_cam_scrollHeight > -0.2) then
{
if (f_cam_scrollHeight < 0.2 && f_cam_scrollHeight > -0.2) then {
f_cam_scrollHeight = 0;
};
_scroll = _scroll*((sqrt _height)/2);
if (abs _scroll < 0.1) then {
if (_scroll < 0) then { _scroll = -0.1;}
else { _scroll = 0.1;};
if (_scroll < 0) then {
_scroll = -0.1;
} else {
_scroll = 0.1;
};
};
_mZ = _mZ + _scroll;
};

//Max speed 50 m/s
_mX = _delta * ((_mX min 50) max -50);
_mX = _delta * ((_mX min 50) max -50);
_mY = _delta * ((_mY min 50) max -50);
f_freecam_x_speed = f_freecam_x_speed * 0.5 + _mX;
f_freecam_y_speed = f_freecam_y_speed * 0.5 + _mY;
Expand All @@ -139,6 +132,6 @@ if(f_cam_mode == 3) then
f_cam_scrollHeight = 0;
f_cam_timestamp = time;
};

cameraEffectEnableHUD true;
showCinemaBorder false;
// =======================================================================================================================================
showCinemaBorder false;
9 changes: 3 additions & 6 deletions ARCMF.VR/f/spect/fn_HandleCamera.sqf
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@

_x = f_cam_mouseCord select 0;
_y = f_cam_mouseCord select 1;
_leftButton = f_cam_MouseButton select 0;
_rightButton = f_cam_MouseButton select 1;
f_cam_mouseDeltaX = f_cam_mouseLastX - (_x);
f_cam_mouseDeltaY = f_cam_mouseLastY - (_y);


if(_rightButton && !_leftButton) then
{
if (_rightButton && !_leftButton) then {
f_cam_angleX = (f_cam_angleX - (f_cam_mouseDeltaX*360));
f_cam_angleY = (f_cam_angleY + (f_cam_mouseDeltaY*180)) min 89 max -89;
};
if(f_cam_ctrl_down && _rightButton && _leftButton) then
{

if (f_cam_ctrl_down && _rightButton && _leftButton) then {
f_cam_fovZoom = 0.7;
};

Expand Down
14 changes: 11 additions & 3 deletions ARCMF.VR/f/spect/fn_HandleMenu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ switch (_button) do {
f_script_briefing = [] execVM "briefing.sqf";
[] execVM "f\briefing\f_orbatNotes.sqf";
[] execVM "f\briefing\f_loadoutNotes.sqf";
{[_x] call hyp_fnc_traceFireRemove} forEach allUnits;
[] spawn {uiSleep 2;{[_x] call hyp_fnc_traceFireRemove} forEach allUnits;};
[_newUnit, ARC_cam_preCamPos, ARC_cam_preCamLoadout] execVM "onSpectatorRespawn.sqf";
} else {
systemChat "Respawn is not enabled.";
Expand All @@ -84,6 +86,12 @@ switch (_button) do {
case 0: {
// Off
{[_x] call hyp_fnc_traceFireRemove} forEach allUnits;

// Make sure it has removed all tracers if some left over
[] spawn {
uiSleep 2;
{[_x] call hyp_fnc_traceFireRemove} forEach allUnits;
};
};
case 1: {
// Players
Expand All @@ -99,7 +107,7 @@ switch (_button) do {
case sideUnknown: {[sideUnknown] call BIS_fnc_sideColor};
};

[_x, _color, 2, 0, -1, -1, false] call hyp_fnc_traceFire;
[_x, _color, 1, 4, 800, 1, false] call hyp_fnc_traceFire;
};
} forEach (allPlayers - entities "HeadlessClient_F");
};
Expand All @@ -117,7 +125,7 @@ switch (_button) do {
case sideUnknown: {[sideUnknown] call BIS_fnc_sideColor};
};

[_x, _color, 2, 0, -1, -1, false] call hyp_fnc_traceFire;
[_x, _color, 1, 4, 800, 1, false] call hyp_fnc_traceFire;
};
} forEach (allUnits - (allPlayers - entities "HeadlessClient_F"));
};
Expand All @@ -135,7 +143,7 @@ switch (_button) do {
case sideUnknown: {[sideUnknown] call BIS_fnc_sideColor};
};

[_x, _color, 2, 0, -1, -1, false] call hyp_fnc_traceFire;
[_x, _color, 1, 4, 800, 1, false] call hyp_fnc_traceFire;
};
} forEach (allUnits - (entities "HeadlessClient_F"));
};
Expand Down
39 changes: 32 additions & 7 deletions ARCMF.VR/f/spect/fn_OnUnload.sqf
Original file line number Diff line number Diff line change
@@ -1,20 +1,45 @@
disableSerialization;
sleep 1;
if (f_cam_forcedExit) ExitWith {};
if (f_cam_forcedExit) exitWith {};
createDialog "f_spec_dialog";

_displayDialog = (findDisplay 9228);
ctrlSetText [2112,(f_cam_sideNames select f_cam_sideButton)];
if(f_cam_playersOnly) then { ctrlSetText [2111,"Players only"];}
else { ctrlSetText [2111,"All units"];};

ctrlSetText [2112, (f_cam_sideNames select f_cam_sideButton)];

ctrlSetText [2113, (f_cam_tagsNames select f_cam_tagsButton)];

ctrlSetText [2236, (f_cam_tracersNames select f_cam_tracersButton)];

if (f_cam_playersOnly) then {
ctrlSetText [2111, "SHOW AI (NO)"];
} else {
ctrlSetText [2111, "SHOW AI (YES)"];
};

_mapWindow = _displayDialog displayCtrl 1350;
_fullmapWindow = _displayDialog displayCtrl 1360;
_mapWindow ctrlShow false;
_fullmapWindow ctrlShow false;
_fullmapWindow mapCenterOnCamera false;
_mapWindow mapCenterOnCamera false;
_helpWindow ctrlSetStructuredText parseText (f_cam_helptext);
// hide it to stop from being spammed open.

ctrlShow [1315, !ctrlVisible 1315];
ctrlShow [1300, !ctrlVisible 1300];
ctrlShow [1305, !ctrlVisible 1305];
ctrlShow [1305, !ctrlVisible 1305];

// Auto-size controls
_btnWidth = safeZoneW / (count f_cam_menuControls);
_w = 0 * safeZoneW + safeZoneX;

{
((findDisplay 9228) displayCtrl _x) ctrlSetPosition [_w, (0 * safeZoneH + safeZoneY), _btnWidth, (0.03 * safeZoneH)];
((findDisplay 9228) displayCtrl _x) ctrlCommit 0;
_w = _w + _btnWidth;
} forEach f_cam_menuControls;

if (!(call ARC_fnc_isRespawnEnabled)) then {
((findDisplay 9228) displayCtrl 5532) ctrlSetTooltip "Disabled";
} else {
((findDisplay 9228) displayCtrl 5532) ctrlSetTooltip "Respawn back into the game";
};

0 comments on commit 7e55f91

Please sign in to comment.