Browse Source

Use ref when passing structs by pointer through P/Invoke. This fixes positions and angles not being updated correctly in 32-bit builds. This was not a problem in 64-bit mode (probably because an entire vec3_t fits into a single register and the call is optimized as such) but it is in 32-bit mode.

console
Nico de Poel 5 years ago
parent
commit
cd7423ae34
  1. 4
      Assets/Scripts/Modules/GameModule.Interop.cs
  2. 4
      Assets/Scripts/Modules/RenderModule.Interop.cs

4
Assets/Scripts/Modules/GameModule.Interop.cs

@ -48,10 +48,10 @@ public partial class GameModule : CallbackHandler<GameModule>
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void GameSetEntityTransformCallback(IntPtr target, int entityNum, QVec3 origin, QVec3 angles);
private delegate void GameSetEntityTransformCallback(IntPtr target, int entityNum, ref QVec3 origin, ref QVec3 angles);
[MonoPInvokeCallback(typeof(GameSetEntityTransformCallback))]
private static void Callback_GameSetEntityTransform(IntPtr target, int entityNum, QVec3 origin, QVec3 angles)
private static void Callback_GameSetEntityTransform(IntPtr target, int entityNum, ref QVec3 origin, ref QVec3 angles)
{
GetSelf(target).SetEntityTransform(entityNum, origin, angles);
}

4
Assets/Scripts/Modules/RenderModule.Interop.cs

@ -124,10 +124,10 @@ public partial class RenderModule: CallbackHandler<RenderModule>
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void SetupViewCallback(IntPtr target, QVec3 origin, QVec3 angles, QLeaf viewLeaf);
private delegate void SetupViewCallback(IntPtr target, ref QVec3 origin, ref QVec3 angles, ref QLeaf viewLeaf);
[MonoPInvokeCallback(typeof(SetupViewCallback))]
private static void Callback_SetupView(IntPtr target, QVec3 origin, QVec3 angles, QLeaf viewLeaf)
private static void Callback_SetupView(IntPtr target, ref QVec3 origin, ref QVec3 angles, ref QLeaf viewLeaf)
{
GetSelf(target).SetupView(origin, angles, viewLeaf);
}

Loading…
Cancel
Save