|
2 | 2 |
|
3 | 3 | #include "UnrealEnginePythonPrivatePCH.h" |
4 | 4 |
|
5 | | -PyObject *py_ue_set_scalar_parameter( ue_PyUObject *self , PyObject * args ) { |
| 5 | +PyObject *py_ue_set_scalar_parameter(ue_PyUObject *self, PyObject * args) { |
6 | 6 |
|
7 | | - ue_py_check( self ); |
| 7 | + ue_py_check(self); |
8 | 8 |
|
9 | | - if ( !self->ue_object->IsA<UMaterialInstanceConstant>() ) { |
10 | | - return PyErr_Format( PyExc_Exception, "uobject is not a UMaterialInstanceConstant" ); |
11 | | - } |
| 9 | + if (!self->ue_object->IsA<UMaterialInstanceConstant>()) { |
| 10 | + return PyErr_Format(PyExc_Exception, "uobject is not a UMaterialInstanceConstant"); |
| 11 | + } |
12 | 12 |
|
13 | | - char *scalarName = nullptr; |
14 | | - float scalarValue = 0; |
15 | | - if ( !PyArg_ParseTuple( args, "sf:set_scalar_parameter", &scalarName, &scalarValue ) ) { |
16 | | - return NULL; |
17 | | - } |
| 13 | + char *scalarName = nullptr; |
| 14 | + float scalarValue = 0; |
| 15 | + if (!PyArg_ParseTuple(args, "sf:set_scalar_parameter", &scalarName, &scalarValue)) { |
| 16 | + return NULL; |
| 17 | + } |
18 | 18 |
|
19 | | - UMaterialInstanceConstant *material_instance = (UMaterialInstanceConstant *)self->ue_object; |
| 19 | + UMaterialInstanceConstant *material_instance = (UMaterialInstanceConstant *)self->ue_object; |
20 | 20 |
|
21 | | - FName parameterName(UTF8_TO_TCHAR( scalarName )); |
22 | | - material_instance->SetScalarParameterValueEditorOnly( parameterName, scalarValue ); |
| 21 | + FName parameterName(UTF8_TO_TCHAR(scalarName)); |
| 22 | + material_instance->SetScalarParameterValueEditorOnly(parameterName, scalarValue); |
23 | 23 |
|
24 | | - Py_INCREF( Py_None ); |
25 | | - return Py_None; |
| 24 | + Py_INCREF(Py_None); |
| 25 | + return Py_None; |
26 | 26 |
|
27 | 27 | } |
28 | 28 |
|
29 | | -PyObject *py_ue_set_vector_parameter( ue_PyUObject *self, PyObject * args ) { |
30 | | - ue_py_check( self ); |
| 29 | +PyObject *py_ue_set_vector_parameter(ue_PyUObject *self, PyObject * args) { |
| 30 | + ue_py_check(self); |
31 | 31 |
|
32 | | - if ( !self->ue_object->IsA<UMaterialInstanceConstant>() ) { |
33 | | - return PyErr_Format( PyExc_Exception, "uobject is not a UMaterialInstanceConstant" ); |
34 | | - } |
| 32 | + if (!self->ue_object->IsA<UMaterialInstanceConstant>()) { |
| 33 | + return PyErr_Format(PyExc_Exception, "uobject is not a UMaterialInstanceConstant"); |
| 34 | + } |
35 | 35 |
|
36 | | - char *vectorName; |
37 | | - PyObject *vectorValue = nullptr; |
38 | | - if ( !PyArg_ParseTuple( args, "sO:set_vector_parameter", &vectorName, &vectorValue ) ) { |
39 | | - return NULL; |
40 | | - } |
| 36 | + char *vectorName; |
| 37 | + PyObject *vectorValue = nullptr; |
| 38 | + if (!PyArg_ParseTuple(args, "sO:set_vector_parameter", &vectorName, &vectorValue)) { |
| 39 | + return NULL; |
| 40 | + } |
41 | 41 |
|
42 | | - FVector vectorParameter( 0, 0, 0 ); |
| 42 | + FVector vectorParameter(0, 0, 0); |
43 | 43 |
|
44 | | - if ( vectorValue ) { |
45 | | - ue_PyFVector *py_vector = py_ue_is_fvector( vectorValue ); |
46 | | - if ( !py_vector ) |
47 | | - return PyErr_Format( PyExc_Exception, "argument must be an FVector" ); |
48 | | - vectorParameter = py_vector->vec; |
49 | | - } |
| 44 | + if (vectorValue) { |
| 45 | + ue_PyFVector *py_vector = py_ue_is_fvector(vectorValue); |
| 46 | + if (!py_vector) |
| 47 | + return PyErr_Format(PyExc_Exception, "argument must be an FVector"); |
| 48 | + vectorParameter = py_vector->vec; |
| 49 | + } |
50 | 50 |
|
51 | | - UMaterialInstanceConstant *material_instance = (UMaterialInstanceConstant *)self->ue_object; |
| 51 | + UMaterialInstanceConstant *material_instance = (UMaterialInstanceConstant *)self->ue_object; |
52 | 52 |
|
53 | | - FName parameterName( UTF8_TO_TCHAR( vectorName ) ); |
54 | | - material_instance->SetVectorParameterValueEditorOnly( parameterName, FLinearColor( vectorParameter) ); |
| 53 | + FName parameterName(UTF8_TO_TCHAR(vectorName)); |
| 54 | + material_instance->SetVectorParameterValueEditorOnly(parameterName, FLinearColor(vectorParameter)); |
55 | 55 |
|
56 | | - Py_INCREF( Py_None ); |
57 | | - return Py_None; |
| 56 | + Py_INCREF(Py_None); |
| 57 | + return Py_None; |
58 | 58 |
|
59 | 59 |
|
60 | 60 | } |
61 | | -PyObject *py_ue_set_texture_parameter( ue_PyUObject *self, PyObject * args ) { |
62 | | - ue_py_check( self ); |
| 61 | +PyObject *py_ue_set_texture_parameter(ue_PyUObject *self, PyObject * args) { |
| 62 | + ue_py_check(self); |
63 | 63 |
|
64 | | - if ( !self->ue_object->IsA<UMaterialInstanceConstant>() ) { |
65 | | - return PyErr_Format( PyExc_Exception, "uobject is not a UMaterialInstanceConstant" ); |
66 | | - } |
| 64 | + if (!self->ue_object->IsA<UMaterialInstanceConstant>()) { |
| 65 | + return PyErr_Format(PyExc_Exception, "uobject is not a UMaterialInstanceConstant"); |
| 66 | + } |
67 | 67 |
|
68 | | - char *textureName; |
69 | | - PyObject *textureObject = nullptr; |
70 | | - if ( !PyArg_ParseTuple( args, "sO:set_texture_parameter", &textureName, &textureObject ) ) { |
71 | | - return NULL; |
72 | | - } |
| 68 | + char *textureName; |
| 69 | + PyObject *textureObject = nullptr; |
| 70 | + if (!PyArg_ParseTuple(args, "sO:set_texture_parameter", &textureName, &textureObject)) { |
| 71 | + return NULL; |
| 72 | + } |
73 | 73 |
|
74 | | - if ( !ue_is_pyuobject( textureObject ) ) { |
75 | | - return PyErr_Format( PyExc_Exception, "argument is not a UObject" ); |
76 | | - } |
| 74 | + if (!ue_is_pyuobject(textureObject)) { |
| 75 | + return PyErr_Format(PyExc_Exception, "argument is not a UObject"); |
| 76 | + } |
77 | 77 |
|
78 | | - ue_PyUObject *py_obj = (ue_PyUObject *)textureObject; |
79 | | - if ( !py_obj->ue_object->IsA<UTexture>() ) |
80 | | - return PyErr_Format( PyExc_Exception, "uobject is not a UTexture" ); |
| 78 | + ue_PyUObject *py_obj = (ue_PyUObject *)textureObject; |
| 79 | + if (!py_obj->ue_object->IsA<UTexture>()) |
| 80 | + return PyErr_Format(PyExc_Exception, "uobject is not a UTexture"); |
81 | 81 |
|
82 | | - UTexture *ue_texture = (UTexture *)py_obj->ue_object; |
| 82 | + UTexture *ue_texture = (UTexture *)py_obj->ue_object; |
83 | 83 |
|
84 | | - UMaterialInstanceConstant *material_instance = (UMaterialInstanceConstant *)self->ue_object; |
| 84 | + UMaterialInstanceConstant *material_instance = (UMaterialInstanceConstant *)self->ue_object; |
85 | 85 |
|
86 | | - FName parameterName( UTF8_TO_TCHAR( textureName ) ); |
87 | | - material_instance->SetTextureParameterValueEditorOnly( parameterName, ue_texture ); |
| 86 | + FName parameterName(UTF8_TO_TCHAR(textureName)); |
| 87 | + material_instance->SetTextureParameterValueEditorOnly(parameterName, ue_texture); |
88 | 88 |
|
89 | | - Py_INCREF( Py_None ); |
90 | | - return Py_None; |
| 89 | + Py_INCREF(Py_None); |
| 90 | + return Py_None; |
91 | 91 | } |
92 | 92 |
|
93 | | -PyObject *py_ue_set_parent( ue_PyUObject *self, PyObject * args ) { |
| 93 | +PyObject *py_ue_set_parent(ue_PyUObject *self, PyObject * args) { |
94 | 94 |
|
95 | | - ue_py_check( self ); |
| 95 | + ue_py_check(self); |
96 | 96 |
|
97 | | - if ( !self->ue_object->IsA<UMaterialInstanceConstant>() ) { |
98 | | - return PyErr_Format( PyExc_Exception, "uobject is not a UMaterialInstanceConstant" ); |
99 | | - } |
| 97 | + if (!self->ue_object->IsA<UMaterialInstanceConstant>()) { |
| 98 | + return PyErr_Format(PyExc_Exception, "uobject is not a UMaterialInstanceConstant"); |
| 99 | + } |
100 | 100 |
|
101 | | - PyObject *py_material = nullptr; |
| 101 | + PyObject *py_material = nullptr; |
102 | 102 |
|
103 | | - if ( !PyArg_ParseTuple( args, "O:set_parent", &py_material ) ) { |
104 | | - return NULL; |
105 | | - } |
| 103 | + if (!PyArg_ParseTuple(args, "O:set_parent", &py_material)) { |
| 104 | + return NULL; |
| 105 | + } |
106 | 106 |
|
107 | | - if ( !ue_is_pyuobject( py_material ) ) { |
108 | | - return PyErr_Format( PyExc_Exception, "argument is not a UObject" ); |
109 | | - } |
| 107 | + if (!ue_is_pyuobject(py_material)) { |
| 108 | + return PyErr_Format(PyExc_Exception, "argument is not a UObject"); |
| 109 | + } |
110 | 110 |
|
111 | | - ue_PyUObject *py_obj = (ue_PyUObject *)py_material; |
112 | | - if ( !py_obj->ue_object->IsA<UMaterialInterface>() ) |
113 | | - return PyErr_Format( PyExc_Exception, "uobject is not a UMaterialInterface" ); |
| 111 | + ue_PyUObject *py_obj = (ue_PyUObject *)py_material; |
| 112 | + if (!py_obj->ue_object->IsA<UMaterialInterface>()) |
| 113 | + return PyErr_Format(PyExc_Exception, "uobject is not a UMaterialInterface"); |
114 | 114 |
|
115 | 115 |
|
116 | | - UMaterialInterface *materialInterface = (UMaterialInterface *)py_obj->ue_object; |
117 | | - UMaterialInstanceConstant *material_instance = (UMaterialInstanceConstant *)self->ue_object; |
118 | | - material_instance->SetParentEditorOnly( materialInterface ); |
119 | | - material_instance->PostEditChange(); |
| 116 | + UMaterialInterface *materialInterface = (UMaterialInterface *)py_obj->ue_object; |
| 117 | + UMaterialInstanceConstant *material_instance = (UMaterialInstanceConstant *)self->ue_object; |
| 118 | + material_instance->SetParentEditorOnly(materialInterface); |
| 119 | + material_instance->PostEditChange(); |
120 | 120 |
|
121 | | - Py_INCREF( Py_None ); |
122 | | - return Py_None; |
| 121 | + Py_INCREF(Py_None); |
| 122 | + return Py_None; |
123 | 123 |
|
124 | 124 | } |
125 | 125 |
|
| 126 | +PyObject *py_ue_static_mesh_set_collision_for_lod(ue_PyUObject *self, PyObject * args) { |
| 127 | + ue_py_check(self); |
| 128 | + |
| 129 | + int lod_index; |
| 130 | + int material_index; |
| 131 | + PyObject *py_bool; |
| 132 | + if (!PyArg_ParseTuple(args, "iiO:static_mesh_set_collision_for_lod", &lod_index, &material_index, &py_bool)) { |
| 133 | + return NULL; |
| 134 | + } |
| 135 | + |
| 136 | + |
| 137 | + if (!self->ue_object->IsA<UStaticMesh>()) { |
| 138 | + return PyErr_Format(PyExc_Exception, "uobject is not a StaticMesh"); |
| 139 | + } |
| 140 | + |
| 141 | + UStaticMesh *mesh = (UStaticMesh *)self->ue_object; |
| 142 | + |
| 143 | + bool enabled = false; |
| 144 | + if (PyObject_IsTrue(py_bool)) { |
| 145 | + enabled = true; |
| 146 | + } |
| 147 | + |
| 148 | + FMeshSectionInfo info = mesh->SectionInfoMap.Get(lod_index, material_index); |
| 149 | + info.bEnableCollision = enabled; |
| 150 | + mesh->SectionInfoMap.Set(lod_index, material_index, info); |
| 151 | + |
| 152 | + mesh->MarkPackageDirty(); |
| 153 | + |
| 154 | + Py_INCREF(Py_None); |
| 155 | + return Py_None; |
| 156 | +} |
| 157 | + |
| 158 | +PyObject *py_ue_static_mesh_set_shadow_for_lod(ue_PyUObject *self, PyObject * args) { |
| 159 | + ue_py_check(self); |
| 160 | + |
| 161 | + int lod_index; |
| 162 | + int material_index; |
| 163 | + PyObject *py_bool; |
| 164 | + if (!PyArg_ParseTuple(args, "iiO:static_mesh_set_shadow_for_lod", &lod_index, &material_index, &py_bool)) { |
| 165 | + return NULL; |
| 166 | + } |
| 167 | + |
| 168 | + |
| 169 | + if (!self->ue_object->IsA<UStaticMesh>()) { |
| 170 | + return PyErr_Format(PyExc_Exception, "uobject is not a StaticMesh"); |
| 171 | + } |
| 172 | + |
| 173 | + UStaticMesh *mesh = (UStaticMesh *)self->ue_object; |
| 174 | + |
| 175 | + bool enabled = false; |
| 176 | + if (PyObject_IsTrue(py_bool)) { |
| 177 | + enabled = true; |
| 178 | + } |
| 179 | + |
| 180 | + FMeshSectionInfo info = mesh->SectionInfoMap.Get(lod_index, material_index); |
| 181 | + info.bCastShadow = enabled; |
| 182 | + mesh->SectionInfoMap.Set(lod_index, material_index, info); |
| 183 | + |
| 184 | + mesh->MarkPackageDirty(); |
| 185 | + |
| 186 | + Py_INCREF(Py_None); |
| 187 | + return Py_None; |
| 188 | +} |
| 189 | + |
126 | 190 | #endif |
0 commit comments