1 /**
2 Base class for all 3D shape resources.
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.shape;
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.resource;
24 import godot.reference;
25 import godot.arraymesh;
26 /**
27 Base class for all 3D shape resources.
28 
29 Nodes that inherit from this can be used as shapes for a $(D PhysicsBody) or $(D Area) objects.
30 */
31 @GodotBaseClass struct Shape
32 {
33 	package(godot) enum string _GODOT_internal_name = "Shape";
34 public:
35 @nogc nothrow:
36 	union { /** */ godot_object _godot_object; /** */ Resource _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_debug_mesh") GodotMethod!(ArrayMesh) getDebugMesh;
44 		@GodotName("get_margin") GodotMethod!(double) getMargin;
45 		@GodotName("set_margin") GodotMethod!(void, double) setMargin;
46 	}
47 	/// 
48 	pragma(inline, true) bool opEquals(in Shape 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 Shape.
60 	/// Note: use `memnew!Shape` instead.
61 	static Shape _new()
62 	{
63 		static godot_class_constructor constructor;
64 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Shape");
65 		if(constructor is null) return typeof(this).init;
66 		return cast(Shape)(constructor());
67 	}
68 	@disable new(size_t s);
69 	/**
70 	Returns the $(D ArrayMesh) used to draw the debug collision for this $(D Shape).
71 	*/
72 	Ref!ArrayMesh getDebugMesh()
73 	{
74 		checkClassBinding!(typeof(this))();
75 		return ptrcall!(ArrayMesh)(GDNativeClassBinding.getDebugMesh, _godot_object);
76 	}
77 	/**
78 	
79 	*/
80 	double getMargin() const
81 	{
82 		checkClassBinding!(typeof(this))();
83 		return ptrcall!(double)(GDNativeClassBinding.getMargin, _godot_object);
84 	}
85 	/**
86 	
87 	*/
88 	void setMargin(in double margin)
89 	{
90 		checkClassBinding!(typeof(this))();
91 		ptrcall!(void)(GDNativeClassBinding.setMargin, _godot_object, margin);
92 	}
93 	/**
94 	The collision margin for the shape. Used in Bullet Physics only.
95 	Collision margins allow collision detection to be more efficient by adding an extra shell around shapes. Collision algorithms are more expensive when objects overlap by more than their margin, so a higher value for margins is better for performance, at the cost of accuracy around edges as it makes them less sharp.
96 	*/
97 	@property double margin()
98 	{
99 		return getMargin();
100 	}
101 	/// ditto
102 	@property void margin(double v)
103 	{
104 		setMargin(v);
105 	}
106 }