mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Transitioned from VectorX to floatX
And some trying to update Rigidbody when transform changes
This commit is contained in:
@@ -30,7 +30,7 @@ enum ScriptFieldType
|
||||
UInt, // UInt2, UInt3, UInt4,
|
||||
ULong,
|
||||
// Half, Half2, Half3, Half4,
|
||||
Float, Vector2, Vector3, Vector4,
|
||||
Float, float2, float3, float4,
|
||||
Double, // Double2, Double3, Double4,
|
||||
|
||||
Entity
|
||||
@@ -53,9 +53,9 @@ static sealed class ScriptEngineHelper
|
||||
("System.UInt64", .ULong),
|
||||
|
||||
("System.Single", .Float),
|
||||
("GlitchyEngine.Math.Vector2", .Vector2),
|
||||
("GlitchyEngine.Math.Vector3", .Vector3),
|
||||
("GlitchyEngine.Math.Vector4", .Vector4),
|
||||
("GlitchyEngine.Math.float2", .float2),
|
||||
("GlitchyEngine.Math.float3", .float3),
|
||||
("GlitchyEngine.Math.float4", .float4),
|
||||
|
||||
("System.Double", .Double),
|
||||
|
||||
@@ -314,9 +314,9 @@ static class ScriptEngine
|
||||
|
||||
Mono.mono_add_internal_call("GlitchyEngine.CSharpTesting::Sample", v);
|
||||
|
||||
function void(in Vector3, in Vector3, out Vector3) v2 = => Add;
|
||||
function void(in float3, in float3, out float3) v2 = => Add;
|
||||
|
||||
Mono.mono_add_internal_call("GlitchyEngine.Vector3::Add_Internal", v2);
|
||||
Mono.mono_add_internal_call("GlitchyEngine.float3::Add_Internal", v2);
|
||||
|
||||
// Create object
|
||||
ScriptClass myClass = scope .("GlitchyEngine", "CSharpTesting");
|
||||
@@ -342,7 +342,7 @@ static class ScriptEngine
|
||||
}
|
||||
|
||||
[LinkName(.C), AlwaysInclude, Export]
|
||||
public static void Add(in Vector3 a, in Vector3 b, out Vector3 c)
|
||||
public static void Add(in float3 a, in float3 b, out float3 c)
|
||||
{
|
||||
c = a + b;
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ static class ScriptGlue
|
||||
#region TransformComponent
|
||||
|
||||
[RegisterCall("ScriptGlue::Transform_GetTranslation")]
|
||||
static void Transform_GetTranslation(UUID entityId, ref Vector3 translation)
|
||||
static void Transform_GetTranslation(UUID entityId, ref float3 translation)
|
||||
{
|
||||
Scene scene = ScriptEngine.Context;
|
||||
Entity entity = scene.GetEntityByID(entityId);
|
||||
@@ -196,12 +196,18 @@ static class ScriptGlue
|
||||
}
|
||||
|
||||
[RegisterCall("ScriptGlue::Transform_SetTranslation")]
|
||||
static void Transform_SetTranslation(UUID entityId, ref Vector3 translation)
|
||||
static void Transform_SetTranslation(UUID entityId, ref float3 translation)
|
||||
{
|
||||
Scene scene = ScriptEngine.Context;
|
||||
Entity entity = scene.GetEntityByID(entityId);
|
||||
|
||||
entity.Transform.Position = translation;
|
||||
|
||||
// if necessary reposition Rigidbody2D
|
||||
if (entity.TryGetComponent<Rigidbody2DComponent>(let rigidbody2D))
|
||||
{
|
||||
rigidbody2D.SetPosition(translation.XY);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion TransformComponent
|
||||
@@ -209,7 +215,7 @@ static class ScriptGlue
|
||||
#region RigidBody2D
|
||||
|
||||
[RegisterCall("ScriptGlue::RigidBody2D_ApplyForce")]
|
||||
static void RigidBody2D_ApplyForce(UUID entityId, ref Vector2 force, ref Vector2 point, bool wakeUp)
|
||||
static void RigidBody2D_ApplyForce(UUID entityId, ref float2 force, ref float2 point, bool wakeUp)
|
||||
{
|
||||
Scene scene = ScriptEngine.Context;
|
||||
Entity entity = scene.GetEntityByID(entityId);
|
||||
@@ -219,7 +225,7 @@ static class ScriptGlue
|
||||
}
|
||||
|
||||
[RegisterCall("ScriptGlue::RigidBody2D_ApplyForceToCenter")]
|
||||
static void RigidBody2D_ApplyForceToCenter(UUID entityId, ref Vector2 force, bool wakeUp)
|
||||
static void RigidBody2D_ApplyForceToCenter(UUID entityId, ref float2 force, bool wakeUp)
|
||||
{
|
||||
Scene scene = ScriptEngine.Context;
|
||||
Entity entity = scene.GetEntityByID(entityId);
|
||||
@@ -235,16 +241,16 @@ static class ScriptGlue
|
||||
// TODO: We need a wrapper class!
|
||||
|
||||
[RegisterCall("ScriptGlue::Physics2D_GetGravity")]
|
||||
static void Physics2D_GetGravity(ref Vector2 gravity)
|
||||
static void Physics2D_GetGravity(ref float2 gravity)
|
||||
{
|
||||
Scene scene = ScriptEngine.Context;
|
||||
|
||||
var box2DGravity = Box2D.World.GetGravity(scene.[Friend]_physicsWorld2D);
|
||||
gravity = *(Vector2*)&box2DGravity;
|
||||
gravity = *(float2*)&box2DGravity;
|
||||
}
|
||||
|
||||
[RegisterCall("ScriptGlue::Physics2D_SetGravity")]
|
||||
static void Physics2D_SetGravity(ref Vector2 gravity)
|
||||
static void Physics2D_SetGravity(ref float2 gravity)
|
||||
{
|
||||
Scene scene = ScriptEngine.Context;
|
||||
|
||||
|
||||
@@ -109,17 +109,17 @@ class ScriptInstance : RefCounter
|
||||
var value = GetFieldValue<float>(field);
|
||||
target.SetFieldValue(field, value);
|
||||
|
||||
/*case .Vector2:
|
||||
GetFieldValue<Vector2>(field, var value);
|
||||
if (ImGui.EditVector2(fieldName, ref value))
|
||||
/*case .float2:
|
||||
GetFieldValue<float2>(field, var value);
|
||||
if (ImGui.Editfloat2(fieldName, ref value))
|
||||
SetFieldValue(field, value);
|
||||
case .Vector3:
|
||||
GetFieldValue<Vector3>(field, var value);
|
||||
if (ImGui.EditVector3(fieldName, ref value))
|
||||
case .float3:
|
||||
GetFieldValue<float3>(field, var value);
|
||||
if (ImGui.Editfloat3(fieldName, ref value))
|
||||
SetFieldValue(field, value);
|
||||
case .Vector4:
|
||||
GetFieldValue<Vector4>(field, var value);
|
||||
if (ImGui.EditVector4(fieldName, ref value))
|
||||
case .float4:
|
||||
GetFieldValue<float4>(field, var value);
|
||||
if (ImGui.Editfloat4(fieldName, ref value))
|
||||
SetFieldValue(field, value);
|
||||
|
||||
case .Double:
|
||||
|
||||
Reference in New Issue
Block a user