Skip to content

Commit

Permalink
Improve object serialization by saving vector dir and up (#499)
Browse files Browse the repository at this point in the history
* Save roll and pitch

* Remove vehicle customization part
  • Loading branch information
Kexanone authored Jan 23, 2021
1 parent e63e3fc commit 6fa3460
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions addons/common/functions/fnc_deserializeObjects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ private _fnc_deserializeVehicle = {
private _placement = ["CAN_COLLIDE", "FLY"] select (_type isKindOf "Air" && {_position select 2 > 5});

private _vehicle = createVehicle [_type, _position, [], 0, _placement];
_vehicle setDir _direction;
if (_direction isEqualType 0) then {
_vehicle setDir _direction;
} else {
_vehicle setVectorDirAndUp _direction;
};

// FLY placement always places aircraft at the same height relative to the ground
if (_placement == "FLY") then {
Expand Down Expand Up @@ -224,7 +228,11 @@ private _fnc_deserializeStatic = {

private _object = createVehicle [_type, [0, 0, 0], [], 0, "CAN_COLLIDE"];
_object setPos _position;
_object setDir _direction;
if (_direction isEqualType 0) then {
_object setDir _direction;
} else {
_object setVectorDirAndUp _direction;
};

// Composition placement aligns objects to the surface normal if they are close to the ground
// This also helps in preventing objects from being destroyed by cliping into the ground
Expand Down
4 changes: 2 additions & 2 deletions addons/common/functions/fnc_serializeObjects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private _fnc_serializeVehicle = {

private _type = typeOf _vehicle;
private _position = ASLtoAGL getPosASL _vehicle vectorDiff _centerPos;
private _direction = getDir _vehicle;
private _direction = [vectorDir _vehicle, vectorUp _vehicle];

private _fuel = fuel _vehicle;
private _inventory = _vehicle call FUNC(serializeInventory);
Expand Down Expand Up @@ -177,7 +177,7 @@ private _fnc_serializeStatic = {

private _type = typeOf _object;
private _position = ASLtoAGL getPosASL _object vectorDiff _centerPos;
private _direction = getDir _object;
private _direction = [vectorDir _object, vectorUp _object];

private _simulationEnabled = simulationEnabled _object;
private _inventory = _object call FUNC(serializeInventory);
Expand Down

0 comments on commit 6fa3460

Please sign in to comment.