mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-06 05:01:53 +00:00
ScriptCore: Added Transform.WorldTransform
This commit is contained in:
@@ -506,6 +506,43 @@ static class ScriptGlue
|
|||||||
}
|
}
|
||||||
// TODO: we need to handle repositioning of colliders that are children of the entity with rigidbody...
|
// TODO: we need to handle repositioning of colliders that are children of the entity with rigidbody...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RegisterCall("ScriptGlue::Transform_GetWorldTranslation")]
|
||||||
|
static void Transform_GetWorldTranslation(UUID entityId, out float3 translationWorld)
|
||||||
|
{
|
||||||
|
Entity entity = GetEntitySafe(entityId);
|
||||||
|
|
||||||
|
TransformComponent* transform = entity.Transform;
|
||||||
|
|
||||||
|
translationWorld = transform.WorldTransform.Translation; //(float4(entity.Transform.Position, 1.0f) * entity.Transform.WorldTransform).XYZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
[RegisterCall("ScriptGlue::Transform_SetWorldTranslation")]
|
||||||
|
static void Transform_SetWorldTranslation(UUID entityId, in float3 translation)
|
||||||
|
{
|
||||||
|
Log.ClientLogger.Warning("Transform_SetWorldTranslation is not implemented!");
|
||||||
|
|
||||||
|
// Entity entity = GetEntitySafe(entityId);
|
||||||
|
|
||||||
|
// entity.Transform.Position = translation;
|
||||||
|
|
||||||
|
// // if necessary reposition Rigidbody2D
|
||||||
|
// if (entity.TryGetComponent<Rigidbody2DComponent>(let rigidbody2D))
|
||||||
|
// {
|
||||||
|
// rigidbody2D.SetPosition(translation.XY);
|
||||||
|
// }
|
||||||
|
// TODO: we need to handle repositioning of colliders that are children of the entity with rigidbody...
|
||||||
|
}
|
||||||
|
|
||||||
|
[RegisterCall("ScriptGlue::Transform_TransformPointToWorld")]
|
||||||
|
static void Transform_TransformPointToWorld(UUID entityId, float3 point, out float3 pointWorld)
|
||||||
|
{
|
||||||
|
Entity entity = GetEntitySafe(entityId);
|
||||||
|
|
||||||
|
float3 localPoint = entity.Transform.Position;
|
||||||
|
|
||||||
|
pointWorld = (float4(localPoint, 1.0f) * entity.Transform.WorldTransform).XYZ;
|
||||||
|
}
|
||||||
|
|
||||||
[RegisterCall("ScriptGlue::Transform_GetRotation")]
|
[RegisterCall("ScriptGlue::Transform_GetRotation")]
|
||||||
static void Transform_GetRotation(UUID entityId, out Quaternion rotation)
|
static void Transform_GetRotation(UUID entityId, out Quaternion rotation)
|
||||||
|
|||||||
@@ -36,6 +36,19 @@ public class Transform : Component
|
|||||||
}
|
}
|
||||||
set => ScriptGlue.Transform_SetTranslation(Entity.UUID, in value);
|
set => ScriptGlue.Transform_SetTranslation(Entity.UUID, in value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the translation (position) of the entity in global space.
|
||||||
|
/// </summary>
|
||||||
|
public float3 WorldTranslation
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
ScriptGlue.Transform_GetWorldTranslation(Entity.UUID, out float3 translation);
|
||||||
|
return translation;
|
||||||
|
}
|
||||||
|
set => ScriptGlue.Transform_SetWorldTranslation(Entity.UUID, in value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the rotation of the entity.
|
/// Gets or sets the rotation of the entity.
|
||||||
|
|||||||
@@ -81,6 +81,12 @@ internal static class ScriptGlue
|
|||||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||||
internal static extern void Transform_SetTranslation(UUID entityId, in float3 translation);
|
internal static extern void Transform_SetTranslation(UUID entityId, in float3 translation);
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||||
|
internal static extern void Transform_GetWorldTranslation(UUID entityId, out float3 translation);
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||||
|
internal static extern void Transform_SetWorldTranslation(UUID entityId, in float3 translation);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||||
internal static extern void Transform_GetRotation(UUID entityId, out Quaternion rotation);
|
internal static extern void Transform_GetRotation(UUID entityId, out Quaternion rotation);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user