// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. using System; using Flax.Build; using Flax.Build.NativeCpp; /// /// Physics module. /// public class Physics : EngineModule { /// /// Enables using collisions cooking. /// public static bool WithCooking = true; /// /// Enables using vehicles simulation. /// public static bool WithVehicle = true; /// /// Enables using cloth simulation. /// public static bool WithCloth = true; /// /// Enables using PhysX library. Can be overriden by SetupPhysicsBackend. /// public static bool WithPhysX = true; /// /// Physics system extension event to override for custom physics backend plugin. /// public static Action SetupPhysicsBackend = SetupPhysicsBackendPhysX; /// public override void Setup(BuildOptions options) { base.Setup(options); SetupPhysicsBackend(this, options); if (WithCooking) { options.PublicDefinitions.Add("COMPILE_WITH_PHYSICS_COOKING"); } } private static void SetupPhysicsBackendPhysX(Physics physics, BuildOptions options) { if (WithPhysX) { options.PrivateDependencies.Add("PhysX"); if (WithCloth && options.Platform.Target != TargetPlatform.PS4) // TODO: build nvcloth for ps4 with vs2017 options.PrivateDependencies.Add("NvCloth"); } else { options.PrivateDefinitions.Add("COMPILE_WITH_EMPTY_PHYSICS"); } } }