Skip to content

Commit 8c7b7f2

Browse files
authored
[Scripts] Small fix on XRay binding in GraphicsAPI and add option readOnly in the SofaRigidMapper to control SOFA object (#211)
* Add readOnly mode to the SofaRigidMapper * [GraphicsAPI] Small fix on XRay binding
1 parent 6204d18 commit 8c7b7f2

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

Core/Plugins/SofaUnityAPI/GraphicAPI/SofaGraphicAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void Dispose()
1919
public static extern int AddRenderEvent_SetPluginTexture(System.IntPtr simuContext, System.IntPtr texture, int w, int h, string objectName);
2020

2121
[DllImport("VirtualXRay")]
22-
public static extern int AddRenderEvent_SetVirtualXRayTexture(System.IntPtr simuContext, System.IntPtr texture, int w, int h, string objectName);
22+
public static extern int AddRenderEvent_SetVirtualXRayTexture(System.IntPtr simuContext, System.IntPtr texture, int w, int h, string objectName, int graphicsType);
2323

2424
[DllImport("ImagingUS")]
2525
public static extern int AddRenderEvent_SetImagingUSTexture(System.IntPtr simuContext, System.IntPtr texture, int w, int h, string objectName, int graphicsType);

Core/Scripts/Modules/Controllers/SofaRigidMapper.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace SofaUnity
99
public class SofaRigidMapper : MonoBehaviour
1010
{
1111
public SofaMesh m_sofaMesh = null;
12+
public bool m_isReadOnly = false;
1213

1314
private bool m_updatedFromSofa = true;
1415

@@ -51,11 +52,20 @@ void FixedUpdate()
5152
if (!m_ready)
5253
return;
5354

54-
if (m_updatedFromSofa) {
55+
if (m_isReadOnly)
56+
{
5557
UpdateFromSofa();
5658
}
59+
else
60+
{
61+
if (m_updatedFromSofa)
62+
{
63+
UpdateFromSofa();
64+
m_updatedFromSofa = false;
65+
}
5766

58-
UpdateToSofa();
67+
UpdateToSofa();
68+
}
5969
}
6070

6171

@@ -77,8 +87,6 @@ protected void UpdateFromSofa()
7787

7888
// Combine current rotation with SofaContext one
7989
this.transform.rotation = m_sofaMesh.m_sofaContext.transform.rotation * this.transform.rotation;
80-
81-
m_updatedFromSofa = false;
8290
}
8391

8492

0 commit comments

Comments
 (0)