Skip to content

Commit de871d6

Browse files
authored
Merge branch 'master' into audio-event-processors
2 parents 73f9196 + 91f8fcf commit de871d6

File tree

197 files changed

+921
-697
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+921
-697
lines changed

engine/Sandbox-Engine.slnx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<Project Path="Mounting/Sandbox.Mounting/Sandbox.Mounting.csproj" />
5151
</Folder>
5252
<Folder Name="/Engine/Tier1/">
53-
<Project Path="Sandbox.Engine/Sandbox.Engine.csproj" />
53+
<Project Path="Sandbox.Engine/Sandbox.Engine.csproj" DefaultStartup="true" />
5454
</Folder>
5555
<Folder Name="/Engine/Tier2/">
5656
<Project Path="Sandbox.AppSystem/Sandbox.AppSystem.csproj" />
@@ -64,9 +64,12 @@
6464
<Folder Name="/Tests/">
6565
<Project Path="Benchmark/Benchmark.csproj" />
6666
<Project Path="Sandbox.Hotload.Test/Sandbox.Hotload.Test.csproj" />
67+
<Project Path="Sandbox.Test/Sandbox.Test.csproj" />
68+
<Project Path="Sandbox.Test.Unit/Sandbox.Test.Unit.csproj" />
69+
</Folder>
70+
<Folder Name="/Tests/Resources/">
6771
<Project Path="Sandbox.Test.Generate/Sandbox.Test.Generate.csproj" />
6872
<Project Path="Sandbox.Test.Hotload/Sandbox.Test.AfterHotload.csproj" />
6973
<Project Path="Sandbox.Test.Hotload/Sandbox.Test.BeforeHotload.csproj" />
70-
<Project Path="Sandbox.Test/Sandbox.Test.csproj" />
7174
</Folder>
7275
</Solution>

engine/Sandbox.Bind/Assembly.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
using System.Runtime.CompilerServices;
77

88
[assembly: InternalsVisibleTo( "Sandbox.Test" )]
9-
[assembly: InternalsVisibleTo( "Sandbox.System.Test" )]
10-
[assembly: InternalsVisibleTo( "Sandbox.UI.Test" )]
11-
[assembly: InternalsVisibleTo( "Sandbox.Bind.Test" )]
12-
9+
[assembly: InternalsVisibleTo( "Sandbox.Test.Unit" )]
1310
[assembly: InternalsVisibleTo( "Sandbox.Engine" )]
1411
[assembly: InternalsVisibleTo( "Sandbox.Tools" )]
1512
[assembly: InternalsVisibleTo( "Sandbox.Menu" )]

engine/Sandbox.CodeUpgrader.Test/Sandbox.CodeUpgrader.Test.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
<IsTestProject>true</IsTestProject>
99
<IsPublishable>false</IsPublishable>
1010
</PropertyGroup>
11-
12-
<PropertyGroup Condition="'$(BuildingForLiveUnitTesting)' == 'true'">
13-
<DefineConstants>$(DefineConstants);LIVE_UNIT_TEST</DefineConstants>
14-
</PropertyGroup>
15-
11+
1612
<ItemGroup>
1713
<Compile Remove="data\**\*.cs" />
1814
<None Include="data\**\*.*" CopyToOutputDirectory="Always" />

engine/Sandbox.Compiling.Test/Sandbox.Compiling.Test.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
<IsPublishable>false</IsPublishable>
1010
</PropertyGroup>
1111

12-
<PropertyGroup Condition="'$(BuildingForLiveUnitTesting)' == 'true'">
13-
<DefineConstants>$(DefineConstants);LIVE_UNIT_TEST</DefineConstants>
14-
</PropertyGroup>
15-
1612
<ItemGroup>
1713
<Compile Remove="data\**\*.cs" />
1814
<None Include="data\**\*.*" CopyToOutputDirectory="Always" />

engine/Sandbox.Engine/Application.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static class Application
2323
/// <summary>
2424
/// True if we're running the engine as part of a unit test
2525
/// </summary>
26-
public static bool IsUnitTest { get; private set; }
26+
public static bool IsUnitTest { get; internal set; }
2727

2828
/// <summary>
2929
/// True if running without a graphics window, such as in a terminal.

engine/Sandbox.Engine/Assembly.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
using System.Runtime.CompilerServices;
1111

1212
[assembly: InternalsVisibleTo( "Sandbox.Test" )]
13-
[assembly: InternalsVisibleTo( "Sandbox.UI.Test" )]
14-
[assembly: InternalsVisibleTo( "Sandbox.Tools.Test" )]
15-
[assembly: InternalsVisibleTo( "Sandbox.Access.Test" )]
13+
[assembly: InternalsVisibleTo( "Sandbox.Test.Unit" )]
1614
[assembly: InternalsVisibleTo( "Sandbox.Hotload.Test" )]
1715
[assembly: InternalsVisibleTo( "Sandbox.GameInstance" )]
1816
[assembly: InternalsVisibleTo( "Sandbox.Tools" )]

engine/Sandbox.Engine/Resources/Terrain/TerrainMaterial.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
using System.IO;
1+
using System.IO;
22
using System.Text.Json.Serialization;
33

44
namespace Sandbox;
55

6+
[Flags]
7+
public enum TerrainFlags : uint
8+
{
9+
None = 0,
10+
NoTile = 1 << 0
11+
}
12+
613
/// <summary>
714
/// Description of a Terrain Material.
815
/// </summary>
@@ -25,7 +32,6 @@ public class TerrainMaterial : GameResource
2532
[JsonIgnore, Hide] public Texture NHOTexture { get; private set; }
2633

2734
[Category( "Material" ), Title( "UV Scale" )] public float UVScale { get; set; } = 1.0f;
28-
[Category( "Material" ), Title( "UV Rotation" )] public float UVRotation { get; set; } = 0.0f;
2935
[Category( "Material" ), Range( 0.0f, 1.0f )] public float Metalness { get; set; } = 0.0f;
3036
[Category( "Material" ), Range( 0.1f, 10 )] public float NormalStrength { get; set; } = 1.0f;
3137
[Category( "Material" ), Range( 0.1f, 10 )] public float HeightBlendStrength { get; set; } = 1.0f;
@@ -36,6 +42,23 @@ public class TerrainMaterial : GameResource
3642
[Category( "Material" ), Range( 0.0f, 10.0f ), Title( "Displacement Scale" ), ShowIf( nameof( HasHeightTexture ), true )]
3743
public float DisplacementScale { get; set; } = 0.0f;
3844

45+
[Category( "Material" ), Title( "No Tiling" )]
46+
public bool NoTiling { get; set; } = false;
47+
48+
[JsonIgnore, Hide]
49+
public TerrainFlags Flags
50+
{
51+
get
52+
{
53+
var flags = TerrainFlags.None;
54+
55+
if ( NoTiling )
56+
flags |= TerrainFlags.NoTile;
57+
58+
return flags;
59+
}
60+
}
61+
3962
[Category( "Misc" )] public Surface Surface { get; set; }
4063

4164
void LoadGeneratedTextures()

engine/Sandbox.Engine/Scene/Components/Joint/WheelJoint.cs

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
public sealed class WheelJoint : Joint
1010
{
1111
/// <inheritdoc cref="Physics.WheelJoint.EnableSuspensionLimit"/>
12-
[Property, ToggleGroup( "EnableSuspensionLimit", Label = "Suspension Limit" )]
12+
[Property, ToggleGroup( "EnableSuspensionLimit", Label = "Suspension Limit" ), ShowIf( nameof( EnableSuspension ), true )]
1313
public bool EnableSuspensionLimit
1414
{
1515
get;
@@ -21,14 +21,14 @@ public bool EnableSuspensionLimit
2121

2222
if ( _joint.IsValid() )
2323
{
24-
_joint.EnableSuspensionLimit = field;
24+
_joint.EnableSuspensionLimit = !EnableSuspension || field;
2525
_joint.WakeBodies();
2626
}
2727
}
2828
}
2929

3030
/// <inheritdoc cref="Physics.WheelJoint.SuspensionLimits"/>
31-
[Property, Group( "EnableSuspensionLimit" ), Title( "Translation Limits" ), Range( -25, 25 )]
31+
[Property, Group( "EnableSuspensionLimit" ), Title( "Translation Limits" ), Range( -25, 25 ), ShowIf( nameof( EnableSuspension ), true )]
3232
public Vector2 SuspensionLimits
3333
{
3434
get;
@@ -40,7 +40,7 @@ public Vector2 SuspensionLimits
4040

4141
if ( _joint.IsValid() )
4242
{
43-
_joint.SuspensionLimits = field;
43+
_joint.SuspensionLimits = EnableSuspension ? field : 0.0f;
4444
_joint.WakeBodies();
4545
}
4646
}
@@ -116,12 +116,31 @@ public bool EnableSuspension
116116

117117
if ( _joint.IsValid() )
118118
{
119-
_joint.EnableSuspension = field;
119+
UpdateSuspension();
120+
120121
_joint.WakeBodies();
121122
}
122123
}
123124
}
124125

126+
void UpdateSuspension()
127+
{
128+
_joint.EnableSuspension = EnableSuspension;
129+
130+
if ( EnableSuspension )
131+
{
132+
// Suspension on, use user limits.
133+
_joint.EnableSuspensionLimit = EnableSuspensionLimit;
134+
_joint.SuspensionLimits = SuspensionLimits;
135+
}
136+
else
137+
{
138+
// Suspension off, limit it to zero.
139+
_joint.EnableSuspensionLimit = true;
140+
_joint.SuspensionLimits = 0.0f;
141+
}
142+
}
143+
125144
/// <inheritdoc cref="Physics.WheelJoint.SuspensionHertz"/>
126145
[Property, Group( "EnableSuspension" ), Title( "Hertz" ), Range( 0, 30 )]
127146
public float SuspensionHertz
@@ -139,7 +158,7 @@ public float SuspensionHertz
139158
_joint.WakeBodies();
140159
}
141160
}
142-
}
161+
} = 10.0f;
143162

144163
/// <inheritdoc cref="Physics.WheelJoint.SuspensionDampingRatio"/>
145164
[Property, Group( "EnableSuspension" ), Title( "Damping" ), Range( 0, 2 )]
@@ -158,7 +177,7 @@ public float SuspensionDampingRatio
158177
_joint.WakeBodies();
159178
}
160179
}
161-
}
180+
} = 1.0f;
162181

163182
/// <inheritdoc cref="Physics.WheelJoint.EnableSteering"/>
164183
[Property, ToggleGroup( "EnableSteering", Label = "Steering" )]
@@ -196,7 +215,7 @@ public float SteeringHertz
196215
_joint.WakeBodies();
197216
}
198217
}
199-
}
218+
} = 10.0f;
200219

201220
/// <inheritdoc cref="Physics.WheelJoint.SteeringDampingRatio"/>
202221
[Property, Group( "EnableSteering" ), Title( "Damping" ), Range( 0, 2 )]
@@ -215,7 +234,7 @@ public float SteeringDampingRatio
215234
_joint.WakeBodies();
216235
}
217236
}
218-
}
237+
} = 1.0f;
219238

220239
/// <inheritdoc cref="Physics.WheelJoint.TargetSteeringAngle"/>
221240
[Property, Group( "EnableSteering" ), Title( "Target Angle" ), Range( -180, 180 )]
@@ -343,19 +362,18 @@ private void UpdateProperties()
343362
_joint.EnableSpinMotor = EnableSpinMotor;
344363
_joint.MaxSpinTorque = MaxSpinTorque;
345364
_joint.SpinMotorSpeed = SpinMotorSpeed;
346-
_joint.EnableSuspension = EnableSuspension;
347365
_joint.SuspensionHertz = SuspensionHertz;
348366
_joint.SuspensionDampingRatio = SuspensionDampingRatio;
349367
_joint.EnableSteering = EnableSteering;
350368
_joint.SteeringHertz = SteeringHertz;
351369
_joint.SteeringDampingRatio = SteeringDampingRatio;
352370
_joint.TargetSteeringAngle = TargetSteeringAngle;
353371
_joint.MaxSteeringTorque = MaxSteeringTorque;
354-
_joint.EnableSuspensionLimit = EnableSuspensionLimit;
355372
_joint.EnableSteeringLimit = EnableSteeringLimit;
356-
_joint.SuspensionLimits = SuspensionLimits;
357373
_joint.SteeringLimits = SteeringLimits;
358374

375+
UpdateSuspension();
376+
359377
_joint.WakeBodies();
360378
}
361379
}

engine/Sandbox.Engine/Scene/Components/Terrain/Terrain.Rendering.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void CreateClipmapSceneObject()
4646
_so.Flags.CastShadows = RenderType == ShadowRenderType.On || RenderType == ShadowRenderType.ShadowsOnly;
4747

4848
// If we have no textures, push a grid texture (SUCKS)
49-
_so.Attributes.SetCombo( "D_GRID", Storage.Materials.Count == 0 );
49+
_so.Attributes.SetCombo( "D_GRID", Storage?.Materials.Count == 0 );
5050

5151
_clipMapLodLevels = ClipMapLodLevels;
5252
_clipMapLodExtentTexels = ClipMapLodExtentTexels;
@@ -70,13 +70,13 @@ private struct GPUTerrain
7070
public float HeightBlendSharpness;
7171
}
7272

73-
[StructLayout( LayoutKind.Sequential, Pack = 0 )]
73+
[StructLayout( LayoutKind.Sequential )]
7474
private struct GPUTerrainMaterial
7575
{
7676
public int BCRTextureID;
7777
public int NHOTextureID;
7878
public float UVScale;
79-
public float UVRotation;
79+
public TerrainFlags Flags;
8080
public float Metalness;
8181
public float HeightBlendStrength;
8282
public float NormalStrength;
@@ -153,11 +153,11 @@ public unsafe void UpdateMaterialsBuffer()
153153
BCRTextureID = layer?.BCRTexture?.Index ?? 0,
154154
NHOTextureID = layer?.NHOTexture?.Index ?? 0,
155155
UVScale = 1.0f / (layer?.UVScale ?? 1.0f),
156-
UVRotation = layer?.UVRotation ?? 1.0f,
157156
Metalness = layer?.Metalness ?? 0.0f,
158157
NormalStrength = 1.0f / (layer?.NormalStrength ?? 1.0f),
159158
HeightBlendStrength = layer?.HeightBlendStrength ?? 1.0f,
160159
DisplacementScale = layer?.DisplacementScale ?? 0.0f,
160+
Flags = layer?.Flags ?? TerrainFlags.None,
161161
};
162162
}
163163

@@ -167,6 +167,6 @@ public unsafe void UpdateMaterialsBuffer()
167167
Scene.RenderAttributes.Set( "TerrainMaterials", MaterialsBuffer );
168168

169169
// If we have no textures, push a grid texture (SUCKS)
170-
_so.Attributes.SetCombo( "D_GRID", Storage.Materials.Count == 0 );
170+
_so.Attributes.SetCombo( "D_GRID", Storage?.Materials.Count == 0 );
171171
}
172172
}

engine/Sandbox.Engine/Systems/Filesystem/Storage/Storage.Query.cs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,31 @@ public class Query
7474
/// <summary>
7575
/// Run the query
7676
/// </summary>
77-
public async Task<QueryResult> Run( CancellationToken token = default )
77+
public Task<QueryResult> Run( CancellationToken token = default )
78+
{
79+
// gets first page of results
80+
return RunEx( "*", token );
81+
}
82+
83+
/// <summary>
84+
/// Run the query
85+
/// </summary>
86+
internal async Task<QueryResult> RunEx( string nextToken, CancellationToken token = default )
7887
{
7988
var json = JsonSerializer.Serialize( this );
80-
using var q = NativeEngine.CUgcQuery.CreateQuery( json, "" );
89+
using var q = NativeEngine.CUgcQuery.CreateQuery( json, nextToken );
8190

8291
while ( !q.m_complete )
8392
{
8493
await Task.Delay( 100, token );
8594
}
8695

8796
var resultJson = q.GetResultJson();
88-
return Json.Deserialize<QueryResult>( resultJson );
89-
}
9097

98+
var result = Json.Deserialize<QueryResult>( resultJson );
99+
result.SourceQuery = this;
100+
return result;
101+
}
91102
}
92103

93104
/// <summary>
@@ -99,6 +110,24 @@ public class QueryResult
99110
public int TotalCount { get; set; }
100111
public string NextCursor { get; set; }
101112
public List<QueryItem> Items { get; set; }
113+
114+
internal Query SourceQuery;
115+
116+
/// <summary>
117+
/// Returns true if there are more results to be fetched
118+
/// </summary>
119+
public bool HasMoreResults() => !string.IsNullOrEmpty( NextCursor );
120+
121+
/// <summary>
122+
/// Get the next set of results from the query. Returns null if none.
123+
/// </summary>
124+
public Task<QueryResult> GetNextResults( CancellationToken token = default )
125+
{
126+
if ( !HasMoreResults() ) return null;
127+
if ( SourceQuery is null ) return null;
128+
129+
return SourceQuery.RunEx( NextCursor, token );
130+
}
102131
}
103132

104133
/// <summary>

0 commit comments

Comments
 (0)