88#include " Runtime/Landscape/Classes/LandscapeInfo.h"
99#include " GameFramework/GameModeBase.h"
1010
11+ #if ENGINE_MINOR_VERSION > 21
12+ #include " Wrappers/UEPyFMeshDescription.h"
13+ #include " Runtime/MeshDescription/Public/MeshDescription.h"
14+ #if ENGINE_MINOR_VERSION > 24
15+ #include " Runtime/StaticMeshDescription/Public/StaticMeshAttributes.h"
16+ #endif
17+ #endif
18+
1119PyObject* py_ue_create_landscape_info (ue_PyUObject* self, PyObject* args)
1220{
1321
@@ -84,6 +92,61 @@ PyObject* py_ue_landscape_import(ue_PyUObject* self, PyObject* args)
8492 Py_RETURN_NONE;
8593}
8694
95+ // so what to do here - create new function or leave as returning
96+ // a different object type - from FRawMesh to FMeshDescription???
97+ // creating new function
98+ // curious - the original code specified > 21 but FMeshDescription appears to exist in version 4.21.2
99+ // for the moment leave as > 21 - but maybe should be >= 21??
100+
101+ #if ENGINE_MINOR_VERSION > 21
102+ PyObject* py_ue_landscape_export_to_mesh_description (ue_PyUObject* self, PyObject* args)
103+ {
104+
105+ ue_py_check (self);
106+
107+ int lod = 0 ;
108+
109+ if (!PyArg_ParseTuple (args, " |i:landscape_import" , &lod))
110+ return nullptr ;
111+
112+ ALandscapeProxy* landscape = ue_py_check_type<ALandscapeProxy>(self);
113+ if (!landscape)
114+ return PyErr_Format (PyExc_Exception, " uobject is not a ULandscapeProxy" );
115+
116+ // ah - now think we dont have to set anything into the FMeshDescription
117+ // well apparently we do have to set some attributes
118+ // - we create a new instance, then run ExportToRawMesh which fills the FMeshDescription
119+ // with all the mesh data
120+
121+ // this code is following MeshMergeHelpers.cpp Landscape ExportToRawMesh code
122+ // another example is in WorldTileCollectionModel.cpp which creates a full UStaticMesh class model
123+ // note this is exporting(converting) to StaticMesh type mesh description
124+ // - we now need to write extraction functions in the FMeshDescription wrapper
125+ // to actually get any data
126+ // we use a locally allocated FMeshDescription here
127+ // - py_ue_new_fmesh_description will allocate a new copy from this
128+ // should I worry about the bounds??
129+
130+ // FMeshDescription* mesh_description = new FMeshDescription();
131+ // FBoxSphereBounds LandscapeBounds = EstimatedMeshProxyBounds;
132+ // Landscape->ExportToRawMesh(LandscapeExportLOD, *MeshDescription, LandscapeBounds);
133+ #if ENGINE_MINOR_VERSION > 24
134+ FMeshDescription mesh_description;
135+ FStaticMeshAttributes (mesh_description).Register ();
136+ #else
137+ // definitely required for 4.22
138+ FMeshDescription mesh_description;
139+ UStaticMesh::RegisterMeshAttributes (mesh_description);
140+ #endif
141+
142+ if (!landscape->ExportToRawMesh (lod, mesh_description))
143+ return PyErr_Format (PyExc_Exception, " unable to export landscape to FMeshDescription" );
144+
145+ return py_ue_new_fmesh_description (mesh_description);
146+ }
147+ #endif
148+
149+
87150PyObject* py_ue_landscape_export_to_raw_mesh (ue_PyUObject* self, PyObject* args)
88151{
89152
@@ -99,7 +162,9 @@ PyObject* py_ue_landscape_export_to_raw_mesh(ue_PyUObject* self, PyObject* args)
99162 return PyErr_Format (PyExc_Exception, " uobject is not a ULandscapeProxy" );
100163
101164#if ENGINE_MINOR_VERSION > 21
102- return PyErr_Format (PyExc_Exception, " MeshDescription struct is still unsupported" );;
165+ // well pigs this means UnrealEnginePython does not support FMeshDescription why??
166+ // return PyErr_Format(PyExc_Exception, "MeshDescription struct is still unsupported");
167+ return PyErr_Format (PyExc_Exception, " RawMesh struct no longer supported in Unreal Engine" );
103168#else
104169 FRawMesh raw_mesh;
105170 if (!landscape->ExportToRawMesh (lod, raw_mesh))
0 commit comments