Skip to content

Commit

Permalink
Merge pull request #135 from Algoryx/feature/cable-instanced-rendering
Browse files Browse the repository at this point in the history
Feature/cable instanced rendering
  • Loading branch information
FilipAlg authored Nov 16, 2023
2 parents 893d38c + e9d49b6 commit 3437f84
Show file tree
Hide file tree
Showing 15 changed files with 844 additions and 121 deletions.
6 changes: 3 additions & 3 deletions AGXUnity/Cable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public CableRoute Route
}

private PointCurve m_routePointCurve = null;
private float m_routePointResulutionPerUnitLength = -1.0f;
private float m_routePointResolutionPerUnitLength = -1.0f;
private Vector3[] m_routePointsCache = new Vector3[] { };

/// <summary>
Expand Down Expand Up @@ -269,7 +269,7 @@ public bool RoutePointCurveUpToDate
get
{
return m_routePointCurve != null &&
Utils.Math.Approximately( m_routePointResulutionPerUnitLength, ResolutionPerUnitLength ) &&
Utils.Math.Approximately( m_routePointResolutionPerUnitLength, ResolutionPerUnitLength ) &&
Route.IsSynchronized( m_routePointCurve, 1.0E-4f );
}
}
Expand Down Expand Up @@ -542,7 +542,7 @@ public PointCurve.SegmentationResult SynchronizeRoutePointCurve()
var numSegments = Mathf.Max( Mathf.CeilToInt( ResolutionPerUnitLength * Route.TotalLength ), 1 );
var result = m_routePointCurve.FindSegmentLength( numSegments, PointCurve.DefaultErrorFunc, 5.0E-3f, 1.0E-3f );
if ( result.Successful ) {
m_routePointResulutionPerUnitLength = ResolutionPerUnitLength;
m_routePointResolutionPerUnitLength = ResolutionPerUnitLength;
var routePoints = new List<Vector3>();
m_routePointCurve.Traverse( ( curr, next, type ) =>
{
Expand Down
9 changes: 7 additions & 2 deletions AGXUnity/CableDamage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public bool RenderCableDamage {
if (CableRenderer == null)
Debug.LogWarning("No CableRenderer to use for rendering cable damages");
else
CableRenderer.SetRenderDamages(value);
CableRenderer.SetRenderDamages(value && m_properties != null);
}
}

Expand All @@ -71,6 +71,11 @@ public CableDamageProperties Properties

if ( Native != null && m_properties != null )
m_properties.Register( this );

if (CableRenderer == null)
Debug.LogWarning("No CableRenderer to use for rendering cable damages");
else
CableRenderer.SetRenderDamages(m_properties != null && m_renderCableDamage);
}
}

Expand Down Expand Up @@ -121,7 +126,7 @@ void Update()

if (m_properties == null)
{
Debug.LogError("No CableDamageProperties set!");
Debug.LogWarning("No CableDamageProperties set - no Cable Damage Calculated!");
return;
}

Expand Down
Loading

0 comments on commit 3437f84

Please sign in to comment.