diff --git a/GlitchyEditor/src/EditWindows/ComponentEditWindow.bf b/GlitchyEditor/src/EditWindows/ComponentEditWindow.bf index 181dd90..d8a1f11 100644 --- a/GlitchyEditor/src/EditWindows/ComponentEditWindow.bf +++ b/GlitchyEditor/src/EditWindows/ComponentEditWindow.bf @@ -436,6 +436,12 @@ namespace GlitchyEditor.EditWindows { rigidBodyComponent.FixedRotation = isFixedRotation; } + + float gravityScale = rigidBodyComponent.GravityScale; + if (ImGui.DragFloat("Gravity Scale", &gravityScale)) + { + rigidBodyComponent.GravityScale = gravityScale; + } } private static void ShowBoxCollider2DComponentEditor(Entity entity, BoxCollider2DComponent* boxCollider) diff --git a/GlitchyEngine/src/Scripting/ScriptGlue.bf b/GlitchyEngine/src/Scripting/ScriptGlue.bf index 80d59f0..39ab632 100644 --- a/GlitchyEngine/src/Scripting/ScriptGlue.bf +++ b/GlitchyEngine/src/Scripting/ScriptGlue.bf @@ -88,12 +88,12 @@ static class ScriptGlue RegisterComponent("GlitchyEngine.Core.Transform"); RegisterComponent("GlitchyEngine.Physics.Rigidbody2D"); RegisterComponent("GlitchyEngine.Core.Camera"); + RegisterComponent("GlitchyEngine.Graphics.CircleRenderer"); } [RegisterMethod] private static void RegisterCalls() { - // Generated at CompTime } private static void RegisterComponent(StringView cSharpClassName = "") where T : struct, new @@ -498,6 +498,105 @@ static class ScriptGlue { rigidbody2D.SetPosition(translation.XY); } + // TODO: we need to handle repositioning of colliders that are children of the entity with rigidbody... + } + + [RegisterCall("ScriptGlue::Transform_GetRotation")] + static void Transform_GetRotation(UUID entityId, out Quaternion rotation) + { + Entity entity = GetEntitySafe(entityId); + + rotation = entity.Transform.Rotation; + } + + [RegisterCall("ScriptGlue::Transform_SetRotation")] + static void Transform_SetRotation(UUID entityId, in Quaternion rotation) + { + Entity entity = GetEntitySafe(entityId); + + entity.Transform.Rotation = rotation; + + if (entity.TryGetComponent(let rigidbody2D)) + { + rigidbody2D.SetAngle(entity.Transform.RotationEuler.Z); + } + // TODO: When rotating around the X- or Y-axis we need to deform and reposition the colliders accordingly... + } + + [RegisterCall("ScriptGlue::Transform_GetRotationEuler")] + static void Transform_GetRotationEuler(UUID entityId, out float3 rotationEuler) + { + Entity entity = GetEntitySafe(entityId); + + rotationEuler = entity.Transform.RotationEuler; + } + + [RegisterCall("ScriptGlue::Transform_SetRotationEuler")] + static void Transform_SetRotationEuler(UUID entityId, in float3 rotationEuler) + { + Entity entity = GetEntitySafe(entityId); + + entity.Transform.RotationEuler = rotationEuler; + + if (entity.TryGetComponent(let rigidbody2D)) + { + rigidbody2D.SetAngle(rotationEuler.Z); + } + } + + [Packed] + struct AxisAngle + { + public float3 Axis; + public float Angle; + + public this((float3 Axis, float Angle) axisAngle) + { + Axis = axisAngle.Axis; + Angle = axisAngle.Angle; + } + } + + [RegisterCall("ScriptGlue::Transform_GetRotationAxisAngle")] + static void Transform_GetRotationAxisAngle(UUID entityId, out AxisAngle rotationAxisAngle) + { + Entity entity = GetEntitySafe(entityId); + + rotationAxisAngle = AxisAngle(entity.Transform.RotationAxisAngle); + } + + [RegisterCall("ScriptGlue::Transform_SetRotationAxisAngle")] + static void Transform_SetRotationAxisAngle(UUID entityId, AxisAngle rotationAxisAngle) + { + Entity entity = GetEntitySafe(entityId); + + entity.Transform.RotationAxisAngle = (rotationAxisAngle.Axis, rotationAxisAngle.Angle); + + if (entity.TryGetComponent(let rigidbody2D)) + { + rigidbody2D.SetAngle(entity.Transform.RotationEuler.Z); + } + } + + [RegisterCall("ScriptGlue::Transform_GetScale")] + static void Transform_GetScale(UUID entityId, out float3 scale) + { + Entity entity = GetEntitySafe(entityId); + + scale = entity.Transform.Scale; + } + + [RegisterCall("ScriptGlue::Transform_SetScale")] + static void Transform_SetScale(UUID entityId, float3 scale) + { + Entity entity = GetEntitySafe(entityId); + + entity.Transform.Scale = scale; + + if (entity.TryGetComponent(let rigidbody2D)) + { + // TODO: we need to scale and reposition the colliders, this is a mess... + } } #endregion TransformComponent @@ -574,6 +673,20 @@ static class ScriptGlue rigidBody.SetAngularVelocity(velocity); } + [RegisterCall("ScriptGlue::Rigidbody2D_GetBodyType")] + static void Rigidbody2D_GetBodyType(UUID entityId, out Rigidbody2DComponent.BodyType bodyType) + { + Rigidbody2DComponent* rigidBody = GetComponentSafe(entityId); + bodyType = rigidBody.BodyType; + } + + [RegisterCall("ScriptGlue::Rigidbody2D_SetBodyType")] + static void Rigidbody2D_SetBodyType(UUID entityId, in Rigidbody2DComponent.BodyType bodyType) + { + Rigidbody2DComponent* rigidBody = GetComponentSafe(entityId); + rigidBody.BodyType = bodyType; + } + [RegisterCall("ScriptGlue::Rigidbody2D_IsFixedRotation")] static void Rigidbody2D_IsFixedRotation(UUID entityId, out bool isFixedRotation) { @@ -588,6 +701,20 @@ static class ScriptGlue rigidBody.FixedRotation = isFixedRotation; } + [RegisterCall("ScriptGlue::Rigidbody2D_GetGravityScale")] + static void Rigidbody2D_GetGravityScale(UUID entityId, out float gravityScale) + { + Rigidbody2DComponent* rigidBody = GetComponentSafe(entityId); + gravityScale = rigidBody.GravityScale; + } + + [RegisterCall("ScriptGlue::Rigidbody2D_SetGravityScale")] + static void Rigidbody2D_SetGravityScale(UUID entityId, in float gravityScale) + { + Rigidbody2DComponent* rigidBody = GetComponentSafe(entityId); + rigidBody.GravityScale = gravityScale; + } + #endregion Rigidbody2D #region Camera @@ -742,6 +869,52 @@ static class ScriptGlue #endregion Physics2D +#region CircleRenderer + + [RegisterCall("ScriptGlue::CircleRenderer_GetColor")] + static void CircleRenderer_GetColor(UUID entityId, out ColorRGBA color) + { + CircleRendererComponent* circleRenderer = GetComponentSafe(entityId); + color = circleRenderer.Color; + } + + [RegisterCall("ScriptGlue::CircleRenderer_SetColor")] + static void CircleRenderer_SetColor(UUID entityId, ColorRGBA color) + { + CircleRendererComponent* circleRenderer = GetComponentSafe(entityId); + circleRenderer.Color = color; + } + + [RegisterCall("ScriptGlue::CircleRenderer_GetUvTransform")] + static void CircleRenderer_GetUvTransform(UUID entityId, out float4 uvTransform) + { + CircleRendererComponent* circleRenderer = GetComponentSafe(entityId); + uvTransform = circleRenderer.UvTransform; + } + + [RegisterCall("ScriptGlue::CircleRenderer_SetUvTransform")] + static void CircleRenderer_SetUvTransform(UUID entityId, float4 uvTransform) + { + CircleRendererComponent* circleRenderer = GetComponentSafe(entityId); + circleRenderer.UvTransform = uvTransform; + } + + [RegisterCall("ScriptGlue::CircleRenderer_GetInnerRadius")] + static void CircleRenderer_GetInnerRadius(UUID entityId, out float innerRadius) + { + CircleRendererComponent* circleRenderer = GetComponentSafe(entityId); + innerRadius = circleRenderer.InnerRadius; + } + + [RegisterCall("ScriptGlue::CircleRenderer_GetInnerRadius")] + static void CircleRenderer_GetInnerRadius(UUID entityId, float innerRadius) + { + CircleRendererComponent* circleRenderer = GetComponentSafe(entityId); + circleRenderer.InnerRadius = innerRadius; + } + +#endregion + #region Math private static void RegisterMathFunctions() diff --git a/GlitchyEngine/src/World/Components/Components.bf b/GlitchyEngine/src/World/Components/Components.bf index 6a1b1c0..d7801cd 100644 --- a/GlitchyEngine/src/World/Components/Components.bf +++ b/GlitchyEngine/src/World/Components/Components.bf @@ -349,11 +349,31 @@ namespace GlitchyEngine.World struct Rigidbody2DComponent : IDisposableComponent { - public enum BodyType { Static = 0, Dynamic = 1, Kinematic = 2 } + public enum BodyType + { + case Static = 0; case Dynamic = 1; case Kinematic = 2; - public BodyType BodyType = .Static; + public b2BodyType GetBox2DBodyType() + { + switch (this) + { + case .Static: + return .b2_staticBody; + case .Dynamic: + return .b2_dynamicBody; + case .Kinematic: + return .b2_kinematicBody; + default: + Log.EngineLogger.AssertDebug(false, "Unknown body type"); + return .b2_staticBody; + } + } + } - public bool _fixedRotation = false; + private BodyType _bodyType = .Static; + + private bool _fixedRotation = false; + private float _gravityScale = 1.0f; private int _runtimeBody = 0; @@ -367,6 +387,20 @@ namespace GlitchyEngine.World [Inline] set mut => _runtimeBody = (int)(void*)value; } + + public BodyType BodyType + { + get => _bodyType; + set mut + { + _bodyType = value; + + if (RuntimeBody != null) + { + Box2D.Body.SetBodyType(RuntimeBody, _bodyType.GetBox2DBodyType()); + } + } + } public bool FixedRotation { @@ -382,6 +416,20 @@ namespace GlitchyEngine.World } } + public float GravityScale + { + get => _gravityScale; + set mut + { + _gravityScale = value; + + if (RuntimeBody != null) + { + Box2D.Body.SetGravityScale(RuntimeBody, _gravityScale); + } + } + } + /*public float LinearDamping { get => _linearDamping; diff --git a/GlitchyEngine/src/World/Scene.bf b/GlitchyEngine/src/World/Scene.bf index 8b59cb2..a202f9b 100644 --- a/GlitchyEngine/src/World/Scene.bf +++ b/GlitchyEngine/src/World/Scene.bf @@ -204,22 +204,6 @@ namespace GlitchyEngine.World } } - static b2BodyType GetBox2DBodyType(Rigidbody2DComponent.BodyType bodyType) - { - switch (bodyType) - { - case .Static: - return .b2_staticBody; - case .Dynamic: - return .b2_dynamicBody; - case .Kinematic: - return .b2_kinematicBody; - default: - Log.EngineLogger.AssertDebug(false, "Unknown body type"); - return .b2_staticBody; - } - } - /** * Starts the scene. * @param startRuntime If true, the script runtime will be started. @@ -477,7 +461,7 @@ namespace GlitchyEngine.World var transform = entity.Transform; b2BodyDef def = .(); - def.type = GetBox2DBodyType(rigidBody.BodyType); + def.type = rigidBody.BodyType.GetBox2DBodyType(); def.userData = (void*)(uint)entity.Handle; // TODO: check how stable this is @@ -488,7 +472,9 @@ namespace GlitchyEngine.World def.angle = worldRotationEuler.Z; b2Body* body = Box2D.World.CreateBody(_physicsWorld2D, &def); + // BodyType set above Box2D.Body.SetFixedRotation(body, rigidBody.FixedRotation); + Box2D.Body.SetGravityScale(body, rigidBody.GravityScale); rigidBody.RuntimeBody = body; } diff --git a/GlitchyEngine/src/World/SceneSerializer.bf b/GlitchyEngine/src/World/SceneSerializer.bf index 65dc1e0..bf73355 100644 --- a/GlitchyEngine/src/World/SceneSerializer.bf +++ b/GlitchyEngine/src/World/SceneSerializer.bf @@ -186,6 +186,8 @@ class SceneSerializer Serialize.Value(writer, "BodyType", component.BodyType); Serialize.Value(writer, "FixedRotation", component.FixedRotation); + + Serialize.Value(writer, "GravityScale", component.GravityScale); }); SerializeComponent(writer, entity, "BoxCollider2D", scope (component) => @@ -584,13 +586,21 @@ class SceneSerializer case "Rigidbody2D": Try!(DeserializeComponent(reader, entity, scope (component) => { - Deserialize.Value(reader, "BodyType", out component.BodyType); + Rigidbody2DComponent.BodyType bodyType = .Static; + Deserialize.Value(reader, "BodyType", out bodyType); + component.BodyType = bodyType; + reader.EntryEnd(); bool fixedRotation = false; Deserialize.Value(reader, "FixedRotation", out fixedRotation); component.FixedRotation = fixedRotation; + reader.EntryEnd(); + + Deserialize.Value(reader, "GravityScale", let gravityScale); + component.GravityScale = gravityScale; + return .Ok; })); case "BoxCollider2D": diff --git a/ScriptCore/Core/Transform.cs b/ScriptCore/Core/Transform.cs index c4b06c6..68c12b5 100644 --- a/ScriptCore/Core/Transform.cs +++ b/ScriptCore/Core/Transform.cs @@ -1,3 +1,4 @@ +using System.Numerics; using GlitchyEngine.Math; namespace GlitchyEngine.Core; @@ -35,4 +36,56 @@ public class Transform : Component } set => ScriptGlue.Transform_SetTranslation(Entity.UUID, in value); } + + /// + /// Gets or sets the rotation of the entity. + /// + public Quaternion Rotation + { + get + { + ScriptGlue.Transform_GetRotation(Entity.UUID, out Quaternion rotation); + return rotation; + } + set => ScriptGlue.Transform_SetRotation(Entity.UUID, in value); + } + + /// + /// Gets or sets the rotation of the entity in radians around each axis. + /// + public float3 RotationEuler + { + get + { + ScriptGlue.Transform_GetRotationEuler(Entity.UUID, out float3 rotationEuler); + return rotationEuler; + } + set => ScriptGlue.Transform_SetRotationEuler(Entity.UUID, in value); + } + + /// + /// Gets or sets the rotation of the entity as an axis of rotation and the angle in radians. + /// + public RotationAxisAngle RotationAxisAngle + { + get + { + ScriptGlue.Transform_GetRotationAxisAngle(Entity.UUID, out RotationAxisAngle rotationEuler); + return rotationEuler; + } + set => ScriptGlue.Transform_SetRotationAxisAngle(Entity.UUID, value); + } + + /// + /// Gets or sets the scale of the entity. + /// + public float3 Scale + { + get + { + ScriptGlue.Transform_GetScale(Entity.UUID, out float3 scale); + return scale; + } + set => ScriptGlue.Transform_SetScale(Entity.UUID, in value); + } } diff --git a/ScriptCore/Graphics/CircleRenderer.cs b/ScriptCore/Graphics/CircleRenderer.cs new file mode 100644 index 0000000..9778b1a --- /dev/null +++ b/ScriptCore/Graphics/CircleRenderer.cs @@ -0,0 +1,51 @@ +using GlitchyEngine.Core; +using GlitchyEngine.Math; + +namespace GlitchyEngine.Graphics; + +/// +/// Component that renders a circle. +/// +public class CircleRenderer : Component +{ + // TODO: Texture2D Sprite + + /// + /// Gets or sets the tint color of the circle. + /// + public ColorRGBA Color + { + get + { + ScriptGlue.CircleRenderer_GetColor(_uuid, out ColorRGBA color); + return color; + } + set => ScriptGlue.CircleRenderer_SetColor(_uuid, value); + } + + /// + /// Gets or sets the UV transform for the texture. XY are an offset, ZW are scaling + /// + public float4 UvTransform + { + get + { + ScriptGlue.CircleRenderer_GetUvTransform(_uuid, out float4 uvTransform); + return uvTransform; + } + set => ScriptGlue.CircleRenderer_SetUvTransform(_uuid, value); + } + + /// + /// Gets or sets the inner radius of the torus. 0 means a circle is rendered. + /// + public float InnerRadius + { + get + { + ScriptGlue.CircleRenderer_GetInnerRadius(_uuid, out float innerRadius); + return innerRadius; + } + set => ScriptGlue.CircleRenderer_SetInnerRadius(_uuid, value); + } +} diff --git a/ScriptCore/Math/ColorRGBA.cs b/ScriptCore/Math/ColorRGBA.cs new file mode 100644 index 0000000..f837fd7 --- /dev/null +++ b/ScriptCore/Math/ColorRGBA.cs @@ -0,0 +1,65 @@ +using System.Runtime.InteropServices; + +namespace GlitchyEngine.Math; + +using static GlitchyEngine.Math.Math; + +/// +/// Represents a color with red, blue, green color channels and alpha. +///
Each channel is represented by a +///
+[StructLayout(LayoutKind.Sequential, Pack=1)] +public struct ColorRGBA +{ + internal const float SrgbToLin = 2.2f; + internal const float LinToSRGB = (float)(1.0 / 2.2); + + /// + /// The red component of the color. + /// + public float R; + + /// + /// The green component of the color. + /// + public float G; + + /// + /// The blue component of the color. + /// + public float B; + + /// + /// The alpha component of the color. + /// + public float A; + + /// + /// Creates a new instance of ColorRGBA with all components set to 0. + /// + public ColorRGBA() { } + + /// + /// Creates a new instance of ColorRGBA with the specified values. + /// + /// The red component of the color. + /// The green component of the color. + /// The blue component of the color. + /// The alpha component of the color. + public ColorRGBA(float r, float g, float b, float a = 1.0f) + { + R = r; + G = g; + B = b; + A = a; + } + + public static explicit operator float4(ColorRGBA color) => new float4(color.R, color.G, color.B, color.A); + public static explicit operator ColorRGBA(float4 vector) => new ColorRGBA(vector.X, vector.Y, vector.Z, vector.W); + + // Converts a Color from sRGB color space to Linear color space. + public static ColorRGBA SRgbToLinear(ColorRGBA sRGB) => new ColorRGBA(pow(sRGB.R, SrgbToLin), pow(sRGB.G, SrgbToLin), pow(sRGB.B, SrgbToLin), sRGB.A); + + // Converts a Color from linear color space to sRGB color space. + public static ColorRGBA LinearToSRGB(ColorRGBA linear) => new ColorRGBA(pow(linear.R, LinToSRGB), pow(linear.G, LinToSRGB), pow(linear.B, LinToSRGB), linear.A); +} diff --git a/ScriptCore/Math/RotationAxisAngle.cs b/ScriptCore/Math/RotationAxisAngle.cs new file mode 100644 index 0000000..425f610 --- /dev/null +++ b/ScriptCore/Math/RotationAxisAngle.cs @@ -0,0 +1,30 @@ +using System.Runtime.InteropServices; + +namespace GlitchyEngine.Math; + +/// +/// Represents a rotation around an axis by a specific angle. +/// +[StructLayout(LayoutKind.Sequential, Pack=1)] +public struct RotationAxisAngle +{ + /// + /// The axis around which the rotation is applied. + /// + public float3 Axis; + /// + /// The angle in radians around the . + /// + public float Angle; + + /// + /// Creates a new instance of an axis angle rotation. + /// + /// The axis. + /// The angle in radians. + public RotationAxisAngle(float3 axis, float angle) + { + Axis = axis; + Angle = angle; + } +} diff --git a/ScriptCore/Physics/BodyType.cs b/ScriptCore/Physics/BodyType.cs new file mode 100644 index 0000000..9e8f1aa --- /dev/null +++ b/ScriptCore/Physics/BodyType.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace GlitchyEngine.Physics; + +/// +/// Describes whether the rigid body is static, dynamic or kinematic. +/// +public enum BodyType : byte +{ + /// + /// A static body does not move under simulation and behaves as if it has infinite mass. + /// Internally, Box2D stores zero for the mass and the inverse mass + /// Static bodies can be moved manually by the user. A static body has zero velocity. + /// Static bodies do not collide with other static or kinematic bodies. + /// + Static = 0, + /// + /// A dynamic body is fully simulated. They can be moved manually by the user, but normally they move according to forces. + /// A dynamic body can collide with all body types. A dynamic body always has finite, non-zero mass. + /// If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won't rotate. + /// + Dynamic = 1, + /// + /// A kinematic body moves under simulation according to its velocity. + /// Kinematic bodies do not respond to forces. They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity. + /// A kinematic body behaves as if it has infinite mass, however, Box2D stores zero for the mass and the inverse mass. + /// Kinematic bodies do not collide with other kinematic or static bodies. + /// + Kinematic = 2 +} diff --git a/ScriptCore/Physics/Rigidbody2D.cs b/ScriptCore/Physics/Rigidbody2D.cs index 6eb3203..08a9bc3 100644 --- a/ScriptCore/Physics/Rigidbody2D.cs +++ b/ScriptCore/Physics/Rigidbody2D.cs @@ -101,4 +101,34 @@ public class Rigidbody2D : Component } set => ScriptGlue.Rigidbody2D_SetFixedRotation(_uuid, value); } + + /// + /// Gets or sets the body type of the rigidbody. + /// + public BodyType BodyType + { + get + { + ScriptGlue.Rigidbody2D_GetBodyType(_uuid, out BodyType bodyType); + + return bodyType; + } + set => ScriptGlue.Rigidbody2D_SetBodyType(_uuid, value); + } + + + /// + /// Gets or sets the gravity scale of this rigidbody. + /// E.g. a value of 0.0 means, that the rigidbody is not affected by gravity and a value of -1.0 means, that it gravity is inverted. + /// + public float GravityScale + { + get + { + ScriptGlue.Rigidbody2D_GetGravityScale(_uuid, out float gravityScale); + + return gravityScale; + } + set => ScriptGlue.Rigidbody2D_SetGravityScale(_uuid, value); + } } diff --git a/ScriptCore/ScriptGlue.cs b/ScriptCore/ScriptGlue.cs index cee7512..bbe419f 100644 --- a/ScriptCore/ScriptGlue.cs +++ b/ScriptCore/ScriptGlue.cs @@ -1,7 +1,9 @@ using System; +using System.Numerics; using System.Runtime.CompilerServices; using GlitchyEngine.Core; using GlitchyEngine.Math; +using GlitchyEngine.Physics; using GlitchyEngine.Serialization; namespace GlitchyEngine; @@ -78,6 +80,30 @@ internal static class ScriptGlue [MethodImpl(MethodImplOptions.InternalCall)] internal static extern void Transform_SetTranslation(UUID entityId, in float3 translation); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void Transform_GetRotation(UUID entityId, out Quaternion rotation); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void Transform_SetRotation(UUID entityId, in Quaternion rotation); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void Transform_GetRotationEuler(UUID entityId, out float3 rotationEuler); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void Transform_SetRotationEuler(UUID entityId, in float3 rotationEuler); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void Transform_GetRotationAxisAngle(UUID entityId, out RotationAxisAngle translation); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void Transform_SetRotationAxisAngle(UUID entityId, RotationAxisAngle translation); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void Transform_GetScale(UUID entityId, out float3 scale); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void Transform_SetScale(UUID entityId, in float3 scale); #endregion TransformComponent @@ -113,12 +139,24 @@ internal static class ScriptGlue [MethodImpl(MethodImplOptions.InternalCall)] internal static extern void Rigidbody2D_GetAngularVelocity(UUID entityId, out float velocity); + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void Rigidbody2D_GetBodyType(UUID entityId, out BodyType bodyType); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void Rigidbody2D_SetBodyType(UUID entityId, in BodyType bodyType); + [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); + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void Rigidbody2D_GetGravityScale(UUID entityId, out float gravityScale); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void Rigidbody2D_SetGravityScale(UUID entityId, in float gravityScale); + #endregion RigidBody2D #region Camera @@ -182,6 +220,28 @@ internal static class ScriptGlue #endregion Physics2D +#region CircleRenderer + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void CircleRenderer_GetColor(UUID entityId, out ColorRGBA color); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void CircleRenderer_SetColor(UUID entityId, ColorRGBA color); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void CircleRenderer_GetUvTransform(UUID entityId, out float4 uvTransform); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void CircleRenderer_SetUvTransform(UUID entityId, float4 uvTransform); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void CircleRenderer_GetInnerRadius(UUID entityId, out float innerRadius); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void CircleRenderer_SetInnerRadius(UUID entityId, float innerRadius); + +#endregion + #region Math [MethodImpl(MethodImplOptions.InternalCall)]