Skip to content

Commit 62d7fa2

Browse files
authored
Merge pull request #2131 from Eideren/bepu_integration
feat: Bepu physics integration
2 parents 66fa00c + 31e8969 commit 62d7fa2

252 files changed

Lines changed: 47292 additions & 3 deletions

File tree

Some content is hidden

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

build/Stride.sln

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGetResolver", "NuGetResol
330330
EndProject
331331
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.Core.Presentation", "..\sources\presentation\Stride.Core.Presentation\Stride.Core.Presentation.csproj", "{0C63EF8B-26F9-4511-9FC5-7431DE9657D6}"
332332
EndProject
333+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Stride.Bepu", "Stride.Bepu", "{DE048114-9AE4-467E-A879-188DC0D88A59}"
334+
EndProject
335+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.BepuPhysics", "..\sources\engine\Stride.BepuPhysics\Stride.BepuPhysics\Stride.BepuPhysics.csproj", "{3E424688-EC44-4DFB-9FC0-4BB1F0683651}"
336+
EndProject
337+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.BepuPhysics.Debug", "..\sources\engine\Stride.BepuPhysics\Stride.BepuPhysics.Debug\Stride.BepuPhysics.Debug.csproj", "{7715D094-DF59-4D91-BC9A-9A5118039ECB}"
338+
EndProject
333339
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.Importer.3D", "..\sources\tools\Stride.Importer.3D\Stride.Importer.3D.csproj", "{66EFFDE4-24F0-4E57-9618-0F5577E20A1E}"
334340
EndProject
341+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stride.BepuPhysics.Tests", "..\sources\engine\Stride.BepuPhysics\Stride.BepuPhysics.Tests\Stride.BepuPhysics.Tests.csproj", "{7B70C783-4085-4702-B3C6-6570FD85CB8F}"
342+
EndProject
335343
Global
336344
GlobalSection(SolutionConfigurationPlatforms) = preSolution
337345
Debug|Any CPU = Debug|Any CPU
@@ -1469,6 +1477,30 @@ Global
14691477
{0C63EF8B-26F9-4511-9FC5-7431DE9657D6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
14701478
{0C63EF8B-26F9-4511-9FC5-7431DE9657D6}.Release|Win32.ActiveCfg = Release|Any CPU
14711479
{0C63EF8B-26F9-4511-9FC5-7431DE9657D6}.Release|Win32.Build.0 = Release|Any CPU
1480+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1481+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651}.Debug|Any CPU.Build.0 = Debug|Any CPU
1482+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
1483+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
1484+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651}.Debug|Win32.ActiveCfg = Debug|Any CPU
1485+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651}.Debug|Win32.Build.0 = Debug|Any CPU
1486+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651}.Release|Any CPU.ActiveCfg = Release|Any CPU
1487+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651}.Release|Any CPU.Build.0 = Release|Any CPU
1488+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
1489+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651}.Release|Mixed Platforms.Build.0 = Release|Any CPU
1490+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651}.Release|Win32.ActiveCfg = Release|Any CPU
1491+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651}.Release|Win32.Build.0 = Release|Any CPU
1492+
{7715D094-DF59-4D91-BC9A-9A5118039ECB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1493+
{7715D094-DF59-4D91-BC9A-9A5118039ECB}.Debug|Any CPU.Build.0 = Debug|Any CPU
1494+
{7715D094-DF59-4D91-BC9A-9A5118039ECB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
1495+
{7715D094-DF59-4D91-BC9A-9A5118039ECB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
1496+
{7715D094-DF59-4D91-BC9A-9A5118039ECB}.Debug|Win32.ActiveCfg = Debug|Any CPU
1497+
{7715D094-DF59-4D91-BC9A-9A5118039ECB}.Debug|Win32.Build.0 = Debug|Any CPU
1498+
{7715D094-DF59-4D91-BC9A-9A5118039ECB}.Release|Any CPU.ActiveCfg = Release|Any CPU
1499+
{7715D094-DF59-4D91-BC9A-9A5118039ECB}.Release|Any CPU.Build.0 = Release|Any CPU
1500+
{7715D094-DF59-4D91-BC9A-9A5118039ECB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
1501+
{7715D094-DF59-4D91-BC9A-9A5118039ECB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
1502+
{7715D094-DF59-4D91-BC9A-9A5118039ECB}.Release|Win32.ActiveCfg = Release|Any CPU
1503+
{7715D094-DF59-4D91-BC9A-9A5118039ECB}.Release|Win32.Build.0 = Release|Any CPU
14721504
{66EFFDE4-24F0-4E57-9618-0F5577E20A1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14731505
{66EFFDE4-24F0-4E57-9618-0F5577E20A1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
14741506
{66EFFDE4-24F0-4E57-9618-0F5577E20A1E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -1481,6 +1513,14 @@ Global
14811513
{66EFFDE4-24F0-4E57-9618-0F5577E20A1E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
14821514
{66EFFDE4-24F0-4E57-9618-0F5577E20A1E}.Release|Win32.ActiveCfg = Release|Any CPU
14831515
{66EFFDE4-24F0-4E57-9618-0F5577E20A1E}.Release|Win32.Build.0 = Release|Any CPU
1516+
{7B70C783-4085-4702-B3C6-6570FD85CB8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1517+
{7B70C783-4085-4702-B3C6-6570FD85CB8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
1518+
{7B70C783-4085-4702-B3C6-6570FD85CB8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
1519+
{7B70C783-4085-4702-B3C6-6570FD85CB8F}.Release|Any CPU.Build.0 = Release|Any CPU
1520+
{7B70C783-4085-4702-B3C6-6570FD85CB8F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
1521+
{7B70C783-4085-4702-B3C6-6570FD85CB8F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
1522+
{7B70C783-4085-4702-B3C6-6570FD85CB8F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
1523+
{7B70C783-4085-4702-B3C6-6570FD85CB8F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
14841524
EndGlobalSection
14851525
GlobalSection(SolutionProperties) = preSolution
14861526
HideSolutionNode = FALSE
@@ -1606,7 +1646,11 @@ Global
16061646
{02FD0BDE-4293-414F-97E6-69FF71105420} = {158087CF-AF74-44E9-AA20-A6AEB1E398A9}
16071647
{158087CF-AF74-44E9-AA20-A6AEB1E398A9} = {1AE1AC60-5D2F-4CA7-AE20-888F44551185}
16081648
{0C63EF8B-26F9-4511-9FC5-7431DE9657D6} = {75A820AB-0F21-40F2-9448-5D7F495B97A0}
1649+
{DE048114-9AE4-467E-A879-188DC0D88A59} = {4C142567-C42B-40F5-B092-798882190209}
1650+
{3E424688-EC44-4DFB-9FC0-4BB1F0683651} = {DE048114-9AE4-467E-A879-188DC0D88A59}
1651+
{7715D094-DF59-4D91-BC9A-9A5118039ECB} = {DE048114-9AE4-467E-A879-188DC0D88A59}
16091652
{66EFFDE4-24F0-4E57-9618-0F5577E20A1E} = {6F473FA6-4F8B-4FBA-AE33-EE5AF997D50C}
1653+
{7B70C783-4085-4702-B3C6-6570FD85CB8F} = {DE048114-9AE4-467E-A879-188DC0D88A59}
16101654
EndGlobalSection
16111655
GlobalSection(ExtensibilityGlobals) = postSolution
16121656
SolutionGuid = {FF877973-604D-4EA7-B5F5-A129961F9EF2}

sources/Directory.Packages.props

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
</PropertyGroup>
55
<!-- Runtime dependencies -->
66
<ItemGroup>
7+
<PackageVersion Include="BepuPhysics" Version="2.5.0-beta.19" />
8+
<PackageVersion Include="BepuUtilities" Version="2.5.0-beta.19" />
9+
<PackageVersion Include="DotRecast.Core" Version="2024.1.1" />
10+
<PackageVersion Include="DotRecast.Detour" Version="2024.2.1" />
11+
<PackageVersion Include="DotRecast.Recast" Version="2024.2.1" />
12+
<PackageVersion Include="DotRecast.Recast.Toolset" Version="2024.3.1" />
713
<PackageVersion Include="FFmpeg.AutoGen" Version="3.4.0.2" />
814
<PackageVersion Include="K4os.Compression.LZ4.Legacy" Version="1.3.6" />
915
<PackageVersion Include="Microsoft.Management.Infrastructure" Version="3.0.0-preview.4" />
@@ -138,4 +144,4 @@
138144
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
139145
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" PrivateAssets="all" />
140146
</ItemGroup>
141-
</Project>
147+
</Project>

sources/assets/Stride.Core.Assets.CompilerApp/Stride.Core.Assets.CompilerApp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
</ItemGroup>
2525
<ItemGroup>
2626
<ProjectReference Include="..\..\engine\Stride.Assets.Models\Stride.Assets.Models.csproj" />
27+
<ProjectReference Include="..\..\engine\Stride.BepuPhysics\Stride.BepuPhysics\Stride.BepuPhysics.csproj" />
2728
<ProjectReference Include="..\..\engine\Stride.Particles\Stride.Particles.csproj" />
2829
<ProjectReference Include="..\..\engine\Stride.Physics\Stride.Physics.csproj" />
2930
<ProjectReference Include="..\..\engine\Stride.SpriteStudio.Offline\Stride.SpriteStudio.Offline.csproj" />

sources/editor/Stride.Assets.Presentation/Stride.Assets.Presentation.sdpkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ TemplateFolders:
1616
Files:
1717
- !file Templates/Assets/Animations/DefaultAnimation.sdtpl
1818
- !file Templates/Assets/Animations/DefaultSkeleton.sdtpl
19+
- !file Templates/Assets/Bepu/HullAsset.sdtpl
1920
- !file Templates/Assets/Fonts/OfflineRasterizedSpriteFont.sdtpl
2021
- !file Templates/Assets/Fonts/RuntimeRasterizedSpriteFont.sdtpl
2122
- !file Templates/Assets/Fonts/SignedDistanceFieldSpriteFont.sdtpl

sources/editor/Stride.Assets.Presentation/StrideDefaultAssetsPlugin.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ public override void InitializeSession(SessionViewModel session)
224224
session.SuggestedPackages.Add(new PackageName(typeof(Stride.Particles.Components.ParticleSystemComponent).Assembly.GetName().Name, new PackageVersion(StrideVersion.NuGetVersion)));
225225
session.SuggestedPackages.Add(new PackageName(typeof(Stride.Navigation.NavigationComponent).Assembly.GetName().Name, new PackageVersion(StrideVersion.NuGetVersion)));
226226
session.SuggestedPackages.Add(new PackageName(typeof(Stride.Physics.StaticColliderComponent).Assembly.GetName().Name, new PackageVersion(StrideVersion.NuGetVersion)));
227+
session.SuggestedPackages.Add(new PackageName(typeof(Stride.BepuPhysics.CollidableComponent).Assembly.GetName().Name, new PackageVersion(StrideVersion.NuGetVersion)));
227228
session.SuggestedPackages.Add(new PackageName(typeof(Stride.Video.VideoComponent).Assembly.GetName().Name, new PackageVersion(StrideVersion.NuGetVersion)));
228229
session.SuggestedPackages.Add(new PackageName(typeof(Stride.Voxels.Module).Assembly.GetName().Name, new PackageVersion(StrideVersion.NuGetVersion)));
229230
session.SuggestedPackages.Add(new PackageName(typeof(Stride.SpriteStudio.Runtime.SpriteStudioNodeLinkComponent).Assembly.GetName().Name, new PackageVersion(StrideVersion.NuGetVersion)));
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
!TemplateAssetFactory
2+
Id: FDBCB65A-9866-4EF2-9A03-AF21F943BDFD
3+
AssetTypeName: HullAsset
4+
Name: Convex hull
5+
Scope: Asset
6+
Description: A convex hull-shaped collider for use with bepu physics, computed from a 3D model
7+
Group: Physics
8+
Icon: ..\.sdtpl\ColliderHull.png
9+
DefaultOutputName: ColliderHull
10+
FactoryTypeName: HullAssetFactory
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
2+
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
3+
using System;
4+
using System.Threading.Tasks;
5+
using Stride.Assets.BepuPhysics;
6+
using Stride.Assets.Models;
7+
using Stride.Core;
8+
using Stride.Core.Assets;
9+
using Stride.Core.Assets.Editor.Services;
10+
using Stride.Core.Assets.Templates;
11+
using Stride.Core.IO;
12+
using Stride.Rendering;
13+
14+
namespace Stride.Assets.Presentation.Templates
15+
{
16+
public class HullAssetFactoryTemplateGenerator : AssetFactoryTemplateGenerator
17+
{
18+
private static readonly PropertyKey<Model> ModelKey = new PropertyKey<Model>("Model", typeof(HullAssetFactoryTemplateGenerator));
19+
public new static readonly HullAssetFactoryTemplateGenerator Default = new HullAssetFactoryTemplateGenerator();
20+
21+
public static readonly Guid TemplateId = new Guid("FDBCB65A-9866-4EF2-9A03-AF21F943BDFD");
22+
23+
public override bool IsSupportingTemplate(TemplateDescription templateDescription)
24+
{
25+
if (templateDescription == null) throw new ArgumentNullException(nameof(templateDescription));
26+
return templateDescription.Id == TemplateId;
27+
}
28+
29+
protected override async Task<bool> PrepareAssetCreation(AssetTemplateGeneratorParameters parameters)
30+
{
31+
if (!await base.PrepareAssetCreation(parameters))
32+
return false;
33+
34+
var modelViewModel = await BrowseForAsset(parameters.Package, new[] { typeof(IModelAsset) }, new UFile(parameters.Name).GetFullDirectory(), "Select the model to use to generate a convex hull - _cancel to leave the model empty_");
35+
var model = ContentReferenceHelper.CreateReference<Model>(modelViewModel);
36+
parameters.SetTag(ModelKey, model);
37+
return true;
38+
}
39+
40+
protected override void PostAssetCreation(AssetTemplateGeneratorParameters parameters, AssetItem assetItem)
41+
{
42+
base.PostAssetCreation(parameters, assetItem);
43+
var model = parameters.GetTag(ModelKey);
44+
((HullAsset)assetItem.Asset).Model = model;
45+
}
46+
}
47+
}

sources/editor/Stride.Assets.Presentation/Templates/StrideTemplates.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static void Register()
1919
TemplateManager.Register(HeightmapFactoryTemplateGenerator.Default);
2020
TemplateManager.Register(ColliderShapeHullFactoryTemplateGenerator.Default);
2121
TemplateManager.Register(ColliderShapeStaticMeshFactoryTemplateGenerator.Default);
22+
TemplateManager.Register(HullAssetFactoryTemplateGenerator.Default);
2223
TemplateManager.Register(ProceduralModelFactoryTemplateGenerator.Default);
2324
TemplateManager.Register(SkyboxFactoryTemplateGenerator.Default);
2425
TemplateManager.Register(GraphicsCompositorTemplateGenerator.Default);

sources/editor/Stride.Editor/Stride.Editor.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
</ItemGroup>
2727
<ItemGroup>
2828
<ProjectReference Include="..\..\assets\Stride.Core.Assets.CompilerApp\Stride.Core.Assets.CompilerApp.csproj" />
29+
<ProjectReference Include="..\..\engine\Stride.BepuPhysics\Stride.BepuPhysics\Stride.BepuPhysics.csproj" />
2930
<ProjectReference Include="..\..\engine\Stride.Voxels\Stride.Voxels.csproj" />
3031
<ProjectReference Include="..\..\presentation\Stride.Core.Presentation.Quantum\Stride.Core.Presentation.Quantum.csproj" />
3132
<ProjectReference Include="..\..\engine\Stride.Assets\Stride.Assets.csproj" />

sources/editor/Stride.GameStudio/Debugging/AssemblyRecompiler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ public async Task<UpdateResult> Recompile(Project gameProject, LoggerResult logg
197197
{
198198
assemblyProcessorApp.ReferencesToAdd.Add(referencePath.EvaluatedInclude);
199199
}
200+
else if (referencePath.EvaluatedInclude.EndsWith("Stride.BepuPhysics.dll")) //todo hard-coded! needs to go when plug in system is in
201+
{
202+
assemblyProcessorApp.ReferencesToAdd.Add(referencePath.EvaluatedInclude);
203+
}
200204
else if (referencePath.EvaluatedInclude.EndsWith("Stride.Particles.dll")) //todo hard-coded! needs to go when plug in system is in
201205
{
202206
assemblyProcessorApp.ReferencesToAdd.Add(referencePath.EvaluatedInclude);

0 commit comments

Comments
 (0)