//
// Generated by Brutal.Jolt.Generate; do not edit by hand.
#nullable enable
using Brutal.Interop;
using Brutal.Numerics;
namespace Brutal.JoltApi
{
///
///
/// C++:
/// Jolt/Physics/PhysicsScene.h:17
///
/// class PhysicsScene : public RefTarget<PhysicsScene>
///
///
///
///
/// Contains the creation settings of a set of bodies
///
///
[InteropHandle]
public readonly partial struct PhysicsScene : IDisposable
{
public static PhysicsScene Create() => Jolt.PInvoke.PhysicsScene_Create();
///
///
/// C++:
/// Jolt/Physics/PhysicsScene.h:23
///
/// void AddBody(const BodyCreationSettings &inBody)
///
///
///
///
/// Add a body to the scene
///
///
public void AddBody(BodyCreationSettings body) => Jolt.PInvoke.PhysicsScene_AddBody(this, body);
///
///
/// C++:
/// Jolt/Physics/PhysicsScene.h:32
///
/// void AddConstraint(const TwoBodyConstraintSettings *inConstraint, uint32 inBody1, uint32 inBody2)
///
///
///
///
/// Add a constraint to the scene
/// @param inConstraint Constraint settings
/// @param inBody1 Index in the bodies list of first body to attach constraint to
/// @param inBody2 Index in the bodies list of the second body to attach constraint to
///
///
public void AddConstraint(TwoBodyConstraintSettings constraint, uint body1, uint body2) => Jolt.PInvoke.PhysicsScene_AddConstraint(this, constraint, body1, body2);
///
///
/// C++:
/// Jolt/Physics/PhysicsScene.h:35
///
/// void AddSoftBody(const SoftBodyCreationSettings &inSoftBody)
///
///
///
///
/// Add a soft body to the scene
///
///
public void AddSoftBody(SoftBodyCreationSettings softBody) => Jolt.PInvoke.PhysicsScene_AddSoftBody(this, softBody);
///
///
/// C++:
/// Jolt/Physics/PhysicsScene.h:38
///
/// size_t GetNumBodies() const
///
///
///
///
/// Get number of bodies in this scene
///
///
public ElementCount GetNumBodies() => (ElementCount)Jolt.PInvoke.PhysicsScene_GetNumBodies(this);
///
///
/// C++:
/// Jolt/Physics/PhysicsScene.h:59
///
/// size_t GetNumConstraints() const
///
///
///
///
/// Get number of constraints in this scene
///
///
public ElementCount GetNumConstraints() => (ElementCount)Jolt.PInvoke.PhysicsScene_GetNumConstraints(this);
///
///
/// C++:
/// Jolt/Physics/PhysicsScene.h:66
///
/// size_t GetNumSoftBodies() const
///
///
///
///
/// Get number of bodies in this scene
///
///
public nuint GetNumSoftBodies() => Jolt.PInvoke.PhysicsScene_GetNumSoftBodies(this);
///
///
/// C++:
/// Jolt/Physics/PhysicsScene.h:73
///
/// bool CreateBodies(PhysicsSystem *inSystem) const
///
///
///
///
/// Instantiate all bodies, returns false if not all bodies could be created
///
///
public bool CreateBodies(PhysicsSystem system) => Jolt.PInvoke.PhysicsScene_CreateBodies(this, system);
///
///
/// C++:
/// Jolt/Physics/PhysicsScene.h:77
///
/// bool FixInvalidScales()
///
///
///
///
/// Go through all body creation settings and fix shapes that are scaled incorrectly (note this will change the scene a bit).
/// @return False when not all scales could be fixed.
///
///
public bool FixInvalidScales() => Jolt.PInvoke.PhysicsScene_FixInvalidScales(this);
///
///
/// C++:
/// Jolt/Physics/PhysicsScene.h:83
///
/// void SaveBinaryState(StreamOut &inStream, bool inSaveShapes, bool inSaveGroupFilter) const
///
///
///
///
/// Saves the state of this object in binary form to inStream.
/// @param inStream The stream to save the state to
/// @param inSaveShapes If the shapes should be saved as well (these could be shared between physics scenes, in which case the calling application may want to write custom code to restore them)
/// @param inSaveGroupFilter If the group filter should be saved as well (these could be shared)
///
///
public void SaveBinaryState(StreamOut stream, bool saveShapes, bool saveGroupFilter) => Jolt.PInvoke.PhysicsScene_SaveBinaryState(this, stream, saveShapes, saveGroupFilter);
///
///
/// C++:
/// Jolt/Physics/PhysicsScene.h:88
///
/// static PhysicsSceneResult sRestoreFromBinaryState(StreamIn &inStream)
///
///
///
///
/// Restore a saved scene from inStream
///
///
/// Throws InvalidOperationException with Jolt's error message when the operation fails.
///
///
public static PhysicsScene sRestoreFromBinaryState(StreamIn stream)
{
var _handle = Jolt.PInvoke.PhysicsScene_sRestoreFromBinaryState(stream);
if (_handle.IsNull()) throw new InvalidOperationException(Jolt.GetLastError());
return _handle;
}
///
///
/// C++:
/// Jolt/Physics/PhysicsScene.h:91
///
/// void FromPhysicsSystem(const PhysicsSystem *inSystem)
///
///
///
///
/// For debugging purposes: Construct a scene from the current state of the physics system
///
///
public void FromPhysicsSystem(PhysicsSystem system) => Jolt.PInvoke.PhysicsScene_FromPhysicsSystem(this, system);
public void AddRef() => Jolt.PInvoke.PhysicsScene_AddRef(this);
public void Release() => Jolt.PInvoke.PhysicsScene_Release(this);
public uint GetRefCount() => Jolt.PInvoke.PhysicsScene_GetRefCount(this);
public void Dispose()
{
if (IsNull()) return;
Release();
}
}
}