yy1717
2020-03-05 6b136af26a51b3d53051cd3e0e7d467ed2ab8a6b
lib/src/main/cpp/driver_test.cpp
@@ -878,40 +878,16 @@
//            }
//        }
        if (mapList[i].type == MAP_TYPE_CURVE) {
            const int step = 10;
            Polygon map;
            bool enter = false;
            Line startLine;
            Line carAxial;
            map.num = 1 + mapList[i].map.num / step + ((mapList[i].map.num % step == 0) ? 0 : 1);
            map.num += 1 + mapList[i].map2.num / step + ((mapList[i].map2.num % step == 0) ? 0 : 1);
            map.point = (PointF *) malloc(map.num * sizeof(PointF));
            MakeLine(&startLine, &mapList[i].map.point[0], &mapList[i].map2.point[0]);
            MakeLine(&carAxial, &car->carXY[car->axial[AXIAL_FRONT]], &car->carXY[car->axial[AXIAL_REAR]]);
            int n = 0, m = 0;
            while (n < mapList[i].map.num - 1) {
                map.point[m++] = mapList[i].map.point[n];
                n += step;
            if (IntersectionOf(startLine, carAxial) == GM_Intersection) {
                if (DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], startLine) > 0.1)
                    return i;
            }
            map.point[m++] = mapList[i].map.point[mapList[i].map.num - 1];
            n = mapList[i].map2.num - 1;
            while (n > 0) {
                map.point[m++] = mapList[i].map2.point[n];
                n -= step;
            }
            map.point[m++] = mapList[i].map2.point[0];
            if (IntersectionOf(car->carXY[ car->axial[AXIAL_FRONT] ], &map) == GM_Containment) {
                Line enterLine1;
                MakeLine(&enterLine1, &(mapList[i].map.point[0]), &(mapList[i].map2.point[0]));
                if (DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], enterLine1) > 0.1)
                    enter = true;
            }
            free(map.point);
            if (enter) return i;
        }
    }
    return -1;
@@ -979,6 +955,25 @@
            free(carBody.point);
            free(map.point);
    }
    if (mapList[index].type == MAP_TYPE_CURVE) {
        Line carAxial;
        Line scanLine;
        MakeLine(&carAxial, &car->carXY[car->axial[AXIAL_FRONT]], &car->carXY[car->axial[AXIAL_REAR]]);
        int startL = 0, startR = 0;
        while (startL < mapList[index].map.num || startR < mapList[index].map2.num) {
            MakeLine(&scanLine, &mapList[index].map.point[startL], &mapList[index].map.point[startR]);
            if (IntersectionOf(scanLine, carAxial) == GM_Intersection) {
                break;
            }
            if (startL < mapList[index].map.num)
                startL++;
            if (startR < mapList[index].map2.num)
                startR++;
        }
        ret = true;
    }
    return ret;
}