Skip to content

Commit

Permalink
Merge pull request #114 from jetelain/multipart-eden-export
Browse files Browse the repository at this point in the history
Reduce Eden export size, and split it into multiple parts if estimated size is too big
  • Loading branch information
jetelain authored Aug 26, 2023
2 parents 66f3c7b + 535de98 commit 479d651
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 10 deletions.
3 changes: 2 additions & 1 deletion @ArmaMapStudio/addons/eden/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ PREP(export);
PREP(getPosWrp);
PREP(recreateHidden);
PREP(transformObject);
PREP(editObject);
PREP(editObject);
PREP(copyPart);
15 changes: 15 additions & 0 deletions @ArmaMapStudio/addons/eden/functions/fnc_copyPart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "script_component.hpp"

copyToClipboard (GVAR(results) # GVAR(current));
GVAR(current) = GVAR(current) + 1;
systemChat (format ["Part %1 on %2 copied", GVAR(current), count GVAR(results)]);

if ( GVAR(current) < count GVAR(results)) then {
[
format [LLSTRING(NextPartMessage),GVAR(current), count GVAR(results)],
LLSTRING(ExportToGrmStudio),
[LLSTRING(NextPartButton),{ 0 spawn { sleep 0.1; call FUNC(copyPart); }; }]
] call BIS_fnc_3DENShowMessage;
} else {
[LLSTRING(ExportDone), 0, 5] call BIS_fnc_3DENNotification;
}
40 changes: 32 additions & 8 deletions @ArmaMapStudio/addons/eden/functions/fnc_export.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ private _toRemoveLayer = if ( count _existingLayers > 0 ) then { _existingLayer
private _progress = 0;
private _progressTotal = count _objects + count _systems;

_data pushBack [".map", worldName, worldSize, getNumber (configFile >> "CfgWorlds" >> worldName >> "grma3_revision")];
private _prelude = (str [".map", worldName, worldSize, getNumber (configFile >> "CfgWorlds" >> worldName >> "grma3_revision")]);

{
if ( _x isKindOf "ModuleHideTerrainObjects_F" ) then {
_x set3DENLayer _toRemoveLayer;
private _hidden = _x getVariable ["#objects",[]];
{
_data pushBack [".hide", (getModelInfo _x) select 1, getPosWorld _x, [_x] call FUNC(getPosWrp), vectorUp _x, vectorDir _x, surfaceNormal (getPosASL _x), getObjectScale _x, getObjectID _x];
_data pushBack [".hide", (getModelInfo _x) select 1, [], [_x] call FUNC(getPosWrp), vectorUp _x, vectorDir _x, surfaceNormal (getPosASL _x), getObjectScale _x, getObjectID _x];
} foreach _hidden;
};

Expand All @@ -31,7 +31,7 @@ _data pushBack [".map", worldName, worldSize, getNumber (configFile >> "CfgWorld
if ( _value == 5 ) then {
private _building = _x getVariable ["#building", objNull];
if ( !isNull _building ) then {
_data pushBack [".hide", (getModelInfo _building) select 1, getPosWorld _building, [_building] call FUNC(getPosWrp), vectorUp _building, vectorDir _building, surfaceNormal (getPosASL _building), getObjectScale _building, getObjectID _building];
_data pushBack [".hide", (getModelInfo _building) select 1, [], [_building] call FUNC(getPosWrp), vectorUp _building, vectorDir _building, surfaceNormal (getPosASL _building), getObjectScale _building, getObjectID _building];
};
_x set3DENLayer _toRemoveLayer;
};
Expand All @@ -42,6 +42,8 @@ _data pushBack [".map", worldName, worldSize, getNumber (configFile >> "CfgWorld

} foreach _systems;

private _deleteCount = count _data;

{
if (_x get3DENAttribute "GRMA3_Exclude" select 0) then {
// Ignored
Expand Down Expand Up @@ -74,7 +76,7 @@ _data pushBack [".map", worldName, worldSize, getNumber (configFile >> "CfgWorld
_classes set [_class,_classData];
};
if ( _classData select 0 ) then {
_data pushBack [".add", _class, getPosWorld _x, [_x] call FUNC(getPosWrp), vectorUp _x, vectorDir _x, surfaceNormal (getPosASL _x), getObjectScale _x];
_data pushBack [".add", _class, [], [_x] call FUNC(getPosWrp), vectorUp _x, vectorDir _x, surfaceNormal (getPosASL _x), getObjectScale _x];
_x set3DENLayer _toRemoveLayer;
};
};
Expand All @@ -85,20 +87,42 @@ _data pushBack [".map", worldName, worldSize, getNumber (configFile >> "CfgWorld

} foreach _objects;


private _addCount = (count _data) - _deleteCount - (count _classes);
private _elevationCount = 0;

// Deformer related data
if ( !isNil "GF_gridMap") then {
_data pushBack [".dhmap", GF_gridMap apply { [_x#0, _x#1, _y#0] }];
toFixed 3;
private _hmap = GF_gridMap apply { [_x#0, _x#1, _y#0] };
_elevationCount = count _hmap;
for "_i" from 0 to (count _hmap) step 25 do {
_data pushBack ((str [".dhmap", _hmap select [_i, 25] ]) regexReplace ["\.000/gio", ""]);
};
};

endloadingscreen;

INFO_1("%1 items", count _data);

private _results = [];

toFixed 20;

private _result = _data joinString endl;
for "_i" from 0 to (count _data) step 20000 do {
_results pushBack (([_prelude] + (_data select [_i, 20000])) joinString endl);
};

toFixed -1;

copyToClipboard _result;
systemChat (format ["Total: %1 deletes, %2 adds, %3 elevation changes", _deleteCount, _addCount, _elevationCount]);

[LLSTRING(ExportDone), 0, 5] call BIS_fnc_3DENNotification;
if ( count _results <= 1 ) then {
copyToClipboard (_results # 0);
[LLSTRING(ExportDone), 0, 5] call BIS_fnc_3DENNotification;
}
else {
GVAR(results) = _results;
GVAR(current) = 0;
call FUNC(copyPart);
};
8 changes: 8 additions & 0 deletions @ArmaMapStudio/addons/eden/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,13 @@
<English>Edit object</English>
<French>Modifier l'objet</French>
</Key>
<Key ID="STR_grma3_eden_NextPartButton">
<English>Next Part</English>
<French>Suivant</French>
</Key>
<Key ID="STR_grma3_eden_NextPartMessage">
<English>Part %1 on %2 of export have been copied. Import it in GameRealisticMap Studio, and then click on Next Part button to continue.</English>
<French>Partie %1 sur %2 de l'export a été copié. Importer le dans GameRealisticMap Studio, puis ensuite cliquer sur le bouton Suivant pour continuer.</French>
</Key>
</Package>
</Project>
2 changes: 1 addition & 1 deletion @ArmaMapStudio/addons/main/script_version.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define MAJOR 0
#define MINOR 3
#define PATCH 0
#define PATCH 1
#define BUILD 0

0 comments on commit 479d651

Please sign in to comment.