1 /** 2 Helper node to calculate generic geometry operations. 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.geometry; 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 /** 24 Helper node to calculate generic geometry operations. 25 26 Geometry provides users with a set of helper functions to create geometric shapes, compute intersections between shapes, and process various other geometric operations. 27 */ 28 @GodotBaseClass struct GeometrySingleton 29 { 30 package(godot) enum string _GODOT_internal_name = "_Geometry"; 31 public: 32 @nogc nothrow: 33 union { /** */ godot_object _godot_object; /** */ GodotObject _GODOT_base; } 34 alias _GODOT_base this; 35 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 36 package(godot) __gshared bool _classBindingInitialized = false; 37 package(godot) static struct GDNativeClassBinding 38 { 39 __gshared: 40 godot_object _singleton; 41 immutable char* _singletonName = "Geometry"; 42 @GodotName("build_box_planes") GodotMethod!(Array, Vector3) buildBoxPlanes; 43 @GodotName("build_capsule_planes") GodotMethod!(Array, double, double, long, long, long) buildCapsulePlanes; 44 @GodotName("build_cylinder_planes") GodotMethod!(Array, double, double, long, long) buildCylinderPlanes; 45 @GodotName("clip_polygon") GodotMethod!(PoolVector3Array, PoolVector3Array, Plane) clipPolygon; 46 @GodotName("clip_polygons_2d") GodotMethod!(Array, PoolVector2Array, PoolVector2Array) clipPolygons2d; 47 @GodotName("clip_polyline_with_polygon_2d") GodotMethod!(Array, PoolVector2Array, PoolVector2Array) clipPolylineWithPolygon2d; 48 @GodotName("convex_hull_2d") GodotMethod!(PoolVector2Array, PoolVector2Array) convexHull2d; 49 @GodotName("exclude_polygons_2d") GodotMethod!(Array, PoolVector2Array, PoolVector2Array) excludePolygons2d; 50 @GodotName("get_closest_point_to_segment") GodotMethod!(Vector3, Vector3, Vector3, Vector3) getClosestPointToSegment; 51 @GodotName("get_closest_point_to_segment_2d") GodotMethod!(Vector2, Vector2, Vector2, Vector2) getClosestPointToSegment2d; 52 @GodotName("get_closest_point_to_segment_uncapped") GodotMethod!(Vector3, Vector3, Vector3, Vector3) getClosestPointToSegmentUncapped; 53 @GodotName("get_closest_point_to_segment_uncapped_2d") GodotMethod!(Vector2, Vector2, Vector2, Vector2) getClosestPointToSegmentUncapped2d; 54 @GodotName("get_closest_points_between_segments") GodotMethod!(PoolVector3Array, Vector3, Vector3, Vector3, Vector3) getClosestPointsBetweenSegments; 55 @GodotName("get_closest_points_between_segments_2d") GodotMethod!(PoolVector2Array, Vector2, Vector2, Vector2, Vector2) getClosestPointsBetweenSegments2d; 56 @GodotName("get_uv84_normal_bit") GodotMethod!(long, Vector3) getUv84NormalBit; 57 @GodotName("intersect_polygons_2d") GodotMethod!(Array, PoolVector2Array, PoolVector2Array) intersectPolygons2d; 58 @GodotName("intersect_polyline_with_polygon_2d") GodotMethod!(Array, PoolVector2Array, PoolVector2Array) intersectPolylineWithPolygon2d; 59 @GodotName("is_point_in_circle") GodotMethod!(bool, Vector2, Vector2, double) isPointInCircle; 60 @GodotName("is_point_in_polygon") GodotMethod!(bool, Vector2, PoolVector2Array) isPointInPolygon; 61 @GodotName("is_polygon_clockwise") GodotMethod!(bool, PoolVector2Array) isPolygonClockwise; 62 @GodotName("line_intersects_line_2d") GodotMethod!(Variant, Vector2, Vector2, Vector2, Vector2) lineIntersectsLine2d; 63 @GodotName("make_atlas") GodotMethod!(Dictionary, PoolVector2Array) makeAtlas; 64 @GodotName("merge_polygons_2d") GodotMethod!(Array, PoolVector2Array, PoolVector2Array) mergePolygons2d; 65 @GodotName("offset_polygon_2d") GodotMethod!(Array, PoolVector2Array, double, long) offsetPolygon2d; 66 @GodotName("offset_polyline_2d") GodotMethod!(Array, PoolVector2Array, double, long, long) offsetPolyline2d; 67 @GodotName("point_is_inside_triangle") GodotMethod!(bool, Vector2, Vector2, Vector2, Vector2) pointIsInsideTriangle; 68 @GodotName("ray_intersects_triangle") GodotMethod!(Variant, Vector3, Vector3, Vector3, Vector3, Vector3) rayIntersectsTriangle; 69 @GodotName("segment_intersects_circle") GodotMethod!(double, Vector2, Vector2, Vector2, double) segmentIntersectsCircle; 70 @GodotName("segment_intersects_convex") GodotMethod!(PoolVector3Array, Vector3, Vector3, Array) segmentIntersectsConvex; 71 @GodotName("segment_intersects_cylinder") GodotMethod!(PoolVector3Array, Vector3, Vector3, double, double) segmentIntersectsCylinder; 72 @GodotName("segment_intersects_segment_2d") GodotMethod!(Variant, Vector2, Vector2, Vector2, Vector2) segmentIntersectsSegment2d; 73 @GodotName("segment_intersects_sphere") GodotMethod!(PoolVector3Array, Vector3, Vector3, Vector3, double) segmentIntersectsSphere; 74 @GodotName("segment_intersects_triangle") GodotMethod!(Variant, Vector3, Vector3, Vector3, Vector3, Vector3) segmentIntersectsTriangle; 75 @GodotName("triangulate_delaunay_2d") GodotMethod!(PoolIntArray, PoolVector2Array) triangulateDelaunay2d; 76 @GodotName("triangulate_polygon") GodotMethod!(PoolIntArray, PoolVector2Array) triangulatePolygon; 77 } 78 /// 79 pragma(inline, true) bool opEquals(in GeometrySingleton other) const 80 { return _godot_object.ptr is other._godot_object.ptr; } 81 /// 82 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 83 { _godot_object.ptr = n; return null; } 84 /// 85 pragma(inline, true) bool opEquals(typeof(null) n) const 86 { return _godot_object.ptr is n; } 87 /// 88 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 89 mixin baseCasts; 90 /// Construct a new instance of GeometrySingleton. 91 /// Note: use `memnew!GeometrySingleton` instead. 92 static GeometrySingleton _new() 93 { 94 static godot_class_constructor constructor; 95 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("_Geometry"); 96 if(constructor is null) return typeof(this).init; 97 return cast(GeometrySingleton)(constructor()); 98 } 99 @disable new(size_t s); 100 /// 101 enum PolyEndType : int 102 { 103 /** 104 Endpoints are joined using the $(D polyjointype) value and the path filled as a polygon. 105 */ 106 endPolygon = 0, 107 /** 108 Endpoints are joined using the $(D polyjointype) value and the path filled as a polyline. 109 */ 110 endJoined = 1, 111 /** 112 Endpoints are squared off with no extension. 113 */ 114 endButt = 2, 115 /** 116 Endpoints are squared off and extended by `delta` units. 117 */ 118 endSquare = 3, 119 /** 120 Endpoints are rounded off and extended by `delta` units. 121 */ 122 endRound = 4, 123 } 124 /// 125 enum PolyBooleanOperation : int 126 { 127 /** 128 Create regions where either subject or clip polygons (or both) are filled. 129 */ 130 operationUnion = 0, 131 /** 132 Create regions where subject polygons are filled except where clip polygons are filled. 133 */ 134 operationDifference = 1, 135 /** 136 Create regions where both subject and clip polygons are filled. 137 */ 138 operationIntersection = 2, 139 /** 140 Create regions where either subject or clip polygons are filled but not where both are filled. 141 */ 142 operationXor = 3, 143 } 144 /// 145 enum PolyJoinType : int 146 { 147 /** 148 Squaring is applied uniformally at all convex edge joins at `1 * delta`. 149 */ 150 joinSquare = 0, 151 /** 152 While flattened paths can never perfectly trace an arc, they are approximated by a series of arc chords. 153 */ 154 joinRound = 1, 155 /** 156 There's a necessary limit to mitered joins since offsetting edges that join at very acute angles will produce excessively long and narrow "spikes". For any given edge join, when miter offsetting would exceed that maximum distance, "square" joining is applied. 157 */ 158 joinMiter = 2, 159 } 160 /// 161 enum Constants : int 162 { 163 endPolygon = 0, 164 operationUnion = 0, 165 joinSquare = 0, 166 endJoined = 1, 167 operationDifference = 1, 168 joinRound = 1, 169 endButt = 2, 170 joinMiter = 2, 171 operationIntersection = 2, 172 endSquare = 3, 173 operationXor = 3, 174 endRound = 4, 175 } 176 /** 177 Returns an array with 6 $(D Plane)s that describe the sides of a box centered at the origin. The box size is defined by `extents`, which represents one (positive) corner of the box (i.e. half its actual size). 178 */ 179 Array buildBoxPlanes(in Vector3 extents) 180 { 181 checkClassBinding!(typeof(this))(); 182 return ptrcall!(Array)(GDNativeClassBinding.buildBoxPlanes, _godot_object, extents); 183 } 184 /** 185 Returns an array of $(D Plane)s closely bounding a faceted capsule centered at the origin with radius `radius` and height `height`. The parameter `sides` defines how many planes will be generated for the side part of the capsule, whereas `lats` gives the number of latitudinal steps at the bottom and top of the capsule. The parameter `axis` describes the axis along which the capsule is oriented (0 for X, 1 for Y, 2 for Z). 186 */ 187 Array buildCapsulePlanes(in double radius, in double height, in long sides, in long lats, in long axis = 2) 188 { 189 checkClassBinding!(typeof(this))(); 190 return ptrcall!(Array)(GDNativeClassBinding.buildCapsulePlanes, _godot_object, radius, height, sides, lats, axis); 191 } 192 /** 193 Returns an array of $(D Plane)s closely bounding a faceted cylinder centered at the origin with radius `radius` and height `height`. The parameter `sides` defines how many planes will be generated for the round part of the cylinder. The parameter `axis` describes the axis along which the cylinder is oriented (0 for X, 1 for Y, 2 for Z). 194 */ 195 Array buildCylinderPlanes(in double radius, in double height, in long sides, in long axis = 2) 196 { 197 checkClassBinding!(typeof(this))(); 198 return ptrcall!(Array)(GDNativeClassBinding.buildCylinderPlanes, _godot_object, radius, height, sides, axis); 199 } 200 /** 201 Clips the polygon defined by the points in `points` against the `plane` and returns the points of the clipped polygon. 202 */ 203 PoolVector3Array clipPolygon(in PoolVector3Array points, in Plane plane) 204 { 205 checkClassBinding!(typeof(this))(); 206 return ptrcall!(PoolVector3Array)(GDNativeClassBinding.clipPolygon, _godot_object, points, plane); 207 } 208 /** 209 Clips `polygon_a` against `polygon_b` and returns an array of clipped polygons. This performs $(D constant OPERATION_DIFFERENCE) between polygons. Returns an empty array if `polygon_b` completely overlaps `polygon_a`. 210 If `polygon_b` is enclosed by `polygon_a`, returns an outer polygon (boundary) and inner polygon (hole) which could be distinguished by calling $(D isPolygonClockwise). 211 */ 212 Array clipPolygons2d(in PoolVector2Array polygon_a, in PoolVector2Array polygon_b) 213 { 214 checkClassBinding!(typeof(this))(); 215 return ptrcall!(Array)(GDNativeClassBinding.clipPolygons2d, _godot_object, polygon_a, polygon_b); 216 } 217 /** 218 Clips `polyline` against `polygon` and returns an array of clipped polylines. This performs $(D constant OPERATION_DIFFERENCE) between the polyline and the polygon. This operation can be thought of as cutting a line with a closed shape. 219 */ 220 Array clipPolylineWithPolygon2d(in PoolVector2Array polyline, in PoolVector2Array polygon) 221 { 222 checkClassBinding!(typeof(this))(); 223 return ptrcall!(Array)(GDNativeClassBinding.clipPolylineWithPolygon2d, _godot_object, polyline, polygon); 224 } 225 /** 226 Given an array of $(D Vector2)s, returns the convex hull as a list of points in counterclockwise order. The last point is the same as the first one. 227 */ 228 PoolVector2Array convexHull2d(in PoolVector2Array points) 229 { 230 checkClassBinding!(typeof(this))(); 231 return ptrcall!(PoolVector2Array)(GDNativeClassBinding.convexHull2d, _godot_object, points); 232 } 233 /** 234 Mutually excludes common area defined by intersection of `polygon_a` and `polygon_b` (see $(D intersectPolygons2d)) and returns an array of excluded polygons. This performs $(D constant OPERATION_XOR) between polygons. In other words, returns all but common area between polygons. 235 The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling $(D isPolygonClockwise). 236 */ 237 Array excludePolygons2d(in PoolVector2Array polygon_a, in PoolVector2Array polygon_b) 238 { 239 checkClassBinding!(typeof(this))(); 240 return ptrcall!(Array)(GDNativeClassBinding.excludePolygons2d, _godot_object, polygon_a, polygon_b); 241 } 242 /** 243 Returns the 3D point on the 3D segment (`s1`, `s2`) that is closest to `point`. The returned point will always be inside the specified segment. 244 */ 245 Vector3 getClosestPointToSegment(in Vector3 point, in Vector3 s1, in Vector3 s2) 246 { 247 checkClassBinding!(typeof(this))(); 248 return ptrcall!(Vector3)(GDNativeClassBinding.getClosestPointToSegment, _godot_object, point, s1, s2); 249 } 250 /** 251 Returns the 2D point on the 2D segment (`s1`, `s2`) that is closest to `point`. The returned point will always be inside the specified segment. 252 */ 253 Vector2 getClosestPointToSegment2d(in Vector2 point, in Vector2 s1, in Vector2 s2) 254 { 255 checkClassBinding!(typeof(this))(); 256 return ptrcall!(Vector2)(GDNativeClassBinding.getClosestPointToSegment2d, _godot_object, point, s1, s2); 257 } 258 /** 259 Returns the 3D point on the 3D line defined by (`s1`, `s2`) that is closest to `point`. The returned point can be inside the segment (`s1`, `s2`) or outside of it, i.e. somewhere on the line extending from the segment. 260 */ 261 Vector3 getClosestPointToSegmentUncapped(in Vector3 point, in Vector3 s1, in Vector3 s2) 262 { 263 checkClassBinding!(typeof(this))(); 264 return ptrcall!(Vector3)(GDNativeClassBinding.getClosestPointToSegmentUncapped, _godot_object, point, s1, s2); 265 } 266 /** 267 Returns the 2D point on the 2D line defined by (`s1`, `s2`) that is closest to `point`. The returned point can be inside the segment (`s1`, `s2`) or outside of it, i.e. somewhere on the line extending from the segment. 268 */ 269 Vector2 getClosestPointToSegmentUncapped2d(in Vector2 point, in Vector2 s1, in Vector2 s2) 270 { 271 checkClassBinding!(typeof(this))(); 272 return ptrcall!(Vector2)(GDNativeClassBinding.getClosestPointToSegmentUncapped2d, _godot_object, point, s1, s2); 273 } 274 /** 275 Given the two 3D segments (`p1`, `p2`) and (`q1`, `q2`), finds those two points on the two segments that are closest to each other. Returns a $(D PoolVector3Array) that contains this point on (`p1`, `p2`) as well the accompanying point on (`q1`, `q2`). 276 */ 277 PoolVector3Array getClosestPointsBetweenSegments(in Vector3 p1, in Vector3 p2, in Vector3 q1, in Vector3 q2) 278 { 279 checkClassBinding!(typeof(this))(); 280 return ptrcall!(PoolVector3Array)(GDNativeClassBinding.getClosestPointsBetweenSegments, _godot_object, p1, p2, q1, q2); 281 } 282 /** 283 Given the two 2D segments (`p1`, `q1`) and (`p2`, `q2`), finds those two points on the two segments that are closest to each other. Returns a $(D PoolVector2Array) that contains this point on (`p1`, `q1`) as well the accompanying point on (`p2`, `q2`). 284 */ 285 PoolVector2Array getClosestPointsBetweenSegments2d(in Vector2 p1, in Vector2 q1, in Vector2 p2, in Vector2 q2) 286 { 287 checkClassBinding!(typeof(this))(); 288 return ptrcall!(PoolVector2Array)(GDNativeClassBinding.getClosestPointsBetweenSegments2d, _godot_object, p1, q1, p2, q2); 289 } 290 /** 291 Used internally by the engine. 292 */ 293 long getUv84NormalBit(in Vector3 normal) 294 { 295 checkClassBinding!(typeof(this))(); 296 return ptrcall!(long)(GDNativeClassBinding.getUv84NormalBit, _godot_object, normal); 297 } 298 /** 299 Intersects `polygon_a` with `polygon_b` and returns an array of intersected polygons. This performs $(D constant OPERATION_INTERSECTION) between polygons. In other words, returns common area shared by polygons. Returns an empty array if no intersection occurs. 300 The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling $(D isPolygonClockwise). 301 */ 302 Array intersectPolygons2d(in PoolVector2Array polygon_a, in PoolVector2Array polygon_b) 303 { 304 checkClassBinding!(typeof(this))(); 305 return ptrcall!(Array)(GDNativeClassBinding.intersectPolygons2d, _godot_object, polygon_a, polygon_b); 306 } 307 /** 308 Intersects `polyline` with `polygon` and returns an array of intersected polylines. This performs $(D constant OPERATION_INTERSECTION) between the polyline and the polygon. This operation can be thought of as chopping a line with a closed shape. 309 */ 310 Array intersectPolylineWithPolygon2d(in PoolVector2Array polyline, in PoolVector2Array polygon) 311 { 312 checkClassBinding!(typeof(this))(); 313 return ptrcall!(Array)(GDNativeClassBinding.intersectPolylineWithPolygon2d, _godot_object, polyline, polygon); 314 } 315 /** 316 Returns `true` if `point` is inside the circle or if it's located exactly $(I on) the circle's boundary, otherwise returns `false`. 317 */ 318 bool isPointInCircle(in Vector2 point, in Vector2 circle_position, in double circle_radius) 319 { 320 checkClassBinding!(typeof(this))(); 321 return ptrcall!(bool)(GDNativeClassBinding.isPointInCircle, _godot_object, point, circle_position, circle_radius); 322 } 323 /** 324 Returns `true` if `point` is inside `polygon` or if it's located exactly $(I on) polygon's boundary, otherwise returns `false`. 325 */ 326 bool isPointInPolygon(in Vector2 point, in PoolVector2Array polygon) 327 { 328 checkClassBinding!(typeof(this))(); 329 return ptrcall!(bool)(GDNativeClassBinding.isPointInPolygon, _godot_object, point, polygon); 330 } 331 /** 332 Returns `true` if `polygon`'s vertices are ordered in clockwise order, otherwise returns `false`. 333 */ 334 bool isPolygonClockwise(in PoolVector2Array polygon) 335 { 336 checkClassBinding!(typeof(this))(); 337 return ptrcall!(bool)(GDNativeClassBinding.isPolygonClockwise, _godot_object, polygon); 338 } 339 /** 340 Checks if the two lines (`from_a`, `dir_a`) and (`from_b`, `dir_b`) intersect. If yes, return the point of intersection as $(D Vector2). If no intersection takes place, returns an empty $(D Variant). 341 $(B Note:) The lines are specified using direction vectors, not end points. 342 */ 343 Variant lineIntersectsLine2d(in Vector2 from_a, in Vector2 dir_a, in Vector2 from_b, in Vector2 dir_b) 344 { 345 checkClassBinding!(typeof(this))(); 346 return ptrcall!(Variant)(GDNativeClassBinding.lineIntersectsLine2d, _godot_object, from_a, dir_a, from_b, dir_b); 347 } 348 /** 349 Given an array of $(D Vector2)s representing tiles, builds an atlas. The returned dictionary has two keys: `points` is a vector of $(D Vector2) that specifies the positions of each tile, `size` contains the overall size of the whole atlas as $(D Vector2). 350 */ 351 Dictionary makeAtlas(in PoolVector2Array sizes) 352 { 353 checkClassBinding!(typeof(this))(); 354 return ptrcall!(Dictionary)(GDNativeClassBinding.makeAtlas, _godot_object, sizes); 355 } 356 /** 357 Merges (combines) `polygon_a` and `polygon_b` and returns an array of merged polygons. This performs $(D constant OPERATION_UNION) between polygons. 358 The operation may result in an outer polygon (boundary) and multiple inner polygons (holes) produced which could be distinguished by calling $(D isPolygonClockwise). 359 */ 360 Array mergePolygons2d(in PoolVector2Array polygon_a, in PoolVector2Array polygon_b) 361 { 362 checkClassBinding!(typeof(this))(); 363 return ptrcall!(Array)(GDNativeClassBinding.mergePolygons2d, _godot_object, polygon_a, polygon_b); 364 } 365 /** 366 Inflates or deflates `polygon` by `delta` units (pixels). If `delta` is positive, makes the polygon grow outward. If `delta` is negative, shrinks the polygon inward. Returns an array of polygons because inflating/deflating may result in multiple discrete polygons. Returns an empty array if `delta` is negative and the absolute value of it approximately exceeds the minimum bounding rectangle dimensions of the polygon. 367 Each polygon's vertices will be rounded as determined by `join_type`, see $(D polyjointype). 368 The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling $(D isPolygonClockwise). 369 $(B Note:) To translate the polygon's vertices specifically, use the $(D Transform2D.xform) method: 370 371 372 var polygon = PoolVector2Array($(D Vector2(0, 0), Vector2(100, 0), Vector2(100, 100), Vector2(0, 100))) 373 var offset = Vector2(50, 50) 374 polygon = Transform2D(0, offset).xform(polygon) 375 print(polygon) # prints $(D Vector2(50, 50), Vector2(150, 50), Vector2(150, 150), Vector2(50, 150)) 376 377 378 */ 379 Array offsetPolygon2d(in PoolVector2Array polygon, in double delta, in long join_type = 0) 380 { 381 checkClassBinding!(typeof(this))(); 382 return ptrcall!(Array)(GDNativeClassBinding.offsetPolygon2d, _godot_object, polygon, delta, join_type); 383 } 384 /** 385 Inflates or deflates `polyline` by `delta` units (pixels), producing polygons. If `delta` is positive, makes the polyline grow outward. Returns an array of polygons because inflating/deflating may result in multiple discrete polygons. If `delta` is negative, returns an empty array. 386 Each polygon's vertices will be rounded as determined by `join_type`, see $(D polyjointype). 387 Each polygon's endpoints will be rounded as determined by `end_type`, see $(D polyendtype). 388 The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling $(D isPolygonClockwise). 389 */ 390 Array offsetPolyline2d(in PoolVector2Array polyline, in double delta, in long join_type = 0, in long end_type = 3) 391 { 392 checkClassBinding!(typeof(this))(); 393 return ptrcall!(Array)(GDNativeClassBinding.offsetPolyline2d, _godot_object, polyline, delta, join_type, end_type); 394 } 395 /** 396 Returns if `point` is inside the triangle specified by `a`, `b` and `c`. 397 */ 398 bool pointIsInsideTriangle(in Vector2 point, in Vector2 a, in Vector2 b, in Vector2 c) const 399 { 400 checkClassBinding!(typeof(this))(); 401 return ptrcall!(bool)(GDNativeClassBinding.pointIsInsideTriangle, _godot_object, point, a, b, c); 402 } 403 /** 404 Tests if the 3D ray starting at `from` with the direction of `dir` intersects the triangle specified by `a`, `b` and `c`. If yes, returns the point of intersection as $(D Vector3). If no intersection takes place, an empty $(D Variant) is returned. 405 */ 406 Variant rayIntersectsTriangle(in Vector3 from, in Vector3 dir, in Vector3 a, in Vector3 b, in Vector3 c) 407 { 408 checkClassBinding!(typeof(this))(); 409 return ptrcall!(Variant)(GDNativeClassBinding.rayIntersectsTriangle, _godot_object, from, dir, a, b, c); 410 } 411 /** 412 Given the 2D segment (`segment_from`, `segment_to`), returns the position on the segment (as a number between 0 and 1) at which the segment hits the circle that is located at position `circle_position` and has radius `circle_radius`. If the segment does not intersect the circle, -1 is returned (this is also the case if the line extending the segment would intersect the circle, but the segment does not). 413 */ 414 double segmentIntersectsCircle(in Vector2 segment_from, in Vector2 segment_to, in Vector2 circle_position, in double circle_radius) 415 { 416 checkClassBinding!(typeof(this))(); 417 return ptrcall!(double)(GDNativeClassBinding.segmentIntersectsCircle, _godot_object, segment_from, segment_to, circle_position, circle_radius); 418 } 419 /** 420 Given a convex hull defined though the $(D Plane)s in the array `planes`, tests if the segment (`from`, `to`) intersects with that hull. If an intersection is found, returns a $(D PoolVector3Array) containing the point the intersection and the hull's normal. If no intersecion is found, an the returned array is empty. 421 */ 422 PoolVector3Array segmentIntersectsConvex(in Vector3 from, in Vector3 to, in Array planes) 423 { 424 checkClassBinding!(typeof(this))(); 425 return ptrcall!(PoolVector3Array)(GDNativeClassBinding.segmentIntersectsConvex, _godot_object, from, to, planes); 426 } 427 /** 428 Checks if the segment (`from`, `to`) intersects the cylinder with height `height` that is centered at the origin and has radius `radius`. If no, returns an empty $(D PoolVector3Array). If an intersection takes place, the returned array contains the point of intersection and the cylinder's normal at the point of intersection. 429 */ 430 PoolVector3Array segmentIntersectsCylinder(in Vector3 from, in Vector3 to, in double height, in double radius) 431 { 432 checkClassBinding!(typeof(this))(); 433 return ptrcall!(PoolVector3Array)(GDNativeClassBinding.segmentIntersectsCylinder, _godot_object, from, to, height, radius); 434 } 435 /** 436 Checks if the two segments (`from_a`, `to_a`) and (`from_b`, `to_b`) intersect. If yes, return the point of intersection as $(D Vector2). If no intersection takes place, returns an empty $(D Variant). 437 */ 438 Variant segmentIntersectsSegment2d(in Vector2 from_a, in Vector2 to_a, in Vector2 from_b, in Vector2 to_b) 439 { 440 checkClassBinding!(typeof(this))(); 441 return ptrcall!(Variant)(GDNativeClassBinding.segmentIntersectsSegment2d, _godot_object, from_a, to_a, from_b, to_b); 442 } 443 /** 444 Checks if the segment (`from`, `to`) intersects the sphere that is located at `sphere_position` and has radius `sphere_radius`. If no, returns an empty $(D PoolVector3Array). If yes, returns a $(D PoolVector3Array) containing the point of intersection and the sphere's normal at the point of intersection. 445 */ 446 PoolVector3Array segmentIntersectsSphere(in Vector3 from, in Vector3 to, in Vector3 sphere_position, in double sphere_radius) 447 { 448 checkClassBinding!(typeof(this))(); 449 return ptrcall!(PoolVector3Array)(GDNativeClassBinding.segmentIntersectsSphere, _godot_object, from, to, sphere_position, sphere_radius); 450 } 451 /** 452 Tests if the segment (`from`, `to`) intersects the triangle `a`, `b`, `c`. If yes, returns the point of intersection as $(D Vector3). If no intersection takes place, an empty $(D Variant) is returned. 453 */ 454 Variant segmentIntersectsTriangle(in Vector3 from, in Vector3 to, in Vector3 a, in Vector3 b, in Vector3 c) 455 { 456 checkClassBinding!(typeof(this))(); 457 return ptrcall!(Variant)(GDNativeClassBinding.segmentIntersectsTriangle, _godot_object, from, to, a, b, c); 458 } 459 /** 460 Triangulates the area specified by discrete set of `points` such that no point is inside the circumcircle of any resulting triangle. Returns a $(D PoolIntArray) where each triangle consists of three consecutive point indices into `points` (i.e. the returned array will have `n * 3` elements, with `n` being the number of found triangles). If the triangulation did not succeed, an empty $(D PoolIntArray) is returned. 461 */ 462 PoolIntArray triangulateDelaunay2d(in PoolVector2Array points) 463 { 464 checkClassBinding!(typeof(this))(); 465 return ptrcall!(PoolIntArray)(GDNativeClassBinding.triangulateDelaunay2d, _godot_object, points); 466 } 467 /** 468 Triangulates the polygon specified by the points in `polygon`. Returns a $(D PoolIntArray) where each triangle consists of three consecutive point indices into `polygon` (i.e. the returned array will have `n * 3` elements, with `n` being the number of found triangles). If the triangulation did not succeed, an empty $(D PoolIntArray) is returned. 469 */ 470 PoolIntArray triangulatePolygon(in PoolVector2Array polygon) 471 { 472 checkClassBinding!(typeof(this))(); 473 return ptrcall!(PoolIntArray)(GDNativeClassBinding.triangulatePolygon, _godot_object, polygon); 474 } 475 } 476 /// Returns: the GeometrySingleton 477 @property @nogc nothrow pragma(inline, true) 478 GeometrySingleton Geometry() 479 { 480 checkClassBinding!GeometrySingleton(); 481 return GeometrySingleton(GeometrySingleton.GDNativeClassBinding._singleton); 482 }