コード例 #1
0
    public void Execute(
        Transform RootTransform,
        float StepTime, Vector3 WindForce,
        int Relaxation, float SpringK,
        bool IsEnableFloorCollision, float FloorHeight,
        bool IsEnableColliderCollision)
    {
        WaitForComplete();

        var pRPoints     = (PointRead *)_PointsR.GetUnsafePtr();
        var pRWPoints    = (PointReadWrite *)_PointsRW.GetUnsafePtr();
        var pColliders   = (Collider *)_Colliders.GetUnsafePtr();
        var pColliderExs = (ColliderEx *)_ColliderExs.GetUnsafePtr();
        var pGrabbers    = (Grabber *)_Grabbers.GetUnsafePtr();
        var pGrabberExs  = (GrabberEx *)_GrabberExs.GetUnsafePtr();

        int ColliderCount = _RefColliders.Length;

        for (int i = 0; i < ColliderCount; ++i)
        {
            var pDst = pColliderExs + i;
            var Src  = _RefColliders[i];
            var SrcT = Src.RefTransform;
            if (Src.Height <= EPSILON)
            {
                pDst->Position = _RefColliders[i].RefTransform.position;
            }
            else
            {
                pDst->Direction = SrcT.rotation * Vector3.up * Src.Height;
                pDst->Position  = SrcT.position - (pDst->Direction * 0.5f);
            }
        }

        int GrabberCount = _RefGrabbers.Length;

        for (int i = 0; i < GrabberCount; ++i)
        {
            var pDst = pGrabberExs + i;

            pDst->IsEnabled = _RefGrabbers[i].IsEnabled ? 1 : 0;
            pDst->Position  = _RefGrabbers[i].RefTransform.position;
        }

        var PointUpdate = new JobPointUpdate();

        PointUpdate.RootMatrix       = RootTransform.localToWorldMatrix;
        PointUpdate.GrabberCount     = _RefGrabbers.Length;
        PointUpdate.pGrabbers        = pGrabbers;
        PointUpdate.pGrabberExs      = pGrabberExs;
        PointUpdate.pRPoints         = pRPoints;
        PointUpdate.pRWPoints        = pRWPoints;
        PointUpdate.WindForce        = WindForce;
        PointUpdate.StepTime_x2_Half = StepTime * StepTime * 0.5f;
        _hJob = PointUpdate.Schedule(_PointCount, 8);

        for (int i = 0; i < Relaxation; ++i)
        {
            foreach (var constraint in _Constraints)
            {
                var ConstraintUpdate = new JobConstraintUpdate();
                ConstraintUpdate.pConstraints  = (Constraint *)constraint.GetUnsafePtr();
                ConstraintUpdate.pRPoints      = pRPoints;
                ConstraintUpdate.pRWPoints     = pRWPoints;
                ConstraintUpdate.pColliders    = pColliders;
                ConstraintUpdate.pColliderExs  = pColliderExs;
                ConstraintUpdate.ColliderCount = ColliderCount;
                ConstraintUpdate.SpringK       = SpringK;
                _hJob = ConstraintUpdate.Schedule(constraint.Length, 8, _hJob);
            }
        }

        if (IsEnableFloorCollision || IsEnableColliderCollision)
        {
            var CollisionPoint = new JobCollisionPoint();
            CollisionPoint.pRWPoints        = pRWPoints;
            CollisionPoint.pColliders       = pColliders;
            CollisionPoint.pColliderExs     = pColliderExs;
            CollisionPoint.ColliderCount    = ColliderCount;
            CollisionPoint.FloorHeight      = FloorHeight;
            CollisionPoint.IsEnableFloor    = IsEnableFloorCollision;
            CollisionPoint.IsEnableCollider = IsEnableColliderCollision;
            _hJob = CollisionPoint.Schedule(_PointCount, 8, _hJob);
        }

        var PointToTransform = new JobPointToTransform();

        PointToTransform.pRPoints  = pRPoints;
        PointToTransform.pRWPoints = pRWPoints;
        _hJob = PointToTransform.Schedule(_TransformArray, _hJob);
    }
コード例 #2
0
    public void Execute(
        float StepTime, Vector3 WindForce,
        int Relaxation, float SpringK,
        bool IsEnableFloorCollision, float FloorHeight,
        bool IsEnableColliderCollision)
    {
        WaitForComplete();

        var pRPoints     = (PointRead *)_PointsR.GetUnsafePtr();
        var pRWPoints    = (PointReadWrite *)_PointsRW.GetUnsafePtr();
        var pColliders   = (Collider *)_Colliders.GetUnsafePtr();
        var pColliderExs = (ColliderEx *)_ColliderExs.GetUnsafePtr();
        var pGrabbers    = (Grabber *)_Grabbers.GetUnsafePtr();
        var pGrabberExs  = (GrabberEx *)_GrabberExs.GetUnsafePtr();

        var ColliderCount = _RefColliders.Length;

        for (int i = 0; i < ColliderCount; ++i)
        {
            var pDst = pColliderExs + i;
            var Src  = _RefColliders[i];
            var SrcT = Src.RefTransform;
            if (Src.Height <= 0.0f)
            {
                pDst->Position = _RefColliders[i].RefTransform.position;
            }
            else
            {
                pDst->Direction = SrcT.rotation * Vector3.up * Src.Height;
                pDst->Position  = SrcT.position - (pDst->Direction * 0.5f);
            }
        }

        var GrabberCount = _RefGrabbers.Length;

        for (int i = 0; i < GrabberCount; ++i)
        {
            var pDst = pGrabberExs + i;

            pDst->IsEnabled = _RefGrabbers[i].IsEnabled ? 1 : 0;
            pDst->Position  = _RefGrabbers[i].RefTransform.position;
        }

        var PointUpdate = new JobPointUpdate {
            GrabberCount     = _RefGrabbers.Length,
            pGrabbers        = pGrabbers,
            pGrabberExs      = pGrabberExs,
            pRPoints         = pRPoints,
            pRWPoints        = pRWPoints,
            WindForce        = WindForce,
            StepTime_x2_Half = StepTime * StepTime * 0.5f
        };

        _hJob = PointUpdate.Schedule(_PointCount, 8);

        for (int i = 0; i < Relaxation; ++i)
        {
            foreach (var constraint in _Constraints)
            {
                var ConstraintUpdate = new JobConstraintUpdate {
                    pConstraints  = (Constraint *)constraint.GetUnsafePtr(),
                    pRPoints      = pRPoints,
                    pRWPoints     = pRWPoints,
                    pColliders    = pColliders,
                    pColliderExs  = pColliderExs,
                    ColliderCount = ColliderCount,
                    SpringK       = SpringK
                };
                _hJob = ConstraintUpdate.Schedule(constraint.Length, 8, _hJob);
            }
        }

        if (IsEnableFloorCollision || IsEnableColliderCollision)
        {
            var CollisionPoint = new JobCollisionPoint {
                pRWPoints        = pRWPoints,
                pColliders       = pColliders,
                pColliderExs     = pColliderExs,
                ColliderCount    = ColliderCount,
                FloorHeight      = FloorHeight,
                IsEnableFloor    = IsEnableFloorCollision,
                IsEnableCollider = IsEnableColliderCollision
            };
            _hJob = CollisionPoint.Schedule(_PointCount, 8, _hJob);
        }

        var PointToTransform = new JobPointToTransform {
            pRPoints  = pRPoints,
            pRWPoints = pRWPoints
        };

        _hJob = PointToTransform.Schedule(_TransformArray, _hJob);
    }