-
Notifications
You must be signed in to change notification settings - Fork 0
/
defines.h
198 lines (161 loc) · 6.28 KB
/
defines.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#ifndef TERRAIN_2D_DEFINES_H
#define TERRAIN_2D_DEFINES_H
#include "core/version.h"
#if VERSION_MAJOR >= 4
#define GODOT4 true
#endif
//includes
#if GODOT4
#define core_input_h "core/input/input_event.h"
#define spatial_editor_plugin_h "editor/plugins/node_3d_editor_plugin.h"
#define camera_h "scene/3d/camera_3d.h"
#define spatial_h "scene/3d/node_3d.h"
#define navigation_h "scene/3d/node_3d.h"
#define Navigation3D Node3D
#define light_h "scene/3d/light_3d.h"
#define visual_server_h "servers/rendering_server.h"
#define mesh_instance_h "scene/3d/mesh_instance_3d.h"
#define pool_vector_h "core/templates/vector.h"
#define physics_server_h "servers/physics_server_3d.h"
#define immediate_geometry_h "scene/3d/immediate_geometry_3d.h"
#define include_pool_vector \
template <class N> \
class Vector; \
template <class N> \
using PoolVector = Vector<N>;
#else
#define core_input_h "core/os/input.h"
#define spatial_editor_plugin_h "editor/plugins/spatial_editor_plugin.h"
#define camera_h "scene/3d/camera.h"
#define spatial_h "scene/3d/spatial.h"
#define navigation_h "scene/3d/navigation.h"
#define light_h "scene/3d/light.h"
#define visual_server_h "servers/visual_server.h"
#define mesh_instance_h "scene/3d/mesh_instance.h"
#define pool_vector_h "core/pool_vector.h"
#define physics_server_h "servers/physics_server.h"
#define immediate_geometry_h "scene/3d/immediate_geometry.h"
#define include_pool_vector
#endif
//Type Defines
#if GODOT4
#define PhysicsDirectSpaceState PhysicsDirectSpaceState3D
#define SpatialEditor Node3DEditor
#define SpatialEditorPlugin Node3DEditorPlugin
#define SpatialEditorViewport Node3DEditorViewport
#define PoolStringArray PackedStringArray
#define REAL FLOAT
#define POOL_STRING_ARRAY PACKED_STRING_ARRAY
#define POOL_BYTE_ARRAY PACKED_BYTE_ARRAY
#define Spatial Node3D
#define SpatialMaterial StandardMaterial3D
#define PoolVector3Array PackedVector3Array
#define PoolVector2Array PackedVector2Array
#define PoolColorArray PackedColorArray
#define PoolIntArray PackedInt64Array
#define PoolRealArray PackedFloat32Array
#define PoolByteArray PackedByteArray
#define MeshInstance MeshInstance3D
#define Camera Camera3D
#define ToolButton Button
#define Shape Shape3D
#define Reference RefCounted
typedef class World3D World;
#define DirectionalLight DirectionalLight3D
typedef class ImmediateGeometry3D ImmediateGeometry;
typedef class Navigation3D Navigation;
typedef class PhysicsServer3D PhysicsServer;
typedef class RenderingServer VisualServer;
typedef class RenderingServer VS;
//typedef class StandardMaterial3D SpatialMaterial;
//toodo figure out a way to have this
//#define Variant::CallError Callable::CallError
#endif
#if GODOT4
#define VARIANT_ARRAY_GET(arr) \
Vector<Variant> r; \
for (int i = 0; i < arr.size(); i++) { \
r.push_back(arr[i]); \
} \
return r;
#else
#define VARIANT_ARRAY_GET(arr) \
Vector<Variant> r; \
for (int i = 0; i < arr.size(); i++) { \
r.push_back(arr[i].get_ref_ptr()); \
} \
return r;
#endif
#define VARIANT_ARRAY_SET(arr, arr_into, type) \
arr_into.clear(); \
for (int i = 0; i < arr.size(); i++) { \
Ref<type> e = Ref<type>(arr[i]); \
arr_into.push_back(e); \
}
#if GODOT4
//TODO do this properly
#define INSTANCE_VALIDATE(var) var
#define CONNECT(sig, obj, target_method_class, method) connect(sig, callable_mp(obj, &target_method_class::method))
#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, callable_mp(obj, &target_method_class::method))
#define INSTANCE instantiate
#define VREMOVE remove_at
#define CALL(func, ...) \
_gdvirtual_##func##_call(__VA_ARGS__)
#define RETURN_CALL(ret_type, func) \
ret_type _return_call_ret_var; \
_gdvirtual_##func##_call(_return_call_ret_var); \
return _return_call_ret_var;
#define RETURN_CALLP(ret_type, func, ...) \
ret_type _return_call_ret_var; \
_gdvirtual_##func##_call(__VA_ARGS__, _return_call_ret_var); \
return _return_call_ret_var;
#define GET_CALL(ret_type, ret_var, func) \
_gdvirtual_##func##_call(ret_var);
#define GET_CALLP(ret_type, ret_var, func, ...) \
_gdvirtual_##func##_call(__VA_ARGS__, ret_var);
#define RETURN_CALLD(ret_type, def_val, func) \
ret_type _return_call_ret_var = def_val; \
if (_gdvirtual_##func##_call(_return_call_ret_var)) { \
return _return_call_ret_var; \
} \
return def_val;
#define RETURN_CALLPD(ret_type, def_val, func, ...) \
ret_type _return_call_ret_var = def_val; \
if (_gdvirtual_##func##_call(__VA_ARGS__, _return_call_ret_var)) { \
return _return_call_ret_var; \
} \
return def_val;
#define GET_CALLD(ret_type, def_val, ret_var, func) \
if (!_gdvirtual_##func##_call(ret_var)) { \
ret_var = def_val; \
}
#define GET_CALLPD(ret_type, def_val, ret_var, func, ...) \
if (!_gdvirtual_##func##_call(__VA_ARGS__, ret_var)) { \
ret_var = def_val; \
}
#else
#define INSTANCE_VALIDATE(var) ObjectDB::instance_validate(var)
#define CONNECT(sig, obj, target_method_class, method) connect(sig, obj, #method)
#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, obj, #method)
#define INSTANCE instance
#define VREMOVE remove
#define CALL(func, ...) \
call(#func, ##__VA_ARGS__);
#define RETURN_CALL(ret_type, func) \
return call(#func);
#define RETURN_CALLP(ret_type, func, ...) \
return call(#func, ##__VA_ARGS__);
#define GET_CALL(ret_type, ret_var, func) \
ret_var = call(#func);
#define GET_CALLP(ret_type, ret_var, func, ...) \
ret_var = call(#func, ##__VA_ARGS__);
#define RETURN_CALLD(ret_type, def_val, func) \
return call(#func);
#define RETURN_CALLPD(ret_type, def_val, func, ...) \
return call(#func, ##__VA_ARGS__);
#define GET_CALLD(ret_type, def_val, ret_var, func) \
ret_var = call(#func);
#define GET_CALLPD(ret_type, def_val, ret_var, func, ...) \
return call(#func, ##__VA_ARGS__);
#endif
#endif