Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Vector.h
Go to the documentation of this file.
1// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "../BasicTypes.h"
7#include "../Containers/FString.h"
8#include "Color.h"
9#include "IntPoint.h"
10#include "Vector2D.h"
11#include "../Misc/ByteSwap.h"
12#include "IntVector.h"
13
14struct FRotator;
15
16#pragma warning(push)
17#pragma warning(disable : 4244)
18
19/**
20 * A vector in 3-D space composed of components (X, Y, Z) with floating point precision.
21 */
22struct FVector
23{
24public:
25
26 /** Vector's X component. */
27 float X;
28
29 /** Vector's Y component. */
30 float Y;
31
32 /** Vector's Z component. */
33 float Z;
34
35
36public:
37
38 static const FVector ZeroVector;
39
40 /** Default constructor */
41 FORCEINLINE FVector() : X(0), Y(0), Z(0)
42 {};
43
44 /**
45 * Constructor initializing all components to a single float value.
46 *
47 * @param InF Value to set all components to.
48 */
49 explicit FORCEINLINE FVector(float InF);
50
51 /**
52 * Constructor using initial values for each component.
53 *
54 * @param InX X Coordinate.
55 * @param InY Y Coordinate.
56 * @param InZ Z Coordinate.
57 */
58 FORCEINLINE CONSTEXPR FVector(float InX, float InY, float InZ);
59
60 /**
61 * Constructs a vector from an FVector2D and Z value.
62 *
63 * @param V Vector to copy from.
64 * @param InZ Z Coordinate.
65 */
66 explicit FORCEINLINE FVector(const FVector2D V, float InZ);
67
68 /**
69 * Constructs a vector from an FLinearColor.
70 *
71 * @param InColor Color to copy from.
72 */
73 explicit FVector(const FLinearColor& InColor);
74
75 /**
76 * Constructs a vector from an FIntVector.
77 *
78 * @param InVector FIntVector to copy from.
79 */
80 explicit FVector(FIntVector InVector);
81
82 /**
83 * Constructs a vector from an FIntPoint.
84 *
85 * @param A Int Point used to set X and Y coordinates, Z is set to zero.
86 */
87 explicit FVector(FIntPoint A);
88
89 /**
90 * Constructor which initializes all components to zero.
91 *
92 * @param EForceInit Force init enum
93 */
94 explicit FORCEINLINE FVector(EForceInit);
95
96#ifdef IMPLEMENT_ASSIGNMENT_OPERATOR_MANUALLY
97 /**
98 * Copy another FVector into this one
99 *
100 * @param Other The other vector.
101 * @return Reference to vector after copy.
102 */
104#endif
105
106 /**
107 * Calculate cross product between this and another vector.
108 *
109 * @param V The other vector.
110 * @return The cross product.
111 */
112 FORCEINLINE FVector operator^(const FVector& V) const;
113
114 /**
115 * Calculate the cross product of two vectors.
116 *
117 * @param A The first vector.
118 * @param B The second vector.
119 * @return The cross product.
120 */
121 FORCEINLINE static FVector CrossProduct(const FVector& A, const FVector& B);
122
123 /**
124 * Calculate the dot product between this and another vector.
125 *
126 * @param V The other vector.
127 * @return The dot product.
128 */
129 FORCEINLINE float operator|(const FVector& V) const;
130
131 /**
132 * Calculate the dot product of two vectors.
133 *
134 * @param A The first vector.
135 * @param B The second vector.
136 * @return The dot product.
137 */
138 FORCEINLINE static float DotProduct(const FVector& A, const FVector& B);
139
140 /**
141 * Gets the result of component-wise addition of this and another vector.
142 *
143 * @param V The vector to add to this.
144 * @return The result of vector addition.
145 */
146 FORCEINLINE FVector operator+(const FVector& V) const;
147
148 /**
149 * Gets the result of component-wise subtraction of this by another vector.
150 *
151 * @param V The vector to subtract from this.
152 * @return The result of vector subtraction.
153 */
154 FORCEINLINE FVector operator-(const FVector& V) const;
155
156 /**
157 * Gets the result of subtracting from each component of the vector.
158 *
159 * @param Bias How much to subtract from each component.
160 * @return The result of subtraction.
161 */
162 FORCEINLINE FVector operator-(float Bias) const;
163
164 /**
165 * Gets the result of adding to each component of the vector.
166 *
167 * @param Bias How much to add to each component.
168 * @return The result of addition.
169 */
170 FORCEINLINE FVector operator+(float Bias) const;
171
172 /**
173 * Gets the result of scaling the vector (multiplying each component by a value).
174 *
175 * @param Scale What to multiply each component by.
176 * @return The result of multiplication.
177 */
178 FORCEINLINE FVector operator*(float Scale) const;
179
180 /**
181 * Gets the result of dividing each component of the vector by a value.
182 *
183 * @param Scale What to divide each component by.
184 * @return The result of division.
185 */
186 FVector operator/(float Scale) const;
187
188 /**
189 * Gets the result of component-wise multiplication of this vector by another.
190 *
191 * @param V The vector to multiply with.
192 * @return The result of multiplication.
193 */
194 FORCEINLINE FVector operator*(const FVector& V) const;
195
196 /**
197 * Gets the result of component-wise division of this vector by another.
198 *
199 * @param V The vector to divide by.
200 * @return The result of division.
201 */
202 FORCEINLINE FVector operator/(const FVector& V) const;
203
204 // Binary comparison operators.
205
206 /**
207 * Check against another vector for equality.
208 *
209 * @param V The vector to check against.
210 * @return true if the vectors are equal, false otherwise.
211 */
212 bool operator==(const FVector& V) const;
213
214 /**
215 * Check against another vector for inequality.
216 *
217 * @param V The vector to check against.
218 * @return true if the vectors are not equal, false otherwise.
219 */
220 bool operator!=(const FVector& V) const;
221
222 /**
223 * Check against another vector for equality, within specified error limits.
224 *
225 * @param V The vector to check against.
226 * @param Tolerance Error tolerance.
227 * @return true if the vectors are equal within tolerance limits, false otherwise.
228 */
229 bool Equals(const FVector& V, float Tolerance=KINDA_SMALL_NUMBER) const;
230
231 /**
232 * Checks whether all components of this vector are the same, within a tolerance.
233 *
234 * @param Tolerance Error tolerance.
235 * @return true if the vectors are equal within tolerance limits, false otherwise.
236 */
237 bool AllComponentsEqual(float Tolerance=KINDA_SMALL_NUMBER) const;
238
239 /**
240 * Get a negated copy of the vector.
241 *
242 * @return A negated copy of the vector.
243 */
244 FORCEINLINE FVector operator-() const;
245
246 /**
247 * Adds another vector to this.
248 * Uses component-wise addition.
249 *
250 * @param V Vector to add to this.
251 * @return Copy of the vector after addition.
252 */
253 FORCEINLINE FVector operator+=(const FVector& V);
254
255 /**
256 * Subtracts another vector from this.
257 * Uses component-wise subtraction.
258 *
259 * @param V Vector to subtract from this.
260 * @return Copy of the vector after subtraction.
261 */
262 FORCEINLINE FVector operator-=(const FVector& V);
263
264 /**
265 * Scales the vector.
266 *
267 * @param Scale Amount to scale this vector by.
268 * @return Copy of the vector after scaling.
269 */
270 FORCEINLINE FVector operator*=(float Scale);
271
272 /**
273 * Divides the vector by a number.
274 *
275 * @param V What to divide this vector by.
276 * @return Copy of the vector after division.
277 */
278 FVector operator/=(float V);
279
280 /**
281 * Multiplies the vector with another vector, using component-wise multiplication.
282 *
283 * @param V What to multiply this vector with.
284 * @return Copy of the vector after multiplication.
285 */
286 FVector operator*=(const FVector& V);
287
288 /**
289 * Divides the vector by another vector, using component-wise division.
290 *
291 * @param V What to divide vector by.
292 * @return Copy of the vector after division.
293 */
294 FVector operator/=(const FVector& V);
295
296 /**
297 * Gets specific component of the vector.
298 *
299 * @param Index the index of vector component
300 * @return reference to component.
301 */
302 float& operator[](int32 Index);
303
304 /**
305 * Gets specific component of the vector.
306 *
307 * @param Index the index of vector component
308 * @return Copy of the component.
309 */
310 float operator[](int32 Index)const;
311
312 /**
313 * Gets a specific component of the vector.
314 *
315 * @param Index The index of the component required.
316 *
317 * @return Reference to the specified component.
318 */
319 float& Component(int32 Index);
320
321 /**
322 * Gets a specific component of the vector.
323 *
324 * @param Index The index of the component required.
325 * @return Copy of the specified component.
326 */
327 float Component(int32 Index) const;
328
329public:
330
331 // Simple functions.
332
333 /**
334 * Set the values of the vector directly.
335 *
336 * @param InX New X coordinate.
337 * @param InY New Y coordinate.
338 * @param InZ New Z coordinate.
339 */
340 void Set(float InX, float InY, float InZ);
341
342 /**
343 * Get the maximum value of the vector's components.
344 *
345 * @return The maximum value of the vector's components.
346 */
347 float GetMax() const;
348
349 /**
350 * Get the maximum absolute value of the vector's components.
351 *
352 * @return The maximum absolute value of the vector's components.
353 */
354 float GetAbsMax() const;
355
356 /**
357 * Get the minimum value of the vector's components.
358 *
359 * @return The minimum value of the vector's components.
360 */
361 float GetMin() const;
362
363 /**
364 * Get the minimum absolute value of the vector's components.
365 *
366 * @return The minimum absolute value of the vector's components.
367 */
368 float GetAbsMin() const;
369
370 /** Gets the component-wise min of two vectors. */
371 FVector ComponentMin(const FVector& Other) const;
372
373 /** Gets the component-wise max of two vectors. */
374 FVector ComponentMax(const FVector& Other) const;
375
376 /**
377 * Get a copy of this vector with absolute value of each component.
378 *
379 * @return A copy of this vector with absolute value of each component.
380 */
381 FVector GetAbs() const;
382
383 /**
384 * Get the length (magnitude) of this vector.
385 *
386 * @return The length of this vector.
387 */
388 float Size() const;
389
390 /**
391 * Get the squared length of this vector.
392 *
393 * @return The squared length of this vector.
394 */
395 float SizeSquared() const;
396
397 /**
398 * Get the length of the 2D components of this vector.
399 *
400 * @return The 2D length of this vector.
401 */
402 float Size2D() const ;
403
404 /**
405 * Get the squared length of the 2D components of this vector.
406 *
407 * @return The squared 2D length of this vector.
408 */
409 float SizeSquared2D() const ;
410
411 /**
412 * Checks whether vector is near to zero within a specified tolerance.
413 *
414 * @param Tolerance Error tolerance.
415 * @return true if the vector is near to zero, false otherwise.
416 */
417 bool IsNearlyZero(float Tolerance=KINDA_SMALL_NUMBER) const;
418
419 /**
420 * Checks whether all components of the vector are exactly zero.
421 *
422 * @return true if the vector is exactly zero, false otherwise.
423 */
424 bool IsZero() const;
425
426 /**
427 * Normalize this vector in-place if it is larger than a given tolerance. Leaves it unchanged if not.
428 *
429 * @param Tolerance Minimum squared length of vector for normalization.
430 * @return true if the vector was normalized correctly, false otherwise.
431 */
432 bool Normalize(float Tolerance=SMALL_NUMBER);
433
434 /**
435 * Checks whether vector is normalized.
436 *
437 * @return true if Normalized, false otherwise.
438 */
439 bool IsNormalized() const;
440
441 /**
442 * Util to convert this vector into a unit direction vector and its original length.
443 *
444 * @param OutDir Reference passed in to store unit direction vector.
445 * @param OutLength Reference passed in to store length of the vector.
446 */
447 void ToDirectionAndLength(FVector &OutDir, float &OutLength) const;
448
449 /**
450 * Get a copy of the vector as sign only.
451 * Each component is set to +1 or -1, with the sign of zero treated as +1.
452 *
453 * @param A copy of the vector with each component set to +1 or -1
454 */
455 FORCEINLINE FVector GetSignVector() const;
456
457 /**
458 * Projects 2D components of vector based on Z.
459 *
460 * @return Projected version of vector based on Z.
461 */
462 FVector Projection() const;
463
464 /**
465 * Calculates normalized version of vector without checking for zero length.
466 *
467 * @return Normalized version of vector.
468 * @see GetSafeNormal()
469 */
470 FORCEINLINE FVector GetUnsafeNormal() const;
471
472 /**
473 * Gets a copy of this vector snapped to a grid.
474 *
475 * @param GridSz Grid dimension.
476 * @return A copy of this vector snapped to a grid.
477 * @see FMath::GridSnap()
478 */
479 FVector GridSnap(const float& GridSz) const;
480
481 /**
482 * Get a copy of this vector, clamped inside of a cube.
483 *
484 * @param Radius Half size of the cube.
485 * @return A copy of this vector, bound by cube.
486 */
487 FVector BoundToCube(float Radius) const;
488
489 /** Create a copy of this vector, with its magnitude clamped between Min and Max. */
490 FVector GetClampedToSize(float Min, float Max) const;
491
492 /** Create a copy of this vector, with the 2D magnitude clamped between Min and Max. Z is unchanged. */
493 FVector GetClampedToSize2D(float Min, float Max) const;
494
495 /** Create a copy of this vector, with its maximum magnitude clamped to MaxSize. */
496 FVector GetClampedToMaxSize(float MaxSize) const;
497
498 /** Create a copy of this vector, with the maximum 2D magnitude clamped to MaxSize. Z is unchanged. */
499 FVector GetClampedToMaxSize2D(float MaxSize) const;
500
501 /**
502 * Gets the reciprocal of this vector, avoiding division by zero.
503 * Zero components are set to BIG_NUMBER.
504 *
505 * @return Reciprocal of this vector.
506 */
507 FVector Reciprocal() const;
508
509 /**
510 * Check whether X, Y and Z are nearly equal.
511 *
512 * @param Tolerance Specified Tolerance.
513 * @return true if X == Y == Z within the specified tolerance.
514 */
515 bool IsUniform(float Tolerance=KINDA_SMALL_NUMBER) const;
516
517 /**
518 * Mirror a vector about a normal vector.
519 *
520 * @param MirrorNormal Normal vector to mirror about.
521 * @return Mirrored vector.
522 */
523 FVector MirrorByVector(const FVector& MirrorNormal) const;
524
525 /**
526 * Rotates around Axis (assumes Axis.Size() == 1).
527 *
528 * @param Angle Angle to rotate (in degrees).
529 * @param Axis Axis to rotate around.
530 * @return Rotated Vector.
531 */
532 FVector RotateAngleAxis(const float AngleDeg, const FVector& Axis) const;
533
534 /**
535 * Gets a normalized copy of the vector, checking it is safe to do so based on the length.
536 * Returns zero vector if vector length is too small to safely normalize.
537 *
538 * @param Tolerance Minimum squared vector length.
539 * @return A normalized copy if safe, (0,0,0) otherwise.
540 */
541 FVector GetSafeNormal(float Tolerance=SMALL_NUMBER) const;
542
543 /**
544 * Gets a normalized copy of the 2D components of the vector, checking it is safe to do so. Z is set to zero.
545 * Returns zero vector if vector length is too small to normalize.
546 *
547 * @param Tolerance Minimum squared vector length.
548 * @return Normalized copy if safe, otherwise returns zero vector.
549 */
550 FVector GetSafeNormal2D(float Tolerance=SMALL_NUMBER) const;
551
552 /**
553 * Returns the cosine of the angle between this vector and another projected onto the XY plane (no Z).
554 *
555 * @param B the other vector to find the 2D cosine of the angle with.
556 * @return The cosine.
557 */
558 FORCEINLINE float CosineAngle2D(FVector B) const;
559
560 /**
561 * Gets a copy of this vector projected onto the input vector.
562 *
563 * @param A Vector to project onto, does not assume it is normalized.
564 * @return Projected vector.
565 */
566 FORCEINLINE FVector ProjectOnTo(const FVector& A) const ;
567
568 /**
569 * Gets a copy of this vector projected onto the input vector, which is assumed to be unit length.
570 *
571 * @param Normal Vector to project onto (assumed to be unit length).
572 * @return Projected vector.
573 */
574 FORCEINLINE FVector ProjectOnToNormal(const FVector& Normal) const;
575
576 /**
577 * Return the FRotator orientation corresponding to the direction in which the vector points.
578 * Sets Yaw and Pitch to the proper numbers, and sets Roll to zero because the roll can't be determined from a vector.
579 *
580 * @return FRotator from the Vector's direction, without any roll.
581 * @see ToOrientationQuat()
582 */
584
585 /**
586 * Return the Quaternion orientation corresponding to the direction in which the vector points.
587 * Similar to the FRotator version, returns a result without roll such that it preserves the up vector.
588 *
589 * @note If you don't care about preserving the up vector and just want the most direct rotation, you can use the faster
590 * 'FQuat::FindBetweenVectors(FVector::ForwardVector, YourVector)' or 'FQuat::FindBetweenNormals(...)' if you know the vector is of unit length.
591 *
592 * @return Quaternion from the Vector's direction, without any roll.
593 * @see ToOrientationRotator(), FQuat::FindBetweenVectors()
594 */
595 FQuat ToOrientationQuat() const;
596
597 /**
598 * Return the FRotator orientation corresponding to the direction in which the vector points.
599 * Sets Yaw and Pitch to the proper numbers, and sets Roll to zero because the roll can't be determined from a vector.
600 * @note Identical to 'ToOrientationRotator()' and preserved for legacy reasons.
601 * @return FRotator from the Vector's direction.
602 * @see ToOrientationRotator(), ToOrientationQuat()
603 */
605
606 /**
607 * Find good arbitrary axis vectors to represent U and V axes of a plane,
608 * using this vector as the normal of the plane.
609 *
610 * @param Axis1 Reference to first axis.
611 * @param Axis2 Reference to second axis.
612 */
613 void FindBestAxisVectors(FVector& Axis1, FVector& Axis2) const;
614
615 /** When this vector contains Euler angles (degrees), ensure that angles are between +/-180 */
617
618 /**
619 * Utility to check if there are any non-finite values (NaN or Inf) in this vector.
620 *
621 * @return true if there are any non-finite values in this vector, false otherwise.
622 */
623 bool ContainsNaN() const;
624
625 /**
626 * Check if the vector is of unit length, with specified tolerance.
627 *
628 * @param LengthSquaredTolerance Tolerance against squared length.
629 * @return true if the vector is a unit vector within the specified tolerance.
630 */
631 FORCEINLINE bool IsUnit(float LengthSquaredTolerance = KINDA_SMALL_NUMBER) const;
632
633 /**
634 * Get a textual representation of this vector.
635 *
636 * @return A string describing the vector.
637 */
638 FString ToString() const;
639
640 /**
641 * Initialize this Vector based on an FString. The String is expected to contain X=, Y=, Z=.
642 * The FVector will be bogus when InitFromString returns false.
643 *
644 * @param InSourceString FString containing the vector values.
645 * @return true if the X,Y,Z values were read successfully; false otherwise.
646 */
647 bool InitFromString(const FString& InSourceString);
648
649 /**
650 * Converts a Cartesian unit vector into spherical coordinates on the unit sphere.
651 * @return Output Theta will be in the range [0, PI], and output Phi will be in the range [-PI, PI].
652 */
654
655 /**
656 * Convert a direction vector into a 'heading' angle.
657 *
658 * @return 'Heading' angle between +/-PI. 0 is pointing down +X.
659 */
660 float HeadingAngle() const;
661
662 /**
663 * Create an orthonormal basis from a basis with at least two orthogonal vectors.
664 * It may change the directions of the X and Y axes to make the basis orthogonal,
665 * but it won't change the direction of the Z axis.
666 * All axes will be normalized.
667 *
668 * @param XAxis The input basis' XAxis, and upon return the orthonormal basis' XAxis.
669 * @param YAxis The input basis' YAxis, and upon return the orthonormal basis' YAxis.
670 * @param ZAxis The input basis' ZAxis, and upon return the orthonormal basis' ZAxis.
671 */
672 static void CreateOrthonormalBasis(FVector& XAxis,FVector& YAxis,FVector& ZAxis);
673
674 /**
675 * Compare two points and see if they're the same, using a threshold.
676 *
677 * @param P First vector.
678 * @param Q Second vector.
679 * @return Whether points are the same within a threshold. Uses fast distance approximation (linear per-component distance).
680 */
681 static bool PointsAreSame(const FVector &P, const FVector &Q);
682
683 /**
684 * Compare two points and see if they're within specified distance.
685 *
686 * @param Point1 First vector.
687 * @param Point2 Second vector.
688 * @param Dist Specified distance.
689 * @return Whether two points are within the specified distance. Uses fast distance approximation (linear per-component distance).
690 */
691 static bool PointsAreNear(const FVector &Point1, const FVector &Point2, float Dist);
692
693 /**
694 * Calculate the signed distance (in the direction of the normal) between a point and a plane.
695 *
696 * @param Point The Point we are checking.
697 * @param PlaneBase The Base Point in the plane.
698 * @param PlaneNormal The Normal of the plane (assumed to be unit length).
699 * @return Signed distance between point and plane.
700 */
701 static float PointPlaneDist(const FVector &Point, const FVector &PlaneBase, const FVector &PlaneNormal);
702
703 /**
704 * Calculate the projection of a point on the plane defined by counter-clockwise (CCW) points A,B,C.
705 *
706 * @param Point The point to project onto the plane
707 * @param A 1st of three points in CCW order defining the plane
708 * @param B 2nd of three points in CCW order defining the plane
709 * @param C 3rd of three points in CCW order defining the plane
710 * @return Projection of Point onto plane ABC
711 */
712 static FVector PointPlaneProject(const FVector& Point, const FVector& A, const FVector& B, const FVector& C);
713
714 /**
715 * Calculate the projection of a point on the plane defined by PlaneBase and PlaneNormal.
716 *
717 * @param Point The point to project onto the plane
718 * @param PlaneBase Point on the plane
719 * @param PlaneNorm Normal of the plane (assumed to be unit length).
720 * @return Projection of Point onto plane
721 */
722 static FVector PointPlaneProject(const FVector& Point, const FVector& PlaneBase, const FVector& PlaneNormal);
723
724 /**
725 * Calculate the projection of a vector on the plane defined by PlaneNormal.
726 *
727 * @param V The vector to project onto the plane.
728 * @param PlaneNormal Normal of the plane (assumed to be unit length).
729 * @return Projection of V onto plane.
730 */
731 static FVector VectorPlaneProject(const FVector& V, const FVector& PlaneNormal);
732
733 /**
734 * Euclidean distance between two points.
735 *
736 * @param V1 The first point.
737 * @param V2 The second point.
738 * @return The distance between two points.
739 */
740 static FORCEINLINE float Dist(const FVector &V1, const FVector &V2);
741 static FORCEINLINE float Distance(const FVector &V1, const FVector &V2) { return Dist(V1, V2); }
742
743 /**
744 * Euclidean distance between two points in the XY plane (ignoring Z).
745 *
746 * @param V1 The first point.
747 * @param V2 The second point.
748 * @return The distance between two points in the XY plane.
749 */
750 static FORCEINLINE float DistXY(const FVector &V1, const FVector &V2);
751 static FORCEINLINE float Dist2D(const FVector &V1, const FVector &V2) { return DistXY(V1, V2); }
752
753 /**
754 * Squared distance between two points.
755 *
756 * @param V1 The first point.
757 * @param V2 The second point.
758 * @return The squared distance between two points.
759 */
760 static FORCEINLINE float DistSquared(const FVector &V1, const FVector &V2);
761
762 /**
763 * Squared distance between two points in the XY plane only.
764 *
765 * @param V1 The first point.
766 * @param V2 The second point.
767 * @return The squared distance between two points in the XY plane
768 */
769 static FORCEINLINE float DistSquaredXY(const FVector &V1, const FVector &V2);
770 static FORCEINLINE float DistSquared2D(const FVector &V1, const FVector &V2) { return DistSquaredXY(V1, V2); }
771
772 /**
773 * Compute pushout of a box from a plane.
774 *
775 * @param Normal The plane normal.
776 * @param Size The size of the box.
777 * @return Pushout required.
778 */
779 static FORCEINLINE float BoxPushOut(const FVector& Normal, const FVector& Size);
780
781 /**
782 * See if two normal vectors are nearly parallel, meaning the angle between them is close to 0 degrees.
783 *
784 * @param Normal1 First normalized vector.
785 * @param Normal1 Second normalized vector.
786 * @param ParallelCosineThreshold Normals are parallel if absolute value of dot product (cosine of angle between them) is greater than or equal to this. For example: cos(1.0 degrees).
787 * @return true if vectors are nearly parallel, false otherwise.
788 */
789 static bool Parallel(const FVector& Normal1, const FVector& Normal2, float ParallelCosineThreshold = THRESH_NORMALS_ARE_PARALLEL);
790
791 /**
792 * See if two normal vectors are coincident (nearly parallel and point in the same direction).
793 *
794 * @param Normal1 First normalized vector.
795 * @param Normal2 Second normalized vector.
796 * @param ParallelCosineThreshold Normals are coincident if dot product (cosine of angle between them) is greater than or equal to this. For example: cos(1.0 degrees).
797 * @return true if vectors are coincident (nearly parallel and point in the same direction), false otherwise.
798 */
799 static bool Coincident(const FVector& Normal1, const FVector& Normal2, float ParallelCosineThreshold = THRESH_NORMALS_ARE_PARALLEL);
800
801 /**
802 * See if two normal vectors are nearly orthogonal (perpendicular), meaning the angle between them is close to 90 degrees.
803 *
804 * @param Normal1 First normalized vector.
805 * @param Normal2 Second normalized vector.
806 * @param OrthogonalCosineThreshold Normals are orthogonal if absolute value of dot product (cosine of angle between them) is less than or equal to this. For example: cos(89.0 degrees).
807 * @return true if vectors are orthogonal (perpendicular), false otherwise.
808 */
809 static bool Orthogonal(const FVector& Normal1, const FVector& Normal2, float OrthogonalCosineThreshold = THRESH_NORMALS_ARE_ORTHOGONAL);
810
811 /**
812 * See if two planes are coplanar. They are coplanar if the normals are nearly parallel and the planes include the same set of points.
813 *
814 * @param Base1 The base point in the first plane.
815 * @param Normal1 The normal of the first plane.
816 * @param Base2 The base point in the second plane.
817 * @param Normal2 The normal of the second plane.
818 * @param ParallelCosineThreshold Normals are parallel if absolute value of dot product is greater than or equal to this.
819 * @return true if the planes are coplanar, false otherwise.
820 */
821 static bool Coplanar(const FVector& Base1, const FVector& Normal1, const FVector& Base2, const FVector& Normal2, float ParallelCosineThreshold = THRESH_NORMALS_ARE_PARALLEL);
822
823 /**
824 * Triple product of three vectors: X dot (Y cross Z).
825 *
826 * @param X The first vector.
827 * @param Y The second vector.
828 * @param Z The third vector.
829 * @return The triple product: X dot (Y cross Z).
830 */
831 static float Triple(const FVector& X, const FVector& Y, const FVector& Z);
832
833 /**
834 * Generates a list of sample points on a Bezier curve defined by 2 points.
835 *
836 * @param ControlPoints Array of 4 FVectors (vert1, controlpoint1, controlpoint2, vert2).
837 * @param NumPoints Number of samples.
838 * @param OutPoints Receives the output samples.
839 * @return The path length.
840 */
841 static float EvaluateBezier(const FVector* ControlPoints, int32 NumPoints, TArray<FVector>& OutPoints);
842
843 /**
844 * Converts a vector containing radian values to a vector containing degree values.
845 *
846 * @param RadVector Vector containing radian values
847 * @return Vector containing degree values
848 */
849 static FVector RadiansToDegrees(const FVector& RadVector);
850
851 /**
852 * Converts a vector containing degree values to a vector containing radian values.
853 *
854 * @param DegVector Vector containing degree values
855 * @return Vector containing radian values
856 */
857 static FVector DegreesToRadians(const FVector& DegVector);
858};
859
860/* FVector inline functions
861 *****************************************************************************/
862
863/**
864 * Multiplies a vector by a scaling factor.
865 *
866 * @param Scale Scaling factor.
867 * @param V Vector to scale.
868 * @return Result of multiplication.
869 */
870FORCEINLINE FVector operator*(float Scale, const FVector& V)
871{
872 return V.operator*(Scale);
873}
874
876 #define INTEL_ORDER_VECTOR(x) (x)
877#else
878 static FORCEINLINE FVector INTEL_ORDER_VECTOR(FVector v)
879 {
880 return FVector(INTEL_ORDERF(v.X), INTEL_ORDERF(v.Y), INTEL_ORDERF(v.Z));
881 }
882#endif
883
884
885/**
886 * Util to calculate distance from a point to a bounding box
887 *
888 * @param Mins 3D Point defining the lower values of the axis of the bound box
889 * @param Max 3D Point defining the lower values of the axis of the bound box
890 * @param Point 3D position of interest
891 * @return the distance from the Point to the bounding box.
892 */
893FORCEINLINE float ComputeSquaredDistanceFromBoxToPoint(const FVector& Mins, const FVector& Maxs, const FVector& Point)
894{
895 // Accumulates the distance as we iterate axis
896 float DistSquared = 0.f;
897
898 // Check each axis for min/max and add the distance accordingly
899 // NOTE: Loop manually unrolled for > 2x speed up
900 if (Point.X < Mins.X)
901 {
902 DistSquared += FMath::Square(Point.X - Mins.X);
903 }
904 else if (Point.X > Maxs.X)
905 {
906 DistSquared += FMath::Square(Point.X - Maxs.X);
907 }
908
909 if (Point.Y < Mins.Y)
910 {
911 DistSquared += FMath::Square(Point.Y - Mins.Y);
912 }
913 else if (Point.Y > Maxs.Y)
914 {
915 DistSquared += FMath::Square(Point.Y - Maxs.Y);
916 }
917
918 if (Point.Z < Mins.Z)
919 {
920 DistSquared += FMath::Square(Point.Z - Mins.Z);
921 }
922 else if (Point.Z > Maxs.Z)
923 {
924 DistSquared += FMath::Square(Point.Z - Maxs.Z);
925 }
926
927 return DistSquared;
928}
929
930
931FORCEINLINE FVector::FVector(const FVector2D V, float InZ)
932 : X(V.X), Y(V.Y), Z(InZ)
933{
934}
935
936FORCEINLINE FIntVector::FIntVector( FVector InVector )
937 : X(FMath::TruncToInt(InVector.X))
938 , Y(FMath::TruncToInt(InVector.Y))
939 , Z(FMath::TruncToInt(InVector.Z))
940{ }
941
942inline FVector FVector::RotateAngleAxis(const float AngleDeg, const FVector& Axis) const
943{
944 float S, C;
946
947 const float XX = Axis.X * Axis.X;
948 const float YY = Axis.Y * Axis.Y;
949 const float ZZ = Axis.Z * Axis.Z;
950
951 const float XY = Axis.X * Axis.Y;
952 const float YZ = Axis.Y * Axis.Z;
953 const float ZX = Axis.Z * Axis.X;
954
955 const float XS = Axis.X * S;
956 const float YS = Axis.Y * S;
957 const float ZS = Axis.Z * S;
958
959 const float OMC = 1.f - C;
960
961 return FVector(
962 (OMC * XX + C) * X + (OMC * XY - ZS) * Y + (OMC * ZX + YS) * Z,
963 (OMC * XY + ZS) * X + (OMC * YY + C) * Y + (OMC * YZ - XS) * Z,
964 (OMC * ZX - YS) * X + (OMC * YZ + XS) * Y + (OMC * ZZ + C) * Z
965 );
966}
967
968inline bool FVector::PointsAreSame(const FVector &P, const FVector &Q)
969{
970 float Temp;
971 Temp=P.X-Q.X;
972 if((Temp > -THRESH_POINTS_ARE_SAME) && (Temp < THRESH_POINTS_ARE_SAME))
973 {
974 Temp=P.Y-Q.Y;
975 if((Temp > -THRESH_POINTS_ARE_SAME) && (Temp < THRESH_POINTS_ARE_SAME))
976 {
977 Temp=P.Z-Q.Z;
978 if((Temp > -THRESH_POINTS_ARE_SAME) && (Temp < THRESH_POINTS_ARE_SAME))
979 {
980 return true;
981 }
982 }
983 }
984 return false;
985}
986
987inline bool FVector::PointsAreNear(const FVector &Point1, const FVector &Point2, float Dist)
988{
989 float Temp;
990 Temp=(Point1.X - Point2.X); if (FMath::Abs(Temp)>=Dist) return false;
991 Temp=(Point1.Y - Point2.Y); if (FMath::Abs(Temp)>=Dist) return false;
992 Temp=(Point1.Z - Point2.Z); if (FMath::Abs(Temp)>=Dist) return false;
993 return true;
994}
995
997(
998 const FVector &Point,
999 const FVector &PlaneBase,
1000 const FVector &PlaneNormal
1001)
1002{
1003 return (Point - PlaneBase) | PlaneNormal;
1004}
1005
1006
1007inline FVector FVector::PointPlaneProject(const FVector& Point, const FVector& PlaneBase, const FVector& PlaneNorm)
1008{
1009 //Find the distance of X from the plane
1010 //Add the distance back along the normal from the point
1011 return Point - FVector::PointPlaneDist(Point,PlaneBase,PlaneNorm) * PlaneNorm;
1012}
1013
1014inline FVector FVector::VectorPlaneProject(const FVector& V, const FVector& PlaneNormal)
1015{
1016 return V - V.ProjectOnToNormal(PlaneNormal);
1017}
1018
1019inline bool FVector::Parallel(const FVector& Normal1, const FVector& Normal2, float ParallelCosineThreshold)
1020{
1021 const float NormalDot = Normal1 | Normal2;
1022 return FMath::Abs(NormalDot) >= ParallelCosineThreshold;
1023}
1024
1025inline bool FVector::Coincident(const FVector& Normal1, const FVector& Normal2, float ParallelCosineThreshold)
1026{
1027 const float NormalDot = Normal1 | Normal2;
1028 return NormalDot >= ParallelCosineThreshold;
1029}
1030
1031inline bool FVector::Orthogonal(const FVector& Normal1, const FVector& Normal2, float OrthogonalCosineThreshold)
1032{
1033 const float NormalDot = Normal1 | Normal2;
1034 return FMath::Abs(NormalDot) <= OrthogonalCosineThreshold;
1035}
1036
1037inline bool FVector::Coplanar(const FVector &Base1, const FVector &Normal1, const FVector &Base2, const FVector &Normal2, float ParallelCosineThreshold)
1038{
1039 if (!FVector::Parallel(Normal1,Normal2,ParallelCosineThreshold)) return false;
1040 else if (FVector::PointPlaneDist (Base2,Base1,Normal1) > THRESH_POINT_ON_PLANE) return false;
1041 else return true;
1042}
1043
1044inline float FVector::Triple(const FVector& X, const FVector& Y, const FVector& Z)
1045{
1046 return
1047 ( (X.X * (Y.Y * Z.Z - Y.Z * Z.Y))
1048 + (X.Y * (Y.Z * Z.X - Y.X * Z.Z))
1049 + (X.Z * (Y.X * Z.Y - Y.Y * Z.X)));
1050}
1051
1052inline FVector FVector::RadiansToDegrees(const FVector& RadVector)
1053{
1054 return RadVector * (180.f / PI);
1055}
1056
1057inline FVector FVector::DegreesToRadians(const FVector& DegVector)
1058{
1059 return DegVector * (PI / 180.f);
1060}
1061
1062FORCEINLINE FVector::FVector(float InF)
1063 : X(InF), Y(InF), Z(InF)
1064{
1065}
1066
1067FORCEINLINE CONSTEXPR FVector::FVector(float InX, float InY, float InZ)
1068 : X(InX), Y(InY), Z(InZ)
1069{
1070}
1071
1072FORCEINLINE FVector::FVector(const FLinearColor& InColor)
1073 : X(InColor.R), Y(InColor.G), Z(InColor.B)
1074{
1075}
1076
1077FORCEINLINE FVector::FVector(FIntVector InVector)
1078 : X(InVector.X), Y(InVector.Y), Z(InVector.Z)
1079{
1080}
1081
1083 : X(A.X), Y(A.Y), Z(0.f)
1084{
1085}
1086
1088 : X(0.0f), Y(0.0f), Z(0.0f)
1089{
1090}
1091
1092#ifdef IMPLEMENT_ASSIGNMENT_OPERATOR_MANUALLY
1093FORCEINLINE FVector& FVector::operator=(const FVector& Other)
1094{
1095 this->X = Other.X;
1096 this->Y = Other.Y;
1097 this->Z = Other.Z;
1098
1099 DiagnosticCheckNaN();
1100
1101 return *this;
1102}
1103#endif
1104
1105FORCEINLINE FVector FVector::operator^(const FVector& V) const
1106{
1107 return FVector
1108 (
1109 Y * V.Z - Z * V.Y,
1110 Z * V.X - X * V.Z,
1111 X * V.Y - Y * V.X
1112 );
1113}
1114
1115FORCEINLINE FVector FVector::CrossProduct(const FVector& A, const FVector& B)
1116{
1117 return A ^ B;
1118}
1119
1120FORCEINLINE float FVector::operator|(const FVector& V) const
1121{
1122 return X*V.X + Y*V.Y + Z*V.Z;
1123}
1124
1125FORCEINLINE float FVector::DotProduct(const FVector& A, const FVector& B)
1126{
1127 return A | B;
1128}
1129
1130FORCEINLINE FVector FVector::operator+(const FVector& V) const
1131{
1132 return FVector(X + V.X, Y + V.Y, Z + V.Z);
1133}
1134
1135FORCEINLINE FVector FVector::operator-(const FVector& V) const
1136{
1137 return FVector(X - V.X, Y - V.Y, Z - V.Z);
1138}
1139
1140FORCEINLINE FVector FVector::operator-(float Bias) const
1141{
1142 return FVector(X - Bias, Y - Bias, Z - Bias);
1143}
1144
1145FORCEINLINE FVector FVector::operator+(float Bias) const
1146{
1147 return FVector(X + Bias, Y + Bias, Z + Bias);
1148}
1149
1150FORCEINLINE FVector FVector::operator*(float Scale) const
1151{
1152 return FVector(X * Scale, Y * Scale, Z * Scale);
1153}
1154
1155FORCEINLINE FVector FVector::operator/(float Scale) const
1156{
1157 const float RScale = 1.f/Scale;
1158 return FVector(X * RScale, Y * RScale, Z * RScale);
1159}
1160
1161FORCEINLINE FVector FVector::operator*(const FVector& V) const
1162{
1163 return FVector(X * V.X, Y * V.Y, Z * V.Z);
1164}
1165
1166FORCEINLINE FVector FVector::operator/(const FVector& V) const
1167{
1168 return FVector(X / V.X, Y / V.Y, Z / V.Z);
1169}
1170
1171FORCEINLINE bool FVector::operator==(const FVector& V) const
1172{
1173 return X==V.X && Y==V.Y && Z==V.Z;
1174}
1175
1176FORCEINLINE bool FVector::operator!=(const FVector& V) const
1177{
1178 return X!=V.X || Y!=V.Y || Z!=V.Z;
1179}
1180
1181FORCEINLINE bool FVector::Equals(const FVector& V, float Tolerance) const
1182{
1183 return FMath::Abs(X-V.X) <= Tolerance && FMath::Abs(Y-V.Y) <= Tolerance && FMath::Abs(Z-V.Z) <= Tolerance;
1184}
1185
1186FORCEINLINE bool FVector::AllComponentsEqual(float Tolerance) const
1187{
1188 return FMath::Abs(X - Y) <= Tolerance && FMath::Abs(X - Z) <= Tolerance && FMath::Abs(Y - Z) <= Tolerance;
1189}
1190
1191
1192FORCEINLINE FVector FVector::operator-() const
1193{
1194 return FVector(-X, -Y, -Z);
1195}
1196
1197
1198FORCEINLINE FVector FVector::operator+=(const FVector& V)
1199{
1200 X += V.X; Y += V.Y; Z += V.Z;
1201 return *this;
1202}
1203
1204FORCEINLINE FVector FVector::operator-=(const FVector& V)
1205{
1206 X -= V.X; Y -= V.Y; Z -= V.Z;
1207 return *this;
1208}
1209
1210FORCEINLINE FVector FVector::operator*=(float Scale)
1211{
1212 X *= Scale; Y *= Scale; Z *= Scale;
1213 return *this;
1214}
1215
1216FORCEINLINE FVector FVector::operator/=(float V)
1217{
1218 const float RV = 1.f/V;
1219 X *= RV; Y *= RV; Z *= RV;
1220 return *this;
1221}
1222
1223FORCEINLINE FVector FVector::operator*=(const FVector& V)
1224{
1225 X *= V.X; Y *= V.Y; Z *= V.Z;
1226 return *this;
1227}
1228
1229FORCEINLINE FVector FVector::operator/=(const FVector& V)
1230{
1231 X /= V.X; Y /= V.Y; Z /= V.Z;
1232 return *this;
1233}
1234
1235FORCEINLINE float& FVector::operator[](int32 Index)
1236{
1237 check(Index >= 0 && Index < 3);
1238 if(Index == 0)
1239 {
1240 return X;
1241 }
1242 else if(Index == 1)
1243 {
1244 return Y;
1245 }
1246 else
1247 {
1248 return Z;
1249 }
1250}
1251
1252FORCEINLINE float FVector::operator[](int32 Index)const
1253{
1254 check(Index >= 0 && Index < 3);
1255 if(Index == 0)
1256 {
1257 return X;
1258 }
1259 else if(Index == 1)
1260 {
1261 return Y;
1262 }
1263 else
1264 {
1265 return Z;
1266 }
1267}
1268
1269FORCEINLINE void FVector::Set(float InX, float InY, float InZ)
1270{
1271 X = InX;
1272 Y = InY;
1273 Z = InZ;
1274}
1275
1276FORCEINLINE float FVector::GetMax() const
1277{
1279}
1280
1281FORCEINLINE float FVector::GetAbsMax() const
1282{
1284}
1285
1286FORCEINLINE float FVector::GetMin() const
1287{
1289}
1290
1291FORCEINLINE float FVector::GetAbsMin() const
1292{
1294}
1295
1296FORCEINLINE FVector FVector::ComponentMin(const FVector& Other) const
1297{
1299}
1300
1301FORCEINLINE FVector FVector::ComponentMax(const FVector& Other) const
1302{
1304}
1305
1306FORCEINLINE FVector FVector::GetAbs() const
1307{
1309}
1310
1311FORCEINLINE float FVector::Size() const
1312{
1313 return FMath::Sqrt(X*X + Y*Y + Z*Z);
1314}
1315
1316FORCEINLINE float FVector::SizeSquared() const
1317{
1318 return X*X + Y*Y + Z*Z;
1319}
1320
1321FORCEINLINE float FVector::Size2D() const
1322{
1323 return FMath::Sqrt(X*X + Y*Y);
1324}
1325
1326FORCEINLINE float FVector::SizeSquared2D() const
1327{
1328 return X*X + Y*Y;
1329}
1330
1331FORCEINLINE bool FVector::IsNearlyZero(float Tolerance) const
1332{
1333 return
1334 FMath::Abs(X)<=Tolerance
1335 && FMath::Abs(Y)<=Tolerance
1336 && FMath::Abs(Z)<=Tolerance;
1337}
1338
1339FORCEINLINE bool FVector::IsZero() const
1340{
1341 return X==0.f && Y==0.f && Z==0.f;
1342}
1343
1344FORCEINLINE bool FVector::Normalize(float Tolerance)
1345{
1346 const float SquareSum = X*X + Y*Y + Z*Z;
1347 if(SquareSum > Tolerance)
1348 {
1349 const float Scale = FMath::InvSqrt(SquareSum);
1350 X *= Scale; Y *= Scale; Z *= Scale;
1351 return true;
1352 }
1353 return false;
1354}
1355
1356FORCEINLINE bool FVector::IsNormalized() const
1357{
1359}
1360
1361FORCEINLINE void FVector::ToDirectionAndLength(FVector &OutDir, float &OutLength) const
1362{
1363 OutLength = Size();
1364 if (OutLength > SMALL_NUMBER)
1365 {
1366 float OneOverLength = 1.0f/OutLength;
1367 OutDir = FVector(X*OneOverLength, Y*OneOverLength,
1368 Z*OneOverLength);
1369 }
1370 else
1371 {
1372 OutDir = FVector::ZeroVector;
1373 }
1374}
1375
1376FORCEINLINE FVector FVector::GetSignVector() const
1377{
1378 return FVector
1379 (
1383 );
1384}
1385
1386FORCEINLINE FVector FVector::Projection() const
1387{
1388 const float RZ = 1.f/Z;
1389 return FVector(X*RZ, Y*RZ, 1);
1390}
1391
1392FORCEINLINE FVector FVector::GetUnsafeNormal() const
1393{
1394 const float Scale = FMath::InvSqrt(X*X+Y*Y+Z*Z);
1395 return FVector(X*Scale, Y*Scale, Z*Scale);
1396}
1397
1398FORCEINLINE FVector FVector::BoundToCube(float Radius) const
1399{
1400 return FVector
1401 (
1402 FMath::Clamp(X,-Radius,Radius),
1403 FMath::Clamp(Y,-Radius,Radius),
1404 FMath::Clamp(Z,-Radius,Radius)
1405 );
1406}
1407
1408FORCEINLINE FVector FVector::GetClampedToSize(float Min, float Max) const
1409{
1410 float VecSize = Size();
1411 const FVector VecDir = (VecSize > SMALL_NUMBER) ? (*this/VecSize) : FVector::ZeroVector;
1412
1413 VecSize = FMath::Clamp(VecSize, Min, Max);
1414
1415 return VecSize * VecDir;
1416}
1417
1418FORCEINLINE FVector FVector::GetClampedToSize2D(float Min, float Max) const
1419{
1420 float VecSize2D = Size2D();
1421 const FVector VecDir = (VecSize2D > SMALL_NUMBER) ? (*this/VecSize2D) : FVector::ZeroVector;
1422
1423 VecSize2D = FMath::Clamp(VecSize2D, Min, Max);
1424
1425 return FVector(VecSize2D * VecDir.X, VecSize2D * VecDir.Y, Z);
1426}
1427
1428FORCEINLINE FVector FVector::GetClampedToMaxSize(float MaxSize) const
1429{
1430 if (MaxSize < KINDA_SMALL_NUMBER)
1431 {
1432 return FVector::ZeroVector;
1433 }
1434
1435 const float VSq = SizeSquared();
1436 if (VSq > FMath::Square(MaxSize))
1437 {
1438 const float Scale = MaxSize * FMath::InvSqrt(VSq);
1439 return FVector(X*Scale, Y*Scale, Z*Scale);
1440 }
1441 else
1442 {
1443 return *this;
1444 }
1445}
1446
1447FORCEINLINE FVector FVector::GetClampedToMaxSize2D(float MaxSize) const
1448{
1449 if (MaxSize < KINDA_SMALL_NUMBER)
1450 {
1451 return FVector(0.f, 0.f, Z);
1452 }
1453
1454 const float VSq2D = SizeSquared2D();
1455 if (VSq2D > FMath::Square(MaxSize))
1456 {
1457 const float Scale = MaxSize * FMath::InvSqrt(VSq2D);
1458 return FVector(X*Scale, Y*Scale, Z);
1459 }
1460 else
1461 {
1462 return *this;
1463 }
1464}
1465
1466FORCEINLINE float& FVector::Component(int32 Index)
1467{
1468 return (&X)[Index];
1469}
1470
1471FORCEINLINE float FVector::Component(int32 Index) const
1472{
1473 return (&X)[Index];
1474}
1475
1476FORCEINLINE FVector FVector::Reciprocal() const
1477{
1478 FVector RecVector;
1479 if (X!=0.f)
1480 {
1481 RecVector.X = 1.f/X;
1482 }
1483 else
1484 {
1485 RecVector.X = BIG_NUMBER;
1486 }
1487 if (Y!=0.f)
1488 {
1489 RecVector.Y = 1.f/Y;
1490 }
1491 else
1492 {
1493 RecVector.Y = BIG_NUMBER;
1494 }
1495 if (Z!=0.f)
1496 {
1497 RecVector.Z = 1.f/Z;
1498 }
1499 else
1500 {
1501 RecVector.Z = BIG_NUMBER;
1502 }
1503
1504 return RecVector;
1505}
1506
1507
1508
1509
1510FORCEINLINE bool FVector::IsUniform(float Tolerance) const
1511{
1512 return AllComponentsEqual(Tolerance);
1513}
1514
1515FORCEINLINE FVector FVector::MirrorByVector(const FVector& MirrorNormal) const
1516{
1517 return *this - MirrorNormal * (2.f * (*this | MirrorNormal));
1518}
1519
1520FORCEINLINE FVector FVector::GetSafeNormal(float Tolerance) const
1521{
1522 const float SquareSum = X*X + Y*Y + Z*Z;
1523
1524 // Not sure if it's safe to add tolerance in there. Might introduce too many errors
1525 if(SquareSum == 1.f)
1526 {
1527 return *this;
1528 }
1529 else if(SquareSum < Tolerance)
1530 {
1531 return FVector(0);
1532 }
1533 const float Scale = FMath::InvSqrt(SquareSum);
1534 return FVector(X*Scale, Y*Scale, Z*Scale);
1535}
1536
1537FORCEINLINE FVector FVector::GetSafeNormal2D(float Tolerance) const
1538{
1539 const float SquareSum = X*X + Y*Y;
1540
1541 // Not sure if it's safe to add tolerance in there. Might introduce too many errors
1542 if(SquareSum == 1.f)
1543 {
1544 if(Z == 0.f)
1545 {
1546 return *this;
1547 }
1548 else
1549 {
1550 return FVector(X, Y, 0.f);
1551 }
1552 }
1553 else if(SquareSum < Tolerance)
1554 {
1555 return FVector::ZeroVector;
1556 }
1557
1558 const float Scale = FMath::InvSqrt(SquareSum);
1559 return FVector(X*Scale, Y*Scale, 0.f);
1560}
1561
1562FORCEINLINE float FVector::CosineAngle2D(FVector B) const
1563{
1564 FVector A(*this);
1565 A.Z = 0.0f;
1566 B.Z = 0.0f;
1567 A.Normalize();
1568 B.Normalize();
1569 return A | B;
1570}
1571
1572FORCEINLINE FVector FVector::ProjectOnTo(const FVector& A) const
1573{
1574 return (A * ((*this | A) / (A | A)));
1575}
1576
1577FORCEINLINE FVector FVector::ProjectOnToNormal(const FVector& Normal) const
1578{
1579 return (Normal * (*this | Normal));
1580}
1581
1582
1583FORCEINLINE bool FVector::ContainsNaN() const
1584{
1585 return (!FMath::IsFinite(X) ||
1588}
1589
1590FORCEINLINE bool FVector::IsUnit(float LengthSquaredTolerance) const
1591{
1592 return FMath::Abs(1.0f - SizeSquared()) < LengthSquaredTolerance;
1593}
1594
1595FORCEINLINE float FVector::HeadingAngle() const
1596{
1597 // Project Dir into Z plane.
1598 FVector PlaneDir = *this;
1599 PlaneDir.Z = 0.f;
1600 PlaneDir = PlaneDir.GetSafeNormal();
1601
1602 float Angle = FMath::Acos(PlaneDir.X);
1603
1604 if(PlaneDir.Y < 0.0f)
1605 {
1606 Angle *= -1.0f;
1607 }
1608
1609 return Angle;
1610}
1611
1612FORCEINLINE float FVector::Dist(const FVector &V1, const FVector &V2)
1613{
1615}
1616
1617FORCEINLINE float FVector::DistXY(const FVector &V1, const FVector &V2)
1618{
1620}
1621
1622FORCEINLINE float FVector::DistSquared(const FVector &V1, const FVector &V2)
1623{
1625}
1626
1627FORCEINLINE float FVector::DistSquaredXY(const FVector &V1, const FVector &V2)
1628{
1629 return FMath::Square(V2.X-V1.X) + FMath::Square(V2.Y-V1.Y);
1630}
1631
1632FORCEINLINE float FVector::BoxPushOut(const FVector& Normal, const FVector& Size)
1633{
1634 return FMath::Abs(Normal.X*Size.X) + FMath::Abs(Normal.Y*Size.Y) + FMath::Abs(Normal.Z*Size.Z);
1635}
1636
1637FORCEINLINE FString FVector::ToString() const
1638{
1639 wchar_t buffer[256];
1640 swprintf_s(buffer, TEXT("X=%3.3f Y=%3.3f Z=%3.3f"), X, Y, Z);
1641
1642 return FString(buffer);
1643}
1644
1645/** Component-wise clamp for FVector */
1646FORCEINLINE FVector ClampVector(const FVector& V, const FVector& Min, const FVector& Max)
1647{
1648 return FVector(
1652 );
1653}
1654
1655#pragma warning(pop)
1656
1657template <> struct TIsPODType<FVector> { enum { Value = true }; };
static unsigned int GetBuildUniqueId()
Definition Atlas.h:30
ARK_API LPVOID GetDataAddress(const std::string &name)
Definition Base.cpp:15
ARK_API BitField GetBitField(LPVOID base, const std::string &name)
Definition Base.cpp:25
ARK_API BitField GetBitField(const void *base, const std::string &name)
Definition Base.cpp:20
#define ARK_API
Definition Base.h:9
ARK_API DWORD64 GetAddress(const void *base, const std::string &name)
Definition Base.cpp:5
ARK_API LPVOID GetAddress(const std::string &name)
Definition Base.cpp:10
#define PLATFORM_LITTLE_ENDIAN
Definition BasicTypes.h:12
#define check(expr)
Definition BasicTypes.h:14
#define CONSTEXPR
Definition BasicTypes.h:7
EForceInit
Definition BasicTypes.h:147
#define THRESH_VECTOR_NORMALIZED
#define THRESH_NORMALS_ARE_PARALLEL
#define THRESH_POINTS_ARE_SAME
#define SMALL_NUMBER
#define THRESH_POINT_ON_PLANE
#define PI
#define THRESH_NORMALS_ARE_ORTHOGONAL
#define KINDA_SMALL_NUMBER
#define BIG_NUMBER
FORCEINLINE float ComputeSquaredDistanceFromBoxToPoint(const FVector &Mins, const FVector &Maxs, const FVector &Point)
Definition Vector.h:893
FORCEINLINE FVector ClampVector(const FVector &V, const FVector &Min, const FVector &Max)
Definition Vector.h:1646
FORCEINLINE FVector operator*(float Scale, const FVector &V)
Definition Vector.h:870
ApiUtils & operator=(ApiUtils &&)=delete
ApiUtils()=default
void SetCheatManager(UShooterCheatManager *cheatmanager)
Definition ApiUtils.cpp:44
void SetWorld(UWorld *uworld)
Definition ApiUtils.cpp:9
ApiUtils & operator=(const ApiUtils &)=delete
void SetShooterGameMode(AShooterGameMode *shooter_game_mode)
Definition ApiUtils.cpp:21
std::unordered_map< uint64, AShooterPlayerController * > steam_id_map_
Definition ApiUtils.h:38
UShooterCheatManager * GetCheatManager() const override
Returns a point to URCON CheatManager.
Definition ApiUtils.cpp:93
UWorld * u_world_
Definition ApiUtils.h:34
ApiUtils(ApiUtils &&)=delete
AShooterGameMode * shooter_game_mode_
Definition ApiUtils.h:35
AShooterGameMode * GetShooterGameMode() const override
Returns a pointer to AShooterGameMode.
Definition ApiUtils.cpp:26
void RemovePlayerController(AShooterPlayerController *player_controller)
Definition ApiUtils.cpp:62
UShooterCheatManager * cheatmanager_
Definition ApiUtils.h:37
void SetPlayerController(AShooterPlayerController *player_controller)
Definition ApiUtils.cpp:49
ServerStatus GetStatus() const override
Returns the current server status.
Definition ApiUtils.cpp:38
ServerStatus status_
Definition ApiUtils.h:36
AShooterPlayerController * FindPlayerFromSteamId_Internal(uint64 steam_id) const override
Definition ApiUtils.cpp:75
~ApiUtils() override=default
void SetStatus(ServerStatus status)
Definition ApiUtils.cpp:33
UWorld * GetWorld() const override
Returns a pointer to UWorld.
Definition ApiUtils.cpp:14
ApiUtils(const ApiUtils &)=delete
static FString GetSteamName(AController *player_controller)
Returns the steam name of player.
static FORCEINLINE FString GetItemBlueprint(UPrimalItem *item)
Returns blueprint from UPrimalItem.
static FVector GetPosition(APlayerController *player_controller)
Returns the position of a player.
uint64 GetSteamIDForPlayerID(int player_id) const
static FORCEINLINE FString GetClassBlueprint(UClass *the_class)
Returns blueprint path from any UClass.
void SendServerMessageToAll(FLinearColor msg_color, const T *msg, Args &&... args)
Sends server message to all players. Using fmt::format.
virtual UShooterCheatManager * GetCheatManager() const =0
Returns a point to URCON CheatManager.
UPrimalGameData * GetGameData()
Returns pointer to Primal Game Data.
static bool IsRidingDino(AShooterPlayerController *player_controller)
Returns true if character is riding a dino, false otherwise.
AShooterGameState * GetGameState()
Get Shooter Game State.
virtual ~IApiUtils()=default
AShooterPlayerController * FindPlayerFromSteamName(const FString &steam_name) const
Finds player from the given steam name.
static UShooterCheatManager * GetCheatManagerByPC(AShooterPlayerController *SPC)
Get UShooterCheatManager* of player controller.
static uint64 GetPlayerID(AController *controller)
static bool IsPlayerDead(AShooterPlayerController *player)
Returns true if player is dead, false otherwise.
void SendNotificationToAll(FLinearColor color, float display_scale, float display_time, UTexture2D *icon, const T *msg, Args &&... args)
Sends notification (on-screen message) to all players. Using fmt::format.
APrimalDinoCharacter * SpawnDino(AShooterPlayerController *player, FString blueprint, FVector *location, int lvl, bool force_tame, bool neutered) const
Spawns a dino near player or at specific coordinates.
TArray< AShooterPlayerController * > FindPlayerFromCharacterName(const FString &character_name, ESearchCase::Type search, bool full_match) const
Finds all matching players from the given character name.
static FORCEINLINE FString GetBlueprint(UObjectBase *object)
Returns blueprint path from any UObject.
static FString GetCharacterName(AShooterPlayerController *player_controller, bool include_first_name=true, bool include_last_name=true)
Returns the character name of player.
TArray< AActor * > GetAllActorsInRange(FVector location, float radius, EServerOctreeGroup::Type ActorType)
Gets all actors in radius at location.
void SendChatMessageToAll(const FString &sender_name, const T *msg, Args &&... args)
Sends chat message to all players. Using fmt::format.
TArray< AActor * > GetAllActorsInRange(FVector location, float radius, EServerOctreeGroup::Type ActorType, TArray< AActor * > ignores)
Gets all actors in radius at location, with ignore actors.
virtual AShooterGameMode * GetShooterGameMode() const =0
Returns a pointer to AShooterGameMode.
static uint64 GetSteamIdFromController(AController *controller)
Returns Steam ID from player controller.
virtual UWorld * GetWorld() const =0
Returns a pointer to UWorld.
static bool TeleportToPos(AShooterPlayerController *player_controller, const FVector &pos)
Teleports player to the given position.
void SendNotification(AShooterPlayerController *player_controller, FLinearColor color, float display_scale, float display_time, UTexture2D *icon, const T *msg, Args &&... args)
Sends notification (on-screen message) to the specific player. Using fmt::format.
static uint64 GetPlayerID(APrimalCharacter *character)
virtual AShooterPlayerController * FindPlayerFromSteamId_Internal(uint64 steam_id) const =0
AShooterPlayerController * FindControllerFromCharacter(AShooterCharacter *character) const
Finds player controller from the given player character.
static APrimalDinoCharacter * GetRidingDino(AShooterPlayerController *player_controller)
Returns the dino the character is riding.
static FString GetIPAddress(AShooterPlayerController *player_controller)
Returns IP address of player.
AShooterPlayerController * FindPlayerFromSteamId(uint64 steam_id) const
Finds player from the given steam id.
virtual ServerStatus GetStatus() const =0
Returns the current server status.
void SendServerMessage(AShooterPlayerController *player_controller, FLinearColor msg_color, const T *msg, Args &&... args)
Sends server message to the specific player. Using fmt::format.
static std::optional< FString > TeleportToPlayer(AShooterPlayerController *me, AShooterPlayerController *him, bool check_for_dino, float max_dist)
Teleport one player to another.
static int GetInventoryItemCount(AShooterPlayerController *player_controller, const FString &item_name)
Counts a specific items quantity.
void SendChatMessage(AShooterPlayerController *player_controller, const FString &sender_name, const T *msg, Args &&... args)
Sends chat message to the specific player. Using fmt::format.
FString Replace(const TCHAR *From, const TCHAR *To, ESearchCase::Type SearchCase=ESearchCase::IgnoreCase) const
Definition FString.h:2766
FORCEINLINE bool FindChar(TCHAR InChar, int32 &Index) const
Definition FString.h:1169
FORCEINLINE FString Mid(int32 Start, int32 Count=INT_MAX) const
Definition FString.h:1099
FORCEINLINE friend bool operator==(const FString &Lhs, const FString &Rhs)
Definition FString.h:994
FORCEINLINE bool FindLastChar(TCHAR InChar, int32 &Index) const
Definition FString.h:1181
FORCEINLINE FString(const CharType *Src, typename TEnableIf< TIsCharType< CharType >::Value >::Type *Dummy=nullptr)
Definition FString.h:98
FORCEINLINE friend FString operator+(const TCHAR *Lhs, FString &&Rhs)
Definition FString.h:687
bool StartsWith(const FString &InPrefix, ESearchCase::Type SearchCase=ESearchCase::IgnoreCase) const
Definition FString.h:2143
FORCEINLINE bool Equals(const FString &Other, ESearchCase::Type SearchCase=ESearchCase::CaseSensitive) const
Definition FString.h:1221
bool EndsWith(const TCHAR *InSuffix, ESearchCase::Type SearchCase=ESearchCase::IgnoreCase) const
Definition FString.h:2155
FORCEINLINE bool IsEmpty() const
Definition FString.h:241
FORCEINLINE int32 Len() const
Definition FString.h:1069
FORCEINLINE friend FString operator+(FString &&Lhs, const TCHAR *Rhs)
Definition FString.h:713
FORCEINLINE int32 Add(const ElementType &Item)
Definition TArray.h:1564
int32 Remove(const ElementType &Item)
Definition TArray.h:1709
FORCEINLINE ObjectType * Get() const
IApiUtils & GetApiUtils()
Definition ApiUtils.cpp:99
@ CaseSensitive
Definition FString.h:28
Definition json.hpp:4518
FVector & DefaultActorLocationField()
Definition Actor.h:920
int & TargetingTeamField()
Definition Actor.h:902
USceneComponent * RootComponentField()
Definition Actor.h:911
APlayerState * PlayerStateField()
Definition Actor.h:2062
UCheatManager * CheatManagerField()
Definition Actor.h:2133
FString * GetPlayerNetworkAddress(FString *result)
Definition Actor.h:2292
FUniqueNetIdRepl & UniqueIdField()
Definition Actor.h:1782
FString & PlayerNameField()
Definition Actor.h:1776
bool TeleportTo(FVector *DestLocation, FRotator *DestRotation, bool bIsATest, bool bNoCheck)
Definition Actor.h:4554
UPrimalInventoryComponent * MyInventoryComponentField()
Definition Actor.h:3798
bool IsDead()
Definition Actor.h:4360
void DoNeuter_Implementation()
Definition Actor.h:7051
static UClass * GetPrivateStaticClass()
Definition Actor.h:6963
void TameDino(AShooterPlayerController *ForPC, bool bIgnoreMaxTameLimit, int OverrideTamingTeamID)
Definition Actor.h:7328
int & TamingTeamIDField()
Definition Actor.h:6194
FString & TamerStringField()
Definition Actor.h:6057
int & AbsoluteBaseLevelField()
Definition Actor.h:6324
UPrimalPlayerData * GetPlayerData()
Definition Actor.h:5166
APrimalDinoCharacter * GetRidingDino()
Definition Actor.h:5159
unsigned __int64 GetSteamIDForPlayerID(int playerDataID)
Definition GameMode.h:1620
void AddPlayerID(int playerDataID, unsigned __int64 netUniqueID)
Definition GameMode.h:1534
__int64 & LinkedPlayerIDField()
Definition Actor.h:2504
void SetPlayerPos(float X, float Y, float Z)
Definition Actor.h:3202
AActor * SpawnActor(FString *blueprintPath, float spawnDistance, float spawnYOffset, float ZOffset, bool bDoDeferBeginPlay)
Definition Actor.h:3222
AShooterCharacter * GetPlayerCharacter()
Definition Actor.h:2916
FString * GetPlayerName(FString *result)
Definition Actor.h:1902
void SetTribeTamingDinoSettings(APrimalDinoCharacter *aDinoChar)
Definition Actor.h:1986
DWORD64 offset
Definition Base.h:674
DWORD bit_position
Definition Base.h:675
ULONGLONG length
Definition Base.h:677
ULONGLONG num_bits
Definition Base.h:676
Definition Base.h:181
Definition Actor.h:10035
ECanvasAllowModes
Definition Base.h:316
@ Allow_DeleteOnRender
Definition Base.h:318
@ Allow_Flush
Definition Base.h:317
EElementType
Definition Base.h:309
@ ET_MAX
Definition Base.h:312
@ ET_Line
Definition Base.h:310
@ ET_Triangle
Definition Base.h:311
Definition Other.h:244
Definition Actor.h:349
static FORCEINLINE float Acos(float Value)
static FORCEINLINE float InvSqrt(float F)
static CONSTEXPR FORCEINLINE T Min(const T A, const T B)
static CONSTEXPR FORCEINLINE float FloatSelect(float Comparand, float ValueGEZero, float ValueLTZero)
static FORCEINLINE float Sqrt(float Value)
static CONSTEXPR FORCEINLINE T Max(const T A, const T B)
static FORCEINLINE bool IsFinite(float A)
static CONSTEXPR FORCEINLINE int32 TruncToInt(float F)
static CONSTEXPR FORCEINLINE T Abs(const T A)
Definition Actor.h:9443
int32 X
Definition IntPoint.h:17
int32 Y
Definition IntPoint.h:20
int32 Z
Definition IntVector.h:25
int32 Y
Definition IntVector.h:22
FIntVector(FVector InVector)
Definition Vector.h:936
int32 X
Definition IntVector.h:19
Definition Inventory.h:50
Definition Base.h:120
Definition Base.h:216
float G
Definition Color.h:36
float B
Definition Color.h:37
float R
Definition Color.h:35
static FORCEINLINE T Clamp(const T X, const T Min, const T Max)
static FORCEINLINE T Square(const T A)
static FORCEINLINE void SinCos(float *ScalarSin, float *ScalarCos, float Value)
static FORCEINLINE auto DegreesToRadians(T const &DegVal) -> decltype(DegVal *(PI/180.f))
Definition Other.h:87
Definition Actor.h:9709
Definition Actor.h:9701
Definition Base.h:191
unsigned __int64 & PlayerDataIDField()
Definition Actor.h:5466
Definition Base.h:360
FORCEINLINE FRotator(float InPitch, float InYaw, float InRoll)
Definition Rotator.h:375
TSharedPtr< FUniqueNetId > UniqueNetId
Definition Actor.h:190
float Y
Definition Vector2D.h:22
float X
Definition Vector2D.h:19
FORCEINLINE FVector operator+(float Bias) const
Definition Vector.h:1145
FORCEINLINE FVector operator*=(float Scale)
Definition Vector.h:1210
bool operator!=(const FVector &V) const
Definition Vector.h:1176
FORCEINLINE FVector()
Definition Vector.h:41
static float Triple(const FVector &X, const FVector &Y, const FVector &Z)
Definition Vector.h:1044
static bool Orthogonal(const FVector &Normal1, const FVector &Normal2, float OrthogonalCosineThreshold=THRESH_NORMALS_ARE_ORTHOGONAL)
Definition Vector.h:1031
static bool Parallel(const FVector &Normal1, const FVector &Normal2, float ParallelCosineThreshold=THRESH_NORMALS_ARE_PARALLEL)
Definition Vector.h:1019
FORCEINLINE FVector operator-(const FVector &V) const
Definition Vector.h:1135
FORCEINLINE FVector operator-=(const FVector &V)
Definition Vector.h:1204
FVector GetSafeNormal(float Tolerance=SMALL_NUMBER) const
Definition Vector.h:1520
static FVector VectorPlaneProject(const FVector &V, const FVector &PlaneNormal)
Definition Vector.h:1014
FVector operator/=(const FVector &V)
Definition Vector.h:1229
static bool PointsAreSame(const FVector &P, const FVector &Q)
Definition Vector.h:968
FORCEINLINE FVector(float InF)
Definition Vector.h:1062
FORCEINLINE FVector operator+=(const FVector &V)
Definition Vector.h:1198
FORCEINLINE FVector operator-() const
Definition Vector.h:1192
FORCEINLINE FVector operator^(const FVector &V) const
Definition Vector.h:1105
bool IsUniform(float Tolerance=KINDA_SMALL_NUMBER) const
Definition Vector.h:1510
FORCEINLINE FVector operator-(float Bias) const
Definition Vector.h:1140
FRotator ToOrientationRotator() const
FVector(const FLinearColor &InColor)
Definition Vector.h:1072
FVector MirrorByVector(const FVector &MirrorNormal) const
Definition Vector.h:1515
FVector Reciprocal() const
Definition Vector.h:1476
static FORCEINLINE float DistSquaredXY(const FVector &V1, const FVector &V2)
Definition Vector.h:1627
float X
Definition Vector.h:27
static bool PointsAreNear(const FVector &Point1, const FVector &Point2, float Dist)
Definition Vector.h:987
bool InitFromString(const FString &InSourceString)
static FORCEINLINE float DotProduct(const FVector &A, const FVector &B)
Definition Vector.h:1125
float Y
Definition Vector.h:30
FVector ComponentMax(const FVector &Other) const
Definition Vector.h:1301
void ToDirectionAndLength(FVector &OutDir, float &OutLength) const
Definition Vector.h:1361
FORCEINLINE float operator|(const FVector &V) const
Definition Vector.h:1120
FRotator Rotation() const
FORCEINLINE FVector GetUnsafeNormal() const
Definition Vector.h:1392
FVector GetClampedToMaxSize(float MaxSize) const
Definition Vector.h:1428
FORCEINLINE FVector operator*(const FVector &V) const
Definition Vector.h:1161
void FindBestAxisVectors(FVector &Axis1, FVector &Axis2) const
float Size2D() const
Definition Vector.h:1321
FVector(FIntVector InVector)
Definition Vector.h:1077
static const FVector ZeroVector
Definition Vector.h:38
float SizeSquared2D() const
Definition Vector.h:1326
FVector GetSafeNormal2D(float Tolerance=SMALL_NUMBER) const
Definition Vector.h:1537
float & Component(int32 Index)
Definition Vector.h:1466
static FORCEINLINE float BoxPushOut(const FVector &Normal, const FVector &Size)
Definition Vector.h:1632
FVector operator/(float Scale) const
Definition Vector.h:1155
static FVector RadiansToDegrees(const FVector &RadVector)
Definition Vector.h:1052
float GetAbsMin() const
Definition Vector.h:1291
FVector2D UnitCartesianToSpherical() const
bool IsZero() const
Definition Vector.h:1339
FVector GetAbs() const
Definition Vector.h:1306
static float PointPlaneDist(const FVector &Point, const FVector &PlaneBase, const FVector &PlaneNormal)
Definition Vector.h:997
FVector BoundToCube(float Radius) const
Definition Vector.h:1398
static FORCEINLINE float DistSquared(const FVector &V1, const FVector &V2)
Definition Vector.h:1622
FORCEINLINE FVector GetSignVector() const
Definition Vector.h:1376
FORCEINLINE FVector operator/(const FVector &V) const
Definition Vector.h:1166
static FORCEINLINE float Dist2D(const FVector &V1, const FVector &V2)
Definition Vector.h:751
FVector ComponentMin(const FVector &Other) const
Definition Vector.h:1296
float Size() const
Definition Vector.h:1311
float GetMin() const
Definition Vector.h:1286
float Z
Definition Vector.h:33
FString ToString() const
Definition Vector.h:1637
float & operator[](int32 Index)
Definition Vector.h:1235
static FORCEINLINE float Dist(const FVector &V1, const FVector &V2)
Definition Vector.h:1612
FVector GridSnap(const float &GridSz) const
static bool Coincident(const FVector &Normal1, const FVector &Normal2, float ParallelCosineThreshold=THRESH_NORMALS_ARE_PARALLEL)
Definition Vector.h:1025
FVector Projection() const
Definition Vector.h:1386
static bool Coplanar(const FVector &Base1, const FVector &Normal1, const FVector &Base2, const FVector &Normal2, float ParallelCosineThreshold=THRESH_NORMALS_ARE_PARALLEL)
Definition Vector.h:1037
FORCEINLINE FVector ProjectOnTo(const FVector &A) const
Definition Vector.h:1572
static FVector PointPlaneProject(const FVector &Point, const FVector &PlaneBase, const FVector &PlaneNormal)
Definition Vector.h:1007
bool IsNormalized() const
Definition Vector.h:1356
FORCEINLINE FVector ProjectOnToNormal(const FVector &Normal) const
Definition Vector.h:1577
static FVector PointPlaneProject(const FVector &Point, const FVector &A, const FVector &B, const FVector &C)
void UnwindEuler()
bool Equals(const FVector &V, float Tolerance=KINDA_SMALL_NUMBER) const
Definition Vector.h:1181
FQuat ToOrientationQuat() const
bool operator==(const FVector &V) const
Definition Vector.h:1171
FVector GetClampedToSize2D(float Min, float Max) const
Definition Vector.h:1418
float SizeSquared() const
Definition Vector.h:1316
float operator[](int32 Index) const
Definition Vector.h:1252
FVector GetClampedToSize(float Min, float Max) const
Definition Vector.h:1408
float GetAbsMax() const
Definition Vector.h:1281
static FORCEINLINE float DistSquared2D(const FVector &V1, const FVector &V2)
Definition Vector.h:770
FVector operator/=(float V)
Definition Vector.h:1216
float GetMax() const
Definition Vector.h:1276
FVector(FIntPoint A)
Definition Vector.h:1082
static FORCEINLINE FVector CrossProduct(const FVector &A, const FVector &B)
Definition Vector.h:1115
FVector operator*=(const FVector &V)
Definition Vector.h:1223
void Set(float InX, float InY, float InZ)
Definition Vector.h:1269
FORCEINLINE FVector operator+(const FVector &V) const
Definition Vector.h:1130
FORCEINLINE FVector operator*(float Scale) const
Definition Vector.h:1150
static FVector DegreesToRadians(const FVector &DegVector)
Definition Vector.h:1057
FORCEINLINE CONSTEXPR FVector(float InX, float InY, float InZ)
Definition Vector.h:1067
FORCEINLINE float CosineAngle2D(FVector B) const
Definition Vector.h:1562
bool AllComponentsEqual(float Tolerance=KINDA_SMALL_NUMBER) const
Definition Vector.h:1186
FVector GetClampedToMaxSize2D(float MaxSize) const
Definition Vector.h:1447
static FORCEINLINE float DistXY(const FVector &V1, const FVector &V2)
Definition Vector.h:1617
static void CreateOrthonormalBasis(FVector &XAxis, FVector &YAxis, FVector &ZAxis)
FORCEINLINE bool IsUnit(float LengthSquaredTolerance=KINDA_SMALL_NUMBER) const
Definition Vector.h:1590
FVector RotateAngleAxis(const float AngleDeg, const FVector &Axis) const
Definition Vector.h:942
bool ContainsNaN() const
Definition Vector.h:1583
float HeadingAngle() const
Definition Vector.h:1595
static float EvaluateBezier(const FVector *ControlPoints, int32 NumPoints, TArray< FVector > &OutPoints)
float Component(int32 Index) const
Definition Vector.h:1471
FORCEINLINE FVector(const FVector2D V, float InZ)
Definition Vector.h:931
bool IsNearlyZero(float Tolerance=KINDA_SMALL_NUMBER) const
Definition Vector.h:1331
FORCEINLINE FVector(EForceInit)
Definition Vector.h:1087
static FORCEINLINE float Distance(const FVector &V1, const FVector &V2)
Definition Vector.h:741
bool Normalize(float Tolerance=SMALL_NUMBER)
Definition Vector.h:1344
Definition UE.h:623
T * Get(bool bEvenIfPendingKill=false)
Definition UE.h:172
FORCEINLINE T * operator->()
Definition UE.h:167
Definition UE.h:399
UObject * GetDefaultObject(bool bCreateIfNeeded)
Definition UE.h:415
Definition UE.h:343
Definition Base.h:215
UClass * ClassField()
Definition UE.h:277
FString * GetFullName(FString *result, UObject *StopOuter)
Definition UE.h:296
bool IsA(UClass *SomeBase)
Definition UE.h:299
Definition UE.h:306
Definition Other.h:211
UPrimalGameData * PrimalGameDataOverrideField()
Definition GameMode.h:878
UPrimalGameData * PrimalGameDataField()
Definition GameMode.h:877
FPrimalPlayerDataStruct * MyDataField()
Definition Actor.h:5507
FVector * GetWorldLocation(FVector *result)
Definition Actor.h:523
Definition UE.h:355
Definition UE.h:817
static TArray< AActor * > * ServerOctreeOverlapActors(TArray< AActor * > *result, UWorld *theWorld, FVector AtLoc, float Radius, EServerOctreeGroup::Type OctreeType, bool bForceActorLocationDistanceCheck)
Definition Other.h:410
TArray< TAutoWeakObjectPtr< APlayerController > > & PlayerControllerListField()
Definition GameMode.h:425
APlayerController * GetFirstPlayerController()
Definition GameMode.h:538
AGameState * GameStateField()
Definition GameMode.h:409