Physx/PhysxBase.cs

51 lines
1.3 KiB
C#
Raw Permalink Normal View History

2023-07-31 13:55:44 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using MagicPhysX; // for enable Extension Methods.
using MagicPhysX.Toolkit;
using static MagicPhysX.NativeMethods; // recommend to use C API.
namespace Physx
{
public unsafe struct PhysxBase : IDisposable
{
public PhysxBase() { }
public void Dispose()
{
foreach (var item in _physicsActors)
{
((PxRigidActor*)item.ToPointer())->ReleaseMut();
}
_physicsActors.Clear();
}
public void AddPhysicsActors(PxRigidActor* actor)
{
_physicsActors.Add((nint)(actor));
//_physicsActors.Add(actor);
}
public void RemoveActor(PxRigidActor* actor)
{
_physicsActors.Remove((nint)actor);
}
public void PickUpActorBase(PxRigidActor* actor)
{
_physicsActors.Remove((nint)actor);
}
public void RemoveAllActor()
{
foreach (var item in _physicsActors)
{
((PxRigidActor*)item.ToPointer())->ReleaseMut();
}
_physicsActors.Clear();
}
public List<nint> _physicsActors;
}
}