Example #1
0
    // Collision check for the lower resolutions model
    public bool CheckRootCollisions(GridPlanningState state)
    {
        Vector3 start  = state.currentPosition - new Vector3(0, 10 * analyzer.GetHeight() / 2, 0);
        Vector3 end    = start + new Vector3(0, 10 * analyzer.GetHeight() / 2, 0);
        float   radius = analyzer.GetRadius();

        if (Physics.CheckCapsule(start, end, radius, layer))
        {
            //if (Physics.CheckSphere(state.currentPosition,radius,layer))
            return(true);
        }


        if (state.previousState != null)
        {
            int     samples = analyzer.samples;
            Vector3 mov     = state.actionMov;

            for (int i = 1; i < samples - 1; i += 2)     // we sample less in this domain the collision check
            {
                start = (state.previousState as GridPlanningState).currentPosition + i / (samples - 1) * mov;
                end   = start + new Vector3(0, analyzer.GetHeight() / 2, 0);

                if (Physics.CheckCapsule(start, end, radius, layer))
                {
                    //if (Physics.CheckSphere(state.previousState.currentPosition,radius,layer))
                    return(true);
                }
            }
        }


        return(false);
    }
Example #2
0
    // Collision check for the lower resolutions model
    public bool CheckRootCollisions(FootstepPlanningState state)
    {
        Vector3 start  = state.currentPosition - new Vector3(0, 10 * analyzer.GetHeight() / 2, 0);
        Vector3 end    = start + new Vector3(0, 10 * analyzer.GetHeight() / 2, 0);
        float   radius = analyzer.GetRadius();

        if (Physics.CheckCapsule(start, end, radius, layer))
        {
            //if (Physics.CheckSphere(state.currentPosition,radius,layer))
            return(true);
        }


        if (state.previousState != null)
        {
            int samples            = analyzer.samples;
            AnotatedAnimation anim = analyzer.GetAnotatedAnimation(state.actionName);

            for (int i = 1; i < samples - 1; i++)
            {
                start = state.previousState.currentPosition + anim.Root[i].position;
                end   = start + new Vector3(0, analyzer.GetHeight() / 2, 0);

                if (Physics.CheckCapsule(start, end, radius, layer))
                {
                    //if (Physics.CheckSphere(state.previousState.currentPosition,radius,layer))
                    return(true);
                }
            }
        }


        return(false);
    }