1 /** 2 Editor-only class for defining a collision polygon in 3D space. 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.collisionpolygon; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.classdb; 24 import godot.spatial; 25 /** 26 Editor-only class for defining a collision polygon in 3D space. 27 28 Allows editing a collision polygon's vertices on a selected plane. Can also set a depth perpendicular to that plane. This class is only available in the editor. It will not appear in the scene tree at run-time. Creates a $(D Shape) for gameplay. Properties modified during gameplay will have no effect. 29 */ 30 @GodotBaseClass struct CollisionPolygon 31 { 32 package(godot) enum string _GODOT_internal_name = "CollisionPolygon"; 33 public: 34 @nogc nothrow: 35 union { /** */ godot_object _godot_object; /** */ Spatial _GODOT_base; } 36 alias _GODOT_base this; 37 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 38 package(godot) __gshared bool _classBindingInitialized = false; 39 package(godot) static struct GDNativeClassBinding 40 { 41 __gshared: 42 @GodotName("_is_editable_3d_polygon") GodotMethod!(bool) _isEditable3dPolygon; 43 @GodotName("get_depth") GodotMethod!(double) getDepth; 44 @GodotName("get_margin") GodotMethod!(double) getMargin; 45 @GodotName("get_polygon") GodotMethod!(PoolVector2Array) getPolygon; 46 @GodotName("is_disabled") GodotMethod!(bool) isDisabled; 47 @GodotName("set_depth") GodotMethod!(void, double) setDepth; 48 @GodotName("set_disabled") GodotMethod!(void, bool) setDisabled; 49 @GodotName("set_margin") GodotMethod!(void, double) setMargin; 50 @GodotName("set_polygon") GodotMethod!(void, PoolVector2Array) setPolygon; 51 } 52 /// 53 pragma(inline, true) bool opEquals(in CollisionPolygon other) const 54 { return _godot_object.ptr is other._godot_object.ptr; } 55 /// 56 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 57 { _godot_object.ptr = n; return null; } 58 /// 59 pragma(inline, true) bool opEquals(typeof(null) n) const 60 { return _godot_object.ptr is n; } 61 /// 62 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 63 mixin baseCasts; 64 /// Construct a new instance of CollisionPolygon. 65 /// Note: use `memnew!CollisionPolygon` instead. 66 static CollisionPolygon _new() 67 { 68 static godot_class_constructor constructor; 69 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("CollisionPolygon"); 70 if(constructor is null) return typeof(this).init; 71 return cast(CollisionPolygon)(constructor()); 72 } 73 @disable new(size_t s); 74 /** 75 76 */ 77 bool _isEditable3dPolygon() const 78 { 79 Array _GODOT_args = Array.make(); 80 String _GODOT_method_name = String("_is_editable_3d_polygon"); 81 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 82 } 83 /** 84 85 */ 86 double getDepth() const 87 { 88 checkClassBinding!(typeof(this))(); 89 return ptrcall!(double)(GDNativeClassBinding.getDepth, _godot_object); 90 } 91 /** 92 93 */ 94 double getMargin() const 95 { 96 checkClassBinding!(typeof(this))(); 97 return ptrcall!(double)(GDNativeClassBinding.getMargin, _godot_object); 98 } 99 /** 100 101 */ 102 PoolVector2Array getPolygon() const 103 { 104 checkClassBinding!(typeof(this))(); 105 return ptrcall!(PoolVector2Array)(GDNativeClassBinding.getPolygon, _godot_object); 106 } 107 /** 108 109 */ 110 bool isDisabled() const 111 { 112 checkClassBinding!(typeof(this))(); 113 return ptrcall!(bool)(GDNativeClassBinding.isDisabled, _godot_object); 114 } 115 /** 116 117 */ 118 void setDepth(in double depth) 119 { 120 checkClassBinding!(typeof(this))(); 121 ptrcall!(void)(GDNativeClassBinding.setDepth, _godot_object, depth); 122 } 123 /** 124 125 */ 126 void setDisabled(in bool disabled) 127 { 128 checkClassBinding!(typeof(this))(); 129 ptrcall!(void)(GDNativeClassBinding.setDisabled, _godot_object, disabled); 130 } 131 /** 132 133 */ 134 void setMargin(in double margin) 135 { 136 checkClassBinding!(typeof(this))(); 137 ptrcall!(void)(GDNativeClassBinding.setMargin, _godot_object, margin); 138 } 139 /** 140 141 */ 142 void setPolygon(in PoolVector2Array polygon) 143 { 144 checkClassBinding!(typeof(this))(); 145 ptrcall!(void)(GDNativeClassBinding.setPolygon, _godot_object, polygon); 146 } 147 /** 148 Length that the resulting collision extends in either direction perpendicular to its polygon. 149 */ 150 @property double depth() 151 { 152 return getDepth(); 153 } 154 /// ditto 155 @property void depth(double v) 156 { 157 setDepth(v); 158 } 159 /** 160 If `true`, no collision will be produced. 161 */ 162 @property bool disabled() 163 { 164 return isDisabled(); 165 } 166 /// ditto 167 @property void disabled(bool v) 168 { 169 setDisabled(v); 170 } 171 /** 172 The collision margin for the generated $(D Shape). See $(D Shape.margin) for more details. 173 */ 174 @property double margin() 175 { 176 return getMargin(); 177 } 178 /// ditto 179 @property void margin(double v) 180 { 181 setMargin(v); 182 } 183 /** 184 Array of vertices which define the polygon. 185 $(B Note:) The returned value is a copy of the original. Methods which mutate the size or properties of the return value will not impact the original polygon. To change properties of the polygon, assign it to a temporary variable and make changes before reassigning the `polygon` member. 186 */ 187 @property PoolVector2Array polygon() 188 { 189 return getPolygon(); 190 } 191 /// ditto 192 @property void polygon(PoolVector2Array v) 193 { 194 setPolygon(v); 195 } 196 }