diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbx.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbx.h deleted file mode 100644 index feff5f8a8..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbx.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#if ENGINE_MINOR_VERSION > 12 -#include "UEPyModule.h" - -#if WITH_EDITOR - -#include "UEPyFbxManager.h" -#include "UEPyFbxIOSettings.h" -#include "UEPyFbxImporter.h" -#include "UEPyFbxScene.h" -#include "UEPyFbxNode.h" -#include "UEPyFbxObject.h" -#include "UEPyFbxProperty.h" -#include "UEPyFbxPose.h" -#include "UEPyFbxMesh.h" - -void ue_python_init_fbx(PyObject *); - -#endif -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.cpp deleted file mode 100644 index c736e7f08..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "UEPyFbxIOSettings.h" - -#if ENGINE_MINOR_VERSION > 12 - -#if WITH_EDITOR - -#include "UEPyFbx.h" - -static PyMethodDef ue_PyFbxIOSettings_methods[] = { - { NULL } /* Sentinel */ -}; - -static PyTypeObject ue_PyFbxIOSettingsType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.FbxIOSettings", /* tp_name */ - sizeof(ue_PyFbxIOSettings), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Unreal Engine FbxIOSettings", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PyFbxIOSettings_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -}; - -static int py_ue_fbx_io_settings_init(ue_PyFbxIOSettings *self, PyObject * args) -{ - PyObject *py_object; - char *name; - if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) - { - return -1; - } - - ue_PyFbxManager *py_fbx_manager = py_ue_is_fbx_manager(py_object); - if (!py_fbx_manager) - { - PyErr_SetString(PyExc_Exception, "argument is not a FbxManager"); - return -1; - } - - self->fbx_io_settings = FbxIOSettings::Create(py_fbx_manager->fbx_manager, name); - return 0; -} - -void ue_python_init_fbx_io_settings(PyObject *ue_module) -{ - ue_PyFbxIOSettingsType.tp_new = PyType_GenericNew;; - ue_PyFbxIOSettingsType.tp_init = (initproc)py_ue_fbx_io_settings_init; - if (PyType_Ready(&ue_PyFbxIOSettingsType) < 0) - return; - - Py_INCREF(&ue_PyFbxIOSettingsType); - PyModule_AddObject(ue_module, "FbxIOSettings", (PyObject *)&ue_PyFbxIOSettingsType); -} - -ue_PyFbxIOSettings *py_ue_is_fbx_io_settings(PyObject *obj) -{ - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxIOSettingsType)) - return nullptr; - return (ue_PyFbxIOSettings *)obj; -} - -#endif -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.h deleted file mode 100644 index 9515ddec9..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include "UEPyModule.h" - -#if WITH_EDITOR - -#if PLATFORM_LINUX -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wnull-dereference" -#endif -#endif - -#include - -struct ue_PyFbxIOSettings -{ - PyObject_HEAD - /* Type-specific fields go here. */ - FbxIOSettings *fbx_io_settings; -}; - - -void ue_python_init_fbx_io_settings(PyObject *); - -ue_PyFbxIOSettings *py_ue_is_fbx_io_settings(PyObject *); -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.cpp deleted file mode 100644 index 432271a18..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.cpp +++ /dev/null @@ -1,147 +0,0 @@ -#include "UEPyFbxImporter.h" - -#if ENGINE_MINOR_VERSION > 12 -#if WITH_EDITOR - -#include "UEPyFbx.h" - -static PyObject *py_ue_fbx_importer_get_anim_stack_count(ue_PyFbxImporter *self, PyObject *args) -{ - return PyLong_FromLong(self->fbx_importer->GetAnimStackCount()); -} - -static PyObject *py_ue_fbx_importer_get_take_local_time_span(ue_PyFbxImporter *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - - FbxTakeInfo *take_info = self->fbx_importer->GetTakeInfo(index); - if (!take_info) - return PyErr_Format(PyExc_Exception, "unable to get FbxTakeInfo for index %d", index); - - FbxTimeSpan time_span = take_info->mLocalTimeSpan; - return Py_BuildValue((char *)"(ff)", time_span.GetStart().GetSecondDouble(), time_span.GetStop().GetSecondDouble()); -} - -static PyObject *py_ue_fbx_importer_initialize(ue_PyFbxImporter *self, PyObject *args) -{ - char *filename; - PyObject *py_object; - if (!PyArg_ParseTuple(args, "sO", &filename, &py_object)) - { - return nullptr; - } - - ue_PyFbxIOSettings *py_fbx_io_settings = py_ue_is_fbx_io_settings(py_object); - if (!py_fbx_io_settings) - { - return PyErr_Format(PyExc_Exception, "argument is not a FbxIOSettings"); - } - - if (self->fbx_importer->Initialize(filename, -1, py_fbx_io_settings->fbx_io_settings)) - { - Py_RETURN_TRUE; - } - - Py_RETURN_FALSE; -} - -static PyObject *py_ue_fbx_importer_import(ue_PyFbxImporter *self, PyObject *args) -{ - PyObject *py_object; - if (!PyArg_ParseTuple(args, "O", &py_object)) - { - return nullptr; - } - - ue_PyFbxScene *py_fbx_scene = py_ue_is_fbx_scene(py_object); - if (!py_fbx_scene) - { - return PyErr_Format(PyExc_Exception, "argument is not a FbxScene"); - } - - if (self->fbx_importer->Import(py_fbx_scene->fbx_scene)) - { - Py_RETURN_TRUE; - } - - Py_RETURN_FALSE; -} - -static PyMethodDef ue_PyFbxImporter_methods[] = { - { "initialize", (PyCFunction)py_ue_fbx_importer_initialize, METH_VARARGS, "" }, - { "_import", (PyCFunction)py_ue_fbx_importer_import, METH_VARARGS, "" }, - { "get_anim_stack_count", (PyCFunction)py_ue_fbx_importer_get_anim_stack_count, METH_VARARGS, "" }, - { "get_take_local_time_span", (PyCFunction)py_ue_fbx_importer_get_take_local_time_span, METH_VARARGS, "" }, - { NULL } /* Sentinel */ -}; - -static PyTypeObject ue_PyFbxImporterType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.FbxImporter", /* tp_name */ - sizeof(ue_PyFbxImporter), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Unreal Engine FbxImporter", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PyFbxImporter_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -}; - -static int py_ue_fbx_importer_init(ue_PyFbxImporter *self, PyObject * args) -{ - PyObject *py_object; - char *name; - if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) - { - return -1; - } - - ue_PyFbxManager *py_fbx_manager = py_ue_is_fbx_manager(py_object); - if (!py_fbx_manager) - { - PyErr_SetString(PyExc_Exception, "argument is not a FbxManager"); - return -1; - } - - self->fbx_importer = FbxImporter::Create(py_fbx_manager->fbx_manager, name); - return 0; -} - -void ue_python_init_fbx_importer(PyObject *ue_module) -{ - ue_PyFbxImporterType.tp_new = PyType_GenericNew;; - ue_PyFbxImporterType.tp_init = (initproc)py_ue_fbx_importer_init; - if (PyType_Ready(&ue_PyFbxImporterType) < 0) - return; - - Py_INCREF(&ue_PyFbxImporterType); - PyModule_AddObject(ue_module, "FbxImporter", (PyObject *)&ue_PyFbxImporterType); -} - -#endif -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.h deleted file mode 100644 index 8c7b24772..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include "UEPyModule.h" - -#if WITH_EDITOR - -#if PLATFORM_LINUX -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wnull-dereference" -#pragma clang diagnostic warning "-Wshadow" -#endif -#endif - -#include - -struct ue_PyFbxImporter -{ - PyObject_HEAD - /* Type-specific fields go here. */ - FbxImporter *fbx_importer; -}; - - -void ue_python_init_fbx_importer(PyObject *); - -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.cpp deleted file mode 100644 index 0a8fe98f1..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.cpp +++ /dev/null @@ -1,138 +0,0 @@ -#include "UEPyFbxManager.h" - -#if ENGINE_MINOR_VERSION > 12 - -#if WITH_EDITOR - -#include "UEPyFbx.h" - -static PyObject *py_ue_fbx_manager_set_io_settings(ue_PyFbxManager *self, PyObject *args) -{ - PyObject *py_object; - if (!PyArg_ParseTuple(args, "O", &py_object)) - { - return nullptr; - } - - ue_PyFbxIOSettings *py_fbx_io_settings = py_ue_is_fbx_io_settings(py_object); - if (!py_fbx_io_settings) - { - return PyErr_Format(PyExc_Exception, "argument is not a FbxIOSettings"); - } - - self->fbx_manager->SetIOSettings(py_fbx_io_settings->fbx_io_settings); - - Py_RETURN_NONE; -} - -static PyObject *py_ue_fbx_manager_create_missing_bind_poses(ue_PyFbxManager *self, PyObject *args) -{ - PyObject *py_object; - if (!PyArg_ParseTuple(args, "O", &py_object)) - { - return nullptr; - } - - ue_PyFbxScene *py_fbx_scene = py_ue_is_fbx_scene(py_object); - if (!py_fbx_scene) - { - return PyErr_Format(PyExc_Exception, "argument is not a FbxScene"); - } - - self->fbx_manager->CreateMissingBindPoses(py_fbx_scene->fbx_scene); - - Py_RETURN_NONE; -} - - -static PyMethodDef ue_PyFbxManager_methods[] = { - { "set_io_settings", (PyCFunction)py_ue_fbx_manager_set_io_settings, METH_VARARGS, "" }, - { "create_missing_bind_poses", (PyCFunction)py_ue_fbx_manager_create_missing_bind_poses, METH_VARARGS, "" }, - { NULL } /* Sentinel */ -}; - -static void ue_py_fbx_manager_dealloc(ue_PyFbxManager *self) -{ - if (self->fbx_manager) - self->fbx_manager->Destroy(); -#if PY_MAJOR_VERSION < 3 - self->ob_type->tp_free((PyObject*)self); -#else - Py_TYPE(self)->tp_free((PyObject*)self); -#endif -} - -static PyTypeObject ue_PyFbxManagerType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.FbxManager", /* tp_name */ - sizeof(ue_PyFbxManager), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)ue_py_fbx_manager_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Unreal Engine FbxManager", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PyFbxManager_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -}; - -static int py_ue_fbx_manager_init(ue_PyFbxManager *self, PyObject * args) -{ - self->fbx_manager = FbxManager::Create(); - return 0; -} - -void ue_python_init_fbx_manager(PyObject *ue_module) -{ - ue_PyFbxManagerType.tp_new = PyType_GenericNew;; - ue_PyFbxManagerType.tp_init = (initproc)py_ue_fbx_manager_init; - if (PyType_Ready(&ue_PyFbxManagerType) < 0) - return; - - Py_INCREF(&ue_PyFbxManagerType); - PyModule_AddObject(ue_module, "FbxManager", (PyObject *)&ue_PyFbxManagerType); -} - - -ue_PyFbxManager *py_ue_is_fbx_manager(PyObject *obj) -{ - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxManagerType)) - return nullptr; - return (ue_PyFbxManager *)obj; -} - -void ue_python_init_fbx(PyObject *module) -{ - ue_python_init_fbx_manager(module); - ue_python_init_fbx_io_settings(module); - ue_python_init_fbx_importer(module); - ue_python_init_fbx_scene(module); - ue_python_init_fbx_node(module); - ue_python_init_fbx_object(module); - ue_python_init_fbx_property(module); - ue_python_init_fbx_pose(module); - ue_python_init_fbx_mesh(module); -} - - -#endif -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.h deleted file mode 100644 index 60c8d3f93..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include "UEPyModule.h" - -#if WITH_EDITOR - -#if PLATFORM_LINUX -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wnull-dereference" -#pragma clang diagnostic warning "-Wshadow" -#endif -#endif - - -#include - -struct ue_PyFbxManager -{ - PyObject_HEAD - /* Type-specific fields go here. */ - FbxManager *fbx_manager; -}; - - -void ue_python_init_fbx_manager(PyObject *); - -ue_PyFbxManager *py_ue_is_fbx_manager(PyObject *); - -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.cpp deleted file mode 100644 index b54d12aa0..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.cpp +++ /dev/null @@ -1,203 +0,0 @@ - -#include "UEPyFbxMesh.h" - -#if WITH_EDITOR -#if ENGINE_MINOR_VERSION > 12 - -#include "UEPyFbx.h" - -static PyObject *py_ue_fbx_mesh_get_polygon_count(ue_PyFbxMesh *self, PyObject *args) -{ - return PyLong_FromLong(self->fbx_mesh->GetPolygonCount()); -} - -static PyObject *py_ue_fbx_mesh_get_control_points_count(ue_PyFbxMesh *self, PyObject *args) -{ - return PyLong_FromLong(self->fbx_mesh->GetControlPointsCount()); -} - -static PyObject *py_ue_fbx_mesh_get_polygon_vertex_count(ue_PyFbxMesh *self, PyObject *args) -{ - return PyLong_FromLong(self->fbx_mesh->GetPolygonVertexCount()); -} - -static PyObject *py_ue_fbx_mesh_get_name(ue_PyFbxMesh *self, PyObject *args) -{ - return PyUnicode_FromString(self->fbx_mesh->GetName()); -} - -static PyObject *py_ue_fbx_mesh_get_polygon_vertices(ue_PyFbxMesh *self, PyObject *args) -{ - PyObject *py_list = PyList_New(0); - int *indices = self->fbx_mesh->GetPolygonVertices(); - for (int i = 0; i < self->fbx_mesh->GetPolygonVertexCount(); i++) - { - PyList_Append(py_list, PyLong_FromLong(indices[i])); - } - return py_list; -} - -static PyObject *py_ue_fbx_mesh_get_control_points(ue_PyFbxMesh *self, PyObject *args) -{ - PyObject *py_list = PyList_New(0); - FbxVector4* control_points = self->fbx_mesh->GetControlPoints(); - for (int i = 0; i < self->fbx_mesh->GetControlPointsCount(); i++) - { - FbxVector4 vec4 = control_points[i]; - PyList_Append(py_list, py_ue_new_fvector(FVector(vec4[0], vec4[1], vec4[2]))); - } - return py_list; -} - -static PyObject *py_ue_fbx_mesh_get_polygon_vertex_normals(ue_PyFbxMesh *self, PyObject *args) -{ - - FbxArray normals; - - if (!self->fbx_mesh->GetPolygonVertexNormals(normals)) - { - Py_RETURN_NONE; - } - - PyObject *py_list = PyList_New(0); - - for (int i = 0; i < normals.Size(); i++) - { - FbxVector4 vec = normals.GetAt(i); - PyList_Append(py_list, py_ue_new_fvector(FVector(vec[0], vec[1], vec[2]))); - } - - return py_list; -} - -static PyObject *py_ue_fbx_mesh_get_uv_set_names(ue_PyFbxMesh *self, PyObject *args) -{ - PyObject *py_list = PyList_New(0); - FbxStringList name_list; - self->fbx_mesh->GetUVSetNames(name_list); - - for (int i = 0; i < name_list.GetCount(); i++) - { - PyList_Append(py_list, PyUnicode_FromString(name_list.GetStringAt(i))); - } - - return py_list; -} - -static PyObject *py_ue_fbx_mesh_get_polygon_vertex_uvs(ue_PyFbxMesh *self, PyObject *args) -{ - char *uv_set; - if (!PyArg_ParseTuple(args, "s", &uv_set)) - return nullptr; - - FbxArray uvs; - - if (!self->fbx_mesh->GetPolygonVertexUVs(uv_set, uvs)) - { - Py_RETURN_NONE; - } - - PyObject *py_list = PyList_New(0); - - for (int i = 0; i < uvs.Size(); i++) - { - FbxVector2 vec = uvs.GetAt(i); - PyList_Append(py_list, Py_BuildValue((char *)"(ff)", vec[0], vec[1])); - } - - return py_list; -} - -static PyObject *py_ue_fbx_mesh_remove_bad_polygons(ue_PyFbxMesh *self, PyObject *args) -{ - self->fbx_mesh->RemoveBadPolygons(); - Py_RETURN_NONE; -} - -static PyMethodDef ue_PyFbxMesh_methods[] = { - { "remove_bad_polygons", (PyCFunction)py_ue_fbx_mesh_remove_bad_polygons, METH_VARARGS, "" }, - { "get_polygon_count", (PyCFunction)py_ue_fbx_mesh_get_polygon_count, METH_VARARGS, "" }, - { "get_polygon_vertices", (PyCFunction)py_ue_fbx_mesh_get_polygon_vertices, METH_VARARGS, "" }, - { "get_polygon_vertex_count", (PyCFunction)py_ue_fbx_mesh_get_polygon_vertex_count, METH_VARARGS, "" }, - { "get_control_points_count", (PyCFunction)py_ue_fbx_mesh_get_control_points_count, METH_VARARGS, "" }, - { "get_control_points", (PyCFunction)py_ue_fbx_mesh_get_control_points, METH_VARARGS, "" }, - { "get_polygon_vertex_uvs", (PyCFunction)py_ue_fbx_mesh_get_polygon_vertex_uvs, METH_VARARGS, "" }, - { "get_uv_set_names", (PyCFunction)py_ue_fbx_mesh_get_uv_set_names, METH_VARARGS, "" }, - { "get_name", (PyCFunction)py_ue_fbx_mesh_get_name, METH_VARARGS, "" }, - { "get_polygon_vertex_normals", (PyCFunction)py_ue_fbx_mesh_get_polygon_vertex_normals, METH_VARARGS, "" }, - { NULL } /* Sentinel */ -}; - -static PyTypeObject ue_PyFbxMeshType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.FbxMesh", /* tp_name */ - sizeof(ue_PyFbxMesh), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Unreal Engine FbxMesh", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PyFbxMesh_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -}; - -static int py_ue_fbx_mesh_init(ue_PyFbxMesh *self, PyObject * args) -{ - PyObject *py_object; - char *name; - if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) - { - return -1; - } - - ue_PyFbxManager *py_fbx_manager = py_ue_is_fbx_manager(py_object); - if (!py_fbx_manager) - { - PyErr_SetString(PyExc_Exception, "argument is not a FbxManager"); - return -1; - } - - self->fbx_mesh = FbxMesh::Create(py_fbx_manager->fbx_manager, name); - return 0; -} - -void ue_python_init_fbx_mesh(PyObject *ue_module) -{ - ue_PyFbxMeshType.tp_new = PyType_GenericNew;; - ue_PyFbxMeshType.tp_init = (initproc)py_ue_fbx_mesh_init; - if (PyType_Ready(&ue_PyFbxMeshType) < 0) - return; - - Py_INCREF(&ue_PyFbxMeshType); - PyModule_AddObject(ue_module, "FbxMesh", (PyObject *)&ue_PyFbxMeshType); -} - -PyObject *py_ue_new_fbx_mesh(FbxMesh *fbx_mesh) -{ - ue_PyFbxMesh *ret = (ue_PyFbxMesh *)PyObject_New(ue_PyFbxMesh, &ue_PyFbxMeshType); - ret->fbx_mesh = fbx_mesh; - return (PyObject *)ret; -} - -#endif -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.h deleted file mode 100644 index 5e5d41594..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include "UEPyModule.h" - -#if WITH_EDITOR -#if ENGINE_MINOR_VERSION > 12 - -#if PLATFORM_LINUX -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wnull-dereference" -#endif -#endif - -#include - -struct ue_PyFbxMesh -{ - PyObject_HEAD - /* Type-specific fields go here. */ - FbxMesh *fbx_mesh; -}; - - -void ue_python_init_fbx_mesh(PyObject *); - -PyObject *py_ue_new_fbx_mesh(FbxMesh *); - -#endif -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.cpp deleted file mode 100644 index 976fe8602..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.cpp +++ /dev/null @@ -1,240 +0,0 @@ -#include "UEPyFbxNode.h" - -#if WITH_EDITOR -#if ENGINE_MINOR_VERSION > 12 - -#include "UEPyFbx.h" - - -static PyObject *py_ue_fbx_node_get_child_count(ue_PyFbxNode *self, PyObject *args) -{ - return PyLong_FromLong(self->fbx_node->GetChildCount()); -} - -static PyObject *py_ue_fbx_node_get_name(ue_PyFbxNode *self, PyObject *args) -{ - return PyUnicode_FromString(self->fbx_node->GetName()); -} - -static PyObject *py_ue_fbx_node_get_local_translation(ue_PyFbxNode *self, PyObject *args) -{ - FbxDouble3 fbx_vec = self->fbx_node->LclTranslation.Get(); - return py_ue_new_fvector(FVector(fbx_vec[0], fbx_vec[1], fbx_vec[2])); -} - -static PyObject *py_ue_fbx_node_get_local_rotation(ue_PyFbxNode *self, PyObject *args) -{ - FbxDouble3 fbx_vec = self->fbx_node->LclRotation.Get(); - return py_ue_new_fvector(FVector(fbx_vec[0], fbx_vec[1], fbx_vec[2])); -} - -static PyObject *py_ue_fbx_node_get_local_scaling(ue_PyFbxNode *self, PyObject *args) -{ - FbxDouble3 fbx_vec = self->fbx_node->LclScaling.Get(); - return py_ue_new_fvector(FVector(fbx_vec[0], fbx_vec[1], fbx_vec[2])); -} - -static PyObject *py_ue_fbx_node_get_child(ue_PyFbxNode *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxNode *fbx_node = self->fbx_node->GetChild(index); - if (!fbx_node) - { - return PyErr_Format(PyExc_Exception, "unable to retrieve FbxNode at index %d", index); - } - return py_ue_new_fbx_node(fbx_node); -} - -static PyObject *py_ue_fbx_node_get_parent(ue_PyFbxNode *self, PyObject *args) -{ - FbxNode *fbx_node = self->fbx_node->GetParent(); - if (!fbx_node) - { - return PyErr_Format(PyExc_Exception, "unable to retrieve FbxNode parent"); - } - return py_ue_new_fbx_node(fbx_node); -} - -static PyObject *py_ue_fbx_node_get_node_attribute(ue_PyFbxNode *self, PyObject *args) -{ - - FbxNodeAttribute *fbx_node_attribute = self->fbx_node->GetNodeAttribute(); - if (!fbx_node_attribute) - { - return PyErr_Format(PyExc_Exception, "unable to retrieve FbxNodeAttribute"); - } - return py_ue_new_fbx_object(fbx_node_attribute); -} - -static PyObject *py_ue_fbx_node_get_node_attribute_count(ue_PyFbxNode *self, PyObject *args) -{ - return PyLong_FromLong(self->fbx_node->GetNodeAttributeCount()); -} - -static PyObject *py_ue_fbx_node_get_node_attribute_by_index(ue_PyFbxNode *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxNodeAttribute *fbx_node_attribute = self->fbx_node->GetNodeAttributeByIndex(index); - if (!fbx_node_attribute) - { - return PyErr_Format(PyExc_Exception, "unable to retrieve FbxNodeAttribute at index %d", index); - } - return py_ue_new_fbx_object(fbx_node_attribute); -} - -static PyObject *py_ue_fbx_node_get_mesh(ue_PyFbxNode *self, PyObject *args) -{ - - FbxMesh *fbx_mesh = self->fbx_node->GetMesh(); - if (!fbx_mesh) - { - return PyErr_Format(PyExc_Exception, "unable to retrieve FbxMesh from FbxNode"); - } - return py_ue_new_fbx_mesh(fbx_mesh); -} - -static PyObject *py_ue_fbx_node_evaluate_local_transform(ue_PyFbxNode *self, PyObject *args) -{ - float t; - if (!PyArg_ParseTuple(args, "f", &t)) - { - return nullptr; - } - FbxTime time; - time.SetSecondDouble(t); - FbxAMatrix& matrix = self->fbx_node->EvaluateLocalTransform(time); - FTransform transform; - FbxVector4 mt = matrix.GetT(); - FbxQuaternion mq = matrix.GetQ(); - FbxVector4 ms = matrix.GetS(); - transform.SetTranslation(FVector(mt[0], -mt[1], mt[2])); - transform.SetRotation(FQuat(mq[0], -mq[1], mq[2], -mq[3])); - transform.SetScale3D(FVector(ms[0], ms[1], ms[2])); - return py_ue_new_ftransform(transform); -} - -static PyObject *py_ue_fbx_node_evaluate_global_transform(ue_PyFbxNode *self, PyObject *args) -{ - float t; - if (!PyArg_ParseTuple(args, "f", &t)) - { - return nullptr; - } - FbxTime time; - time.SetSecondDouble(t); - FbxAMatrix& matrix = self->fbx_node->EvaluateGlobalTransform(time); - FTransform transform; - FbxVector4 mt = matrix.GetT(); - FbxQuaternion mq = matrix.GetQ(); - FbxVector4 ms = matrix.GetS(); - transform.SetTranslation(FVector(mt[0], -mt[1], mt[2])); - transform.SetRotation(FQuat(mq[0], -mq[1], mq[2], -mq[3])); - transform.SetScale3D(FVector(ms[0], ms[1], ms[2])); - return py_ue_new_ftransform(transform); -} - -static PyMethodDef ue_PyFbxNode_methods[] = { - { "get_child_count", (PyCFunction)py_ue_fbx_node_get_child_count, METH_VARARGS, "" }, - { "get_name", (PyCFunction)py_ue_fbx_node_get_name, METH_VARARGS, "" }, - { "evaluate_local_transform", (PyCFunction)py_ue_fbx_node_evaluate_local_transform, METH_VARARGS, "" }, - { "evaluate_global_transform", (PyCFunction)py_ue_fbx_node_evaluate_global_transform, METH_VARARGS, "" }, - { "get_local_translation", (PyCFunction)py_ue_fbx_node_get_local_translation, METH_VARARGS, "" }, - { "get_local_rotation", (PyCFunction)py_ue_fbx_node_get_local_rotation, METH_VARARGS, "" }, - { "get_local_scaling", (PyCFunction)py_ue_fbx_node_get_local_scaling, METH_VARARGS, "" }, - { "get_child", (PyCFunction)py_ue_fbx_node_get_child, METH_VARARGS, "" }, - { "get_parent", (PyCFunction)py_ue_fbx_node_get_parent, METH_VARARGS, "" }, - { "get_node_attribute", (PyCFunction)py_ue_fbx_node_get_node_attribute, METH_VARARGS, "" }, - { "get_node_attribute_count", (PyCFunction)py_ue_fbx_node_get_node_attribute_count, METH_VARARGS, "" }, - { "get_node_attribute_by_index", (PyCFunction)py_ue_fbx_node_get_node_attribute_by_index, METH_VARARGS, "" }, - { "get_mesh", (PyCFunction)py_ue_fbx_node_get_mesh, METH_VARARGS, "" }, - { NULL } /* Sentinel */ -}; - -static PyTypeObject ue_PyFbxNodeType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.FbxNode", /* tp_name */ - sizeof(ue_PyFbxNode), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Unreal Engine FbxNode", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PyFbxNode_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -}; - -static int py_ue_fbx_node_init(ue_PyFbxNode *self, PyObject * args) -{ - PyObject *py_object; - char *name; - if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) - { - return -1; - } - - ue_PyFbxManager *py_fbx_manager = py_ue_is_fbx_manager(py_object); - if (!py_fbx_manager) - { - PyErr_SetString(PyExc_Exception, "argument is not a FbxManager"); - return -1; - } - - self->fbx_node = FbxNode::Create(py_fbx_manager->fbx_manager, name); - return 0; -} - -void ue_python_init_fbx_node(PyObject *ue_module) -{ - ue_PyFbxNodeType.tp_new = PyType_GenericNew;; - ue_PyFbxNodeType.tp_init = (initproc)py_ue_fbx_node_init; - if (PyType_Ready(&ue_PyFbxNodeType) < 0) - return; - - Py_INCREF(&ue_PyFbxNodeType); - PyModule_AddObject(ue_module, "FbxNode", (PyObject *)&ue_PyFbxNodeType); -} - -PyObject *py_ue_new_fbx_node(FbxNode *fbx_node) -{ - ue_PyFbxNode *ret = (ue_PyFbxNode *)PyObject_New(ue_PyFbxNode, &ue_PyFbxNodeType); - ret->fbx_node = fbx_node; - return (PyObject *)ret; -} - -ue_PyFbxNode *py_ue_is_fbx_node(PyObject *obj) -{ - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxNodeType)) - return nullptr; - return (ue_PyFbxNode *)obj; -} - -#endif -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.h deleted file mode 100644 index 276dc2487..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include "UEPyModule.h" - -#if WITH_EDITOR -#if ENGINE_MINOR_VERSION > 12 - -#if PLATFORM_LINUX -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wnull-dereference" -#endif -#endif - -#include - -struct ue_PyFbxNode -{ - PyObject_HEAD - /* Type-specific fields go here. */ - FbxNode *fbx_node; -}; - - -void ue_python_init_fbx_node(PyObject *); - -PyObject *py_ue_new_fbx_node(FbxNode *); - -ue_PyFbxNode *py_ue_is_fbx_node(PyObject *); - -#endif -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.cpp deleted file mode 100644 index a4937b7e3..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.cpp +++ /dev/null @@ -1,376 +0,0 @@ - -#include "UEPyFbxObject.h" - -#if ENGINE_MINOR_VERSION > 12 -#if WITH_EDITOR - -#include "UEPyFbx.h" - -#include "Runtime/Engine/Classes/Curves/RichCurve.h" - -static PyObject *py_ue_fbx_object_get_name(ue_PyFbxObject *self, PyObject *args) -{ - return PyUnicode_FromString(self->fbx_object->GetName()); -} - -static PyObject *py_ue_fbx_object_get_class_name(ue_PyFbxObject *self, PyObject *args) -{ - return PyUnicode_FromString(self->fbx_object->GetClassId().GetName()); -} - -static PyObject *py_ue_fbx_object_get_member_count(ue_PyFbxObject *self, PyObject *args) -{ - FbxCollection *fbx_collection = FbxCast(self->fbx_object); - if (!fbx_collection) - return PyErr_Format(PyExc_Exception, "unable to cast to FbxCollection"); - return PyLong_FromLong(fbx_collection->GetMemberCount()); -} - -static PyObject *py_ue_fbx_object_get_member(ue_PyFbxObject *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxCollection *fbx_collection = FbxCast(self->fbx_object); - if (!fbx_collection) - return PyErr_Format(PyExc_Exception, "unable to cast to FbxCollection"); - FbxObject *fbx_object = fbx_collection->GetMember(index); - if (!fbx_object) - return PyErr_Format(PyExc_Exception, "unable to find FbxObject with index %d", index); - return py_ue_new_fbx_object(fbx_collection->GetMember(index)); -} - -static PyObject *py_ue_fbx_object_get_next_property(ue_PyFbxObject *self, PyObject *args) -{ - PyObject *py_object; - if (!PyArg_ParseTuple(args, "O", &py_object)) - { - return nullptr; - } - - ue_PyFbxProperty *py_fbx_property = py_ue_is_fbx_property(py_object); - if (!py_fbx_property) - { - return PyErr_Format(PyExc_Exception, "argument is not a FbxProperty"); - } - - FbxProperty fbx_property = self->fbx_object->GetNextProperty(py_fbx_property->fbx_property); - if (!fbx_property.IsValid()) - Py_RETURN_NONE; - return py_ue_new_fbx_property(fbx_property); -} - -static PyObject *py_ue_fbx_object_get_first_property(ue_PyFbxObject *self, PyObject *args) -{ - FbxProperty fbx_property = self->fbx_object->GetFirstProperty(); - if (!fbx_property.IsValid()) - Py_RETURN_NONE; - return py_ue_new_fbx_property(fbx_property); -} - -static PyObject *py_ue_fbx_object_get_channels_count(ue_PyFbxObject *self, PyObject *args) -{ - FbxAnimCurveNode *fbx_anim_curve_node = FbxCast(self->fbx_object); - if (!fbx_anim_curve_node) - return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurveNode"); - return PyLong_FromLong(fbx_anim_curve_node->GetChannelsCount()); -} - -static PyObject *py_ue_fbx_object_to_node(ue_PyFbxObject *self, PyObject *args) -{ - FbxNode *fbx_node = FbxCast(self->fbx_object); - if (!fbx_node) - return PyErr_Format(PyExc_Exception, "object is not a FbxNode"); - return py_ue_new_fbx_node(fbx_node); -} - -static PyObject *py_ue_fbx_object_get_channel_name(ue_PyFbxObject *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxAnimCurveNode *fbx_anim_curve_node = FbxCast(self->fbx_object); - if (!fbx_anim_curve_node) - return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurveNode"); - return PyUnicode_FromString(fbx_anim_curve_node->GetChannelName(index)); -} - -static PyObject *py_ue_fbx_object_get_curve_count(ue_PyFbxObject *self, PyObject *args) -{ - int channel; - if (!PyArg_ParseTuple(args, "i", &channel)) - { - return nullptr; - } - FbxAnimCurveNode *fbx_anim_curve_node = FbxCast(self->fbx_object); - if (!fbx_anim_curve_node) - return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurveNode"); - return PyLong_FromLong(fbx_anim_curve_node->GetCurveCount(channel)); -} - -static PyObject *py_ue_fbx_object_get_curve(ue_PyFbxObject *self, PyObject *args) -{ - int channel; - int index = 0; - if (!PyArg_ParseTuple(args, "i|i:get_curve", &channel, &index)) - { - return nullptr; - } - FbxAnimCurveNode *fbx_anim_curve_node = FbxCast(self->fbx_object); - if (!fbx_anim_curve_node) - return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurveNode"); - FbxAnimCurve *fbx_anim_curve = fbx_anim_curve_node->GetCurve(channel, index); - if (!fbx_anim_curve) - Py_RETURN_NONE; - return py_ue_new_fbx_object(fbx_anim_curve_node->GetCurve(channel, index)); -} - -static PyObject *py_ue_fbx_object_key_get_count(ue_PyFbxObject *self, PyObject *args) -{ - FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); - if (!fbx_anim_curve) - return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurve"); - return PyLong_FromLong(fbx_anim_curve->KeyGetCount()); -} - -static PyObject *py_ue_fbx_object_key_get_value(ue_PyFbxObject *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); - if (!fbx_anim_curve) - return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurve"); - return PyFloat_FromDouble(fbx_anim_curve->KeyGetValue(index)); -} - -static PyObject *py_ue_fbx_object_key_get_seconds(ue_PyFbxObject *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); - if (!fbx_anim_curve) - return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurve"); - return PyFloat_FromDouble(fbx_anim_curve->KeyGetTime(index).GetSecondDouble()); -} - -static PyObject *py_ue_fbx_object_key_get_left_tangent(ue_PyFbxObject *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); - if (!fbx_anim_curve) - return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurve"); - return PyFloat_FromDouble(fbx_anim_curve->KeyGetLeftDerivative(index)); -} - -static PyObject *py_ue_fbx_object_key_get_right_tangent(ue_PyFbxObject *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); - if (!fbx_anim_curve) - return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurve"); - return PyFloat_FromDouble(fbx_anim_curve->KeyGetRightDerivative(index)); -} - -static PyObject *py_ue_fbx_object_key_get_interp_mode(ue_PyFbxObject *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); - if (!fbx_anim_curve) - return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurve"); - - ERichCurveInterpMode Mode = RCIM_Linear; - // Convert the interpolation type from FBX to Unreal. - switch (fbx_anim_curve->KeyGetInterpolation(index)) - { - case FbxAnimCurveDef::eInterpolationCubic: - Mode = RCIM_Cubic; - break; - - case FbxAnimCurveDef::eInterpolationConstant: - if (fbx_anim_curve->KeyGetTangentMode(index) != (FbxAnimCurveDef::ETangentMode)FbxAnimCurveDef::eConstantStandard) - { - // warning not support - ; - } - Mode = RCIM_Constant; - break; - - case FbxAnimCurveDef::eInterpolationLinear: - Mode = RCIM_Linear; - break; - } - - return PyLong_FromUnsignedLong(uint64(Mode)); -} - -static PyObject *py_ue_fbx_object_key_get_tangent_mode(ue_PyFbxObject *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); - if (!fbx_anim_curve) - return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurve"); - - ERichCurveTangentMode Mode = RCTM_Auto; - // Convert the interpolation type from FBX to Unreal. - if (fbx_anim_curve->KeyGetInterpolation(index) == - FbxAnimCurveDef::eInterpolationCubic) - { - switch (fbx_anim_curve->KeyGetTangentMode(index)) - { - // Auto tangents will now be imported as user tangents to allow the - // user to modify them without inadvertently resetting other tangents - // case KFbxAnimCurveDef::eTANGENT_AUTO: - // if ((KFbxAnimCurveDef::eTANGENT_GENERIC_CLAMP & FbxKey.GetTangentMode(true))) - // { - // Mode = CIM_CurveAutoClamped; - // } - // else - // { - // Mode = CIM_CurveAuto; - // } - // break; - case FbxAnimCurveDef::eTangentBreak: - Mode = RCTM_Break; - break; - case FbxAnimCurveDef::eTangentAuto: - Mode = RCTM_Auto; - break; - case FbxAnimCurveDef::eTangentUser: - case FbxAnimCurveDef::eTangentTCB: - Mode = RCTM_User; - break; - default: - break; - } - } - - return PyLong_FromUnsignedLong(uint64(Mode)); -} - -static PyMethodDef ue_PyFbxObject_methods[] = { - { "get_member_count", (PyCFunction)py_ue_fbx_object_get_member_count, METH_VARARGS, "" }, - { "get_member", (PyCFunction)py_ue_fbx_object_get_member, METH_VARARGS, "" }, - { "get_name", (PyCFunction)py_ue_fbx_object_get_name, METH_VARARGS, "" }, - { "to_node", (PyCFunction)py_ue_fbx_object_to_node, METH_VARARGS, "" }, - { "get_class_name", (PyCFunction)py_ue_fbx_object_get_class_name, METH_VARARGS, "" }, - { "get_first_property", (PyCFunction)py_ue_fbx_object_get_first_property, METH_VARARGS, "" }, - { "get_next_property", (PyCFunction)py_ue_fbx_object_get_next_property, METH_VARARGS, "" }, - { "get_channels_count", (PyCFunction)py_ue_fbx_object_get_channels_count, METH_VARARGS, "" }, - { "get_channel_name", (PyCFunction)py_ue_fbx_object_get_channel_name, METH_VARARGS, "" }, - { "get_curve_count", (PyCFunction)py_ue_fbx_object_get_curve_count, METH_VARARGS, "" }, - { "get_curve", (PyCFunction)py_ue_fbx_object_get_curve, METH_VARARGS, "" }, - { "key_get_count", (PyCFunction)py_ue_fbx_object_key_get_count, METH_VARARGS, "" }, - { "key_get_value", (PyCFunction)py_ue_fbx_object_key_get_value, METH_VARARGS, "" }, - { "key_get_seconds", (PyCFunction)py_ue_fbx_object_key_get_seconds, METH_VARARGS, "" }, - { "key_get_left_tangent", (PyCFunction)py_ue_fbx_object_key_get_left_tangent, METH_VARARGS, "" }, - { "key_get_right_tangent", (PyCFunction)py_ue_fbx_object_key_get_right_tangent, METH_VARARGS, "" }, - { "key_get_interp_mode", (PyCFunction)py_ue_fbx_object_key_get_interp_mode, METH_VARARGS, "" }, - { "key_get_tangent_mode", (PyCFunction)py_ue_fbx_object_key_get_tangent_mode, METH_VARARGS, "" }, - { NULL } /* Sentinel */ -}; - -static PyTypeObject ue_PyFbxObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.FbxObject", /* tp_name */ - sizeof(ue_PyFbxObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Unreal Engine FbxObject", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PyFbxObject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -}; - -static int py_ue_fbx_object_init(ue_PyFbxObject *self, PyObject * args) -{ - PyObject *py_object; - char *name; - if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) - { - return -1; - } - - ue_PyFbxManager *py_fbx_manager = py_ue_is_fbx_manager(py_object); - if (!py_fbx_manager) - { - PyErr_SetString(PyExc_Exception, "argument is not a FbxManager"); - return -1; - } - - self->fbx_object = FbxObject::Create(py_fbx_manager->fbx_manager, name); - return 0; -} - -void ue_python_init_fbx_object(PyObject *ue_module) -{ - ue_PyFbxObjectType.tp_new = PyType_GenericNew;; - ue_PyFbxObjectType.tp_init = (initproc)py_ue_fbx_object_init; - if (PyType_Ready(&ue_PyFbxObjectType) < 0) - return; - - Py_INCREF(&ue_PyFbxObjectType); - PyModule_AddObject(ue_module, "FbxObject", (PyObject *)&ue_PyFbxObjectType); -} - -PyObject *py_ue_new_fbx_object(FbxObject *fbx_object) -{ - ue_PyFbxObject *ret = (ue_PyFbxObject *)PyObject_New(ue_PyFbxObject, &ue_PyFbxObjectType); - ret->fbx_object = fbx_object; - return (PyObject *)ret; -} - -ue_PyFbxObject *py_ue_is_fbx_object(PyObject *obj) -{ - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxObjectType)) - return nullptr; - return (ue_PyFbxObject *)obj; -} -#endif -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.h deleted file mode 100644 index 0b80931ce..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include "UEPyModule.h" - -#if WITH_EDITOR - - -#if PLATFORM_LINUX -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wnull-dereference" -#endif -#endif - -#include - -struct ue_PyFbxObject { - PyObject_HEAD - /* Type-specific fields go here. */ - FbxObject *fbx_object; -}; - - -void ue_python_init_fbx_object(PyObject *); - -PyObject *py_ue_new_fbx_object(FbxObject *); - -ue_PyFbxObject *py_ue_is_fbx_object(PyObject *); - -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.cpp deleted file mode 100644 index 6d0390297..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.cpp +++ /dev/null @@ -1,174 +0,0 @@ -#include "UEPyFbxPose.h" - -#if ENGINE_MINOR_VERSION > 12 - -#if WITH_EDITOR - -#include "UEPyFbx.h" - -static PyObject *py_ue_fbx_pose_get_count(ue_PyFbxPose *self, PyObject *args) -{ - return PyLong_FromLong(self->fbx_pose->GetCount()); -} - -static PyObject *py_ue_fbx_pose_get_name(ue_PyFbxPose *self, PyObject *args) -{ - return PyUnicode_FromString(self->fbx_pose->GetName()); -} - -static PyObject *py_ue_fbx_pose_is_bind_pose(ue_PyFbxPose *self, PyObject *args) -{ - if (self->fbx_pose->IsBindPose()) - { - Py_RETURN_TRUE; - } - Py_RETURN_FALSE; -} - -static PyObject *py_ue_fbx_pose_is_rest_pose(ue_PyFbxPose *self, PyObject *args) -{ - if (self->fbx_pose->IsRestPose()) - { - Py_RETURN_TRUE; - } - Py_RETURN_FALSE; -} - -static PyObject *py_ue_fbx_pose_get_node(ue_PyFbxPose *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxNode *fbx_node = self->fbx_pose->GetNode(index); - if (!fbx_node) - { - return PyErr_Format(PyExc_Exception, "unable to retrieve FbxNode at index %d", index); - } - return py_ue_new_fbx_node(fbx_node); -} - -static PyObject *py_ue_fbx_pose_find(ue_PyFbxPose *self, PyObject *args) -{ - PyObject *py_obj; - if (!PyArg_ParseTuple(args, "O", &py_obj)) - { - return nullptr; - } - - ue_PyFbxNode *py_node = py_ue_is_fbx_node(py_obj); - if (!py_node) - return PyErr_Format(PyExc_Exception, "argument is not a FbxNode"); - - int index = self->fbx_pose->Find(py_node->fbx_node); - if (index < 0) - return PyErr_Format(PyExc_Exception, "unable to retrieve FbxNode index from FbxPose"); - - return PyLong_FromLong(index); -} - -static PyObject *py_ue_fbx_pose_get_transform(ue_PyFbxPose *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - - FbxMatrix fbx_matrix = self->fbx_pose->GetMatrix(index); - FbxAMatrix matrix = *(FbxAMatrix *)&fbx_matrix; - FTransform transform; - FbxVector4 mt = matrix.GetT(); - FbxQuaternion mq = matrix.GetQ(); - FbxVector4 ms = matrix.GetS(); - transform.SetTranslation(FVector(mt[0], -mt[1], mt[2])); - transform.SetRotation(FQuat(mq[0], -mq[1], mq[2], -mq[3])); - transform.SetScale3D(FVector(ms[0], ms[1], ms[2])); - return py_ue_new_ftransform(transform); -} - -static PyMethodDef ue_PyFbxPose_methods[] = { - { "get_count", (PyCFunction)py_ue_fbx_pose_get_count, METH_VARARGS, "" }, - { "get_name", (PyCFunction)py_ue_fbx_pose_get_name, METH_VARARGS, "" }, - { "get_node", (PyCFunction)py_ue_fbx_pose_get_node, METH_VARARGS, "" }, - { "is_bind_pose", (PyCFunction)py_ue_fbx_pose_is_bind_pose, METH_VARARGS, "" }, - { "is_rest_pose", (PyCFunction)py_ue_fbx_pose_is_rest_pose, METH_VARARGS, "" }, - { "find", (PyCFunction)py_ue_fbx_pose_find, METH_VARARGS, "" }, - { "get_transform", (PyCFunction)py_ue_fbx_pose_get_transform, METH_VARARGS, "" }, - { NULL } /* Sentinel */ -}; - -static PyTypeObject ue_PyFbxPoseType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.FbxPose", /* tp_name */ - sizeof(ue_PyFbxPose), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Unreal Engine FbxPose", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PyFbxPose_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -}; - -static int py_ue_fbx_pose_init(ue_PyFbxPose *self, PyObject * args) -{ - PyObject *py_object; - char *name; - if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) - { - return -1; - } - - ue_PyFbxManager *py_fbx_manager = py_ue_is_fbx_manager(py_object); - if (!py_fbx_manager) - { - PyErr_SetString(PyExc_Exception, "argument is not a FbxManager"); - return -1; - } - - self->fbx_pose = FbxPose::Create(py_fbx_manager->fbx_manager, name); - return 0; -} - -void ue_python_init_fbx_pose(PyObject *ue_module) -{ - ue_PyFbxPoseType.tp_new = PyType_GenericNew;; - ue_PyFbxPoseType.tp_init = (initproc)py_ue_fbx_pose_init; - if (PyType_Ready(&ue_PyFbxPoseType) < 0) - return; - - Py_INCREF(&ue_PyFbxPoseType); - PyModule_AddObject(ue_module, "FbxPose", (PyObject *)&ue_PyFbxPoseType); -} - -PyObject *py_ue_new_fbx_pose(FbxPose *fbx_pose) -{ - ue_PyFbxPose *ret = (ue_PyFbxPose *)PyObject_New(ue_PyFbxPose, &ue_PyFbxPoseType); - ret->fbx_pose = fbx_pose; - return (PyObject *)ret; -} - -#endif -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.h deleted file mode 100644 index 7d0f1a163..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "UEPyModule.h" - -#if WITH_EDITOR - -#if PLATFORM_LINUX -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wnull-dereference" -#endif -#endif - -#include - -struct ue_PyFbxPose -{ - PyObject_HEAD - /* Type-specific fields go here. */ - FbxPose *fbx_pose; -}; - - -void ue_python_init_fbx_pose(PyObject *); - -PyObject *py_ue_new_fbx_pose(FbxPose *); - -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.cpp deleted file mode 100644 index 37eaa2a2a..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "UEPyFbxProperty.h" - -#if ENGINE_MINOR_VERSION > 12 -#if WITH_EDITOR - -#include "UEPyFbx.h" - -static PyObject *py_ue_fbx_property_get_name(ue_PyFbxProperty *self, PyObject *args) -{ - return PyUnicode_FromString(self->fbx_property.GetName()); -} - -static PyObject *py_ue_fbx_property_get_double3(ue_PyFbxProperty *self, PyObject *args) -{ - FbxDouble3 value = self->fbx_property.Get(); - return Py_BuildValue((char *)"(fff)", value[0], value[1], value[2]); -} - -static PyObject *py_ue_fbx_property_get_string(ue_PyFbxProperty *self, PyObject *args) -{ - return PyUnicode_FromString(self->fbx_property.Get()); -} - -static PyObject *py_ue_fbx_property_is_valid(ue_PyFbxProperty *self, PyObject *args) -{ - if (self->fbx_property.IsValid()) - { - Py_RETURN_TRUE; - } - Py_RETURN_FALSE; -} - -static PyObject *py_ue_fbx_property_get_curve_node(ue_PyFbxProperty *self, PyObject *args) -{ - PyObject *py_object; - if (!PyArg_ParseTuple(args, "O", &py_object)) - { - return nullptr; - } - - ue_PyFbxObject *py_fbx_object = py_ue_is_fbx_object(py_object); - if (!py_fbx_object) - return PyErr_Format(PyExc_Exception, "argument is not a FbxObject"); - - FbxAnimLayer *fbx_anim_layer = FbxCast(py_fbx_object->fbx_object); - if (!fbx_anim_layer) - return PyErr_Format(PyExc_Exception, "argument is not a FbxAnimLayer"); - - FbxAnimCurveNode *fbx_anim_curve_node = self->fbx_property.GetCurveNode(fbx_anim_layer); - if (!fbx_anim_curve_node) - Py_RETURN_NONE; - return py_ue_new_fbx_object(fbx_anim_curve_node); -} - -static PyObject *py_ue_fbx_property_get_bool(ue_PyFbxProperty *self, PyObject *args) -{ - if (self->fbx_property.Get()) - Py_RETURN_TRUE; - - Py_RETURN_FALSE; - -} - -static PyObject *py_ue_fbx_property_get_int(ue_PyFbxProperty *self, PyObject *args) -{ - return PyLong_FromLong(self->fbx_property.Get()); - -} - - -static PyMethodDef ue_PyFbxProperty_methods[] = { - { "get_name", (PyCFunction)py_ue_fbx_property_get_name, METH_VARARGS, "" }, - { "get_double3", (PyCFunction)py_ue_fbx_property_get_double3, METH_VARARGS, "" }, - { "get_string", (PyCFunction)py_ue_fbx_property_get_string, METH_VARARGS, "" }, - { "get_bool", (PyCFunction)py_ue_fbx_property_get_bool, METH_VARARGS, "" }, - { "get_int", (PyCFunction)py_ue_fbx_property_get_int, METH_VARARGS, "" }, - { "is_valid", (PyCFunction)py_ue_fbx_property_is_valid, METH_VARARGS, "" }, - { "get_curve_node", (PyCFunction)py_ue_fbx_property_get_curve_node, METH_VARARGS, "" }, - { NULL } /* Sentinel */ -}; - -static PyTypeObject ue_PyFbxPropertyType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.FbxProperty", /* tp_name */ - sizeof(ue_PyFbxProperty), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Unreal Engine FbxProperty", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PyFbxProperty_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -}; - -static int py_ue_fbx_property_init(ue_PyFbxProperty *self, PyObject * args) -{ - PyErr_SetString(PyExc_Exception, "instantiating a new FbxProperty is currently not supported"); - return -1; -} - -void ue_python_init_fbx_property(PyObject *ue_module) -{ - ue_PyFbxPropertyType.tp_new = PyType_GenericNew;; - ue_PyFbxPropertyType.tp_init = (initproc)py_ue_fbx_property_init; - if (PyType_Ready(&ue_PyFbxPropertyType) < 0) - return; - - Py_INCREF(&ue_PyFbxPropertyType); - PyModule_AddObject(ue_module, "FbxProperty", (PyObject *)&ue_PyFbxPropertyType); -} - -PyObject *py_ue_new_fbx_property(FbxProperty fbx_property) -{ - ue_PyFbxProperty *ret = (ue_PyFbxProperty *)PyObject_New(ue_PyFbxProperty, &ue_PyFbxPropertyType); - ret->fbx_property = fbx_property; - return (PyObject *)ret; -} - -ue_PyFbxProperty *py_ue_is_fbx_property(PyObject *obj) -{ - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxPropertyType)) - return nullptr; - return (ue_PyFbxProperty *)obj; -} -#endif -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.h deleted file mode 100644 index 225f967f9..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "UEPyModule.h" - -#if WITH_EDITOR - -#if PLATFORM_LINUX -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wnull-dereference" -#endif -#endif - -#include - -struct ue_PyFbxProperty { - PyObject_HEAD - /* Type-specific fields go here. */ - FbxProperty fbx_property; -}; - - -void ue_python_init_fbx_property(PyObject *); - -PyObject *py_ue_new_fbx_property(FbxProperty); - -ue_PyFbxProperty *py_ue_is_fbx_property(PyObject *); -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.cpp deleted file mode 100644 index 8fd9ca67c..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include "UEPyFbxScene.h" -#if ENGINE_MINOR_VERSION > 12 - - -#if WITH_EDITOR - -#include "UEPyFbx.h" - -static PyObject *py_ue_fbx_scene_get_root_node(ue_PyFbxScene *self, PyObject *args) -{ - FbxNode *fbx_node = self->fbx_scene->GetRootNode(); - if (!fbx_node) - { - return PyErr_Format(PyExc_Exception, "unable to get RootNode from FbxScene"); - } - - return py_ue_new_fbx_node(fbx_node); -} - -static PyObject *py_ue_fbx_scene_get_src_object_count(ue_PyFbxScene *self, PyObject *args) -{ - return PyLong_FromLong(self->fbx_scene->GetSrcObjectCount()); -} - -static PyObject *py_ue_fbx_scene_get_pose_count(ue_PyFbxScene *self, PyObject *args) -{ - return PyLong_FromLong(self->fbx_scene->GetPoseCount()); -} - -static PyObject *py_ue_fbx_scene_get_src_object(ue_PyFbxScene *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxObject *fbx_object = self->fbx_scene->GetSrcObject(index); - if (!fbx_object) - return PyErr_Format(PyExc_Exception, "unable to find FbxObject with index %d", index); - - return py_ue_new_fbx_object(fbx_object); -} - -static PyObject *py_ue_fbx_scene_get_pose(ue_PyFbxScene *self, PyObject *args) -{ - int index; - if (!PyArg_ParseTuple(args, "i", &index)) - { - return nullptr; - } - FbxPose *fbx_pose = self->fbx_scene->GetPose(index); - if (!fbx_pose) - return PyErr_Format(PyExc_Exception, "unable to find FbxPose with index %d", index); - - return py_ue_new_fbx_pose(fbx_pose); -} - -static PyObject *py_ue_fbx_scene_convert(ue_PyFbxScene *self, PyObject *args) -{ - FbxScene *scene = self->fbx_scene; - - FbxAxisSystem::ECoordSystem coord_system = FbxAxisSystem::eRightHanded; - FbxAxisSystem::EUpVector up_vector = FbxAxisSystem::eZAxis; - FbxAxisSystem::EFrontVector front_vector = (FbxAxisSystem::EFrontVector) - FbxAxisSystem::eParityOdd; - - FbxAxisSystem unreal(up_vector, front_vector, coord_system); - - if (scene->GetGlobalSettings().GetAxisSystem() != unreal) - { - FbxRootNodeUtility::RemoveAllFbxRoots(scene); - unreal.ConvertScene(scene); - } - - scene->GetAnimationEvaluator()->Reset(); - - Py_RETURN_NONE; -} - -static PyObject *py_ue_fbx_scene_triangulate(ue_PyFbxScene *self, PyObject *args) -{ - FbxScene *scene = self->fbx_scene; - - FbxGeometryConverter converter(scene->GetFbxManager()); - - if (converter.Triangulate(scene, true)) - { - Py_RETURN_TRUE; - } - - Py_RETURN_FALSE; -} - -static PyMethodDef ue_PyFbxScene_methods[] = { - { "convert", (PyCFunction)py_ue_fbx_scene_convert, METH_VARARGS, "" }, - { "triangulate", (PyCFunction)py_ue_fbx_scene_triangulate, METH_VARARGS, "" }, - { "get_root_node", (PyCFunction)py_ue_fbx_scene_get_root_node, METH_VARARGS, "" }, - { "get_src_object_count", (PyCFunction)py_ue_fbx_scene_get_src_object_count, METH_VARARGS, "" }, - { "get_src_object", (PyCFunction)py_ue_fbx_scene_get_src_object, METH_VARARGS, "" }, - { "get_pose_count", (PyCFunction)py_ue_fbx_scene_get_pose_count, METH_VARARGS, "" }, - { "get_pose", (PyCFunction)py_ue_fbx_scene_get_pose, METH_VARARGS, "" }, - { NULL } /* Sentinel */ -}; - -static PyTypeObject ue_PyFbxSceneType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.FbxScene", /* tp_name */ - sizeof(ue_PyFbxScene), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Unreal Engine FbxScene", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PyFbxScene_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ -}; - -static int py_ue_fbx_scene_init(ue_PyFbxScene *self, PyObject * args) -{ - PyObject *py_object; - char *name; - if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) - { - return -1; - } - - ue_PyFbxManager *py_fbx_manager = py_ue_is_fbx_manager(py_object); - if (!py_fbx_manager) - { - PyErr_SetString(PyExc_Exception, "argument is not a FbxManager"); - return -1; - } - - self->fbx_scene = FbxScene::Create(py_fbx_manager->fbx_manager, name); - return 0; -} - -void ue_python_init_fbx_scene(PyObject *ue_module) -{ - ue_PyFbxSceneType.tp_new = PyType_GenericNew;; - ue_PyFbxSceneType.tp_init = (initproc)py_ue_fbx_scene_init; - if (PyType_Ready(&ue_PyFbxSceneType) < 0) - return; - - Py_INCREF(&ue_PyFbxSceneType); - PyModule_AddObject(ue_module, "FbxScene", (PyObject *)&ue_PyFbxSceneType); -} - -ue_PyFbxScene *py_ue_is_fbx_scene(PyObject *obj) -{ - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxSceneType)) - return nullptr; - return (ue_PyFbxScene *)obj; -} - -#endif -#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.h deleted file mode 100644 index 761c35a8f..000000000 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include "UEPyModule.h" - -#if WITH_EDITOR - -#if PLATFORM_LINUX -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wnull-dereference" -#endif -#endif - -#include - -struct ue_PyFbxScene { - PyObject_HEAD - /* Type-specific fields go here. */ - FbxScene *fbx_scene; -}; - - -void ue_python_init_fbx_scene(PyObject *); - -ue_PyFbxScene *py_ue_is_fbx_scene(PyObject *); - -#endif diff --git a/Source/UnrealEnginePython/Private/PythonComponent.cpp b/Source/UnrealEnginePython/Private/PythonComponent.cpp index 11082d6ac..03c817133 100644 --- a/Source/UnrealEnginePython/Private/PythonComponent.cpp +++ b/Source/UnrealEnginePython/Private/PythonComponent.cpp @@ -17,6 +17,7 @@ UPythonComponent::UPythonComponent() bWantsInitializeComponent = true; + py_component_module = nullptr; py_generator = nullptr; } @@ -34,22 +35,27 @@ void UPythonComponent::InitializePythonComponent() return; } - PyObject *py_component_module = PyImport_ImportModule(TCHAR_TO_UTF8(*PythonModule)); - if (!py_component_module) + if (py_component_module == nullptr) { - unreal_engine_py_log_error(); - return; + py_component_module = PyImport_ImportModule(TCHAR_TO_UTF8(*PythonModule)); + if (!py_component_module) + { + unreal_engine_py_log_error(); + return; + } } - -#if WITH_EDITOR - // todo implement autoreload with a dictionary of module timestamps - py_component_module = PyImport_ReloadModule(py_component_module); - if (!py_component_module) + else { - unreal_engine_py_log_error(); - return; - } +#if WITH_EDITOR + // todo implement autoreload with a dictionary of module timestamps + py_component_module = PyImport_ReloadModule(py_component_module); + if (!py_component_module) + { + unreal_engine_py_log_error(); + return; + } #endif + } if (PythonClass.IsEmpty()) return; diff --git a/Source/UnrealEnginePython/Private/UEPyModule.cpp b/Source/UnrealEnginePython/Private/UEPyModule.cpp index 1c56a47c1..17032f4bb 100644 --- a/Source/UnrealEnginePython/Private/UEPyModule.cpp +++ b/Source/UnrealEnginePython/Private/UEPyModule.cpp @@ -50,7 +50,7 @@ #if WITH_EDITOR #include "UEPyEditor.h" #include "Blueprint/UEPyEdGraph.h" -#include "Fbx/UEPyFbx.h" +// #include "Fbx/UEPyFbx.h" #include "Editor/BlueprintGraph/Classes/EdGraphSchema_K2.h" #include "Editor/BlueprintGraph/Public/BlueprintActionDatabase.h" #endif @@ -2128,7 +2128,7 @@ void unreal_engine_init_py_module() ue_python_init_edgraphpin(new_unreal_engine_module); ue_python_init_fstring_asset_reference(new_unreal_engine_module); #if ENGINE_MINOR_VERSION > 12 - ue_python_init_fbx(new_unreal_engine_module); + // ue_python_init_fbx(new_unreal_engine_module); #endif #if ENGINE_MINOR_VERSION > 13 #if ENGINE_MINOR_VERSION > 21 @@ -4468,7 +4468,8 @@ PyObject* ue_bind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* py_ #if ENGINE_MINOR_VERSION < 23 FMulticastScriptDelegate multiscript_delegate = casted_prop->GetPropertyValue_InContainer(u_obj->ue_object); #else - FMulticastScriptDelegate multiscript_delegate = *casted_prop->GetMulticastDelegate(u_obj->ue_object); + //FMulticastScriptDelegate multiscript_delegate = *casted_prop->GetMulticastDelegate(u_obj->ue_object); + FMulticastScriptDelegate multiscript_delegate = *casted_prop->GetMulticastDelegate(casted_prop->ContainerPtrToValuePtr(u_obj->ue_object)); #endif FScriptDelegate script_delegate; @@ -4488,7 +4489,8 @@ PyObject* ue_bind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* py_ #if ENGINE_MINOR_VERSION < 23 casted_prop->SetPropertyValue_InContainer(u_obj->ue_object, multiscript_delegate); #else - casted_prop->SetMulticastDelegate(u_obj->ue_object, multiscript_delegate); + //casted_prop->SetMulticastDelegate(u_obj->ue_object, multiscript_delegate); + casted_prop->SetMulticastDelegate(casted_prop->ContainerPtrToValuePtr(u_obj->ue_object), multiscript_delegate); #endif } #if ENGINE_MINOR_VERSION >= 25 diff --git a/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp b/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp index 742d38037..e3ec2a341 100644 --- a/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp +++ b/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp @@ -367,7 +367,7 @@ void FUnrealEnginePythonModule::StartupModule() IniValue.ParseIntoArray(ImportModules, separators, 3); } - FString ProjectScriptsPath = FPaths::Combine(*PROJECT_CONTENT_DIR, UTF8_TO_TCHAR("Scripts")); + FString ProjectScriptsPath = FPaths::Combine(*PROJECT_CONTENT_DIR, UTF8_TO_TCHAR("Python")); if (!FPaths::DirectoryExists(ProjectScriptsPath)) { FPlatformFileManager::Get().GetPlatformFile().CreateDirectory(*ProjectScriptsPath); @@ -377,7 +377,7 @@ void FUnrealEnginePythonModule::StartupModule() #if WITH_EDITOR for (TSharedRefplugin : IPluginManager::Get().GetEnabledPlugins()) { - FString PluginScriptsPath = FPaths::Combine(plugin->GetContentDir(), UTF8_TO_TCHAR("Scripts")); + FString PluginScriptsPath = FPaths::Combine(plugin->GetContentDir(), UTF8_TO_TCHAR("Python")); if (FPaths::DirectoryExists(PluginScriptsPath)) { ScriptsPaths.Add(PluginScriptsPath); diff --git a/Source/UnrealEnginePython/Public/PythonComponent.h b/Source/UnrealEnginePython/Public/PythonComponent.h index 1f8a13dc1..21c8b5f47 100644 --- a/Source/UnrealEnginePython/Public/PythonComponent.h +++ b/Source/UnrealEnginePython/Public/PythonComponent.h @@ -90,6 +90,8 @@ class UNREALENGINEPYTHON_API UPythonComponent : public UActorComponent private: PyObject * py_component_instance; + PyObject * py_component_module; + // mapped uobject, required for debug and advanced reflection ue_PyUObject *py_uobject;