1 /** 2 Damped spring constraint 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.dampedspringjoint2d; 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.joint2d; 25 /** 26 Damped spring constraint for 2D physics. 27 28 This resembles a spring joint that always wants to go back to a given length. 29 */ 30 @GodotBaseClass struct DampedSpringJoint2D 31 { 32 package(godot) enum string _GODOT_internal_name = "DampedSpringJoint2D"; 33 public: 34 @nogc nothrow: 35 union { /** */ godot_object _godot_object; /** */ Joint2D _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("get_damping") GodotMethod!(double) getDamping; 43 @GodotName("get_length") GodotMethod!(double) getLength; 44 @GodotName("get_rest_length") GodotMethod!(double) getRestLength; 45 @GodotName("get_stiffness") GodotMethod!(double) getStiffness; 46 @GodotName("set_damping") GodotMethod!(void, double) setDamping; 47 @GodotName("set_length") GodotMethod!(void, double) setLength; 48 @GodotName("set_rest_length") GodotMethod!(void, double) setRestLength; 49 @GodotName("set_stiffness") GodotMethod!(void, double) setStiffness; 50 } 51 /// 52 pragma(inline, true) bool opEquals(in DampedSpringJoint2D other) const 53 { return _godot_object.ptr is other._godot_object.ptr; } 54 /// 55 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 56 { _godot_object.ptr = n; return null; } 57 /// 58 pragma(inline, true) bool opEquals(typeof(null) n) const 59 { return _godot_object.ptr is n; } 60 /// 61 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 62 mixin baseCasts; 63 /// Construct a new instance of DampedSpringJoint2D. 64 /// Note: use `memnew!DampedSpringJoint2D` instead. 65 static DampedSpringJoint2D _new() 66 { 67 static godot_class_constructor constructor; 68 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("DampedSpringJoint2D"); 69 if(constructor is null) return typeof(this).init; 70 return cast(DampedSpringJoint2D)(constructor()); 71 } 72 @disable new(size_t s); 73 /** 74 75 */ 76 double getDamping() const 77 { 78 checkClassBinding!(typeof(this))(); 79 return ptrcall!(double)(GDNativeClassBinding.getDamping, _godot_object); 80 } 81 /** 82 83 */ 84 double getLength() const 85 { 86 checkClassBinding!(typeof(this))(); 87 return ptrcall!(double)(GDNativeClassBinding.getLength, _godot_object); 88 } 89 /** 90 91 */ 92 double getRestLength() const 93 { 94 checkClassBinding!(typeof(this))(); 95 return ptrcall!(double)(GDNativeClassBinding.getRestLength, _godot_object); 96 } 97 /** 98 99 */ 100 double getStiffness() const 101 { 102 checkClassBinding!(typeof(this))(); 103 return ptrcall!(double)(GDNativeClassBinding.getStiffness, _godot_object); 104 } 105 /** 106 107 */ 108 void setDamping(in double damping) 109 { 110 checkClassBinding!(typeof(this))(); 111 ptrcall!(void)(GDNativeClassBinding.setDamping, _godot_object, damping); 112 } 113 /** 114 115 */ 116 void setLength(in double length) 117 { 118 checkClassBinding!(typeof(this))(); 119 ptrcall!(void)(GDNativeClassBinding.setLength, _godot_object, length); 120 } 121 /** 122 123 */ 124 void setRestLength(in double rest_length) 125 { 126 checkClassBinding!(typeof(this))(); 127 ptrcall!(void)(GDNativeClassBinding.setRestLength, _godot_object, rest_length); 128 } 129 /** 130 131 */ 132 void setStiffness(in double stiffness) 133 { 134 checkClassBinding!(typeof(this))(); 135 ptrcall!(void)(GDNativeClassBinding.setStiffness, _godot_object, stiffness); 136 } 137 /** 138 The spring joint's damping ratio. A value between `0` and `1`. When the two bodies move into different directions the system tries to align them to the spring axis again. A high `damping` value forces the attached bodies to align faster. 139 */ 140 @property double damping() 141 { 142 return getDamping(); 143 } 144 /// ditto 145 @property void damping(double v) 146 { 147 setDamping(v); 148 } 149 /** 150 The spring joint's maximum length. The two attached bodies cannot stretch it past this value. 151 */ 152 @property double length() 153 { 154 return getLength(); 155 } 156 /// ditto 157 @property void length(double v) 158 { 159 setLength(v); 160 } 161 /** 162 When the bodies attached to the spring joint move they stretch or squash it. The joint always tries to resize towards this length. 163 */ 164 @property double restLength() 165 { 166 return getRestLength(); 167 } 168 /// ditto 169 @property void restLength(double v) 170 { 171 setRestLength(v); 172 } 173 /** 174 The higher the value, the less the bodies attached to the joint will deform it. The joint applies an opposing force to the bodies, the product of the stiffness multiplied by the size difference from its resting length. 175 */ 176 @property double stiffness() 177 { 178 return getStiffness(); 179 } 180 /// ditto 181 @property void stiffness(double v) 182 { 183 setStiffness(v); 184 } 185 }