1 /** 2 Convex polygon shape for 2D physics. 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.convexpolygonshape2d; 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.shape2d; 25 /** 26 Convex polygon shape for 2D physics. 27 28 A convex polygon, whatever its shape, is internally decomposed into as many convex polygons as needed to ensure all collision checks against it are always done on convex polygons (which are faster to check). 29 The main difference between a $(D ConvexPolygonShape2D) and a $(D ConcavePolygonShape2D) is that a concave polygon assumes it is concave and uses a more complex method of collision detection, and a convex one forces itself to be convex in order to speed up collision detection. 30 */ 31 @GodotBaseClass struct ConvexPolygonShape2D 32 { 33 package(godot) enum string _GODOT_internal_name = "ConvexPolygonShape2D"; 34 public: 35 @nogc nothrow: 36 union { /** */ godot_object _godot_object; /** */ Shape2D _GODOT_base; } 37 alias _GODOT_base this; 38 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 39 package(godot) __gshared bool _classBindingInitialized = false; 40 package(godot) static struct GDNativeClassBinding 41 { 42 __gshared: 43 @GodotName("get_points") GodotMethod!(PoolVector2Array) getPoints; 44 @GodotName("set_point_cloud") GodotMethod!(void, PoolVector2Array) setPointCloud; 45 @GodotName("set_points") GodotMethod!(void, PoolVector2Array) setPoints; 46 } 47 /// 48 pragma(inline, true) bool opEquals(in ConvexPolygonShape2D other) const 49 { return _godot_object.ptr is other._godot_object.ptr; } 50 /// 51 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 52 { _godot_object.ptr = n; return null; } 53 /// 54 pragma(inline, true) bool opEquals(typeof(null) n) const 55 { return _godot_object.ptr is n; } 56 /// 57 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 58 mixin baseCasts; 59 /// Construct a new instance of ConvexPolygonShape2D. 60 /// Note: use `memnew!ConvexPolygonShape2D` instead. 61 static ConvexPolygonShape2D _new() 62 { 63 static godot_class_constructor constructor; 64 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ConvexPolygonShape2D"); 65 if(constructor is null) return typeof(this).init; 66 return cast(ConvexPolygonShape2D)(constructor()); 67 } 68 @disable new(size_t s); 69 /** 70 71 */ 72 PoolVector2Array getPoints() const 73 { 74 checkClassBinding!(typeof(this))(); 75 return ptrcall!(PoolVector2Array)(GDNativeClassBinding.getPoints, _godot_object); 76 } 77 /** 78 Based on the set of points provided, this creates and assigns the $(D points) property using the convex hull algorithm. Removing all unneeded points. See $(D Geometry.convexHull2d) for details. 79 */ 80 void setPointCloud(in PoolVector2Array point_cloud) 81 { 82 checkClassBinding!(typeof(this))(); 83 ptrcall!(void)(GDNativeClassBinding.setPointCloud, _godot_object, point_cloud); 84 } 85 /** 86 87 */ 88 void setPoints(in PoolVector2Array points) 89 { 90 checkClassBinding!(typeof(this))(); 91 ptrcall!(void)(GDNativeClassBinding.setPoints, _godot_object, points); 92 } 93 /** 94 The polygon's list of vertices. Can be in either clockwise or counterclockwise order. 95 */ 96 @property PoolVector2Array points() 97 { 98 return getPoints(); 99 } 100 /// ditto 101 @property void points(PoolVector2Array v) 102 { 103 setPoints(v); 104 } 105 }