Skip to content

Commit

Permalink
Fix #84
Browse files Browse the repository at this point in the history
  • Loading branch information
James Kingsley committed Oct 2, 2016
1 parent 76a3557 commit adabf59
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ARCMF.VR/f/spect/fn_CamInit.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// [<newUnit>,<oldUnit>,<respawn>,<respawnDelay>]
// [player, objNull, 4, 1, true] call f_fnc_CamInit;
// [player, objNull, 1, 1, true] call f_fnc_CamInit;

_this spawn {
params [
Expand Down
21 changes: 13 additions & 8 deletions ARCMF.VR/f/spect/fn_FreeCam.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ if (f_cam_mode == 3) then {
_mX = 0;
_mY = 0;
_mZ = 0;

private _inBuilding = [_currPos] call f_fnc_inBuilding;

_height = 0 max (((getPosATL f_cam_freecamera) select 2));
_accel = 0.2 max (_height/8); // 0.8
_accelshift = _accel*4.25;//2;
_accel = 0.1 max (_height / ([10,35] select _inBuilding)); // 0.8
_accelshift = _accel * 4.25;//2;

systemChat format ["In Building: %1, Accel: %2", _inBuilding, _accel];

if (f_cam_freecam_buttons select 0) then { // W
if (f_cam_shift_down) then {
Expand Down Expand Up @@ -75,7 +80,7 @@ if (f_cam_mode == 3) then {
};

if (f_cam_freecam_buttons select 4) then { // Q
_scroll = 1*((sqrt _height)/2)*_delta;
_scroll = 1 * ((sqrt _height) / 2) * _delta;
if (abs _scroll < 0.1) then {
if (_scroll < 0) then {
_scroll = -0.1;
Expand All @@ -87,7 +92,7 @@ if (f_cam_mode == 3) then {
};

if (f_cam_freecam_buttons select 5) then { // Z
_scroll = -1*((sqrt _height)/2)*_delta;
_scroll = -1 * ((sqrt _height) / 2) * _delta;
if (abs _scroll < 0.1) then {
if (_scroll < 0) then {
_scroll = -0.1;
Expand All @@ -98,13 +103,13 @@ if (f_cam_mode == 3) then {
_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 {
f_cam_scrollHeight = 0;
};
_scroll = _scroll*((sqrt _height)/2);
_scroll = _scroll * ((sqrt _height) / 2);
if (abs _scroll < 0.1) then {
if (_scroll < 0) then {
_scroll = -0.1;
Expand All @@ -120,12 +125,12 @@ if (f_cam_mode == 3) then {
_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;
f_freecam_z_speed = f_freecam_z_speed * 0.5 + _mZ;
f_freecam_z_speed = f_freecam_z_speed * 0.5 + (_mZ * (_accel min ([1.5, 5] select f_cam_shift_down)));

_x = (_currPos select 0) + (f_freecam_x_speed * (cos f_cam_angleX)) + (f_freecam_y_speed * (sin f_cam_angleX));
_y = (_currPos select 1) - (f_freecam_x_speed * (sin f_cam_angleX)) + (f_freecam_y_speed * (cos f_cam_angleX));
_newHeight = (getTerrainHeightASL [_x,_y]);
_z = ((_currPos select 2) + f_freecam_z_speed) min (650 + _newHeight);
_z = ((_currPos select 2) + f_freecam_z_speed) min (1000 + _newHeight);
f_cam_freecamera setPosASL [_x,_y,_z max _newHeight];
f_cam_freecamera setDir f_cam_angleX;
[f_cam_freecamera,f_cam_angleY,0] call BIS_fnc_setPitchBank;
Expand Down
33 changes: 33 additions & 0 deletions ARCMF.VR/f/spect/fn_inBuilding.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Author: commy2, Kingsley
* Check if the position is in a building. Will return true if the position is in a bush.
*
* Arguments:
* 0: Position <ARRAY>
*
* Return Value:
* Is the position in a building? <BOOL>
*
* Example:
* [getPos myUnit] call f_fnc_inBuilding;
*
* Public: Yes
*/

#define CHECK_DISTANCE 15

params [["_position", []]];

if (_position isEqualTo []) exitWith {};

private _intersections = {
lineIntersects [_position, _position vectorAdd _x]
} count [
[0, 0, +CHECK_DISTANCE],
[+CHECK_DISTANCE, 0, 0],
[-CHECK_DISTANCE, 0, 0],
[0, +CHECK_DISTANCE, 0],
[0, -CHECK_DISTANCE, 0]
];

_intersections > 3
1 change: 1 addition & 0 deletions ARCMF.VR/f/spect/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ class fspectator
class addToTracers {};
class removeAllTracers {};
class handleTracers {};
class inBuilding {};
};

0 comments on commit adabf59

Please sign in to comment.