mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Get/Set FixedRotation in play mode
This commit is contained in:
@@ -431,8 +431,11 @@ namespace GlitchyEditor.EditWindows
|
|||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isFixedRotation = rigidBodyComponent.FixedRotation;
|
||||||
ImGui.Checkbox("Fixed Rotation", &rigidBodyComponent.FixedRotation);
|
if (ImGui.Checkbox("Fixed Rotation", &isFixedRotation))
|
||||||
|
{
|
||||||
|
rigidBodyComponent.FixedRotation = isFixedRotation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ShowBoxCollider2DComponentEditor(Entity entity, BoxCollider2DComponent* boxCollider)
|
private static void ShowBoxCollider2DComponentEditor(Entity entity, BoxCollider2DComponent* boxCollider)
|
||||||
|
|||||||
@@ -574,6 +574,20 @@ static class ScriptGlue
|
|||||||
rigidBody.SetAngularVelocity(velocity);
|
rigidBody.SetAngularVelocity(velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RegisterCall("ScriptGlue::Rigidbody2D_IsFixedRotation")]
|
||||||
|
static void Rigidbody2D_IsFixedRotation(UUID entityId, out bool isFixedRotation)
|
||||||
|
{
|
||||||
|
Rigidbody2DComponent* rigidBody = GetComponentSafe<Rigidbody2DComponent>(entityId);
|
||||||
|
isFixedRotation = rigidBody.FixedRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
[RegisterCall("ScriptGlue::Rigidbody2D_SetFixedRotation")]
|
||||||
|
static void Rigidbody2D_SetFixedRotation(UUID entityId, in bool isFixedRotation)
|
||||||
|
{
|
||||||
|
Rigidbody2DComponent* rigidBody = GetComponentSafe<Rigidbody2DComponent>(entityId);
|
||||||
|
rigidBody.FixedRotation = isFixedRotation;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Rigidbody2D
|
#endregion Rigidbody2D
|
||||||
|
|
||||||
#region Camera
|
#region Camera
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ namespace GlitchyEngine.World
|
|||||||
|
|
||||||
public BodyType BodyType = .Static;
|
public BodyType BodyType = .Static;
|
||||||
|
|
||||||
public bool FixedRotation = false;
|
public bool _fixedRotation = false;
|
||||||
|
|
||||||
private int _runtimeBody = 0;
|
private int _runtimeBody = 0;
|
||||||
|
|
||||||
@@ -368,6 +368,20 @@ namespace GlitchyEngine.World
|
|||||||
set mut => _runtimeBody = (int)(void*)value;
|
set mut => _runtimeBody = (int)(void*)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool FixedRotation
|
||||||
|
{
|
||||||
|
get => _fixedRotation;
|
||||||
|
set mut
|
||||||
|
{
|
||||||
|
_fixedRotation = value;
|
||||||
|
|
||||||
|
if (RuntimeBody != null)
|
||||||
|
{
|
||||||
|
Box2D.Body.SetFixedRotation(RuntimeBody, _fixedRotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*public float LinearDamping
|
/*public float LinearDamping
|
||||||
{
|
{
|
||||||
get => _linearDamping;
|
get => _linearDamping;
|
||||||
|
|||||||
@@ -587,7 +587,9 @@ class SceneSerializer
|
|||||||
Deserialize.Value(reader, "BodyType", out component.BodyType);
|
Deserialize.Value(reader, "BodyType", out component.BodyType);
|
||||||
reader.EntryEnd();
|
reader.EntryEnd();
|
||||||
|
|
||||||
Deserialize.Value(reader, "FixedRotation", out component.FixedRotation);
|
bool fixedRotation = false;
|
||||||
|
Deserialize.Value(reader, "FixedRotation", out fixedRotation);
|
||||||
|
component.FixedRotation = fixedRotation;
|
||||||
|
|
||||||
return .Ok;
|
return .Ok;
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class Rigidbody2D : Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the angulara velocity of the rigidbody.
|
/// Gets or sets the angular velocity of the rigidbody.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float AngularVelocity
|
public float AngularVelocity
|
||||||
{
|
{
|
||||||
@@ -87,4 +87,18 @@ public class Rigidbody2D : Component
|
|||||||
}
|
}
|
||||||
set => ScriptGlue.Rigidbody2D_SetAngularVelocity(_uuid, value);
|
set => ScriptGlue.Rigidbody2D_SetAngularVelocity(_uuid, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets whether the rigidbody can rotate or not.
|
||||||
|
/// </summary>
|
||||||
|
public bool FixedRotation
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
ScriptGlue.Rigidbody2D_IsFixedRotation(_uuid, out bool isFixedRotation);
|
||||||
|
|
||||||
|
return isFixedRotation;
|
||||||
|
}
|
||||||
|
set => ScriptGlue.Rigidbody2D_SetFixedRotation(_uuid, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,12 @@ internal static class ScriptGlue
|
|||||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||||
internal static extern void Rigidbody2D_GetAngularVelocity(UUID entityId, out float velocity);
|
internal static extern void Rigidbody2D_GetAngularVelocity(UUID entityId, out float velocity);
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||||
|
internal static extern void Rigidbody2D_IsFixedRotation(UUID entityId, out bool isFixedRotation);
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||||
|
internal static extern void Rigidbody2D_SetFixedRotation(UUID entityId, in bool isFixedRotation);
|
||||||
|
|
||||||
#endregion RigidBody2D
|
#endregion RigidBody2D
|
||||||
|
|
||||||
#region Camera
|
#region Camera
|
||||||
|
|||||||
Reference in New Issue
Block a user