Skip to content

Commit

Permalink
Merge from 'develop' into 'main' for CLOiSim-4.5.1 (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunseok-yang authored May 2, 2024
2 parents 346b0fc + 59474dc commit 25727e2
Show file tree
Hide file tree
Showing 39 changed files with 2,848 additions and 179 deletions.
33 changes: 21 additions & 12 deletions Assets/Scripts/CLOiSimPlugins/Modules/Base/CLOiSimPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract partial class CLOiSimPlugin : MonoBehaviour, ICLOiSimPlugin

private Pose pluginPose = Pose.identity;

private SDF.Plugin pluginParameters;
private SDF.Plugin _pluginParameters;

private List<ushort> allocatedDevicePorts = new List<ushort>();
private List<string> allocatedDeviceHashKeys = new List<string>();
Expand All @@ -36,9 +36,13 @@ public abstract partial class CLOiSimPlugin : MonoBehaviour, ICLOiSimPlugin

protected abstract void OnAwake();
protected abstract void OnStart();
protected virtual void OnPluginLoad() { }
protected virtual void OnReset() { }

/// <summary>
/// This method should be called in Awake()
/// </summary>
protected virtual void OnPluginLoad() { }

protected void OnDestroy()
{
thread.Dispose();
Expand All @@ -55,29 +59,36 @@ public void ChangePluginType(in ICLOiSimPlugin.Type targetType)

public void SetPluginParameters(in SDF.Plugin plugin)
{
pluginParameters = plugin;
_pluginParameters = plugin;
}

public SDF.Plugin GetPluginParameters()
{
return pluginParameters;
return _pluginParameters;
}

public void StorePluginParametersInAttachedDevices()
{
foreach (var device in attachedDevices.Values)
{
device.SetPluginParameters(_pluginParameters);
}
}

void Awake()
{
SetCustomHandleRequestMessage();

OnAwake();

StorePluginParametersInAttachedDevices();

OnPluginLoad();
}

// Start is called before the first frame update
void Start()
{
foreach (var device in attachedDevices.Values)
{
device.SetPluginParameters(pluginParameters);
}

StorePose();

if (string.IsNullOrEmpty(modelName))
Expand All @@ -87,11 +98,9 @@ void Start()

if (string.IsNullOrEmpty(partsName))
{
partsName = pluginParameters.Name;
partsName = _pluginParameters.Name;
}

OnPluginLoad();

OnStart();

thread.Start();
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Devices/DepthCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ protected override void SetupTexture()
var width = camParameter.image.width;
var height = camParameter.image.height;
var format = CameraData.GetPixelFormat(camParameter.image.format);

GraphicsFormat graphicFormat;
switch (format)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// Copyright 2021 Alejandro Villalba Avila
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.

using System.Collections.Generic;

namespace Game.Utils.Triangulation
{
/// <summary>
/// Data tha describe a triangle and its context in a triangulation.
/// </summary>
public unsafe struct DelaunayTriangle
{
/// <summary>
/// The indices of the points that define the triangle.
/// </summary>
public fixed int p[3];

/// <summary>
/// The indices of the triangles that are adjacent.
/// </summary>
public fixed int adjacent[3];

private const int NO_ADJACENT_TRIANGLE = -1;

/// <summary>
/// Constructor that receives 3 vertex indices.
/// </summary>
/// <param name="point0">The index of the first vertex.</param>
/// <param name="point1">The index of the second vertex.</param>
/// <param name="point2">The index of the third vertex.</param>
public DelaunayTriangle(int point0, int point1, int point2)
{
p[0] = point0;
p[1] = point1;
p[2] = point2;

adjacent[0] = NO_ADJACENT_TRIANGLE;
adjacent[1] = NO_ADJACENT_TRIANGLE;
adjacent[2] = NO_ADJACENT_TRIANGLE;
}

/// <summary>
/// Constructor that receives all the data.
/// </summary>
/// <param name="point0">The index of the first vertex.</param>
/// <param name="point1">The index of the second vertex.</param>
/// <param name="point2">The index of the third vertex.</param>
/// <param name="adjacent0">The index of the triangle that is adjacent in the first edge.</param>
/// <param name="adjacent1">The index of the triangle that is adjacent in the second edge.</param>
/// <param name="adjacent2">The index of the triangle that is adjacent in the third edge.</param>
public DelaunayTriangle(int point0, int point1, int point2, int adjacent0, int adjacent1, int adjacent2)
{
p[0] = point0;
p[1] = point1;
p[2] = point2;

adjacent[0] = adjacent0;
adjacent[1] = adjacent1;
adjacent[2] = adjacent2;
}

#if UNITY_EDITOR

/// <summary>
/// Gets the content of the triangle vertices array, which cannot be watch by Visual Studio unless you convert it to a list.
/// </summary>
public List<int> DebugP
{
get
{
List<int> debugArray = new List<int>(3);
for (int i = 0; i < 3; ++i)
{
debugArray.Add(p[i]);
}
return debugArray;
}
}

/// <summary>
/// Gets the content of the triangle adjacents array, which cannot be watch by Visual Studio unless you convert it to a list.
/// </summary>
public List<int> DebugAdjacent
{
get
{
List<int> debugArray = new List<int>(3);
for (int i = 0; i < 3; ++i)
{
debugArray.Add(adjacent[i]);
}
return debugArray;
}
}

#endif

}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2021 Alejandro Villalba Avila
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.

namespace Game.Utils.Triangulation
{
/// <summary>
/// Data that describes the edge of a triangle.
/// </summary>
public struct DelaunayTriangleEdge
{
/// <summary>
/// The index of the triangle.
/// </summary>
public int TriangleIndex;

/// <summary>
/// The local index of the edge in the triangle (0, 1 or 2).
/// </summary>
public int EdgeIndex;

/// <summary>
/// The index of the first vertex that form the edge.
/// </summary>
public int EdgeVertexA;

/// <summary>
/// The index of the second vertex that form the edge.
/// </summary>
public int EdgeVertexB;

/// <summary>
/// Constructor that receives all the data.
/// </summary>
/// <param name="triangleIndex">The index of the triangle.</param>
/// <param name="edgeIndex">The local index of the edge (0, 1 or 2).</param>
/// <param name="edgeVertexA">The index of the first vertex that form the edge.</param>
/// <param name="edgeVertexB">The index of the second vertex that form the edge.</param>
public DelaunayTriangleEdge(int triangleIndex, int edgeIndex, int edgeVertexA, int edgeVertexB)
{
TriangleIndex = triangleIndex;
EdgeIndex = edgeIndex;
EdgeVertexA = edgeVertexA;
EdgeVertexB = edgeVertexB;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 25727e2

Please sign in to comment.