Removing surface height adjustment - not working as expected

This commit is contained in:
sethduda 2016-04-08 20:00:19 -04:00
parent 2ec8366349
commit bec973517c

View File

@ -126,8 +126,7 @@ SA_Simulate_Towing = {
private ["_vehicleHitchPosition","_cargoHitchPosition","_newCargoHitchPosition","_cargoVector","_movedCargoVector","_attachedObjects","_currentCargo"]; private ["_vehicleHitchPosition","_cargoHitchPosition","_newCargoHitchPosition","_cargoVector","_movedCargoVector","_attachedObjects","_currentCargo"];
private ["_newCargoDir","_lastCargoVectorDir","_newCargoPosition","_doExit","_cargoPosition","_vehiclePosition","_maxVehicleSpeed","_vehicleMass","_cargoMass","_cargoCanFloat"]; private ["_newCargoDir","_lastCargoVectorDir","_newCargoPosition","_doExit","_cargoPosition","_vehiclePosition","_maxVehicleSpeed","_vehicleMass","_cargoMass","_cargoCanFloat"];
private ["_cargoCorner1AGL","_cargoCorner1ASL","_cargoCorner2AGL","_cargoCorner2ASL","_cargoCorner3AGL","_cargoCorner3ASL","_cargoCorner4AGL","_cargoCorner4ASL","_surfaceNormal1","_surfaceNormal2","_surfaceNormal"]; private ["_cargoCorner1AGL","_cargoCorner1ASL","_cargoCorner2AGL","_cargoCorner2ASL","_cargoCorner3AGL","_cargoCorner3ASL","_cargoCorner4AGL","_cargoCorner4ASL","_surfaceNormal1","_surfaceNormal2","_surfaceNormal"];
private ["_maxSurfaceMidpointASLHeight","_surfaceMidpoint1","_surfaceMidpoint2","_surfaceMidpointASLGL"];
_maxVehicleSpeed = getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "maxSpeed"); _maxVehicleSpeed = getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "maxSpeed");
_cargoCanFloat = if( getNumber (configFile >> "CfgVehicles" >> typeOf _cargo >> "canFloat") == 1 ) then { true } else { false }; _cargoCanFloat = if( getNumber (configFile >> "CfgVehicles" >> typeOf _cargo >> "canFloat") == 1 ) then { true } else { false };
@ -209,13 +208,6 @@ SA_Simulate_Towing = {
_surfaceNormal2 = (_cargoCorner4ASL vectorFromTo _cargoCorner2ASL) vectorCrossProduct (_cargoCorner4ASL vectorFromTo _cargoCorner3ASL); _surfaceNormal2 = (_cargoCorner4ASL vectorFromTo _cargoCorner2ASL) vectorCrossProduct (_cargoCorner4ASL vectorFromTo _cargoCorner3ASL);
_surfaceNormal = _surfaceNormal1 vectorAdd _surfaceNormal2; _surfaceNormal = _surfaceNormal1 vectorAdd _surfaceNormal2;
// Calculate adjusted surface height (prevents vehicle from clipping into ground)
_surfaceMidpoint1 = (_cargoCorner1ASL vectorAdd _cargoCorner4ASL) vectorMultiply 0.5;
_surfaceMidpoint2 = (_cargoCorner2ASL vectorAdd _cargoCorner3ASL) vectorMultiply 0.5;
_surfaceMidpointASLGL = AGLToASL [_surfaceMidpoint2 select 0, _surfaceMidpoint2 select 1, 0];
_maxSurfaceMidpointASLHeight = (_surfaceMidpoint1 select 2) max (_surfaceMidpoint2 select 2) max (_surfaceMidpointASLGL select 2);
_newCargoPosition set [2, _maxSurfaceMidpointASLHeight ];
_newCargoPosition = _newCargoPosition vectorAdd ( _cargoModelCenterGroundPosition vectorMultiply -1 ); _newCargoPosition = _newCargoPosition vectorAdd ( _cargoModelCenterGroundPosition vectorMultiply -1 );
_cargo setVectorDir _newCargoDir; _cargo setVectorDir _newCargoDir;