Skip to content

Commit 404a4a3

Browse files
author
Roberto De Ioris
committed
heightmap expander api
1 parent 80f4f4c commit 404a4a3

5 files changed

Lines changed: 35 additions & 2 deletions

File tree

‎Source/UnrealEnginePython/Private/UEPyEditor.cpp‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "Runtime/Engine/Classes/EdGraph/EdGraphSchema.h"
2222
#include "Toolkits/AssetEditorManager.h"
2323
#include "LevelEditor.h"
24+
#include "Editor/LandscapeEditor/Public/LandscapeEditorUtils.h"
2425

2526

2627
PyObject *py_unreal_engine_editor_play_in_viewport(PyObject * self, PyObject * args)
@@ -2118,5 +2119,31 @@ PyObject *py_unreal_engine_transactions(PyObject * self, PyObject * args)
21182119
return transactions;
21192120
}
21202121

2122+
PyObject *py_unreal_engine_heightmap_expand(PyObject * self, PyObject * args)
2123+
{
2124+
Py_buffer buf;
2125+
int width;
2126+
int height;
2127+
int new_width;
2128+
int new_height;
2129+
if (!PyArg_ParseTuple(args, "y*iiii:heightmap_expand", &buf, &width, &height, &new_width, &new_height))
2130+
return nullptr;
2131+
2132+
uint16 *original_data_buf = (uint16 *)buf.buf;
2133+
2134+
TArray<uint16> original_data;
2135+
original_data.AddZeroed(buf.len / 2);
2136+
2137+
FMemory::Memcpy(original_data.GetData(), original_data_buf, buf.len);
2138+
2139+
int offset_x = (new_width - width) / 2;
2140+
int offset_y = (new_height - height) / 2;
2141+
2142+
TArray<uint16> data = LandscapeEditorUtils::ExpandData<uint16>(original_data, 0, 0, width - 1, height - 1, -offset_x, -offset_y, new_width - offset_x - 1, new_height - offset_y - 1);
2143+
2144+
return PyByteArray_FromStringAndSize((char *)data.GetData(), data.Num() * sizeof(uint16));
2145+
2146+
}
2147+
21212148
#endif
21222149

‎Source/UnrealEnginePython/Private/UEPyEditor.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,6 @@ PyObject *py_unreal_engine_editor_undo(PyObject *, PyObject *);
104104
PyObject *py_unreal_engine_editor_redo(PyObject *, PyObject *);
105105
PyObject *py_unreal_engine_transactions(PyObject *, PyObject *);
106106

107+
PyObject *py_unreal_engine_heightmap_expand(PyObject *, PyObject *);
108+
107109
#endif

‎Source/UnrealEnginePython/Private/UEPyModule.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ static PyMethodDef unreal_engine_methods[] = {
253253

254254
{ "string_to_guid", py_unreal_engine_string_to_guid, METH_VARARGS, "" },
255255
{ "new_guid", py_unreal_engine_new_guid, METH_VARARGS, "" },
256+
#if WITH_EDITOR
257+
{ "heightmap_expand", py_unreal_engine_heightmap_expand, METH_VARARGS, "" },
258+
#endif
256259
#pragma warning(suppress: 4191)
257260
{ "get_assets_by_filter", (PyCFunction)py_unreal_engine_get_assets_by_filter, METH_VARARGS | METH_KEYWORDS, "" },
258261
{ "create_blueprint", py_unreal_engine_create_blueprint, METH_VARARGS, "" },

‎Source/UnrealEnginePython/Private/UObject/UEPyLandscape.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ PyObject *py_ue_landscape_import(ue_PyUObject *self, PyObject * args)
6969

7070
TArray<FLandscapeImportLayerInfo> infos;
7171

72-
landscape->Import(FGuid::NewGuid(), 0, 0, size_x-1, size_y-1, sections_per_component, section_size, data, nullptr, infos, (ELandscapeImportAlphamapType)layer_type);
72+
landscape->Import(FGuid::NewGuid(), 0, 0, size_x - 1, size_y - 1, sections_per_component, section_size, data, nullptr, infos, (ELandscapeImportAlphamapType)layer_type);
7373

7474
Py_RETURN_NONE;
7575
}

‎Source/UnrealEnginePython/UnrealEnginePython.Build.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ public UnrealEnginePython(TargetInfo Target)
158158
"EditorWidgets",
159159
"FBX",
160160
"Persona",
161-
"PropertyEditor"
161+
"PropertyEditor",
162+
"LandscapeEditor"
162163
});
163164
}
164165

0 commit comments

Comments
 (0)