Skip to content

Commit

Permalink
Expose primitive component radial force and impulse ignore functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
nxrighthere committed Sep 16, 2020
1 parent c724c15 commit 43aebf3
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 4 deletions.
8 changes: 8 additions & 0 deletions API/PrimitiveComponent-IgnoreRadialForce.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### [UnrealEngine.Framework](./UnrealEngine-Framework.md 'UnrealEngine.Framework').[PrimitiveComponent](./PrimitiveComponent.md 'UnrealEngine.Framework.PrimitiveComponent')
## PrimitiveComponent.IgnoreRadialForce Property
Gets or sets whether the component should ignore radial forces
```csharp
public bool IgnoreRadialForce { get; set; }
```
#### Property Value
[System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')
8 changes: 8 additions & 0 deletions API/PrimitiveComponent-IgnoreRadialImpulse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### [UnrealEngine.Framework](./UnrealEngine-Framework.md 'UnrealEngine.Framework').[PrimitiveComponent](./PrimitiveComponent.md 'UnrealEngine.Framework.PrimitiveComponent')
## PrimitiveComponent.IgnoreRadialImpulse Property
Gets or sets whether the component should ignore radial impulses
```csharp
public bool IgnoreRadialImpulse { get; set; }
```
#### Property Value
[System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')
2 changes: 2 additions & 0 deletions API/PrimitiveComponent.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Derived
### Properties
- [AngularDamping](./PrimitiveComponent-AngularDamping.md 'UnrealEngine.Framework.PrimitiveComponent.AngularDamping')
- [CastShadow](./PrimitiveComponent-CastShadow.md 'UnrealEngine.Framework.PrimitiveComponent.CastShadow')
- [IgnoreRadialForce](./PrimitiveComponent-IgnoreRadialForce.md 'UnrealEngine.Framework.PrimitiveComponent.IgnoreRadialForce')
- [IgnoreRadialImpulse](./PrimitiveComponent-IgnoreRadialImpulse.md 'UnrealEngine.Framework.PrimitiveComponent.IgnoreRadialImpulse')
- [IsGravityEnabled](./PrimitiveComponent-IsGravityEnabled.md 'UnrealEngine.Framework.PrimitiveComponent.IsGravityEnabled')
- [LinearDamping](./PrimitiveComponent-LinearDamping.md 'UnrealEngine.Framework.PrimitiveComponent.LinearDamping')
- [Mass](./PrimitiveComponent-Mass.md 'UnrealEngine.Framework.PrimitiveComponent.Mass')
Expand Down
Binary file modified Content/Tests/Tests.umap
Binary file not shown.
2 changes: 1 addition & 1 deletion MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ Several options are available to pass data between the managed runtime and the e

**Commands, functions, and events**

The engine's reflection system allows to dynamically invoke commands, functions, and events of engine's classes from managed code to pass data on demand.
The engine's reflection system allows to dynamically invoke commands, functions, and events of engine classes from managed code to pass data on demand.

Blueprint event dispatcher:

Expand Down
14 changes: 13 additions & 1 deletion Source/Managed/Framework/Codegen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace UnrealEngine.Framework {
// Automatically generated

internal static class Shared {
internal const int checksum = 0x27D;
internal const int checksum = 0x281;
internal static Dictionary<int, IntPtr> userFunctions = new Dictionary<int, IntPtr>();
private const string dynamicTypesAssemblyName = "UnrealEngine.DynamicTypes";
private static readonly ModuleBuilder moduleBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(dynamicTypesAssemblyName), AssemblyBuilderAccess.RunAndCollect).DefineDynamicModule(dynamicTypesAssemblyName);
Expand Down Expand Up @@ -657,6 +657,8 @@ internal static unsafe Dictionary<int, IntPtr> Load(IntPtr* events, IntPtr funct
PrimitiveComponent.getCastShadow = GenerateOptimizedFunction<PrimitiveComponent.GetCastShadowFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.getOnlyOwnerSee = GenerateOptimizedFunction<PrimitiveComponent.GetOnlyOwnerSeeFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.getOwnerNoSee = GenerateOptimizedFunction<PrimitiveComponent.GetOwnerNoSeeFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.getIgnoreRadialForce = GenerateOptimizedFunction<PrimitiveComponent.GetIgnoreRadialForceFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.getIgnoreRadialImpulse = GenerateOptimizedFunction<PrimitiveComponent.GetIgnoreRadialImpulseFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.getMaterial = GenerateOptimizedFunction<PrimitiveComponent.GetMaterialFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.getMaterialsNumber = GenerateOptimizedFunction<PrimitiveComponent.GetMaterialsNumberFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.getDistanceToCollision = GenerateOptimizedFunction<PrimitiveComponent.GetDistanceToCollisionFunction>(primitiveComponentFunctions[head++]);
Expand All @@ -675,6 +677,8 @@ internal static unsafe Dictionary<int, IntPtr> Load(IntPtr* events, IntPtr funct
PrimitiveComponent.setCastShadow = GenerateOptimizedFunction<PrimitiveComponent.SetCastShadowFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.setOnlyOwnerSee = GenerateOptimizedFunction<PrimitiveComponent.SetOnlyOwnerSeeFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.setOwnerNoSee = GenerateOptimizedFunction<PrimitiveComponent.SetOwnerNoSeeFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.setIgnoreRadialForce = GenerateOptimizedFunction<PrimitiveComponent.SetIgnoreRadialForceFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.setIgnoreRadialImpulse = GenerateOptimizedFunction<PrimitiveComponent.SetIgnoreRadialImpulseFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.setMaterial = GenerateOptimizedFunction<PrimitiveComponent.SetMaterialFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.setSimulatePhysics = GenerateOptimizedFunction<PrimitiveComponent.SetSimulatePhysicsFunction>(primitiveComponentFunctions[head++]);
PrimitiveComponent.setAngularDamping = GenerateOptimizedFunction<PrimitiveComponent.SetAngularDampingFunction>(primitiveComponentFunctions[head++]);
Expand Down Expand Up @@ -2218,6 +2222,8 @@ partial class PrimitiveComponent {
internal delegate Bool GetCastShadowFunction(IntPtr primitiveComponent);
internal delegate Bool GetOnlyOwnerSeeFunction(IntPtr primitiveComponent);
internal delegate Bool GetOwnerNoSeeFunction(IntPtr primitiveComponent);
internal delegate Bool GetIgnoreRadialForceFunction(IntPtr primitiveComponent);
internal delegate Bool GetIgnoreRadialImpulseFunction(IntPtr primitiveComponent);
internal delegate IntPtr GetMaterialFunction(IntPtr primitiveComponent, int elementIndex);
internal delegate int GetMaterialsNumberFunction(IntPtr primitiveComponent);
internal delegate float GetDistanceToCollisionFunction(IntPtr primitiveComponent, in Vector3 point, ref Vector3 closestPointOnCollision);
Expand All @@ -2236,6 +2242,8 @@ partial class PrimitiveComponent {
internal delegate void SetCastShadowFunction(IntPtr primitiveComponent, Bool value);
internal delegate void SetOnlyOwnerSeeFunction(IntPtr primitiveComponent, Bool value);
internal delegate void SetOwnerNoSeeFunction(IntPtr primitiveComponent, Bool value);
internal delegate void SetIgnoreRadialForceFunction(IntPtr primitiveComponent, Bool value);
internal delegate void SetIgnoreRadialImpulseFunction(IntPtr primitiveComponent, Bool value);
internal delegate void SetMaterialFunction(IntPtr primitiveComponent, int elementIndex, IntPtr material);
internal delegate void SetSimulatePhysicsFunction(IntPtr primitiveComponent, Bool value);
internal delegate void SetAngularDampingFunction(IntPtr primitiveComponent, float value);
Expand Down Expand Up @@ -2274,6 +2282,8 @@ partial class PrimitiveComponent {
internal static GetCastShadowFunction getCastShadow;
internal static GetOnlyOwnerSeeFunction getOnlyOwnerSee;
internal static GetOwnerNoSeeFunction getOwnerNoSee;
internal static GetIgnoreRadialForceFunction getIgnoreRadialForce;
internal static GetIgnoreRadialImpulseFunction getIgnoreRadialImpulse;
internal static GetMaterialFunction getMaterial;
internal static GetMaterialsNumberFunction getMaterialsNumber;
internal static GetDistanceToCollisionFunction getDistanceToCollision;
Expand All @@ -2292,6 +2302,8 @@ partial class PrimitiveComponent {
internal static SetCastShadowFunction setCastShadow;
internal static SetOnlyOwnerSeeFunction setOnlyOwnerSee;
internal static SetOwnerNoSeeFunction setOwnerNoSee;
internal static SetIgnoreRadialForceFunction setIgnoreRadialForce;
internal static SetIgnoreRadialImpulseFunction setIgnoreRadialImpulse;
internal static SetMaterialFunction setMaterial;
internal static SetSimulatePhysicsFunction setSimulatePhysics;
internal static SetAngularDampingFunction setAngularDamping;
Expand Down
18 changes: 17 additions & 1 deletion Source/Managed/Framework/Framework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal static string BytesToString(this byte[] buffer) {
for (end = 0; end < buffer.Length && buffer[end] != 0; end++);

unsafe {
fixed (byte* pinnedBuffer = buffer) {
fixed (byte* pinnedBuffer = buffer) {
return new String((sbyte*)pinnedBuffer, 0, end);
}
}
Expand Down Expand Up @@ -8048,6 +8048,22 @@ public bool OwnerNoSee {
set => setOwnerNoSee(Pointer, value);
}

/// <summary>
/// Gets or sets whether the component should ignore radial forces
/// </summary>
public bool IgnoreRadialForce {
get => getIgnoreRadialForce(Pointer);
set => setIgnoreRadialForce(Pointer, value);
}

/// <summary>
/// Gets or sets whether the component should ignore radial impulses
/// </summary>
public bool IgnoreRadialImpulse {
get => getIgnoreRadialImpulse(Pointer);
set => setIgnoreRadialImpulse(Pointer, value);
}

/// <summary>
/// Gets or sets the angular damping of the component
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/Managed/Tests/BlueprintsExtensibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void OnBeginPlay() {
const string eventMessage = "Blueprint event dispatched";
const float eventValue = 100.0f;

Assert.IsTrue(levelScript.Invoke($"Test_Event \"{ eventMessage }: \" { eventValue }"));
Assert.IsTrue(levelScript.Invoke($"TestEvent \"{ eventMessage }: \" { eventValue }"));

if (actor.IsSpawned)
Debug.AddOnScreenMessage(-1, 30.0f, Color.Tomato, "Blueprint actor is spawned!");
Expand Down
4 changes: 4 additions & 0 deletions Source/Native/Source/UnrealCLR/Private/UnrealCLR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,8 @@ void UnrealCLR::Module::StartupModule() {
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::GetCastShadow;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::GetOnlyOwnerSee;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::GetOwnerNoSee;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::GetIgnoreRadialForce;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::GetIgnoreRadialImpulse;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::GetMaterial;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::GetMaterialsNumber;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::GetDistanceToCollision;
Expand All @@ -833,6 +835,8 @@ void UnrealCLR::Module::StartupModule() {
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::SetCastShadow;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::SetOnlyOwnerSee;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::SetOwnerNoSee;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::SetIgnoreRadialForce;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::SetIgnoreRadialImpulse;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::SetMaterial;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::SetSimulatePhysics;
Shared::PrimitiveComponentFunctions[head++] = (void*)&UnrealCLRFramework::PrimitiveComponent::SetAngularDamping;
Expand Down
16 changes: 16 additions & 0 deletions Source/Native/Source/UnrealCLR/Private/UnrealCLRFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2578,6 +2578,14 @@ namespace UnrealCLRFramework {
return PrimitiveComponent->bOwnerNoSee;
}

bool GetIgnoreRadialForce(UPrimitiveComponent* PrimitiveComponent) {
return PrimitiveComponent->bIgnoreRadialForce;
}

bool GetIgnoreRadialImpulse(UPrimitiveComponent* PrimitiveComponent) {
return PrimitiveComponent->bIgnoreRadialImpulse;
}

UMaterialInstanceDynamic* GetMaterial(UPrimitiveComponent* PrimitiveComponent, int32 ElementIndex) {
return Cast<UMaterialInstanceDynamic>(PrimitiveComponent->GetMaterial(ElementIndex));
}
Expand Down Expand Up @@ -2678,6 +2686,14 @@ namespace UnrealCLRFramework {
PrimitiveComponent->bOwnerNoSee = Value;
}

void SetIgnoreRadialForce(UPrimitiveComponent* PrimitiveComponent, bool Value) {
PrimitiveComponent->bIgnoreRadialForce = Value;
}

void SetIgnoreRadialImpulse(UPrimitiveComponent* PrimitiveComponent, bool Value) {
PrimitiveComponent->bIgnoreRadialImpulse = Value;
}

void SetMaterial(UPrimitiveComponent* PrimitiveComponent, int32 ElementIndex, UMaterialInterface* Material) {
PrimitiveComponent->SetMaterial(ElementIndex, Material);
}
Expand Down
4 changes: 4 additions & 0 deletions Source/Native/Source/UnrealCLR/Public/UnrealCLRFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ namespace UnrealCLRFramework {
static bool GetCastShadow(UPrimitiveComponent* PrimitiveComponent);
static bool GetOnlyOwnerSee(UPrimitiveComponent* PrimitiveComponent);
static bool GetOwnerNoSee(UPrimitiveComponent* PrimitiveComponent);
static bool GetIgnoreRadialForce(UPrimitiveComponent* PrimitiveComponent);
static bool GetIgnoreRadialImpulse(UPrimitiveComponent* PrimitiveComponent);
static UMaterialInstanceDynamic* GetMaterial(UPrimitiveComponent* PrimitiveComponent, int32 ElementIndex);
static int32 GetMaterialsNumber(UPrimitiveComponent* PrimitiveComponent);
static float GetDistanceToCollision(UPrimitiveComponent* PrimitiveComponent, const Vector3* Point, Vector3* ClosestPointOnCollision);
Expand All @@ -878,6 +880,8 @@ namespace UnrealCLRFramework {
static void SetCastShadow(UPrimitiveComponent* PrimitiveComponent, bool Value);
static void SetOnlyOwnerSee(UPrimitiveComponent* PrimitiveComponent, bool Value);
static void SetOwnerNoSee(UPrimitiveComponent* PrimitiveComponent, bool Value);
static void SetIgnoreRadialForce(UPrimitiveComponent* PrimitiveComponent, bool Value);
static void SetIgnoreRadialImpulse(UPrimitiveComponent* PrimitiveComponent, bool Value);
static void SetMaterial(UPrimitiveComponent* PrimitiveComponent, int32 ElementIndex, UMaterialInterface* Material);
static void SetSimulatePhysics(UPrimitiveComponent* PrimitiveComponent, bool Value);
static void SetAngularDamping(UPrimitiveComponent* PrimitiveComponent, float Value);
Expand Down

0 comments on commit 43aebf3

Please sign in to comment.