public static void Contacts(int particleIndex, int colliderIndex, float4 particlePosition, quaternion particleOrientation, float4 particleVelocity, float4 particleRadii, float deltaTime, ref NativeArray <BIHNode> bihNodes, ref NativeArray <Edge> edges, ref NativeArray <float2> vertices, EdgeMeshHeader header, ref BurstAffineTransform colliderToSolver, ref BurstColliderShape shape, NativeQueue <BurstContact> .ParallelWriter contacts) { float4 colliderSpacePosition = colliderToSolver.InverseTransformPoint(particlePosition); float4 colliderSpaceVel = colliderToSolver.InverseTransformVector(particleVelocity * deltaTime); BurstAabb particleBounds = new BurstAabb(colliderSpacePosition, colliderSpacePosition + colliderSpaceVel, particleRadii.x / math.cmax(colliderToSolver.scale)); colliderSpacePosition *= colliderToSolver.scale; BIHTraverse(particleIndex, colliderIndex, colliderSpacePosition, particleOrientation, colliderSpaceVel, particleRadii, ref particleBounds, 0, ref bihNodes, ref edges, ref vertices, ref header, ref colliderToSolver, ref shape, contacts); }
public static float4 GetRigidbodyVelocityAtPoint(int rigidbodyIndex, float4 point, NativeArray <BurstRigidbody> rigidbodies, NativeArray <float4> linearDeltas, NativeArray <float4> angularDeltas, BurstAffineTransform transform) { float4 linear = rigidbodies[rigidbodyIndex].velocity + linearDeltas[rigidbodyIndex]; float4 angular = rigidbodies[rigidbodyIndex].angularVelocity + angularDeltas[rigidbodyIndex]; float4 r = transform.TransformPoint(point) - rigidbodies[rigidbodyIndex].com; // Point is assumed to be expressed in solver space. Since rigidbodies are expressed in world space, we need to convert the // point to world space, and convert the resulting velocity back to solver space. return(transform.InverseTransformVector(linear + new float4(math.cross(angular.xyz, r.xyz), 0))); }
public static float4 GetRigidbodyVelocityAtPoint(BurstRigidbody rigidbody, float4 point, float4 linearDelta, float4 angularDelta, BurstAffineTransform transform) { // Point is assumed to be expressed in solver space. Since rigidbodies are expressed in world space, we need to convert the // point to world space, and convert the resulting velocity back to solver space. return(transform.InverseTransformVector(rigidbody.GetVelocityAtPoint(transform.TransformPoint(point), linearDelta, angularDelta))); }