Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve object serialization by saving vector dir and up #499

Merged
merged 3 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions addons/common/functions/fnc_deserializeObjects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,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 @@ -223,7 +227,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