Skip to content

Commit 0193d64

Browse files
author
Anders Modén
committed
added some stuff
1 parent 1a4327c commit 0193d64

4 files changed

Lines changed: 57 additions & 5 deletions

File tree

Assets/Saab/GizmoSDK/GizmoBase/Message.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static public void Initialize()
6666
s_class_init = new Initializer();
6767
}
6868

69-
static public void UnInitialize()
69+
static public void Uninitialize()
7070
{
7171
if (s_class_init != null)
7272
s_class_init = null;

Assets/Saab/GizmoSDK/GizmoBase/Platform.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static public void InitializeFactories()
7171
Image.InitializeFactory();
7272
}
7373

74-
static public void UnInitializeFactories()
74+
static public void UninitializeFactories()
7575
{
7676
Module.UninitializeFactory();
7777
Image.UninitializeFactory();
@@ -89,11 +89,11 @@ public static bool Initialize()
8989
return result;
9090
}
9191

92-
public static bool UnInitialize(bool forceShutdown = false)
92+
public static bool Uninitialize(bool forceShutdown = false)
9393
{
94-
Message.UnInitialize();
94+
Message.Uninitialize();
9595

96-
UnInitializeFactories();
96+
UninitializeFactories();
9797
return Platform_uninitialize(forceShutdown);
9898
}
9999

Assets/Saab/GizmoSDK/GizmoBase/Vec.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ public double length()
246246
[Serializable]
247247
public struct Vec3D
248248
{
249+
public static Vec3D Zero = default(Vec3D);
249250
public Vec3D(double _x = 0, double _y = 0, double _z = 0)
250251
{
251252
x = _x;
@@ -286,13 +287,48 @@ public void normalize()
286287
x /= l;
287288
y /= l;
288289
z /= l;
290+
}
289291

292+
public void normalize(out double l)
293+
{
294+
l = Math.Sqrt(x * x + y * y + z * z);
295+
x /= l;
296+
y /= l;
297+
z /= l;
290298
}
291299

292300
public double length()
293301
{
294302
return Math.Sqrt(x * x + y * y + z * z);
295303
}
304+
305+
public static Vec3D Normalize(Vec3D v)
306+
{
307+
var result = v;
308+
result.normalize();
309+
return result;
310+
}
311+
312+
public static Vec3D Normalize(Vec3D v, out double l)
313+
{
314+
l = Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
315+
return new Vec3D(v.x / l, v.y / l, v.z / l);
316+
}
317+
318+
public static Vec3D Lerp(ref Vec3D a, ref Vec3D b, double t)
319+
{
320+
t = Math.Min(1, Math.Max(0, t));
321+
322+
return new Vec3D(
323+
a.x + (b.x - a.x) * t,
324+
a.y + (b.y - a.y) * t,
325+
a.z + (b.z - a.z) * t);
326+
}
327+
328+
public static double Distance(ref Vec3D a, ref Vec3D b)
329+
{
330+
return (b - a).length();
331+
}
296332
}
297333

298334
[Serializable]

Assets/Saab/GizmoSDK/GizmoDistribution/gzDistribution/DistClient.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ public bool SendEvent(DistEvent e,DistSession session)
169169
return DistClient_sendEvent(GetNativeReference(), e.GetNativeReference(), session.GetNativeReference());
170170
}
171171

172+
public DistEvent SendEventAndAwaitResponse(DistEvent e, DistSession session, DistEvent responseEventType, UInt32 timeout=100)
173+
{
174+
if (e.GetType().IsDefined(typeof(DistPropertyAutoStore), true))
175+
e.StorePropertiesAndFields();
176+
177+
DistEvent response = Reference.CreateObject(DistClient_sendEventAndAwaitResponse(GetNativeReference(), e.GetNativeReference(), session.GetNativeReference(), responseEventType.GetNativeReference(), timeout)) as DistEvent;
178+
179+
if(response?.IsValid() ?? false)
180+
if (response.GetType().IsDefined(typeof(DistPropertyAutoRestore), true))
181+
e.RestorePropertiesAndFields();
182+
183+
return response;
184+
}
185+
172186
public bool AddObject(DistObject o, DistSession session, Int32 timeOut = 0)
173187
{
174188
return DistClient_addObject(GetNativeReference(), o.GetNativeReference(), session.GetNativeReference(), timeOut);
@@ -416,6 +430,8 @@ private void OnRemoveAttributes_callback(IntPtr notif, IntPtr o, IntPtr session)
416430
[DllImport(Platform.BRIDGE, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
417431
private static extern bool DistClient_sendEvent(IntPtr client_ref, IntPtr event_ref, IntPtr session_ref);
418432
[DllImport(Platform.BRIDGE, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
433+
private static extern IntPtr DistClient_sendEventAndAwaitResponse(IntPtr client_ref, IntPtr event_ref, IntPtr session_ref,IntPtr response_ref,UInt32 timeout);
434+
[DllImport(Platform.BRIDGE, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
419435
private static extern bool DistClient_subscribeEvents(IntPtr client_ref, IntPtr session_ref,string typeName,Int32 timeOut);
420436
[DllImport(Platform.BRIDGE, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
421437
private static extern bool DistClient_unsubscribeEvents(IntPtr client_ref, IntPtr session_ref, string typeName, Int32 timeOut);

0 commit comments

Comments
 (0)