-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSofaBaseAPI.cs
More file actions
82 lines (66 loc) · 2.09 KB
/
SofaBaseAPI.cs
File metadata and controls
82 lines (66 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using UnityEngine;
using System;
using System.Runtime.InteropServices;
namespace SofaUnityAPI
{
public class SofaBaseAPI : IDisposable
{
/// Name of the Sofa 3D Object mapped to this Object.
protected string m_name;
/// Pointer to the SofaPhysicsAPI
protected IntPtr m_simu = IntPtr.Zero;
protected bool m_isReady = false;
protected bool m_isCustom = false;
// TODO: check if needed
bool m_isDisposed;
/// Parameter to activate internal logging
protected bool displayLog = false;
/// <summary> Default constructor, will call impl method: @see createObject() </summary>
/// <param name="simu">Pointer to the SofaPhysicsAPI</param>
/// <param name="nameID">Name of this Object</param>
public SofaBaseAPI(IntPtr simu, string nameID, bool isCustom)
{
m_isReady = false;
m_simu = simu;
m_name = nameID;
m_isCustom = isCustom;
if (m_simu == IntPtr.Zero)
{
Debug.LogError("SBaseAPI created with null SofaContextAPI pointer.");
m_isReady = false;
return;
}
m_isReady = Init();
}
/// method to be overriden by cildren
virtual protected bool Init()
{
//Debug.Log("SBaseAPI::Init() " + m_name);
return true;
}
/// Memory free method
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// Memory free method
protected virtual void Dispose(bool disposing)
{
if (!m_isDisposed)
{
m_isDisposed = true;
}
}
protected bool checkNativePointer()
{
if (m_simu == IntPtr.Zero) // use native pointer?? m_native
{
Debug.LogError("Can't access Sofa native API for: " + m_name);
return false;
}
else
return true;
}
}
}