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.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 import godot.shape;
26 import godot.resource;
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 	package(godot) 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 GDNativeClassBinding
42 	{
43 		__gshared:
44 		@GodotName("get_shape") GodotMethod!(Shape) getShape;
45 		@GodotName("is_disabled") GodotMethod!(bool) isDisabled;
46 		@GodotName("make_convex_from_brothers") GodotMethod!(void) makeConvexFromBrothers;
47 		@GodotName("resource_changed") GodotMethod!(void, Resource) resourceChanged;
48 		@GodotName("set_disabled") GodotMethod!(void, bool) setDisabled;
49 		@GodotName("set_shape") GodotMethod!(void, Shape) setShape;
50 	}
51 	/// 
52 	pragma(inline, true) bool opEquals(in CollisionShape 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 CollisionShape.
64 	/// Note: use `memnew!CollisionShape` instead.
65 	static CollisionShape _new()
66 	{
67 		static godot_class_constructor constructor;
68 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("CollisionShape");
69 		if(constructor is null) return typeof(this).init;
70 		return cast(CollisionShape)(constructor());
71 	}
72 	@disable new(size_t s);
73 	/**
74 	
75 	*/
76 	Ref!Shape getShape() const
77 	{
78 		checkClassBinding!(typeof(this))();
79 		return ptrcall!(Shape)(GDNativeClassBinding.getShape, _godot_object);
80 	}
81 	/**
82 	
83 	*/
84 	bool isDisabled() const
85 	{
86 		checkClassBinding!(typeof(this))();
87 		return ptrcall!(bool)(GDNativeClassBinding.isDisabled, _godot_object);
88 	}
89 	/**
90 	Sets the collision shape's shape to the addition of all its convexed $(D MeshInstance) siblings geometry.
91 	*/
92 	void makeConvexFromBrothers()
93 	{
94 		checkClassBinding!(typeof(this))();
95 		ptrcall!(void)(GDNativeClassBinding.makeConvexFromBrothers, _godot_object);
96 	}
97 	/**
98 	If this method exists within a script it will be called whenever the shape resource has been modified.
99 	*/
100 	void resourceChanged(Resource resource)
101 	{
102 		checkClassBinding!(typeof(this))();
103 		ptrcall!(void)(GDNativeClassBinding.resourceChanged, _godot_object, resource);
104 	}
105 	/**
106 	
107 	*/
108 	void setDisabled(in bool enable)
109 	{
110 		checkClassBinding!(typeof(this))();
111 		ptrcall!(void)(GDNativeClassBinding.setDisabled, _godot_object, enable);
112 	}
113 	/**
114 	
115 	*/
116 	void setShape(Shape shape)
117 	{
118 		checkClassBinding!(typeof(this))();
119 		ptrcall!(void)(GDNativeClassBinding.setShape, _godot_object, shape);
120 	}
121 	/**
122 	A disabled collision shape has no effect in the world.
123 	*/
124 	@property bool disabled()
125 	{
126 		return isDisabled();
127 	}
128 	/// ditto
129 	@property void disabled(bool v)
130 	{
131 		setDisabled(v);
132 	}
133 	/**
134 	The actual shape owned by this collision shape.
135 	*/
136 	@property Shape shape()
137 	{
138 		return getShape();
139 	}
140 	/// ditto
141 	@property void shape(Shape v)
142 	{
143 		setShape(v);
144 	}
145 }