add 2D physics (use box2d), fixed some little bugs

This commit is contained in:
2025-12-12 16:47:04 +08:00
parent 804c1d84ce
commit 4140a5b4be
27 changed files with 805 additions and 64 deletions

View File

@ -57,6 +57,10 @@ namespace Prism
SetVec3_Native(m_UnmanagedInstance, uniform, ref value);
}
public void Set(string uniform, Vec4 value)
{
SetVec4_Native(m_UnmanagedInstance, uniform, ref value);
}
public void SetTexture(string uniform, Texture2D texture)
{
@ -82,6 +86,8 @@ namespace Prism
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void SetVec3_Native(IntPtr unmanagedInstance, string uniform, ref Vec3 value);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void SetVec4_Native(IntPtr unmanagedInstance, string uniform, ref Vec4 value);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void SetTexture_Native(IntPtr unmanagedInstance, string uniform, IntPtr texture);
}
}

View File

@ -71,10 +71,10 @@ namespace Prism
}
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern IntPtr GetMesh_Native(ulong entityID);
internal static extern IntPtr GetMesh_Native(ulong entityID);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void SetMesh_Native(ulong entityID, IntPtr unmanagedInstance);
internal static extern void SetMesh_Native(ulong entityID, IntPtr unmanagedInstance);
}
@ -92,4 +92,15 @@ namespace Prism
{
// TODO
}
public class RigidBody2DComponent : Component
{
public void ApplyLinearImpulse(Vec2 impulse, Vec2 offset, bool wake)
{
ApplyLinearImpulse_Native(Entity.ID, ref impulse, ref offset, wake);
}
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void ApplyLinearImpulse_Native(ulong entityID, ref Vec2 impulse, ref Vec2 offset, bool wake);
}
}