Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f9a6716
[WIP] Update movable terrain with createTerrainBedFromGeometries
FilipAlg Feb 3, 2026
71566a0
Merge branch 'master' into feature/movable-terrain-updates
FilipAlg Feb 4, 2026
c52f856
Merge branch 'master' into feature/movable-terrain-updates
FilipAlg Feb 4, 2026
2cc2dfa
Add option to use Delayed field variants to avoid frequent, costly up…
FilipAlg Feb 5, 2026
75bcb87
Moved utility method to find GUIContent and added a utility method to…
FilipAlg Feb 5, 2026
1e203a1
Rename utility method
FilipAlg Feb 5, 2026
43d619b
Update MovableTerrain to allow for creating terrain given a set of be…
FilipAlg Feb 5, 2026
6ff6d45
Added options to render sides of movable terrain and to add height da…
FilipAlg Feb 6, 2026
4a4eddd
Fix FailureVolume serialization issue
FilipAlg Feb 6, 2026
579d977
Add simple MovableTerrain tests
FilipAlg Feb 6, 2026
c0c849e
Merge remote-tracking branch 'origin/master' into feature/movable-ter…
FilipAlg Feb 10, 2026
327a731
Merge branch 'master' into feature/movable-terrain-updates
FilipAlg Feb 12, 2026
336ed72
Move max depth inspector element
FilipAlg Feb 12, 2026
b998cd4
Update log assertions
FilipAlg Feb 13, 2026
ed99b39
Update tests with proper warning types and fix issue with simulation …
FilipAlg Feb 13, 2026
93ceb47
Recreate movable terrain mesh when changing more properties
FilipAlg Feb 18, 2026
60325bb
Merge branch 'master' into feature/movable-terrain-updates
FilipAlg Mar 4, 2026
8ece374
Merge branch 'feature/movable-terrain-updates' of github.com:Algoryx/…
FilipAlg Mar 4, 2026
27b6d38
Merge remote-tracking branch 'origin/master' into feature/movable-ter…
FilipAlg Mar 9, 2026
2cbaca6
Merge remote-tracking branch 'origin/master' into feature/movable-ter…
FilipAlg Apr 21, 2026
2a49ca4
Update MovableTerrain to allow for dynamic mass updates
FilipAlg Apr 23, 2026
4ea7eef
Update tooltip
FilipAlg Apr 23, 2026
fc2ad4b
Update agxDotNet
FilipAlg Apr 24, 2026
fcc2a6f
Make test more reliable
FilipAlg Apr 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions AGXUnity/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ public bool IsValid( Vector2Int value )

public bool OptionalOverrideIsValid( object value )
{
var wrappedType = value.GetType().GenericTypeArguments[ 0 ];
var ooType = typeof( OptionalOverrideValue<> ).MakeGenericType( wrappedType );
var wrappedVal = ooType.GetProperty( "OverrideValue" ).GetValue( value );
var validator = this.GetType().GetMethod( "IsValid", new Type[] { wrappedType } );
var wrappedType = value.GetType().GenericTypeArguments[0];
var ooType = typeof(OptionalOverrideValue<>).MakeGenericType(wrappedType);
var wrappedVal = ooType.GetProperty("OverrideValue").GetValue(value);
var validator = this.GetType().GetMethod("IsValid", new Type[] { wrappedType });
if ( validator == null )
return true;
return (bool)validator.Invoke( this, new object[] { wrappedVal } );
Expand Down Expand Up @@ -244,6 +244,14 @@ public DynamicallyShowInInspector( string name, bool isMethod = false, bool inve
public bool Invert { get; private set; }
}

[AttributeUsage( AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false )]
public class DelayedInspectorAttribute : Attribute
{
public DelayedInspectorAttribute()
{
}
}

[AttributeUsage( AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false )]
public class RuntimeValue : Attribute
{
Expand Down
3 changes: 2 additions & 1 deletion AGXUnity/IO/OpenPLX/OpenPLXUnityMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -805,11 +805,12 @@ GameObject MapTerrain( openplx.Terrain.Terrain terrain )
rbComp.MotionControl = agx.RigidBody.MotionControl.KINEMATICS;

var terrainComp = terrainGO.AddComponent<MovableTerrain>();
terrainComp.PlacementMode = MovableTerrain.Placement.Manual;

terrainComp.ElementSize = (float)terrain.element_size();
terrainComp.MaximumDepth = (float)terrain.max_depth();
terrainComp.SizeCells = new Vector2Int( (int)terrain.num_elements_y(), (int)terrain.num_elements_x() );
terrainComp.InvertDepthDirection = false;
terrainComp.MaxDepthAsInitialHeight = false;

var terrainMat = terrain.material();
if ( !terrainMat.is_default_terrain_material() ) {
Expand Down
1 change: 1 addition & 0 deletions AGXUnity/Model/DeformableTerrainBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public DeformableTerrainProperties TerrainProperties
[IgnoreSynchronization]
[DisableInRuntimeInspector]
[ClampAboveZeroInInspector( true )]
[DelayedInspector]
public float MaximumDepth
{
get { return m_maximumDepth; }
Expand Down
20 changes: 15 additions & 5 deletions AGXUnity/Model/DeformableTerrainFailureVolume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,40 @@ namespace AGXUnity.Model
[HelpURL( "https://us.download.algoryx.se/AGXUnity/documentation/current/editor_interface.html#soil-failure-volumes" )]
public class DeformableTerrainFailureVolume : ScriptComponent
{
[field: SerializeField]
public bool AddAllTerrainsOnStart { get; set; } = true;

private HashSet<DeformableTerrainBase> m_terrains = new HashSet<DeformableTerrainBase>();
[field: SerializeField]
private List<DeformableTerrainBase> m_terrains = new List<DeformableTerrainBase>();

public DeformableTerrainBase[] Terrains => m_terrains.ToArray();

public bool Add( DeformableTerrainBase terrain )
{
return m_terrains.Add( terrain );
if ( m_terrains.Contains( terrain ) ) {
Debug.LogWarning( $"Failure volume '{name}' already contains terrain '{terrain.name}'" );
return false;
}
m_terrains.Add( terrain );
return true;
}

public bool Remove( DeformableTerrainBase terrain )
{
if ( !m_terrains.Contains( terrain ) ) {
Debug.LogWarning( $"Failure volume '{name}' does not contain terrain '{terrain.name}'" );
return false;
}
return m_terrains.Remove( terrain );
}

protected override bool Initialize()
{
if ( AddAllTerrainsOnStart ) {
#if UNITY_2022_2_OR_NEWER
m_terrains.UnionWith( FindObjectsByType<DeformableTerrainBase>( FindObjectsSortMode.None ) );
m_terrains.AddRange( FindObjectsByType<DeformableTerrainBase>( FindObjectsSortMode.None ).Where( t => !m_terrains.Contains( t ) ) );
#else
m_terrains.UnionWith( FindObjectsOfType<DeformableTerrainBase>() );
m_terrains.AddRange( FindObjectsOfType<DeformableTerrainBase>().Where( t => !m_terrains.Contains( t ) ) );
#endif
}
return base.Initialize();
Expand All @@ -59,5 +70,4 @@ private void TriggerFailure()
terr.ConvertToDynamicMassInShape( shape );
}
}

}
Loading
Loading