Exemplo n.º 1
0
        //外周の周辺で判定
        public bool isHitOutline(LDPoint pt, float hitRange)
        {
            if (!isPreHit(pt, hitRange))
            {
                return(false);
            }
            LDIndexLineList outline = getIndexOutline();

            return(outline.isHit(toForm(), pt, hitRange));
        }
Exemplo n.º 2
0
        /*
         * public void serializeTest()
         * {
         *  const char* name = "lineList";
         *  QSharedPointer<LDIndexLineList> src(new LDIndexLineList);
         *  src->push_back(LDIndexLine(0, 1));
         *
         *  //シリアライズ
         *  SerializeHelper::writeBoostXml(name, src);
         *
         *  //デシリアライズ
         *  auto dst = SerializeHelper::readBoostXml<LDIndexLineList>(name);
         *
         *  QVERIFY(*(dst.data()) == *(src.data()));
         * }
         */

        public void hitTest()
        {
            LDIndexLineList lines  = new LDIndexLineList();
            LDIndexLine     line_1 = new LDIndexLine(0, 1);
            LDIndexLine     line_2 = new LDIndexLine(1, 2);
            LDIndexLine     line_3 = new LDIndexLine(2, 3);
            LDIndexLine     line_4 = new LDIndexLine(3, 0);

            lines.add(line_1);
            lines.add(line_2);
            lines.add(line_3);
            lines.add(line_4);

            LDPointList points = new LDPointList();

            points.Add(new LDPoint(0, 0));
            points.Add(new LDPoint(100, 0));
            points.Add(new LDPoint(100, 100));
            points.Add(new LDPoint(0, 100));


            TestUtil.COMPARE(lines.isHit(points, new LDPoint(0, 0), 1), true);    //頂点上
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(50, 0), 1), true);   //線上
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(50, 1), 3), true);   //線からちょっと離れたところ
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(50, 4), 3), false);  //線から範囲外に離れたところ
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(200, 0), 3), false); //線の延長戦上に離れたところ
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(200, 1), 3), false); //線の延長戦上に離れたところ
        }