Tagging - Fix tag orientation on walls (#7795)

Fix #7769
This commit is contained in:
PabstMirror 2020-07-22 10:25:34 -05:00 committed by GitHub
parent 2f5c602316
commit d751aca8ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,13 +70,20 @@ if (_surfaceNormal vectorDotProduct (_endPosASL vectorDiff _startPosASL) > 0) t
// Check if its a valid surface: big enough, reasonably plane
private _v1 = vectorNormalized (_surfaceNormal vectorMultiply -1);
private _v2 = vectorNormalized (_v1 vectorCrossProduct (_endPosASL vectorDiff _startPosASL));
private _v2 = [];
private _v3 = [];
// If the surface is not horizontal (>20º), create vup _v2 pointing upward instead of away
if (abs (_v1 select 2) < 0.94) then {
private _v3Temp = _v1 vectorCrossProduct [0, 0, 1];
_v2 = _v3Temp vectorCrossProduct _v1;
private _vectorDirAndUp = if (abs (_v1 select 2) < 0.94) then {
_v3 = _v1 vectorCrossProduct [0, 0, 1];
_v2 = _v3 vectorCrossProduct _v1;
TRACE_2("Wall Placement",_v1,_v2);
[_v1, _v2]
} else {
_v2 = vectorNormalized (_v1 vectorCrossProduct (_endPosASL vectorDiff _startPosASL));
_v3 = _v2 vectorCrossProduct _v1;
TRACE_2("Ground Placement",_v1,_v3);
[_v1, _v3]
};
private _v3 = _v2 vectorCrossProduct _v1;
TRACE_3("Reference:", _v1, _v2, _v3);
@ -101,7 +108,6 @@ if ( !([ 0.5 * TAG_SIZE, 0.5 * TAG_SIZE] call _fnc_isOk) ||
false
};
private _vectorDirAndUp = [_surfaceNormal vectorMultiply -1, _v3];
// Everything ok, make the unit create the tag
[_unit, "PutDown"] call EFUNC(common,doGesture);