Skip to content

Commit

Permalink
Expose rotating movement component
Browse files Browse the repository at this point in the history
  • Loading branch information
nxrighthere committed Sep 11, 2021
1 parent d80cc19 commit 8a43fd1
Show file tree
Hide file tree
Showing 20 changed files with 311 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
### [UnrealEngine.Framework](./UnrealEngine-Framework.md 'UnrealEngine.Framework').[MovementComponent](./MovementComponent.md 'UnrealEngine.Framework.MovementComponent')
## MovementComponent.IsInWater() Method
## MovementComponent.IsInWater Property
Returns `true` if it's in physics volume with water flag
```csharp
public bool IsInWater();
public bool IsInWater { get; }
```
#### Returns
#### Property Value
[System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')
5 changes: 4 additions & 1 deletion API/MovementComponent.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ An abstract component that defines functionality for moving a [PrimitiveComponen
public abstract class MovementComponent : UnrealEngine.Framework.ActorComponent
```
Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.Object 'System.Object') 🡒 [ActorComponent](./ActorComponent.md 'UnrealEngine.Framework.ActorComponent') 🡒 MovementComponent

Derived
↳ [RotatingMovementComponent](./RotatingMovementComponent.md 'UnrealEngine.Framework.RotatingMovementComponent')
### Properties
- [ConstrainToPlane](./MovementComponent-ConstrainToPlane.md 'UnrealEngine.Framework.MovementComponent.ConstrainToPlane')
- [IsInWater](./MovementComponent-IsInWater.md 'UnrealEngine.Framework.MovementComponent.IsInWater')
- [PlaneConstraint](./MovementComponent-PlaneConstraint.md 'UnrealEngine.Framework.MovementComponent.PlaneConstraint')
- [SnapToPlaneAtStart](./MovementComponent-SnapToPlaneAtStart.md 'UnrealEngine.Framework.MovementComponent.SnapToPlaneAtStart')
- [UpdateOnlyIfRendered](./MovementComponent-UpdateOnlyIfRendered.md 'UnrealEngine.Framework.MovementComponent.UpdateOnlyIfRendered')
Expand All @@ -23,7 +27,6 @@ Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.O
- [GetVelocity()](./MovementComponent-GetVelocity().md 'UnrealEngine.Framework.MovementComponent.GetVelocity()')
- [GetVelocity(System.Numerics.Vector3)](./MovementComponent-GetVelocity(Vector3).md 'UnrealEngine.Framework.MovementComponent.GetVelocity(System.Numerics.Vector3)')
- [IsExceedingMaxSpeed(float)](./MovementComponent-IsExceedingMaxSpeed(float).md 'UnrealEngine.Framework.MovementComponent.IsExceedingMaxSpeed(float)')
- [IsInWater()](./MovementComponent-IsInWater().md 'UnrealEngine.Framework.MovementComponent.IsInWater()')
- [SetPlaneConstraintFromVectors(System.Numerics.Vector3, System.Numerics.Vector3)](./MovementComponent-SetPlaneConstraintFromVectors(Vector3_Vector3).md 'UnrealEngine.Framework.MovementComponent.SetPlaneConstraintFromVectors(System.Numerics.Vector3, System.Numerics.Vector3)')
- [SetPlaneConstraintNormal(System.Numerics.Vector3)](./MovementComponent-SetPlaneConstraintNormal(Vector3).md 'UnrealEngine.Framework.MovementComponent.SetPlaneConstraintNormal(System.Numerics.Vector3)')
- [SetPlaneConstraintOrigin(System.Numerics.Vector3)](./MovementComponent-SetPlaneConstraintOrigin(Vector3).md 'UnrealEngine.Framework.MovementComponent.SetPlaneConstraintOrigin(System.Numerics.Vector3)')
Expand Down
8 changes: 8 additions & 0 deletions API/RotatingMovementComponent-GetPivotTranslation().md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### [UnrealEngine.Framework](./UnrealEngine-Framework.md 'UnrealEngine.Framework').[RotatingMovementComponent](./RotatingMovementComponent.md 'UnrealEngine.Framework.RotatingMovementComponent')
## RotatingMovementComponent.GetPivotTranslation() Method
Returns translation of pivot point around which the component rotates, relative to the current rotation
```csharp
public System.Numerics.Vector3 GetPivotTranslation();
```
#### Returns
[System.Numerics.Vector3](https://docs.microsoft.com/en-us/dotnet/api/System.Numerics.Vector3 'System.Numerics.Vector3')
10 changes: 10 additions & 0 deletions API/RotatingMovementComponent-GetPivotTranslation(Vector3).md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### [UnrealEngine.Framework](./UnrealEngine-Framework.md 'UnrealEngine.Framework').[RotatingMovementComponent](./RotatingMovementComponent.md 'UnrealEngine.Framework.RotatingMovementComponent')
## RotatingMovementComponent.GetPivotTranslation(System.Numerics.Vector3) Method
Retrieves translation of pivot point around which the component rotates, relative to the current rotation
```csharp
public void GetPivotTranslation(ref System.Numerics.Vector3 value);
```
#### Parameters
<a name='UnrealEngine-Framework-RotatingMovementComponent-GetPivotTranslation(System-Numerics-Vector3)-value'></a>
`value` [System.Numerics.Vector3](https://docs.microsoft.com/en-us/dotnet/api/System.Numerics.Vector3 'System.Numerics.Vector3')

8 changes: 8 additions & 0 deletions API/RotatingMovementComponent-GetRotationRate().md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### [UnrealEngine.Framework](./UnrealEngine-Framework.md 'UnrealEngine.Framework').[RotatingMovementComponent](./RotatingMovementComponent.md 'UnrealEngine.Framework.RotatingMovementComponent')
## RotatingMovementComponent.GetRotationRate() Method
Returns yaw, pitch, and roll rotation rate of the component
```csharp
public System.Numerics.Quaternion GetRotationRate();
```
#### Returns
[System.Numerics.Quaternion](https://docs.microsoft.com/en-us/dotnet/api/System.Numerics.Quaternion 'System.Numerics.Quaternion')
10 changes: 10 additions & 0 deletions API/RotatingMovementComponent-GetRotationRate(Quaternion).md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### [UnrealEngine.Framework](./UnrealEngine-Framework.md 'UnrealEngine.Framework').[RotatingMovementComponent](./RotatingMovementComponent.md 'UnrealEngine.Framework.RotatingMovementComponent')
## RotatingMovementComponent.GetRotationRate(System.Numerics.Quaternion) Method
Retrieves yaw, pitch, and roll rotation rate of the component
```csharp
public void GetRotationRate(ref System.Numerics.Quaternion value);
```
#### Parameters
<a name='UnrealEngine-Framework-RotatingMovementComponent-GetRotationRate(System-Numerics-Quaternion)-value'></a>
`value` [System.Numerics.Quaternion](https://docs.microsoft.com/en-us/dotnet/api/System.Numerics.Quaternion 'System.Numerics.Quaternion')

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### [UnrealEngine.Framework](./UnrealEngine-Framework.md 'UnrealEngine.Framework').[RotatingMovementComponent](./RotatingMovementComponent.md 'UnrealEngine.Framework.RotatingMovementComponent')
## RotatingMovementComponent(UnrealEngine.Framework.Actor, string) Constructor
Creates the component attached to an actor
```csharp
public RotatingMovementComponent(UnrealEngine.Framework.Actor actor, string name=null);
```
#### Parameters
<a name='UnrealEngine-Framework-RotatingMovementComponent-RotatingMovementComponent(UnrealEngine-Framework-Actor_string)-actor'></a>
`actor` [Actor](./Actor.md 'UnrealEngine.Framework.Actor')
The actor to attach the component to

<a name='UnrealEngine-Framework-RotatingMovementComponent-RotatingMovementComponent(UnrealEngine-Framework-Actor_string)-name'></a>
`name` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String')
The name of the component

8 changes: 8 additions & 0 deletions API/RotatingMovementComponent-RotationInLocalSpace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### [UnrealEngine.Framework](./UnrealEngine-Framework.md 'UnrealEngine.Framework').[RotatingMovementComponent](./RotatingMovementComponent.md 'UnrealEngine.Framework.RotatingMovementComponent')
## RotatingMovementComponent.RotationInLocalSpace Property
Gets or sets whether rotation is applied in local or world space
```csharp
public bool RotationInLocalSpace { get; set; }
```
#### Property Value
[System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')
10 changes: 10 additions & 0 deletions API/RotatingMovementComponent-SetPivotTranslation(Vector3).md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### [UnrealEngine.Framework](./UnrealEngine-Framework.md 'UnrealEngine.Framework').[RotatingMovementComponent](./RotatingMovementComponent.md 'UnrealEngine.Framework.RotatingMovementComponent')
## RotatingMovementComponent.SetPivotTranslation(System.Numerics.Vector3) Method
Sets translation of pivot point around which the component rotates, relative to the current rotation
```csharp
public void SetPivotTranslation(in System.Numerics.Vector3 value);
```
#### Parameters
<a name='UnrealEngine-Framework-RotatingMovementComponent-SetPivotTranslation(System-Numerics-Vector3)-value'></a>
`value` [System.Numerics.Vector3](https://docs.microsoft.com/en-us/dotnet/api/System.Numerics.Vector3 'System.Numerics.Vector3')

10 changes: 10 additions & 0 deletions API/RotatingMovementComponent-SetRotationRate(Quaternion).md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### [UnrealEngine.Framework](./UnrealEngine-Framework.md 'UnrealEngine.Framework').[RotatingMovementComponent](./RotatingMovementComponent.md 'UnrealEngine.Framework.RotatingMovementComponent')
## RotatingMovementComponent.SetRotationRate(System.Numerics.Quaternion) Method
Sets yaw, pitch, and roll rotation rate of the component
```csharp
public void SetRotationRate(in System.Numerics.Quaternion value);
```
#### Parameters
<a name='UnrealEngine-Framework-RotatingMovementComponent-SetRotationRate(System-Numerics-Quaternion)-value'></a>
`value` [System.Numerics.Quaternion](https://docs.microsoft.com/en-us/dotnet/api/System.Numerics.Quaternion 'System.Numerics.Quaternion')

18 changes: 18 additions & 0 deletions API/RotatingMovementComponent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
### [UnrealEngine.Framework](./UnrealEngine-Framework.md 'UnrealEngine.Framework')
## RotatingMovementComponent Class
A component that performs continuous rotation at a specific rotation rate
```csharp
public class RotatingMovementComponent : UnrealEngine.Framework.MovementComponent
```
Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.Object 'System.Object') &#129106; [ActorComponent](./ActorComponent.md 'UnrealEngine.Framework.ActorComponent') &#129106; [MovementComponent](./MovementComponent.md 'UnrealEngine.Framework.MovementComponent') &#129106; RotatingMovementComponent
### Constructors
- [RotatingMovementComponent(UnrealEngine.Framework.Actor, string)](./RotatingMovementComponent-RotatingMovementComponent(Actor_string).md 'UnrealEngine.Framework.RotatingMovementComponent.RotatingMovementComponent(UnrealEngine.Framework.Actor, string)')
### Properties
- [RotationInLocalSpace](./RotatingMovementComponent-RotationInLocalSpace.md 'UnrealEngine.Framework.RotatingMovementComponent.RotationInLocalSpace')
### Methods
- [GetPivotTranslation()](./RotatingMovementComponent-GetPivotTranslation().md 'UnrealEngine.Framework.RotatingMovementComponent.GetPivotTranslation()')
- [GetPivotTranslation(System.Numerics.Vector3)](./RotatingMovementComponent-GetPivotTranslation(Vector3).md 'UnrealEngine.Framework.RotatingMovementComponent.GetPivotTranslation(System.Numerics.Vector3)')
- [GetRotationRate()](./RotatingMovementComponent-GetRotationRate().md 'UnrealEngine.Framework.RotatingMovementComponent.GetRotationRate()')
- [GetRotationRate(System.Numerics.Quaternion)](./RotatingMovementComponent-GetRotationRate(Quaternion).md 'UnrealEngine.Framework.RotatingMovementComponent.GetRotationRate(System.Numerics.Quaternion)')
- [SetPivotTranslation(System.Numerics.Vector3)](./RotatingMovementComponent-SetPivotTranslation(Vector3).md 'UnrealEngine.Framework.RotatingMovementComponent.SetPivotTranslation(System.Numerics.Vector3)')
- [SetRotationRate(System.Numerics.Quaternion)](./RotatingMovementComponent-SetRotationRate(Quaternion).md 'UnrealEngine.Framework.RotatingMovementComponent.SetRotationRate(System.Numerics.Quaternion)')
1 change: 1 addition & 0 deletions API/UnrealEngine-Framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
- [PrimitiveComponent](./PrimitiveComponent.md 'UnrealEngine.Framework.PrimitiveComponent')
- [RadialForceComponent](./RadialForceComponent.md 'UnrealEngine.Framework.RadialForceComponent')
- [RectLight](./RectLight.md 'UnrealEngine.Framework.RectLight')
- [RotatingMovementComponent](./RotatingMovementComponent.md 'UnrealEngine.Framework.RotatingMovementComponent')
- [SceneComponent](./SceneComponent.md 'UnrealEngine.Framework.SceneComponent')
- [ShapeComponent](./ShapeComponent.md 'UnrealEngine.Framework.ShapeComponent')
- [SkeletalMesh](./SkeletalMesh.md 'UnrealEngine.Framework.SkeletalMesh')
Expand Down
30 changes: 27 additions & 3 deletions Source/Managed/Framework/Codegen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace UnrealEngine.Framework {
// Automatically generated

internal static class Shared {
internal const int checksum = 0x2E8;
internal const int checksum = 0x2F0;
internal static Dictionary<int, IntPtr> userFunctions = new();
private const string dynamicTypesAssemblyName = "UnrealEngine.DynamicTypes";
private static readonly ModuleBuilder moduleBuilder = AssemblyBuilder.DefineDynamicAssembly(new(dynamicTypesAssemblyName), AssemblyBuilderAccess.RunAndCollect).DefineDynamicModule(dynamicTypesAssemblyName);
Expand Down Expand Up @@ -600,6 +600,19 @@ internal static unsafe Dictionary<int, IntPtr> Load(IntPtr* events, IntPtr funct
MovementComponent.constrainNormalToPlane = (delegate* unmanaged[Cdecl]<IntPtr, in Vector3, ref Vector3, void>)movementComponentFunctions[head++];
}

unchecked {
int head = 0;
IntPtr* rotatingMovementComponentFunctions = (IntPtr*)buffer[position++];

RotatingMovementComponent.create = (delegate* unmanaged[Cdecl]<IntPtr, string, IntPtr>)rotatingMovementComponentFunctions[head++];
RotatingMovementComponent.getRotationInLocalSpace = (delegate* unmanaged[Cdecl]<IntPtr, Bool>)rotatingMovementComponentFunctions[head++];
RotatingMovementComponent.getPivotTranslation = (delegate* unmanaged[Cdecl]<IntPtr, ref Vector3, void>)rotatingMovementComponentFunctions[head++];
RotatingMovementComponent.getRotationRate = (delegate* unmanaged[Cdecl]<IntPtr, ref Quaternion, void>)rotatingMovementComponentFunctions[head++];
RotatingMovementComponent.setRotationInLocalSpace = (delegate* unmanaged[Cdecl]<IntPtr, Bool, void>)rotatingMovementComponentFunctions[head++];
RotatingMovementComponent.setPivotTranslation = (delegate* unmanaged[Cdecl]<IntPtr, in Vector3, void>)rotatingMovementComponentFunctions[head++];
RotatingMovementComponent.setRotationRate = (delegate* unmanaged[Cdecl]<IntPtr, in Quaternion, void>)rotatingMovementComponentFunctions[head++];
}

unchecked {
int head = 0;
IntPtr* sceneComponentFunctions = (IntPtr*)buffer[position++];
Expand Down Expand Up @@ -1362,11 +1375,12 @@ internal enum ActorType : int {
}

internal enum ComponentType : int {
// Non-attachable
// Non-movable
Actor,
Input,
Movement,
// Attachable
RotatingMovement,
// Movable
Scene,
Audio,
Camera,
Expand Down Expand Up @@ -1880,6 +1894,16 @@ unsafe partial class MovementComponent {
internal static delegate* unmanaged[Cdecl]<IntPtr, in Vector3, ref Vector3, void> constrainNormalToPlane;
}

unsafe partial class RotatingMovementComponent {
internal static delegate* unmanaged[Cdecl]<IntPtr, string, IntPtr> create;
internal static delegate* unmanaged[Cdecl]<IntPtr, Bool> getRotationInLocalSpace;
internal static delegate* unmanaged[Cdecl]<IntPtr, ref Vector3, void> getPivotTranslation;
internal static delegate* unmanaged[Cdecl]<IntPtr, ref Quaternion, void> getRotationRate;
internal static delegate* unmanaged[Cdecl]<IntPtr, Bool, void> setRotationInLocalSpace;
internal static delegate* unmanaged[Cdecl]<IntPtr, in Vector3, void> setPivotTranslation;
internal static delegate* unmanaged[Cdecl]<IntPtr, in Quaternion, void> setRotationRate;
}

unsafe partial class SceneComponent {
internal static delegate* unmanaged[Cdecl]<IntPtr, IntPtr, Bool> isAttachedToComponent;
internal static delegate* unmanaged[Cdecl]<IntPtr, IntPtr, Bool> isAttachedToActor;
Expand Down
86 changes: 81 additions & 5 deletions Source/Managed/Framework/Framework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8202,6 +8202,11 @@ public PlaneConstraintAxis PlaneConstraint {
set => setPlaneConstraint(Pointer, value);
}

/// <summary>
/// Returns <c>true</c> if it's in physics volume with water flag
/// </summary>
public bool IsInWater => isInWater(Pointer);

/// <summary>
/// Retrieves the current velocity of updated component
/// </summary>
Expand Down Expand Up @@ -8285,11 +8290,6 @@ public Vector3 GetPlaneConstraintOrigin() {
/// </summary>
public bool IsExceedingMaxSpeed(float maxSpeed) => isExceedingMaxSpeed(Pointer, maxSpeed);

/// <summary>
/// Returns <c>true</c> if it's in physics volume with water flag
/// </summary>
public bool IsInWater() => isInWater(Pointer);

/// <summary>
/// Stops movement immediately, zeroes velocity, usually zeros acceleration for components with acceleration
/// </summary>
Expand All @@ -8311,6 +8311,82 @@ public Vector3 GetPlaneConstraintOrigin() {
public void ConstrainNormalToPlane(in Vector3 normal, ref Vector3 value) => constrainNormalToPlane(Pointer, normal, ref value);
}

/// <summary>
/// A component that performs continuous rotation at a specific rotation rate
/// </summary>
public unsafe partial class RotatingMovementComponent : MovementComponent {
internal override ComponentType Type => ComponentType.RotatingMovement;

private protected RotatingMovementComponent() { }

internal RotatingMovementComponent(IntPtr pointer) => Pointer = pointer;

/// <summary>
/// Creates the component attached to an actor
/// </summary>
/// <param name="actor">The actor to attach the component to</param>
/// <param name="name">The name of the component</param>
public RotatingMovementComponent(Actor actor, string name = null) {
if (name?.Length == 0)
name = null;

if (actor == null)
throw new ArgumentNullException(nameof(actor));

Pointer = create(actor.Pointer, name);
}

/// <summary>
/// Gets or sets whether rotation is applied in local or world space
/// </summary>
public bool RotationInLocalSpace {
get => getRotationInLocalSpace(Pointer);
set => setRotationInLocalSpace(Pointer, value);
}

/// <summary>
/// Retrieves translation of pivot point around which the component rotates, relative to the current rotation
/// </summary>
public void GetPivotTranslation(ref Vector3 value) => getPivotTranslation(Pointer, ref value);

/// <summary>
/// Returns translation of pivot point around which the component rotates, relative to the current rotation
/// </summary>
public Vector3 GetPivotTranslation() {
Vector3 value = default;

getPivotTranslation(Pointer, ref value);

return value;
}

/// <summary>
/// Retrieves yaw, pitch, and roll rotation rate of the component
/// </summary>
public void GetRotationRate(ref Quaternion value) => getRotationRate(Pointer, ref value);

/// <summary>
/// Returns yaw, pitch, and roll rotation rate of the component
/// </summary>
public Quaternion GetRotationRate() {
Quaternion value = default;

getRotationRate(Pointer, ref value);

return value;
}

/// <summary>
/// Sets translation of pivot point around which the component rotates, relative to the current rotation
/// </summary>
public void SetPivotTranslation(in Vector3 value) => setPivotTranslation(Pointer, value);

/// <summary>
/// Sets yaw, pitch, and roll rotation rate of the component
/// </summary>
public void SetRotationRate(in Quaternion value) => setRotationRate(Pointer, value);
}

/// <summary>
/// The base class of components that can be transformed or attached, but has no rendering or collision capabilities
/// </summary>
Expand Down
16 changes: 16 additions & 0 deletions Source/Managed/Tests/ExternalConsistency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public void OnBeginPlay() {
ChildActorsTest();
ComponentsAttachmentTest();
ComponentsMatchingTest();
NonSceneComponentTest();
ObjectIDsTest();
MaxFramesPerSecondTest();
TagsTest();
Expand Down Expand Up @@ -424,6 +425,21 @@ private void ComponentsMatchingTest() {
Debug.Log(LogLevel.Display, "Test passed successfully");
}

private void NonSceneComponentTest() {
Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

Actor actor = new();
RotatingMovementComponent rotatingMovementComponent = new(actor, "TestName");

if (rotatingMovementComponent == null) {
Debug.Log(LogLevel.Error, "Component was not instantiated!");

return;
}

Debug.Log(LogLevel.Display, "Test passed successfully");
}

private void ObjectIDsTest() {
Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

Expand Down
Loading

0 comments on commit 8a43fd1

Please sign in to comment.