Use GDNative API struct
This commit is contained in:
parent
cf75723fa1
commit
b62db02d8f
32 changed files with 2846 additions and 1535 deletions
|
|
@ -1,109 +1,121 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import internal.godotstrings
|
||||
|
||||
type
|
||||
Vector2* {.byref.} = object
|
||||
x*: float32
|
||||
y*: float32
|
||||
import internal.godotinternaltypes, godotcoretypes, gdnativeapi
|
||||
|
||||
proc vec2*(x, y: float32): Vector2 {.inline.} =
|
||||
Vector2(x: x, y: y)
|
||||
|
||||
proc toGodotString(self: Vector2): GodotString {.
|
||||
importc: "godot_vector2_as_string".}
|
||||
|
||||
proc `$`*(self: Vector2): string {.inline.} =
|
||||
$self.toGodotString()
|
||||
$getGDNativeAPI().vector2AsString(self)
|
||||
|
||||
proc normalized*(self: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_normalized".}
|
||||
proc length*(self: Vector2): float32 {.
|
||||
importc: "godot_vector2_length".}
|
||||
proc angle*(self: Vector2): float32 {.
|
||||
importc: "godot_vector2_angle".}
|
||||
proc lengthSquared*(self: Vector2): float32 {.
|
||||
importc: "godot_vector2_length_squared".}
|
||||
proc isNormalized*(self: Vector2): bool {.
|
||||
importc: "godot_vector2_is_normalized".}
|
||||
proc distanceTo*(self, to: Vector2): float32 {.
|
||||
importc: "godot_vector2_distance_to".}
|
||||
proc distanceSquaredTo*(self, to: Vector2): float32 {.
|
||||
importc: "godot_vector2_distance_squared_to".}
|
||||
proc angleTo*(self, to: Vector2): float32 {.
|
||||
importc: "godot_vector2_angle_to".}
|
||||
proc angleToPoint*(self, to: Vector2): float32 {.
|
||||
importc: "godot_vector2_angle_to_point".}
|
||||
proc lerp*(self, b: Vector2; t: float32): Vector2 {.
|
||||
importc: "godot_vector2_linear_interpolate".}
|
||||
proc cubicInterpolate*(self, b, pre_a, post_b: Vector2; t: float32): Vector2 {.
|
||||
importc: "godot_vector2_cubic_interpolate".}
|
||||
proc rotated*(self: Vector2; phi: float32): Vector2 {.
|
||||
importc: "godot_vector2_rotated".}
|
||||
proc tangent*(self: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_tangent".}
|
||||
proc floor*(self: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_floor".}
|
||||
proc snapped*(self: Vector2; by: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_snapped".}
|
||||
proc aspect*(self: Vector2): float32 {.
|
||||
importc: "godot_vector2_aspect".}
|
||||
proc dot*(a, b: Vector2): float32 {.
|
||||
importc: "godot_vector2_dot".}
|
||||
proc slide*(self, n: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_slide".}
|
||||
proc bounce*(self, n: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_bounce".}
|
||||
proc reflect*(self, n: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_reflect".}
|
||||
proc abs*(self: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_abs".}
|
||||
proc clamped*(self: Vector2; length: float32): Vector2 {.
|
||||
importc: "godot_vector2_clamped".}
|
||||
proc normalized*(self: Vector2): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2Normalized(self)
|
||||
|
||||
proc `+`*(a, b: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_operator_add".}
|
||||
proc `+=`*(a: var Vector2, b: Vector2) {.inline.} =
|
||||
a += b
|
||||
proc length*(self: Vector2): float32 {.inline.} =
|
||||
getGDNativeAPI().vector2Length(self)
|
||||
|
||||
proc `-`*(a, b: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_operator_substract".}
|
||||
proc `-=`*(a: var Vector2, b: Vector2) {.inline.} =
|
||||
a = a - b
|
||||
proc angle*(self: Vector2): float32 {.inline.} =
|
||||
getGDNativeAPI().vector2Angle(self)
|
||||
|
||||
proc `*`*(a, b: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_operator_multiply_vector".}
|
||||
proc lengthSquared*(self: Vector2): float32 {.inline.} =
|
||||
getGDNativeAPI().vector2LengthSquared(self)
|
||||
|
||||
proc `*=`*(a: var Vector2, b: Vector2) {.inline.} =
|
||||
a = a * b
|
||||
proc isNormalized*(self: Vector2): bool {.inline.} =
|
||||
getGDNativeAPI().vector2IsNormalized(self)
|
||||
|
||||
proc distanceTo*(self, to: Vector2): float32 {.inline.} =
|
||||
getGDNativeAPI().vector2DistanceTo(self, to)
|
||||
|
||||
proc distanceSquaredTo*(self, to: Vector2): float32 {.inline.} =
|
||||
getGDNativeAPI().vector2DistanceSquaredTo(self, to)
|
||||
|
||||
proc angleTo*(self, to: Vector2): float32 {.inline.} =
|
||||
getGDNativeAPI().vector2AngleTo(self, to)
|
||||
|
||||
proc angleToPoint*(self, to: Vector2): float32 {.inline.} =
|
||||
getGDNativeAPI().vector2AngleToPoint(self, to)
|
||||
|
||||
proc lerp*(self, b: Vector2; t: float32): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2LinearInterpolate(self, b, t)
|
||||
|
||||
proc cubicInterpolate*(self, b, preA, postB: Vector2;
|
||||
t: float32): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2CubicInterpolate(self, b, preA, postB, t)
|
||||
|
||||
proc rotated*(self: Vector2; phi: float32): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2Rotated(self, phi)
|
||||
|
||||
proc tangent*(self: Vector2): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2Tangent(self)
|
||||
|
||||
proc floor*(self: Vector2): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2Floor(self)
|
||||
|
||||
proc snapped*(self: Vector2; by: Vector2): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2Snapped(self, by)
|
||||
|
||||
proc aspect*(self: Vector2): float32 {.inline.} =
|
||||
getGDNativeAPI().vector2Aspect(self)
|
||||
|
||||
proc dot*(a, b: Vector2): float32 {.inline.} =
|
||||
getGDNativeAPI().vector2Dot(a, b)
|
||||
|
||||
proc slide*(self, n: Vector2): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2Slide(self, n)
|
||||
|
||||
proc bounce*(self, n: Vector2): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2Bounce(self, n)
|
||||
|
||||
proc reflect*(self, n: Vector2): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2Reflect(self, n)
|
||||
|
||||
proc abs*(self: Vector2): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2Abs(self)
|
||||
|
||||
proc clamped*(self: Vector2; length: float32): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2Clamped(self, length)
|
||||
|
||||
proc `+`*(self, other: Vector2): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2OperatorAdd(self, other)
|
||||
|
||||
proc `+=`*(self: var Vector2, other: Vector2) {.inline.} =
|
||||
self += other
|
||||
|
||||
proc `-`*(self, other: Vector2): Vector2 =
|
||||
getGDNativeAPI().vector2OperatorSubtract(self, other)
|
||||
|
||||
proc `-=`*(self: var Vector2, other: Vector2) {.inline.} =
|
||||
self = self - other
|
||||
|
||||
proc `*`*(self, other: Vector2): Vector2 =
|
||||
getGDNativeAPI().vector2OperatorMultiplyVector(self, other)
|
||||
|
||||
proc `*=`*(self: var Vector2, other: Vector2) {.inline.} =
|
||||
self = self * other
|
||||
|
||||
proc `*`*(self: Vector2, scalar: float32): Vector2 =
|
||||
getGDNativeAPI().vector2OperatorMultiplyScalar(self, scalar)
|
||||
|
||||
proc `*`*(self: Vector2, scalar: float32): Vector2 {.
|
||||
importc: "godot_vector2_operator_multiply_scalar".}
|
||||
proc `*=`*(self: var Vector2, scalar: float32) {.inline.} =
|
||||
self = self * scalar
|
||||
|
||||
proc `/`*(a, b: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_operator_divide_vector".}
|
||||
proc `/=`*(a: var Vector2, b: Vector2) {.inline.} =
|
||||
a = a / b
|
||||
proc `/`*(self, other: Vector2): Vector2 =
|
||||
getGDNativeAPI().vector2OperatorDivideVector(self, other)
|
||||
|
||||
proc `/=`*(self: var Vector2, other: Vector2) {.inline.} =
|
||||
self = self / other
|
||||
|
||||
proc `/`*(self: Vector2; scalar: float32): Vector2 =
|
||||
getGDNativeAPI().vector2OperatorDivideScalar(self, scalar)
|
||||
|
||||
proc `/`*(self: Vector2; scalar: float32): Vector2 {.
|
||||
importc: "godot_vector2_operator_divide_scalar".}
|
||||
proc `/=`*(self: var Vector2; scalar: float32) {.inline.} =
|
||||
self = self / scalar
|
||||
|
||||
proc `==`*(a, b: Vector2): bool {.
|
||||
importc: "godot_vector2_operator_equal".}
|
||||
proc `<`*(a, b: Vector2): bool {.
|
||||
importc: "godot_vector2_operator_less".}
|
||||
proc `-`*(self: Vector2): Vector2 {.
|
||||
importc: "godot_vector2_operator_neg".}
|
||||
proc `==`*(self, other: Vector2): bool {.inline.} =
|
||||
getGDNativeAPI().vector2OperatorEqual(self, other)
|
||||
|
||||
proc `x=`*(self: var Vector2; x: float32) {.
|
||||
importc: "godot_vector2_set_x".}
|
||||
proc `y=`*(self: var Vector2; y: float32) {.
|
||||
importc: "godot_vector2_set_y".}
|
||||
proc x*(self: Vector2): float32 {.
|
||||
importc: "godot_vector2_get_x".}
|
||||
proc y*(self: Vector2): float32 {.
|
||||
importc: "godot_vector2_get_y".}
|
||||
proc `<`*(self, other: Vector2): bool {.inline.} =
|
||||
getGDNativeAPI().vector2OperatorLess(self, other)
|
||||
|
||||
proc `-`*(self: Vector2): Vector2 {.inline.} =
|
||||
getGDNativeAPI().vector2OperatorNeg(self)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue