1 /** 2 Node that represents collision shape data 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.collisionshape; 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.spatial; 24 import godot.resource; 25 import godot.shape; 26 import godot.node; 27 /** 28 Node that represents collision shape data in 3D space. 29 30 Editor facility for creating and editing collision shapes in 3D space. You can use this node to represent all sorts of collision shapes, for example, add this to an $(D Area) to give it a detection shape, or add it to a $(D PhysicsBody) to create a solid object. $(B IMPORTANT): this is an Editor-only helper to create shapes, use $(D CollisionObject.shapeOwnerGetShape) to get the actual shape. 31 */ 32 @GodotBaseClass struct CollisionShape 33 { 34 enum string _GODOT_internal_name = "CollisionShape"; 35 public: 36 @nogc nothrow: 37 union { godot_object _godot_object; Spatial _GODOT_base; } 38 alias _GODOT_base this; 39 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 40 package(godot) __gshared bool _classBindingInitialized = false; 41 package(godot) static struct _classBinding 42 { 43 __gshared: 44 @GodotName("resource_changed") GodotMethod!(void, Resource) resourceChanged; 45 @GodotName("set_shape") GodotMethod!(void, Shape) setShape; 46 @GodotName("get_shape") GodotMethod!(Shape) getShape; 47 @GodotName("set_disabled") GodotMethod!(void, bool) setDisabled; 48 @GodotName("is_disabled") GodotMethod!(bool) isDisabled; 49 @GodotName("make_convex_from_brothers") GodotMethod!(void) makeConvexFromBrothers; 50 } 51 bool opEquals(in CollisionShape other) const { return _godot_object.ptr is other._godot_object.ptr; } 52 CollisionShape opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 53 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 54 mixin baseCasts; 55 static CollisionShape _new() 56 { 57 static godot_class_constructor constructor; 58 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("CollisionShape"); 59 if(constructor is null) return typeof(this).init; 60 return cast(CollisionShape)(constructor()); 61 } 62 @disable new(size_t s); 63 /** 64 If this method exists within a script it will be called whenever the shape resource has been modified. 65 */ 66 void resourceChanged(Resource resource) 67 { 68 checkClassBinding!(typeof(this))(); 69 ptrcall!(void)(_classBinding.resourceChanged, _godot_object, resource); 70 } 71 /** 72 73 */ 74 void setShape(Shape shape) 75 { 76 checkClassBinding!(typeof(this))(); 77 ptrcall!(void)(_classBinding.setShape, _godot_object, shape); 78 } 79 /** 80 81 */ 82 Ref!Shape getShape() const 83 { 84 checkClassBinding!(typeof(this))(); 85 return ptrcall!(Shape)(_classBinding.getShape, _godot_object); 86 } 87 /** 88 89 */ 90 void setDisabled(in bool enable) 91 { 92 checkClassBinding!(typeof(this))(); 93 ptrcall!(void)(_classBinding.setDisabled, _godot_object, enable); 94 } 95 /** 96 97 */ 98 bool isDisabled() const 99 { 100 checkClassBinding!(typeof(this))(); 101 return ptrcall!(bool)(_classBinding.isDisabled, _godot_object); 102 } 103 /** 104 Sets the collision shape's shape to the addition of all its convexed $(D MeshInstance) siblings geometry. 105 */ 106 void makeConvexFromBrothers() 107 { 108 checkClassBinding!(typeof(this))(); 109 ptrcall!(void)(_classBinding.makeConvexFromBrothers, _godot_object); 110 } 111 /** 112 The actual shape owned by this collision shape. 113 */ 114 @property Shape shape() 115 { 116 return getShape(); 117 } 118 /// ditto 119 @property void shape(Shape v) 120 { 121 setShape(v); 122 } 123 /** 124 A disabled collision shape has no effect in the world. 125 */ 126 @property bool disabled() 127 { 128 return isDisabled(); 129 } 130 /// ditto 131 @property void disabled(bool v) 132 { 133 setDisabled(v); 134 } 135 }