1 /** 2 Provides high performance mesh instancing. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.multimesh; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.resource; 24 import godot.mesh; 25 import godot.reference; 26 /** 27 Provides high performance mesh instancing. 28 29 MultiMesh provides low level mesh instancing. If the amount of $(D Mesh) instances needed goes from hundreds to thousands (and most need to be visible at close proximity) creating such a large amount of $(D MeshInstance) nodes may affect performance by using too much CPU or video memory. 30 For this case a MultiMesh becomes very useful, as it can draw thousands of instances with little API overhead. 31 As a drawback, if the instances are too far away of each other, performance may be reduced as every single instance will always rendered (they are spatially indexed as one, for the whole object). 32 Since instances may have any behavior, the AABB used for visibility must be provided by the user. 33 */ 34 @GodotBaseClass struct MultiMesh 35 { 36 enum string _GODOT_internal_name = "MultiMesh"; 37 public: 38 @nogc nothrow: 39 union { godot_object _godot_object; Resource _GODOT_base; } 40 alias _GODOT_base this; 41 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 42 package(godot) __gshared bool _classBindingInitialized = false; 43 package(godot) static struct _classBinding 44 { 45 __gshared: 46 @GodotName("set_mesh") GodotMethod!(void, Mesh) setMesh; 47 @GodotName("get_mesh") GodotMethod!(Mesh) getMesh; 48 @GodotName("set_color_format") GodotMethod!(void, long) setColorFormat; 49 @GodotName("get_color_format") GodotMethod!(MultiMesh.ColorFormat) getColorFormat; 50 @GodotName("set_custom_data_format") GodotMethod!(void, long) setCustomDataFormat; 51 @GodotName("get_custom_data_format") GodotMethod!(MultiMesh.CustomDataFormat) getCustomDataFormat; 52 @GodotName("set_transform_format") GodotMethod!(void, long) setTransformFormat; 53 @GodotName("get_transform_format") GodotMethod!(MultiMesh.TransformFormat) getTransformFormat; 54 @GodotName("set_instance_count") GodotMethod!(void, long) setInstanceCount; 55 @GodotName("get_instance_count") GodotMethod!(long) getInstanceCount; 56 @GodotName("set_instance_transform") GodotMethod!(void, long, Transform) setInstanceTransform; 57 @GodotName("get_instance_transform") GodotMethod!(Transform, long) getInstanceTransform; 58 @GodotName("set_instance_color") GodotMethod!(void, long, Color) setInstanceColor; 59 @GodotName("get_instance_color") GodotMethod!(Color, long) getInstanceColor; 60 @GodotName("set_instance_custom_data") GodotMethod!(void, long, Color) setInstanceCustomData; 61 @GodotName("get_instance_custom_data") GodotMethod!(Color, long) getInstanceCustomData; 62 @GodotName("get_aabb") GodotMethod!(AABB) getAabb; 63 @GodotName("_set_transform_array") GodotMethod!(void, PoolVector3Array) _setTransformArray; 64 @GodotName("_get_transform_array") GodotMethod!(PoolVector3Array) _getTransformArray; 65 @GodotName("_set_color_array") GodotMethod!(void, PoolColorArray) _setColorArray; 66 @GodotName("_get_color_array") GodotMethod!(PoolColorArray) _getColorArray; 67 @GodotName("_set_custom_data_array") GodotMethod!(void, PoolColorArray) _setCustomDataArray; 68 @GodotName("_get_custom_data_array") GodotMethod!(PoolColorArray) _getCustomDataArray; 69 } 70 bool opEquals(in MultiMesh other) const { return _godot_object.ptr is other._godot_object.ptr; } 71 MultiMesh opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 72 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 73 mixin baseCasts; 74 static MultiMesh _new() 75 { 76 static godot_class_constructor constructor; 77 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("MultiMesh"); 78 if(constructor is null) return typeof(this).init; 79 return cast(MultiMesh)(constructor()); 80 } 81 @disable new(size_t s); 82 /// 83 enum TransformFormat : int 84 { 85 /** 86 87 */ 88 transform2d = 0, 89 /** 90 91 */ 92 transform3d = 1, 93 } 94 /// 95 enum CustomDataFormat : int 96 { 97 /** 98 99 */ 100 customDataNone = 0, 101 /** 102 103 */ 104 customData8bit = 1, 105 /** 106 107 */ 108 customDataFloat = 2, 109 } 110 /// 111 enum ColorFormat : int 112 { 113 /** 114 115 */ 116 colorNone = 0, 117 /** 118 119 */ 120 color8bit = 1, 121 /** 122 123 */ 124 colorFloat = 2, 125 } 126 /// 127 enum Constants : int 128 { 129 colorNone = 0, 130 transform2d = 0, 131 customDataNone = 0, 132 customData8bit = 1, 133 transform3d = 1, 134 color8bit = 1, 135 colorFloat = 2, 136 customDataFloat = 2, 137 } 138 /** 139 140 */ 141 void setMesh(Mesh mesh) 142 { 143 checkClassBinding!(typeof(this))(); 144 ptrcall!(void)(_classBinding.setMesh, _godot_object, mesh); 145 } 146 /** 147 148 */ 149 Ref!Mesh getMesh() const 150 { 151 checkClassBinding!(typeof(this))(); 152 return ptrcall!(Mesh)(_classBinding.getMesh, _godot_object); 153 } 154 /** 155 156 */ 157 void setColorFormat(in long format) 158 { 159 checkClassBinding!(typeof(this))(); 160 ptrcall!(void)(_classBinding.setColorFormat, _godot_object, format); 161 } 162 /** 163 164 */ 165 MultiMesh.ColorFormat getColorFormat() const 166 { 167 checkClassBinding!(typeof(this))(); 168 return ptrcall!(MultiMesh.ColorFormat)(_classBinding.getColorFormat, _godot_object); 169 } 170 /** 171 172 */ 173 void setCustomDataFormat(in long format) 174 { 175 checkClassBinding!(typeof(this))(); 176 ptrcall!(void)(_classBinding.setCustomDataFormat, _godot_object, format); 177 } 178 /** 179 180 */ 181 MultiMesh.CustomDataFormat getCustomDataFormat() const 182 { 183 checkClassBinding!(typeof(this))(); 184 return ptrcall!(MultiMesh.CustomDataFormat)(_classBinding.getCustomDataFormat, _godot_object); 185 } 186 /** 187 188 */ 189 void setTransformFormat(in long format) 190 { 191 checkClassBinding!(typeof(this))(); 192 ptrcall!(void)(_classBinding.setTransformFormat, _godot_object, format); 193 } 194 /** 195 196 */ 197 MultiMesh.TransformFormat getTransformFormat() const 198 { 199 checkClassBinding!(typeof(this))(); 200 return ptrcall!(MultiMesh.TransformFormat)(_classBinding.getTransformFormat, _godot_object); 201 } 202 /** 203 204 */ 205 void setInstanceCount(in long count) 206 { 207 checkClassBinding!(typeof(this))(); 208 ptrcall!(void)(_classBinding.setInstanceCount, _godot_object, count); 209 } 210 /** 211 212 */ 213 long getInstanceCount() const 214 { 215 checkClassBinding!(typeof(this))(); 216 return ptrcall!(long)(_classBinding.getInstanceCount, _godot_object); 217 } 218 /** 219 Set the transform for a specific instance. 220 */ 221 void setInstanceTransform(in long instance, in Transform transform) 222 { 223 checkClassBinding!(typeof(this))(); 224 ptrcall!(void)(_classBinding.setInstanceTransform, _godot_object, instance, transform); 225 } 226 /** 227 Return the transform of a specific instance. 228 */ 229 Transform getInstanceTransform(in long instance) const 230 { 231 checkClassBinding!(typeof(this))(); 232 return ptrcall!(Transform)(_classBinding.getInstanceTransform, _godot_object, instance); 233 } 234 /** 235 Set the color of a specific instance. 236 */ 237 void setInstanceColor(in long instance, in Color color) 238 { 239 checkClassBinding!(typeof(this))(); 240 ptrcall!(void)(_classBinding.setInstanceColor, _godot_object, instance, color); 241 } 242 /** 243 Get the color of a specific instance. 244 */ 245 Color getInstanceColor(in long instance) const 246 { 247 checkClassBinding!(typeof(this))(); 248 return ptrcall!(Color)(_classBinding.getInstanceColor, _godot_object, instance); 249 } 250 /** 251 252 */ 253 void setInstanceCustomData(in long instance, in Color custom_data) 254 { 255 checkClassBinding!(typeof(this))(); 256 ptrcall!(void)(_classBinding.setInstanceCustomData, _godot_object, instance, custom_data); 257 } 258 /** 259 260 */ 261 Color getInstanceCustomData(in long instance) const 262 { 263 checkClassBinding!(typeof(this))(); 264 return ptrcall!(Color)(_classBinding.getInstanceCustomData, _godot_object, instance); 265 } 266 /** 267 Return the visibility AABB. 268 */ 269 AABB getAabb() const 270 { 271 checkClassBinding!(typeof(this))(); 272 return ptrcall!(AABB)(_classBinding.getAabb, _godot_object); 273 } 274 /** 275 276 */ 277 void _setTransformArray(in PoolVector3Array arg0) 278 { 279 Array _GODOT_args = Array.empty_array; 280 _GODOT_args.append(arg0); 281 String _GODOT_method_name = String("_set_transform_array"); 282 this.callv(_GODOT_method_name, _GODOT_args); 283 } 284 /** 285 286 */ 287 PoolVector3Array _getTransformArray() const 288 { 289 Array _GODOT_args = Array.empty_array; 290 String _GODOT_method_name = String("_get_transform_array"); 291 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!PoolVector3Array); 292 } 293 /** 294 295 */ 296 void _setColorArray(in PoolColorArray arg0) 297 { 298 Array _GODOT_args = Array.empty_array; 299 _GODOT_args.append(arg0); 300 String _GODOT_method_name = String("_set_color_array"); 301 this.callv(_GODOT_method_name, _GODOT_args); 302 } 303 /** 304 305 */ 306 PoolColorArray _getColorArray() const 307 { 308 Array _GODOT_args = Array.empty_array; 309 String _GODOT_method_name = String("_get_color_array"); 310 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!PoolColorArray); 311 } 312 /** 313 314 */ 315 void _setCustomDataArray(in PoolColorArray arg0) 316 { 317 Array _GODOT_args = Array.empty_array; 318 _GODOT_args.append(arg0); 319 String _GODOT_method_name = String("_set_custom_data_array"); 320 this.callv(_GODOT_method_name, _GODOT_args); 321 } 322 /** 323 324 */ 325 PoolColorArray _getCustomDataArray() const 326 { 327 Array _GODOT_args = Array.empty_array; 328 String _GODOT_method_name = String("_get_custom_data_array"); 329 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!PoolColorArray); 330 } 331 /** 332 333 */ 334 @property MultiMesh.ColorFormat colorFormat() 335 { 336 return getColorFormat(); 337 } 338 /// ditto 339 @property void colorFormat(long v) 340 { 341 setColorFormat(v); 342 } 343 /** 344 345 */ 346 @property MultiMesh.TransformFormat transformFormat() 347 { 348 return getTransformFormat(); 349 } 350 /// ditto 351 @property void transformFormat(long v) 352 { 353 setTransformFormat(v); 354 } 355 /** 356 357 */ 358 @property MultiMesh.CustomDataFormat customDataFormat() 359 { 360 return getCustomDataFormat(); 361 } 362 /// ditto 363 @property void customDataFormat(long v) 364 { 365 setCustomDataFormat(v); 366 } 367 /** 368 369 */ 370 @property long instanceCount() 371 { 372 return getInstanceCount(); 373 } 374 /// ditto 375 @property void instanceCount(long v) 376 { 377 setInstanceCount(v); 378 } 379 /** 380 381 */ 382 @property Mesh mesh() 383 { 384 return getMesh(); 385 } 386 /// ditto 387 @property void mesh(Mesh v) 388 { 389 setMesh(v); 390 } 391 /** 392 393 */ 394 @property PoolVector3Array transformArray() 395 { 396 return _getTransformArray(); 397 } 398 /// ditto 399 @property void transformArray(PoolVector3Array v) 400 { 401 _setTransformArray(v); 402 } 403 /** 404 405 */ 406 @property PoolColorArray colorArray() 407 { 408 return _getColorArray(); 409 } 410 /// ditto 411 @property void colorArray(PoolColorArray v) 412 { 413 _setColorArray(v); 414 } 415 /** 416 417 */ 418 @property PoolColorArray customDataArray() 419 { 420 return _getCustomDataArray(); 421 } 422 /// ditto 423 @property void customDataArray(PoolColorArray v) 424 { 425 _setCustomDataArray(v); 426 } 427 }