添加物理系统

This commit is contained in:
段平 2023-07-31 13:55:44 +08:00
parent f8ae0447da
commit 44571198c1
40 changed files with 20852 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,427 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>MagicPhysX.Toolkit</name>
</assembly>
<members>
<member name="T:MagicPhysX.Toolkit.Colliders.BoxCollider">
<summary>
<para>A box-shaped primitive collider.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.BoxCollider.center">
<summary>
<para>The center of the box, measured in the object's local space.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.BoxCollider.size">
<summary>
<para>The size of the box, measured in the object's local space.</para>
</summary>
</member>
<member name="T:MagicPhysX.Toolkit.Colliders.CapsuleCollider">
<summary>
<para>A capsule-shaped primitive collider.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.CapsuleCollider.center">
<summary>
<para>The center of the capsule, measured in the object's local space.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.CapsuleCollider.radius">
<summary>
<para>The radius of the sphere, measured in the object's local space.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.CapsuleCollider.height">
<summary>
<para>The height of the capsule measured in the object's local space.</para>
</summary>
</member>
<member name="T:MagicPhysX.Toolkit.Colliders.Collider">
<summary>
<para>A base class of all colliders.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.PlaneCollider.center">
<summary>
<para>The center of the plane in the object's local space.</para>
</summary>
</member>
<member name="T:MagicPhysX.Toolkit.Colliders.SphereCollider">
<summary>
<para>A sphere-shaped primitive collider.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.SphereCollider.center">
<summary>
<para>The center of the sphere in the object's local space.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.SphereCollider.radius">
<summary>
<para>The radius of the sphere measured in the object's local space.</para>
</summary>
</member>
<member name="T:MagicPhysX.Toolkit.CollisionDetectionMode">
<summary>
<para>The collision detection mode constants used for Rigidbody.collisionDetectionMode.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.CollisionDetectionMode.Discrete">
<summary>
<para>Continuous collision detection is off for this Rigidbody.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.CollisionDetectionMode.Continuous">
<summary>
<para>Continuous collision detection is on for colliding with static mesh geometry.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.CollisionDetectionMode.ContinuousDynamic">
<summary>
<para>Continuous collision detection is on for colliding with static and dynamic geometry.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.CollisionDetectionMode.ContinuousSpeculative">
<summary>
<para>Speculative continuous collision detection is on for static and dynamic geometries</para>
</summary>
</member>
<member name="T:MagicPhysX.Toolkit.ForceMode">
<summary>
<para>Use ForceMode to specify how to apply a force using Rigidbody.AddForce or ArticulationBody.AddForce.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ForceMode.Force">
<summary>
<para>Add a continuous force to the rigidbody, using its mass.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ForceMode.Impulse">
<summary>
<para>Add an instant force impulse to the rigidbody, using its mass.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ForceMode.VelocityChange">
<summary>
<para>Add an instant velocity change to the rigidbody, ignoring its mass.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ForceMode.Acceleration">
<summary>
<para>Add a continuous acceleration to the rigidbody, ignoring its mass.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ContactPairsMode.DefaultContactPairs">
<summary>
Receive collision and trigger events from all contact pairs except kinematic-kinematic and kinematic-static pairs.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ContactPairsMode.EnableKinematicKinematicPairs">
<summary>
Receive collision and trigger events from kinematic-kinematic contact pairs.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ContactPairsMode.EnableKinematicStaticPairs">
<summary>
Receive collision and trigger events from kinematic-static contact pairs.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ContactPairsMode.EnableAllContactPairs">
<summary>
Receive collision and trigger events from all contact pairs.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.FrictionType.PatchFrictionType">
<summary>
A basic strong friction algorithm which typically leads to the most stable results at low solver iteration counts. This method uses only up to four scalar solver constraints per pair of touching objects.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.FrictionType.OneDirectionalFrictionType">
<summary>
A simplification of the Coulomb friction model, in which the friction for a given point of contact is applied in the alternating tangent directions of the contacts normal. This requires more solver iterations than patch friction but is not as accurate as the two-directional model. For Articulation bodies to work with this friction type, set the Solver Type to Temporal Gauss Seidel.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.FrictionType.TwoDirectionalFrictionType">
<summary>
Like the one-directional model, but applies friction in both tangent directions simultaneously. This requires more solver iterations but is more accurate. More expensive than patch friction for scenarios with many contact points because it is applied at every contact point. For Articulation bodies to work with this friction type, set the Solver Type to Temporal Gauss Seidel.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.SolverType.ProjectedGaussSeidel">
<summary>
The default PhysX solver.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.SolverType.TemporalGaussSeidel">
<summary>
This solver offers a better convergence and a better handling of high-mass ratios, minimizes energy introduced when correcting penetrations and improves the resistance of joints
to overstretch. It usually helps when you experience some erratic behavior during simulation with the default solver.
</summary>
</member>
<member name="T:MagicPhysX.Toolkit.Rigidbody">
<summary>
<para>Control of an object's position through physics simulation.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.velocity">
<summary>
<para>The velocity vector of the rigidbody. It represents the rate of change of Rigidbody position.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.angularVelocity">
<summary>
<para>The angular velocity vector of the rigidbody measured in radians per second.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.drag">
<summary>
<para>The drag of the object.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.angularDrag">
<summary>
<para>The angular drag of the object.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.mass">
<summary>
<para>The mass of the rigidbody.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.useGravity">
<summary>
<para>Controls whether gravity affects this rigidbody.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.maxDepenetrationVelocity">
<summary>
<para>Maximum velocity of a rigidbody when moving out of penetrating state.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.isKinematic">
<summary>
<para>Controls whether physics affects the rigidbody.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.freezeRotation">
<summary>
<para>Controls whether physics will change the rotation of the object.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.constraints">
<summary>
<para>Controls which degrees of freedom are allowed for the simulation of this Rigidbody.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.collisionDetectionMode">
<summary>
<para>The Rigidbody's collision detection mode.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.centerOfMass">
<summary>
<para>The center of mass relative to the transform's origin.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.worldCenterOfMass">
<summary>
<para>The center of mass of the rigidbody in world space (Read Only).</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.inertiaTensor">
<summary>
<para>The inertia tensor of this body, defined as a diagonal matrix in a reference frame positioned at this body's center of mass and rotated by Rigidbody.inertiaTensorRotation.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.detectCollisions">
<summary>
<para>Should collision detection be enabled? (By default always enabled).</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.position">
<summary>
<para>The position of the rigidbody.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.rotation">
<summary>
<para>The rotation of the Rigidbody.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.solverIterations">
<summary>
<para>The solverIterations determines how accurately Rigidbody joints and collision contacts are resolved. Overrides Physics.defaultSolverIterations. Must be positive.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.sleepThreshold">
<summary>
<para>The mass-normalized energy threshold, below which objects start going to sleep.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.maxAngularVelocity">
<summary>
<para>The maximimum angular velocity of the rigidbody measured in radians per second. (Default 7) range { 0, infinity }.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.solverVelocityIterations">
<summary>
<para>The solverVelocityIterations affects how how accurately Rigidbody joints and collision contacts are resolved. Overrides Physics.defaultSolverVelocityIterations. Must be positive.</para>
</summary>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.SetDensity(System.Single)">
<summary>
<para>Sets the mass based on the attached colliders assuming a constant density.</para>
</summary>
<param name="density"></param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.Sleep">
<summary>
<para>Forces a rigidbody to sleep at least one frame.</para>
</summary>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.IsSleeping">
<summary>
<para>Is the rigidbody sleeping?</para>
</summary>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.WakeUp">
<summary>
<para>Forces a rigidbody to wake up.</para>
</summary>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.ResetCenterOfMass">
<summary>
<para>Reset the center of mass of the rigidbody.</para>
</summary>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.ResetInertiaTensor">
<summary>
<para>Reset the inertia tensor value and rotation.</para>
</summary>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddForce(System.Numerics.Vector3,MagicPhysX.Toolkit.ForceMode)">
<summary>
<para>Adds a force to the Rigidbody.</para>
</summary>
<param name="force">Force vector in world coordinates.</param>
<param name="mode">Type of force to apply.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddForce(System.Numerics.Vector3)">
<summary>
<para>Adds a force to the Rigidbody.</para>
</summary>
<param name="force">Force vector in world coordinates.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddRelativeForce(System.Numerics.Vector3,MagicPhysX.Toolkit.ForceMode)">
<summary>
<para>Adds a force to the rigidbody relative to its coordinate system.</para>
</summary>
<param name="force">Force vector in local coordinates.</param>
<param name="mode">Type of force to apply.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddRelativeForce(System.Numerics.Vector3)">
<summary>
<para>Adds a force to the rigidbody relative to its coordinate system.</para>
</summary>
<param name="force">Force vector in local coordinates.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddTorque(System.Numerics.Vector3,MagicPhysX.Toolkit.ForceMode)">
<summary>
<para>Adds a torque to the rigidbody.</para>
</summary>
<param name="torque">Torque vector in world coordinates.</param>
<param name="mode">The type of torque to apply.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddTorque(System.Numerics.Vector3)">
<summary>
<para>Adds a torque to the rigidbody.</para>
</summary>
<param name="torque">Torque vector in world coordinates.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddRelativeTorque(System.Numerics.Vector3,MagicPhysX.Toolkit.ForceMode)">
<summary>
<para>Adds a torque to the rigidbody relative to its coordinate system.</para>
</summary>
<param name="torque">Torque vector in local coordinates.</param>
<param name="mode">Type of force to apply.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddRelativeTorque(System.Numerics.Vector3)">
<summary>
<para>Adds a torque to the rigidbody relative to its coordinate system.</para>
</summary>
<param name="torque">Torque vector in local coordinates.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddForceAtPosition(System.Numerics.Vector3,System.Numerics.Vector3,MagicPhysX.Toolkit.ForceMode)">
<summary>
<para>Applies force at position. As a result this will apply a torque and force on the object.</para>
</summary>
<param name="force">Force vector in world coordinates.</param>
<param name="position">Position in world coordinates.</param>
<param name="mode">Type of force to apply.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddForceAtPosition(System.Numerics.Vector3,System.Numerics.Vector3)">
<summary>
<para>Applies force at position. As a result this will apply a torque and force on the object.</para>
</summary>
<param name="force">Force vector in world coordinates.</param>
<param name="position">Position in world coordinates.</param>
</member>
<member name="T:MagicPhysX.Toolkit.RigidbodyConstraints">
<summary>
<para>Use these flags to constrain motion of Rigidbodies.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.None">
<summary>
<para>No constraints.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezePositionX">
<summary>
<para>Freeze motion along the X-axis.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezePositionY">
<summary>
<para>Freeze motion along the Y-axis.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezePositionZ">
<summary>
<para>Freeze motion along the Z-axis.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezePosition">
<summary>
<para>Freeze motion along all axes.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezeRotationX">
<summary>
<para>Freeze rotation along the X-axis.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezeRotationY">
<summary>
<para>Freeze rotation along the Y-axis.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezeRotationZ">
<summary>
<para>Freeze rotation along the Z-axis.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezeRotation">
<summary>
<para>Freeze rotation along all axes.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezeAll">
<summary>
<para>Freeze rotation and motion along all axes.</para>
</summary>
</member>
</members>
</doc>

BIN
CPhysxlib/MagicPhysX.dll Normal file

Binary file not shown.

8783
CPhysxlib/MagicPhysX.xml Normal file

File diff suppressed because it is too large Load Diff

50
PhysxBase.cs Normal file
View File

@ -0,0 +1,50 @@
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;
}
}

406
PhysxCommon.cs Normal file
View File

@ -0,0 +1,406 @@
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 System.Formats.Asn1.AsnWriter;
using static MagicPhysX.NativeMethods; // recommend to use C API.
namespace Physx
{
using PxI64 = Int64;
using PxU64 = UInt64;
using PxI32 = Int32;
using PxU32 = UInt32;
using PxI16 = Int16;
using PxU16 = UInt16;
using PxI8 = Byte;
using PxU8 = SByte;
//using PxF32 = System.Runtime.InteropServices.NFloat;
//using PxF64 =double;
//using PxReal = float;
public unsafe class PhysxCommon : IDisposable
{
public const float PxPi = 3.141592653589793f;
public const float PxHalfPi = 1.57079632679489661923f;
public const float PxTwoPi = 6.28318530717958647692f;
public const float PxInvPi = 0.31830988618379067154f;
public const float PxInvTwoPi = 0.15915494309189533577f;
public const float PxPiDivTwo = 1.57079632679489661923f;
public const float PxPiDivFour = 0.78539816339744830962f;
public static PxFoundation* _Foundation;
public static PxPhysics* _Physics;
public static PxMaterial* _Material;
public static PxDefaultCpuDispatcher* _Dispatcher;
public static PxPvd* _Pvd;
public static PxAllocatorCallback _Allocator;
public static PxDefaultErrorCallback _ErrorCallback;
bool disposedValue;
public PhysxCommon() { }
public static PhysxCommon Instance { get { return instance; } }
private static readonly PhysxCommon instance = new PhysxCommon();
//系统自动调用
~PhysxCommon()
{
Dispose(disposing: false);
}
private void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
// cleanup managed code
}
// cleanup unmanaged resource
disposedValue = true;
}
}
//手动调用
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
//physx_common::~physx_common() { Destory(); }
public bool InitPhyxsSDK()
{
// create physics
uint PX_PHYSICS_VERSION_MAJOR = 5;
uint PX_PHYSICS_VERSION_MINOR = 1;
uint PX_PHYSICS_VERSION_BUGFIX = 3;
uint versionNumber = (PX_PHYSICS_VERSION_MAJOR << 24) + (PX_PHYSICS_VERSION_MINOR << 16) + (PX_PHYSICS_VERSION_BUGFIX << 8);
if (_Foundation == null)
{
fixed (PxAllocatorCallback* allocPtr = &_Allocator)
{
fixed (PxDefaultErrorCallback* errorPtr = &_ErrorCallback)
{
//_Foundation = phys_PxCreateFoundation(versionNumber, allocPtr,
//errorPtr);
// _Foundation =
}
}
}
if (_Foundation == null)
{
//LogMgr::GetInstance()->Error(
// "physx_common::InitPhyxsSDK() error:px_foundation_ is null");
return false;
}
//if (!px_pvd_)
//{
// px_pvd_ = PxCreatePvd(*px_foundation_);
//}
//if (px_pvd_ == nullptr) return false;
if (_Physics == null)
{
var tolerancesScale = new PxTolerancesScale { length = 1, speed = 10 };
_Physics = phys_PxCreatePhysics(versionNumber, _Foundation, &tolerancesScale, true, _Pvd, null);
}
if (_Physics == null)
{
//LogMgr::GetInstance()->Error(
// "physx_common::InitPhyxsSDK() error: px_physics_ is null");
return false;
}
if (_Dispatcher == null)
//_Dispatcher = phys_PxDefaultCpuDispatcherCreate(0);
phys_PxDefaultCpuDispatcherCreate(1, null, PxDefaultCpuDispatcherWaitForWorkMode.WaitForWork, 0);
if (_Material == null)
// _Material = _Physics->createMaterial(0.0f, 0.0f, 0.0f);
_Material = PxPhysics_createMaterial_mut(_Physics, 0.0f, 0.0f, 0.0f);
return true;
}
//public void Destory()
//{
//if (instance_ != nullptr)
//{
// ReleaseSDK();
// delete instance_;
// instance_ = nullptr;
//}
//}
bool IsConnectedPvd()
{
// return _Pvd !=null ? _Pvd->PxPvd_isConnected_mut() : false;
return _Pvd != null ? PxPvd_isConnected_mut(_Pvd, true) : false;
}
public void ConnectPvdServer()
{
if (IsConnectedPvd() == false)
return;
if (_Pvd == null)
return;
//PxPvdTransport* transport = PxDefaultPvdSocketTransportCreate(g_pGameWorld->m_Settings.Ip_Pvd, 5425, 10);
byte hostip = 10;
PxPvdTransport* transport = phys_PxDefaultPvdSocketTransportCreate(&hostip, 5425, 10);
if (transport == null)
return;
bool is_connected = _Pvd->ConnectMut(transport, PxPvdInstrumentationFlags.All);
if (!is_connected)
{
//LogMgr::GetInstance()->Error(
// "physx_common::InitPhyxsSDK() error:pvd connect error.");
}
}
public void DisconnectPvdServer()
{
if (!IsConnectedPvd())
return;
if (_Pvd == null) return;
_Pvd->DisconnectMut();
}
public void ReleaseSDK()
{
if (_Physics != null)
{
_Dispatcher->ReleaseMut();
_Physics->ReleaseMut();
if (_Pvd != null)
{
PxPvdTransport* transport = _Pvd->GetTransportMut();
if (transport != null)
{
transport->ReleaseMut();
transport = null;
}
_Pvd->ReleaseMut();
_Pvd = null;
}
_Foundation->ReleaseMut();
_Dispatcher = null;
_Physics = null;
_Foundation = null;
}
}
public PxPhysics* GetPhysics() { return _Physics; }
public PxDefaultCpuDispatcher* GetCpuDispatcher() { return _Dispatcher; }
public PxMaterial* GetDefaultMaterial() { return _Material; }
/////////////////////////////////////////////////////////////////////////
// maths tools
/////////////////////////////////////////////////////////////////////////
void SetEulerYXZ(ref float yaw, ref float pitch,
ref float roll, ref PxQuat quat)
{
float halfYaw = yaw * 0.5f;
float halfPitch = pitch * 0.5f;
float halfRoll = roll * 0.5f;
float cosYaw = MathF.Cos(halfYaw);
float sinYaw = MathF.Sin(halfYaw);
float cosPitch = MathF.Cos(halfPitch);
float sinPitch = MathF.Sin(halfPitch);
float cosRoll = MathF.Cos(halfRoll);
float sinRoll = MathF.Sin(halfRoll);
//效率更高
quat.x = cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw;
quat.y = cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw;
quat.z = sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw;
quat.w = cosRoll * cosPitch * cosYaw + sinRoll * sinPitch * sinYaw;
}
//PxVec3 GetQuatRotate(KVector3D& dir, KVector3D& velocity)
//{
// PxQuat px_qua;
// SetEulerYXZ((float)((PI_F * dir.nY) / (1000 * 180)), (float)((PI_F * dir.nX) / (1000 * 180)),
// (float)((PI_F * dir.nZ) / (1000 * 180)), px_qua);
// return px_qua.rotate(PxVec3((float)velocity.nX, (float)velocity.nY,
// (float)velocity.nZ));
//}
PxVec3 QuatToEuler(PxQuat* q)
{
//PxVec3 dir = -PxMat33(q)[2];
PxVec3 dir = PxVec3_new_3(-q->Mat33New6().column2.x, -q->Mat33New6().column2.y, -q->Mat33New6().column2.z);
float r = MathF.Sqrt(dir.x * dir.x + dir.z * dir.z);
PxVec3 rot = PxVec3_new_3(0.0f, PxHalfPi, 0.0f);
if (r != 0.0f)
{
rot.x = -MathF.Atan(dir.y / r);
rot.y = MathF.Asin(dir.x / r);
if (dir.z > 0.0f) rot.y = PxPi - rot.y;
}
return rot;
}
PxVec3 GetEuler(PxVec3 forward)
{
PxVec3 euler = PxVec3_new_3(0, 0, 0);
PxVec3 tmp_forward = forward;
tmp_forward.y = 0;
//tmp_forward = BaseBehavior::SafeNormalized(tmp_forward);
// xz平面
//float angle = BaseBehavior::PxVec3Angle(PxVec3(0, 0, 1), tmp_forward) /
// PxPi * 180; // 角度值
//TODO:需要重写
float angle = 1.0f;
if (tmp_forward.x >= 0)
{
euler.y = angle;
}
else
{
euler.y = -angle;
}
// pitch角度
tmp_forward = forward;
tmp_forward.z = MathF.Sqrt(tmp_forward.x * tmp_forward.x + tmp_forward.z * tmp_forward.z);
tmp_forward.x = 0;
//tmp_forward = BaseBehavior::SafeNormalized(tmp_forward);
//angle = BaseBehavior::PxVec3Angle(PxVec3(0, 0, 1), tmp_forward) /
// PxPi * 180; // 角度值
if (tmp_forward.y >= 0)
{
euler.x = -angle;
}
else
{
euler.x = angle;
}
return euler;
}
float GetAngle(PxVec3* v0, PxVec3* v1)
{
float m = v0->MagnitudeSquared() * v1->MagnitudeSquared();
float s = MathF.Sqrt(m);
if (s < (float)(1e-20f))
{
return 0.0f;
}
s = 1.0f / s;
return MathF.Acos(v0->Dot(v1) * s);
}
void QuatToMatrix(float* quat, float* matrix)
{
float xx = quat[0] * quat[0];
float yy = quat[1] * quat[1];
float zz = quat[2] * quat[2];
float xy = quat[0] * quat[1];
float xz = quat[0] * quat[2];
float yz = quat[1] * quat[2];
float wx = quat[3] * quat[0];
float wy = quat[3] * quat[1];
float wz = quat[3] * quat[2];
matrix[0 * 4 + 0] = 1 - 2 * (yy + zz);
matrix[1 * 4 + 0] = 2 * (xy - wz);
matrix[2 * 4 + 0] = 2 * (xz + wy);
matrix[0 * 4 + 1] = 2 * (xy + wz);
matrix[1 * 4 + 1] = 1 - 2 * (xx + zz);
matrix[2 * 4 + 1] = 2 * (yz - wx);
matrix[0 * 4 + 2] = 2 * (xz - wy);
matrix[1 * 4 + 2] = 2 * (yz + wx);
matrix[2 * 4 + 2] = 1 - 2 * (xx + yy);
matrix[3 * 4 + 0] = matrix[3 * 4 + 1] = matrix[3 * 4 + 2] =
(float)0.0f;
matrix[0 * 4 + 3] = matrix[1 * 4 + 3] = matrix[2 * 4 + 3] =
(float)0.0f;
matrix[3 * 4 + 3] = (float)1.0f;
}
PxVec3 ToEulerAngle(float* quat)
{
// float matrix[16];
float* matrix = stackalloc float[16];
QuatToMatrix(quat, matrix);
float m11 = matrix[0], m12 = matrix[4], m13 = matrix[8];
float m21 = matrix[1], m22 = matrix[5], m23 = matrix[9];
float m31 = matrix[2], m32 = matrix[6], m33 = matrix[10];
if (m23 < -1)
{
m23 = -1;
}
if (m23 > 1)
{
m23 = 1;
}
float _x, _y, _z;
_x = MathF.Asin(-m23);
if (MathF.Abs(m23) < 0.99999)
{
_y = MathF.Atan2(m13, m33);
_z = MathF.Atan2(m21, m22);
}
else
{
_y = MathF.Atan2(-m31, m11);
_z = 0;
}
return PxVec3_new_3(_x, _y, _z);
}
public double Distance2(PxVec3* a, PxVec3* b)
{
PxVec3 tmp = a->Multiply(b);
return tmp.Dot(&tmp);
}
public double Distane(PxVec3* a, ref PxVec3* b)
{
return Math.Sqrt(Distance2(a, b));
}
}
}

281
PhysxTriger.cs Normal file
View File

@ -0,0 +1,281 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
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
{
//delegate void TRIGGER_FUNC(PxRigidActor* actorA, PxRigidActor* actorB, UInt32 c);
//先用原来的命名方式 后续修改为微软命名方式
public unsafe struct TriggerCallBack : IDisposable
{
public PxShape* shape_;
public TRIGGER_FUNC enter_func_;
public TRIGGER_FUNC leave_func_;
public UInt32 effectType_;
public UInt64 endStamp_;
//std::shared_ptr<std::string> shape_name_ptr_;
public IntPtr StrPtr;
public delegate void TRIGGER_FUNC(PxRigidActor* actorA, PxRigidActor* actorB, UInt32 c);
public TriggerCallBack()
{
}
public TriggerCallBack(PxShape* shape, UInt32 effectType, UInt64 effectValue, TRIGGER_FUNC enter, TRIGGER_FUNC leave)
{
shape_ = shape;
enter_func_ = enter;
leave_func_ = leave;
effectType_ = effectType;
}
public void Dispose()
{
//TODO 这里需要详细测试 如何释放内存 shape_ 是delete 指向的对象 还是只是 置为null
}
//TriggerCallBack(PxShape* shape, UInt32 effectType,
// UInt64 effectValue, TRIGGER_FUNC** enter,
// TRIGGER_FUNC** leave);
//~TriggerCallBack();
public void OnEnter(PxRigidActor* tActor, PxRigidActor* oActor, UInt32 args = 0)
{
if (enter_func_ != null)
{
enter_func_(tActor, oActor, args);
}
}
public void OnLeave(PxRigidActor* tActor, PxRigidActor* oActor, UInt32 args = 0)
{
if (leave_func_ != null)
{
leave_func_(tActor, oActor, args);
}
}
public void ResetCall()
{
enter_func_ = null;
leave_func_ = null;
}
public bool IsNeedDelete()
{
if (endStamp_ > 0)
{
//return endStamp_ < KG_GetTimeStamp();
}
return false;
}
//TODO;需要测试
public bool EuqalShapeName(IntPtr strPtr)
{
return strPtr.Equals(strPtr);
}
}
/////////////////////////////////////////////////////////////////////////
// TriggerManager
/////////////////////////////////////////////////////////////////////////
public unsafe struct TriggerManager
{
//TriggerManager();
//~TriggerManager();
// add a TriggerCallBackPtr
public void Push(TriggerCallBack* ptr)
{
callbacks_.Add((nint)ptr);
}
// remve a trigger by shape
public void Remove(PxShape* shape)
{
if (shape == null) return;
foreach (IntPtr it in callbacks_)
{
TriggerCallBack* call = (TriggerCallBack*)it.ToPointer();
if (call->EuqalShapeName((IntPtr)shape->GetName()))
{
callbacks_.Remove(it);
//TODO 需要测试
//因为it 原先是智能指针实现 这里需要释放智能指针指向的对象
//需要考虑引用次数?
//call->Dispose();
return;
}
}
}
// reset all triggers of a actor shapes
public void ResetTriggersInActor(PxRigidActor* actor)
{
if (actor == null) return;
UInt32 num = actor->GetNbShapes();
//NativeMethodsGroupingExtensions.GetNbShapes(ref *actor);
if (num < 1) return;
//std::vector<physx::PxShape*> shapes(nb);
//List<IntPtr> shapes = new List<IntPtr>((int)nb);
//
PxShape*[] shapes = new PxShape*[num];
//UInt32 nbShapes = actor->GetShapes(reinterpret_cast<physx::PxShape**>(&shapes[0]), nb);
fixed (PxShape** p = shapes)
{
UInt32 nbShapes = actor->GetShapes(p, num, 0);
if (num != nbShapes) return;
}
for (UInt32 i = 0; i < num; i++)
{
if (((int)shapes[i]->GetFlags() & (int)PxShapeFlag.TriggerShape) != 0)
{
//TriggerCallBackPtr ptr = FindTrigger(shapes[i]);
TriggerCallBack* TriggerCallBackPtr = FindTrigger(shapes[i]);
if (TriggerCallBackPtr != null)
{
TriggerCallBackPtr->ResetCall();
//(IntPtr)(TriggerCallBackPtr)->ResetCall();
}
}
}
}
// when release actor, remove all TriggerCallBackPtrs of the actor
public void OnReleaseActor(PxRigidActor* actor)
{
if (actor == null) return;
UInt32 num = actor->GetNbShapes();
if (num < 1) return;
//std::vector<physx::PxShape*> shapes(nb);
PxShape*[] shapes = new PxShape*[num];
fixed (PxShape** p = shapes)
{
UInt32 nbShapes = actor->GetShapes(p, num, 0);
if (num != nbShapes) return;
}
for (UInt32 i = 0; i < num; i++)
{
if (((int)shapes[i]->GetFlags() & (int)PxShapeFlag.TriggerShape) != 0)
{
Remove(shapes[i]);
}
}
}
// find a TriggerCallBackPtr by shape
public TriggerCallBack* FindTrigger(PxShape* shape)
{
if (shape == null) return null;
if (((int)shape->GetFlags() & (int)PxShapeFlag.TriggerShape) != 0)
{
}
else
{
//LogMgr::GetInstance()->Error(
// "TriggerManager::FindTrigger is not triggerrrrrrrrrrrrrrrrrrrr\n");
}
foreach (IntPtr it in callbacks_)
{
TriggerCallBack* call = (TriggerCallBack*)it.ToPointer();
if (call->EuqalShapeName((IntPtr)shape->GetName()))
{
return call;
}
}
return null;
}
public void Update()
{
if (callbacks_.Count() == 0) return;
foreach (IntPtr it in callbacks_)
{
TriggerCallBack* call = (TriggerCallBack*)it.ToPointer();
{
PxRigidActor* actor = call->shape_->GetActor();
if (actor != null)
{
UInt32 nb = actor->GetNbShapes();
if (nb <= 2)
{
//KHero* hero = static_cast<ClassType*>(actor->userData)->is < KHero *> ();
//if (hero)
//{
// auto cur = hero->attribute_manager_.GetCurrent();
// cur.hp = 0;
// hero->attribute_manager_.SetCurrent(cur);
// hero->Die(nullptr);
//}
}
}
callbacks_.Remove(it);
}
}
}
public void Clear()
{
callbacks_.Clear();
}
public void PrintV()
{
//LogMgr::GetInstance()->Error("TriggerManager::PrintV ============\n");
//for (auto it : callbacks_)
//{
// printf("shape=%p,", it->shape_);
// physx::PxSphereGeometry geo;
// if (it->shape_->getSphereGeometry(geo))
// {
// printf("radius=%f\n", geo.radius);
// }
//}
}
//禁止拷贝构造 c#中是否有这样语法
// private:
//TriggerManager& operator=(const TriggerManager&);
//TriggerCallBack* 是否存在指向内容的释放
//List<TriggerCallBack*> callbacks_;
List<IntPtr> callbacks_;
};
}

1300
PhysxWorld.cs Normal file

File diff suppressed because it is too large Load Diff

85
PhysxWorldManager.cs Normal file
View File

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MagicPhysX; // for enable Extension Methods.
using MagicPhysX.Toolkit;
using PhysX;
using static MagicPhysX.NativeMethods; // recommend to use C API.
namespace Physx
{
public unsafe struct PhysxWorldManager
{
public PhysxWorldManager()
{
//TODO 后续根据实际业务来写
//stamp_ = KG_GetTimeStamp();
stamp_ = 0;
physx_world_manager_.Clear();
}
//virtual ~PhysxWorldManager();
bool AddPhysxWorld(UInt64 area_id)
{
var itl = physx_world_manager_.ContainsKey(area_id);
if (itl = true)
return false;
var physx_world = new PhysxWorld();
// physx_world
if (physx_world.Equals(default(PhysxWorld)) == false)
return false;
physx_world.OnInit();
//physx_world_manager_.Add< area_id, physx_world});
physx_world_manager_.Add(area_id, (nint)(&physx_world));
return true;
}
PhysxWorld* GetPhysxWorld(UInt64 area_id)
{
nint ret = 0;
if (physx_world_manager_.TryGetValue(area_id, out ret))
{
return (PhysxWorld*)(ret.ToPointer());
}
return null;
}
bool AddActorToPhysxWorld(UInt64 area_id, PxRigidActor* obj)
{
var physx_world = GetPhysxWorld(area_id);
if (physx_world == null)
{
return false;
}
physx_world->AddActorToDaynamicWorld(obj);
return true;
}
bool PickUpActorFromPhysxWorld(UInt64 area_id, PxRigidActor* obj)
{
var physx_world = GetPhysxWorld(area_id);
if (physx_world == null)
{
return false;
}
physx_world->PickUpActor(obj);
return true;
}
//暂不实现 业务代码
//bool SwitchPhysxWorld(KScene* scene, UInt64 cur_area_id, UInt64 to_area_id, KHero* hero)
//{
//}
//bool UpdatePhysxWorld(KScene* secene)
//{
// return false;
//}
bool HasPhysxWorld()
{
return physx_world_manager_.Count() > 0;
}
Dictionary<UInt64, IntPtr> physx_world_manager_;
UInt64 stamp_;
}
}

View File

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Folder Include="CPhysxlib\" />
</ItemGroup>
<ItemGroup>
<Reference Include="MagicPhysX">
<HintPath>C:\Users\Win11\.nuget\packages\magicphysx\1.0.0\lib\net6.0\MagicPhysX.dll</HintPath>
</Reference>
<Reference Include="MagicPhysX.Toolkit">
<HintPath>CPhysxlib\MagicPhysX.Toolkit.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

Binary file not shown.

View File

@ -0,0 +1,427 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>MagicPhysX.Toolkit</name>
</assembly>
<members>
<member name="T:MagicPhysX.Toolkit.Colliders.BoxCollider">
<summary>
<para>A box-shaped primitive collider.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.BoxCollider.center">
<summary>
<para>The center of the box, measured in the object's local space.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.BoxCollider.size">
<summary>
<para>The size of the box, measured in the object's local space.</para>
</summary>
</member>
<member name="T:MagicPhysX.Toolkit.Colliders.CapsuleCollider">
<summary>
<para>A capsule-shaped primitive collider.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.CapsuleCollider.center">
<summary>
<para>The center of the capsule, measured in the object's local space.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.CapsuleCollider.radius">
<summary>
<para>The radius of the sphere, measured in the object's local space.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.CapsuleCollider.height">
<summary>
<para>The height of the capsule measured in the object's local space.</para>
</summary>
</member>
<member name="T:MagicPhysX.Toolkit.Colliders.Collider">
<summary>
<para>A base class of all colliders.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.PlaneCollider.center">
<summary>
<para>The center of the plane in the object's local space.</para>
</summary>
</member>
<member name="T:MagicPhysX.Toolkit.Colliders.SphereCollider">
<summary>
<para>A sphere-shaped primitive collider.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.SphereCollider.center">
<summary>
<para>The center of the sphere in the object's local space.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Colliders.SphereCollider.radius">
<summary>
<para>The radius of the sphere measured in the object's local space.</para>
</summary>
</member>
<member name="T:MagicPhysX.Toolkit.CollisionDetectionMode">
<summary>
<para>The collision detection mode constants used for Rigidbody.collisionDetectionMode.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.CollisionDetectionMode.Discrete">
<summary>
<para>Continuous collision detection is off for this Rigidbody.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.CollisionDetectionMode.Continuous">
<summary>
<para>Continuous collision detection is on for colliding with static mesh geometry.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.CollisionDetectionMode.ContinuousDynamic">
<summary>
<para>Continuous collision detection is on for colliding with static and dynamic geometry.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.CollisionDetectionMode.ContinuousSpeculative">
<summary>
<para>Speculative continuous collision detection is on for static and dynamic geometries</para>
</summary>
</member>
<member name="T:MagicPhysX.Toolkit.ForceMode">
<summary>
<para>Use ForceMode to specify how to apply a force using Rigidbody.AddForce or ArticulationBody.AddForce.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ForceMode.Force">
<summary>
<para>Add a continuous force to the rigidbody, using its mass.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ForceMode.Impulse">
<summary>
<para>Add an instant force impulse to the rigidbody, using its mass.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ForceMode.VelocityChange">
<summary>
<para>Add an instant velocity change to the rigidbody, ignoring its mass.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ForceMode.Acceleration">
<summary>
<para>Add a continuous acceleration to the rigidbody, ignoring its mass.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ContactPairsMode.DefaultContactPairs">
<summary>
Receive collision and trigger events from all contact pairs except kinematic-kinematic and kinematic-static pairs.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ContactPairsMode.EnableKinematicKinematicPairs">
<summary>
Receive collision and trigger events from kinematic-kinematic contact pairs.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ContactPairsMode.EnableKinematicStaticPairs">
<summary>
Receive collision and trigger events from kinematic-static contact pairs.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.ContactPairsMode.EnableAllContactPairs">
<summary>
Receive collision and trigger events from all contact pairs.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.FrictionType.PatchFrictionType">
<summary>
A basic strong friction algorithm which typically leads to the most stable results at low solver iteration counts. This method uses only up to four scalar solver constraints per pair of touching objects.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.FrictionType.OneDirectionalFrictionType">
<summary>
A simplification of the Coulomb friction model, in which the friction for a given point of contact is applied in the alternating tangent directions of the contacts normal. This requires more solver iterations than patch friction but is not as accurate as the two-directional model. For Articulation bodies to work with this friction type, set the Solver Type to Temporal Gauss Seidel.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.FrictionType.TwoDirectionalFrictionType">
<summary>
Like the one-directional model, but applies friction in both tangent directions simultaneously. This requires more solver iterations but is more accurate. More expensive than patch friction for scenarios with many contact points because it is applied at every contact point. For Articulation bodies to work with this friction type, set the Solver Type to Temporal Gauss Seidel.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.SolverType.ProjectedGaussSeidel">
<summary>
The default PhysX solver.
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.SolverType.TemporalGaussSeidel">
<summary>
This solver offers a better convergence and a better handling of high-mass ratios, minimizes energy introduced when correcting penetrations and improves the resistance of joints
to overstretch. It usually helps when you experience some erratic behavior during simulation with the default solver.
</summary>
</member>
<member name="T:MagicPhysX.Toolkit.Rigidbody">
<summary>
<para>Control of an object's position through physics simulation.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.velocity">
<summary>
<para>The velocity vector of the rigidbody. It represents the rate of change of Rigidbody position.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.angularVelocity">
<summary>
<para>The angular velocity vector of the rigidbody measured in radians per second.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.drag">
<summary>
<para>The drag of the object.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.angularDrag">
<summary>
<para>The angular drag of the object.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.mass">
<summary>
<para>The mass of the rigidbody.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.useGravity">
<summary>
<para>Controls whether gravity affects this rigidbody.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.maxDepenetrationVelocity">
<summary>
<para>Maximum velocity of a rigidbody when moving out of penetrating state.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.isKinematic">
<summary>
<para>Controls whether physics affects the rigidbody.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.freezeRotation">
<summary>
<para>Controls whether physics will change the rotation of the object.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.constraints">
<summary>
<para>Controls which degrees of freedom are allowed for the simulation of this Rigidbody.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.collisionDetectionMode">
<summary>
<para>The Rigidbody's collision detection mode.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.centerOfMass">
<summary>
<para>The center of mass relative to the transform's origin.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.worldCenterOfMass">
<summary>
<para>The center of mass of the rigidbody in world space (Read Only).</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.inertiaTensor">
<summary>
<para>The inertia tensor of this body, defined as a diagonal matrix in a reference frame positioned at this body's center of mass and rotated by Rigidbody.inertiaTensorRotation.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.detectCollisions">
<summary>
<para>Should collision detection be enabled? (By default always enabled).</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.position">
<summary>
<para>The position of the rigidbody.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.rotation">
<summary>
<para>The rotation of the Rigidbody.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.solverIterations">
<summary>
<para>The solverIterations determines how accurately Rigidbody joints and collision contacts are resolved. Overrides Physics.defaultSolverIterations. Must be positive.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.sleepThreshold">
<summary>
<para>The mass-normalized energy threshold, below which objects start going to sleep.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.maxAngularVelocity">
<summary>
<para>The maximimum angular velocity of the rigidbody measured in radians per second. (Default 7) range { 0, infinity }.</para>
</summary>
</member>
<member name="P:MagicPhysX.Toolkit.Rigidbody.solverVelocityIterations">
<summary>
<para>The solverVelocityIterations affects how how accurately Rigidbody joints and collision contacts are resolved. Overrides Physics.defaultSolverVelocityIterations. Must be positive.</para>
</summary>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.SetDensity(System.Single)">
<summary>
<para>Sets the mass based on the attached colliders assuming a constant density.</para>
</summary>
<param name="density"></param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.Sleep">
<summary>
<para>Forces a rigidbody to sleep at least one frame.</para>
</summary>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.IsSleeping">
<summary>
<para>Is the rigidbody sleeping?</para>
</summary>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.WakeUp">
<summary>
<para>Forces a rigidbody to wake up.</para>
</summary>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.ResetCenterOfMass">
<summary>
<para>Reset the center of mass of the rigidbody.</para>
</summary>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.ResetInertiaTensor">
<summary>
<para>Reset the inertia tensor value and rotation.</para>
</summary>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddForce(System.Numerics.Vector3,MagicPhysX.Toolkit.ForceMode)">
<summary>
<para>Adds a force to the Rigidbody.</para>
</summary>
<param name="force">Force vector in world coordinates.</param>
<param name="mode">Type of force to apply.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddForce(System.Numerics.Vector3)">
<summary>
<para>Adds a force to the Rigidbody.</para>
</summary>
<param name="force">Force vector in world coordinates.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddRelativeForce(System.Numerics.Vector3,MagicPhysX.Toolkit.ForceMode)">
<summary>
<para>Adds a force to the rigidbody relative to its coordinate system.</para>
</summary>
<param name="force">Force vector in local coordinates.</param>
<param name="mode">Type of force to apply.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddRelativeForce(System.Numerics.Vector3)">
<summary>
<para>Adds a force to the rigidbody relative to its coordinate system.</para>
</summary>
<param name="force">Force vector in local coordinates.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddTorque(System.Numerics.Vector3,MagicPhysX.Toolkit.ForceMode)">
<summary>
<para>Adds a torque to the rigidbody.</para>
</summary>
<param name="torque">Torque vector in world coordinates.</param>
<param name="mode">The type of torque to apply.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddTorque(System.Numerics.Vector3)">
<summary>
<para>Adds a torque to the rigidbody.</para>
</summary>
<param name="torque">Torque vector in world coordinates.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddRelativeTorque(System.Numerics.Vector3,MagicPhysX.Toolkit.ForceMode)">
<summary>
<para>Adds a torque to the rigidbody relative to its coordinate system.</para>
</summary>
<param name="torque">Torque vector in local coordinates.</param>
<param name="mode">Type of force to apply.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddRelativeTorque(System.Numerics.Vector3)">
<summary>
<para>Adds a torque to the rigidbody relative to its coordinate system.</para>
</summary>
<param name="torque">Torque vector in local coordinates.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddForceAtPosition(System.Numerics.Vector3,System.Numerics.Vector3,MagicPhysX.Toolkit.ForceMode)">
<summary>
<para>Applies force at position. As a result this will apply a torque and force on the object.</para>
</summary>
<param name="force">Force vector in world coordinates.</param>
<param name="position">Position in world coordinates.</param>
<param name="mode">Type of force to apply.</param>
</member>
<member name="M:MagicPhysX.Toolkit.Rigidbody.AddForceAtPosition(System.Numerics.Vector3,System.Numerics.Vector3)">
<summary>
<para>Applies force at position. As a result this will apply a torque and force on the object.</para>
</summary>
<param name="force">Force vector in world coordinates.</param>
<param name="position">Position in world coordinates.</param>
</member>
<member name="T:MagicPhysX.Toolkit.RigidbodyConstraints">
<summary>
<para>Use these flags to constrain motion of Rigidbodies.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.None">
<summary>
<para>No constraints.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezePositionX">
<summary>
<para>Freeze motion along the X-axis.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezePositionY">
<summary>
<para>Freeze motion along the Y-axis.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezePositionZ">
<summary>
<para>Freeze motion along the Z-axis.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezePosition">
<summary>
<para>Freeze motion along all axes.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezeRotationX">
<summary>
<para>Freeze rotation along the X-axis.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezeRotationY">
<summary>
<para>Freeze rotation along the Y-axis.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezeRotationZ">
<summary>
<para>Freeze rotation along the Z-axis.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezeRotation">
<summary>
<para>Freeze rotation along all axes.</para>
</summary>
</member>
<member name="F:MagicPhysX.Toolkit.RigidbodyConstraints.FreezeAll">
<summary>
<para>Freeze rotation and motion along all axes.</para>
</summary>
</member>
</members>
</doc>

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,53 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v7.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v7.0": {
"SpaceNation.Core.Physx/1.0.0": {
"dependencies": {
"MagicPhysX": "1.0.0.0",
"MagicPhysX.Toolkit": "1.0.0.0"
},
"runtime": {
"SpaceNation.Core.Physx.dll": {}
}
},
"MagicPhysX/1.0.0.0": {
"runtime": {
"MagicPhysX.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
},
"MagicPhysX.Toolkit/1.0.0.0": {
"runtime": {
"MagicPhysX.Toolkit.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
}
}
},
"libraries": {
"SpaceNation.Core.Physx/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"MagicPhysX/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"MagicPhysX.Toolkit/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")]

View File

@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("SpaceNation.Core.Physx")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("SpaceNation.Core.Physx")]
[assembly: System.Reflection.AssemblyTitleAttribute("SpaceNation.Core.Physx")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// 由 MSBuild WriteCodeFragment 类生成。

View File

@ -0,0 +1 @@
b4496c070bca034b2c458c69a1c2685480b9d851

View File

@ -0,0 +1,11 @@
is_global = true
build_property.TargetFramework = net7.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = SpaceNation.Core.Physx
build_property.ProjectDir = D:\work\SpaceNation.Core.Physx\

View File

@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

Binary file not shown.

View File

@ -0,0 +1 @@
698a744d8518333a9500ff6704cabf7fabbba51d

View File

@ -0,0 +1,22 @@
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.csproj.AssemblyReference.cache
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.GeneratedMSBuildEditorConfig.editorconfig
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.AssemblyInfoInputs.cache
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.AssemblyInfo.cs
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.csproj.CoreCompileInputs.cache
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.csproj.AssemblyReference.cache
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.GeneratedMSBuildEditorConfig.editorconfig
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.AssemblyInfoInputs.cache
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.AssemblyInfo.cs
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.csproj.CoreCompileInputs.cache
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\bin\Debug\net7.0\SpaceNation.Core.Physx.deps.json
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\bin\Debug\net7.0\SpaceNation.Core.Physx.dll
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\bin\Debug\net7.0\SpaceNation.Core.Physx.pdb
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\bin\Debug\net7.0\MagicPhysX.dll
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\bin\Debug\net7.0\MagicPhysX.Toolkit.dll
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\bin\Debug\net7.0\MagicPhysX.xml
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\bin\Debug\net7.0\MagicPhysX.Toolkit.xml
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.csproj.CopyComplete
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.dll
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\obj\Debug\net7.0\refint\SpaceNation.Core.Physx.dll
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\obj\Debug\net7.0\SpaceNation.Core.Physx.pdb
D:\project\SpaceNationProject\SpaceNationServerProjects\SpaceNation.Core\SpaceNation.Core.Physx\obj\Debug\net7.0\ref\SpaceNation.Core.Physx.dll

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,67 @@
{
"format": 1,
"restore": {
"D:\\work\\SpaceNation.Core.Physx\\SpaceNation.Core.Physx.csproj": {}
},
"projects": {
"D:\\work\\SpaceNation.Core.Physx\\SpaceNation.Core.Physx.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\work\\SpaceNation.Core.Physx\\SpaceNation.Core.Physx.csproj",
"projectName": "SpaceNation.Core.Physx",
"projectPath": "D:\\work\\SpaceNation.Core.Physx\\SpaceNation.Core.Physx.csproj",
"packagesPath": "C:\\Users\\Win11\\.nuget\\packages\\",
"outputPath": "D:\\work\\SpaceNation.Core.Physx\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Win11\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net7.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.302\\RuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Win11\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.6.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\Win11\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

73
obj/project.assets.json Normal file
View File

@ -0,0 +1,73 @@
{
"version": 3,
"targets": {
"net7.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net7.0": []
},
"packageFolders": {
"C:\\Users\\Win11\\.nuget\\packages\\": {},
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\work\\SpaceNation.Core.Physx\\SpaceNation.Core.Physx.csproj",
"projectName": "SpaceNation.Core.Physx",
"projectPath": "D:\\work\\SpaceNation.Core.Physx\\SpaceNation.Core.Physx.csproj",
"packagesPath": "C:\\Users\\Win11\\.nuget\\packages\\",
"outputPath": "D:\\work\\SpaceNation.Core.Physx\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Win11\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net7.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.302\\RuntimeIdentifierGraph.json"
}
}
}
}

8
obj/project.nuget.cache Normal file
View File

@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "C6JXgbbqNfUp0SIMenqceedWBdJDLasd3mdsii6YE6Tc+Vq7UNdeiaR8SJY533N+t3YBq/ebvAYDP2AYQZ7/Bw==",
"success": true,
"projectFilePath": "D:\\work\\SpaceNation.Core.Physx\\SpaceNation.Core.Physx.csproj",
"expectedPackageFiles": [],
"logs": []
}