1 /**
2 The CSG base class.
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.csgshape;
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.visualinstance;
23 import godot.spatial;
24 import godot.node;
25 /**
26 The CSG base class.
27 
28 This is the CSG base class that provides CSG operation support to the various CSG nodes in Godot.
29 */
30 @GodotBaseClass struct CSGShape
31 {
32 	enum string _GODOT_internal_name = "CSGShape";
33 public:
34 @nogc nothrow:
35 	union { godot_object _godot_object; VisualInstance _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 _classBinding
40 	{
41 		__gshared:
42 		@GodotName("_update_shape") GodotMethod!(void) _updateShape;
43 		@GodotName("is_root_shape") GodotMethod!(bool) isRootShape;
44 		@GodotName("set_operation") GodotMethod!(void, long) setOperation;
45 		@GodotName("get_operation") GodotMethod!(CSGShape.Operation) getOperation;
46 		@GodotName("set_use_collision") GodotMethod!(void, bool) setUseCollision;
47 		@GodotName("is_using_collision") GodotMethod!(bool) isUsingCollision;
48 		@GodotName("set_snap") GodotMethod!(void, double) setSnap;
49 		@GodotName("get_snap") GodotMethod!(double) getSnap;
50 	}
51 	bool opEquals(in CSGShape other) const { return _godot_object.ptr is other._godot_object.ptr; }
52 	CSGShape 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 CSGShape _new()
56 	{
57 		static godot_class_constructor constructor;
58 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("CSGShape");
59 		if(constructor is null) return typeof(this).init;
60 		return cast(CSGShape)(constructor());
61 	}
62 	@disable new(size_t s);
63 	/// 
64 	enum Operation : int
65 	{
66 		/**
67 		Geometry of both primitives is merged, intersecting geometry is removed.
68 		*/
69 		operationUnion = 0,
70 		/**
71 		Only intersecting geometry remains, the rest is removed.
72 		*/
73 		operationIntersection = 1,
74 		/**
75 		The second shape is susbtracted from the first, leaving a dent with it's shape.
76 		*/
77 		operationSubtraction = 2,
78 	}
79 	/// 
80 	enum Constants : int
81 	{
82 		operationUnion = 0,
83 		operationIntersection = 1,
84 		operationSubtraction = 2,
85 	}
86 	/**
87 	
88 	*/
89 	void _updateShape()
90 	{
91 		Array _GODOT_args = Array.empty_array;
92 		String _GODOT_method_name = String("_update_shape");
93 		this.callv(_GODOT_method_name, _GODOT_args);
94 	}
95 	/**
96 	Returns true if this is a root shape and is thus the object that is rendered.
97 	*/
98 	bool isRootShape() const
99 	{
100 		checkClassBinding!(typeof(this))();
101 		return ptrcall!(bool)(_classBinding.isRootShape, _godot_object);
102 	}
103 	/**
104 	
105 	*/
106 	void setOperation(in long operation)
107 	{
108 		checkClassBinding!(typeof(this))();
109 		ptrcall!(void)(_classBinding.setOperation, _godot_object, operation);
110 	}
111 	/**
112 	
113 	*/
114 	CSGShape.Operation getOperation() const
115 	{
116 		checkClassBinding!(typeof(this))();
117 		return ptrcall!(CSGShape.Operation)(_classBinding.getOperation, _godot_object);
118 	}
119 	/**
120 	
121 	*/
122 	void setUseCollision(in bool operation)
123 	{
124 		checkClassBinding!(typeof(this))();
125 		ptrcall!(void)(_classBinding.setUseCollision, _godot_object, operation);
126 	}
127 	/**
128 	
129 	*/
130 	bool isUsingCollision() const
131 	{
132 		checkClassBinding!(typeof(this))();
133 		return ptrcall!(bool)(_classBinding.isUsingCollision, _godot_object);
134 	}
135 	/**
136 	
137 	*/
138 	void setSnap(in double snap)
139 	{
140 		checkClassBinding!(typeof(this))();
141 		ptrcall!(void)(_classBinding.setSnap, _godot_object, snap);
142 	}
143 	/**
144 	
145 	*/
146 	double getSnap() const
147 	{
148 		checkClassBinding!(typeof(this))();
149 		return ptrcall!(double)(_classBinding.getSnap, _godot_object);
150 	}
151 	/**
152 	The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent.
153 	*/
154 	@property CSGShape.Operation operation()
155 	{
156 		return getOperation();
157 	}
158 	/// ditto
159 	@property void operation(long v)
160 	{
161 		setOperation(v);
162 	}
163 	/**
164 	Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body. Note that the collision shape is still active even if the CSG shape itself is hidden.
165 	*/
166 	@property bool useCollision()
167 	{
168 		return isUsingCollision();
169 	}
170 	/// ditto
171 	@property void useCollision(bool v)
172 	{
173 		setUseCollision(v);
174 	}
175 	/**
176 	
177 	*/
178 	@property double snap()
179 	{
180 		return getSnap();
181 	}
182 	/// ditto
183 	@property void snap(double v)
184 	{
185 		setSnap(v);
186 	}
187 }